Skip to content

Each lead gets a writable state folder, named in its shell as $SONNY_STATE (J2) - #771

Merged
lydakis merged 9 commits into
mainfrom
claude/project-thread-0twv9e
Nov 7, 2026
Merged

lydakis merged 9 commits into
mainfrom
claude/project-thread-0twv9e

Conversation

@lydakis

@lydakis lydakis commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

George OK'd the daemon part (the env setting). It takes protocol 53, after #774's 52.

Why

Monitors and trackers kept their files under ~/.agents. Auto keeps .agents read-only, as Codex does, so these jobs failed in Auto within minutes (J2). George decided to keep .agents read-only and give each agent a writable XDG state folder instead, with its path passed in an environment variable. Claude Code does the same for plugins: each gets a data folder named by CLAUDE_PLUGIN_DATA. Codex has no per-agent folder, only shell_environment_policy.set.

What changes

Sonny (sonny/src/state.rs)

  • Each lead gets ~/.local/state/sonny/agents/LEAD, or the same path under $XDG_STATE_HOME when that is an absolute path. Sonny creates it with mode 700.
  • Every permissions row that writes adds it to the writable folders, beside the zen folder (approvals::sandbox(mode, workspace, state)). That covers the lead's own sandbox, its tasks' (start_task), and agents a --start automation makes, which take the state folder of the agent that added the automation.
  • Agents created from an agent's shell inherit their creator's writable folders, so they get it too.
  • There is one folder per lead, not per task. Whatever a task sets up for its lead, such as a monitor, has to outlive the task.
  • /permissions row matching ignores the state folder, the same way it ignores the zen folder.
  • Existing bots pick the folder up the next time their row is set again. A bot keeps the state folder it has. A bot made before this takes its maker's folder, or its own if no one made it.
  • The repository walk is still cached once per pick (Sandboxes). Only the state folder is added per agent.

Daemon (protocol 53)

  • New env setting on create and configure: variables a bot's commands get beside the daemon's environment, like Codex's shell_environment_policy.set.
  • A bot made by another always takes its creator's env, and a change reaches the bots it made, exactly as command rules do. This stops a sandboxed bot from planting PATH or LD_PRELOAD for a command that was approved to leave its sandbox. The kin update returns each bot once, so it stays linear.
  • AGENT_* names are refused, along with names a shell can't set and values containing NUL. The limit is 16 KiB of JSON.
  • Docs: docs/RUST_PROTOTYPE.md settings table.
  • Sonny sets SONNY_STATE on every lead it makes or opens, in every row, Full access included. Tasks take it from their lead.

Where the agent-facing text changed

  • sonny/agents/lead.md, monitor sentence. Before: "do not check it in your own turns: read the automation skill listed under Skills and give it a monitor, its own agent." After: "give it a monitor, its own agent, as the automation skill says, not your own turns. Keep files that outlive a task in "$SONNY_STATE"." This keeps the role within its byte budget.
  • Automation skill: a job's folder is "$SONNY_STATE"/jobs/NAME. An if gate doesn't get SONNY_STATE, so the gate uses the whole path.
  • sonny-config skill lists the folder. The README permissions paragraph says every row that writes writes it, and that ~/.agents stays read-only.
  • sonny/agents/task.md is unchanged because its budget is full.

Security

Codex's security review flagged that an automation if gate such as cd FOLDER && ! ./quiet runs a script agents can rewrite, unsandboxed, as the person. That gap is already on main, because the monitor's own folder held quiet before this PR; this PR adds the lead's other tasks to the agents that can write it. George chose a follow-up PR that runs gates and goal checks sandboxed. It is on the 0.9.0 must-land list.

Performance

  • A few syscalls (mkdir and canonicalize) when a lead is opened or made, or a task is started. None per frame.
  • The shell environment gains one entry per turn. The matched Perf screen is recorded in docs/DAEMON_MEASUREMENTS.md: store work per turn is unchanged and the gate passed.

Tests

  • Unit tests: state::tests; approvals::tests::a_lead_and_its_tasks_write_the_lead_s_state_folder; store contract a_bot_s_variables_are_its_creator_s (inheritance, kin propagation, refusals); every_setting_is_named.
  • sonny/tests/task.rs: a task writes its lead's state folder. Lab shells drop XDG_STATE_HOME.
  • Runtime tests: test_cli (including test_a_bot_s_variables_reach_its_shell_and_the_bots_it_makes) passes locally; test_served's state-folder expectation runs in CI with bubblewrap.
  • cargo fmt --check, cargo clippy -D warnings and cargo test --workspace all pass.

Upgrade notes

  • No migration. A lead gets its folder and SONNY_STATE the next time Sonny opens it or ACP sets it up. Its tasks get them when their row is set again or the lead's env changes.
  • Anything kept under ~/.agents that agents need to write, such as a monitor's folder, moves to the lead's state folder by hand. Update the automation's message and its if path to match.
  • Daemon protocol bump (53), so restart the daemon after upgrading.

