ci red on main since b5cb2c30: prefer-const fires on the #1244 lazy dash getter in the three provision/re-apply drives #1251

Closed
opened 2026-09-06 03:55:02 +00:00 by matou-build-agent · 3 comments

Symptom

ci seam is RED on main and has been since b5cb2c30 (2026-09-06 00:24:58Z, "#1244 — the three provision/re-apply drives pass the dash getter to installLegCapture"). Three main pushes have landed on top of it (3e8cb171, 25d102a8, 5855aecf) and every one of them reds the same way.

Failing stage (scripts/seam-smoke.sh:166): TypeScript: build (tsc), test (vitest), lint (eslint). pnpm -r run build and pnpm -r run test pass; the failure is the last command in the stage, pnpm run lint:

app/tests/e2e/provision-archive.live.spec.ts
  136:9  error  'dash' is never reassigned. Use 'const' instead  prefer-const
app/tests/e2e/provision-nextcloud.live.spec.ts
  75:9  error  'dash' is never reassigned. Use 'const' instead  prefer-const
app/tests/e2e/settings-brand-reapply.live.spec.ts
  86:9  error  'dash' is never reassigned. Use 'const' instead  prefer-const
✖ 3 problems (3 errors, 0 warnings)

Reproduced verbatim at main's head (5855aecf) with ./node_modules/.bin/eslint app/tests/e2e/{provision-archive,provision-nextcloud,settings-brand-reapply}.live.spec.ts.

Cause

prefer-const resolves as [2, {destructuring: "any", ignoreReadBeforeAssign: false}] (verified via eslint --print-config). With ignoreReadBeforeAssign: false, the rule reports let x; … x = v; whenever the declaration and the single write sit in the same scope — even when a closure reads the binding before that write.

That is exactly the #1244 shape. In all three drives:

  • let dash: Page | undefined; is declared in the test callback body,
  • installLegCapture(live.app, live.runDir, () => dash) (the lazy getter) is registered a few lines later, while dash is still undefined — deliberately, so leg 1 / the founding prefix captures tolerate it,
  • dash = ext.page; is the single write, also directly in the test callback body.

The rule's autofix (const dash = ext.page) would break the drive: it moves the binding below installLegCapture, so the getter closes over a TDZ/undeclared dash and every leg-frame capture throws. Do not apply --fix here.

Why the sibling drives are green: journey.device.spec.ts:220 and journey.idip.debug.spec.ts:174 use the same lazy-dash pattern but write it from a nested scope (journey.device.spec.ts:466 inside a callback, journey.idip.debug.spec.ts:176 inside a try), which prefer-const does not report. The three #1244 drives write at the same scope level as the declaration. The difference is incidental, not intentional.

Fixes on the table (pick one — this needs a call, not a guess)

  1. Product-local, narrow. In each of the three drives, keep let and add // eslint-disable-next-line prefer-const with a one-line why ("read by the installLegCapture getter before the write — const would hoist it below the registration"). Three lines, no Standards-contract change.
  2. Config, repo-wide. Set 'prefer-const': ['error', { ignoreReadBeforeAssign: true }] in eslint.config.mjs. This is ESLint's documented escape hatch for precisely the declare → closure-reads → assign-later shape, and it would cover the pattern everywhere rather than three times. But eslint.config.mjs bills itself as "the Standards review contract for TypeScript" (CODING-STANDARDS.md), so loosening a rule there is a standards decision, not a mechanical repair — hence this ticket rather than a healer commit.

