Skip to content

feat(run-dash): universal agent run observability + Codex L2 integration#16

Open
simota wants to merge 8 commits intomainfrom
feat/run-dash
Open

feat(run-dash): universal agent run observability + Codex L2 integration#16
simota wants to merge 8 commits intomainfrom
feat/run-dash

Conversation

@simota
Copy link
Copy Markdown
Owner

@simota simota commented Apr 30, 2026

Summary

apex-dash (Apex 専用ダッシュボード) を run-dash にリネーム/汎化し、/nexus apex だけでなく feature / bug / refactor の各 Recipe、単発の skill 起動、手動セッションまで含めた任意のエージェント実行をリアルタイム可視化できるようにしました。L1 Claude Code hooks / L2 recipe orchestrator / L3 specialist の3層プロトコルとして RUN_DASH_PROTOCOL.md に成文化し、Codex CLI 用の L2-only ラッパー (codex-wrap.sh) を追加して engine boundary も観測可能にしています。

Changes

Core protocol

  • _common/RUN_DASH_PROTOCOL.md (新規): L1/L2/L3 責務分離マトリクス、recipe override パターン、env 規約、Codex CLI L2-only 契約 (§11)。
  • _common/scripts/run-emit.sh (新規): pure bash の event emit ヘルパー。RUN_ID 未設定時は silent no-op、mkdir lock で seq、ISO8601 ms タイムスタンプ。apex-emit.sh は薄いエイリアスとして互換維持。
  • _common/scripts/codex-wrap.sh (新規): Codex CLI 起動を agent_start engine=codex_cli / agent_end status/duration で挟む薄ラッパー。stdout/stderr/exit code 透過。

Dashboard spec (_common/run-dash/)

  • README.md / DESIGN.md / EVENTS.md / INTEGRATION.md / UI.md / POSTMORTEM.md / GENERATION.md: 3 mode (apex / recipe / generic) アーキテクチャ、event schema、生成手順を完全英語化。
  • TOPOLOGIES/{apex,feature,bug,generic}.md: Recipe ごとの UI トポロジ。generic は dynamic DAG 構築アルゴリズムを定義。

Working MVP (_common/run-dash/sample/)

  • Bun + Hono SSE server + chokidar tail (events.jsonl 監視)。
  • React 18 + @xyflow/react v12 + zustand 5 + Recharts + dagre + Framer Motion + Tailwind v4。
  • 3 mode 切替対応: apex は phase rail + risk gate radar + orbit chart、recipe は step rail、generic は dynamic graph + Gantt timeline。
  • Run picker: 全プロジェクト横断、[project] run-id · run_kind 形式、5s polling。
  • サンプル fixture: apex 66 events / feature 30 events / manual 11 events。

Recipe wiring

  • nexus/SKILL.md: Live Dashboard Integration セクション + recipe override パターン参照。
  • nexus/references/apex-recipe.md §13: 完全 emit スケルトン、Phase 6 で codex-wrap.sh 使用、§13.5 に Codex L2-only 制限を独立記載。
  • nexus/references/feature-recipe.md (新規) / bug-recipe.md (新規): step-based emit checklist。

Layout (rename)

  • _common/apex-dash/_common/run-dash/ (リネーム + 内容拡張)
  • レガシー env (APEX_RUN_ID / APEX_DASH_DIR / APEX_DASH_DISABLED) は run-emit.sh で引き続き honour。

Architecture

L1  Claude Code hooks (~/.claude/hooks/run-dash-*.sh)
    SessionStart → run_start (manual)
    PreToolUse:Agent → agent_start
    PostToolUse:Agent|Bash|Read|... → agent_end / tool_use
    Stop → run_end
    ⚠ Codex CLI: 利用不可 (相当する hook 面が無い)

L2  Recipe orchestrators (Nexus apex / feature / bug)
    RUN_ID を recipe スコープに override
    phase / step / risk_gate / spec_gate / orbit_iter を emit
    完了時に親 RUN_ID を復元
    engine 非依存 (Claude Code でも Codex CLI でも動作)

L3  Specialist agents (plea / accord / atlas / builder / ...)
    直接 emit しない (L1 hooks が全 Agent 起動を捕捉)
    例外: Codex spawn は parent recipe から codex-wrap.sh で bracket

Test plan

  • run-emit.sh smoke (apex / feature / manual の 3 fixture を実 events.jsonl から再現)
  • codex-wrap.sh smoke: 成功 / exit 7 失敗 / RUN_ID 未設定 (silent no-op) の 3 path
  • Sample dashboard: bun run dev 起動、RUN_DASH_EVENTS_DIR=$HOME/.claude/run-dash で global mode 動作確認、3 sample run を picker から切替表示
  • Hook 経由の自動 emit を別セッションで確認 (SessionStart → manual run が picker に出現)
  • /nexus apex 実行時に L2 emit + L1 自動 emit がマージされて表示

Notes

  • 個人環境の ~/.claude/hooks/run-dash-*.sh および ~/.claude/settings.json の hook 配線はリポジトリ外 (このPRには含まれない)。
  • ダッシュボード本体は _common/run-dash/sample/ に常駐し、RUN_DASH_EVENTS_DIR~/.claude/run-dash/ に向けることで全プロジェクトの run を 1 ダッシュボードで観測する global mode を推奨。

simota added 8 commits April 30, 2026 14:46
Specs only (no code) under _common/apex-dash/ for a Web dashboard that
visualises long-running /nexus apex sessions. Generators (forge/builder)
materialise per-repo instances under <repo>/.agents/apex-dash/ via the
prompt in GENERATION.md.

Why: apex chains span 8-25 agents across two sub-orchestrators and an
engine boundary; postmortem-only logs are insufficient for live ops.

Covers: events.jsonl schema (single source of truth), declarative
topology, UI/animation spec, emit protocol, auto-spawn pre-flight.
- _common/scripts/apex-emit.sh: portable bash emitter that producers
  (Nexus apex agents and Codex orbit subagents) call to append
  events.jsonl entries. No-op when APEX_RUN_ID is unset.
- _common/apex-dash/POSTMORTEM.md: spec for run_end postmortem
  generation and Lore handoff.
- _common/apex-dash/sample/: end-to-end Bun + Hono + React + xyflow
  reference MVP. Tails events.jsonl over SSE, renders the phased
  topology with state animations, Risk Gate radar, Orbit convergence
  chart, active agents cards, checkpoints, event stream, and a
  postmortem export button after run_end.

Serves as a golden reference for forge/builder when materialising
per-repo dashboards via GENERATION.md.
Lift the dashboard from "apex only" to "any run kind" by renaming
apex-dash → run-dash and splitting the schema into a core + per-recipe
extensions.

- Schema: events.jsonl gains run_kind / parent_agent / depth / recipe in
  the core. Apex-only kinds (phase_enter, risk_gate, orbit_iter,
  engine_switch) remain as `apex` extensions.
- Modes: apex (fixed topology), recipe (step rail; feature / bug /
  refactor), generic (dynamic DAG built from parent_agent + depth, with
  Gantt timeline) auto-selected from run_kind.
- Topologies: split TOPOLOGY.md into TOPOLOGIES/{apex,feature,bug,
  generic}.md.
- Helper: scripts/run-emit.sh handles every recipe; scripts/apex-emit.sh
  is a thin alias for backward compatibility.
- Hooks: INTEGRATION.md documents Claude Code SessionStart / PreToolUse
  / PostToolUse / Stop hook configuration so any session can be observed
  without per-skill changes.
- Sample: reducer tracks run_kind / steps / dynamicNodes / toolCounts;
  Header surfaces a run_kind colour badge; ships feature-* and manual-*
  example runs alongside the existing apex run.

Backward compatible: APEX_RUN_ID / APEX_DASH_DIR / APEX_DASH_DISABLED
env vars and apex-emit.sh continue to work.
- App.tsx derives mode from run_kind and switches panels:
  apex → PhaseRail + Topology + RiskGateRadar + OrbitChart
  recipe → StepRail + Topology + ToolHistogram + OrbitChart
  generic → rail placeholder + DynamicGraph + ToolHistogram + Timeline
- StepRail.tsx: dynamic step rail driven by step_enter / step_exit events
- DynamicGraph.tsx: dagre-laid-out DAG built from dynamicNodes
  (parent_agent + depth) with xyflow rendering
- Timeline.tsx: SVG Gantt of completed + active agents with tool_use ticks
- ToolHistogram.tsx: Recharts BarChart of top-6 tool counts
- Add @dagrejs/dagre dependency
- Fix server boot log ("run-dash sample server listening")
- styles.css: step-rail / timeline / empty-canvas / rail-placeholder
- _common/RUN_DASH_PROTOCOL.md: agent-side contract (L1 hooks / L2 recipes /
  L3 specialists) defining who emits which event, env vars, recipe override
  pattern, state-sharing files, failure behaviour, and end-to-end
  verification procedure
- nexus/SKILL.md: add "Live Dashboard Integration" section pointing to the
  protocol and the per-recipe emit checklists
- nexus/references/apex-recipe.md: add §13 "Live Dashboard Emit" with the
  full emit-point table and a copy-paste skeleton for apex orchestration
- nexus/references/feature-recipe.md: new — 4-step (Discover/Spec/Implement
  /Ship) recipe with topology link and emit skeleton
- nexus/references/bug-recipe.md: new — 4-step (Reproduce/RCA/Fix/Verify)
  recipe with topology link and emit skeleton

Specialist agents (plea, accord, atlas, builder, …) intentionally NOT
modified — Claude Code hooks already capture every Agent invocation.
Codex CLI lacks PreToolUse / PostToolUse hooks, so L1 auto-instrumentation
does not apply. Document Codex as L2-only and ship codex-wrap.sh, a pure-bash
wrapper that brackets a Codex spawn with agent_start / agent_end events
tagged engine=codex_cli, preserving stdout, stderr, and exit code.

- _common/scripts/codex-wrap.sh: new wrapper (silent when RUN_ID unset)
- RUN_DASH_PROTOCOL.md: new section 11 covering Codex L2-only contract
- INTEGRATION.md section 2.5: rewritten with wrapper usage and limits
- apex-recipe.md section 13: Phase 6 skeleton uses codex-wrap; new
  section 13.5 calls out L2-only constraints (no per-tool ticks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant