drift guard gap: a session can edit a FACTORY_MANIFEST file and only find out when main goes red (follow-up to #931) #932
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#932
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?
Symptom
mainwent red on theseamdrift stage (#931) only AFTER the drift-causingcommit (
d0a74a65) had already landed. A session with legitimate.sandcastle/standing (#445) edited a file that happens to be factory-vendored (listed in
.sandcastle/FACTORY_MANIFEST, ADR 0180), and nothing warned it before push.Why the first signal was a red main
protected-paths-lib.shcorrectly did NOT fire — the session held.sandcastle/standing..sandcastle/git-hooks/pre-pushis sandbox-only (FACTORY_SANDBOX=1) and carries no drift gate.pre-pushhook is installed in the swarm/session workdir.So
check-harness-drift.sh— which exists and is correct — only ran inseam,i.e. after the push, on
main. The door that should stay shut opened first andalarmed second.
Proposed fix (two-way, a session can rule)
Either (a) add a drift gate to the shared
pre-pushhook (factory change, everyconsumer inherits — mirrors how #931 grew the report-guard seam), gated so it
runs in real workdirs not just the sandbox; or (b) a lighter session-side note:
when a session is about to edit a
.sandcastle/file that is inFACTORY_MANIFEST, warn that it is read-only here (land upstream + re-vendor).(a) is the durable fix — it catches the whole class at the last revertible
moment before
main. Proposed default: (a).Context
Follow-up to #931 (which healed the incident by moving the #919 block into a
consumer-owned
.sandcastle/report-guard.shbehind a new factory hook). #931explicitly asked that this guard gap be considered separately. Filed by the
session-runner under ADR 0174.
Ruled by agent under ADR 0174 — veto anytime
Ruling: Route to
ready-for-session+bug, and adopt the filer's proposed default (a) — the durable fix: a drift gate that fires at the last revertible moment beforemain, wired the #931 way (a consumer-owned gate behind the shared factory pre-push hook, not an in-place edit of the vendoredgit-hooks/pre-push).Why this is a two-way door: the change is a hook/gate addition — revertible by a single commit or config change, and provable by an existing probe.
check-harness-drift.shalready exists and already runs in the post-pushseamstage; the fix only moves that same signal earlier (pre-push). Nothing on the one-way-door list is touched: no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no spend.Why
ready-for-session, notready-for-agent: the work lives in protected.sandcastle/paths (#445) and is factory-vendored — bothgit-hooks/pre-pushandcheck-harness-drift.share listed in.sandcastle/FACTORY_MANIFEST(ADR 0180: "DO NOT EDIT BY HAND … Re-vendor to change it"). A swarm worker must not pick that up; only an interactive session with.sandcastle/standing + the factory land-upstream/re-vendor route can land it. The swarm queue (list-ready-tasks.sh) reads onlyready-for-agent, so this stays invisible to workers by construction.Verified against the codebase (2026-08-28):
.sandcastle/git-hooks/pre-pushis sandbox-only ([ "${FACTORY_SANDBOX:-}" = "1" ] || exit 0) and carries only the Go language gate (gate.sh --prepush) — no drift check. Confirmed.check-harness-drift.shexists, is factory-vendored, and runs post-push inseam. Confirmed the gap: the door alarms after the push, not before..out-of-scope/; not already implemented.Agent Brief
Category: bug
Summary: A
.sandcastle/session can edit a factory-vendored file with no warning untilmainreds on theseamdrift stage; add a drift gate that fires before the push.Current behavior:
A session holding legitimate
.sandcastle/standing (#445) can edit a factory-vendored file (any path in.sandcastle/FACTORY_MANIFEST, ADR 0180) and get no signal until after the drift-causing commit has already landed onmain.protected-paths-lib.shcorrectly does not fire (the session holds standing), the sharedpre-pushhook is sandbox-only with no drift check, and nopre-pushhook is installed in the swarm/session workdir — socheck-harness-drift.shonly runs in the post-pushseamstage. The door that should stay shut opens first and alarms second (incident: commitd0a74a65, #931).Desired behavior:
The harness-drift signal fires at the last revertible moment before
main— a pre-push drift gate that runs in real session/swarm workdirs (not only theFACTORY_SANDBOX=1sandbox). When a push would carry an edit to aFACTORY_MANIFEST-listed file that diverges fromFACTORY_REF, the push is blocked with a message pointing at the land-upstream-and-re-vendor remedy. A push with no factory drift is unaffected.Implement per default (a), following the #931 pattern: grow a consumer-owned gate (a
.sandcastle/-local script, mirroringreport-guard.sh) wired behind the shared factory pre-push hook, so every consumer inherits it and the vendored hook stays byte-identical to the factory. Option (b) — a session-side edit-time note — is the lighter alternative the filer explicitly deprioritised; do not do both.Key interfaces:
pre-pushfactory hook — currently gated toFACTORY_SANDBOX=1only; the drift gate must also run in real workdirs, without regressing the existing Go language gate or run-swarm.sh's reconcile push.check-harness-drift.sh— reuse its existing drift-detection logic; do not fork a second drift check..sandcastle/report-guard.sh(#931).Acceptance criteria:
FACTORY_MANIFEST-listed file so it diverges fromFACTORY_REF, then attempting to push, is blocked pre-push in a real (non-sandbox) session/swarm workdir.git-hooks/pre-pushstays byte-identical toFACTORY_REF— the gate is consumer-owned, wired behind the hook — so this fix does not itself introduce drift.main.Out of scope:
protected-paths-lib.shguards (session standing over.sandcastle/is intentional per #445).Session standing needed:
.sandcastle/protected-path write (#445) plus the factory land-upstream/re-vendor route — the fix is a factory change, and the vendored hook must stay byte-identical, so any factory-core edit lands in dev-factory first and is re-vendored here.Ruled by agent under ADR 0174 — veto anytime. Close-report for #932.
Landed the triage-ruled default (a): a pre-push factory-drift gate that fires at the last revertible moment before
main, not only on a redseamafterward.What landed
Per ADR 0180 the fix is a factory change — all three touched harness files (
git-hooks/pre-push,session-runner.sh,git-setup.sh) are factory-vendored — so it was authored + pushed toMatou/dev-factorymain (as asession-runner, exactly as #931's factory side landed), then re-vendored here byte-identical.1fc29e0— "pre-push: block factory-vendored drift before the push, in real workdirs too (idss #932)". The sharedpre-pushhook grew a factory-drift gate that runs in EVERY workdir (real session/swarm host checkouts and theFACTORY_SANDBOX=1sandbox).core.hooksPathis now wired into real workdirs fromsession-runner.sh(dedicated session checkout) andgit-setup.sh(swarm/triage workdir), mirroringmain.mts's sandbox wiring — this is what closes the "no pre-push hook is installed in the swarm/session workdir" half of the gap. New offline testtests/prepush-drift-gate-test.sh.ab2643c2— re-vendor at the new pin (FACTORY_REF9057c9dd→1fc29e0);check-harness-driftOK (vendored hook byte-identical to the pin).STATUS.mdupdated.Design note (one deliberate deviation from the triage brief, same outcome)
The brief suggested a consumer-owned gate body (mirroring #931's
report-guard.sh) wired behind the hook. I instead put the gate directly in the factorypre-push, reusing the factory-ownedcheck-harness-drift.sh. Rationale: #931 needed a consumer body because the #919 logic was IDSS-specific (it sources this repo's libs / reads get.idss.nz). The drift check is generic factory logic — it readsFACTORY_MANIFEST/FACTORY_REFand works identically for every consumer — so a consumer-owned body would be pointless indirection. Every acceptance criterion still holds: the vendored hook stays byte-identical toFACTORY_REF, no second drift check is forked, and it fires in real workdirs. Veto if you'd prefer the consumer-body shape.Why this is a safe two-way door (the reconcile-push concern)
The existing hook was sandbox-only by design (its comment: "run-swarm.sh's reconcile push must not stall on a Go build"). The new gate respects that:
check-harness-drift.shruns only when the pushed range actually touches a manifest path (a localgit diffotherwise), so an ordinary push and the reconcile push pay nothing extra.DRIFT:. A network blip can never stall the reconcile rail; any bug degrades to today's behaviour (seam still catches real drift onmain).Revert path: revert
1fc29e0+ revert theFACTORY_REFbump (onboard.sh vendor … 9057c9dd). Single-commit revertible on both repos. No one-way door touched (no credentials, no security-posture widening, no trust accept, no data destruction, no spend).Proof
tests/prepush-drift-gate-test.sh(offline, drives real pushes to a bare remote) — PASS: no-manifest push never runs the drift check; drifted manifest push is BLOCKED; in-sync passes; infra error fails open; the sandbox Go gate still fires and propagates its exit. Runs green in both dev-factory and here.core.hooksPath, made a d0a74a65-class edit to a vendored file (.sandcastle/gate.sh),git push→ blocked pre-push by the real networkedcheck-harness-drift, printing the divergent file, the diff, the pinned ref and the#932remedy. (The incident that reddedmainatd0a74a65now stops one step earlier.)ab2643c2push to origin exercised the in-sync path with the gate active (range touches manifest paths, in sync) and proceeded — a legitimate push is not blocked.Acceptance (triage brief)
git-hooks/pre-pushstays byte-identical toFACTORY_REF(gate is factory-owned + re-vendored) — no self-inflicted drift.main.One honesty note
idss commit
ab2643c2's subject line lost its#932 —prefix: during thegit rebase --continueafter aSTATUS.mdconflict, git's editorcleanup=striptreated the leading#as a comment and dropped that line, promoting a body paragraph to the subject. The content/diff is correct and the body references #932 throughout; I did not force-push sharedmainto fix a cosmetic subject (against repo discipline). Flagging for the record.Closing #932. Follow-ups: none required.
dashgetter in the three provision/re-apply drives #1251