Skip to content

fix(cli): a confined Seatbelt turn's write grants hold only for the folders the CLI made - #3519

Merged
lilyshen0722 merged 2 commits into
mainfrom
cto/f197-seatbelt-state-pin
Nov 5, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
cto/f197-seatbelt-state-pin

Conversation

@lilyshen0722

@lilyshen0722 lilyshen0722 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

@coderabbitai ignore

A confined macOS Seatbelt turn's write grants now hold only for the folders the CLI meant to grant. Public seats also always reap the processes their turn started.

What changes

  • Pinned write grants. buildSeatbeltProfile pins the state folder on every seat, and the writable scratch workspace on public seats. A turn is refused unless the folder isn't a link and its realpath is its parent's realpath plus its own name. The error names the folder.
    • The CLI creates both of these folders, so neither is ever a link on purpose.
    • An operator-chosen workspace on a workspace-trust seat keeps today's link-following grant. The profile can't tell an operator's link from any other, and refusing it would break working setups.
  • Every adapter. claude passes pinWorkspace on public trust. pi, opencode, goose and qwen pin always, because they build a Seatbelt profile only for public seats. dsh refuses public trust, so it's unchanged.
  • Reaping. A public Claude Code seat no longer honours COMMONLY_KEEP_PROCESS, so every process the turn marked is reaped. The reap log names any pid that asked to stay. Workspace-trust seats keep the setting (packages/seats/src/turn-processes.js: markTurn({ confined }), honorKeep).
  • Docs. docs/cli/README.md notes the public-seat exception on the COMMONLY_KEEP_PROCESS row.

Tests

  • seatbelt.test.mjs: 31/31.
  • adapters.claude.state-symlinks.test.mjs: 30/30. Covers a folder replaced by a link after prepare, refused with no spawn; a public workspace link refused; a workspace-trust operator link granted at its target.
  • turn-leftovers.test.mjs: 6/6, with real processes.
  • packages/seats: 264/264.
  • Every guard was reverse-checked.
  • Other adapter suites (opencode, goose, pi, qwen, codex, dsh) pass.
  • adapters.claude.environment has the same one bwrap failure as main (environmental).

🤖 Generated with Claude Code

https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw

lilyshen0722 and others added 2 commits November 5, 2026 04:19
…e folder, and a public seat reaps every process it started

- buildSeatbeltProfile pins the state folder, and on public seats the
  writable scratch workspace: the turn is refused unless the folder is not a
  link and its realpath is its parent's realpath plus its own name. Both are
  folders the CLI creates. An operator-chosen workspace on a workspace-trust
  seat keeps today's link-following grant, since the profile cannot tell an
  operator's link from any other.
- A public seat no longer honours COMMONLY_KEEP_PROCESS: every process the
  turn marked is reaped, and the reap log names the pid that asked to stay.
  Workspace-trust seats keep the setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw
…every public Seatbelt adapter has a test for it

- qwen passes pinWorkspace on its public Seatbelt profile.
- qwen, pi, goose and opencode each get a test that a public seat whose
  workspace is a link is refused with nothing spawned; dropping the flag from
  any adapter fails its test.
- pinnedRealpath resolves its input first, so a trailing "." is checked
  against the real folder.
- Comments: a public seat given environment.workspace.path that is a link is
  refused; the reaper comment says only that the pin is the boundary.
- The confinement probe script builds the public profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

HEAD: f75b874 — GATE: PASS

This is an Opus review. The first round at b8fd4fc was a HOLD, because a public qwen Seatbelt profile left its writable workspace unpinned. f75b874 fixes that.

Every public file-write* grant is now pinned.

  • claude: pinned on public trust. A workspace seat that gets downgraded arrives as public.
  • qwen, pi, goose and opencode: pinned. Each one builds a Seatbelt profile only on its public path.
  • dsh: refuses public trust, so it only ever runs private.
  • The state folder is pinned on every caller.
  • The only other write rules are fixed /dev paths.

Pin check

  • pinnedRealpath resolves its input before comparing, so a trailing . is caught.
  • The grant uses that same resolved path.

Time between check and use

  • Seatbelt checks each access against its resolved path.
  • After the check, a swap can only break that turn's own writes.
  • A link inside the granted folder is denied.

Tests: seatbelt 32/32 and qwen 20/20. On a scratch copy, removing qwen's pin and removing the resolve each turn the matching new test red. Each public adapter has a test that fails if its flag is dropped.

Reaper: it re-reads each process's start time before SIGTERM and SIGKILL, so a reused pid is skipped.

Comments: they're neutral.

Filed, not blocking:

  • F200: a workspace-trust seat can replace its operator workspace with a link within one turn.
  • F201: public codex seats still honour COMMONLY_KEEP_PROCESS.

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 535caa0 Nov 5, 2026
39 of 41 checks passed
lilyshen0722 added a commit that referenced this pull request Nov 5, 2026
…ame confinement rule as Claude Code and Codex (F175a)

Squashed onto main 06798fa to clear a test-file conflict with #3519 (both sides
added tests at the end of adapters.opencode.test.mjs; both kept). Earlier
heads: 3fcd909, ae2bd1f, 4c8b485.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw
lilyshen0722 added a commit to KGKallasmaa/commonly that referenced this pull request Nov 10, 2026
…a public Claude Code seat does (F201) (Team-Commonly#3522)

Team-Commonly#3519 made public Claude Code seats ignore COMMONLY_KEEP_PROCESS when a
turn ends. Codex still marked its turns without `confined`, so a public
Codex seat kept a process the turn asked to keep. runCodex now passes
`confined` for a public seat (publicSandboxMode !== null, which codex only
sets for trust: 'public'); markTurn turns that into honorKeep: false.
Private Codex seats are unchanged.


Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
lilyshen0722 added a commit to KGKallasmaa/commonly that referenced this pull request Nov 10, 2026
…nfined seat (D252, F175a) (Team-Commonly#3487)

* feat(cli): OpenCode joins the connector grant broker set, under the same confinement rule as Claude Code and Codex (F175a)

Squashed onto main 06798fa to clear a test-file conflict with Team-Commonly#3519 (both sides
added tests at the end of adapters.opencode.test.mjs; both kept). Earlier
heads: 3fcd909, ae2bd1f, 4c8b485.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw

* test(cli): the opencode worktree fixture is a real worktree, and the .GIT write probes case folding

Linux CI (git 2.56) failed two tests that pass on macOS:
- The worktree test pointed a .git file at a repo that didn't exist, so git
  failed before the containment check. It now builds a real linked worktree.
  With git answering, the core.worktree check fired first and blamed a
  setting that isn't there, so the credential-containment check now runs
  before it. Which workspaces are refused is unchanged; only the message is.
- The fsmonitor/hooks test wrote through .GIT/config, which doesn't exist on
  a case-sensitive filesystem. A real probe of the temp dir picks the spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DPFVAooJnqCSwrdxVw

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant