# STEP 1948 — orphan-gauge-v02-archive-detection

**Timestamp**: 2026-09-11T00:25 (JST)
**Tab worktree**: main (rei-aios-9b、shared tree — device refinement は 全 user 対象)
**Commit**: (this commit)

## 一行 summary

orphan-gauge v0.2: archive detection 8 pattern 拡張 + defaultConfig excludeModes に archive 追加、RUIN 1,136 → 334 (-70.6%)、test 45/45 PASS。

## 主要 finding / evidence

**Refactor summary** (STEP 1947 evidence-based):
- `src/aios/orphan-gauge/consumption-mode.ts`: v0.1 (89 line) → v0.2 (114 line)
  - `ARCHIVE_DIR_PREFIXES` 新設: `data/external-oss/` + `data/external-research/` + `data/anki/` + `data/lean4-transfer/` (4 dir)
  - `ARCHIVE_FILENAME_PATTERNS` 拡張: v0.1 3 pattern + v0.2 5 pattern = 計 8
    - `^approved-YYYY-MM-DD.json$` — invention approval trail
    - `^publish-log-.*.json$` — publication audit log
    - `^.+[-_]YYYY-MM-DD([-_T.].*)?.\w+$` — mid-filename dated dataset
    - `^YYYY-MM-DD[-_].+.\w+$` — date-prefixed
    - `^.+[-_]YYYYMMDDTHHMMSS.*.\w+$` — compact ISO datetime
- `src/aios/orphan-gauge/index.ts`: `defaultConfig.excludeModes` = `["human-read"]` → `["human-read", "archive"]`

**Before/after real-repo measurement** (both runs 2026-09-11):

| Metric | v0.1 (STEP 1947) | v0.2 (STEP 1948) | Δ |
|---|---|---|---|
| total in-scope | 18,824 | 14,882 | -3,942 (-20.9%) |
| scoped-out | 1,176 | 5,118 | +3,942 (+335%) |
| LIVE | 142 | 132 | -10 |
| ORPHAN | 1,210 | 811 | -399 |
| **RUIN** | **1,136** | **334** | **-802 (-70.6%)** |
| DEAD | 16,336 | 13,605 | -2,731 |

**v0.2 remaining RUIN 334 の cluster 分布**:
- `data/lean4-mathlib/*` : **297 (89%)** — mostly stable Lean 4 proofs (mathlib-prep artifacts)
- `data/open-problems/*` : 5
- `data/phase-a-ranking/*` : 2 / `data/buchi25-spot/*` : 2 / others 24 clusters (1-2 each)

**Actionable rate estimate v0.2**:
- lean4-mathlib 297 × STEP 1947 sample A rate 20% (1/5) ≈ **59** actionable
- non-lean4-mathlib 37 × sample rate ~2% (1/44) ≈ **1** actionable
- **v0.2 actionable ≈ 60 / 334 ≈ 18%**  (**v0.1 の 4% から 5x 改善**)

**Test evidence**: 45/45 PASS (v0.1 29 + v0.2 15 new + T26b defaultConfig update = 45)

## Honest scope

- **予測との差**:
  - Notepad STEP 1947 で「RUIN → 150-200」「actionable rate 40-70%」 と予測
  - **実測は RUIN → 334 / actionable rate ~18%** = 予測より下振れ (RUIN は 2x 大きい、actionable rate は half 以下)
  - 原因: (a) `data/*/latest.json` を archive に auto-classify しない選択 (active 域 誤分類 risk 回避)、いくつか completed-domain latest.json が RUIN 残 (b) lean4-mathlib 297 stable proof cluster が想定より大きい (mathlib-prep + CollatzRei bridge proofs は 「stale だが 正しく referenced」 の 塊、簡単には shrink できない)
  - 下振れ = 予測精度の失敗、装置改善の失敗ではない (70.6% shrinkage 自体は 実質改善)
- **主張しないこと**:
  - actionable rate 18% は sample n=50 からの extrapolation、n=5 (lean4-mathlib cluster only) で 20% 推定は wide CI (95% CI 0-72%)
  - v0.2 が「正解」ではない、v0.3+ で `data/*/latest.json` (completed domain) や lean4-mathlib pilot-file 検出 の 追加余地あり
  - archive-classified 除外 = user が「これ 消したい」 と 判断する self-audit path を 装置経路 から外す trade-off、必要なら `excludeModes: ["human-read"]` で 明示 include 可
- **v0.2 の 内在 trade-off**:
  - **利**: RUIN 70.6% 縮小 で 装置 signal-to-noise 大幅 improve、次 arc の user attention を lean4-mathlib pilot 特定 に集中できる
  - **害**: 3,942 file が「見えない」 になる、hidden regression risk (例: `data/external-oss/**` に misplaced Rei 自作 file があっても検出 escape)。緩和策: 定期 `--include-human` フル scan で 全 layer 再確認可能

