STEP 1382 — discovery-worker v0.5 hunter_gamma + fdr_gate wire

STEP 1382 discovery-worker external test 40/40 PASS 4 next candidates 全完了
2026-08-23 · hunter_gamma primitive + pipeline → fdr_gate 直列 wire 確立

1. 契機

STEP 1377 (2026-08-23) fdr_gate landing 時 non-scope 明示: 「Pipeline auto-wire は defer。hunter_alpha/beta は p-value を 生成しない設計 (verdict TRUE/FALSE/INFINITY/NEITHER) なので caller-provided p 前提。使い方 3 通り: CLI / import / **future v0.5+ hunter_gamma stage で wire up 検討**」

本 STEP: 「future v0.5+ hunter_gamma stage」 を 実装。 pipeline output → p-value → fdr_gate の 直列 wire を 確立し、 fdr_gate primitive の 「caller-provided p 前提」 制約を discovery-worker 内部で 解決。

2. 実装 (discovery-worker external repo)

2.1 新規 file 3 (local commit `ac0338e`)

2.2 Verdict → p-value 変換表

hunter_alpha verdictp-value 変換method markerfdr_gate 側 扱い
TRUE (counterexample found)p = 0counterexample_found_deterministic_p0naive_significant + fdr_survivor (両方)
FALSE (K iter、 no counter)p = (1-r0)^Kno_counterexample_binomial_upperK 大 → p 小 → significant
INFINITY (iter cap)p = Noneiteration_cap_reached_undecidablevalid_p_value_count から excluded
NEITHER / unknownp = Noneneither_or_unknownexcluded

2.3 Semantic model

H0: 真の failure rate ≤ r0 (「conjecture holds ≥ 100(1-r0)%」)

H1: rate > r0 (「conjecture has non-trivial failure」)

Observed: K iterations, k counterexamples (typically k=0 for exhaustive search up to cap、または k≥1)

2.4 順序原則遵守

null_failure_rate は 引数注入強制 (定数化禁止)。 caller (pipeline runner) が 「先に決めた」 rate を 渡す設計。 pre-registration workflow との 相補 (rei-aios STEP 1359 rei-preregister 系譜)。

3. Pipeline wire (直列 usage)

# Step 1: pipeline runs (hunter_alpha + hunter_beta)
python worker/pipeline.py --input-dir input/
  # → output/pipeline-batch-XXX.json

# Step 2: hunter_gamma synthesizes p-values from pipeline verdicts
python worker/hunter_gamma.py output/pipeline-batch-XXX.json \
  --null-rate 0.001 --trials-only \
  > output/gamma-trials-batch-XXX.json

# Step 3: fdr_gate applies BH FDR + D-FUMT₈ aggregate verdict
python worker/fdr_gate.py output/gamma-trials-batch-XXX.json \
  --fdr-q 0.05 --alpha 0.05

3-stage direct chain。 各 stage は 独立 CLI = manual composition (caller judgment で null_rate / fdr_q / alpha を 決めて 直列実行)、 auto-pipeline 化は defer (別 STEP)。

4. Verify 実測 (40/40 PASS)

4.1 Test coverage (13 part)

4.2 E2E test [13] 実測

Input: 10 conjectures pipeline output
  - 2 TRUE (counterexamples): "true-1", "true-2"
  - 7 FALSE (iter 100/200/500/1000/2000/5000/10000): "false-1..7"
  - 1 INFINITY (iter cap): "inf-1"

hunter_gamma (null_rate=0.001) 変換:
  - true-1, true-2 → p=0 (deterministic)
  - false-7 (100 iter) → p ≈ 0.999^100 ≈ 0.905 (not significant)
  - false-6 (200) → p ≈ 0.819
  - false-1 (500) → p ≈ 0.606
  - false-2 (1000) → p ≈ 0.368
  - false-3 (2000) → p ≈ 0.135
  - false-4 (5000) → p ≈ 6.7e-3 (significant!)
  - false-5 (10000) → p ≈ 4.5e-5 (highly significant!)
  - inf-1 → p=None (excluded)

fdr_gate (fdr_q=0.05, alpha=0.05):
  - valid_p_value_count = 9 (INFINITY excluded ✓)
  - naive_significant_count = 4 (2 TRUE + false-4 + false-5)
  - fdr_survivor_count = 4 (BH survives 4/4)
  - aggregate_verdict = TRUE (all_naive_survive_fdr)

chain end-to-end 動作 ✓。 INFINITY の valid_p_value_count 除外は 「undecidable evidence の 統計汚染回避」 の operational 実現。

5. defer 5 → 4 next candidates 全完了 status

ItemDescriptionSTEPStatus
1MCP tool count systemic drift 対策STEP 1378✅ auto-count (banner v2.8.4)
2TS/Python 決定表 drift 検知 CISTEP 1380✅ subprocess parity test 52/52
3STEP 1376 v0.2 Cohen's d threshold BOTHSTEP 1379✅ v0.2 5/8 activate (39/39)
4discovery-worker v0.5 hunter_gamma → fdr_gate wireSTEP 1382 (本 STEP)✅ 40/40 + E2E ✓

4 next candidates 全完了達成 (STEP 1378 → 1379 → 1380 → 1381、同日 2026-08-23 に 全 landing)。

6. Rei stack 相補構造 (7/8 値 activate 不変)

STEPDomainActivate
rei-aios 1350single measurementTRUE/NEITHER/ZERO/INFINITY/FLOWING
rei-aios 1371multi-trial FDR (TS)TRUE/NEITHER/ZERO/FALSE/BOTH
rei-aios 1376 v0.2sample-pair Welch + Cohen dTRUE/FALSE/NEITHER/INFINITY/BOTH
discovery-worker 1377multi-trial FDR (Python sibling)TRUE/NEITHER/ZERO/FALSE/BOTH
discovery-worker 1381 (本 STEP)hunter_gamma (fdr_gate feeder、p-value synthesis adapter)indirect — fdr_gate 経由で 全 5 値 emit 可能

hunter_gamma 自体は verdict emit しない (feeder role)。 Union 7/8 値 activate は STEP 1377 で 既 達成、 本 STEP は 「pipeline 経由の 実 caller」 追加のみで value coverage 変化なし。

7. Honest scope

  1. 「世界初」 主張ゼロ、binomial hypothesis test は 20 世紀初頭 (Neyman-Pearson 1928) 既知、 novelty は Rei stack 内 discovery-worker pipeline へ 適用の初 arc のみ
  2. Verdict → p-value 変換は semantic approximation (deterministic exhaustive search を probabilistic hypothesis test に mapping)、 statistical purist からは 議論の余地あり、 但し fdr_gate wire の operational 実現に有用
  3. Independent random-sampling worker (check_family 実行 + サンプリング) は v0.6+ candidate (現時点は verdict-based adapter のみ)
  4. Bayesian Beta-Binomial posterior、Boschloo/conditional exact test は scope 外
  5. hunter_beta similarity score → p-value 変換は 別 conversion 系統 (v0.6+ candidate)
  6. pipeline.py 内 hunter_gamma 自動 stage 化は defer (manual chain 継続、 caller が null_rate 判断)
  7. Isolation contract 維持 (rei-aios / rei-* dependency ゼロ、 stdlib only、 hunter_alpha/beta の code import なし)

8. 関連