Repository navigation
An automation gate an agent wrote runs in that agent's sandbox - #783
Conversation
Codex's review of #771 found that a trigger's `--if` ran as the person, so a gate such as `cd FOLDER && ! ./quiet` ran whatever script an agent had last written there unsandboxed. A gate now runs where its writer's own commands run, as Codex runs whatever an agent wrote. - Daemon (protocol 54): `lend` answers a bot's record with its own capped socket, listening while the asking session lasts; a bot's own socket refuses it. - `agent sandbox --bot NAME [--bot-id ID]` runs a command in that bot's sandbox, with its env setting and its socket; 125 when it could not run. - Sonny records who wrote each gate (`--if-by`) and runs an agent's gate through `agent sandbox --bot`; the person's and Sonny's own run as before. - Upgrade step `agent-gates` asks the lead to add its older gated automations again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
Codex Review Summary: ✅ CompletedThis 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: 22f3b1fc68
ℹ️ 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".
Every new gate's definition now names its writer: an agent (`--if-by NAME --if-by-id ID`) or the person (`--if-by-person`). One with neither was added before this release and could be an agent's, so it no longer runs as the person: its check fails, told once to the agent, until the automation is added again. Sonny's own two gates, the memory cleanup's and an ask's deadline's, still run, recognised by their whole text. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02a32c41e5
ℹ️ 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".
Codex review of #783: - `lend` answers the policy the daemon builds for the bot's commands, its protections and walls included, and their whole environment (the daemon's, without the credentials it holds or withholds), shared with the tool shell (`shell_environment`); `agent sandbox --bot` runs in them in place of its caller's. - An ask's deadline names its fields to `add_sonnys` (an envelope had made every deadline fail to schedule). - An automation keeps the daemon's own socket, not the bot's own a confined shell on macOS has (`SOCKET.d/ID`), which may not lend. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8f57a024b
ℹ️ 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".
… it keeps is the daemon's own socket Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
…-0twv9e # Conflicts: # SECURITY.md
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eac55be130
ℹ️ 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".
A lent command's placeholders for missing protected folders were held in the CLI's own list, apart from the daemon's: whichever side ended first could remove one the other's sandbox still mounted, lifting it there. The daemon now holds the lent policy as one of the bot's own commands until the session closes, and agent sandbox --bot holds nothing itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
…-0twv9e # Conflicts: # sonny/FEATURES.md # sonny/src/trigger.rs
What
Codex's review of #771 found that an automation's
--ifgate runs as the person, unsandboxed, so a gate likecd FOLDER && ! ./quietruns whatever script an agent last wrote there with the person's full permissions. George picked the fix: a gate runs in the sandbox of the agent that wrote it, with that agent's own capped daemon socket, as Codex runs whatever an agent wrote. Gates the person or Sonny added still run as the person.lend.{"op":"lend","bot":NAME,"bot_id":ID?}answers{bot, bot_id, policy, env}.policyis the sandbox the daemon builds for the bot's commands, from the samebot_sandboxits turns call, so every--protect-path,--walland the store stay kept; the bot's own capped socket listens while the asking session lasts.envis the command's whole environment: the daemon's own minus the credentials it holds and what--shell-excludewithholds, built byshell_environment, which the tool shell now shares. Only a session outside every sandbox may lend; a bot's own socket refuses it (not_permitted). A wrongbot_idisbot_not_found.agent sandbox --bot NAME [--bot-id ID] [--store/--socket]. Lends, then runs the command in that policy with that environment in place of the caller's: the bot'senvsetting (so$SONNY_STATE),AGENT_BOT,AGENT_BOT_ID, andAGENT_SOCKETreaching the daemon through the bot's socket (a handed descriptor on Linux, as turns do). An unconfined bot's command runs unconfined, with the same environment. Exits as the command does, or 125 when it couldn't run it (usage, no sandbox, bot not found), asenvandtimeoutdo.--if-by NAME --if-by-id ID), set from the agent whose shell or automations tool added it, or the person (--if-by-person). A fire runs an agent's gate throughagent sandbox --bot; the gate's agent gone means the check couldn't run (a failed fire, told once, as any broken gate is). The person's gates, and Sonny's own (the memory cleanup's, an ask's deadline's), run as the person. An ask's deadline goes through a newadd_sonnys(name, at, gate, message)so its Sonny-written gate stays Sonny's. An automation added from a confined shell on macOS keeps the daemon's own socket, not the bot's (SOCKET.d/ID), which can't lend.'~/.agent/memory' changedand an ask's deadline's'SONNY' ask open 'BOT' TURN 'CALL', recognised by their whole text, so nothing appended to them passes. This is fail-closed, not a migration: the writer can't be recovered from an old definition.agent-gates. Tells the lead its gated automations stopped checking and asks it to add each again withreplace(or name to the person the ones they wrote). A lead re-adds its.nextwhenever it looks. Done once every gate runs.lend,agent sandbox --bot), SECURITY.md Triggers + Known limits, docs/SONNY.md--if, the automation skill (a monitor's gate now has$SONNY_STATE:cd "$SONNY_STATE"/jobs/NAME && ! ./quiet), FEATURES Automations row (the upgrade-step test needs it named there).Goal checks are out of scope: /goal was removed wholesale in #782.
Performance
A person's gate costs what it did. An agent's gate adds one
agentprocess, onelendround trip (the policy plus the daemon's environment, some tens of variables) and the sandbox launch per check. Nothing changes on the turn path: the tool shell's environment comes from the shared function with the same steps in the same order, and the service holds one more map, empty unless a gate runs. Local timings (docs/DAEMON_MEASUREMENTS.md, "An automation gate in its agent's sandbox"): the person's gate 1.4 ms, an unconfined agent's 4.7 ms, a read-only agent's 14.3 ms against 12.2 ms for bareagent sandbox, so the lend is about 2 ms over the sandbox's own launch. The Perf workflow's matched screen (head 3515a11) shows no change past noise on any daemon or Sonny measure (lone submit CPU 31.1 → 30.8 ms, CPU per turn 0.92 → 0.92 ms, idle RSS 15.2 → 15.3 MiB, quiet window 1.54 → 1.34 ms/s); recorded in the same section.Tests
tests/test_cli.py: a command run as a workspace-write bot can't write a daemon--protect-pathand sees neither a withheld daemon variable nor the caller's environment; a command run as a read-only bot sees its variables, reaches the daemon through its own socket, writes nothing, can't lend again from inside (125); an unconfined bot's runs unconfined; a wrong id or a missing bot runs nothing (125,bot_not_found).tests/test_trigger.py: a real fire with an agent's gate runs it in that agent's sandbox (its$SONNY_STATE, no write), a gone identity fails the check with 125, the person's gate still writes as the person, and a gate with no recorded writer runs nowhere.sonny/src/trigger.rs: a gate runs as its writer; one from before runs only when it is Sonny's own word for word (appended commands, another path tosonny, a non-numeric turn all fail);add_sonnys's arguments parse; a capability socket path resolves to the daemon's own;--if-byand--if-by-personround-trip through a definition; the same gate by another writerdiffersonif.src/cli.rs: the new flags.Local, after merging main (with #782's /goal removal; the only conflict was SECURITY.md):
cargo fmt,cargo clippy --workspace --all-targets -D warnings,cargo test --workspacegreen;tests.test_trigger(release runtime, bubblewrap) passes.Upgrade notes
agent sandbox --bot, which needs a daemon that knowslend.ifadded before 0.9.0, except Sonny's memory cleanup and ask deadlines, stops running: its checks fail and it sends nothing until it is added again. A lead re-adds its own.nextwhen it next looks, which, with that check failing, is when the person next writes to it or the upgrade note reaches it (until then that lead isn't woken for what it holds). Theagent-gatesupgrade step asks the lead to re-add the rest and to name to the person any it can't (theirs, or ones its sandbox can't run); the person re-adds those withsonny automation add --replace.quietscript that needs a folder or the network outside the lead's sandbox fails its check (told once) until the person widens the lead's sandbox or adds the automation themselves.🤖 Generated with Claude Code