Repository navigation
feat(agent-audit): per-rule allow/ask/deny ledger across Claude Code, Codex, Cursor CLI and Gemini CLI, with a baseline - #1121
Merged
sandstream merged 3 commits intoNov 27, 2026
Conversation
kit agent-audit now lists every saved permission rule it can read, one row per rule (harness, scope, file, rule, kind, class, first-seen date), for Claude Code (user, project, local, managed), Codex prefix_rule (user and project, parsed as text and never evaluated), Cursor CLI and Gemini CLI. The class comes from the trifecta tables (grantClass). ~/.kit/agent-rules.json records the accepted rules; new allow rules and removed deny or ask rules are reported by agent-audit and kit check until a person runs `kit agent-audit --accept-rules`, which trail-guard refuses from an agent. Unparsed rules are reported, never dropped. --json adds `rules`. The trifecta pass row now names the Claude Code files it read instead of "no agent holds ...", and FEATURES.md no longer says Codex has no command allowlist. Found by kit-research#239 (prismor-always-allowed-rules-vs-kit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
The fallback flag scan gave --accept-rules to every handler in commands/info.ts (status, health, supply-chain), which pushed the generated src/flag-surface.ts past its 700-line cap. agent-audit now declares its own flags (--accept-rules, --accept-user-surfaces, --json) in contracts/command-flags.json, and info.ts reads the acceptance flag through a constant, so the sibling handlers keep the flags they had. --attest, --mode and --no-auto-install were picked up from siblings and never read by agent-audit. The ledger test now runs --accept-rules through the CLI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
sandstream
deleted the
claude/web-kit-status-sync-p6fg9a-protected-agent-rule-ledger
branch
November 27, 2026 11:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Protected — owner merges. The branch is under the
protected-prefix; it changes no protected path (src/agent-audit.tsis untouched), but it adds a new audit and a new acceptance command, which the owner approved as a feature.Found by kit-research#239 (
prismor-always-allowed-rules-vs-kit), Measurement §1 and §2 and the Innovation section. A reply to a permission prompt can add allow rules and remove deny rules in a settings file, and the change outlives whoever sent it. kit read Claude Code's allow rules only as trifecta legs, never listed one, read no Codex, Cursor or Gemini rule, and removing five of kit's own deny rules changed no row ofkit check.What changes
kit agent-auditlists one row per saved rule: harness, scope (user, project, local or managed), file, rule, kind (allow, ask, deny, or unparsed), class, and first-seen date.--jsonaddsrulesandledger: { read, notCovered }.~/.claude/settings.json(or$CLAUDE_CONFIG_DIR),.claude/settings.json,.claude/settings.local.json, managedmanaged-settings.json+managed-settings.d/*.jsonin/etc/claude-code,/Library/Application Support/ClaudeCode,C:\Program Files\ClaudeCodeprefix_rule(...)in$CODEX_HOME/rules/*.rulesand.codex/rules/*.rulesallowis markedunsandboxed~/.cursor/cli-config.json,.cursor/cli.jsontools.allowed,tools.exclude,tools.autoAccept/autoAccept,general.defaultApprovalMode: auto_editin user, project and system settings (per OS)Codex rules are parsed as text, never evaluated (
src/codex-rules.ts). A statement is accepted only as a literalprefix_rule(...)with keyword arguments that are string literals or lists of them. A variable,load(), concatenation, positional argument, unknown keyword or triple-quoted string becomes an unparsed row and a warning. A settings file that is not a JSON object, or a non-string rule entry, does the same. Nothing is dropped, so nothing unreadable counts as narrow.The class is kit's existing classification, not a new score.
grantClass()insrc/agent-trifecta.tsrunslegsOfandwriteGrantson the rule, mapped to Claude Code's grant shape (Shell(x)→Bash(x:*),run_shell_command(x)→Bash(x:*), a Codex prefix →Bash(prefix:*)). SoRead(~/.ssh/**)isprivate data, a Codexprefix_rule(pattern=["bash"])isall three legs, writes, unsandboxed, and a curl to an internal host isuntrusted input, way out.The baseline is
~/.kit/agent-rules.json, next touser-surfaces.jsonunder the trail-guarded~/.kit. It is recorded on the first run (not in read-only mode). After that, on every run ofkit agent-auditandkit check:warnwith severity high;warnwith severity medium.Both stay until a person runs
kit agent-audit --accept-rules.trail-guardrefuses that command from an agent, the same way it refuses--accept-user-surfaces. First-seen dates are kept in the same file, because agents store no dates.An allow rule outside Claude Code whose class is
all three legsgets a warning. Claude Code's are already reported by the trifecta row.Trifecta ✓ text. It used to say "no agent holds…". It now says "no Claude Code session or subagent holds…", names the files it read, and points to the ledger for the other harnesses.
Not covered, printed in the output: Antigravity (Prismor's store is not verified against Google's docs, and kit has no fixture for it), Copilot CLI (docs not read), Amazon Q, AWS Kiro, Factory Droid, Augment, OpenCode, Cline, Continue, Codex team and system config layers, Gemini CLI policy files, and Claude Code MDM, registry and server-managed policy.
Before / after
scripts/ledger-demo.sh(scratch):.claude/settings.jsondeniesRead(~/.ssh/**)andBash(git push --force:*),.codex/rules/default.rulesallowsbash, and~/.cursor/cli-config.jsonallowsShell(bash). Run 2 removes the ssh deny and addsRead(~/.ssh/**)tosettings.local.json.Before (
origin/main), both runs:After, run 2:
Tests:
src/agent-rule-ledger.test.ts,src/agent-rule-sources.test.tsandsrc/codex-rules.test.ts. They reuse the note's fixtures. Onmainthey fail withERR_MODULE_NOT_FOUND: dist/agent-rule-ledger.js; on this branch, 11/11 pass.Cross-platform
node:path. The managed and system directories per OS come fromclaudeManagedDir/geminiSystemFiles(win32/posixjoin) and are unit-tested for Linux, macOS and Windows.0o600, which is ignored on Windows, the same asuser-surfaces.json./Library/Application Support/...paths are checked only as strings.Choices for the owner
kit checkreports the drift, unparsed and three-legs rows too, throughcheck-agent-config.ts. It does not show the per-rule listing.KIT_DENY_RULESare present whereagent-configwrote them (Plan step 3), and it does not changegate-self-edit(Plan step 4).docs/FEATURES.mdCodex-allowlist sentence is left to docs: Codex has a command allowlist (prefix_rule) #1112, to avoid a conflict.agent-auditnow has an explicit entry incontracts/command-flags.json:--accept-rules,--accept-user-surfacesand--json. The fallback scan had been giving--accept-rulesto every handler incommands/info.ts(status,health,supply-chain), and that pushed the generatedsrc/flag-surface.tspast its 700-line cap. As a result,agent-auditno longer accepts--attest,--modeand--no-auto-install. It picked those up from sibling handlers and never read them.Generated by Claude Code