Skip to content

feat(dag-viewer): three-lane Stages view with Stage 3 costs - #574

Draft
zzylol wants to merge 2 commits into
stack/528-08-cleanupfrom
stack/509-viewer-stages
Draft

zzylol wants to merge 2 commits into
stack/528-08-cleanupfrom
stack/509-viewer-stages

Conversation

@zzylol

@zzylol zzylol commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Why

#509 defines four planning stages:

Stage 0 LogicalDAG → Stage 1 CandidateLogicalASAPDAGs → Stage 2 CandidatePhysicalASAPDAGs → Stage 3 one selected PhysicalASAPDAG

The DAG viewer only had a two-lane Pre/Post-ASAP view, so it could not show the candidate sets at each stage or why Stage 3 picked one plan.

What

A Stages view in tools/dag-viewer for asap-stage-pipeline/v1 documents:

  • Three lanes:
    • Logical (Stage 0);
    • Logical ASAP (Stage 1 candidates, with a switcher);
    • Physical ASAP (Stage 2 candidates, with a switcher).
  • Roots per query: a DAG has one root per batch query, and each root is labelled with its query id.
  • Cost: only from Stage 3. Stage 3 results are ranked by total cost with a badge on each node, and every candidate is marked ✓ selected, valid-but-costlier, or ✗ invalid, with its reason. Selecting a physical candidate highlights the logical candidate it came from.
  • Physical nodes show output_state.timing. The details panel shows payload, schema, guarantee, coverage and query requirements, and physical edges also show data_state.
  • Partial documents load: stages that have not run show "not produced".
  • Pre/Post-ASAP mode still works. The Stages mode becomes the default only when a stage document is loaded.

The logic that needs no page lives in stages.js, so it can be tested headless: validation (17 malformed-document cases), ranking, lanes and outcomes.

Before / After

  • Before: only Pre/Post-ASAP lanes, with cost/benefit badges on post-ASAP nodes.
  • After: python3 tools/dag-viewer/server.py --port 8765, then open /?doc=<stage document>.

Validation

python3 -m unittest discover -s tools/dag-viewer -p test_render.py: 40 tests pass (16 JS tests are skipped without py_mini_racer). The real Example 1 document passes the viewer's validator with no errors, and the server serves the page, stages.js and the document.

Based on #543 (Phase C in #528). The format is in /tools/dag-viewer/README.md, section "Stages view".

🤖 Generated with Claude Code

zzylol and others added 2 commits October 3, 2026 21:29
Load an asap-stage-pipeline/v1 document (file picker or ?doc=<path>) and
show Logical, Logical ASAP and Physical ASAP lanes side by side, with
candidate switchers, per-node timing and cost, a cost-ranked list of
physical candidates, and the stage-3 selection and rejection reasons.
Selecting a physical candidate shows its from_logical candidate in lane 2.
Pre/Post-ASAP stays the default unless a stage document is loaded.

stages.js holds the DOM-free validation, lane construction and ranking,
tested headless against a hand-written #509 Example 1 Q2 fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contract v2 (Q28-Q30) gives each DAG one root per workload query and
moves cost out of Stage 2 into stage3_selection.costs.

- Read `roots` (still accepting a single `root`); mark every root and
  label it with its query id.
- Take node badges, totals and ranking only from Stage 3 costs, labelled
  as a Stage 3 result; without Stage 3 the physical lane has no cost.
- Load partial documents; missing later stages render "not produced".
- Require every Stage 2 candidate to be selected or rejected, and show
  valid-but-costlier apart from invalid.
- Show optional per-query requirements in the query list and on roots.
- Rewrite the sample as #509 Example 1 with both queries, and label
  sort/limit physical operators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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