Merge branch 'feature/hub-firewall-rule-table' into unify/skills-20261114

This commit is contained in:
Kevin Veen-Birkenbach committed 2026-11-14 22:00:10 +00:00
commit 1ab9cf02de
9 files changed
+377 -85

No files matched your search

+75 -6
View File
@@ -10,6 +10,7 @@ from .errors import Conflict, Missing, ToolError
from .fields import decode, expect, visible
from .ledger import Ledger
from .records import read_json, stamp
from .requesting import RECENT_DAYS, matched
from .rules import EVERY_AGENT, RULE_KINDS
from .signed import signing
@@ -25,21 +26,86 @@ HASH = re.compile(r"[0-9a-f]{64}")
PERMISSION_LISTS = ("allow", "ask", "deny")
SET_KEYS = ("kind", "tool", "pattern", "scope")
CHAINED = "chains, pipes, redirects or substitutions"
COUNT_ID = "0" * 16
UNSEEN = {"hits": None, "never": ""}
def settings_request(raw: object) -> bool:
return isinstance(raw, list) and bool(raw) and all(isinstance(entry, dict) and entry.get("kind") == "settings" for entry in raw)
def tool_and_spec(entry: str) -> tuple[str, str]:
"""Returns:
The tool of a permission rule such as Bash(git push:*) and its
specifier, git push:*; "" without specifier.
"""
found = RULE_TEXT.fullmatch(entry)
if found is None:
return entry.strip(), ""
return found.group("tool").strip(), (found.group("spec") or "").strip()
def tool_and_prefix(entry: str) -> tuple[str, str]:
"""Returns:
The tool of a permission rule such as Bash(git push:*) and the first
word of its specifier, for Bash the command; "" without specifier.
"""
found = RULE_TEXT.fullmatch(entry)
if found is None:
return entry.strip(), ""
return found.group("tool").strip(), WORD.split((found.group("spec") or "").strip(), maxsplit=1)[0]
tool, spec = tool_and_spec(entry)
return tool, WORD.split(spec, maxsplit=1)[0]
def entry_rule(entry: str) -> dict:
"""Returns:
A permissions.ask entry as the fields of an ask rule for every agent
in every directory: its tool, and its specifier as pattern, where a
trailing :* or no specifier matches any rest.
"""
tool, spec = tool_and_spec(entry)
pattern = f"{spec.removesuffix(':*')}*" if spec.endswith(":*") or not spec else spec
return {"kind": "ask", "tool": tool, "pattern": pattern, "scope": "*"}
def hits(rule: dict, asks: list[dict], now: float) -> dict:
"""Args:
rule: kind ask, tool, pattern and scope of a rule, with agents when
it applies to one agent or group only.
asks: the asks of the last RECENT_DAYS as recent_subjects() lists
them.
now: the current time in epoch seconds.
Returns:
{"hits": how many of the asks the rule matches, on or off, expired or
not, "never": ""}; hits None and never the warning when the pattern
itself names a command the matcher never grants.
"""
pattern = rule["pattern"]
never = [*signing.warnings(pattern), *([CHAINED] if signing.CHAINED.search(pattern) else [])]
if never:
return {"hits": None, "never": never[0]}
return {"hits": matched({**rule, "id": COUNT_ID, "expires": now + RECENT_DAYS * 86400}, asks, now), "never": ""}
def counted(groups: list[dict], asks: list[dict], now: float) -> list[dict]:
"""Returns:
groups with each entry's specifier and hits: counted for an ask
entry, UNSEEN for an allow or deny entry.
"""
def shown(entry: dict) -> dict:
found = hits(entry_rule(entry["entry"]), asks, now) if entry["list"] == "ask" else UNSEEN
return {**entry, "spec": tool_and_spec(entry["entry"])[1], **found}
return [{**group, "entries": [shown(entry) for entry in group["entries"]]} for group in groups]
def stored_hits(rule: dict, asks: list[dict], now: float) -> dict:
"""Returns:
hits() of a stored ask rule for the agents it is signed for, UNSEEN
for a review or decision rule.
"""
if rule["kind"] != "ask":
return UNSEEN
fields = {key: rule[key] for key in ("kind", "tool", "pattern", "scope")}
return hits({**fields, "agents": rule["agents"]} if "agents" in rule else fields, asks, now)
def grouped(permissions: object) -> list[dict]:
@@ -130,8 +196,11 @@ class Firewall:
def firewall(self) -> dict:
files, meta = self.settings_files()
listed = [{key: entry[key] for key in ("path", "exists", "sha256", "error")} | {"groups": grouped(entry["settings"].get("permissions")), "sandbox": sandbox_entries(entry["settings"].get("sandbox"), "sandbox")} for entry in files]
return {**meta, "files": listed, "lists": list(signing.SETTINGS_LISTS), "patterns": deny_patterns(), "groups": self.groups.listed(), "sets": self.rule_sets.listed()}
now = time.time()
asks = self.recent_subjects("ask", now)
listed = [{key: entry[key] for key in ("path", "exists", "sha256", "error")} | {"groups": counted(grouped(entry["settings"].get("permissions")), asks, now), "sandbox": sandbox_entries(entry["settings"].get("sandbox"), "sandbox")} for entry in files]
rules = {rule["id"]: stored_hits(rule, asks, now) for rule in self.rules.listed()}
return {**meta, "files": listed, "lists": list(signing.SETTINGS_LISTS), "patterns": deny_patterns(), "groups": self.groups.listed(), "sets": self.rule_sets.listed(), "days": RECENT_DAYS, "rules": rules}
def settings_changes(self, raw: object) -> list[dict]:
"""Args:
+29 -7
View File
@@ -26,6 +26,24 @@ def created_of(record: dict) -> float:
return record["created_ts"] if "created_ts" in record else iso_epoch(record["created"]) or 0.0
def matched(record: dict, subjects: list[dict], now: float) -> int:
"""Args:
record: id, kind, tool, pattern, scope and expires of a rule, with
agents when it applies to one agent or group only.
subjects: what recent_subjects() lists for the rule's kind.
now: the current time in epoch seconds.
Returns:
How many subjects the rule would have approved.
"""
kind_name = record["kind"]
payload = signing.rule_payload(record["id"], [kind_name], record["tool"], record["pattern"], record["scope"], int(record["expires"]))
if "agents" in record:
payload = signing.targeted(payload, record["agents"])
rule = {**{key: record[key] for key in RULE_FIELDS}, "enabled": True, "proof": {"payload": payload, "assertion": None}}
return sum(rule_matches(rule, kind_name, subject, now) for subject in subjects)
class Requesting:
def open_requests(self, now: float) -> list[dict]:
return [record for record in self.rule_requests.pending() if request_status(record, now) == "pending"]
@@ -60,19 +78,23 @@ class Requesting:
raise ToolError(f"no rule request {request_id}")
return request_state(record, time.time())
def recent_subjects(self, kind_name: str, now: float) -> list[dict]:
"""Returns:
The asks, reviews or decisions of the last RECENT_DAYS as a rule
of that kind is matched against them.
"""
ledger = {"ask": self.asks, "review": self.reviews, "decision": self.decisions}[kind_name]
since = now - RECENT_DAYS * 86400
return [subject_of(kind_name, entry, self.deciders(kind_name, entry)) for entry in ledger.listed() if created_of(entry) >= since]
def dry_run(self, record: dict, now: float) -> dict:
"""Returns:
How many of the asks, reviews or decisions of the last
RECENT_DAYS the requested rule would have approved, matched by
the same code that applies a stored rule.
"""
kind_name = record["kind"]
payload = signing.rule_payload(record["id"], [kind_name], record["tool"], record["pattern"], record["scope"], int(record["expires"]))
rule = {**{key: record[key] for key in RULE_FIELDS}, "enabled": True, "proof": {"payload": payload, "assertion": None}}
ledger = {"ask": self.asks, "review": self.reviews, "decision": self.decisions}[kind_name]
since = now - RECENT_DAYS * 86400
subjects = [subject_of(kind_name, entry, self.deciders(kind_name, entry)) for entry in ledger.listed() if created_of(entry) >= since]
return {"matched": sum(rule_matches(rule, kind_name, subject, now) for subject in subjects), "total": len(subjects), "days": RECENT_DAYS}
subjects = self.recent_subjects(record["kind"], now)
return {"matched": matched(record, subjects, now), "total": len(subjects), "days": RECENT_DAYS}
def request_items(self, base: dict, now: float, claims: list[dict]) -> list[dict]:
items = []
+126 -20
View File
@@ -1,11 +1,20 @@
const FIREWALL_LISTS = {"permissions.allow": "Allow", "permissions.ask": "Ask", "permissions.deny": "Deny", "sandbox.filesystem.allowWrite": "Sandbox: write", "sandbox.filesystem.denyRead": "Sandbox: no read", "sandbox.network.allowedDomains": "Sandbox: domain"};
const LIST_TONES = {allow: "ok", ask: "warn", deny: "bad"};
const ROW_FILTERS = [["allow", "Allow"], ["ask", "Ask"], ["deny", "Deny"], ["sandbox", "Sandbox"], ["signed", "Signed"]];
const ACTION_ORDER = ["deny", "ask", "allow", "sandbox", "signed"];
const ENTRY_HINTS = {
allow: "Claude Code runs a matching call without asking, so it never reaches the ask ledger.",
ask: "Claude Code asks before a matching call; the ask reaches the Agent Orchestrator.",
deny: "Claude Code refuses a matching call, so it never reaches the ask ledger.",
sandbox: "Bounds what a sandboxed command may write, read or reach.",
};
const HUB_SOURCE = "hub";
const SETTINGS_RESULTS = {done: ["written", "ok"], refused: ["refused", "bad"], failed: ["failed", "bad"]};
const EVERY_AGENT = "*";
const TARGET_GONE = "gone";
const TARGET_PICK = "";
const SESSION_KEY = /^(?!-)[A-Za-z0-9_-]{1,128}$/;
const firewall = {data: null, busy: false, staged: {}, dom: null, targets: new Set(), picks: {}};
const firewall = {data: null, busy: false, staged: {}, dom: null, targets: new Set(), picks: {}, shown: new Set(ROW_FILTERS.map(([id]) => id)), open: new Set()};
const knownAgents = () => Object.keys(people()).filter((key) => key !== HUMAN && SESSION_KEY.test(key)).sort();
const firewallGroups = () => (firewall.data ? firewall.data.groups : []);
@@ -270,24 +279,121 @@
drawFirewall();
}
function entryRow(path, list, entry) {
const last = list.split(".").pop();
const tone = Object.hasOwn(LIST_TONES, last) ? LIST_TONES[last] : "neutral";
const editable = Object.hasOwn(FIREWALL_LISTS, list);
return h("li", {"data-entry": entry, "data-list": list}, h("div", {class: "row"}, pill(FIREWALL_LISTS[list] || list, tone), h("code", {}, revealed(entry)), h("span", {class: "spacer"}),
editable ? iconBtn("bi-dash-circle", "Remove", "btn small ghost", () => stageChange(path, {list, op: "remove", entry}), `Remove: stage the removal of ${revealed(entry)} from ${list}`) : null));
/**
* @param {Object} file a settings file as /api/firewall lists it.
* @returns {Object[]} one row per permissions entry and sandbox value: filter, action, tone, tool, pattern, list, entry (null for a sandbox value no list holds), hits and never.
*/
function fileRows(file) {
const permissions = file.groups.flatMap((group) => group.entries.map((entry) => ({filter: entry.list, action: FIREWALL_LISTS[`permissions.${entry.list}`], tone: LIST_TONES[entry.list], tool: group.tool, pattern: entry.spec, list: `permissions.${entry.list}`, entry: entry.entry, hits: entry.hits, never: entry.never})));
const sandbox = file.sandbox.flatMap((entry) => {
const base = {filter: "sandbox", action: FIREWALL_LISTS[entry.key] || "Sandbox", tone: "info", tool: entry.key.replace(/^sandbox\./, ""), list: entry.key, hits: null, never: ""};
return entry.values ? entry.values.map((value) => ({...base, pattern: value, entry: value})) : [{...base, pattern: JSON.stringify(entry.value), entry: null}];
});
return [...permissions, ...sandbox];
}
function fileCard(file) {
const groups = file.groups.map((group) => h("details", {class: "fw-group", open: true, "data-tool": group.tool, "data-prefix": group.prefix},
h("summary", {}, h("strong", {}, group.tool), group.prefix ? h("code", {}, group.prefix) : null, counter(group.entries.length)),
h("ul", {class: "mini"}, group.entries.map((entry) => entryRow(file.path, `permissions.${entry.list}`, entry.entry)))));
const sandbox = file.sandbox.map((entry) => (entry.values
? h("details", {class: "fw-group", "data-key": entry.key}, h("summary", {}, h("strong", {}, entry.key), counter(entry.values.length)), h("ul", {class: "mini"}, entry.values.map((value) => entryRow(file.path, entry.key, value))))
: h("div", {class: "rule-row", "data-key": entry.key}, h("strong", {}, entry.key), h("code", {}, JSON.stringify(entry.value)))));
const status = file.error ? pill(file.error, "bad") : file.exists ? pill(`sha256 ${file.sha256.slice(0, 12)}`, "neutral") : pill("missing: a change creates it", "warn");
return h("section", {class: "fw-file", "data-file": file.path, "aria-label": file.path}, h("div", {class: "row"}, h("code", {class: "fw-path"}, file.path), status),
groups.length ? groups : h("p", {class: "muted"}, "No permission entries."), sandbox.length ? h("h4", {}, "Sandbox") : null, sandbox);
/**
* @returns {Object[]} one row per stored hub rule, with the hits /api/firewall counted for it; pending until the next fetch counts a new rule.
*/
function signedRows() {
const counted = firewall.data.rules;
return state.rules.map((rule) => ({filter: "signed", action: `Grant ${rule.kind}`, tone: "ok", tool: rule.tool, pattern: rule.pattern, rule, ...(Object.hasOwn(counted, rule.id) ? counted[rule.id] : {hits: null, never: "", pending: true})}));
}
const fileStatus = (file) => (file.error ? pill(file.error, "bad") : file.exists ? pill(`sha256 ${file.sha256.slice(0, 12)}`, "neutral") : pill("missing: a change creates it", "warn"));
const byAction = (one, two) => ACTION_ORDER.indexOf(one.filter) - ACTION_ORDER.indexOf(two.filter);
function sourceGroups() {
return [{id: HUB_SOURCE, label: "Hub rules", file: false, status: null, rows: signedRows()}, ...firewall.data.files.map((file) => ({id: file.path, label: file.path, file: true, status: fileStatus(file), rows: fileRows(file)}))];
}
function hitsCell(row) {
if (row.pending) {
return h("span", {class: "muted", title: "Counted with the next refresh"}, "…");
}
if (row.never) {
return h("span", {class: "muted", title: `The matcher never grants a command that ${row.never}`}, `never granted: ${row.never}`);
}
if (row.hits === null) {
return h("span", {class: "muted", title: "Only asks reach the ledger the hits come from"}, "not seen");
}
return row.hits ? h("strong", {}, String(row.hits)) : ["0 ", h("span", {class: "pill", "data-tone": "warn", title: "No ask of the counted days matched this entry"}, "unused")];
}
function actionCell(row) {
const rule = row.rule;
const action = h("span", {class: "pill", "data-tone": row.tone, title: rule ? RULE_HINTS[rule.kind] : ENTRY_HINTS[row.filter]}, row.action);
if (!rule) {
return action;
}
const until = `until ${absolute.format(stampOf(rule.expires))}`;
return [action, rule.expires <= nowSeconds() ? pill("expired", "bad") : null, h("span", {class: "pill", "data-tone": rule.enabled ? "ok" : "neutral", title: until}, rule.enabled ? "active" : "off")];
}
function changeCell(group, row) {
const rule = row.rule;
if (rule) {
return [btn(rule.enabled ? "Turn off" : "Turn on", "btn small", () => changeRule(rule, rule.enabled ? "disable" : "enable")), btn("Delete", "btn small danger", () => {
if (window.confirm("Delete rule?")) {
changeRule(rule, "delete");
}
})];
}
const editable = row.entry !== null && Object.hasOwn(FIREWALL_LISTS, row.list);
return editable ? iconBtn("bi-dash-circle", "Remove", "btn small ghost", () => stageChange(group.id, {list: row.list, op: "remove", entry: row.entry}), `Remove: stage the removal of ${revealed(row.entry)} from ${row.list}`) : null;
}
/**
* @param {Object} group the source the row belongs to: id, label and file, false for the hub rules.
* @param {Object} row a row of fileRows() or signedRows().
* @returns {HTMLTableRowElement} the row: action, tool, pattern, scope, source, hits and its change buttons.
*/
function ruleRow(group, row) {
const rule = row.rule;
const pattern = [h("code", {}, revealed(row.pattern)), rule && rule.kind !== "decision" ? h("span", {class: "muted"}, " in ", h("code", {}, rule.scope ? revealed(rule.scope) : "–")) : null];
const source = rule ? h("span", {class: "muted"}, rule.signed ? "Hub, passkey-signed" : "Hub, unsigned: has no effect") : h("code", {class: "fw-path"}, revealed(group.label));
return h("tr", {"data-filter": row.filter, "data-list": row.list, "data-entry": row.entry, "data-rule": rule ? rule.id : null, "data-unused": row.hits === 0},
h("td", {}, actionCell(row)), h("td", {}, row.tool ? h("code", {}, revealed(row.tool)) : "–"), h("td", {}, pattern),
h("td", {}, rule ? targetPill(rule.agents) : h("span", {class: "muted"}, "file")), h("td", {}, source),
h("td", {class: "fw-hits"}, hitsCell(row)), h("td", {class: "fw-change"}, changeCell(group, row)));
}
function sourceBody(group) {
const rows = group.rows.filter((row) => firewall.shown.has(row.filter)).sort(byAction);
if (!rows.length && group.rows.length) {
return null;
}
const open = firewall.open.has(group.id);
const unused = rows.filter((row) => row.hits === 0).length;
const fold = h("button", {type: "button", class: "fw-fold", "aria-expanded": String(open), on: {click: () => {
if (open) {
firewall.open.delete(group.id);
} else {
firewall.open.add(group.id);
}
drawFirewall();
}}}, icon(open ? "bi-chevron-down" : "bi-chevron-right"), group.file ? h("code", {class: "fw-path"}, revealed(group.label)) : h("strong", {}, group.label), counter(rows.length), unused ? pill(`${unused} unused`, "warn") : null);
return h("tbody", {"data-source": group.id}, h("tr", {class: "fw-source"}, h("th", {colspan: 7, scope: "rowgroup"}, h("div", {class: "row"}, fold, group.status))), open ? rows.map((row) => ruleRow(group, row)) : []);
}
function filterChips() {
return h("div", {class: "chips", role: "group", "aria-label": "Show rules"}, ROW_FILTERS.map(([id, label]) => h("button", {type: "button", class: "chip", "data-filter": id, "aria-pressed": String(firewall.shown.has(id)), on: {click: () => {
if (firewall.shown.has(id)) {
firewall.shown.delete(id);
} else {
firewall.shown.add(id);
}
drawFirewall();
}}}, label)));
}
function ruleTable() {
const bodies = sourceGroups().map(sourceBody).filter(Boolean);
if (!bodies.length) {
return h("p", {class: "muted"}, "No rule matches the chosen chips.");
}
const head = h("thead", {}, h("tr", {}, ["Action", "Tool", "Pattern", "Scope", "Source", `Hits (${firewall.data.days} days)`].map((label) => h("th", {scope: "col"}, label)), h("th", {scope: "col", "aria-label": "Change"})));
return h("div", {class: "fw-table-wrap"}, h("table", {class: "fw-table", "aria-label": "Firewall rules"}, head, bodies));
}
function addForm(files) {
@@ -325,10 +431,10 @@
return h("section", {class: "card"}, h("p", {class: "muted"}, "Loading the settings …"));
}
const files = data.files;
return h("section", {class: "card stack-tight", "aria-label": "Claude settings"}, h("h3", {}, "Claude settings"),
h("p", {class: "muted"}, "Permissions and sandbox entries of the listed settings files, grouped by tool and prefix as the host read them. A change shows as a diff, is signed with your passkey and is written by the host, never by an agent."),
return h("section", {class: "card stack-tight fw-rules", "aria-label": "Firewall rules"}, h("h3", {}, "Firewall rules"),
h("p", {class: "muted"}, `Every rule in one table: the hub rules and the permissions and sandbox entries of the listed settings files as the host read them, one folded group per source. Hits count the asks of the last ${data.days} days a rule matches, with the matcher of the rule request dry run; allow, deny and sandbox entries never reach the ask ledger and show not seen. A settings change shows as a diff, is signed with your passkey and is written by the host, never by an agent.`),
data.error ? h("p", {class: "muted"}, data.error) : null,
files.map(fileCard), files.length ? addForm(files) : null, stagedList());
filterChips(), ruleTable(), files.length ? addForm(files) : null, stagedList());
}
function diffLines(text) {
+14 -25
View File
@@ -14,6 +14,18 @@
return signed ? sendJson(`/api/rules/${encodeURIComponent(rule.id)}/enable`, {proof: signed.proof}) : null;
}
/**
* @param {Object} rule the stored rule.
* @param {string} verb enable, disable or delete.
*/
async function changeRule(rule, verb) {
const result = verb === "enable" ? await turnOn(rule) : await send(`/api/rules/${encodeURIComponent(rule.id)}/${verb}`, "", "application/json");
if (result && !result.ok) {
toast("Rule not changed", fail(result), false);
}
await load();
}
function rulesScreen() {
const kind = h("select", {class: "field", "aria-label": "Kind"}, Object.entries(RULE_KINDS).map(([value, label]) => h("option", {value}, label)));
const target = targetSelect("Applies to", null);
@@ -63,29 +75,6 @@
toast(result.ok ? "Rule created" : "Rule not created", result.ok ? [] : fail(result), result.ok);
await load();
});
const change = async (rule, verb) => {
const result = verb === "enable" ? await turnOn(rule) : await send(`/api/rules/${encodeURIComponent(rule.id)}/${verb}`, "", "application/json");
if (result && !result.ok) {
toast("Rule not changed", fail(result), false);
}
await load();
};
const now = nowSeconds();
const list = state.rules.length ? h("div", {class: "mini"}, state.rules.map((rule) => h("div", {class: "rule-row"},
pill(rule.kind, KIND_TONES[rule.kind]),
targetPill(rule.agents),
rule.tool ? h("code", {}, revealed(rule.tool)) : null,
h("code", {}, revealed(rule.pattern)),
rule.kind === "decision" ? null : h("code", {title: "Directory"}, rule.scope ? revealed(rule.scope) : "–"),
pill(rule.signed ? "signed" : "unsigned: has no effect", rule.signed ? "ok" : "bad"),
rule.expires <= now ? pill("expired", "bad") : h("span", {class: "muted"}, `until ${absolute.format(stampOf(rule.expires))}`),
rule.enabled ? pill("active", "ok") : pill("off", "neutral"),
h("span", {class: "spacer"}),
btn(rule.enabled ? "Turn off" : "Turn on", "btn small", () => change(rule, rule.enabled ? "disable" : "enable")),
btn("Delete", "btn small danger", () => {
if (window.confirm("Delete rule?")) {
change(rule, "delete");
}
})))) : h("p", {class: "muted"}, "No rule yet. Every automatic grant shows up in the stream and can be undone for 3 s.");
return h("div", {class: "stack"}, h("h2", {class: "title"}, "Firewall"), h("h3", {}, "Hub rules for automatic grants"), list, h("div", {class: "card"}, hint, form), ...firewallSections());
const [table, ...rest] = firewallSections();
return h("div", {class: "stack"}, h("h2", {class: "title"}, "Firewall"), table, h("div", {class: "card"}, h("h3", {}, "New hub rule for automatic grants"), hint, form), ...rest);
}
+13 -4
View File
@@ -2,11 +2,20 @@
.fw-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; align-items: end; }
.fw-form label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: var(--fs-sm); }
.fw-form .field { width: 100%; min-width: 0; }
.fw-file { display: grid; gap: 8px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.fw-file > .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fw-path { overflow-wrap: anywhere; }
.fw-group > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; cursor: pointer; }
.fw-group code, .fw-patterns code { overflow-wrap: anywhere; }
.fw-patterns code { overflow-wrap: anywhere; }
.fw-rules { grid-template-columns: minmax(0, 1fr); }
.fw-table-wrap { min-width: 0; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.fw-table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: var(--fs-sm); }
.fw-table th, .fw-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.fw-table thead th { background: var(--sunken); color: var(--muted); font-weight: 650; white-space: nowrap; }
.fw-table td { overflow-wrap: anywhere; }
.fw-table td .pill { margin: 0 4px 2px 0; }
.fw-source > th { background: var(--sunken); font-weight: 560; }
.fw-source .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fw-fold { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.fw-hits { white-space: nowrap; font-variant-numeric: tabular-nums; }
.fw-change { white-space: nowrap; text-align: right; }
.fw-diff { max-height: 50vh; margin: 4px 0 0; padding: 8px; overflow: auto; border-radius: 8px; background: var(--sunken); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.fw-diff .add { color: var(--ok); }
.fw-diff .del { color: var(--bad); }