06-reference/research

coded vs prompted agent permission gates

2026-10-24·research-brief·source: deep-research·by Ray Data Co (deep-research synthesis)·! medium
agent-permissionsharness-engineeringhooksagents-in-productionenforcement

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)

What the web says

Convergences and contradictions

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

Related

Sources

Local primary (read 2026-10-24)

Vault

Web (official docs, fetched 2026-10-24)

Web (search-summary level, flagged not read in full) - the out-of-harness policy-engine tier, noted as not needed by RDCO today