Skip to content

Sonny: each repository inside an agent's folder keeps what git runs - #444

Merged
lydakis merged 2 commits into
mainfrom
claude/project-thread-5nccau
Oct 30, 2026
Merged

lydakis merged 2 commits into
mainfrom
claude/project-thread-5nccau

Conversation

@lydakis

@lydakis lydakis commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #414.

Why

The daemon's sandbox keeps .git/hooks and config read-only only at the top of a writable folder. A sandboxed agent whose folder holds repositories below its own, such as a workspace of packages, could write their hooks and config. Git then runs those as the person, outside any sandbox: the next git the person runs there, or Sonny's own git worktree add for a task given folder (#409).

George's call: the daemon shouldn't care what a bot does; the client decides. No daemon change is needed. The daemon already guards any git folder (.git, NAME.git) a client gives in writable: hooks, config, config.worktree, modules and commondir stay read-only, and commits still work. Sonny already does this for a folder's own repository.

What

approvals::sandbox (every lead and task Sonny configures) now also gives each repository inside the agent's folder as a writable git folder of its own. It looks for them:

  • up to six folders down;
  • in at most 10,000 folders, so a start never walks a whole tree;
  • never inside a repository's own tree, a hidden folder, or through links.

A linked checkout's .git file names a folder elsewhere and is left out. A repository cloned later leaves the agent's recorded sandbox stale, so it is picked up the next time Sonny starts or reconfigures the agent. A repository the agent makes itself is its own, which is where Claude Code draws the line too. At most 64 folders, the daemon's bound, keeping the shallowest.

FEATURES.md: the sandbox row's history.

Tests

  • approvals::tests::the_repositories_inside_an_agent_s_folder_are_given_as_folders_of_their_own:
    • repositories found two and three folders down;
    • left out: one inside another repository's tree, one in a hidden folder, one too deep, and a .git file;
    • a later clone makes the sandbox stale.
  • tests/test_approvals.py pins the daemon behavior this relies on. With a nested .git given in writable:
    • a commit there works;
    • writing its hooks or config, or moving .git aside, fails;
    • a repository the bot makes stays its own.

Locally, cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, the Sonny tests, and the new runtime test (with bubblewrap) pass.

A sandboxed agent could write the hooks and config of a repository inside
its folder, below its own, which git then runs as the person. Sonny now
gives each such repository's .git as a writable folder of its own, as it
gives the folder's own repository: the daemon keeps a git folder's hooks,
config, submodules and commondir read-only, and commits still run without
asking. Repositories are looked for up to six folders down, never inside
a repository or a hidden folder, nor through links; one cloned since
makes the sandbox stale, so it is given on the next start. A repository
the agent makes is its own, as Claude Code draws the line.

Closes #414.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGCrDV3wjc6rUfmxAoc
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-10-30T05:32:54.887214Z fcb7d5a PR opened
🔒 Security Review ✅ Completed 2026-10-30T05:37:53.317201Z fcb7d5a 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.

lydakis commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

The macos job failed in one daemon test, provider::tests::a_stream_that_only_pings_stalls_after_its_last_content (src/provider.rs:2887): it got "012" where it expected "012345". That test checks streaming timing against a stall bound. This PR doesn't touch the daemon or provider code; it changes only sonny/src/approvals.rs, sonny/FEATURES.md and one runtime test. The failure is the timing test running slow on the macOS runner, not this change. I can't re-run jobs from this session, so no fix is ported here. The rust and runtime jobs decide this PR.


Generated by Claude Code

@lydakis
lydakis merged commit 0f8e0e9 into main Oct 30, 2026
3 of 4 checks passed
@lydakis lydakis mentioned this pull request Oct 30, 2026
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.

Sandbox: protect nested repositories' .git, not only the root's

2 participants