Server-side merge gate: Forgejo branch protection on main; hooks become defence in depth #194

Open
opened 2026-10-15 02:58:54 +00:00 by ben · 0 comments
Owner

Filed from the 2026-10-14 infrastructure review (Claude Code session on Ben's workstation; four parallel read-only review passes over the root harness). Line anchors are against main at 3e50274.

Symptom

Every gate a swarm worker faces is client-side and bypassable from inside the sandbox (verified):

  • git-fence:33-64 refuses only git worktree add|remove|move|lock|unlock|prune|repair.
  • --no-verify, git -c core.hooksPath=/dev/null push, /usr/bin/git push, and env GATE_TS_CMD=true git push (gate-lib.sh:154-156 evals a worker-controlled env var) all skip the pre-push gate.
  • core.hooksPath is a RELATIVE path into the worker's own checkout (main.mts:319), so the worker can edit .sandcastle/git-hooks/pre-push in its worktree.
  • git-hooks/commit-msg:31-32 is inert when SWARM_RUN_ID is unset or 0 — SWARM_RUN_ID=0 git commit disables the claim gate (and tests/commit-msg-gate-test.sh case 6 pins that as correct).
  • Agent and human pushes run different gate profiles (pre-push:116-121), so gates are not identical for agent and human code.

Proposed change

  • Enable Forgejo branch protection on main for dev-factory and every consumer: push allowlist = the host landing identity only; require the ci status check; block force-push.
  • Scope the worker's forge credential to agent/* and sandcastle/worker/* branches (pairs with #201).
  • Run the language gates (gate.sh) on the HOST before landing, not only in the worker's hook; keep the hooks as fast-feedback only.
  • Add tests/ cases that assert each bypass above is REFUSED by the host landing path (today none exist).

Why human

One-way-door ruling: a security-posture change on the forge (branch protection, token scopes) that locks out today's direct pushes, including Ben's own. Proposed default ruling: enable protection on dev-factory first, consumers at their next pin bump.

depends_on

#193 (workers need a branch to push to once main is protected).

_Filed from the 2026-10-14 infrastructure review (Claude Code session on Ben's workstation; four parallel read-only review passes over the root harness). Line anchors are against `main` at 3e50274._ ## Symptom Every gate a swarm worker faces is client-side and bypassable from inside the sandbox (verified): - `git-fence:33-64` refuses only `git worktree add|remove|move|lock|unlock|prune|repair`. - `--no-verify`, `git -c core.hooksPath=/dev/null push`, `/usr/bin/git push`, and `env GATE_TS_CMD=true git push` (`gate-lib.sh:154-156` evals a worker-controlled env var) all skip the pre-push gate. - `core.hooksPath` is a RELATIVE path into the worker's own checkout (`main.mts:319`), so the worker can edit `.sandcastle/git-hooks/pre-push` in its worktree. - `git-hooks/commit-msg:31-32` is inert when `SWARM_RUN_ID` is unset or 0 — `SWARM_RUN_ID=0 git commit` disables the claim gate (and `tests/commit-msg-gate-test.sh` case 6 pins that as correct). - Agent and human pushes run different gate profiles (`pre-push:116-121`), so gates are not identical for agent and human code. ## Proposed change - Enable Forgejo branch protection on `main` for dev-factory and every consumer: push allowlist = the host landing identity only; require the `ci` status check; block force-push. - Scope the worker's forge credential to `agent/*` and `sandcastle/worker/*` branches (pairs with #201). - Run the language gates (`gate.sh`) on the HOST before landing, not only in the worker's hook; keep the hooks as fast-feedback only. - Add `tests/` cases that assert each bypass above is REFUSED by the host landing path (today none exist). ## Why human One-way-door ruling: a security-posture change on the forge (branch protection, token scopes) that locks out today's direct pushes, including Ben's own. Proposed default ruling: enable protection on dev-factory first, consumers at their next pin bump. ## depends_on #193 (workers need a branch to push to once main is protected).
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.

Reference
Matou/dev-factory#194
No description provided.