## Failure mode (機械学習用 dataset)

- **(ll) 予測 vs 実測 の 楽観 bias**: STEP 1947 で予測「RUIN 150-200 / actionable 40-70%」→ 実測「334 / 18%」。予測は sample cluster distribution から extrapolate したが、v0.2 で 除外 対象になる file が cluster ごとに 一様分布しない (lean4-mathlib 5 sample のうち 4 が B stable proof、しかし cluster 全体で は 90% が同 pattern) ため 過小評価。Prevention: 予測は「達成 min-max range」ではなく「lower bound + upper bound 幅」+「予測失敗時の recovery path」を併記、point prediction 禁止。
- **(mm) dir-prefix vs filename-pattern の 優先順位 定義漏れ**: v0.2 で `data/lean4-transfer/*.lean` は dir prefix hit で archive、`data/lean4-mathlib/CollatzRei/Step1248PrintAxioms.lean` は filename pattern hit なく pipeline → RUIN。だが両方 stable "STEP N の 一時 artifact" pattern。Prevention: pattern 追加 は 単発でなく category 全体を 一貫 heuristic で覆う設計を先に (今回は「STEP N artifact = archive」 の 統一 pattern を出さなかった、v0.3 candidate)。
- **(nn) v0.2 で 全 lean4-mathlib excluded にはしない honest gap**: `data/lean4-mathlib/CollatzRei/` は Rei 自作 の 進行中 Lean 4 proof、外部 mirror ではない = archive 全 excluded は overreach。しかし cluster 内 に isolated pilot (SnstRealComparison) が混在。Prevention: pilot 検出は import graph (別 device candidate) が要る、単純 heuristic では区別不能、v0.2 で cover しないのは spec 通り。

## 詳細参照 (任意)

- 装置本体: `src/aios/orphan-gauge/consumption-mode.ts` v0.2 (114 line) + `index.ts` defaultConfig update
- Test: `test/step1926-orphan-gauge-test.ts` (45 test, v0.1 29 + v0.2 15 + T26b) 45/45 PASS
- v0.2 report: `data/orphan-gauge/step-1948/v02-report-summary.json` (counts + ruinList + cluster distribution + honest scope)
- v0.1 evidence: `data/orphan-gauge/step-1947/sample-50-verdicts.tsv`
- 関連 STEP: STEP 1909 (chat-Claude simulator origin)、STEP 1926 (device v0.1)、STEP 1947 (50-sample calibration = 本 STEP の evidence base)

## 追加 section — v0.3 candidate (defer、藤本さん judgment 領分)

**残り 334 RUIN の うち 大 cluster** = lean4-mathlib 297 (89%)。v0.3 で対応するなら:

1. **Lean import-graph reader**: `.lean` file の `import` chain を parse、build graph、isolated (0 imported-by、mathlib-prep 系除く) node を A verdict 候補として flag。SnstRealComparison.lean が典型。
2. **`data/*/latest.json` conditional archive**: 「domain fetcher script が scripts/research-radar/ or scripts/data-fetchers/ に **存在** かつ **最終 run が Xd 以内**」条件で active 判定、そうでなければ archive。実装 = fetcher script 名 heuristic + git log 依存 で 中複雑。
3. **STEP N 一時 artifact 一括 archive**: filename に `^step\d+_.+\.(lean|json)$` or path が `data/lean4-transfer/` は既 v0.2 covered、他 (`Step1248PrintAxioms.lean` 等) は名前 pattern 検出可能。

**実装 cost**: 1 は 2-3 時間 (Lean parser 必要)、2 は 1 時間、3 は 30 分。ROI 高い順 = 3 → 2 → 1。**私 推奨** = v0.3 defer (v0.2 で cost/value cliff superrior、次 arc は evidence review or 別 topic)、v0.3 起票は 「lean4-mathlib pilot cleanup arc」 の 実 need 発生時。

## Meta finding — Prediction post-mortem

STEP 1947 で「actionable rate 40-70%」 予測、実測 18%。差分 root cause:
- lean4-mathlib sample 5 → cluster 全体 297 の extrapolation、「1/5 = 20% Cluster A rate」 は 統計的 unreliable
- 「A rate cluster ごとに 均一」 隠れ assumption、実際は 「stable proof 塊 + isolated pilot 混在」 で 非 uniform

Prevention: 予測時 は 「(a) 予測レンジ 40-70% (b) sample n=5 で CI が 0-72% と 広く、20% point-estimate に強く依存 (c) 実測で下振れ ~15% 可能」 と 3 段で書けば、実測 18% を「予測範囲内」に収められた。今回 predicted range 提示 なしで point だけ → 実測との mismatch。次回 predict 時 の rule 化。
