STEP 1534 — PlanRunner v0.2 (arc 3/3 完)

STEP 1534 · Bluesky 残 Msg type 6 種追加 + event bus + lifecycle · STEP 1569 arc 実 hardware 統合 3/3 完 · Rei-AIOS · 2026-08-30
Counter drift note: STEP 番号 1534 だが narrative 上は STEP 1533 (MCP tool wrapping) の続き。 rebase の副作用で counter reset された状態、 別 STEP で修復候補。

目的

藤本さん directive「Bluesky の残 10 Msg type (open_run/close_run/subscribe/monitor 等) を semantics 明確化しつつ追加」 応答。

STEP 1579 (b) の v0.1 は 5 Msg type (call/check/dry_run_hint/wait/checkpoint)。 Bluesky RunEngine の 15+ Msg type のうち Rei stack に持ち帰れる意味のあるもの 6 種を追加 して v0.2 完成。

追加 6 Msg type

BlueskyRei v0.2意味
open_runopen_runplan 実行 session の開始、 runId 生成 + __run__.opened event 自動 emit
close_runclose_runsession 終了、 exitCode 記録 + __run__.closed event 自動 emit
subscribesubscribeevent bus 購読 (topic + handler + optional filter)
monitormonitorsubscribe + 即時 N tick emit (ticksToEmit)
stagestageresource setup lifecycle (setup callback + stagedResources 追加)
unstageunstageresource teardown lifecycle (teardown callback + stagedResources 削除)

意図的に追加しない Bluesky Msg

Bluesky理由
set / read / triggerRei では call で十分 (verdict 出力が primary)
kickoff / complete長時間 background task の async 高度化は別 STEP
pause / resumeinteractive control は separate agent 統合が必要
nullno-op、 checkpoint で代替可
create / save / dropdocument store 相当、 Rei には data 層が不在 (別 STEP で benchtop-mcp ledger と統合検討)

PlanRunnerV02 class

const runner = new PlanRunnerV02({
  toolHandler, safetyGate, waitFn,  // v0.1 と同じ
  runIdGen: () => 'my-run-id',       // v0.2 新規 (auto generation)
  dryRun: false,
});

// event bus emit (外部から)
runner.emit('sensor.reading', { value: 42 });

// introspection
runner.staged();            // ['probe_a', 'probe_b']
runner.subscribedTopics();  // ['sensor.reading', '__run__.opened']

Example: full lifecycle plan

function* fullPlan(): PlanV02 {
  yield openRunMsg();                                    // → runId 生成 + __run__.opened emit
  yield stageMsg('disk_probe', async () => connect());   // → setup callback + stagedResources 追加
  yield subscribeMsg('__run__.closed', (e) => log(e));   // → close 時に自動通知
  yield callMsg('disk_health_verdict', {...});           // 通常の tool call
  yield unstageMsg('disk_probe', async () => close());   // → teardown callback + 削除
  yield closeRunMsg(undefined, 'success', { calls: 1 }); // → __run__.closed emit
}
const trace = await runner.run(fullPlan());
// trace 6 entry + __run__.closed subscriber が exitCode='success' を受信

Backward compat

Test — 47/47 PASS + regression 130/130 clean

  1. Msg constructors (6 新 v0.2 type)
  2. PlanRunnerV02 basic run (v0.1 Msg backward compat)
  3. open_run / close_run lifecycle
  4. open_run generates runId when omitted
  5. subscribe + emit delivery
  6. subscribe with filter
  7. monitor with ticksToEmit
  8. stage / unstage lifecycle (setup + teardown 呼出)
  9. staged() introspection
  10. __run__ lifecycle events auto-emitted
  11. summarizeTraceV02
  12. dryRun skips setup/teardown, still traces
  13. Full sequence (open → stage → subscribe → call → close)

Regression: STEP 1579 v0.1 (48/48) + STEP 1584 SafetyGate (44/44) + STEP 1533 wrapper (38/38) 全通過。

STEP 1569 arc 完結

STEPLayerCommit
1569arc 起点 (Ophyd 読解 + top 3 宣言)082609899
1571 (a)No-Data Primitives700c4c98c
1576 (c)Connector Protocols5e4b2ec4c
1579 (b)Plan Runner Msg v0.15beed1c41
1584SafetyGate (実 hardware 統合 1/3)e89dd95ab
1533MCP tool wrapping (実 hardware 統合 2/3)1328ee77e
1534PlanRunner v0.2 (実 hardware 統合 3/3)(this)

Ophyd 10 年設計 + Bluesky RunEngine の系統的輸入完了:

Honest scope