Adjacent gap (not this ticket's fix, worth a look)

.sandcastle/git-hooks/pre-push gates factory drift (#932) and Go (#198), but has no TypeScript lint gate. A TS lint break therefore lands on main and is only caught post-push by ci. That is how b5cb2c30 shipped red and why three further commits rode on top of it. If the shape recurs, a pre-push pnpm run lint on changed TS would close it.

Evidence

  • Heal run heal-Matou-idss-1788666697-3679075, signature 64b0fa91dd74, run https://git.matou.nz/Matou/idss/actions/runs/18682
  • run-verdict.txt: stage=TypeScript: build (tsc), test (vitest), lint (eslint) / exit=1 / ELIFECYCLE Command failed with exit code 1.
  • Host healthy (68 G free, load fine), Forgejo API 4 s — not infra.
## Symptom `ci` seam is RED on main and has been since **b5cb2c30** (2026-09-06 00:24:58Z, "#1244 — the three provision/re-apply drives pass the dash getter to installLegCapture"). Three main pushes have landed on top of it (3e8cb171, 25d102a8, 5855aecf) and every one of them reds the same way. Failing stage (`scripts/seam-smoke.sh:166`): `TypeScript: build (tsc), test (vitest), lint (eslint)`. `pnpm -r run build` and `pnpm -r run test` pass; the failure is the last command in the stage, `pnpm run lint`: ``` app/tests/e2e/provision-archive.live.spec.ts 136:9 error 'dash' is never reassigned. Use 'const' instead prefer-const app/tests/e2e/provision-nextcloud.live.spec.ts 75:9 error 'dash' is never reassigned. Use 'const' instead prefer-const app/tests/e2e/settings-brand-reapply.live.spec.ts 86:9 error 'dash' is never reassigned. Use 'const' instead prefer-const ✖ 3 problems (3 errors, 0 warnings) ``` Reproduced verbatim at main's head (5855aecf) with `./node_modules/.bin/eslint app/tests/e2e/{provision-archive,provision-nextcloud,settings-brand-reapply}.live.spec.ts`. ## Cause `prefer-const` resolves as `[2, {destructuring: "any", ignoreReadBeforeAssign: false}]` (verified via `eslint --print-config`). With `ignoreReadBeforeAssign: false`, the rule reports `let x;` … `x = v;` whenever the **declaration and the single write sit in the same scope** — even when a closure reads the binding *before* that write. That is exactly the #1244 shape. In all three drives: - `let dash: Page | undefined;` is declared in the test callback body, - `installLegCapture(live.app, live.runDir, () => dash)` (the lazy getter) is registered a few lines later, **while `dash` is still undefined** — deliberately, so leg 1 / the founding prefix captures tolerate it, - `dash = ext.page;` is the single write, also directly in the test callback body. The rule's autofix (`const dash = ext.page`) would **break the drive**: it moves the binding below `installLegCapture`, so the getter closes over a TDZ/undeclared `dash` and every leg-frame capture throws. Do not apply `--fix` here. Why the sibling drives are green: `journey.device.spec.ts:220` and `journey.idip.debug.spec.ts:174` use the same lazy-`dash` pattern but write it from a *nested* scope (`journey.device.spec.ts:466` inside a callback, `journey.idip.debug.spec.ts:176` inside a `try`), which `prefer-const` does not report. The three #1244 drives write at the same scope level as the declaration. The difference is incidental, not intentional. ## Fixes on the table (pick one — this needs a call, not a guess) 1. **Product-local, narrow.** In each of the three drives, keep `let` and add `// eslint-disable-next-line prefer-const` with a one-line why ("read by the installLegCapture getter before the write — const would hoist it below the registration"). Three lines, no Standards-contract change. 2. **Config, repo-wide.** Set `'prefer-const': ['error', { ignoreReadBeforeAssign: true }]` in `eslint.config.mjs`. This is ESLint's documented escape hatch for precisely the declare → closure-reads → assign-later shape, and it would cover the pattern everywhere rather than three times. But `eslint.config.mjs` bills itself as "the Standards review contract for TypeScript" (CODING-STANDARDS.md), so loosening a rule there is a standards decision, not a mechanical repair — hence this ticket rather than a healer commit. ## Adjacent gap (not this ticket's fix, worth a look) `.sandcastle/git-hooks/pre-push` gates factory drift (#932) and Go (#198), but has **no TypeScript lint gate**. A TS lint break therefore lands on main and is only caught post-push by `ci`. That is how b5cb2c30 shipped red and why three further commits rode on top of it. If the shape recurs, a pre-push `pnpm run lint` on changed TS would close it. ## Evidence - Heal run `heal-Matou-idss-1788666697-3679075`, signature `64b0fa91dd74`, run https://git.matou.nz/Matou/idss/actions/runs/18682 - `run-verdict.txt`: `stage=TypeScript: build (tsc), test (vitest), lint (eslint)` / `exit=1` / `ELIFECYCLE Command failed with exit code 1.` - Host healthy (68 G free, load fine), Forgejo API 4 s — not infra.
Author
Member

swarm-claim host=matou-dev-server-01 run=18673
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=18673 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Ruling: Fix 1 (product-local eslint-disable), not Fix 2 (config).

Each of the three #1244 drives keeps let dash and gains a // eslint-disable-next-line prefer-const with a one-line why (the installLegCapture getter closes over dash before the single write, so --fix to const would hoist the binding below the registration and every leg-frame capture would throw a TDZ). Three lines, zero change to eslint.config.mjs — the Standards review contract stays intact, so this is a mechanical CI repair rather than a standards loosening.

Why two-way: fully revertible by a later commit (delete three comment lines, or swap in Fix 2 if a session later prefers the repo-wide ignoreReadBeforeAssign: true), and provable by an existing check — pnpm run lint goes from red to green. Not on the one-way-door list (no credentials, no security-posture widening, no trust accept, no data destruction, no spend).

Proof: eslint app/tests/e2e/{provision-archive,provision-nextcloud,settings-brand-reapply}.live.spec.ts red before / green after.

The adjacent pre-push TS-lint-gate gap is noted but out of scope here (protected path .sandcastle/git-hooks/pre-push, #445) — filing separately if it is not already tracked.

**Ruled by agent under ADR 0174 — veto anytime.** **Ruling: Fix 1 (product-local eslint-disable), not Fix 2 (config).** Each of the three #1244 drives keeps `let dash` and gains a `// eslint-disable-next-line prefer-const` with a one-line why (the `installLegCapture` getter closes over `dash` before the single write, so `--fix` to `const` would hoist the binding below the registration and every leg-frame capture would throw a TDZ). Three lines, zero change to `eslint.config.mjs` — the Standards review contract stays intact, so this is a mechanical CI repair rather than a standards loosening. **Why two-way:** fully revertible by a later commit (delete three comment lines, or swap in Fix 2 if a session later prefers the repo-wide `ignoreReadBeforeAssign: true`), and provable by an existing check — `pnpm run lint` goes from red to green. Not on the one-way-door list (no credentials, no security-posture widening, no trust accept, no data destruction, no spend). **Proof:** `eslint app/tests/e2e/{provision-archive,provision-nextcloud,settings-brand-reapply}.live.spec.ts` red before / green after. The adjacent pre-push TS-lint-gate gap is noted but out of scope here (protected path `.sandcastle/git-hooks/pre-push`, #445) — filing separately if it is not already tracked.
Author
Member

close-report for #1251 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1251,
  "status": "success",
  "commits": [
    "5098e505"
  ],
  "changed_files": [
    "app/tests/e2e/provision-archive.live.spec.ts",
    "app/tests/e2e/provision-nextcloud.live.spec.ts",
    "app/tests/e2e/settings-brand-reapply.live.spec.ts"
  ],
  "tests": [
    {
      "command": "./node_modules/.bin/eslint app/tests/e2e/{provision-archive,provision-nextcloud,settings-brand-reapply}.live.spec.ts",
      "exit_code": 0
    },
    {
      "command": "CI=true ./node_modules/.bin/eslint .",
      "exit_code": 0
    }
  ],
  "criteria": {
    "prefer-const no longer reds on the three drives": "eslint on the three files exits 0 (commit 5098e505 adds a scoped // eslint-disable-next-line prefer-const to each let dash)",
    "no --fix applied (would TDZ the leg capturer)": "let dash retained in all three; disable comment used instead, so the installLegCapture getter still closes over the pre-write binding",
    "Standards contract untouched / decision recorded": "eslint.config.mjs unchanged; Fix 1 chosen over the config Fix 2 and ruled under ADR 0174 in the issue thread",
    "repo-wide lint green": "CI=true eslint . exits 0"
  },
  "summary": "Added a scoped prefer-const eslint-disable to the three #1244 lazy-dash drives (product-local Fix 1, ruled under ADR 0174), taking main's ci lint from red to green without touching the Standards contract.",
  "reason": "",
  "blockers": []
}
**close-report** for #1251 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1251, "status": "success", "commits": [ "5098e505" ], "changed_files": [ "app/tests/e2e/provision-archive.live.spec.ts", "app/tests/e2e/provision-nextcloud.live.spec.ts", "app/tests/e2e/settings-brand-reapply.live.spec.ts" ], "tests": [ { "command": "./node_modules/.bin/eslint app/tests/e2e/{provision-archive,provision-nextcloud,settings-brand-reapply}.live.spec.ts", "exit_code": 0 }, { "command": "CI=true ./node_modules/.bin/eslint .", "exit_code": 0 } ], "criteria": { "prefer-const no longer reds on the three drives": "eslint on the three files exits 0 (commit 5098e505 adds a scoped // eslint-disable-next-line prefer-const to each let dash)", "no --fix applied (would TDZ the leg capturer)": "let dash retained in all three; disable comment used instead, so the installLegCapture getter still closes over the pre-write binding", "Standards contract untouched / decision recorded": "eslint.config.mjs unchanged; Fix 1 chosen over the config Fix 2 and ruled under ADR 0174 in the issue thread", "repo-wide lint green": "CI=true eslint . exits 0" }, "summary": "Added a scoped prefer-const eslint-disable to the three #1244 lazy-dash drives (product-local Fix 1, ruled under ADR 0174), taking main's ci lint from red to green without touching the Standards contract.", "reason": "", "blockers": [] } ``` </details>
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#1251
No description provided.