ci: the whole seam gate is toothless — set -e is suspended inside seam(), so every stage but the last is unable to fail a run #871

Closed
opened 2026-08-26 18:43:44 +00:00 by ben · 3 comments
Owner

Found while working #867 (its step 3 asks whether the ci seam stage was actually failing on the vendored-harness drift). The answer is no, and the reason is not specific to that stage.

The defect

scripts/seam-smoke.sh runs its whole body through one function and captures the result like this:

# Run the seam, teeing its output so a failure can be reduced to a verdict the
# healer reads. The `if` keeps `set -e` fail-fast active inside seam() (its own
# subshell) while letting us capture the pipeline's real exit via PIPESTATUS.
if seam 2>&1 | tee "$SEAM_LOG"; then ec=0; else ec=${PIPESTATUS[0]}; fi

The comment states the opposite of what bash does. set -e is suspended for any command executed as an if condition, and for any non-final element of a pipeline — and that suspension propagates into a called function's body. seam() is both. So no failing command inside seam() aborts it; every later stage runs anyway; and seam() returns the exit status of its last command only.

Minimal repro, exactly the shape of the real line:

$ bash -c 'set -euo pipefail; f() { echo A; false; echo B; echo C; }
           if f 2>&1 | tee /dev/null; then ec=0; else ec=${PIPESTATUS[0]}; fi; echo "ec=$ec"'
A
B
C
ec=0

false neither aborted f nor reddened the run.

What this means in practice

seam()'s stages in order: toolchain, Factory core drift, TypeScript install, OpenAPI generated-client contract, the mermaid/theming contracts, both languages' builds, vets, tests and linters, and finally the broker module's ( cd broker; go build; go vet; go test; golangci-lint run ./... ).

Because errexit is suspended, ci's verdict is the status of that final subshell — which, errexit being suspended there too, is the status of its own last command, golangci-lint run ./.... Every other stage in the gate has been advisory output. A broken OpenAPI contract, a red go test, a failed pnpm install, a drifted vendored harness: all of them print their failure into the log and the run goes green.

This is the same class of fault as #868 (a seam that passes against nothing) but at the gate itself, and it silently weakens every "door stays shut" discipline layered into this script — each of those stages was added because something rotted unnoticed, and none of them could actually shut a door.

It also means the healer's write_verdict path has effectively never fired for a non-final-stage fault, so the stage= line it keys incident signatures on has only ever been able to say the last stage.

