Skip to content

fix(code): a citizen's git works in her card worktree — the gitdir and common dir are granted (held for Joel's read) - #5116

Closed
joelteply wants to merge 1 commit into
canaryfrom
fable/worktree-git-grant
Closed

joelteply wants to merge 1 commit into
canaryfrom
fable/worktree-git-grant

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Split out of #5112 at Cormac's request so the reviewed parts there can merge; this commit is the confinement change alone (core/continuum-core/src/code/confinement.rs, +84).

Defect: confinement had no gitdir/commondir handling. A card checkout is a git worktree whose .git file names a gitdir under the main checkout's .git; her hands were granted the worktree and denied the rest of $HOME, so git status in her own worktree answered fatal: not a git repository: …/.git/worktrees/cc2db61d while her test -e on the path said EXISTS (Benchy 15:34Z, Aiko's worktree 1b232595 likewise). Every confined citizen's git has been dead since #4882 (10/9).

Fix: worktree_git_dirs grants the gitdir and the common dir for write, guarded by git's own back-pointer (<gitdir>/gitdir must physically name this checkout's .git): a forged .git file grants nothing; a symlinked pointer is resolved physical first; a commondir outside the .git holding the gitdir is dropped. Credential carve-outs still apply.

Scope (the open concern, Cormac → Joel): the grant is the whole common .git of the one repository her card lives in — every branch's refs and objects — which git's worktree model needs for a commit, and the reach she had before confinement for that repo and no other. The narrower design (card checkouts as clones with a shared object store; grant = one directory under her workspace) is airc's seam, not confinement's.

Measured

  • Test: a_card_worktree_gets_its_gitdir_and_common_dir_and_a_forged_link_gets_nothing; confinement tests 4 passed, 0 failed (M5, metal,accelerate).
  • Live (M5, core 3ad1300 which carries this commit's content): Benchy 18:02:49Z in ~/.airc/worktrees/cc2db61d under confined hands — git status --short exit 0, git log --oneline -3 lists her branch, git branch --show-current → cc2db61d/source-hygiene-ratchet-a-fn-inserted. Same command: fatal: not a git repository at 15:34:47Z on the previous core.

Hold: not to be merged or deployed beyond the M5 until Joel or root has read the scope concern.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…d common dir are granted

Confinement had no gitdir/commondir handling. A card checkout is a `git worktree` whose `.git`
FILE names a gitdir under the main checkout's `.git`; her hands were granted the worktree and
denied the rest of $HOME, so `git status` in her own worktree answered "fatal: not a git
repository: …/.git/worktrees/cc2db61d" while her `test -e` on the path said EXISTS (Benchy,
M5, 15:34Z 2026-10-16); the same for Aiko's worktree 1b232595. Every confined citizen's git had
been dead since #4882 (10/9), so no citizen could commit.

`worktree_git_dirs` grants the gitdir and the common dir for write, guarded by git's own
back-pointer (`<gitdir>/gitdir` must physically name this checkout's `.git`): a `.git` file she
forged toward another repository cannot carry that back-pointer and grants nothing; a symlinked
pointer is resolved physical before the check; a commondir outside the `.git` that holds the
gitdir is dropped. The grant is the whole common `.git` of the ONE repository her card lives in
(every branch's refs and objects): git's worktree model needs it for a commit, and it is the
reach she had before confinement for that repo and no other. Credential carve-outs still apply.

Measured (M5, 3ad1300 which carries this): Benchy 18:02:49Z in ~/.airc/worktrees/cc2db61d
under her confined hands: git status exit 0, git log shows her branch, git branch
--show-current → cc2db61d/source-hygiene-ratchet-a-fn-inserted. Test:
a_card_worktree_gets_its_gitdir_and_common_dir_and_a_forged_link_gets_nothing (confinement 4/4).

Held for Joel's read (Cormac, #5112): the scope of the common-.git write grant.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
(cherry picked from commit 516276b)
@joelteply
joelteply force-pushed the fable/worktree-git-grant branch from 516276b to 98652b1 Compare October 16, 2026 19:09
@joelteply

Copy link
Copy Markdown
Contributor Author

Rebased as one commit on canary (98652b1 = 150fd2f + the grant; the branch had been cut from #5112's lineage and was CONFLICTING). Mergeable now; CI running. Hold unchanged: Joel's read.

joelteply added a commit that referenced this pull request Oct 18, 2026
…recious mirror; confinement reads only the mirror's objects (card 573cc58a, airc half d166e4f2)

card_staging::stage_for_card made the card's checkout a worktree of
repo_registry's clone, which for continuum is the DEPLOY checkout. Every
resident's card was therefore registered in the deploy repo's .git (M5:
.git/worktrees/cc2db61d). git under confinement failed there, and #5116
could only fix it by granting write on that .git. Joel: do it right.

- card_staging: ensure_mirror(repo, registry clone), then
  ensure_card_clone from the mirror (airc-lib, airc #1581). The
  checkout is at the same worktree_path_for path; its .git is inside it,
  objects are borrowed through alternates, and origin is the real
  remote, so the carry pushes.
- confinement: each ~/.airc/mirrors/*/*.git/objects is a READ-only root
  (canonicalised with every root). No write root is added anywhere, and
  nothing of a mirror but its objects is readable.
- disk governor: TrackedDir airc-mirrors, with a decided deferred
  eviction: whole-mirror removal only when no live card clone names it
  in its alternates. Never prune in place; preciousObjects refuses it.

Test (macOS, real sandbox-exec):
  on_macos_a_card_clone_reads_its_mirror_and_commits_but_cannot_write_the_mirror.
  Her git reads the borrowed base, her commit lands, and a write into
  the mirror's objects is refused by the OS.

Not in this commit: the airc-lib pin bump (needs #1581 merged) and
migration of existing linked worktrees (follow-up card).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 18, 2026
…recious mirror; confinement reads only the mirror's objects (card 573cc58a, airc half d166e4f2)

card_staging::stage_for_card made the card's checkout a worktree of
repo_registry's clone, which for continuum is the DEPLOY checkout. Every
resident's card was therefore registered in the deploy repo's .git (M5:
.git/worktrees/cc2db61d). git under confinement failed there, and #5116
could only fix it by granting write on that .git. Joel: do it right.

- card_staging: ensure_mirror(repo, registry clone), then
  ensure_card_clone from the mirror (airc-lib, airc #1581). The
  checkout is at the same worktree_path_for path; its .git is inside it,
  objects are borrowed through alternates, and origin is the real
  remote, so the carry pushes.
- confinement: each ~/.airc/mirrors/*/*.git/objects is a READ-only root
  (canonicalised with every root). No write root is added anywhere, and
  nothing of a mirror but its objects is readable.
- disk governor: TrackedDir airc-mirrors, with a decided deferred
  eviction: whole-mirror removal only when no live card clone names it
  in its alternates. Never prune in place; preciousObjects refuses it.

Test (macOS, real sandbox-exec):
  on_macos_a_card_clone_reads_its_mirror_and_commits_but_cannot_write_the_mirror.
  Her git reads the borrowed base, her commit lands, and a write into
  the mirror's objects is refused by the OS.

Not in this commit: the airc-lib pin bump (needs #1581 merged) and
migration of existing linked worktrees (follow-up card).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Closed unmerged, superseded by #5132 (Joel 2026-10-17: "do it right"). Instead of granting the deploy repo's .git to residents, a card checkout is now its own clone, borrowing objects from a precious mirror (airc #1581 and #1582), and residents' credential access is decided in #5170. — Cormac (IntelMac)

@joelteply joelteply closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant