Skip to content

feat(dag-viewer): redesign the viewer around the stage pipeline - #574

Draft
zzylol wants to merge 8 commits into
stack/509-demo-examplesfrom
stack/509-viewer-stages
Draft

zzylol wants to merge 8 commits into
stack/509-demo-examplesfrom
stack/509-viewer-stages

Conversation

@zzylol

@zzylol zzylol commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #574 → #620 → #618 → #621 → #627 → #625 → #628 → #632 → #634 → #616 → #617 → #622 → #624 → #629 → #630 → #631 → #633 → #635 → #636 → #637
Stack: #605 → #607 → #608 → #609 → #610 → #612 → #613 → this PR

Rebased on main d4869a7 (DF 54). At this head fmt, clippy -D warnings and cargo test --workspace pass (1668 passed, 0 failed, 21 ignored).

Why

With #509's stages and #572's crates, there are no pre-ASAP and post-ASAP DAGs any more. What the planner produces is one asap-stage-pipeline/v1 document per workload:

  • Stage 0: the logical DAG.
  • Stage 1: the logical ASAP candidates.
  • Stage 2: the physical candidates.
  • Stage 3: costs, rejections and the selection.

The viewer is redesigned around that document, using the layout of the published Stage Viewer.

The page

  • Example tabs for the six docs: propose workload-wide planning, summary sharing, and materialization #509 examples (1, 2, 3a, 3b, 4a, 4b). Each has a short explanation of the workload and why its plan wins, and #example4b in the URL opens that example.

  • Workload queries with their accuracy, latency and recurrence.

  • Deployment inputs (Show deployment inputs in the stage document and viewers #610):

    • the exact aggregates;
    • each sketch with the estimates it can be read for;
    • ingestion-time maintenance;
    • the memory budget;
    • raw-data retention;
    • the cost model with its calibration constants;
    • the accuracy model.
  • Stage 3 · plans by cost: every plan, cheapest first, marked selected, valid but costlier, or invalid with the reason. When a document carries only the cheapest plans (devtools: stage_pipeline examples planner-layering-2 and 4b #613's shown_of), the list says "showing 64 of 486 plans, cheapest first; Stage 3 priced 486 and selected among all of them".

  • Three DAG lanes, one cytoscape instance each:

    • Stage 0;
    • the chosen Stage 1 candidate;
    • the chosen Stage 2 candidate, with each node's timing and Stage 3 cost.

    Summary builds print their configuration (for example CmsWithHeap · depth 7 · heap 100 · width 272) and whether there is one instance per group, one per series, or one shared instance.

  • Details for a clicked node (operator, output schema, coverage, guarantee, cost) or edge (schema, data state).

  • Open stage document…, drag and drop, or ?doc=<path> to load other documents.

  • Query editor: plans PromQL queries, with an optional ε and δ and the sample interval, through /api/plan, which now runs stage_pipeline. SQL needs a catalog and is left for later.

Changes

  • index.html and app.js replace viewer.js.

    • stages.js (validation, ranking, lane elements, labels) is reused as is.
    • node-style.js keeps only KIND_CATEGORY_JSON, which viewer_contract.rs checks, plus the three node groups (data source, relational, summary).
  • examples.json lists the examples. server.py builds stage_pipeline, writes any missing documents into the git-ignored out/ directory (--regenerate rewrites them), and serves /api/plan.

  • Removed:

    • the Pre/Post-ASAP view and WorkloadDAG loading;
    • render.py's standalone HTML;
    • planner-ui.js;
    • the dag_export sample and the post-ASAP fixture;
    • the screenshots.

    The dag_export binary itself stays for a later cleanup PR.

  • README.md, RUNNING.md and the user guide describe the Stage Viewer.

  • test_viewer.py replaces test_render.py. It has:

    • the stage-document tests;
    • checks that the page's scripts and element ids line up;
    • the example manifest against stage_pipeline's examples;
    • the server's request checks;
    • app.js loading documents against a stub DOM in V8.

Test plan

  • python3 -m unittest test_viewer in tools/dag-viewer, with py-mini-racer==0.6.0: 24 tests, OK (without it, 17 JS tests are skipped).
  • cargo test -p asap-devtools: 45 passed, including viewer_contract and the Example 1 fixture check.
  • server.py serves the page and all six example documents. /api/plan with a top-k query at ε=0.01, δ=0.001 returns a valid document; δ without ε returns 400.
  • All six example documents load through app.js, selecting P82, P86, P365, P2, P365 and P4-m1.
  • Not checked in a real browser in CI. The published Stage Viewer artifact runs the same page code.

🤖 Generated with Claude Code

@zzylol
zzylol force-pushed the stack/509-viewer-stages branch from ce8844d to f76cc22 Compare October 4, 2026 15:23
@zzylol
zzylol changed the base branch from stack/528-08-cleanup to stack/572-b5-executor October 4, 2026 15:23
@zzylol
zzylol force-pushed the stack/509-viewer-stages branch from 7fcca4c to ed7522e Compare October 4, 2026 21:48
@zzylol
zzylol changed the base branch from stack/572-b5-executor to stack/509-demo-examples October 4, 2026 21:49
@zzylol zzylol changed the title feat(dag-viewer): three-lane Stages view with Stage 3 costs feat(dag-viewer): redesign the viewer around the stage pipeline Oct 4, 2026
zzylol and others added 8 commits October 5, 2026 04:48
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>
…stances

Summary nodes now show their family's configured parameters, e.g.
CmsWithHeap · depth 7 · heap 100 · width 272, and whether they keep one state
per group or one shared (Hydra) state, instead of the bare algorithm name and
the raw grouping strategy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a stage document carries a `deployment` section (#610), the Stages view
lists the deployment's capabilities, raw-data retention, cost model with its
calibration, and accuracy model next to the workload queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exact aggregates have no readouts, so "exact Sum ()" read as an empty list.
The deployment inputs now show the exact aggregates in one row and each
sketch with the estimates it can be read for in another.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stage_pipeline now prices every plan and writes the cheapest
--max-candidates (#613); the Stages view says "showing N of M plans" from
the document's shown_of section. The README shows how to generate all six
#509 examples into an ignored out/ directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pre/post-ASAP DAGs no longer exist after #509/#572, so the viewer now
reads only asap-stage-pipeline/v1 documents and uses the layout of the
published Stage Viewer: example tabs with what each shows, the workload's
queries and the deployment inputs on top, the Stage 3 plans ranked by cost
beside three DAG lanes (Stage 0, the chosen Stage 1 candidate, the chosen
Stage 2 candidate with costs), and node and edge details below.

- index.html and app.js replace viewer.js; stages.js is unchanged and
  node-style.js keeps only the kind table the contract test reads, plus
  the three node groups.
- examples.json lists the six #509 examples; server.py writes any
  missing document into out/ with stage_pipeline.
- The query editor (editor.js) plans PromQL queries with optional ε/δ
  through /api/plan, which now runs stage_pipeline.
- Removed: the Pre/Post-ASAP view, WorkloadDAG loading, render.py's
  standalone HTML, the dag_export-based sample and fixtures, screenshots.
- test_viewer.py replaces test_render.py: the stage-document tests, the
  page and server checks, and app.js run against a stub DOM in V8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol
zzylol force-pushed the stack/509-demo-examples branch from e3d77b0 to 727cf89 Compare October 5, 2026 06:21
@zzylol
zzylol force-pushed the stack/509-viewer-stages branch from 7516caa to 58f4814 Compare October 5, 2026 06:21
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