FEATURES.md row: goes in the 0.9.0 release PR through wave2-audit/features-rows.md.

🤖 Generated with Claude Code

Sonny makes ~/.local/state/sonny/agents/LEAD (under $XDG_STATE_HOME when
set) for each lead, mode 700, and adds it to the folders every
sandboxed row writes, beside the zen folder: the lead's own sandbox, its
tasks', and agents a --start automation makes for it. A bot keeps the
state folder it was made with; one made before takes its maker's, or its
own, when its row is set again. ~/.agents stays read-only, as Codex keeps
.agents. The roles, the automation and config skills and the README say
jobs and monitors keep their files there.

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

The daemon takes an env setting on create and configure: variables a
bot's commands get beside the daemon's environment, as Codex's
shell_environment_policy.set. A bot made by another always goes by its
creator's, and a change reaches the bots it made, as command rules do, so
no sandboxed bot plants PATH or LD_PRELOAD for a command approved to
leave its sandbox. AGENT_ names stay the daemon's; 16 KiB at most.

Sonny sets SONNY_STATE to the lead's state folder on every lead it makes
or opens, in every permissions row, and tasks take it from their lead.
The FEATURES.md row moves to the release PR's list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGNwXWgNygYbrrZ9DK
… fit their budgets

The lead role names $SONNY_STATE in one short line within its budget; the
task role is unchanged, its budget being full, and the automation skill
tells a task that sets up a monitor where its files go.

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

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T05:39:33.586810Z c83e4df New commits
🔒 Security Review ✅ Completed 2026-11-07T03:33:10.383086Z 0382fab PR opened

Security findings

Advisory findings (1)

ℹ️ 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: 0382fab30f

ℹ️ 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/state.rs Resolved
Comment thread sonny/src/main.rs Resolved
Comment thread sonny/src/main.rs Resolved

@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 Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 0382fab30f

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sonny/src/approvals.rs Resolved

@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: abc1586f99

ℹ️ 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 src/store/db.rs Resolved

@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: 0c40eb7333

ℹ️ 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 src/server/turn.rs Resolved
@lydakis
lydakis merged commit cc4fb6c into main Nov 7, 2026
5 checks passed
@lydakis
lydakis deleted the claude/project-thread-0twv9e branch November 7, 2026 06:06
lydakis pushed a commit that referenced this pull request Nov 7, 2026
…w takes one

#776 and #771 each built on their own; together the deadline cleanup in
asks.rs called trigger::tool with one argument. Same line as #785.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGYoqceB21grsa5Q3v
lydakis added a commit that referenced this pull request Nov 7, 2026
…ons where the call lands (#782)

* Remove goals: the goal tool, /goal, and the lookout's check runner

George never used goals, and their check runner made the lookout run
work (a command for up to an hour, then another turn for the agent)
rather than only watch and tell. Gone with them: the `checking` and
`checked` task states, the lookout's hold on a goal's turns, the sky's
goal pulse, and the tool process budget's quarter for checks, so the
tool host now has all of `sonny.tool_processes`. A one-time migration
removes STORE.lookout/goals (retires 0.11.0).

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

* Keep a lead's reaction in a task where its react call lands

A lead reacting in one of its tasks named the task, and the lookout
followed every bot's newest message to find which of the person's words
it landed on, then wrote the task's Picked file. That is work only the
window needs, done by the companion that exists for agents while no
window is open.

Sonny's tool host now answers `react`: one naming another agent of the
same project is kept under the person's newest message there as the call
is answered; one on the caller's own messages is answered at once. The
lookout drops its reaction tracking, and nothing watches the stream for
reactions.

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

* Answer react in the tool host itself, and drop retired Sonny tools on refresh

The tool host answered react by spawning a `sonny tool` process like any
other served call, behind the process budget. Now it answers it in its own
process, as it takes the call: a reaction on the caller's own messages is
"Done." with no process, one naming a task lands on what the person had
written when it was taken, and those that write the task's file take
turns, so two never overwrite each other.

A bot made before goals were removed kept `goal` declared through every
refresh, since only this build's tool names counted as Sonny's. A
declared tool Sonny answers (`answered_by: sonny`) now counts as Sonny's
too, so a refresh drops one this build no longer has.

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

* Pass the ask deadline's trigger removal a caller, as trigger::tool now takes one

#776 and #771 each built on their own; together the deadline cleanup in
asks.rs called trigger::tool with one argument. Same line as #785.

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

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 7, 2026
… each stands (#787)

* Questions: close_ask's deadline removal passes the caller trigger::tool now takes

#776 and #771 merged in turn: #771 gave trigger::tool a caller, and
#776's close_ask still called it without one, so main did not build.
Removal ignores the caller, as the deadline's creation does.

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

* sonny ask list: the questions a lead's agents asked lately and where each stands

The ask description points agents at it before asking; the sentence on
what to do meanwhile moves out, since every ask result already says it.

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

* sonny ask list: --all goes on as --all, a yes says what it covers, a node's questions stay together, a fork leaves its source's question to it

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

---------

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