arc 3 段 (STEP 1632 spatial + STEP 1635 temporal + STEP 1638 irreversibility) は 「repo 常駐 の 部品」 として 実装された。
但し STEP 1638 の honest scope に 明示された 欠陥 = 「誰かが 手動で 実行しない 限り 誰も verdict を 見ない」。
本 STEP は 既存 scripts/git-hooks/pre-commit (3 section 実装済) に Section 4 を 追加し、 3 段を **commit 単位で 発火する 装置** に 昇格させる。
if [ -f data/checker-ledger/entries.jsonl ]; then npx tsx scripts/checker/ledger-bootstrap.ts --verify # exit 1 → hook exit 1 + block message # exit 0 → 1 行 summary print + continue fi
| staged file pattern | trigger する test |
|---|---|
scripts/checker/ledger*.ts or test/step1638-*.ts | test:step1638 (73 test, ~2s) |
scripts/checker/refactor-guard.ts or test/refactor-guards/ or test/step1635-*.ts | test:step1635 (31 test, ~1s) |
scripts/checker/arbitrariness-audit.ts or test/step1632-*.ts | test:step1632 (28 test, ~1s) |
SKIP_CHECKER_VERIFY=1 git commit ... # Section 4 のみ skip SKIP_ALL_HOOKS=1 git commit ... # 全 hook skip (既存) git commit --no-verify # 全 hook skip (git native)
$ sed -i 's/"specDigest":"4e94/"specDigest":"deadbee/' data/checker-ledger/entries.jsonl
$ SKIP_LEAN_VERIFY=1 INBOX_PROTOCOL_BYPASS=1 bash scripts/git-hooks/pre-commit
[pre-commit] SKIP_LEAN_VERIFY=1 — skipping Lean verification
═══════════════════════════════════════════════════════════════
[pre-commit] Commit blocked: ledger verify FAILED (exit 1)
chain: ok=false entries=2
VIOLATION[hash-mismatch] seq=1: stored b7974b99b160… ≠ recomputed 0349e663fc50…
bindings: ok=false total=1 intact=0 drifted=1 missing=0
DRIFTED: harvest-lag-window-compared-does-not-follow-actual-retention …
This means one of:
- the ledger chain has been tampered
- a bound refactor-guard has been deleted (status = missing)
- a bound refactor-guard has drifted structurally (status = drifted)
To bypass (defeats the purpose, use only for hook maintenance):
SKIP_CHECKER_VERIFY=1 git commit ...
═══════════════════════════════════════════════════════════════
exit: 1
$ SKIP_CHECKER_VERIFY=1 SKIP_LEAN_VERIFY=1 INBOX_PROTOCOL_BYPASS=1 bash scripts/git-hooks/pre-commit
[pre-commit] SKIP_LEAN_VERIFY=1 — skipping Lean verification
[pre-commit] SKIP_CHECKER_VERIFY=1 — skipping Section 4 (checker arc)
exit: 0
$ SKIP_LEAN_VERIFY=1 INBOX_PROTOCOL_BYPASS=1 bash scripts/git-hooks/pre-commit
[pre-commit] SKIP_LEAN_VERIFY=1 — skipping Lean verification
[pre-commit] chain: ok=true entries=2 | bindings: ok=true total=1 intact=1 drifted=0 missing=0
exit: 0
3 scenario の 実測が Section 4 の 全 code path を cover。 block / bypass / pass の 3 判定が 期待通りに 動く 証拠。
test/step1649-pre-commit-checker-test.ts: Section 1: SKIP_CHECKER_VERIFY=1 bypass (subprocess exit 0 + message check) Section 2: SKIP_ALL_HOOKS=1 regression (Section 4 が 走らないこと の regression) Section 3: clean ledger, hook runs verify (compact one-liner "chain: ok=true ... | bindings: ok=true ...") Section 4: tampered ledger detected (temp tamper → verify exit 1 with hash-mismatch) Section 5: guard removed from registry (temp REGISTRY empty → verify exit 1 with MISSING) Section 6: ledger-verify output shape (line format stability for hook parsing)
実装過程で Section 3 (Lean 4 verify) の exit 0 が 2 箇所 (SKIP_LEAN_VERIFY 時 と 「no staged .lean file」 時) にあり、 Section 4 到達前に 抜けていた ことを 発見・修正。
section3_skipped=1 flag + if [ -n "$staged_lean" ] wrap で fall-through に 変更、 「Section 3 を skip しても Section 4 は 走る」 不変条件を 実装。
| STEP | 部品 | 次元 | test | hook 統合 |
|---|---|---|---|---|
| 1632 | arbitrariness_audit | spatial | 28 | conditional (staged file 時) |
| 1635 | refactor-guard | temporal | 31 | conditional (staged file 時) |
| 1638 | hash-chained ledger | irreversibility | 73 | always (~1s) |
| 1649 | hook 統合 | enforcement | 18 | — |
arc 累計 test 150/150 PASS。 「保証は 外部からしか 来ない」 の 3 checker + 「commit 単位で 発火」 の enforcement layer で、 4 部品 が operational に 揃った。
--no-verify flag は 依然 全 hook を skip する (git native の 契約)。 これは pre-commit hook の 一般的 限界で、 CI (GitHub Actions 等) が 補完する 前提。--no-verify の 抜け穴も 事後検出可能。SKIP_CHECKER_VERIFY=1 使用の 累計 記録 → 「なぜ bypass したか」 の rationale trail。