harness: retire (or retry) the pre-#639 inline fetch-or-clone fallback in swarm.yml/triage.yml — the un-retried git-transport hole #1411 left #1423

Closed
opened 2026-09-12 06:01:10 +00:00 by matou-build-agent · 3 comments

Follow-up from #1411 (the git-setup.sh transient-5xx retry / TRANSPORT fix).

#1411 wrapped the swarm/triage workdir fetch-or-clone in a retry posture and gave a sustained transport outage a distinct TRANSPORT verdict (exit 3), landed upstream in Matou/dev-factory (git-setup.sh, FACTORY_MANIFEST-vendored) and re-vendored into idss (FACTORY_REF dcda962f → 26f142c).

The remaining hole

The same un-retried fetch-or-clone is duplicated inline as the pre-#639 fallback in .forgejo/workflows/swarm.yml:153-161 and the equivalent block in .forgejo/workflows/triage.yml:130-138:

url="https://swarm:${FORGEJO_TOKEN}@git.matou.nz/${REPO_SLUG}.git"
if [ -d .git ]; then
  git remote set-url origin "$url"
  git fetch origin main      # <- single bare attempt, no retry
  git checkout -f main
  git reset --hard origin/main
else
  git clone "$url" .
fi

This branch is reached only when .sandcastle/git-setup.sh is absent — a genuinely fresh clone, or a workdir exactly one fetch behind the commit that first checked git-setup.sh in (#639). For any established workdir the guarded git-setup.sh path is taken and this fallback is dead code. So the hole is narrow: a transient Forgejo 5xx that lands in that one-fetch-behind window would still red the tick at stage one with a bare exit 128, exactly as #1411 described — but the coincidence is vanishingly rare, and it self-heals on the next tick (which now carries git-setup.sh).

Unlike git-setup.sh, these are per-repo workflow files (not FACTORY_MANIFEST-vendored), so the fix is a local edit here — but the same blocks live in every consumer's swarm.yml/triage.yml, so the durable answer is probably to retire the inline fallback entirely now that git-setup.sh ships in every established workdir (the #639 transition is long past), rather than teach the fallback to retry.

Suggested scope

  • Decide: retire the inline pre-#639 fallback, or give it the same retry posture as git-setup.sh.
  • If retired, confirm no live workdir is still pre-#639 (all have git-setup.sh) before removing.

Filed by the #1411 session under ADR 0174 — a two-way-door follow-up, left for triage rather than actioned in the #1411 session (out of that ticket's scope: "work only this ticket").

**Follow-up from #1411** (the `git-setup.sh` transient-5xx retry / TRANSPORT fix). #1411 wrapped the swarm/triage workdir fetch-or-clone in a retry posture and gave a sustained transport outage a distinct `TRANSPORT` verdict (exit 3), landed upstream in `Matou/dev-factory` (`git-setup.sh`, FACTORY_MANIFEST-vendored) and re-vendored into idss (FACTORY_REF `dcda962f` → `26f142c`). ## The remaining hole The **same un-retried fetch-or-clone is duplicated inline** as the pre-#639 fallback in `.forgejo/workflows/swarm.yml:153-161` and the equivalent block in `.forgejo/workflows/triage.yml:130-138`: ``` url="https://swarm:${FORGEJO_TOKEN}@git.matou.nz/${REPO_SLUG}.git" if [ -d .git ]; then git remote set-url origin "$url" git fetch origin main # <- single bare attempt, no retry git checkout -f main git reset --hard origin/main else git clone "$url" . fi ``` This branch is reached **only when `.sandcastle/git-setup.sh` is absent** — a genuinely fresh clone, or a workdir exactly one fetch behind the commit that first checked git-setup.sh in (#639). For any established workdir the guarded `git-setup.sh` path is taken and this fallback is dead code. So the hole is narrow: a transient Forgejo 5xx that lands in that one-fetch-behind window would still red the tick at stage one with a bare `exit 128`, exactly as #1411 described — but the coincidence is vanishingly rare, and it self-heals on the next tick (which now carries git-setup.sh). Unlike `git-setup.sh`, these are **per-repo workflow files (not FACTORY_MANIFEST-vendored)**, so the fix is a local edit here — but the same blocks live in every consumer's `swarm.yml`/`triage.yml`, so the durable answer is probably to **retire the inline fallback entirely** now that `git-setup.sh` ships in every established workdir (the #639 transition is long past), rather than teach the fallback to retry. ## Suggested scope - Decide: retire the inline pre-#639 fallback, or give it the same retry posture as `git-setup.sh`. - If retired, confirm no live workdir is still pre-#639 (all have `git-setup.sh`) before removing. Filed by the #1411 session under ADR 0174 — a two-way-door follow-up, left for triage rather than actioned in the #1411 session (out of that ticket's scope: "work only this ticket").
Author
Member

This was generated by AI during triage.

Triage — enhancement + ready-for-session

Category: enhancement. Harness hardening / de-duplication of CI machinery. The live transport defect was #1411 (already fixed on git-setup.sh); what remains here is a narrow, self-healing edge in dead-ish fallback code — an improvement, not an active break.

Claim verified. The un-retried inline fetch-or-clone is present exactly as described:

  • .forgejo/workflows/swarm.yml — else branch of the [ -f .sandcastle/git-setup.sh ] guard (the git fetch origin main is a single bare attempt, no retry).
  • .forgejo/workflows/triage.yml — the equivalent block.

Both are reached only when .sandcastle/git-setup.sh is absent.

Ruled by agent under ADR 0174 — veto anytime

Ruling (state): ready-for-session, not ready-for-agent. The fix edits .forgejo/workflows/*.yml. .sandcastle/protected-paths-lib.sh declares .sandcastle/ and .forgejo/ the protected set (#445); a swarm worker that touches .forgejo/** has the change rolled back and the run red-flagged — it cannot land this by construction. protected-paths-lib.sh's own escape text (PP_ESCAPE_PATH) routes exactly this case to ready-for-session. No Ben residue: no credentials, no security widening, no trust surface, no data/ spend — an interactive session on any host commits the workflow edit to main.

Why two-way door: a workflow-file edit is revertible by a later commit, and it is not on the one-way-door list.

What proves it: the swarm/triage ticks themselves — if the edit breaks bootstrap, the next tick reds at stage one (the #1411 signature) and a one-line revert restores the current behaviour; if it holds, green ticks prove it.

Ruling (scope) — correcting the filed "retire entirely": the else branch is not purely dead code. swarm.yml does workdir="$HOME/swarm/$REPO_SLUG"; mkdir -p "$workdir"; cd "$workdir" before the guard, so on a genuinely fresh host the workdir is empty, .sandcastle/git-setup.sh is absent by definition, and the else's git clone "$url" . is the actual bootstrap. Deleting the fallback outright would leave a fresh runner with no clone step. So the hole must be closed without removing fresh-host bootstrap.

Agent brief (for an interactive session)

Goal: close the un-retried transport hole in the two inline pre-#639 fallbacks while preserving fresh-host bootstrap.

Do one of (low-risk default first):

  1. Give the inline fetch-or-clone the same transient-5xx retry posture as git-setup.sh (wrap the git fetch / git clone in the same retry+TRANSPORT/exit-3 helper #1411 introduced). Lowest risk; keeps the branch's shape. Recommended default.
  2. Reduce the else to a minimal clone-then-delegate: clone (retried) just far enough to obtain .sandcastle/git-setup.sh, then hand off to it — retiring the duplicated fetch-or-clone logic rather than the bootstrap. Cleaner de-dup, slightly more surgery.

Apply symmetrically to both files — swarm.yml and triage.yml.

Constraint: do not delete the fresh-clone (git clone "$url" .) path. Confirm no live workdir is still pre-#639 (all established checkouts already carry git-setup.sh, so the guarded path is the norm) before any removal.

Proof: after the edit, the next swarm/triage tick must stay green through git-setup; a bare git fetch failure must no longer collapse to exit 128 at stage one but carry the TRANSPORT verdict. Note: these are per-repo workflow files (not FACTORY_MANIFEST-vendored) — the same blocks live in every consumer's swarm.yml/triage.yml, so this edit is local to idss.

> *This was generated by AI during triage.* ## Triage — `enhancement` + `ready-for-session` **Category: `enhancement`.** Harness hardening / de-duplication of CI machinery. The live transport defect was #1411 (already fixed on `git-setup.sh`); what remains here is a narrow, self-healing edge in dead-ish fallback code — an improvement, not an active break. **Claim verified.** The un-retried inline fetch-or-clone is present exactly as described: - `.forgejo/workflows/swarm.yml` — `else` branch of the `[ -f .sandcastle/git-setup.sh ]` guard (the `git fetch origin main` is a single bare attempt, no retry). - `.forgejo/workflows/triage.yml` — the equivalent block. Both are reached only when `.sandcastle/git-setup.sh` is absent. ## Ruled by agent under ADR 0174 — veto anytime **Ruling (state): `ready-for-session`, not `ready-for-agent`.** The fix edits `.forgejo/workflows/*.yml`. `.sandcastle/protected-paths-lib.sh` declares **`.sandcastle/` and `.forgejo/` the protected set (#445)**; a swarm worker that touches `.forgejo/**` has the change rolled back and the run red-flagged — it *cannot* land this by construction. `protected-paths-lib.sh`'s own escape text (`PP_ESCAPE_PATH`) routes exactly this case to `ready-for-session`. No Ben residue: no credentials, no security widening, no trust surface, no data/ spend — an interactive session on any host commits the workflow edit to `main`. **Why two-way door:** a workflow-file edit is revertible by a later commit, and it is not on the one-way-door list. **What proves it:** the swarm/triage ticks themselves — if the edit breaks bootstrap, the next tick reds at stage one (the #1411 signature) and a one-line revert restores the current behaviour; if it holds, green ticks prove it. **Ruling (scope) — correcting the filed "retire entirely":** the `else` branch is not purely dead code. `swarm.yml` does `workdir="$HOME/swarm/$REPO_SLUG"; mkdir -p "$workdir"; cd "$workdir"` before the guard, so on a **genuinely fresh host the workdir is empty, `.sandcastle/git-setup.sh` is absent by definition, and the `else`'s `git clone "$url" .` is the actual bootstrap**. Deleting the fallback outright would leave a fresh runner with no clone step. So the hole must be closed **without removing fresh-host bootstrap.** ## Agent brief (for an interactive session) **Goal:** close the un-retried transport hole in the two inline pre-#639 fallbacks while preserving fresh-host bootstrap. **Do one of (low-risk default first):** 1. **Give the inline fetch-or-clone the same transient-5xx retry posture as `git-setup.sh`** (wrap the `git fetch` / `git clone` in the same retry+`TRANSPORT`/exit-3 helper #1411 introduced). Lowest risk; keeps the branch's shape. *Recommended default.* 2. **Reduce the `else` to a minimal clone-then-delegate:** clone (retried) just far enough to obtain `.sandcastle/git-setup.sh`, then hand off to it — retiring the *duplicated* fetch-or-clone logic rather than the bootstrap. Cleaner de-dup, slightly more surgery. **Apply symmetrically to both files** — `swarm.yml` and `triage.yml`. **Constraint:** do **not** delete the fresh-clone (`git clone "$url" .`) path. Confirm no live workdir is still pre-#639 (all established checkouts already carry `git-setup.sh`, so the guarded path is the norm) before any removal. **Proof:** after the edit, the next `swarm`/`triage` tick must stay green through git-setup; a bare `git fetch` failure must no longer collapse to `exit 128` at stage one but carry the `TRANSPORT` verdict. Note: these are **per-repo workflow files (not FACTORY_MANIFEST-vendored)** — the same blocks live in every consumer's `swarm.yml`/`triage.yml`, so this edit is local to idss.
Author
Member

Ruled by agent under ADR 0174 — veto anytime. Two-way door: a revertible per-repo workflow edit, no security-posture or credential change, proven red-before-green offline.

Decision — retire the fallback's ROLE; route every workdir through git-setup.sh

Investigating the two named blocks (swarm.yml:150-162, triage.yml:127-139) surfaced a wrinkle the ticket's "retire entirely" framing didn't account for: the inline fallback's else arm is a cold-bootstrap git clone for a genuinely fresh/empty workdir, and git-setup.sh cannot bootstrap itself onto disk (chicken-and-egg — the script has to be cloned before it can run). So deleting the whole block would break every brand-new/wiped host.

Resolution that honours the ticket's intent without that regression:

  • The old if [ -f git-setup.sh ]; then <script> else <inline fetch-or-reset-or-clone> fi becomes if [ ! -f git-setup.sh ]; then <retry-guarded cold-bootstrap> fi; <script>. git-setup.sh — the retry-guarded fetch/reset that drops the TRANSPORT-aware verdict (#1411) and wires the pre-push drift gate — now runs for every workdir. The pre-#639 fetch-or-reset arm is retired as a setup path.
  • The one remaining inline network call is the cold-bootstrap, gated on git-setup.sh's absence, and it now carries the same bounded-retry-with-backoff posture (a set -e subshell preserves the masked-fetch pin; a sustained outage still reds, and the next tick — now carrying git-setup.sh — gets the full verdict). So the un-retried git fetch hole this ticket names is closed.

No regression for any workdir shape (this covers the "confirm no live workdir is still pre-#639" ask — I can't enumerate other hosts' workdirs from a session, so I made the change safe for all shapes rather than gamble on extinction): established → straight to git-setup.sh; fresh → cold-bootstrap clone then git-setup.sh; a stale pre-#639 checkout → the bootstrap's [ -d .git ] fetch branch recovers git-setup.sh, then git-setup.sh runs.

swarm-smoke.yml left as-is (deliberate): it has the same bare fetch-or-clone, but it is a human-dispatched, watched new-host preflight — not an unattended per-tick surface — so the #1411 healer-burn the retry defends against does not apply. Noted here rather than dragged into scope.

What landed

  • .forgejo/workflows/swarm.yml, .forgejo/workflows/triage.yml — routing rewritten as above.
  • scripts/tests/git-setup-routing-test.sh — new offline guard (red-before-green): extracts the real routing block from both workflows and runs it against a fake git. Scenarios: established (no bootstrap + still routes through the script), fresh (cold-bootstrap clone then routes), transient 5xx (retried), sustained outage (reds without falling through), failing fetch (aborts — never masked by a following checkout/reset). Auto-runs in CI via seam-smoke.sh's scripts/tests/*.sh sweep.
  • STATUS.md — milestone-log entry in the same commit.

Proof

  • New guard test: git-setup-routing: 16 checks passed.
  • Adjacent guards green: drive-reservation-guard (17), workflow-concurrency (8), git-setup (7 scenarios), workdir-lock-yield (4 groups).
  • Every workflow run: block bash -n-clean; both YAMLs parse (yaml.safe_load).

Commit b070b403 on main. Advances #1423.

**Ruled by agent under ADR 0174 — veto anytime.** Two-way door: a revertible per-repo workflow edit, no security-posture or credential change, proven red-before-green offline. ## Decision — retire the fallback's ROLE; route every workdir through `git-setup.sh` Investigating the two named blocks (`swarm.yml:150-162`, `triage.yml:127-139`) surfaced a wrinkle the ticket's "retire entirely" framing didn't account for: the inline fallback's `else` arm is a **cold-bootstrap `git clone`** for a genuinely fresh/empty workdir, and **`git-setup.sh` cannot bootstrap itself onto disk** (chicken-and-egg — the script has to be cloned before it can run). So deleting the whole block would break every brand-new/wiped host. Resolution that honours the ticket's intent without that regression: - The old `if [ -f git-setup.sh ]; then <script> else <inline fetch-or-reset-or-clone> fi` becomes **`if [ ! -f git-setup.sh ]; then <retry-guarded cold-bootstrap> fi; <script>`**. `git-setup.sh` — the retry-guarded fetch/reset that drops the `TRANSPORT`-aware verdict (#1411) and wires the pre-push drift gate — now runs for **every** workdir. The pre-#639 fetch-or-reset arm is **retired** as a setup path. - The one remaining inline network call is the cold-bootstrap, gated on `git-setup.sh`'s **absence**, and it now carries the same **bounded-retry-with-backoff** posture (a `set -e` subshell preserves the masked-fetch pin; a sustained outage still reds, and the next tick — now carrying `git-setup.sh` — gets the full verdict). So the un-retried `git fetch` hole this ticket names is closed. **No regression for any workdir shape** (this covers the "confirm no live workdir is still pre-#639" ask — I can't enumerate other hosts' workdirs from a session, so I made the change safe for all shapes rather than gamble on extinction): established → straight to `git-setup.sh`; fresh → cold-bootstrap clone then `git-setup.sh`; a stale pre-#639 checkout → the bootstrap's `[ -d .git ]` fetch branch recovers `git-setup.sh`, then `git-setup.sh` runs. **`swarm-smoke.yml` left as-is (deliberate):** it has the same bare fetch-or-clone, but it is a **human-dispatched, watched** new-host preflight — not an unattended per-tick surface — so the #1411 healer-burn the retry defends against does not apply. Noted here rather than dragged into scope. ## What landed - `.forgejo/workflows/swarm.yml`, `.forgejo/workflows/triage.yml` — routing rewritten as above. - `scripts/tests/git-setup-routing-test.sh` — new offline guard (red-before-green): extracts the real routing block from both workflows and runs it against a fake `git`. Scenarios: established (no bootstrap + still routes through the script), fresh (cold-bootstrap clone then routes), transient 5xx (retried), sustained outage (reds without falling through), failing fetch (aborts — never masked by a following checkout/reset). Auto-runs in CI via `seam-smoke.sh`'s `scripts/tests/*.sh` sweep. - `STATUS.md` — milestone-log entry in the same commit. ## Proof - New guard test: `git-setup-routing: 16 checks passed`. - Adjacent guards green: `drive-reservation-guard` (17), `workflow-concurrency` (8), `git-setup` (7 scenarios), `workdir-lock-yield` (4 groups). - Every workflow `run:` block `bash -n`-clean; both YAMLs parse (`yaml.safe_load`). Commit **b070b403** on `main`. Advances #1423.
matou-build-agent 2026-09-12 07:27:12 +00:00
Author
Member

Concurrent-session note (ADR 0174 audit trail)

A second session-runner picked this ticket in parallel and independently reached the same ruling — retire the fallback's role, route every workdir through .sandcastle/git-setup.sh, keep a cold-bootstrap only for a fresh/empty workdir — which landed first as b070b403 and closed this ticket. On git push I hit the non-fast-forward, inspected the landed commit, confirmed my own change was a strict duplicate (theirs is slightly stronger: its cold-bootstrap carries the #1411 retry posture, and scripts/tests/git-setup-routing-test.sh covers 5 scenarios), discarded my duplicate commit (git reset --hard origin/main), and re-verified the landed guard green (git-setup-routing: 16 checks passed), alongside workflow-concurrency / drive-reservation-guard / host-capacity-lib. No further change needed here.

Follow-up filed — #1427 (not covered by b070b403): these workflow files are a render of dev-factory's onboarding/templates/workflows/*.tmpl (not FACTORY_MANIFEST-vendored). The idss render is fixed, but the source template still carries the inline fallback, so a future re-render would regress it (now caught by the CI guard) and every other consumer still carries the un-retried inline git fetch. #1427 tracks propagating the retirement to the factory template + re-rendering consumers.

Ruled by agent under ADR 0174 — veto anytime.

## Concurrent-session note (ADR 0174 audit trail) A second session-runner picked this ticket in parallel and independently reached the **same** ruling — retire the fallback's role, route every workdir through `.sandcastle/git-setup.sh`, keep a cold-bootstrap only for a fresh/empty workdir — which landed first as `b070b403` and closed this ticket. On `git push` I hit the non-fast-forward, inspected the landed commit, confirmed my own change was a strict duplicate (theirs is slightly stronger: its cold-bootstrap carries the #1411 retry posture, and `scripts/tests/git-setup-routing-test.sh` covers 5 scenarios), **discarded my duplicate commit** (`git reset --hard origin/main`), and re-verified the landed guard green (`git-setup-routing: 16 checks passed`), alongside `workflow-concurrency` / `drive-reservation-guard` / `host-capacity-lib`. No further change needed here. **Follow-up filed — #1427** (not covered by `b070b403`): these workflow files are a **render** of dev-factory's `onboarding/templates/workflows/*.tmpl` (not FACTORY_MANIFEST-vendored). The idss render is fixed, but the source template still carries the inline fallback, so a future re-render would regress it (now caught by the CI guard) and every other consumer still carries the un-retried inline `git fetch`. #1427 tracks propagating the retirement to the factory template + re-rendering consumers. Ruled by agent under ADR 0174 — veto anytime.
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#1423
No description provided.