swarm: worker sandbox can corrupt the shared worktree admin — in-sandbox git worktree repair killed run 1649's sibling worker #239
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#239
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happened (healer-diagnosed, human-verified)
Swarm run 1649 (2026-07-31 21:30) went red at
stage=sandcastle run (workers):The trigger is in the sibling worker's log (
-447133, issue #234). Its workspace's recorded worktree path didn't match the container mount, which brokenix develop .#go-cigit evaluation and would have blocked the #198 pre-push gate. To unblock it, the worker rangit worktree repairinside the sandbox. Because every.sandcastle/worktrees/<name>shares the parent repo's.git/worktrees/admin directory, that rewrote the admingitdirpointer to the container-only path/home/agent/workspace— so when Sandcastle set up the sibling worker's worktree in the same run, git refused it ("is not a working tree") and the run died.Impact was partial: #234's commit
18ebc92had already merged; only the sibling worker was lost. The post-run sweep cleaned the admin; later runs recovered (#233, #238 landed).Why this is a class, not a one-off
git worktree prunemishap in-sandbox.sandcastle/worker/*→mainmerge with a preserved branch.git worktree repairto get the gate through — this WILL recur.Evidence:
/tmp/matou-heal.YCPvq8on matou-workstation (worker log lines 53–55 show the repair with before/aftergitdir), healer ledger sig424240d0561a, Mattermost threadz7od1s4w5bffum8yrm8uc5d16a.The design call (pick one or combine — needs a ruling)
git worktree repair. Recommended: removes the incentive rather than policing it..git/worktrees/, so no in-sandbox git command can touch shared admin. Costs disk/setup time per worker.git worktree repair|prunein the worker prompt/gate on the shared repo. Cheapest, but prompt-level fences are advisory and the underlying mismatch keeps biting (nix evaluation stays broken until repaired).A pragmatic combination is 1 + 3: fix the mount/path agreement so nix evaluation works out of the box, and fence
repair|pruneas a backstop.Acceptance (once ruled)
nix develop .#go-ci) without running anygit worktreeadmin command..git/worktrees/state.Related: #235 (healer signature fidelity — validated on this incident), #238 (swarm queue hygiene), #197.
Ruling (Ben, 2026-07-31): go with the suggested combination — options 1 + 3.
nix develop .#go-ciout of the box — workers must never need to rungit worktreeadmin commands.git worktree repair|prune(and any mutation of the shared parent.git/worktrees/admin) out of the worker sandbox via the worker prompt/gate.Option 2 (per-worker clones) is NOT taken — keep worktrees.
Acceptance criteria in the issue body stand. This is
.sandcastle/harness work; ready-for-agent.Shipped in
93c6afb(onmain), per Ben's ruling (options 1 + 3).Root fix (1) —
.sandcastle/align-worktree.sh, run first inmain.mts'sonSandboxReady, re-points ONLY this worker's own worktree admin back-link (.git/worktrees/<name>/gitdir) at the container mount (<toplevel>/.git) via a direct one-file write in.sandcastle/worktree-lib.sh— never agit worktreecommand, never a sibling's entry.nix develop .#go-ci(the #198 pre-push gate) now evaluates the flake cleanly with no repair needed, and two parallel workers cannot touch each other's shared.git/worktrees/state.Backstop (3) —
.sandcastle/git-fenceinstalls as/usr/local/bin/git(ahead of apt's git, via the Dockerfile) and refuses the mutatinggit worktreeoperations (repair/prune/add/remove/move/lock/unlock) inside the sandbox, passing every other git invocation through.prompt.mdrule 8 is the advisory layer.Acceptance:
git worktreeadmin command — the back-link is aligned at startup, so the flake evaluates; the worker never needs (and, via the fence, cannot run)repair.tests/worktree-lib-test.sh.giton PATH and runsgit worktree repairfrom a worker checkout while a sibling is mid-setup: the repair is refused, the sibling's admin is byte-identical, and the sibling stays a valid working tree.Evidence:
.sandcastle/tests/worktree-lib-test.sh(21 checks passing offline — no container, no nix). Sibling gate/sweep tests still green. The host post-run sweep is unaffected (it runs on the host, where the shim is not installed).Follow-up (2026-08-01): the landed fix
93c6afbregressed — replaced by the worktrees mount (0fb0d70).The in-container back-link write persisted through the bind-mounted
.git/worktrees/admin to the HOST, so the host's own merge-to-head lost the worker's worktree the moment the container exited — every swarm run from 1654 (22:56) reded at the workers stage withWorktreeError: … is not a working tree. Worker pushes still landed; only host bookkeeping threw. The healer diagnosed it six times at high confidence (evidence/tmp/matou-heal-Matou-ourcloud.*on matou-workstation) but each run minted a fresh signature — the worker name's 6-hex suffix defeatsnormalize_error_line's 7-char hex floor — so the ledger's dedup never engaged and every run posted to Mattermost (fixed ina0f1e02).The standing fix (still Ben's option 1, implemented without writes):
main.mtsnow mounts.sandcastle/worktreesat its host path inside the sandbox, so the admin back-link resolves identically in both environments and nothing ever rewrites shared admin.align-worktree.shis unwired and must not return toonSandboxReady;git-fence(option 3) stays as the backstop. Offline suites green (heal-lib 13, worktree-lib 21).reset --hard origin/mainmid-run is attributed to the worker and DELETES main-owned machinery (run 57327 lost #2099) #2104