STEP 1347HOTFIX + 予防修正 STEP 1346 継承 + Downloads 3 file review 経由

daily-invention-reporter hotfix + archived rei-automator-bridge 予防修正

2026-08-20 藤本さん共有 3 file (Downloads/{rei-automator-bridge.ts, invention-engine.ts, daily-invention-reporter.ts}) の review 依頼を契機に、 前 session (別 tab) 指摘 「verdict を仮説テキストをキーにした Map で対応させているので同一テキスト仮説が 2 件出ると片方上書きされる」 が本体 STEP 1346 実装に的中していると 実測 verify → hotfix + archive/ 予防修正。 藤本伸樹 × Claude Code / 2026-08-20

1. 経緯

藤本さん共有 (2026-08-20): C:\Users\user\Downloads\ 内の 3 file (rei-automator-bridge.ts + invention-engine.ts + daily-invention-reporter.ts) と、 前 session (別 tab) の作業結果として次の 3 主張:

  1. invention-engine.ts に STEP 1279 wire を書き戻し済 (2 flag 設計 で 実 SEED の identityClass 宣言 0 件対応)
  2. rei-automator/src/aios/rei-automator-bridge.ts の logDir を env var 化して書き戻し済
  3. STEP 1277 wire は別 session が STEP 1346 として先行、 mtime ガードで書き戻し不可、 「あちらの実装は verdict を仮説テキストをキーにした Map で Evaluation に対応づけているので、 同一テキストの仮説が 2 件出ると片方が上書きされる」 と 指摘記録

私 (Claude Code) 対応: 現状 rei-aios 側 3 file を 実測 verify → 前 session 指摘の 妥当性判定 → 具体 fix 実施 (藤本さん判断: ② bug fix ON、 ③ 最初 (A) → 「やっぱり何かして頂けないでしょうか」 で (C) 予防修正)。

2. 現状 vs Downloads 3 file 突き合わせ結果

#Downloads file本体パス本体状態対応
invention-engine.ts src/aios/invention/invention-engine.ts 既に反映済 (STEP 1279 wire 全 landed、 mtime 08-20 05:43、 24/27/41/46/521-540/2432-2451/2840/2876/2880 に wire) 書き戻し不要
daily-invention-reporter.ts src/aios/daily/daily-invention-reporter.ts (Downloads は src/aios/invention/ 想定でパス想定違い) STEP 1346 実装済だが Map<hypothesis text, verdict> の verdict 消失 bug 混入 (前 session 指摘的中) hotfix 実施 (index 対応化、 +4 行)
rei-automator-bridge.ts archive/rei-automator-bridge/rei-automator-bridge.ts (Downloads 想定パス rei-automator/src/aios/ は 実在せず、 実際は archive/ 内 dead code) STEP 1336 以降 dead code (WorkspaceAutomator に一本化済)、 logDir cwd 相対ハードコード のまま 予防修正 (C) 実施 (ARCHIVED banner + env var 化、 +30 行 diff)

3. ② daily-invention-reporter.ts hotfix 詳細

3.1 混入 bug (STEP 1346 L268-274)

問題箇所 (修正前):

const verdictMap = new Map<string, NonCommutativityVerdict>();
for (let i = 0; i < inventionResult.hypotheses.length; i++) {
  verdictMap.set(inventionResult.hypotheses[i].hypothesis, verdicts[i]);  // ← key = hypothesis text
}
for (const e of evaluations) {
  const v = verdictMap.get(e.invention.hypothesis);  // ← 同一 text 2 件で片方消失
  if (v) e.nonCommutativityVerdict = v;
}

Failure mode: 同一 hypothesis text が batch 内に 2 件出た場合、 Map の 1 件目が 2 件目で 上書きされて verdict 消失。 稀な graceful fallback 経路 (STEP 1211 (m) + 1227 (u) の within-batch dedup を strict-normalize 後の 一致で塞いでいるが、 rotation exhaustion 経由の 同一 text 通過は理論的に発生し得る)。

3.2 invariant 事前 verify (invention-engine.ts L3055-3065)

allHypotheses = voids.slice(0, maxInventions).map((v, i) => transplantStructure(v, dateSeed, i));  // index 保存 map
hypotheses    = allHypotheses.filter((h): h is Hypothesis => h !== null);                          // null 除外
inventions    = hypotheses.map((h, i) => this.convergeToInvention(h, i));                          // 1:1 index preserving

evaluate() (evaluateLocally = .map() / evaluateWithClaudeAPI = for...of push) は order preserving。 したがって:

hypotheses[i] ↔ inventions[i] ↔ evaluations[i] ↔ verdicts[i] の 4 者 index 対応が成立。

3.3 fix (index 対応化)

修正後 (src/aios/daily/daily-invention-reporter.ts L259-282, 16 → 20 行, +4 net):

