CI-time Verilog bake sync gate

TS VERILOG_*_TABLE 定数 vs 実 Verilog の drift 検出
STEP 1802 · 2026-09-06 · commit 9ff5eb83a

目的

STEP 1779 の VERILOG_TABLE_PROVENANCE.warning field で 明示的に 挙げた STEP 1780+ candidate (ii) 「CI-time bake sync check (Verilog file と TS 定数 の diff)」 の 実装。 藤本さん 2026-09-06 turn 5 hard discipline 「照合していないのに 照合していると 名乗る」 pattern の structural fix

data/verilog/dfumt8_alu.v が 書き換えられた 時、 TS 定数 VERILOG_NOT_TABLE / VERILOG_AND_TABLE / VERILOG_OR_TABLE (src/mcp/d8-connectors.ts) が sync されない と、 STEP 1779 の cross-impl-drift claim が 古い snapshot と 比較し続ける。 fail 前提 の claim なので、 ずれても 気づかない。 本 gate が 検出する。

実装

scripts/check-verilog-bake-sync.ts = 165 行、 Node/tsx で 実行。 Regex で Verilog file の case block (NOT / AND / OR) を 直接 parse、 cross-tier default rule も 内部で 適用。 TS 定数を 同 file から regex 抽出、 全 136 entry で diff。

f4 の buggy dump_verilog_tables.py (line 59-60 で NOT hardcode) には 依存せず。 実 Verilog の case block を 直接 parse する self-contained 実装。

Exit code protocol

0 = TS 定数 と Verilog が sync (drift なし、 全 136/136 一致)
1 = drift 検出。 stderr に:
  • divergent entry list (sample 15 件、 op/a/b/verilog/baked)
  • 対応方針 3 種:
    • (a) intentional Verilog change → TS 定数 update + bakeDate 更新
    • (b) accidental change / seven-logic 側 変更 → revert or investigate
    • (c) parser out of date (新 op 追加時) → script parser update
  • Anti-pattern 明示禁止: 「tableProvenance.currentVerilogNotComparedfalse に flip する 回避 は 禁止、 藤本さん 2026-09-06 turn 5 hard discipline」
2 = parse error (Verilog file or TS 定数 unreadable)

使用例

# 直接実行
npx tsx scripts/check-verilog-bake-sync.ts

# npm script 経由 (test suite 統合)
npm run test:step1802

# CI で drift 検出
npx tsx scripts/check-verilog-bake-sync.ts || exit 1

現状 実行結果:

[bake-sync] OK: VERILOG_*_TABLE in src\mcp\d8-connectors.ts
[bake-sync]     is in sync with data\verilog\dfumt8_alu.v
[bake-sync]     (checked 8+64+64=136 entries)

Test 統合

test/step1802-verilog-bake-sync-test.ts (39 行) = spawnSync で script を 呼び、 exit 0 を assert。 npm test 経路 で 自動検出可能、 開発者が Verilog 変更を 忘れた場合 も test suite で 発見。

現状: 1/1 pass (136/136 一致確認)

Discipline 継承 (STEP 1803 corrigendum の pattern)

本 STEP は STEP 1779 の tableProvenance.warning field と 直接 対応。 warning field の 文言:

To eliminate this failure mode, either
  (i) implement runtime .v parsing in a future STEP,
  or (ii) add CI-time bake sync check
       (dump_verilog_tables.py output vs VERILOG_*_TABLE constant diff).

本 STEP は (ii) の 実装。 (i) runtime .v parsing は 別 STEP candidate、 未実装。

Honest scope

主張しないこと:
  • 本 gate が Verilog file の 全 operator を parse する (現状 NOT / AND / OR のみ、 OMEGA/PHI/PSI/XOR/ADIABATIC/RESET は 未 cover)
  • Verilog の semantic 全体 を verify する (case block の regex parse のみ、 module 構造 や timing は 対象外)
  • runtime に .v file を parse する (build-time / commit-time の gate のみ、 STEP 1779 の currentVerilogNotCompared: true 状態は 不変)
Not in scope (別 STEP candidate):
  • pre-commit hook 統合 (scripts/git-hooks/install.sh 経路)
  • Verilog の 他 op の bake sync check
  • Lean 4 file の runtime parse (STEP 1779 warning (i))

Cross-refs