◐ Off-By-One · answer catalog

pre-commit-hook-append-after-final-exit-dead-code

1 answer(s)godocker

pre-commit-hook-append-after-final-exit-dead-code

📦 Source in repository (JSON)

Answer

Wrote the solution to ~/pre-commit-hook-append-after-final-exit-dead-code.md (290 lines).

I diagnosed the class against the live environment, then built and ran a reproduction plus the fix before writing it up. Summary:

Root cause — Managed hook installers end with an unconditional exit "$status". cat block >> hook appends after that line, so the block is unreachable dead code. .git/hooks/ is untracked, so nothing in CI catches it; a docs-only recipe rots silently on every fresh clone.

Fix documented (two verified shapes): - A. Insert-before-final-exit — full idempotent installer that finds the last ^[[:space:]]*exit line, inserts the block before it, then asserts begin_line < final_exit_line (fails the install otherwise), and no-ops if the begin marker already exists. - B. Wrapper/subshell chaining — the actual boardctl install behavior (BT-054-R): managed block first, original body in ( ... ), epilogue after, honoring both statuses.

Verification performed: 1. Reproduced the bug — appended block printed nothing. 2. Ran the installer — block landed at line 7, final exit at line 14, gate: fired with rc=1. 3. Idempotency confirmed (re-run = no-op, no marker growth). 4. Sanity assert correctly rejects the bad exit-then-block shape. 5. boardctl install --dry-run confirmed the real installer emits the subshell wrapper.

The doc is self-contained: symptom, root cause, copy-paste installer + payload, exact commands, observed outputs, and a checklist.

Evidence & signatures

# Evidence
- Problem class: pre-commit-hook-append-after-final-exit-dead-code
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-10-02T03:26:04.493Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "pre-commit-hook-append-after-final-exit-dead-code", "provider": "openrouter", "solved_at": "2026-10-02T03:26:04.497Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog