Skip to content

Approver: only the person may let a call reach ~/.agent - #630

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-di7sns
Nov 1, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-di7sns

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Why

In row 10 of the Monday rehearsal, the reviewer allowed an escalated command that wrote ~/.agent/triggers/jobs/x. The scheduler runs that job as the person, outside every sandbox. --protect-path ~/.agent (#587) holds only inside the sandbox, because an escalated command runs unconfined. The judge's policy also still listed "the agent's own … triggers … under ~/.agent" as ordinary low work. That wording dates from before agents had the triggers tool, so by its own rules the 2.6 s allow was correct.

George picked option B from the options doc: https://claude.ai/artifact/1wczPNrRgGsFZG1HAJKTar

What changes

Judge policy (client/src/approver.rs, policy!()):

  • Ordinary work drops "triggers": it now reads "the agent's own plan, memory, and task folders under ~/.agent".
  • The approval channel (critical) now also covers writing, moving or deleting the scheduler's jobs (~/.agent/triggers), the command rules (~/.agent/rules), or the scripts Sonny writes in ~/.agent, other than through Sonny's own tools.
  • Persistent security weakening now names changing ~/.agent/config.toml or ~/.agent/env directly. It is denied unless the person asked for that exact change.

A rule over the verdict (agent_client::approver::Home, own_home; sonny/src/approver.rs): the approver never allows a call that reaches ~/.agent on the judge's word alone, unless the call stays inside a folder the agent was given in there (a task's worktree, the zen folder). If the judge would allow such a call, it becomes a doubt and waits for the person in /permissions. A denial stays a denial.

  • write, edit, apply_patch: checked by the path the change resolves to, lexically and through links.
  • shell: only a command that would run outside the sandbox (escalated, or the bot has no sandbox). The check matches any path word with .agent as a whole part, reading ~, $HOME and ${HOME} as the home and resolving relative words from workdir or the turn's folder.
  • A lead in $HOME gets no pass: its folder holds the home, which its sandbox keeps read-only.

No daemon or protocol change.

Differences from Codex and Claude Code (documented in docs/APPROVALS.md)

  • Codex's guardian may approve writes to ~/.codex. We hand those to the person.
  • Claude Code's default auto mode routes writes to its own paths to the classifier. We follow its --restricted behaviour, where only the person may allow them.
  • Known limits, also documented: the command check reads words, so a command that spells the name another way is left to the judge. A command that an allow rule lets out is not reviewed at all, as in Codex.

Tests

  • cargo fmt --all --check, cargo clippy -p sonny -p agent-client --all-targets -- -D warnings, cargo test -p sonny -p agent-client: all pass.
  • New tests: the verdict rule and policy wording; files in and out of the home and in the folders given there; command spellings (~, $HOME, ${HOME}, absolute, quoted, --config=, cd) and look-alikes (.agents, my.agent.name, a project's own ./.agent); a sandboxed command that doesn't escalate is left alone; a write through a link into the home; a patch; Sonny's triggers tool left alone.

The Monday rehearsal had the reviewer allow an escalated command that
wrote ~/.agent/triggers/jobs/x, a job the scheduler runs outside every
sandbox. --protect-path holds only inside the sandbox, and the judge's
policy still called triggers under ~/.agent ordinary work, from before
agents had the triggers tool.

The policy now rates raw writes to the scheduler's jobs, the command
rules and Sonny's scripts in ~/.agent as the approval channel, and
changing config.toml or env directly as persistent weakening. And Sonny's
approver never allows a call that reaches ~/.agent outside the folders
the agent was given there on the judge's word: a write, edit or patch by
the path it resolves to, or a command that would leave the sandbox by any
path word holding .agent. What the judge would allow waits for the
person, as Claude Code's --restricted keeps its own paths from its
classifier; a denial stays one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFS1nm7W5mbwsNK4BH
@lydakis lydakis self-assigned this Nov 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T19:57:05.954835Z 3dff491 New commits
🔒 Security Review ✅ Completed 2026-11-01T19:51:08.108914Z 9630f1f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9630f1fb93

ℹ️ 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".

Comment thread sonny/src/approver.rs Resolved
Comment thread client/src/approver.rs Resolved
Each folder the agent was given in the home is kept as the daemon has it
and as $HOME/.agent spells it, so a worktree named through a linked
~/.agent still counts as the agent's own; the command check matches the
home by its real path too. The home is resolved in the blocking task
with the per-call checks, so a slow mount can't hold up lease renewal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGFS1nm7W5mbwsNK4BH
@lydakis
lydakis merged commit 063957d into main Nov 1, 2026
10 checks passed
@lydakis
lydakis deleted the claude/project-thread-di7sns branch November 1, 2026 20:20
lydakis added a commit that referenced this pull request Nov 1, 2026
* Sonny: triggers are automations, for the person and for agents

The person's word for them is automation, so agents, who talk to the
person, now read and say it too: the `automations` tool with `run`, the
`~/.agent/automation` script, `sonny automation`, `/automations`, the
`[automation NAME · ...]` headers, `origin: "automation"` and the
automation_* error codes. Internal names (trigger.rs, request ids,
--trigger-fire, scheduler labels) stay.

Upgrade: the first 0.8.0 Sonny, scheduler or script to look moves
~/.agent/triggers to ~/.agent/automations, and Sonny's old
~/.agent/trigger script goes (migration automations-folder, retired in
0.10.0). History with origin "trigger" and old tool calls still read as
an automation's. The memory cleanup schedules through the new script.

The role eval gains an `automation` day (set up, list, run, remove) and
accepts the old names so an arm of an older build compares.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: the runtime test adds from an agent's shell with the automation script

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: a broken --if fails the automation's run

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: an automation's turn cap says it counts the agent's history

Agents set their own jobs caps of 4k to 12k tokens, and every first run
failed on 29k to 42k of the agent's history. The tool and the skill now say
what the cap counts and to set one only when the person asks for a
spending limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: the triggers folder moves only once nothing works in it

A fire of the old Sonny keeps its paths to its end, so moving the folder
under it lost its result and could run a one-off again (Codex review).
Places::moved takes the folder's files lock, its scheduler's and every
fire's first; while any is held, everything works in the old folder, and
the scheduler, which holds its own, moves it within a minute of the last
fire ending and runs again from the new place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: #630's approver lines and tests name the automations folder and tool

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: the old triggers path links to the moved folder

An add that chose ~/.agent/triggers before the scheduler moved it wrote
there after the move, where nothing reads (Codex review). The move now
leaves ~/.agent/triggers as a link to automations, made while the files'
lock is held, and a writer that finds neither between the move and the
link gets automations_moved rather than making the old folder again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: a restore's list and the backup's list keep their pre-0.8.0 names readable

restored-triggers.json, left by a restore for leads not opened yet, becomes
restored-automations.json when next read; a backup's triggers.json is read
when the copy has no automations.json and goes at its next sync (Codex
review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: the automations folder moves through upgrade::once, and a backup during a pending move keeps the old folder's list

The folder's move and the restored list's rename are one migration run by
upgrade::once wherever the folder is found, so its completion is recorded
in ~/.agent/sonny/migrated; a HOME without ~/.agent gets no record (the
scheduler's gone-HOME guard). Sonny's old ~/.agent/trigger script is its
own migration, automation-script, at Sonny's start. home sync reads the
active folder, so a sync while the move waits keeps triggers.json's
replacement instead of deleting it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: a restore's list is renamed without waiting for the automations folder to move

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

* Sonny: the background-command row reads as an automation's run

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGD7saFpzzSnMyV12Dg

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants