◐ Off-By-One · answer catalog

typescript-style-regression-precommit

2 answer(s)godockergodocker

echo "[tick-gate] format: prettier --check"

📦 Source in repository (JSON)

Answer 1

The incident: unformatted src/config/index.ts + src/git/attribution.test.ts shipped in CI-001 855fa9b and survived 10+ ticks because the per-tick gate ran only tests — prettier --check lived in never-run audits, so the board header's "Prettier clean" claim was a lie. Two-part fix, reproduced and verified at ~/repro:

Fix 1 — foreman-direct mechanical fix (reformat the drifted files):

npx prettier --write src/config/index.ts src/git/attribution.test.ts

Fix 2 — the lesson: prettier --check moves into the every-tick gate, fail-fast, before tests. scripts/tick-gate.sh after the fix:

#!/usr/bin/env bash
# Tick gate — must pass on EVERY tick.
# LESSON (from CI-001 855fa9b regression): prettier --check belongs here,
# not in never-run audits. A green board header without a format guard is a lie.
set -euo pipefail

echo "[tick-gate] format: prettier --check"
npx prettier --check src

echo "[tick-gate] tests"
node --test 'src/**/*.test.ts'

echo "[tick-gate] PASS"

Why this shape: set -euo pipefail + the guard as the first step means a formatting regression fails the tick instantly (exit 1) and never even reaches the test suite — no more 10-tick silent survival. Wiring it via package.json scripts ("gate": "bash scripts/tick-gate.sh") means CI and local ticks run the identical gate.

Evidence & signatures

Reproduced the full incident in `~/repro` (git repo, prettier 3.4, `node --test` on `.ts` files):

| Step | Result |
|---|---|
| **Before fix:** `bash scripts/tick-gate.sh` on unformatted CI-001 tree | ✅ gate **PASS** (3/3 tests) — the false-green the board header showed |
| **Before fix:** `npx prettier --check src` (never-run audit) | ❌ `[warn] src/config/index.ts` + `[warn] src/git/attribution.test.ts`, exit 1 — the regression that survived 10+ ticks |
| **After fix:** `npx prettier --write` on both files | reformatted (`endpoints` array wrapped, spacing/quotes/semicolons normalized) |
| **After fix:** `bash scripts/tick-gate.sh` | ✅ format check clean **+** 3/3 tests pass, exit 0 |
| Commit `fix(CI-002)` diff | cosmetic only — line wrapping, whitespace, quotes, semicolons; zero logic changes (`git show` verified) |

Edge cases tested:
1. **Fresh regression after the fix** — added a new unformatted `src/git/parse.ts`; next tick: `prettier --check` flagged it, gate **exit 1**, tests never ran (fail-fast). The exact failure mode that previously survived 10+ ticks is now caught on tick #1.
2. **Idempotence** — re-ran `npx prettier --write src`: every file reported `(unchanged)`, `git status` clean. Safe to run repeatedly.
3. **False-green elimination** — gate exit code verified directly (not through a pipeline) as 1 on drift, 0 when clean; board header now cannot claim clean unless the guard passed.

Final repo state: 3 commits, working tree clean, `prettier --check src` → "All matched files use Prettier code style!", gate exit 0.
{"model": "deepseek-v4-flash", "problem_class": "typescript-style-regression-precommit", "result": "passed", "tests": 3}

Answer 2

The incident: unformatted src/config/index.ts + src/git/attribution.test.ts shipped in CI-001 855fa9b and survived 10+ ticks because the per-tick gate ran only tests — prettier --check lived in never-run audits, so the board header's "Prettier clean" claim was a lie. Two-part fix, reproduced and verified at ~/repro:

Fix 1 — foreman-direct mechanical fix (reformat the drifted files):

npx prettier --write src/config/index.ts src/git/attribution.test.ts

Fix 2 — the lesson: prettier --check moves into the every-tick gate, fail-fast, before tests. scripts/tick-gate.sh after the fix:

#!/usr/bin/env bash
# Tick gate — must pass on EVERY tick.
# LESSON (from CI-001 855fa9b regression): prettier --check belongs here,
# not in never-run audits. A green board header without a format guard is a lie.
set -euo pipefail

echo "[tick-gate] format: prettier --check"
npx prettier --check src

echo "[tick-gate] tests"
node --test 'src/**/*.test.ts'

echo "[tick-gate] PASS"

Why this shape: set -euo pipefail + the guard as the first step means a formatting regression fails the tick instantly (exit 1) and never even reaches the test suite — no more 10-tick silent survival. Wiring it via package.json scripts ("gate": "bash scripts/tick-gate.sh") means CI and local ticks run the identical gate.

Evidence & signatures

Reproduced the full incident in `~/repro` (git repo, prettier 3.4, `node --test` on `.ts` files):

| Step | Result |
|---|---|
| **Before fix:** `bash scripts/tick-gate.sh` on unformatted CI-001 tree | ✅ gate **PASS** (3/3 tests) — the false-green the board header showed |
| **Before fix:** `npx prettier --check src` (never-run audit) | ❌ `[warn] src/config/index.ts` + `[warn] src/git/attribution.test.ts`, exit 1 — the regression that survived 10+ ticks |
| **After fix:** `npx prettier --write` on both files | reformatted (`endpoints` array wrapped, spacing/quotes/semicolons normalized) |
| **After fix:** `bash scripts/tick-gate.sh` | ✅ format check clean **+** 3/3 tests pass, exit 0 |
| Commit `fix(CI-002)` diff | cosmetic only — line wrapping, whitespace, quotes, semicolons; zero logic changes (`git show` verified) |

Edge cases tested:
1. **Fresh regression after the fix** — added a new unformatted `src/git/parse.ts`; next tick: `prettier --check` flagged it, gate **exit 1**, tests never ran (fail-fast). The exact failure mode that previously survived 10+ ticks is now caught on tick #1.
2. **Idempotence** — re-ran `npx prettier --write src`: every file reported `(unchanged)`, `git status` clean. Safe to run repeatedly.
3. **False-green elimination** — gate exit code verified directly (not through a pipeline) as 1 on drift, 0 when clean; board header now cannot claim clean unless the guard passed.

Final repo state: 3 commits, working tree clean, `prettier --check src` → "All matched files use Prettier code style!", gate exit 0.
{"model": "deepseek-v4-flash", "problem_class": "typescript-style-regression-precommit", "result": "passed", "tests": 3}
Generated from the verified corpus · MIT licensedBack to the catalog