Skip to content

Workbench: Internal Data API + System DAG view (closes #306, #314) - #322

Merged
nockawa merged 2 commits into
mainfrom
feature/306-wb-data-api
May 7, 2026
Merged

nockawa merged 2 commits into
mainfrom
feature/306-wb-data-api

Conversation

@nockawa

@nockawa nockawa commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

One PR covering both umbrella issues:

Both umbrellas closed with detailed summaries on the issues themselves; remaining sub-issues (#318 polish, #320 compound expand, #321 visual regression) tracked separately.

The DAG view sits on top of the new Internal Data API — the data plumbing and the consumer were built together on this branch, and the DAG view's three implementation phases are the API's first major consumer beyond the existing profiler. Single PR keeps the two halves reviewable as one unit.

What landed — Internal Data API (#306)

v1

  • New endpoints: /api/sessions/{id}/topology, /track/..., /aggregate. JSON wire.
  • Header-based versioning (X-Workbench-Api, X-Workbench-Wire) with soft-launch tolerance.
  • Cross-panel state: useSelectionStore (typed dimension slots + URL sync), useHoverStore (volatile, cross-panel hover for system + phase).
  • SSE typed-event refactor across the existing 5 streams + new /stream unified endpoint with selective subscription.
  • SessionLifecycle field migration (Loading / Ready / Closed).

v2 — engine instrumentation phases that landed

  • 2.1 RFC 07 access declarations on the topology endpoint (incl. engine-built predecessors / successors).
  • 2.2 Per-system tracks — SystemTickSummary[] cache section (v12+) with (durationUs, startUs, endUs, readyUs, entitiesProcessed, workersTouched, chunksProcessed, skipReasonCode, flags).
  • 2.3 Per-system readyUs capture (folded into the same section).
  • 2.4 Per-queue tracks via QueueTickEnd instant event (kind 244) → QueueTickSummaries cache section.
  • 2.5 Post-tick serial markers via PostTickSummary cache section.
  • 2.6 Critical-path computation — pure client-side per the design's §9.3 decision (zero engine cost when the workbench isn't attached).

What landed — System DAG view (#314)

  • Phase 1 (Workbench: System DAG view Phase 1 — topology view (no stats) #315) — topology view. Four layout modes (horizontal-lanes / vertical-lanes / compact / circular). xyflow + dagre. Edge derivation from RFC 07 declarations.
  • Phase 2 (Workbench: System DAG view Phase 2 — stats overlay #316) — stats overlay. Heat-coloured node borders, queue backpressure on dashed edges, snapshot button, cross-panel binding to TimeArea.
  • Phase 3 (Workbench: System DAG view Phase 3 — critical-path tape #317) — Critical-Path tape, reshaped from "in-DAG column" to its own dockable panel:
    • Single-tick + aggregate + full-Gantt + linear/log + auto/horizontal/vertical orientations + lock-zoom + optional metronome stripe.
    • Three wait classes with click-throughs (phase-fence → straggler, worker-claim → waiting system).
    • Post-tick serial block.
    • CP badges on DAG nodes (★ + dominant-tick red outline).
    • Cross-panel selection + hover sync (system + phase).
    • Performance test: 1024 ticks × 200 systems < 200 ms.
  • Bonus polish. ? help overlays on both panels. Phase-flow arrows in lanes layouts. Phase-coloured backdrop in compact/circular layouts. Theme-aware hover indicators. ViewportPortal integration so all lane decorations pan/zoom with nodes.

Bug fixes during the work

  • Engine — DagScheduler chunk-exception wedge. A throwing chunk left the scheduler in a tight CPU spin (FindReadySystem kept returning the failed system; workers walked into ProcessPipeline → break → repeat). Fixed via DrainFailedSystemChunks — failure path drains remaining chunks atomically so OnSystemComplete fires.
  • Workbench — QueueTickEnd (kind 244) misclassified as a span. Decoder was reading 25 payload bytes as a fake span header → garbage timings → ~30 phantom nested spans on the TickDriver track per tick. Fixed via IsSpan carve-out (C# + TS mirror), proper instant decoder, missing label entries.

Design doc updates

Test plan

  • Full engine suite: dotnet test test/Typhon.Engine.Tests/Typhon.Engine.Tests.csproj -c Debug — should pass 3,786 (the new ParallelQueryException_TickCompletes_NoFullCpuWedge test in ExceptionHandlingTests.cs covers the chunk-exception wedge fix; without the fix it times out at 2 s).
  • Workbench server tests: dotnet test test/Typhon.Workbench.Tests/Typhon.Workbench.Tests.csproj.
  • Workbench client tests: cd tools/Typhon.Workbench/ClientApp && npx vitest run — should pass 381 (24 in criticalPath.test.ts including the 1024×200 perf test).
  • Manual: /wb-dev start, open an AntHill trace, verify the DAG renders in all four layouts, snapshot the last 600 ticks, open the Critical Path panel, exercise single ↔ aggregate ↔ full-Gantt ↔ metronome toggles, hover a phase stripe to confirm cross-panel highlight, click a phase-fence wait to confirm straggler jump.
  • Manual: re-open the AntHill trace and confirm no phantom "Kind[244]" spans on the TickDriver track (the QueueTickEnd misclassification fix).
  • Manual: run AntHill ProfileRunner, force a chunk to throw, confirm the engine doesn't wedge in a full-CPU spin (the DrainFailedSystemChunks fix).

🤖 Generated with Claude Code

@nockawa
nockawa merged commit af67b4f into main May 7, 2026
6 checks passed
@nockawa
nockawa deleted the feature/306-wb-data-api branch May 7, 2026 02:35
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