Skip to content

Runtime: introduce Track → DAG partitioning hierarchy (foundations) #354

Closed

Description

@nockawa

Summary

Replace the current "one user DAG + a .Internal()-flagged Fence bolt-on" model with a first-class
partitioning hierarchy:

Engine → Track → DAG → Phase → System
  • Track — ordered, tagged (open tag set) container of DAGs. Track order = execution sequence.
  • DAG — dependency graph of systems; belongs to exactly one Track (mandatory); declares its own
    ordered phases. No public/internal distinction — every DAG is declared/executed the same way.
  • Phase — DAG-local ordering of systems (no engine-global phase namespace).

Built-in ordered tracks: Engine-Pre (engine tag) → Public → Engine-Post (engine tag).
The Fence becomes a normal DAG in Engine-Post.

Working note: claude/scratch/track-dag-foundations.md.

Motivation

The Fence internal DAG is a bolt-on (InternalScheduleBuilder + SystemBuilder.Internal()). This
surfaces two defects in the Workbench:

  1. RuntimeSchedule.Build force-stamps every phase-less system with DefaultPhase — the Fence systems
    land in the Render swim-lane (System DAG view).
  2. IsInternal never crosses the wire — the Workbench can't distinguish engine systems from user ones;
    the Critical Path view orphans the Fence chain.

Root cause: there is no structural model for multiple DAGs.

Scope

In scope — partitioning + identity + ordering + API exposure:

  • W1 Engine model — Track / DAG types; RuntimeSchedule declaration API; DAG-local phase
    resolution; drop .Internal(); DagScheduler dispatches track-by-track in order.
  • W2 Fence as a normal DAG in Engine-Post; retire InternalScheduleBuilder / Internal() /
    SystemDefinition.IsInternal.
  • W3 Wire/trace format — SystemDefinitionRecord.DagId; Tracks + DAGs tables; DAG-scoped
    PhaseName; TraceFileHeader version bump.
  • W4 Data API / DTOs — TopologyDto exposes tracks → dags → phases → systems; orval regen.
  • W5 Workbench — System DAG + Critical Path group by Track → DAG → Phase; hide engine-tagged
    tracks by default (toggle to reveal).
  • W6 Docs — overview/13-runtime.md, ADR for the hierarchy, affected design docs.

Out of scope (Runtime v2): per-DAG triggers / execution frequency, channels, inter-DAG communication,
resource budgets, failure isolation.

Decisions

  • No default-DAG convenience — explicit Track/DAG declaration is mandatory; unit tests + AntHill are
    migrated directly.
  • Terminology supersedes system-tracks.md §2.1 (Track == DAG → Track contains DAGs).

Notes

Tracked as an issue for visibility; the work is done on the current branch, not a separate PR.

