STEP 1537 — rei-mcp-server Msg 2 層化 design spec
要旨
rei-mcp-server (現状 v2.8.5、 83 tool) の tool dispatch を、 tool 毎 direct call から bluesky/bluesky (BSD-3-Clause) 準拠の Msg indirection layer に refactor する design spec。 dry-run / 中断-再開 / audit trail 自動化 / SafetyGate 統一 dispatch / plan composition (multi-tool arc + clean rollback) が目的。
★ STEP 1594 retrospective: 起草時 (STEP 1537) は design-only、 同日 別 tab で 全 Layer 実装済と判明 (STEP 1533 wrapper + STEP 1534 PlanRunner v0.2 + STEP 1584 SafetyGate)。 現在 は canonical spec description role。
bluesky verbatim quote (core insight)
"Calling epics.caput inside a plan prevents the RunEngine from knowing about it and thus circumvents its facilities for putting devices in a safe state in the event of an unexpected exit or error."
Rei stack でも 同構造 = rei-mcp-server tool を Claude Code から 直接 call すると SafetyGate / audit / rollback が bypass される、 Msg indirection layer 必須。
Actual implementation status (retrospective STEP 1594)
| 私 spec Layer | 別 tab 実 file | STEP | Status |
|---|---|---|---|
| L1 Msg (5-tuple + command) | src/mcp/plan-runner-msg.ts | 1579 | COMPLETED |
| L2 Plan (async generator) | 同上 | 1579 | COMPLETED |
| L3 RunEngine (dispatch) | 同上 + plan-runner-msg-v02.ts (6 新 Msg) | 1579 + 1534 | COMPLETED |
| L4 SafetyGate 統合 | safety-gate.ts + msg-tool-wrapper.ts | 1584 + 1533 | COMPLETED |
| L5 v0.3 (私 spec 未言及) | plan-runner-msg-v03.ts | 未 grep | IN PROGRESS (別 tab) |
私 spec との 主要差分 4 件 (別 tab canonical)
- 一斉 refactor vs 逐次 opt-in: 私 spec = 全 82 tool 一斉 / 別 tab = 既存
rei-mcp-server.ts不変 +wrapAsMsgToolfactory 経由 opt-in migration (canonical、 breaking change zero) - Msg command 種類: 私 spec 8 command / 別 tab v01+v02 base 5 + 拡張 6 (Bluesky Msg source 直輸入)
- SafetyGate 統合: 私 spec Phase 4 defer → 別 tab STEP 1584 で 3-tier hazard + 6 rule constructor 実装済
- Pilot tool: 私 spec 1 tool 推奨 → 別 tab 3 pilot 同時 (disk_health + shannon_entropy + puzzle_verify) の 3x coverage
Rei stack lesson (multi-tab spec collision)
- STEP 1554 atomic-commit protocol は code file 衝突 には有効
- spec doc 内容重複 / 認識ずれ には 別 mechanism 必要:
- 別 tab の
git log事前確認 が 有効 preventive step - Design-spec 起草前 に 別 tab activity survey が 推奨
- 別 tab の
- 本 STEP 1594 retrospective update = 「spec ↔ 実装 認識ずれ の operational 訂正」 の 実例
Honest scope
- 私 spec の core insight (bluesky verbatim quote) は 別 tab 実装 と 一致 = direction 正しかった
- 私 spec の 「一斉 refactor」 方針 は 別 tab 実装で 却下、 「逐次 opt-in」 が canonical = 私 spec の scoping error を honest 明記
- v0.3 (
plan-runner-msg-v03.ts) の 内部 は 本 STEP 未 read、 別 STEP で detail update 候補 - Bluesky Python は 直接 port せず、 TypeScript + async generator で 独自実装 (別 tab canonical)
Related
docs/REI_MCP_SERVER_MSG_2_LAYER_DESIGN_SPEC.md— 詳細 spec (retrospective updated)src/mcp/plan-runner-msg.ts— v01 base (別 tab STEP 1579)src/mcp/plan-runner-msg-v02.ts— v02 (別 tab STEP 1534)src/mcp/plan-runner-msg-v03.ts— v03 (更に別 tab)src/mcp/safety-gate.ts— 3-tier hazard model (別 tab STEP 1584)src/mcp/msg-tool-wrapper.ts— wrapper factory + 3 pilot (別 tab STEP 1533)- STEP 1594 — retrospective spec update