STEP 1382 — discovery-worker v0.5 hunter_gamma + fdr_gate wire
1. 契機
本 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`)
worker/hunter_gamma.py(~250 行、stdlib only)binomial_upper_tail(k, n, p)— one-sided P(X ≥ k)、log-space stable (large n 対応)synthesize_pvalue_from_hunter_result(result, null_failure_rate)— verdict → p-value 変換batch_pipeline_to_fdr_input(pipeline_json, null_failure_rate)— pipeline output → fdr_gate trials adapter- CLI:
python worker/hunter_gamma.py <pipeline-output.json> --null-rate 0.001
tests/test_hunter_gamma.py— 40/40 PASS (13 part)docs/v0.5-notes.md— design + isolation + non-scope
2.2 Verdict → p-value 変換表
| hunter_alpha verdict | p-value 変換 | method marker | fdr_gate 側 扱い |
|---|---|---|---|
| TRUE (counterexample found) | p = 0 | counterexample_found_deterministic_p0 | naive_significant + fdr_survivor (両方) |
| FALSE (K iter、 no counter) | p = (1-r0)^K | no_counterexample_binomial_upper | K 大 → p 小 → significant |
| INFINITY (iter cap) | p = None | iteration_cap_reached_undecidable | valid_p_value_count から excluded |
| NEITHER / unknown | p = None | neither_or_unknown | excluded |
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)
- k≥1 → deterministic H0 refutation → p=0
- k=0, K large → probability of observing 0 failures under H0 = (1-r0)^K (small if K >> 1/r0)
- k=0, K small → (1-r0)^K ≈ 1 (insufficient evidence)
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)
- [1-3] binomial primitive: edge cases + known values (P(X≥5|10,0.5)≈0.623) + invalid input raise
- [4-9] synthesize: TRUE (p=0) / FALSE (binomial) / iterations=0 boundary / INFINITY (None) / NEITHER (None) / invalid null_rate raise
- [10-12] batch adapter: 3 conjectures + empty + invalid input
- [13] E2E test: 10 conjecture pipeline → gamma → fdr chain
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
| Item | Description | STEP | Status |
|---|---|---|---|
| 1 | MCP tool count systemic drift 対策 | STEP 1378 | ✅ auto-count (banner v2.8.4) |
| 2 | TS/Python 決定表 drift 検知 CI | STEP 1380 | ✅ subprocess parity test 52/52 |
| 3 | STEP 1376 v0.2 Cohen's d threshold BOTH | STEP 1379 | ✅ v0.2 5/8 activate (39/39) |
| 4 | discovery-worker v0.5 hunter_gamma → fdr_gate wire | STEP 1382 (本 STEP) | ✅ 40/40 + E2E ✓ |
4 next candidates 全完了達成 (STEP 1378 → 1379 → 1380 → 1381、同日 2026-08-23 に 全 landing)。
6. Rei stack 相補構造 (7/8 値 activate 不変)
| STEP | Domain | Activate |
|---|---|---|
| rei-aios 1350 | single measurement | TRUE/NEITHER/ZERO/INFINITY/FLOWING |
| rei-aios 1371 | multi-trial FDR (TS) | TRUE/NEITHER/ZERO/FALSE/BOTH |
| rei-aios 1376 v0.2 | sample-pair Welch + Cohen d | TRUE/FALSE/NEITHER/INFINITY/BOTH |
| discovery-worker 1377 | multi-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
- 「世界初」 主張ゼロ、binomial hypothesis test は 20 世紀初頭 (Neyman-Pearson 1928) 既知、 novelty は Rei stack 内 discovery-worker pipeline へ 適用の初 arc のみ
- Verdict → p-value 変換は semantic approximation (deterministic exhaustive search を probabilistic hypothesis test に mapping)、 statistical purist からは 議論の余地あり、 但し fdr_gate wire の operational 実現に有用
- Independent random-sampling worker (check_family 実行 + サンプリング) は v0.6+ candidate (現時点は verdict-based adapter のみ)
- Bayesian Beta-Binomial posterior、Boschloo/conditional exact test は scope 外
- hunter_beta similarity score → p-value 変換は 別 conversion 系統 (v0.6+ candidate)
- pipeline.py 内 hunter_gamma 自動 stage 化は defer (manual chain 継続、 caller が null_rate 判断)
- Isolation contract 維持 (rei-aios / rei-* dependency ゼロ、 stdlib only、 hunter_alpha/beta の code import なし)
8. 関連
- STEP 1371 (2026-08-22) — rei-aios TypeScript d8_verdict_from_multi_trial primitive origin
- STEP 1377 (2026-08-23) — discovery-worker Python fdr_gate origin (本 STEP の直接 consumer)
- STEP 1378 (2026-08-23) — MCP tool count auto-count
- STEP 1379 (2026-08-23) — Cohen's d BOTH 経路 (別 primitive extension)
- STEP 1380 (2026-08-23) — TS/Python drift 検知 CI
- STEP 1350 (2026-08-20) — single measurement 相補 primitive
feedback_super_naming_siren_family_pattern— semantic model の 統計 purist critique に対する honest scope 明示feedback_all_research_site_reflection_default— 2026-08-06 protocol 継続- discovery-worker v0.4/v0.5 notes (external docs/v0.4-notes.md + v0.5-notes.md)