swarm harness: Sandcastle merge-to-head can still fast-forward local main onto an unpushed orphan (defense-in-depth residual of #1717) #1739
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#1739
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?
Follow-up from #1717 (ask 3 — the deeper defense-in-depth half).
#1717 landed the mechanical fix that eliminates the incident at its source:
git-hooks/commit-msgrefuses a swarm worker's commit for a ticket its run never claimed, and the# Donere-check is now a completion test rather than a work order. Because no orphan is ever committed, it can never fast-forward the shared workdir's localmain— the run-29782SyncError's true cause is gone.What #1717 deliberately did not do is ask 3's standalone defense-in-depth: "don't fast-forward local
mainonto an unpushed orphan." That fast-forward happens inside Sandcastle's ownbranchStrategy: merge-to-headstep (@ai-hero/sandcastle), between iterations, on the host workdir. Our harness has:.sandcastle/main.mts— "Sandcastle offers no between-iteration host hook"), andSo a clean fix here needs Sandcastle library support (e.g. refuse to merge a worktree branch onto a local
mainthat has diverged fromorigin/mainwith un-pushed commits, or a between-iteration reset-to-origin/mainhook).git-setup.sh's next-tickreset --hard origin/mainalready masks the cross-run case; the residual is the same-run second-iterationSyncError, which only arises if an unclaimed orphan exists — which #1717 now prevents.Why this is not just done in the vendored harness: a fetched-dependency patch is a one-way / unprovable-offline door (a seam-fake models merge-to-head as success), and there is no host hook to reset between iterations. Route to whoever owns the Sandcastle dependency pin; likely worth raising upstream.
Proposed default (adoptable under ADR 0174 once a seam exists): between iterations, if local
mainis ahead oforigin/mainwith commits absent fromorigin,reset --hard origin/mainbefore the next iteration's merge.Filed by agent under ADR 0174 while closing #1717.
# Donestaleness re-check — duplicate work, and the orphan commit poisons localmaininto a SyncError #1717Ruled by agent under ADR 0174 — veto anytime.
Ruling:
ready-for-session(categorybugstays). Notready-for-agent, notready-for-human.The ruling. The residual defense-in-depth fix lives in protected
.sandcastle/paths and/or the vendored@ai-hero/sandcastledependency pin — a swarm worker must not touch either (.sandcastle/prompt.md:126, #445). An interactive agent session owns that pin and can raise the fix upstream or add a between-iteration reset once a seam exists. This needs a session's standing, not Ben's — patching a dependency pin / adding areset --hard origin/mainbetween iterations is none of the ADR 0174 one-way-door residues (no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend, no physical hands/eyes).Why not
ready-for-agent. Two reasons, both fatal to a swarm brief: (a) the change is in protected paths (.sandcastle/main.mts,.sandcastle/git-setup.sh, or the vendored dependency) that the swarm queue is barred from by construction; (b) the issue itself notes the clean fix is unprovable offline — a seam-fake models merge-to-head as success — so there is no existing test/drive that a worker'sclose-reportcould gate on.Why this is a two-way door (so an agent may rule it). The routing is revertible by a single label change, and it is provable against the tree as it stands today:
.sandcastle/main.mts:139records the absent between-iteration host hook;:279setsbranchStrategy: merge-to-head..sandcastle/git-setup.sh:92already does the cross-runreset --hard origin/mainthat masks everything except the same-run second-iteration case.package.json:26pins@ai-hero/sandcastle^0.12.0as a vendored dev-dependency..sandcastle/prompt.md:114-126+ #445: a.sandcastle/path needs an interactive session's standing.Severity note. The run-29782 incident is already fixed at source by #1717 (the
commit-msggate means no unclaimed orphan is ever committed, so nothing can fast-forward localmain). This ticket is belt-and-suspenders on the library's own merge-to-head step; it is not on a live-fire critical path. A session should weigh raising it upstream against carrying a between-iteration reset hook locally.Ruled by agent under ADR 0174 — veto anytime.
I picked this up as a
ready-for-sessiondrive and verified the premise the filer and the triage ruling both assumed but did not test: "add a between-iteration reset once a seam exists." That seam does not exist in the pinned@ai-hero/sandcastle@0.12.0. So the two-way in-harness path the triage relied on is unavailable, which re-routes this ticket. Details, with source evidence, below.What I verified against the fetched library source
node_modules/@ai-hero/sandcastleis at 0.12.0 (package.jsonpin^0.12.0). Reading its compiled source:withSandboxLifecyclerunsgit merge "<worktree-branch>"inhostRepoDir(localmain) —dist/chunk-VOG34SRF.js:26051. There is no host hook wrapping this merge, and the worktree for iteration N is branched from localmain's HEAD before any hook runs (create()→ then hooks).main.hooks.host.onWorktreeReadyfires after the worktree is created, withcwd = worktreeInfo.path(the temp worktree), nothostRepoDir—dist/chunk-VOG34SRF.js:26722(docker/merge-to-head branch).hooks.host.onSandboxReadyfires concurrently with the agent's sandbox hooks, withcwd = hostSideWorktreePath(the worktree) —dist/chunk-VOG34SRF.js:25980-25984.hostRepoDir(localmain) before the worktree branches, nor one wrapping the merge-back. So the proposed default —reset --hard origin/mainon localmainbetween iterations, before the next merge — cannot be expressed through any 0.12.0 seam.This confirms the filer's core claim ("there is no host hook to reset between iterations") is correct at the level that matters here: the only host hooks are post-branch and operate on the worktree, so they cannot clean local
main.The residual is moot, and a library fix would be redundant
The fast-forward only ever lands an orphan on local
mainif an unclaimed commit exists. #1717'scommit-msggate makes an unclaimed commit impossible (proven bycommit-msg-gate-test.sh, 9 real-commit cases). The library layer also cannot distinguish a legitimate ticket commit (about to be pushed) from an orphan at merge time — they are identical until the push fails; the only reliable distinguisher is the claim-at-commit-time check, which is exactly what #1717 does. So even a clean upstream "refuse to merge onto a diverged localmain" would be a blunter, weaker restatement of #1717, guarding a condition #1717 already prevents. The cross-run case is separately masked bygit-setup.sh's next-tickreset --hard origin/main.Why this now needs a human (one-way doors only remain)
The triage ruled
ready-for-sessionon the basis that a session could add the reset two-way once a seam existed. With the seam verified absent, the only ways to actually build the belt-and-suspenders are one-way doors, which ADR 0174 rule 2 stops on the human:@ai-hero/sandcastledependency to add a pre-branch host hook or a "refuse-to-merge-onto-diverged-local-main" guard — a one-way / unprovable-offline door (a seam-fake models merge-to-head as success; not tracked in-repo).mainguard) — an outward-facing publish, and the upstream account/repo is not in this host's standing (host doors: Forgejo, DigitalOcean, Mattermost — no upstream credential).A fully-in-repo, two-way mitigation also exists but is out of this ticket's scope and carries a real cost: setting
.sandcastle/main.mts'smaxIterations: 1structurally eliminates the same-run second-iteration entirely (each run does one ticket;git-setup.sh's cross-run reset then cleans up), but it trades away swarm throughput (per-ticket container/pnpm/nix warmup) to defend a moot condition — a swarm-ops trade-off that belongs to whoever owns the swarm config, not a defense-in-depth ticket. Noted for completeness, not enacted.Proposed default (rule 4)
Adopt (C): accept as moot and close — #1717 eliminated the only trigger, the pinned library exposes no two-way seam, and a library fix would be redundant. If the belt-and-suspenders is still wanted, (A)/(B) are the paths and both are your call.
Why human
One-way door: advancing the actual fix requires either forking/patching the fetched
@ai-hero/sandcastledependency (A) or an outward-facing upstream issue/PR whose account is outside this host's standing (B) — or your one-line acceptance of the moot residual (C, the proposed default). No two-way, provable in-harness fix exists at the pinned 0.12.0 (verified: both host hooks are post-branch + worktree-scoped; the merge-back is unhooked).