Repository navigation
Command rules: Codex-style allow, prompt and forbidden rules replace a bot's unsandboxed list - #572
Conversation
A SigV4 refusal is told as clock skew when the error names it, or when the response's Date is more than four minutes from when the request was signed, the AWS SDK for Java's rule. A machine that slept with a signed request in flight now re-signs instead of failing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
The `history` tool's view already dropped reasoning items' encrypted content. It now also drops a thinking block's signature, a redacted thinking block's data, and a web search result's encrypted content: bytes the provider hands back only to be replayed, which no agent can read. Thinking text stays; stored items, raw reads, forks and replay are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
The history view's READING_ITEM now matches quoted JSON keys, and the planner's constant pattern stopped at its first escaped quote. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
…ent/rules replace a bot's unsandboxed list The daemon reads every *.rules file in the folder it is started with (`serve --rules DIR`; the CLI passes ~/.agent/rules) and decides each shell call by the strictest rule its commands match, as Codex's execpolicy does: allow runs outside the sandbox without asking, prompt waits on the gate even when confined (or fails command_needs_approval with no gate), forbidden fails command_forbidden with the justification. A turn pins its rules when its rounds begin; the folder is read again when its files change, keeping the last good rules, and a folder broken before any read fails every shell call with rules_invalid. The folder is read-only in every sandbox. The files are read by a small reader of Codex's documented form (literal prefix_rule and host_executable calls, comments), not a Starlark runtime. `agent rules check -- COMMAND...` shows what the rules decide. The unsandboxed bot setting is gone (schema 75 strips it from stored bots; protocol 39). Sonny's "always allow" writes an allow rule to default.rules, and an existing [sonny] unsandboxed list moves there once at start. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
…s no force Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d19789530
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… the runtime thread, linked rules files refused A planned call keeps what the rules made of it (tools.ruling, schema 75), and its run reads that, so a park, restart or edit between announcement and run can't gate a call no request was made for. The rules folder is read on a blocking thread. A rules file that is a symlink or has another hard link is rules_invalid: the sandbox keeps only the folder itself read-only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
… and linked files Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7632127e42
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…nreadable rules file is refused A fresh round runs by the rules the turn read, which its announcement used, so it needs no store read; only a resumed park reads the rulings its round recorded, in the resume's own store job. A rules file whose metadata can't be read is refused rather than skipped, so the rules last read stay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
…s no force Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT
…fig.toml (#574) * Daemon: a SigV4 refusal dated far from its signing is clock skew A SigV4 refusal is told as clock skew when the error names it, or when the response's Date is more than four minutes from when the request was signed, the AWS SDK for Java's rule. A machine that slept with a signed request in flight now re-signs instead of failing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * History reads leave out the opaque state Claude replays The `history` tool's view already dropped reasoning items' encrypted content. It now also drops a thinking block's signature, a redacted thinking block's data, and a web search result's encrypted content: bytes the provider hands back only to be replayed, which no agent can read. Thinking text stays; stored items, raw reads, forks and replay are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Docs: a refusal dated far from its signing retries signed again Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Query plans: read store constants that hold escaped quotes The history view's READING_ITEM now matches quoted JSON keys, and the planner's constant pattern stopped at its first escaped quote. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: Codex-style allow, prompt and forbidden rules in ~/.agent/rules replace a bot's unsandboxed list The daemon reads every *.rules file in the folder it is started with (`serve --rules DIR`; the CLI passes ~/.agent/rules) and decides each shell call by the strictest rule its commands match, as Codex's execpolicy does: allow runs outside the sandbox without asking, prompt waits on the gate even when confined (or fails command_needs_approval with no gate), forbidden fails command_forbidden with the justification. A turn pins its rules when its rounds begin; the folder is read again when its files change, keeping the last good rules, and a folder broken before any read fails every shell call with rules_invalid. The folder is read-only in every sandbox. The files are read by a small reader of Codex's documented form (literal prefix_rule and host_executable calls, comments), not a Starlark runtime. `agent rules check -- COMMAND...` shows what the rules decide. The unsandboxed bot setting is gone (schema 75 strips it from stored bots; protocol 39). Sonny's "always allow" writes an allow rule to default.rules, and an existing [sonny] unsandboxed list moves there once at start. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Features: the always-allow row names #572 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: a call runs as its round was announced, rules read off the runtime thread, linked rules files refused A planned call keeps what the rules made of it (tools.ruling, schema 75), and its run reads that, so a park, restart or edit between announcement and run can't gate a call no request was made for. The rules folder is read on a blocking thread. A rules file that is a symlink or has another hard link is rules_invalid: the sandbox keeps only the folder itself read-only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: tests for recorded rulings; docs for runs as announced and linked files Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: a resumed park reads its rulings with the resume; an unreadable rules file is refused A fresh round runs by the rules the turn read, which its announcement used, so it needs no store read; only a resumed park reads the rulings its round recorded, in the resume's own store job. A rules file whose metadata can't be read is refused rather than skipped, so the rules last read stay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: docs say a resume reads the rulings back Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * configure takes every setting create takes; Sonny's agents follow config.toml `configure` gains `settings`, a map with create's names: a value given replaces the setting, null resets it to its default, and the rest stay. Naming `sandbox` resets writable, network and unix_sockets unless they are named too. `fallback`, `compaction_instructions` and `compaction_model` take null to remove. The old top-level sandbox, writable, network, unix_sockets, cache_ttl and speed fields are gone. `changed` names each setting key, with the sandbox's four reported as `sandbox`. Protocol 41. Sonny's tool host checks config.toml every five seconds and configures its agents to a changed [fallbacks] entry or senders setting. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * configure: refuse an unknown setting reset to null; check sandbox folders only when the sandbox changes A setting named with null was dropped before the names were checked, so a misspelled reset passed silently. And every settings change resolved the writable folders again, so one deleted since failed an unrelated change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT --------- Co-authored-by: Claude <[email protected]>
…aemon applies what each bot is given (#577) * Daemon: a SigV4 refusal dated far from its signing is clock skew A SigV4 refusal is told as clock skew when the error names it, or when the response's Date is more than four minutes from when the request was signed, the AWS SDK for Java's rule. A machine that slept with a signed request in flight now re-signs instead of failing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * History reads leave out the opaque state Claude replays The `history` tool's view already dropped reasoning items' encrypted content. It now also drops a thinking block's signature, a redacted thinking block's data, and a web search result's encrypted content: bytes the provider hands back only to be replayed, which no agent can read. Thinking text stays; stored items, raw reads, forks and replay are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Docs: a refusal dated far from its signing retries signed again Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Query plans: read store constants that hold escaped quotes The history view's READING_ITEM now matches quoted JSON keys, and the planner's constant pattern stopped at its first escaped quote. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: Codex-style allow, prompt and forbidden rules in ~/.agent/rules replace a bot's unsandboxed list The daemon reads every *.rules file in the folder it is started with (`serve --rules DIR`; the CLI passes ~/.agent/rules) and decides each shell call by the strictest rule its commands match, as Codex's execpolicy does: allow runs outside the sandbox without asking, prompt waits on the gate even when confined (or fails command_needs_approval with no gate), forbidden fails command_forbidden with the justification. A turn pins its rules when its rounds begin; the folder is read again when its files change, keeping the last good rules, and a folder broken before any read fails every shell call with rules_invalid. The folder is read-only in every sandbox. The files are read by a small reader of Codex's documented form (literal prefix_rule and host_executable calls, comments), not a Starlark runtime. `agent rules check -- COMMAND...` shows what the rules decide. The unsandboxed bot setting is gone (schema 75 strips it from stored bots; protocol 39). Sonny's "always allow" writes an allow rule to default.rules, and an existing [sonny] unsandboxed list moves there once at start. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Features: the always-allow row names #572 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: a call runs as its round was announced, rules read off the runtime thread, linked rules files refused A planned call keeps what the rules made of it (tools.ruling, schema 75), and its run reads that, so a park, restart or edit between announcement and run can't gate a call no request was made for. The rules folder is read on a blocking thread. A rules file that is a symlink or has another hard link is rules_invalid: the sandbox keeps only the folder itself read-only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: tests for recorded rulings; docs for runs as announced and linked files Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: a resumed park reads its rulings with the resume; an unreadable rules file is refused A fresh round runs by the rules the turn read, which its announcement used, so it needs no store read; only a resumed park reads the rulings its round recorded, in the resume's own store job. A rules file whose metadata can't be read is refused rather than skipped, so the rules last read stay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules: docs say a resume reads the rulings back Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * configure takes every setting create takes; Sonny's agents follow config.toml `configure` gains `settings`, a map with create's names: a value given replaces the setting, null resets it to its default, and the rest stay. Naming `sandbox` resets writable, network and unix_sockets unless they are named too. `fallback`, `compaction_instructions` and `compaction_model` take null to remove. The old top-level sandbox, writable, network, unix_sockets, cache_ttl and speed fields are gone. `changed` names each setting key, with the sandbox's four reported as `sandbox`. Protocol 41. Sonny's tool host checks config.toml every five seconds and configures its agents to a changed [fallbacks] entry or senders setting. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * configure: refuse an unknown setting reset to null; check sandbox folders only when the sandbox changes A setting named with null was dropped before the names were checked, so a misspelled reset passed silently. And every settings change resolved the writable folders again, so one deleted since failed an unrelated change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Command rules as data: Sonny runs Codex's Starlark rules files, the daemon applies what each bot is given The daemon no longer reads rules files. A bot's `rules` setting holds its command rules as Codex's execpolicy shape in JSON (prefix_rules, host_executables, or invalid with why), and the daemon matches each shell call against them as before. A bot made by another always goes by its creator's rules and follows their changes; configuring rules on it is invalid_setting. Sonny reads ~/.agent/rules as Codex does: Starlark in its extended dialect with f-strings, prefix_rule and host_executable (now with effect), examples checked after the file runs. network_rule is refused until a proxy can filter a sandbox's network by host. Sonny gives the rules to every agent it makes and keeps them current from its tool host. `sonny rules check` replaces `agent rules check`, and `serve --protect-path` replaces `serve --rules`, so the folder stays read-only in every sandbox. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Rules: reserve reply bytes for them, show them in settings, and let a bot whose creator is gone own its own A create reply repeats the bot's settings, now with its command rules, which admission reserves room for: what the command gives, or the cap for a bot that takes its creator's. inspect and the create reply show `rules` with the other settings. A bot whose creator is deleted keeps the rules it had and may be given its own, as no creator's sandbox holds it either; Sonny's tool host gives such an agent its rules as it gives a root one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT * Rules: an allow rule lets a program out by its name only at a path host_executable names Codex matches a program run by any absolute path by its name's rules when no host_executable names it. For an allow rule, which runs the command outside the sandbox, that lets a sandboxed bot write /tmp/rg and run it unasked. Such a path is still asked about or refused by the name's rules, but only a listed path is allowed by them. Examples still match by pattern alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGxFkGajbntA1atiYT --------- Co-authored-by: Claude <[email protected]>
PR 3a of the day-5 review, as the command rules design doc lays out (approved).
What changes
*.rulesfile in the folder it's started with (agent serve --rules DIR; the CLI passes~/.agent/rules). Rules are Codex'sprefix_rule(pattern, decision, justification, match, not_match)calls, with the same matching: one decision per command of a plain script, and the strictest one wins. A script goes outside only when every command in it is allowed.shelltool:forbiddenfailscommand_forbiddenwith the justification, or names the rule's file and line. It's never gated, even when the call escalates.promptwaits on the gate even when the sandbox would confine the call. With no gate it failscommand_needs_approval, as Codex treats prompt under approvalnever. Once approved it runs where it asked to run.allowruns outside the sandbox without asking.rules_invalidwithFILE:LINE. The folder is read-only inside every sandbox and can't be created there.prefix_rule/host_executablecalls, strings with Starlark escapes, lists,None/True/False, and comments. Anything else Starlark allows, such as a variable or a loop, isrules_invalidwith the line. Thestarlarkcrate took the binary from 19.4 MB to 27.6 MB and added 146 crates; with the reader it's 19.8 MB and adds none.agent rules check [--rules DIR] [--pretty] -- COMMAND...prints what the rules decide about one command, ascodex execpolicy checkdoes. It needs no store or daemon.unsandboxedbot setting is removed (--unsandboxed,configure, settings). Schema 75 strips it from stored bots. This is protocol 39.a) on an approval prompt appendsprefix_rule(pattern=[...], decision="allow")todefault.rules, as Codex's "don't ask again" does. At start, an existing[sonny] unsandboxedlist moves into allow rules once (the upgrade migration retires at 0.10.0). This is done in code, not as an agent upgrade step, because a sandboxed agent can't write the protected rules folder.Places this goes beyond the doc
agent rules checkshows the error.host_executableis checked but has no effect: matching uses a command's first word as written.network_ruleis refused, since a sandbox's network is either on or off.auto: aforbiddenorallowcommand never reaches one. docs/APPROVALS.md notes this.Tests
test_command_rules_let_a_command_out_ask_about_it_or_forbid_it: allow outside the sandbox, forbid even when escalated, prompt gated then confined, refusal with no approver, live reload from the next turn,unsandboxedrefused oncreate.test_rules_check_says_what_the_rules_decide_without_a_daemon. Workflow tests now use rules instead ofunsandboxed.cargo test --release --workspaceand clippy-D warningsare clean. Runtime modulestest_cli,test_approvals,test_workflows,test_daemonandtest_runtimepass withAGENT_TEST_SANDBOX=1.No screenshots: Sonny's prompt looks the same, and only where "always allow" writes has changed.