Confirmed hiding behind it right now

  • Factory core drift — check-harness-drift.sh exits 1 today (#867, 6620f7ca hand-edited two vendored files). ci has been green throughout.

What else is behind it is not yet known: nobody has seen an errexit-enforced run of this script. Enumerating that is part of this ticket — the fix cannot land blind, because restoring the gate turns every currently-hidden failure into a red main at once and stalls the swarm.

The fix (proven shape, not yet landed)

Re-arming set -e inside the subshell does NOT work — the suspension survives it:

$ bash -c 'set -euo pipefail; f() { echo A; false; echo B; }
           if ( set -e; f ) 2>&1 | tee /dev/null; then ec=0; else ec=${PIPESTATUS[0]}; fi; echo "ec=$ec"'
A
B
ec=0

What does work is taking the pipeline out of the condition entirely and reading the failure from an ERR trap, keeping pipefail so the pipeline reports seam's status rather than tee's:

ec=0
seam_failed() { ec=$?; write_verdict "$ec"; rm -f "$SEAM_LOG"; exit "$ec"; }
trap seam_failed ERR
seam 2>&1 | tee "$SEAM_LOG"
trap - ERR
rm -f "$SEAM_LOG"
$ bash -c 'set -euo pipefail; f() { echo A; false; echo B; }
           trap "echo TRAP ec=\$?" ERR; f 2>&1 | tee /dev/null; echo unreachable'
A
TRAP ec=1
# exit 1

f aborts at the failing command, the trap fires, the script exits non-zero, and write_verdict still gets the real failing stage off the teed log (which is why the log is read for the stage name rather than a variable — that part of the design is fine and unchanged).

Acceptance

  • An errexit-enforced run of scripts/seam-smoke.sh is completed and every stage that fails is listed on this ticket — the honest inventory of what the gate has been hiding.
  • Each of those is fixed, or filed with a named owner ticket, BEFORE the gate is re-armed.
  • seam-smoke.sh fails on a non-final stage failure, proven by an offline test that injects a failing stage (there is no test for this today — that absence is why the comment could assert the opposite of the behaviour for months).
  • write_verdict still writes the correct stage= for a non-final-stage failure.

ready-for-session: the inventory run needs nix develop and a real toolchain, and the re-arming decision is a judgement about when to let main go red — not swarm-sandbox work.

Refs: #867 (the drift the gate failed to catch), #868 (a seam proving nothing, at the route layer), ADR 0100.

Found while working #867 (its step 3 asks whether the `ci` seam stage was actually failing on the vendored-harness drift). The answer is no, and the reason is not specific to that stage. ## The defect `scripts/seam-smoke.sh` runs its whole body through one function and captures the result like this: ```bash # Run the seam, teeing its output so a failure can be reduced to a verdict the # healer reads. The `if` keeps `set -e` fail-fast active inside seam() (its own # subshell) while letting us capture the pipeline's real exit via PIPESTATUS. if seam 2>&1 | tee "$SEAM_LOG"; then ec=0; else ec=${PIPESTATUS[0]}; fi ``` The comment states the opposite of what bash does. `set -e` is suspended for any command executed as an `if` condition, **and** for any non-final element of a pipeline — and that suspension propagates into a called function's body. `seam()` is both. So no failing command inside `seam()` aborts it; every later stage runs anyway; and `seam()` returns the exit status of its **last** command only. Minimal repro, exactly the shape of the real line: ```bash $ bash -c 'set -euo pipefail; f() { echo A; false; echo B; echo C; } if f 2>&1 | tee /dev/null; then ec=0; else ec=${PIPESTATUS[0]}; fi; echo "ec=$ec"' A B C ec=0 ``` `false` neither aborted `f` nor reddened the run. ## What this means in practice `seam()`'s stages in order: toolchain, **Factory core drift**, TypeScript install, **OpenAPI generated-client contract**, the mermaid/theming contracts, both languages' builds, vets, tests and linters, and finally the `broker` module's `( cd broker; go build; go vet; go test; golangci-lint run ./... )`. Because errexit is suspended, `ci`'s verdict is the status of that final subshell — which, errexit being suspended there too, is the status of its own last command, `golangci-lint run ./...`. **Every other stage in the gate has been advisory output.** A broken OpenAPI contract, a red `go test`, a failed `pnpm install`, a drifted vendored harness: all of them print their failure into the log and the run goes green. This is the same class of fault as #868 (a seam that passes against nothing) but at the gate itself, and it silently weakens every "door stays shut" discipline layered into this script — each of those stages was added *because* something rotted unnoticed, and none of them could actually shut a door. It also means the healer's `write_verdict` path has effectively never fired for a non-final-stage fault, so the `stage=` line it keys incident signatures on has only ever been able to say the last stage. ## Confirmed hiding behind it right now - **Factory core drift** — `check-harness-drift.sh` exits 1 today (#867, `6620f7ca` hand-edited two vendored files). `ci` has been green throughout. What else is behind it is not yet known: nobody has seen an errexit-enforced run of this script. **Enumerating that is part of this ticket** — the fix cannot land blind, because restoring the gate turns every currently-hidden failure into a red `main` at once and stalls the swarm. ## The fix (proven shape, not yet landed) Re-arming `set -e` inside the subshell does NOT work — the suspension survives it: ```bash $ bash -c 'set -euo pipefail; f() { echo A; false; echo B; } if ( set -e; f ) 2>&1 | tee /dev/null; then ec=0; else ec=${PIPESTATUS[0]}; fi; echo "ec=$ec"' A B ec=0 ``` What does work is taking the pipeline out of the condition entirely and reading the failure from an `ERR` trap, keeping `pipefail` so the pipeline reports `seam`'s status rather than `tee`'s: ```bash ec=0 seam_failed() { ec=$?; write_verdict "$ec"; rm -f "$SEAM_LOG"; exit "$ec"; } trap seam_failed ERR seam 2>&1 | tee "$SEAM_LOG" trap - ERR rm -f "$SEAM_LOG" ``` ```bash $ bash -c 'set -euo pipefail; f() { echo A; false; echo B; } trap "echo TRAP ec=\$?" ERR; f 2>&1 | tee /dev/null; echo unreachable' A TRAP ec=1 # exit 1 ``` `f` aborts at the failing command, the trap fires, the script exits non-zero, and `write_verdict` still gets the real failing stage off the teed log (which is why the log is read for the stage name rather than a variable — that part of the design is fine and unchanged). ## Acceptance - [ ] An errexit-enforced run of `scripts/seam-smoke.sh` is completed and every stage that fails is listed on this ticket — the honest inventory of what the gate has been hiding. - [ ] Each of those is fixed, or filed with a named owner ticket, BEFORE the gate is re-armed. - [ ] `seam-smoke.sh` fails on a non-final stage failure, proven by an offline test that injects a failing stage (there is no test for this today — that absence is why the comment could assert the opposite of the behaviour for months). - [ ] `write_verdict` still writes the correct `stage=` for a non-final-stage failure. `ready-for-session`: the inventory run needs `nix develop` and a real toolchain, and the re-arming decision is a judgement about when to let `main` go red — not swarm-sandbox work. Refs: #867 (the drift the gate failed to catch), #868 (a seam proving nothing, at the route layer), ADR 0100.
Author
Owner

The inventory — first pass, run on main at 974962bf

Ran the seam locally under nix develop, each stage isolated so one failure cannot hide the next. Fourteen stages:

RED   ts:build        pnpm -r run build
PASS  ts:test         pnpm -r run test
RED   ts:lint         pnpm run lint          (see caveat)
PASS  go:gofmt        go:build  go:vet  go:test  go:lint
PASS  go:dev-build    go:dev-vet
PASS  broker:build    broker:vet  broker:test  broker:lint

All eleven Go and broker stages are genuinely green, which is consistent with the diagnosis: the gate's real verdict has been golangci-lint run ./... in broker/, and that has been passing.

RED 1 — pnpm -r run build: the TypeScript type gate has been broken since 2026-08-25

app build: tests/unit/mermaidDocs.test.ts(7,3): error TS2305: Module '"../../../scripts/check-mermaid.mjs"' has no exported member 'DEFAULT_TARGETS'.
app build: tests/unit/slicesYaml.test.ts(9,8): error TS7016: Could not find a declaration file for module '../../../scripts/check-slices-yaml.mjs'. … implicitly has an 'any' type.
app build: Failed
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @idss/app@0.1.0 build: `vue-tsc -p tsconfig.json`

Both files are tracked, both landed with d9eabfe8 (#834, 2026-08-25), and ci has been green on every push since. DEFAULT_TARGETS is exported (scripts/check-mermaid.mjs:141) — the failure is that the app's vue-tsc project has no declaration path for a plain .mjs under scripts/, so one import resolves to a shape without the member and the other is an implicit any. Note pnpm -r run test PASSES: vitest does not typecheck, so the tests these files contain genuinely run and genuinely pass. It is the type gate that is down, which is exactly the kind of rot the stage exists to catch.

RED 2 — pnpm run lint: one real error, and a much larger reporting problem

22,585 errors across 16 files. 15 of those 16 files are git-ignored local build artefacts — .claude/worktrees/…/mermaid.min.js, app/dist-electron/, app/dist-package/, app/.dev/payload/, test-results/…/trace/*.js — which a fresh CI checkout would not have. So this stage is very likely GREEN on the runner today, and I am not claiming otherwise.

The one tracked source file that genuinely fails:

dashboard/tests/unit/backupReplicationMatrix.test.ts
  526:11  error  'wrapper' is assigned a value but never used  @typescript-eslint/no-unused-vars

Landed with d1c78cfd (#822, 2026-08-25). One line, trivially fixable.

Worth its own note either way: pnpm run lint walking into dist-electron/, test-results/ and .claude/worktrees/ at all means the eslint ignore config does not track .gitignore. On a developer machine that turns a real lint run into 22k lines of noise around a single genuine error, which is its own reason nobody runs it by hand.

What this changes about the fix order

Smaller than feared — two tracked-source failures, both from 2026-08-25, both narrow. That makes re-arming the gate a realistic near-term move rather than a long excavation:

  1. Fix app/tests/unit/mermaidDocs.test.ts + slicesYaml.test.ts so vue-tsc passes (a .d.ts for the two scripts/*.mjs helpers, or move the helpers into a typed workspace package).
  2. Fix the unused wrapper at backupReplicationMatrix.test.ts:526.
  3. Decide whether pnpm run lint should honour .gitignore — separate from re-arming, but it will bite the first person who runs the gate locally.
  4. THEN land the ERR-trap fix and its offline test.

Caveats on this pass

  • Run on this laptop's nix develop, not the matou-workstation runner. Go 1.23.8 / node 22.16.0 / pnpm 9.15.9 there.
  • The ts:lint verdict is confounded by a dirty working tree, as described. A clean-checkout re-run is still owed before step 4.
  • Stages are isolated, so a failure that only appears in ORDER (a stage depending on an earlier stage's side effects) would not show here. pnpm install ran first, which is the only ordering dependency in the script.

Ruled by agent under ADR 0174 — veto anytime.

## The inventory — first pass, run on `main` at `974962bf` Ran the seam locally under `nix develop`, each stage isolated so one failure cannot hide the next. Fourteen stages: ``` RED ts:build pnpm -r run build PASS ts:test pnpm -r run test RED ts:lint pnpm run lint (see caveat) PASS go:gofmt go:build go:vet go:test go:lint PASS go:dev-build go:dev-vet PASS broker:build broker:vet broker:test broker:lint ``` All eleven Go and broker stages are genuinely green, which is consistent with the diagnosis: the gate's real verdict has been `golangci-lint run ./...` in `broker/`, and that has been passing. ### RED 1 — `pnpm -r run build`: the TypeScript type gate has been broken since 2026-08-25 ``` app build: tests/unit/mermaidDocs.test.ts(7,3): error TS2305: Module '"../../../scripts/check-mermaid.mjs"' has no exported member 'DEFAULT_TARGETS'. app build: tests/unit/slicesYaml.test.ts(9,8): error TS7016: Could not find a declaration file for module '../../../scripts/check-slices-yaml.mjs'. … implicitly has an 'any' type. app build: Failed ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @idss/app@0.1.0 build: `vue-tsc -p tsconfig.json` ``` Both files are tracked, both landed with `d9eabfe8` (#834, 2026-08-25), and `ci` has been green on every push since. `DEFAULT_TARGETS` *is* exported (`scripts/check-mermaid.mjs:141`) — the failure is that the app's `vue-tsc` project has no declaration path for a plain `.mjs` under `scripts/`, so one import resolves to a shape without the member and the other is an implicit `any`. Note `pnpm -r run test` PASSES: vitest does not typecheck, so the tests these files contain genuinely run and genuinely pass. It is the *type* gate that is down, which is exactly the kind of rot the stage exists to catch. ### RED 2 — `pnpm run lint`: one real error, and a much larger reporting problem 22,585 errors across 16 files. **15 of those 16 files are git-ignored local build artefacts** — `.claude/worktrees/…/mermaid.min.js`, `app/dist-electron/`, `app/dist-package/`, `app/.dev/payload/`, `test-results/…/trace/*.js` — which a fresh CI checkout would not have. So this stage is very likely GREEN on the runner today, and I am not claiming otherwise. The one tracked source file that genuinely fails: ``` dashboard/tests/unit/backupReplicationMatrix.test.ts 526:11 error 'wrapper' is assigned a value but never used @typescript-eslint/no-unused-vars ``` Landed with `d1c78cfd` (#822, 2026-08-25). One line, trivially fixable. Worth its own note either way: `pnpm run lint` walking into `dist-electron/`, `test-results/` and `.claude/worktrees/` at all means the eslint ignore config does not track `.gitignore`. On a developer machine that turns a real lint run into 22k lines of noise around a single genuine error, which is its own reason nobody runs it by hand. ### What this changes about the fix order Smaller than feared — two tracked-source failures, both from 2026-08-25, both narrow. That makes re-arming the gate a realistic near-term move rather than a long excavation: 1. Fix `app/tests/unit/mermaidDocs.test.ts` + `slicesYaml.test.ts` so `vue-tsc` passes (a `.d.ts` for the two `scripts/*.mjs` helpers, or move the helpers into a typed workspace package). 2. Fix the unused `wrapper` at `backupReplicationMatrix.test.ts:526`. 3. Decide whether `pnpm run lint` should honour `.gitignore` — separate from re-arming, but it will bite the first person who runs the gate locally. 4. THEN land the `ERR`-trap fix and its offline test. ### Caveats on this pass - Run on this laptop's `nix develop`, not the `matou-workstation` runner. Go 1.23.8 / node 22.16.0 / pnpm 9.15.9 there. - The `ts:lint` verdict is confounded by a dirty working tree, as described. A clean-checkout re-run is still owed before step 4. - Stages are isolated, so a failure that only appears in ORDER (a stage depending on an earlier stage's side effects) would not show here. `pnpm install` ran first, which is the only ordering dependency in the script. Ruled by agent under ADR 0174 — veto anytime.

The inventory — an errexit-enforced run of every stage (AC1)

Run 2026-08-26 on matou-workstation inside nix develop. Method: each stage's own commands re-run in a fresh bash -c 'set -euo pipefail; …' child process — a new process is the one shape the errexit suspension cannot leak into (( set -e; … ) does not work, as the ticket says; a child bash -c does), and running each stage in its own child means the sweep continues past a failure instead of stopping at the first, so the inventory is complete rather than first-red-only.

21 stages. 18 green, 3 red.

stage verdict
toolchain PASS
Factory core drift (check-harness-drift.sh) PASS — see note below
Shell: scripts/tests/*.sh sweep (#873) FAIL
TypeScript: pnpm install PASS
OpenAPI: check:client PASS
Docs: mermaid blocks parse PASS
Docs: slice-map yaml unquoted-# PASS
TypeScript: pnpm -r run build (tsc) FAIL (exit 2)
TypeScript: pnpm -r run test (vitest) PASS
TypeScript: pnpm run lint (eslint) FAIL (5,699 errors)
Go: gofmt PASS
Go: build / vet / test / golangci-lint ./... PASS (4/4)
Go: dev-tag build + vet PASS (2/2)
Go(broker): build / vet / test / golangci-lint PASS (4/4)

The one confirmed-hiding item in the ticket body is stale, in the good direction. Factory core drift is green: #867's hand-edited vendored files were fixed by the FACTORY_REF bump in 974962bf, which landed after this ticket was filed. Nothing is hiding behind that stage now.

The three, and what each one was

1. pnpm -r run build — two TypeScript errors. Both are the same shape: a repo-root .mjs checker imported by a seam test, whose declaration file did not keep up.

  • TS2305 — #798 added DEFAULT_TARGETS to scripts/check-mermaid.mjs and to app/tests/unit/mermaidDocs.test.ts, but not to scripts/check-mermaid.d.mts.
  • TS7016 — #834's scripts/check-slices-yaml.mjs shipped with no declaration file at all, so app/tests/unit/slicesYaml.test.ts imported an implicit any under strict.

Fixed: DEFAULT_TARGETS declared, and scripts/check-slices-yaml.d.mts written to match check-mermaid.d.mts's shape.

2. pnpm run lint — 5,699 errors, and only ONE of them is source. 5,698 come from linting app/dist-electron/ (packaged main+preload bundles) and test-results/…/report/trace/ (a rehearsal drive's Playwright trace viewer — thousands of minified vendor lines). Both are gitignored, but eslint's flat config does not read .gitignore, and the flat ignores list had **/dist/** without **/dist-electron/** or test-results/**. So the lint stage's verdict depended on whether the checkout happened to have driven or packaged once — a stage that is red on a working machine and green on a fresh clone. Both ignored now, same class as the **/dist/** already there.

The 1 real error is genuine and fixed: an unused wrapper binding in dashboard/tests/unit/backupReplicationMatrix.test.ts:526 (the mount itself is load-bearing — it is what makes client.reads reach 1 — so the call stays, only the dead binding goes).

3. scripts/tests/rehearsal-rented-target-test.sh — reads REHEARSAL_KEEP_RED_DROPLET from the AMBIENT shell. Case 4 ("a matching IP is deleted by its id") assumes keep-on-red is off; cases 7/8 set it explicitly per-invocation. But it is a standing export on the workstation's rehearsal executor, so it is in the environment of any shell on that host — including this session, and including the host-mode ci runner. The test was therefore red on the one host it most needs to pass on and green everywhere else. The test now unsets it: a test's preconditions belong to the test, never to whoever's shell it runs in.

Note this stage already had teeth before today's fix (#873 made it return 1 rather than lean on set -e), so this one was not hidden by #871 — it was hidden by ci not having run since 05:41 (see the residue below).

AC2 — none deferred

All three are fixed in 96f425ca, not filed. None needed an owner ticket.


A second defect, found by the test rather than the inventory

write_verdict could not survive its own errexit. errs="$(grep -hiE …|grep -v|tail -12)" exits 1 when nothing matches, pipefail hands that to the command substitution, and the assignment failing under a now-live set -e killed the writer before it wrote anything. So exactly the quiet failures that most need a verdict — a stage that dies without printing an error-ish line — would have produced none, and the run's exit code would have been flattened to grep's 1 instead of the stage's real code.

This was latent in the old shape too (write_verdict was called from an if-body, where errexit is live), it just could never be reached, because the only stage that could fail was the last one and it always printed something. My test caught it on the first green attempt: the injected stage exits 3 silently, and the assertion exit=3 failed with 1. Every capture in write_verdict is || true-guarded now.

AC3/AC4 — the proof

scripts/tests/seam-errexit-test.sh, 10 checks, red before the fix with FAIL: a failing non-final stage did not redden the run (exit 0) — the gate is toothless.

It injects a failing stage into the real script: only seam()'s body is swapped (for a synthetic ALPHA/BETA/GAMMA), so the errexit preamble, stage(), write_verdict() and the runner block under test are the committed file verbatim, and the swap asserts it actually took. It proves:

  1. a failing NON-FINAL stage reddens the run with its own exit code (3, not a flattened 1);
  2. seam() stops AT the failing command — neither the rest of that stage nor any later stage runs;
  3. AC4 — write_verdict writes stage=INJECTED-STAGE-BETA, the failing stage, not the last one;
  4. a silent failure still gets its log-tail fallback in the verdict (the second defect above);
  5. a last-stage failure still reddens and names itself (the one case the old shape could catch — no regression);
  6. an all-green seam still exits 0 and leaves no verdict behind for the healer to chase;
  7. the committed script never returns to a shape that suspends errexit — if/while/until seam, seam …&&/||, ! seam are all asserted absent, and the ERR trap asserted present. The defect was one line under a comment asserting the inverse of it, so the shape itself is pinned.

It lives in scripts/tests/, so #873's sweep runs it from the next ci onward.

And the whole thing end to end: a full errexit-enforced run of scripts/seam-smoke.sh — 12 stages, exit 0, seam smoke OK, no verdict file left behind. Re-run again after rebasing onto #868/#753, and the Go half again after #875 landed.

The fix

Exactly the ticket's proposed shape, with local ec=$? as the trap's first statement:

seam_failed() {
  local ec=$?
  write_verdict "$ec"
  rm -f "$SEAM_LOG"
  exit "$ec"
}
trap seam_failed ERR
seam 2>&1 | tee "$SEAM_LOG"
trap - ERR

GOTCHAS #93 carries the rule, both footguns (the harness's, and write_verdict's), and the inventory.

Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout: one commit, revertible; every claim above is reproducible with bash scripts/tests/seam-errexit-test.sh and nix develop -c bash scripts/seam-smoke.sh.

Residue — and it is not small

ci has not fired since 34c0863a at 05:41 today. Eleven main pushes have produced zero runs, including this fix. I applied the remedy the workflow's own header documents (touch .forgejo/workflows/ci.yml and push, c45adc47) — it did not work. A POST .../actions/workflows/ci.yml/dispatches returns 204 and produces no run either, while Forgejo serves ci.yml at main (200) and has c45adc47 as the branch head. Scheduled workflows (triage, resume, watchdog) keep running normally, so the instance and the runner are alive; it is this workflow's push and dispatch events that go nowhere.

So the gate is armed but not firing. From main's point of view those are the same outcome, which is why I am naming it here rather than letting a green ticket imply a working gate. Filed as its own ticket.

## The inventory — an errexit-enforced run of every stage (AC1) Run 2026-08-26 on `matou-workstation` inside `nix develop`. Method: each stage's own commands re-run in a **fresh `bash -c 'set -euo pipefail; …'` child process** — a new process is the one shape the errexit suspension cannot leak into (`( set -e; … )` does not work, as the ticket says; a child `bash -c` does), and running each stage in its own child means the sweep continues past a failure instead of stopping at the first, so the inventory is complete rather than first-red-only. **21 stages. 18 green, 3 red.** | stage | verdict | |---|---| | toolchain | PASS | | Factory core drift (`check-harness-drift.sh`) | **PASS** — see note below | | Shell: `scripts/tests/*.sh` sweep (#873) | **FAIL** | | TypeScript: `pnpm install` | PASS | | OpenAPI: `check:client` | PASS | | Docs: mermaid blocks parse | PASS | | Docs: slice-map yaml unquoted-`#` | PASS | | TypeScript: `pnpm -r run build` (tsc) | **FAIL** (exit 2) | | TypeScript: `pnpm -r run test` (vitest) | PASS | | TypeScript: `pnpm run lint` (eslint) | **FAIL** (5,699 errors) | | Go: gofmt | PASS | | Go: `build` / `vet` / `test` / `golangci-lint` `./...` | PASS (4/4) | | Go: dev-tag build + vet | PASS (2/2) | | Go(broker): `build` / `vet` / `test` / `golangci-lint` | PASS (4/4) | **The one confirmed-hiding item in the ticket body is stale, in the good direction.** Factory core drift is green: #867's hand-edited vendored files were fixed by the `FACTORY_REF` bump in `974962bf`, which landed after this ticket was filed. Nothing is hiding behind that stage now. ### The three, and what each one was **1. `pnpm -r run build` — two TypeScript errors.** Both are the same shape: a repo-root `.mjs` checker imported by a seam test, whose declaration file did not keep up. - `TS2305` — #798 added `DEFAULT_TARGETS` to `scripts/check-mermaid.mjs` **and** to `app/tests/unit/mermaidDocs.test.ts`, but not to `scripts/check-mermaid.d.mts`. - `TS7016` — #834's `scripts/check-slices-yaml.mjs` shipped with **no** declaration file at all, so `app/tests/unit/slicesYaml.test.ts` imported an implicit `any` under `strict`. Fixed: `DEFAULT_TARGETS` declared, and `scripts/check-slices-yaml.d.mts` written to match `check-mermaid.d.mts`'s shape. **2. `pnpm run lint` — 5,699 errors, and only ONE of them is source.** 5,698 come from linting `app/dist-electron/` (packaged main+preload bundles) and `test-results/…/report/trace/` (a rehearsal drive's Playwright trace viewer — thousands of minified vendor lines). Both are gitignored, but **eslint's flat config does not read `.gitignore`**, and the flat `ignores` list had `**/dist/**` without `**/dist-electron/**` or `test-results/**`. So the lint stage's verdict depended on whether the checkout happened to have driven or packaged once — a stage that is red on a working machine and green on a fresh clone. Both ignored now, same class as the `**/dist/**` already there. The 1 real error is genuine and fixed: an unused `wrapper` binding in `dashboard/tests/unit/backupReplicationMatrix.test.ts:526` (the mount itself is load-bearing — it is what makes `client.reads` reach 1 — so the call stays, only the dead binding goes). **3. `scripts/tests/rehearsal-rented-target-test.sh` — reads `REHEARSAL_KEEP_RED_DROPLET` from the AMBIENT shell.** Case 4 ("a matching IP is deleted by its id") assumes keep-on-red is off; cases 7/8 set it explicitly per-invocation. But it is a **standing export on the workstation's rehearsal executor**, so it is in the environment of any shell on that host — including this session, and including the host-mode `ci` runner. The test was therefore red on the one host it most needs to pass on and green everywhere else. The test now unsets it: a test's preconditions belong to the test, never to whoever's shell it runs in. Note this stage **already had teeth** before today's fix (#873 made it `return 1` rather than lean on `set -e`), so this one was not hidden by #871 — it was hidden by `ci` not having run since 05:41 (see the residue below). ### AC2 — none deferred All three are **fixed** in `96f425ca`, not filed. None needed an owner ticket. --- ## A second defect, found by the test rather than the inventory `write_verdict` could not survive its own errexit. `errs="$(grep -hiE …|grep -v|tail -12)"` exits 1 when nothing matches, `pipefail` hands that to the command substitution, and the assignment failing under a now-live `set -e` killed the writer **before it wrote anything**. So exactly the quiet failures that most need a verdict — a stage that dies without printing an error-ish line — would have produced **none**, and the run's exit code would have been flattened to grep's `1` instead of the stage's real code. This was latent in the old shape too (`write_verdict` was called from an `if`-body, where errexit is live), it just could never be reached, because the only stage that could fail was the last one and it always printed something. My test caught it on the first green attempt: the injected stage exits 3 silently, and the assertion `exit=3` failed with `1`. Every capture in `write_verdict` is `|| true`-guarded now. ## AC3/AC4 — the proof `scripts/tests/seam-errexit-test.sh`, **10 checks, red before the fix** with `FAIL: a failing non-final stage did not redden the run (exit 0) — the gate is toothless`. It injects a failing stage into the **real script**: only `seam()`'s body is swapped (for a synthetic ALPHA/BETA/GAMMA), so the errexit preamble, `stage()`, `write_verdict()` and the runner block under test are the committed file verbatim, and the swap asserts it actually took. It proves: 1. a failing NON-FINAL stage reddens the run **with its own exit code** (3, not a flattened 1); 2. `seam()` stops AT the failing command — neither the rest of that stage nor any later stage runs; 3. **AC4** — `write_verdict` writes `stage=INJECTED-STAGE-BETA`, the *failing* stage, not the last one; 4. a silent failure still gets its log-tail fallback in the verdict (the second defect above); 5. a last-stage failure still reddens and names itself (the one case the old shape could catch — no regression); 6. an all-green seam still exits 0 and leaves **no** verdict behind for the healer to chase; 7. the committed script never returns to a shape that suspends errexit — `if/while/until seam`, `seam …&&/||`, `! seam` are all asserted absent, and the ERR trap asserted present. The defect was one line under a comment asserting the inverse of it, so the shape itself is pinned. It lives in `scripts/tests/`, so #873's sweep runs it from the next `ci` onward. And the whole thing end to end: a full errexit-enforced run of `scripts/seam-smoke.sh` — 12 stages, **exit 0**, `seam smoke OK`, no verdict file left behind. Re-run again after rebasing onto #868/#753, and the Go half again after #875 landed. ## The fix Exactly the ticket's proposed shape, with `local ec=$?` as the trap's first statement: ```bash seam_failed() { local ec=$? write_verdict "$ec" rm -f "$SEAM_LOG" exit "$ec" } trap seam_failed ERR seam 2>&1 | tee "$SEAM_LOG" trap - ERR ``` GOTCHAS #93 carries the rule, both footguns (the harness's, and `write_verdict`'s), and the inventory. Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout: one commit, revertible; every claim above is reproducible with `bash scripts/tests/seam-errexit-test.sh` and `nix develop -c bash scripts/seam-smoke.sh`. ## Residue — and it is not small **`ci` has not fired since `34c0863a` at 05:41 today.** Eleven main pushes have produced zero runs, including this fix. I applied the remedy the workflow's own header documents (touch `.forgejo/workflows/ci.yml` and push, `c45adc47`) — **it did not work**. A `POST .../actions/workflows/ci.yml/dispatches` returns `204` and produces no run either, while Forgejo serves `ci.yml` at `main` (200) and has `c45adc47` as the branch head. Scheduled workflows (`triage`, `resume`, `watchdog`) keep running normally, so the instance and the runner are alive; it is this workflow's push and dispatch events that go nowhere. So the gate is armed but not firing. From `main`'s point of view those are the same outcome, which is why I am naming it here rather than letting a green ticket imply a working gate. Filed as its own ticket.

Close report

Landed: 96f425ca (the fix) and c45adc47 (the ci re-registration attempt), on main.

What changed

file why
scripts/seam-smoke.sh the ERR-trap runner shape; write_verdict's captures || true-guarded; the #873 stage's now-stale "#871 suspends errexit" comment corrected
scripts/tests/seam-errexit-test.sh new — 10 checks, injects a failing NON-FINAL stage into the real script
scripts/check-mermaid.d.mts DEFAULT_TARGETS declared (#798's miss)
scripts/check-slices-yaml.d.mts new — #834's checker had no declaration at all
dashboard/tests/unit/backupReplicationMatrix.test.ts the one real lint error: dead wrapper binding
eslint.config.mjs ignore dist-electron/ + test-results/ build output
scripts/tests/rehearsal-rented-target-test.sh unset the ambient REHEARSAL_KEEP_RED_DROPLET
docs/GOTCHAS.md entry #93 (renumbered from 92 on rebase — #875 took 92)
STATUS.md header lead

Acceptance

  • AC1 — errexit-enforced run completed, every failing stage listed: 21 stages, 18 green, 3 red, in the inventory comment above. Factory core drift, the one item the ticket named as confirmed-hiding, is green — 974962bf fixed it after this ticket was filed.
  • AC2 — all three fixed here, before the gate re-armed, in the same commit. None deferred to an owner ticket.
  • AC3 — scripts/tests/seam-errexit-test.sh: red before (a failing non-final stage did not redden the run (exit 0) — the gate is toothless), 10 checks green after. Swept by #873's stage, so it runs in ci from now on.
  • AC4 — write_verdict writes stage=INJECTED-STAGE-BETA for a non-final failure, asserted; plus the exit= code is the failing stage's own (3), not a flattened 1.

Proof

  • bash scripts/tests/seam-errexit-test.sh → seam-errexit: 10 checks passed
  • nix develop -c bash scripts/seam-smoke.sh → 12 stages, exit 0, seam smoke OK, no verdict file. Run twice (before and after rebasing onto #868/#753), plus the Go half again after #875 landed.
  • The old shape's toothlessness, reproduced against the real script before the fix: the variant ran ALPHA → BETA → BETA-CONTINUED-PAST-ITS-OWN-FAILURE → GAMMA → seam smoke OK, exit 0.

Two things this session found that the ticket did not ask for

  1. write_verdict could not survive its own errexit — a no-match grep under pipefail killed the writer before it wrote anything, so a quiet failure would have produced no verdict and a flattened exit code. Latent under the old shape, fatal under the new one. Caught by the new test, not by inspection.
  2. ci has not fired at all since 05:41 today — eleven pushes, zero runs; the documented re-registration touch failed, and workflow_dispatch returns 204 and produces nothing while scheduled workflows keep running. Filed as #880 (bug, priority, ready-for-session), with the full ruling-out. This fix has therefore not been verified by ci itself — only locally, twice, end to end. That is the honest limit of what this session can claim, and #880 is the ticket that closes it.

Ruled by agent under ADR 0174 — veto anytime.

## Close report **Landed:** `96f425ca` (the fix) and `c45adc47` (the ci re-registration attempt), on `main`. ### What changed | file | why | |---|---| | `scripts/seam-smoke.sh` | the ERR-trap runner shape; `write_verdict`'s captures `\|\| true`-guarded; the #873 stage's now-stale "#871 suspends errexit" comment corrected | | `scripts/tests/seam-errexit-test.sh` | **new** — 10 checks, injects a failing NON-FINAL stage into the real script | | `scripts/check-mermaid.d.mts` | `DEFAULT_TARGETS` declared (#798's miss) | | `scripts/check-slices-yaml.d.mts` | **new** — #834's checker had no declaration at all | | `dashboard/tests/unit/backupReplicationMatrix.test.ts` | the one real lint error: dead `wrapper` binding | | `eslint.config.mjs` | ignore `dist-electron/` + `test-results/` build output | | `scripts/tests/rehearsal-rented-target-test.sh` | unset the ambient `REHEARSAL_KEEP_RED_DROPLET` | | `docs/GOTCHAS.md` | entry **#93** (renumbered from 92 on rebase — #875 took 92) | | `STATUS.md` | header lead | ### Acceptance - [x] **AC1** — errexit-enforced run completed, every failing stage listed: 21 stages, 18 green, **3 red**, in the inventory comment above. Factory core drift, the one item the ticket named as confirmed-hiding, is green — `974962bf` fixed it after this ticket was filed. - [x] **AC2** — all three fixed here, before the gate re-armed, in the same commit. None deferred to an owner ticket. - [x] **AC3** — `scripts/tests/seam-errexit-test.sh`: red before (`a failing non-final stage did not redden the run (exit 0) — the gate is toothless`), 10 checks green after. Swept by #873's stage, so it runs in `ci` from now on. - [x] **AC4** — `write_verdict` writes `stage=INJECTED-STAGE-BETA` for a non-final failure, asserted; plus the `exit=` code is the failing stage's own (3), not a flattened 1. ### Proof - `bash scripts/tests/seam-errexit-test.sh` → `seam-errexit: 10 checks passed` - `nix develop -c bash scripts/seam-smoke.sh` → 12 stages, **exit 0**, `seam smoke OK`, no verdict file. Run twice (before and after rebasing onto #868/#753), plus the Go half again after #875 landed. - The old shape's toothlessness, reproduced against the real script before the fix: the variant ran ALPHA → BETA → **`BETA-CONTINUED-PAST-ITS-OWN-FAILURE`** → GAMMA → `seam smoke OK`, exit **0**. ### Two things this session found that the ticket did not ask for 1. **`write_verdict` could not survive its own errexit** — a no-match `grep` under `pipefail` killed the writer before it wrote anything, so a quiet failure would have produced no verdict and a flattened exit code. Latent under the old shape, fatal under the new one. Caught by the new test, not by inspection. 2. **`ci` has not fired at all since 05:41 today** — eleven pushes, zero runs; the documented re-registration touch failed, and `workflow_dispatch` returns 204 and produces nothing while scheduled workflows keep running. Filed as **#880** (`bug`, `priority`, `ready-for-session`), with the full ruling-out. **This fix has therefore not been verified by `ci` itself** — only locally, twice, end to end. That is the honest limit of what this session can claim, and #880 is the ticket that closes it. Ruled by agent under ADR 0174 — veto anytime.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#871
No description provided.