try {
  const verdicts = checkNonCommutativityBatch(inventionResult.hypotheses.map(h => ({
    transplantFrom: h.transplantFrom,
    transplantTo:   h.transplantTo,
    hypothesis:     h.hypothesis,
  })));
  const n = Math.min(evaluations.length, verdicts.length);
  for (let i = 0; i < n; i++) {
    evaluations[i].nonCommutativityVerdict = verdicts[i];
  }
  const nonCommSummary = summarizeNonCommutativity(evaluations
    .map(e => e.nonCommutativityVerdict)
    .filter((v): v is NonCommutativityVerdict => !!v));
  ...

Map<text> の text 一致 lookup 経路 自体を除去、 verdict 消失 pattern は 構造的に発生不能。

3.4 test 回帰確認 58/58 PASS

test結果目的
step1346-daily-reporter-lens-wire-test.ts20/20 PASS主 wire test
step1277-non-commutativity-lens-test.ts21/21 PASSlens 本体
step238-daily-invention-test.ts17/17 PASS元 daily reporter

4. ③ archived rei-automator-bridge.ts 予防修正 (option C)

4.1 判断経緯

藤本さん最初 (A) 「何もしない」 選択後、 「やっぱり何かして頂けないでしょうか」 で (C) 「将来 revival 時の負債除去」 に変更。 blast radius 最小 (archive/ 内のみ、 production import なし、 既存 test 影響なし)。

4.2 2 セクション 変更 (+30 行 diff)

1. File header に ARCHIVED banner 追加 (JSDoc 冒頭 +14 行):

  • STEP 1336 以降 dead code 明示
  • 現行 live path (src/workspace/rei-automator/WorkspaceAutomator) への誘導
  • revival 時の前提 2 点: (i) 2 実装並存の wrong-wiring 罠 (memory/feedback_success_signal_decoupled_from_operational_state_2026-08-14.md 参照) + (ii) 相対 import パス書き換え必要 (../axiom-os/... は archive/ 相対で存在しない)

2. logDir を env var 3 段 fallback 化 (Constructor 内 +14 行 comment 込み):

logDir: process.env.REI_AUTOMATOR_LOG_DIR
     ?? path.join(process.env.REI_DATA_ROOT ?? process.cwd(), 'data', 'automator-log'),
  • REI_AUTOMATOR_LOG_DIR (最優先) → REI_DATA_ROOT + /data/automator-logprocess.cwd() + /data/automator-log (従来動作 = 後方互換)
  • 全 env var 未設定時は従来と完全同一パスなので既存運用への影響ゼロ
  • rei-automator-mcp (Python 側) が既に採用している env var 方式に統一

4.3 type check note

tsc --noEmit で 5 件の TS2307 (module not found) が出るが、 私の編集起因ではない: archive/ 内相対 import (../axiom-os/rei-task-queue, ./action-executor 等) が存在しない pre-existing dead-code state であり、 私の変更は path.join + process.env のみ使用で 型解決可能。 新 ARCHIVED banner で 「復活時は現行パスに書き換える必要あり」 と 明記した内容 そのもの。

5. STEP 1336 教訓の継承

STEP 1336 (2026-08-15) で発見された wrong-implementation wiring subtype = 「2 実装並存で誤側に wired」 (persistence 無し WorkspaceAutomator が persistence 持ちの ReiAutomatorBridge の代わりに使われていた) の 逆パターンとして、 本 STEP 1347 archive 予防修正は 将来 revival 時に 同 domain 複数実装で 再び 誤 wired にしない ための banner + honest fallback design。

STEP 1346 bug fix も同種の 「テスト緑 + 実運用で稀な bug」 pattern — Map<text> lookup は通常 case で動くが 重複 text で silent 消失、 test カバレッジは通常 case のみで 未捕捉。 [[feedback-success-signal-decoupled-from-operational-state-2026-08-14]] 適用継続。

6. Honest scope

  1. ② bug は理論的発生条件のみ verify、 実 leak 事例は未観測: 同一 hypothesis text が batch 内に 2 件出る条件は STEP 1211 (m) + 1227 (u) の within-batch dedup 通過が必要で、 実運用で発生した記録なし。 本 fix は 「発生し得る」 → 「発生不能」 の構造的除去。
  2. ③ archive 修正は dead code のみ: WorkspaceAutomator (live path) は本 STEP scope 外、 STEP 1336 で持続化済で 別軸。 予防修正は 将来 revival 時の 負債除去 のみ、 現時点で 実行系路の 挙動 変化ゼロ。
  3. 前 session 主張パス rei-automator/src/aios/rei-automator-bridge.ts は 実在せず: 別 repo (TS 版) 想定の 可能性 は 藤本さん確認済で 該当なし (rei-automator-mcp は Python 版のみ、 TS 実装は archive/ + WorkspaceAutomator 2 系のみ)。
  4. 「世界唯一」 主張ゼロ: 本 STEP は 既存 wire (STEP 1346) の bug fix + archive 予防のみ、 新 novelty なし。
  5. data/ 側 cron 生成 559 file 変更を commit 除外: git status --short | wc -l = 560、 うち 559 が daily radar / arxiv / crypto 等 auto-generated data、 実際の 私の変更は 2 file のみ。 明示 git add で 混入 回避。
  6. 「site 反映 default」 protocol 適用: 2026-08-06 藤本さん永久 protocol、 backend engine hotfix + archived dead code 予防も site visible 化。

7. 関連 memory / STEP

  • STEP 1346 — レーダー/レンズ/エンジン 3 領域 進化 arc (別 session 実装、 本 STEP は そこの bug fix 継承)
  • STEP 1345 — benchtop-mcp v0.5.0-alpha 機器層/記録層 分割 spike
  • memory project_step1347_daily_reporter_hotfix_and_archived_bridge_prophylactic_2026-08-20.md (本 STEP 詳細記録)
  • memory feedback_success_signal_decoupled_from_operational_state_2026-08-14.md (STEP 1336 「wrong-implementation wiring subtype」 教訓、 本 STEP archive banner で 予防形 5 例目)
  • memory feedback_all_research_site_reflection_default.md (2026-08-06 藤本さん永久 protocol、 本 STEP も適用)