Encoding RDCO's hard-gates as code: three deny lines close the email gate, and the 251 blocks RDCO already lives with are a coded gate with a wrong default
Confidence legend: (V) = verified today in a primary source or in the named local file. (U) = inferred, single-source, or an estimate. Local-config claims were read from the live files on 2026-10-24; Claude Code mechanism claims were read from code.claude.com/docs/en/* on 2026-10-24. sensitivity: medium is a deliberate deviation from the template's low, because this brief names the on-disk location of a live credential.
The question
"What would it take to encode RDCO's existing AGENTS.md hard-gates (deploy/production-write denial, no-autonomous-external-email) as code-level permission checks instead of prompt-level rules, Every-style?"
One premise correction before anything else: neither named gate is in ~/AGENTS.md. (V) AGENTS.md's four hard rules are the date check, channel-reply routing, the calendar UTC-offset rule, and subagent routing for long artifacts. Deploy/production-write denial lives in [[feedback_automode_classifier_hard_gate]] and external-email denial in [[feedback_no_autonomous_external_email]] - both memory-backed, which places them lower in the precedence chain than the question assumes. Ten gates are load-bearing in practice; all ten are inventoried below.
What we already know (from the vault)
- Every's thesis is about persuasion resistance, not precision. [[2026-10-20-every-shared-agent-permissions-architecture]] records Every encoding ownership rules in code beneath the model "specifically because 'the model can't be convinced to bend rules that it shouldn't'" - an instructed-only agent in testing tried to edit a skill it didn't own, and the coded layer refused. Every's own reported failure of the coded approach was a July migration that defaulted 24 skills to private ownership and locked out the teams who built them for about a week. (V) The framing of that as "wrong defaults rather than persuasion" is the vault note's mapping, not Every's own words. (U)
- RDCO's measured gating is inverted with respect to blast radius. [[2026-10-23-rdco-auto-mode-classifier-miss-profile]] counted, over 2026-10-08 to 2026-10-23, 251 denial events across 401 runs, all on
Bash(248) orWrite(3) and zero on MCP; 249 of 251 came fromgraph-reingestandsync-contacts, denied in 15 of 15 runs each, againstsync-contacts-ledger.json(64),/tmpscratch files (59),cron-undelivered/(42) andops-log.md(37). Over the same window 920 MCP write-class calls ran, and "920 match a wildcard allow-rule and 0 were denied" - iMessage reply 687, notion-update-page 152, notion-create-pages 62, Calendar create/update 19. Its verdict: "reversible local appends are adjudicated 251 times whilenotion-delete-pagesandGmail__send_messageride a wildcard allow-rule with zero adjudication." (V) - That brief already identified the mechanism, and it is not a risk judgment. It states: "This is not a classifier risk judgment; the message text is a sensitive-file protection on
~/.claude/state/." (V) It also recordedgraph-reingest.logandsync-contacts-ledger.jsonfrozen at mtime 2026-08-17 while all 401 runs reportsubtype: "success",is_error: false,safety_stops: 0- calling thatsuccess-on-a-denied-run fact "the single most expensive fact in this brief." It explicitly declined to attribute the freeze to the blocks: "the 2026-08-17 → 2026-09-23 gap is unexplained by available logs and I am not claiming the block caused the full 67 days." (V) So the blocks are verified and the files are verified frozen; the causal link between them is (U). - Three sources converge on the principle. [[2026-10-22-technically-agent-access-control-workos]] has WorkOS's Grinich arguing approval pop-ups cannot scale to agent speed ("to err is human, but to screw up 10,000 times per second you need a computer"), with the vault note paraphrasing his second point as risk tolerance being company-specific rather than model-specific, and drawing the line itself: "authorization has to live in a layer the model can't talk its way around." (V)
- RDCO already has a design for the judgment-call remainder. [[2026-06-04-supervisor-agent-write-path-pattern-design-v0]] specifies a narrow-scope fresh-eyes reviewer with zero execution authority - it reads, judges, returns a verdict, and cannot send, charge, push or write. (V)
What the web says
- The docs state the prompt-versus-code distinction in the question's own terms. permissions.md: "Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or
CLAUDE.mdshape what Claude tries to do, but they don't change what Claude Code allows." (V) - Deny beats allow across every scope, with one carve-out that applies to this machine. Rules evaluate deny, then ask, then allow; "the first match in that order determines the outcome, and rule specificity doesn't change the order." List keys merge rather than replace across settings files, so "if a tool is denied at any level, no other level can allow it." A bare tool name in
denyremoves the tool from Claude's context entirely; a scoped rule leaves it present. The carve-out: "With neither managed settings nor a Team or Enterprise/loginas the session's credential, the mod can approve a call that a deny rule refuses or aPreToolUsehook blocked." RDCO has no managed settings and is on an individual plan, so this path is open in principle; it requires an installed mod handling thetool.checkevent, which this brief did not audit. (V for the sentence, U for whether any installed mod exercises it**)** - Allow rules do pre-empt the auto-mode classifier, except on a published exception list. permission-modes.md, step 1 of the classifier's decision order: "Actions matching your allow, ask, or deny rules resolve immediately," with exceptions including protected-path writes, recognized
rm/rmdircritical-path removals, MCP tools markedrequiresUserInteraction, and - importantly for anyaskrule RDCO writes - "Ask rules that match on a command's content, such asBash(git push *), fall back to a permission prompt." (V) .claudeis a protected path, and that is the mechanical cause of the 251 blocks. permission-modes.md: "Writes to a small set of paths are never auto-approved,".claudeis on the list, inautomode protected-path writes are "Routed to the classifier," and "permissions.allowrules in settings files do not pre-approve protected-path writes. The safety check runs before Claude Code evaluates allow rules from settings." The named exceptions to.claudeprotection include~/.claude/worktrees/, session plan files, background-job scratch dirs, and markdown under~/.claude/projects/<project>/memory/- but not~/.claude/state/, which is where RDCO keepssync-contacts-ledger.json,graph-reingest.logandops-log.md. (V)PreToolUsehooks see every tool including MCP, with full arguments, and block past an allow rule. The stdin payload carriessession_id,transcript_path,cwd,permission_mode,tool_name,tool_input,tool_use_id, and for MCP toolsmcp_server. "MCP server tools appear as regular tools in tool events ... so you can match them the same way you match any other tool name." Blocking is exit code 2 (stderr becomes the reason Claude sees) or JSONhookSpecificOutputwithpermissionDecisioninallow/deny/ask/defer; multi-hook precedence isdeny > defer > ask > allow. "A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed." The converse fails: a hook'sallowcannot override a matching deny or ask rule, and a hookask"forces a permission prompt in auto mode." A hook can rewrite the call viaupdatedInput, after which permission rules are re-evaluated against the hook's output. (V)- Rule matchers are coarser than the gates need, and the docs say so. For MCP, "when Claude Code loads a settings file, it skips any
mcp__rule that has parentheses" - argument-level MCP gating from settings.json is discarded, not merely undocumented. For Bash,*"stands in for any text, including spaces" over a command Claude Code does split on&&,||,;,|,|&,&and newlines, which is the mechanical explanation for [[feedback_allowlisted_commands_run_standalone]]; but the docs publish their own bypass table showingBash(git push *)failing to stopgit -C . push origin main,git -c push.default=current push, orgit 'push' origin main, and conclude a Bash rule "isn't a security boundary around the program." For paths, "Claude Code checks file permissions againstEdit(path)andRead(path)rules only" - aWrite(path)rule is accepted and never matches. (V) - Settings hot-reload, and the only file a local agent cannot edit is managed settings. settings.md: Claude Code "watches your settings files and reloads them when they change, so it applies most edits to the running session without a restart, including edits to
permissions,hooks." Writes under~/.claude/are themselves protected-path writes routed to the classifier, which is why [[feedback_paper_trade_deploy_authorization]] observed settings self-modification being blocked - but that is a model layer, not a lock. The lock is/Library/Application Support/ClaudeCode/managed-settings.json("Nothing in your own settings files or--settingsoverrides a managed key"), optionally withallowManagedPermissionRulesOnly,allowManagedHooksOnly, and aConfigChangehook offered to "block unauthorized modifications to configuration files." That directory does not exist on this machine. (V) Separately, permissions.md names sandboxing as OS-level enforcement that "applies to Bash, PowerShell, and Monitor tool commands and their child processes," useful because "sandbox restrictions still apply even if a prompt injection bypasses Claude's decision-making." (V)
Convergences and contradictions
- The posture, not a coverage gap, is the finding.
~/.claude/settings.jsoncarries 68 allow rules, 0 deny rules, 0 ask rules,permissions.defaultMode: auto,skipAutoPermissionPrompt: true. (V) RDCO has used the coded layer only as an accelerator and never once as a brake. Exactly one gate is live-contradicted by it:mcp__claude_ai_Gmail__*is wildcard-allowed, soGmail__send_messageis auto-approved today against [[feedback_no_autonomous_external_email]]. (V) Two near-misses are not contradictions on inspection - themcp__plugin_discord_discord__*allow rules in both settings files are inert leftovers, since no Discord plugin appears inenabledPlugins, and theBash(~/.claude/scripts/wrangler.sh *)allow rule is the deploy gate's own sanctioned outcome, since [[feedback_automode_classifier_hard_gate]] names a founder-set allow rule as "the only path" to durable autonomy. (V) - The 251 blocks are a coded gate with a default that does not fit RDCO's layout - which is Every's July failure observed locally. The protected-path rule is real enforcement: it runs before allow rules and cannot be allow-listed away. It is firing because RDCO treats
~/.claude/state/as a working data directory, a use the exception list does not cover. So the lesson from Every to bank is not only "rules in code beneath the model"; it is that coded gates are better at resisting argument and no better at being correctly targeted, and their characteristic failure is a right rule with a wrong default breaking work silently. The fix here is not a permission rule at all - it is relocating those three files out of~/.claude/state/into a path RDCO owns. (V for the mechanism, U for the fix being sufficient**)** - Convergence RDCO can bank immediately: the mechanism is already in-house.
settings.jsonalready runs aPreToolUseblock of ten handlers using the per-handlerif:filter in permission-rule syntax, callingpackage-security-check.sh(which blocks withexit 2) andsql-guardrail.sh(which emitspermissionDecision: "ask"). (V) Both documented block mechanisms are already deployed here. Nothing recommended below is greenfield.
Synthesis for RDCO
| # | Gate | Source | Tier | Encoding recipe | Size |
|---|---|---|---|---|---|
| 1 | No autonomous external email | memory | (a) static deny | permissions.deny on mcp__claude_ai_Gmail__send_message, __forward, __reply; removes those three tools from context, leaves create_draft and all reads |
3 lines, one file |
| 2 | Finance data DM-only, cheap 80% | memory | (a) static deny | permissions.deny on the Slack write tools; the connected workspace is empty and a send is never wanted |
1-2 lines |
| 3 | Discord retired | AGENTS.md r2 | (a) static deny | drop the inert mcp__plugin_discord_discord__* allow rules; hygiene, not a live hole |
2 lines, 2 files |
| 4 | PR-only on RDCO repos | memory | (a), but outside the harness | GitHub branch protection requiring a PR on main; a Bash(git push *) deny rule is defeated by the docs' own bypass table, server-side protection is not. HQ carve-out left unprotected by design |
gh api per repo |
| 5 | Deploy / production-write denial | memory | (a)+(b) mixed | the autoMode.soft_deny prose becomes ask rules on the named production verbs, e.g. Bash(*wrangler.sh pages deploy *). Caution: a content-matching ask rule "falls back to a permission prompt," which in an unattended cron session is a hard stop, so scope it to the production verbs only |
2-4 lines + a cron audit |
| 6 | Paper-trade deploy authorization | memory | (b) hook + state | PreToolUse handler if: "Bash(*alpaca-*-deploy.py*)", reads a token file written only by the HQ decision rail, matches the slug out of tool_input.command, exits 2 unless an unexpired DECISION:<slug>:APPROVE exists |
~40-line script |
| 7 | No secrets on disk | memory | (b) hook, content | PreToolUse on Write/Edit scanning tool_input.content and new_string for known credential prefixes |
~30-line script |
| 8 | Finance data DM-only, full | memory | (b) hook + state | settings-file mcp__ rules with parentheses are discarded, so pinning imessage__reply to the founder's chat_id or taint-tracking a Monarch read to a later send both require a hook reading tool_input and transcript_path |
~60-line script |
| 9 | Channel replies via the reply tool | AGENTS.md r2 | (b) hook, Stop event | on Stop, if the session was channel-initiated and no imessage__reply call appears in the transcript, block the stop |
~30-line script |
| 10 | Route long artifacts to subagents | AGENTS.md r4 | (b) hook, obviating | PreToolUse on Read stats tool_input.file_path and returns ask when size exceeds the threshold with no offset/limit |
~20-line script |
| - | date before time claims |
AGENTS.md r1 | obviate | inject the current timestamp as SessionStart / UserPromptSubmit context; a gate you no longer need is cheaper than one you enforce |
~5 lines |
| - | Calendar UTC-offset rule | AGENTS.md r3 | obviate | PostToolUse on list_events appends already-converted Eastern times |
~20-line script |
| - | <$20/mo spend, SC originality, undo-cost judgment |
memory | (c) irreducible | no tool input carries the price, and taste is not a predicate; these belong to the zero-execution-authority reviewer in [[2026-06-04-supervisor-agent-write-path-pattern-design-v0]] | n/a |
Inventoried against the real enforcement surface, the ten gates sort into four tiers, and the distribution is better than the question's framing implies: "codeable" is not one thing, and a static deny pattern, a hook that parses arguments and consults state, an enforcement point outside the harness, and a judgment no check can express are four different sizes of job. Gate 1 is the whole exercise in miniature and should ship first. Deny beats the wildcard allow at every scope and in every mode, a bare MCP tool name in deny removes the tool from context rather than merely refusing it, and create_draft plus the entire read surface survive untouched. That is exactly the drafts-plus-human-send-key shape the founder specified on 2026-05-01, except the model stops being asked not to send and instead has no send tool. Gates 2 and 3 are the same shape for a few more lines. Gate 4 is the one where the honest answer is "not in this harness": the docs' bypass table shows a git push deny rule failing against git -C ., git -c push.default=current push, and git 'push', while GitHub branch protection sits where neither Ray nor a hook can reach it.
The hook tier is real work but not research, and the gating question for it is not capability. Capability is settled: hooks see MCP arguments, can consult a state file and the transcript path, and block past an allow rule with exit 2. The question is whether the state each hook consults is written by a path Ray does not control. Gate 6 is the clean case, because the HQ decision rail already exists and produces a canonical DECISION:<slug>:APPROVE string, so the hook only has to read a file it never writes. Gate 8 is the weak case, because a taint-tracking hook that reads its own session's transcript is checking an artifact the same agent produced. That distinction - who writes the state the gate reads - is a better predictor of whether a coded gate holds than which mechanism it uses.
The gap Every's architecture does not close here is the honest limit of the whole exercise, and it has three layers. Every put rules in a codebase the agent does not administer; RDCO's would live in ~/.claude/settings.json. Writes there are protected-path writes routed to the classifier, which is why [[feedback_paper_trade_deploy_authorization]] saw settings self-modification blocked - but that is a model adjudicating, not a lock, and permissions and hooks edits hot-reload into the running session. On top of that sits the documented mod carve-out: with neither managed settings nor a Team or Enterprise login, a mod handling tool.check can approve a call a deny rule refused or a hook blocked. So every coded gate recommended above is drift-protective and persuasion-protective but not adversary-protective: it defeats a model argued into an exception, a stale prose rule nobody re-read, and an inconsistently adjudicated write, which is precisely the failure class the 10-23 numbers document. It does not defeat a determined or compromised agent. Closing that needs a root-owned managed-settings.json with allowManagedHooksOnly plus a ConfigChange hook, and installing it is a founder action at a sudo prompt that Ray cannot and should not perform. The answer to "what would it take" is therefore: tier (a) is an afternoon, tier (b) is a few days of small scripts, and the only step that converts any of it from a habit into a boundary is five minutes of founder time at a sudo prompt. (U on both estimates.) Sequence it one gate at a time with each affected target's mtime checked after, because the documented failure mode of coded enforcement - Every's July lockout, and RDCO's own protected-path freeze - is a correct rule with a wrong default breaking work while every log reports success.
One live exception surfaced while reading the config, and it belongs in front of the founder rather than in the table. ~/.claude/settings.local.json holds a plaintext 1Password service-account token under env.OP_SERVICE_ACCOUNT_TOKEN; the file's mtime is 2026-08-12, and nothing on disk dates when the token was added. (V for the token's presence and the mtime, U for how long it has been there.) As written, [[feedback_no_secrets_on_disk]] forbids exactly this shape - "never store secrets in .env files, mcp.json env blocks, or any file on disk" - but the gate never addressed a real chicken-and-egg: reaching 1Password requires a credential that cannot itself come from 1Password. So this is not simply a violation to clean up. Either the gate needs an explicit bootstrap-credential carve-out, or the token moves to the macOS Keychain behind a helper. Which one is the founder's call; the brief's point is that an instructed gate sat next to a config that contradicted it and nothing noticed, which is the thesis in miniature.
Why this is in the vault
This sizes the fix that [[2026-10-23-rdco-auto-mode-classifier-miss-profile]] recommended but did not scope, and it reorders that brief's priorities on new evidence: its first priority was repairing the frozen state files as a reliability defect and its second was narrowing the MCP wildcards, whereas the protected-paths documentation read today shows the reliability defect is not repairable by any permission rule - those three files have to move out of ~/.claude/state/ - while the single highest-value wildcard narrowing is three deny lines on Gmail. It also gives the phData agents-in-production credibility thread in [[project_credibility_for_phdata_sales]] a first-person artifact: an enumerated gate inventory, a four-tier codeability model, and a measured account of what an instructed gate costs, which is more defensible to publish than commentary on someone else's architecture.
Open follow-ups
- What does enforcement mean when the operator is the administrator? Every, WorkOS and Anthropic's managed-settings design all assume an admin distinct from the agent's operator. A solo founder installing a root-owned policy file against his own agent is a different trust model, and nothing in the vault examines whether such self-imposed constraints hold or what makes them hold. This is the question the managed-settings recommendation rests on and cannot answer itself.
- Is there a documented detection pattern for the correct-rule-wrong-default failure? Every's July lockout and RDCO's protected-path freeze are the same accident: a defensible access decision whose default silently broke work that used to run, discovered weeks later by a human. Worth a night because it is the one documented failure mode of everything this brief recommends, and neither source describes how they would catch it next time.
- What is the published threat model for mod-based permission override? The
tool.checkcarve-out is the one documented path that defeats both a deny rule and aPreToolUseblock on a non-managed individual-plan install, which makes it the ceiling on every tier-(a) and tier-(b) gate above. Whether anyone outside Anthropic's docs has characterised it is unknown.
Related
- [[2026-11-06-correct-rule-wrong-default-permission-detection]] - closes this brief's open follow-up #2 (no documented detection pattern exists as a named class; composes alert-on-absence and enforcement-staging into the freshness-manifest control RDCO was missing)
- [[2026-10-25-coded-vs-prompted-permission-gates]] - the concept article this brief's inventory fed; names the coded/prompted distinction this brief applies gate-by-gate
- [[2026-10-20-every-shared-agent-permissions-architecture]]
- [[2026-10-23-rdco-auto-mode-classifier-miss-profile]]
- [[2026-10-22-technically-agent-access-control-workos]]
- [[2026-06-04-supervisor-agent-write-path-pattern-design-v0]]
- [[2026-06-07-agent-write-action-gating-patterns]]
- [[2026-10-22-automode-classifier-channel-text-injection-surface]]
- [[2026-06-09-claude-md-prompt-precedence-full]]
- [[feedback_automode_classifier_hard_gate]]
- [[feedback_no_autonomous_external_email]]
- [[feedback_paper_trade_deploy_authorization]]
- [[feedback_pr_only_workflow]]
- [[feedback_pr_only_workflow_hq_carveout]]
- [[feedback_no_secrets_on_disk]]
- [[feedback_personal_finance_data_dm_only]]
- [[feedback_allowlisted_commands_run_standalone]]
- [[project_credibility_for_phdata_sales]]
Sources
Local primary (read 2026-10-24)
~/AGENTS.md- the four numbered hard rules; neither named gate is among them~/.claude/settings.json- 68 allow / 0 deny / 0 ask,defaultMode: auto,skipAutoPermissionPrompt: true, theautoMode.soft_denyprose array,enabledPlugins(no Discord), and the existing ten-handlerPreToolUseblock~/.claude/settings.local.json- local allow rules, mtime 2026-08-12, and theenv.OP_SERVICE_ACCOUNT_TOKENfinding~/.claude/scripts/sql-guardrail.sh- in-housepermissionDecision: "ask"pattern~/.claude/scripts/package-security-check.sh- in-houseexit 2block pattern/Library/Application Support/ClaudeCode/- confirmed absent, no managed settings on this machine- Memory gate files under
~/.claude/projects/-Users-ray/memory/:feedback_automode_classifier_hard_gate,feedback_no_autonomous_external_email,feedback_paper_trade_deploy_authorization,feedback_pr_only_workflow,feedback_pr_only_workflow_hq_carveout,feedback_no_secrets_on_disk,feedback_personal_finance_data_dm_only,feedback_allowlisted_commands_run_standalone
Vault
~/rdco-vault/06-reference/2026-10-20-every-shared-agent-permissions-architecture.md~/rdco-vault/06-reference/research/2026-10-23-rdco-auto-mode-classifier-miss-profile.md~/rdco-vault/06-reference/2026-10-22-technically-agent-access-control-workos.md~/rdco-vault/06-reference/concepts/2026-06-04-supervisor-agent-write-path-pattern-design-v0.md~/rdco-vault/06-reference/research/2026-06-07-agent-write-action-gating-patterns.md~/rdco-vault/02-sops/2026-06-09-claude-md-prompt-precedence-full.md
Web (official docs, fetched 2026-10-24)
- https://code.claude.com/docs/en/permissions.md - rule syntax, precedence, the Bash bypass table, the mod
tool.checkcarve-out, the sandboxing sentences - https://code.claude.com/docs/en/permission-modes.md - the classifier's decision order and the Protected paths section
- https://code.claude.com/docs/en/hooks.md - events,
PreToolUsepayload, block mechanisms, matcher andif:syntax - https://code.claude.com/docs/en/settings.md - scope precedence, list-key merging, hot reload
- https://code.claude.com/docs/en/settings-reference.md -
permissionsandsandboxkey shapes - https://code.claude.com/docs/en/managed-settings.md - managed file paths and the admin-lock keys
- https://code.claude.com/docs/en/agent-sdk/permissions.md -
canUseTooland its shadowing caveat
Web (search-summary level, flagged not read in full) - the out-of-harness policy-engine tier, noted as not needed by RDCO today
- https://hidekazu-konishi.com/entry/amazon_bedrock_agentcore_policy_implementation_guide.html - Cedar at an AgentCore Gateway
- https://www.gravitee.io/corpus/gen-1947/technical-writing/gapl-policy-documentation.html - GAPL, a Cedar subset evaluated at a gateway
- https://help.aliyun.com/en/agentidentity/policy-description - Cedar policy set bound to an AI Gateway