Pre-push drift gate is fail-open on TRANSPORT: a sandbox worker with no factory network can push a vendored-path edit (design call) #1965

Closed
opened 2026-09-28 16:04:12 +00:00 by matou-build-agent · 1 comment

Split off from #1964 (factory drift on main: gate 9 was authored into vendored .sandcastle/ files by a sandbox worker and pushed without the seam stage catching it pre-push).

The gap (CONFIRMED)

.sandcastle/git-hooks/pre-push gate 1 (the #932 drift gate) is fail-open by design. At line ~85 it emits DRIFT_BLOCK only when check-harness-drift.sh exits non-zero and its output contains a ^DRIFT: or check-harness-drift: FAILED line:

if [ "$rc" -ne 0 ] && printf '%s\n' "$out" | grep -q '^DRIFT:\|^check-harness-drift: FAILED'; then
    echo "DRIFT_BLOCK"

A sandbox worker whose factory fetch cannot reach git.matou.nz gets check-harness-drift.sh exit 3 (TRANSPORT) — drift was never read, so the output has neither marker — and the push falls through. So the pre-push gate can never block a sandbox-authored vendored edit when the sandbox has no factory network. The seam stage on main is then the only real gate — which is exactly how #1963's gate-9 edit landed drift onto main (see #1964).

Confirmed by reading the shipped hook on f2dde647; the specific #1963 worker log was not in #1964's evidence, so the "this is what happened to #1963" attribution stays inferred, but the gate behaviour itself is confirmed from the code.

Why this needs a design call (not a two-way fix)

The fail-open posture is deliberate (the hook comments say so). Flipping gate 1 to fail-closed on a TRANSPORT error would block every push from any workdir that cannot reach the factory — a fleet-wide wedge whenever git.matou.nz is unreachable or a sandbox is offline by policy. That is a real tradeoff, not an obvious bug. Options a session/human should weigh:

  • fail-closed only for sandbox workers (detect the sandbox), leaving human/host pushes fail-open;
  • require a fresh successful drift check as a precondition to any vendored-path edit reaching a push, enforced where the sandbox does have the pinned factory checkout;
  • accept the seam stage as the sole gate and instead make the seam stage's red block the merge/land, not just report.

.sandcastle/git-hooks/pre-push is a factory-vendored protected path (#445 / ADR 0180): any change lands upstream in Matou/dev-factory first, then re-vendors here — it cannot be edited in this repo.

Ruled by agent under ADR 0174 while working #1964 — filing the follow-up rather than folding a protected-path machinery change into the drift-clearing ticket. Veto anytime.

Split off from #1964 (factory drift on main: gate 9 was authored into vendored `.sandcastle/` files by a sandbox worker and pushed without the seam stage catching it pre-push). ## The gap (CONFIRMED) `.sandcastle/git-hooks/pre-push` gate 1 (the #932 drift gate) is **fail-open by design**. At line ~85 it emits `DRIFT_BLOCK` only when `check-harness-drift.sh` exits non-zero **and** its output contains a `^DRIFT:` or `check-harness-drift: FAILED` line: ``` if [ "$rc" -ne 0 ] && printf '%s\n' "$out" | grep -q '^DRIFT:\|^check-harness-drift: FAILED'; then echo "DRIFT_BLOCK" ``` A sandbox worker whose factory fetch cannot reach `git.matou.nz` gets `check-harness-drift.sh` exit **3 (TRANSPORT)** — drift was never read, so the output has neither marker — and the push falls through. So the pre-push gate can **never** block a sandbox-authored vendored edit when the sandbox has no factory network. The `seam` stage on `main` is then the only real gate — which is exactly how #1963's gate-9 edit landed drift onto `main` (see #1964). Confirmed by reading the shipped hook on `f2dde647`; the specific #1963 worker log was not in #1964's evidence, so the "this is what happened to #1963" attribution stays inferred, but the gate behaviour itself is confirmed from the code. ## Why this needs a design call (not a two-way fix) The fail-open posture is **deliberate** (the hook comments say so). Flipping gate 1 to fail-closed on a TRANSPORT error would block *every* push from any workdir that cannot reach the factory — a fleet-wide wedge whenever `git.matou.nz` is unreachable or a sandbox is offline by policy. That is a real tradeoff, not an obvious bug. Options a session/human should weigh: - fail-**closed** only for sandbox workers (detect the sandbox), leaving human/host pushes fail-open; - require a fresh successful drift check as a precondition to any vendored-path edit reaching a push, enforced where the sandbox *does* have the pinned factory checkout; - accept the seam stage as the sole gate and instead make the seam stage's red **block the merge/land**, not just report. `.sandcastle/git-hooks/pre-push` is a factory-vendored protected path (#445 / ADR 0180): any change lands upstream in `Matou/dev-factory` first, then re-vendors here — it cannot be edited in this repo. Ruled by agent under ADR 0174 while working #1964 — filing the follow-up rather than folding a protected-path machinery change into the drift-clearing ticket. Veto anytime.
Author
Member

Close-report — the drift gate now fails CLOSED on an unverified vendored-file push

Ruled by agent under ADR 0174 — veto anytime. This was the "design call" the ticket asked for; recorded as design DDR docs/adr/0287-design-the-drift-gate-fails-closed-on-an-unverified-vendored-edit.md.

The ruling (among the ticket's three options)

Option 2, realised at the pre-push gate itself: once the gate's cheap local pre-filter confirms a FACTORY_MANIFEST path is in the push, check-harness-drift.sh must return a CLEAN verdict (exit 0) for the push to proceed. Every non-zero blocks — confirmed drift → the existing #932 message; a TRANSPORT fault (exit 3) or any other non-zero without a drift marker → a new VERIFY_BLOCK / #1965 message naming the unverified edit.

Not option 1 (sandbox-detection), and the "fleet-wide wedge" fear does not apply. The gate runs the network drift check only when the pushed range touches a vendored path — so the fail-closed path is unreachable for an ordinary push and for run-swarm.sh's reconcile push (both return before the check runs and stay fail-open). The case (a vendored-file edit that cannot be verified) is the scope; an actor test is redundant, and it would leave a host/human vendored edit during an outage equally unverified. This honours the principle check-harness-drift.sh is already built around and cites (GOTCHAS #30 — a guard that could not reach the code it guards must never be mistaken for a clean result; it already retries a blip before exiting 3, so only a sustained outage lands here). Option 3 (make the seam red block the land) is a larger, different-subsystem change and forfeits the "last revertible moment" this gate exists for.

What landed

  • Matou/dev-factory@1aba93c (direct push to main, the #1940/#1943/#1964 precedent): git-hooks/pre-push — the gate's tail now requires exit 0 and emits DRIFT_BLOCK vs VERIFY_BLOCK; tests/prepush-drift-gate-test.sh updated.
  • Matou/idss@99e74ea8: re-vendored (FACTORY_REF 78db030 → 1aba93c, git-hooks/pre-push + tests/prepush-drift-gate-test.sh byte-identical from the pin, check-harness-drift.sh → OK), design DDR 0287, and STATUS.md.

Proof (TDD, offline)

tests/prepush-drift-gate-test.sh drives real git pushes to a local bare remote so git invokes the hook with genuine stdin:

  • RED against the old hook — the unverified vendored push landed (2a7f031..17560c6), case 4 failed.
  • GREEN against the new hook — prepush-drift-gate-test: PASS.
  • Case 4 reversed (an infra fault on a vendored-edit push now blocks with the #1965 message); case 4b added (a TRANSPORT exit-3 fault blocks); case 1b added (an ordinary push stays fail-open under a transport fault — the reconcile rail / an offline workdir is untouched).
  • Adjacent factory suites green: commit-msg-gate-test.sh 9/0, gate-lib-test.sh 34, check-harness-drift-test.sh 14.

Notes

  • Two-way door: a revertible dev-factory commit + FACTORY_REF bump, proven by an existing offline test. It is a tightening of an integrity gate, not a security-posture widening — not on ADR 0174's one-way-door list; .sandcastle/ is protected (#445), a session's standing.
  • Pre-existing / out of scope (unchanged, as #1964 noted): the non-fatal stale-render NOTE on prompt.md against the pinned skeleton (prompt.md is rendered, never hand-edited).
  • Consumers other than idss pick this up only when they bump their own FACTORY_REF, so blast radius is contained.
## Close-report — the drift gate now fails CLOSED on an unverified vendored-file push **Ruled by agent under ADR 0174 — veto anytime.** This was the "design call" the ticket asked for; recorded as **design DDR `docs/adr/0287-design-the-drift-gate-fails-closed-on-an-unverified-vendored-edit.md`**. ### The ruling (among the ticket's three options) **Option 2, realised at the pre-push gate itself:** once the gate's cheap local pre-filter confirms a `FACTORY_MANIFEST` path is in the push, `check-harness-drift.sh` must return a **CLEAN verdict (exit 0)** for the push to proceed. Every non-zero blocks — confirmed drift → the existing `#932` message; a **TRANSPORT fault (exit 3)** or any other non-zero without a drift marker → a new `VERIFY_BLOCK` / `#1965` message naming the unverified edit. **Not option 1 (sandbox-detection), and the "fleet-wide wedge" fear does not apply.** The gate runs the network drift check **only** when the pushed range touches a vendored path — so the fail-closed path is **unreachable** for an ordinary push and for `run-swarm.sh`'s reconcile push (both return *before* the check runs and stay fail-open). The case (a vendored-file edit that cannot be verified) **is** the scope; an actor test is redundant, and it would leave a host/human vendored edit during an outage equally unverified. This honours the principle `check-harness-drift.sh` is already built around and cites (GOTCHAS #30 — a guard that could not reach the code it guards must never be mistaken for a clean result; it already retries a blip before exiting 3, so only a **sustained** outage lands here). Option 3 (make the `seam` red block the land) is a larger, different-subsystem change and forfeits the "last revertible moment" this gate exists for. ### What landed - **`Matou/dev-factory@1aba93c`** (direct push to `main`, the #1940/#1943/#1964 precedent): `git-hooks/pre-push` — the gate's tail now requires exit 0 and emits `DRIFT_BLOCK` vs `VERIFY_BLOCK`; `tests/prepush-drift-gate-test.sh` updated. - **`Matou/idss@99e74ea8`**: re-vendored (`FACTORY_REF 78db030 → 1aba93c`, `git-hooks/pre-push` + `tests/prepush-drift-gate-test.sh` byte-identical from the pin, `check-harness-drift.sh` → OK), design DDR 0287, and STATUS.md. ### Proof (TDD, offline) `tests/prepush-drift-gate-test.sh` drives **real `git push`es** to a local bare remote so git invokes the hook with genuine stdin: - **RED** against the old hook — the unverified vendored push landed (`2a7f031..17560c6`), case 4 failed. - **GREEN** against the new hook — `prepush-drift-gate-test: PASS`. - Case 4 **reversed** (an infra fault on a vendored-edit push now blocks with the `#1965` message); **case 4b added** (a TRANSPORT exit-3 fault blocks); **case 1b added** (an ordinary push stays fail-open under a transport fault — the reconcile rail / an offline workdir is untouched). - Adjacent factory suites green: `commit-msg-gate-test.sh` 9/0, `gate-lib-test.sh` 34, `check-harness-drift-test.sh` 14. ### Notes - **Two-way door:** a revertible dev-factory commit + `FACTORY_REF` bump, proven by an existing offline test. It is a **tightening** of an integrity gate, not a security-posture widening — not on ADR 0174's one-way-door list; `.sandcastle/` is protected (#445), a session's standing. - Pre-existing / out of scope (unchanged, as #1964 noted): the non-fatal stale-render NOTE on `prompt.md` against the pinned skeleton (`prompt.md` is rendered, never hand-edited). - Consumers other than idss pick this up only when they bump their own `FACTORY_REF`, so blast radius is contained.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1965
No description provided.