Activity

  1. moved this to In Progress in Typhon devon May 17, 2026
  2. moved this from In Progress to Ready in Typhon devon May 17, 2026
  3. moved this from Ready to In Progress in Typhon devon May 17, 2026
  4. nockawa commented on May 17, 2026

    @nockawa
    CollaboratorAuthor

    Accepted implementation plan — W1→W3 (W4 descoped)

    Implementing via /implement-feature. Scope reduced to W1, W2, W3; W4 descoped and paired with W5 as a later follow-up (W4 DTOs are tightly coupled to W5 panel consumption — landing W4 alone leaves the Workbench half-migrated). Consequence: the two Workbench bugs in the Motivation section stay unfixed until W4+W5.

    Key decisions

    • D1 — Engine-Post track dispatches from the post-tick hook (RunParallelFence), not the in-tick track loop. DagScheduler.DispatchInternalSchedule() → generalized DispatchTrack(int). Forced by the Fence's dependency on serial WriteTickFence prep. Noted deviation from the working note's literal "DagScheduler dispatches track-by-track in order."
    • D2 — W4 descoped (see above).
    • D3 — Phase struct + Phase.Input/Simulation/Output/Cleanup statics kept as reusable tokens; only RuntimeOptions.Phases/DefaultPhase global resolution removed.
    • D4 — Trace format v11, hard-rejects v10-and-older (consistent with v6→v7 precedent).
    • D5 — AntHill migrates to a single "AntHill" DAG in the Public track.
    • D6 — Engine-Pre track defined though empty (symmetry).

    Workstreams

    • W1 — Track/Dag types; RuntimeSchedule track→DAG declaration API; per-DAG phase resolution + access-edge derivation; SystemDefinition.DagId; DagScheduler track-by-track dispatch; drop RuntimeOptions.Phases/DefaultPhase.
    • W2 — Fence as a normal DAG in Engine-Post; delete InternalScheduleBuilder, SystemBuilder.Internal(), SystemDefinition.IsInternal.
    • W3 — SystemDefinitionRecord.DagId; Tracks + DAGs trace tables; DAG-scoped phases; TraceFileHeader v11.

    Out of scope here: W4 (DTOs/orval), W5 (Workbench panels), W6 (docs/ADR). Work is on branch feature/354-track-dag-foundations.

  5. nockawa commented on May 17, 2026

    @nockawa
    CollaboratorAuthor

    W1–W3 implemented — ready for review + commit

    Branch feature/354-track-dag-foundations. Build clean (0 errors, 0 new warnings); 4084 tests pass (3716 engine + 333 Workbench + 35 client), 0 failed.

    Acceptance criteria — evidence

    W1 — Engine model

    • Track / Dag first-class types (Runtime/public/Track.cs, Dag.cs); RuntimeSchedule exposes the 3 built-in tracks + Track.DeclareDag(...). Declaring a DAG is mandatory — system registration exists only on Dag.
    • SystemDefinition.DagId added; IsInternal removed; flat global system index preserved.
    • RuntimeSchedule.Build resolves phases + runs AccessDagDeriver per-DAG; cross-DAG .After()/.Before() edges rejected.
    • RuntimeOptions.Phases / DefaultPhase / DefaultPhases removed.
    • DagScheduler holds Track[]→Dag[]; DispatchInternalSchedule generalized to DispatchTrack(int) + DispatchDeferredTracks(); in-tick loop dispatches Engine-Pre + Public track-by-track with a barrier; single-thread mode walks per-track topo order. UserSystems/SystemCount filter by engine track tag.
    • Evidence: RuntimeScheduleTests, DagSchedulerTests, PhaseTests, AccessDagDerivationTests (per-DAG phase resolution, track barrier, mandatory-DAG) — all green.

    W2 — Fence as a normal DAG

    • Fence declared as the "Fence" DAG on the Engine-Post track via the public API (FenceDagBuilder). InternalScheduleBuilder, SystemBuilder.Internal(), SystemDefinition.IsInternal deleted; Fence Configure drops .Internal().
    • RunParallelFence dispatches Engine-Post via DispatchDeferredTracks(); EnableParallelFence=false ⇒ empty Engine-Post + serial fallback.
    • Evidence: ParallelFenceTests (incl. single-threaded path) — green.

    W3 — Wire/trace format

    • SystemDefinitionRecord.DagId; new TrackRecord/DagRecord + TracksTable/DagsTable sections (replacing the global PhasesTable); DAG-scoped phase names; RuntimeConfigRecord drops phases; TraceFileHeader → v11, MinSupportedVersion rejects v10-and-older.
    • Profiler builders + exporters + Workbench trace-reader updated; round-trip tests green.

    Noted deviations (all flagged at plan time or below)

    • D1 — Engine-Post dispatches from the post-tick hook, not the in-tick track loop (forced by the Fence's dependency on serial WriteTickFence prep). DispatchInternalSchedule → DispatchTrack/DispatchDeferredTracks.
    • FenceExecBundle (4-system tuple) retained, moved into FenceDagBuilder.cs — the plan listed it for deletion alongside InternalScheduleBuilder; kept as it's a trivial useful struct.
    • RuntimeServiceExtensions.AddDagScheduler deleted — dead DI helper (no callers) built on the removed flat-DAG-from-DagBuilder construction path.
    • TyphonRuntime.PhaseNames / TyphonBridge.PhaseNames removed — vestigial flat phase list, no consumers after W3.

    Follow-ups

    • claude/rules/runtime-scheduling.md PR-01/PR-02 reference options.Phases/options.DefaultPhase in their mechanism text — the invariants still hold, only the wording is stale. Belongs to W6 (docs/ADR), out of this scope.
    • W4 (DTOs/orval) + W5 (Workbench panels) descoped as a paired follow-up; the Workbench still shows the pre-Runtime: introduce Track → DAG partitioning hierarchy (foundations) #354 System-DAG/Critical-Path behavior until then.
  6. nockawa commented on May 17, 2026

    @nockawa
    CollaboratorAuthor

    Accepted implementation plan — W4 + W5(System DAG) + W6

    Implementing via /implement-feature. Scope for this pass:

    • W4 — DTOs expose the Tracks[] → Dags[] → Phases[] hierarchy; SystemDefinitionDto.DagId; orval regen.
    • W5 — System DAG panel only: group by Track → DAG → Phase, hide engine-tagged tracks by default (toolbar toggle). Critical Path panel is out of scope — Loïc owns that rework.
    • W6 — Docs: overview/13-runtime.md, new ADR, rules/runtime-scheduling.md PR-01/02 fix, affected design docs, discard the scratch note.

    Key decisions

    • DTO shape — Solution A — TrackDto nests DagDto[]; Systems stays a flat top-level array (the flat global system index is load-bearing — predecessor/successor ushort refs, the active-systems bitmask, buildIndexToName). DagDto.Phases is a bare DAG-local string[]. Mirrors the trace's three tables 1:1.
    • Flat TopologyDto.Phases / ProfilerMetadataDto.Phases retained as a derived transitional field so non-W5 panels (DataFlow, AccessMatrix, ExecutionInspector) keep working untouched.
    • W5 covers the System DAG only. The Critical Path rework stays with Loïc — criticalPath.ts keeps consuming the retained flat Phases and is left untouched here.
    • Consequence: issue Runtime: introduce Track → DAG partitioning hierarchy (foundations) #354 stays open after this pass; the W5 checkbox is checked only once the Critical Path side also lands.

    Work continues on branch feature/354-track-dag-foundations.

  7. nockawa commented on May 17, 2026

    @nockawa
    CollaboratorAuthor

    W4 + W5(System DAG) + W6 implemented — ready for review + commit

    Branch feature/354-track-dag-foundations. Builds clean (0 errors, 0 new warnings); all suites green — 3716 engine + 334 Workbench + 682 client (Vitest); client tsc clean.

    Acceptance criteria — evidence

    W4 — Data API / DTOs

    • New TrackDto(Name, OrderIndex, Tags, Dags) + DagDto(Id, Name, Phases) in Dtos/Profiler/. SystemDefinitionDto gains DagId; ProfilerMetadataDto + TopologyDto gain Tracks (flat Phases retained as a doc-commented transitional field).
    • TrackHierarchyProjection.Project builds tracks[] → dags[] from the trace's Tracks/DAGs tables; wired into both TraceSessionRuntime and AttachSessionRuntime; DataController.GetTopology passes it through.
    • Orval regenerated — schema/openapi.json refreshed, trackDto.ts / dagDto.ts generated, topologyDto.ts + systemDefinitionDto.ts updated.
    • Evidence: TopologyAccessDeclarationsTests.Topology_ExposesTrackDagHierarchy — a 3-track / 2-DAG trace round-trips the full hierarchy through GET /topology with every system's DagId resolving.

    W5 — Workbench: System DAG panel (Critical Path deliberately untouched — Loïc's scope)

    • dagModel.ts buckets Track → DAG → Phase; lanes ordered track-order → DAG-order → DAG-local phase-order; lanes keyed ${dagId}::${phase} (DAG-local phase names can collide). DagModel gains dagGroups delimiter boxes.
    • SystemDagCanvas renders DAG group boxes (engine groups: dashed amber border + engine badge); useDagViewStore.showEngineTracks + a SystemDagToolbar "Show engine tracks" toggle (default off → engine-track systems excluded entirely).
    • Evidence: dagModel.test.ts — 24 tests (hierarchy bucketing, engine-track filtering, DAG-group emission, track-less fallback). Verified live in the browser via /wb-dev: the AntHill-shaped trace shows the user DAG grouped; toggling reveals the Fence DAG as its own ENGINE-POST / FENCE [engine] group.

    W6 — Docs

    • overview/13-runtime.md — scheduling-model section rewritten for Engine → Track → DAG → Phase → System; new ADR 052 (adr/052-track-dag-partitioning-hierarchy.md, indexed in adr/README.md).
    • rules/runtime-scheduling.md — PR-01/PR-02/PR-03 corrected to per-DAG phase resolution (stale options.Phases / DefaultPhase text removed); invariants unchanged.
    • Affected design docs updated: design/Runtime/02-system-scheduling.md, 07-system-access-declarations.md, design/Apps/Workbench/Modules/09-system-dag.md; scratch/system-tracks.md §2.1 terminology reconciled. Scratch note scratch/track-dag-foundations.md deleted.

    Noted deviations

    • W5 scoped to the System DAG panel only. The Critical Path rework stays with Loïc; criticalPath.ts is untouched and keeps consuming the retained flat TopologyDto.Phases.
    • Flat Phases retained on TopologyDto / ProfilerMetadataDto as a transitional field so non-W5 panels (DataFlow, AccessMatrix, ExecutionInspector) are not migrated in this pass.
    • A with-track-hierarchy variant was added to the DEBUG /api/fixtures/trace endpoint for the browser/e2e check.

    Status

    W4 + W6 checkboxes ticked. W5 left unchecked and the issue stays open — it also covers the Critical Path panel; the box is ticked once that lands.

  8. nockawa commented on May 17, 2026

    @nockawa
    CollaboratorAuthor

    W5 — Critical Path panel: track-aware rework (complete)

    The Critical Path half of W5 is done (the System DAG half landed earlier this session). The CP panel did a single global traceback which, because predecessors is DAG-local, only ever surfaced the last DAG of the last track (the Fence) — never the app's work. It is now track-aware.

    Acceptance criteria — evidence

    AC Evidence
    Shared engine-visibility setting (useViewOptionsStore.showEngineSystems) New persisted store; useDagViewStore.showEngineTracks removed, System DAG migrated. Browser-verified: toggling it updates both panels.
    Options panel "DAG" section New DagForm.tsx + "DAG" category in OptionsPanel. Browser-verified: "DAG & Critical Path" form with the toggle renders.
    Per-track CP algorithm criticalPath.ts — per-track measured traceback (terminus = track-wide argmax endUs); multi-DAG-per-track needs no special handling. criticalPath.test.ts +7 tests.
    Cross-track "All" mode Per-track chains concatenated in track order; engine tracks excluded unless showEngineSystems. Participation + aggregate use the same walk.
    Tracks band TickPathBars.trackSpans; CriticalPathView draws a single-lane Tracks band between the worker ribbon and the phase band, "All" scope only.
    Track selector + scope-honest header CriticalPathToolbar track <select> ("All" + tracks ≥1 DAG, engine-filtered); total = sum of what's shown. Browser-verified: selector shows All / Public, gains Engine-Post when the engine setting is on.
    Track-less fallback A topology with no track table falls back to the single global traceback — existing 31 CP tests unchanged.

    Verification

    • Vitest: 696 passed (CP criticalPath.test.ts 38, incl. 7 new track-aware tests; new useViewOptionsStore test).
    • tsc + vite build clean.
    • Browser (/wb-dev, fixture-trackdag trace): track selector + Options "DAG" section + cross-panel reactivity verified. The Tracks band / cross-track bars need a trace with measured per-tick data (the topology-only fixture shows the empty state) — covered by the build + unit tests.

    Docs

    design/Apps/Workbench/Modules/09-system-dag.md §5 updated to record the track-aware CP (it described only the pre-track global traceback).

    All of W1–W6 are now complete. Engine-side, app-declarable tracks (RuntimeSchedule.DeclareTrack) also landed this session as a follow-up — separate from #354's foundations scope.

    Not committed — handed off for review + commit.

  9. moved this from In Progress to Done in Typhon devon May 17, 2026
  10. added a commit that references this issue on May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions