STEP 1380 — TS/Python 決定表 drift 検知 CI

STEP 1380 cross-language parity CI test 52/52 PASS
2026-08-23 · rei-aios TS ↔ discovery-worker Python semantic contract drift 検知

1. 契機

STEP 1377 (2026-08-23) で discovery-worker Python fdr_gate.spec_table() を rei-aios TypeScript d8MultiTrialSpecTable() の Python 移植として 実装。 決定表 8 rule M1-M8 は 「一字一句同じ」 と 明示したが、 現時点は manual 同期 = 実装 lag / drift risk。

本 STEP: **subprocess ベースで TS 実行時に Python spec 実測 + 差分 diff** の CI test を 追加、 drift 発生時 test fail で 即検出。

2. 実装

2.1 Python 側 (discovery-worker/worker/fdr_gate.py)

CLI に --spec-json flag 追加 (spec table のみを JSON dump、 他 output なし):

if args.spec_json:
    print(json.dumps(spec_table(), ensure_ascii=False, indent=2))
    return

2.2 TS 側 (rei-aios test/step1380-ts-python-drift-check-test.ts)

2.3 SKIP conditions (graceful degradation)

3. Verify 実測 (52/52 PASS)

3.1 Semantic contract 一致

[6] rule 名 M1-M8 全一致: TS ↔ Python
[7] verdict (D-FUMT₈ name) 全 8 rule 一致
[8] reason (payload key) 全 8 rule 一致
[10] activation subset 一致: 5 値 (TRUE / FALSE / NEITHER / ZERO / BOTH)
[11] reason set 一致: 8 reason 全部 双方向 subset check

3.2 Condition variations (documented allowed diffs)

RuleTS conditionPython condition
M1trials.length === 0trials.length == 0
M2fdrQ null / NaN / ≤0 / ≥1fdr_q null / NaN / <=0 / >=1
M3alpha null / NaN / ≤0 / ≥1alpha null / NaN / <=0 / >=1
M4全 trial の pValue が invalidall p_value invalid
M5naive_significant_count === 0naive_significant_count == 0
M6fdr_survivors === 0 かつ naive_significant > 0fdr_survivors == 0 and naive > 0
M70 < fdr_survivors < naive_significant0 < fdr_survivors < naive
M8fdr_survivors > 0 かつ === naive_significantfdr_survivors == naive > 0

Documented parity: 0/8 exact match, 8 language variations (allowed): === vs ==、 ≤ vs <=、 かつ vs and、 camelCase vs snake_case、 Japanese vs English 混在。 「documentation 差」 として test 内で warn 出力、 fail しない。

4. Design rationale

4.1 「Semantic contract」 vs 「documentation」 分離

4.2 SKIP graceful design

CI 環境が Python missing / discovery-worker absent 場合、 test は SKIP (exit 0)、 fail しない。 rei-aios は Python 依存を hard requirement 化しない。 但し 存在するなら full parity 検証。

4.3 Drift 発生時の 挙動

5. Honest scope

  1. 「世界初」 主張ゼロ、 cross-language contract testing は 30+ 年前既知 pattern (Contract Testing / Consumer-Driven Contracts、 Fowler 2011 等)、 novelty は Rei stack 内 TS/Python parity 初 CI arc のみ
  2. subprocess spawnSync 依存 = Python 環境 hard requirement、 但し SKIP graceful で mitigation
  3. Condition parity は intentional差 が 主 (language variation)、 exact match 期待は 非現実的 → warn-only。 v0.2 で shared spec source (ex: JSON schema) から 両実装 生成する option candidate
  4. drift 検出 rule 名一字違い (M1 → M01 等) は catch する、 但し **意味は同じで 名前だけ変更** も FAIL 扱い (breaking change の 明示)
  5. Python 側 fdr_gate.py に --spec-json flag 追加は minor CLI 追加のみ、 既存 CLI (normal mode) と 排他 (両方 required なら error)、 backward compat 維持
  6. 本 CI test は npm run test:step1380 で 実行、 GitHub Actions 統合 は 別 STEP (Rei stack は 現状 CI service 未 setup)

6. 関連