Skip to content

SchedulerSystemArchetype touch rollup never emits — its two gates are mutually exclusive for cluster-native parallel systems #631

Closed

Description

@nockawa

Summary

TyphonEvent.EmitSchedulerSystemArchetype — the per-(system, archetype) entity-touch rollup that feeds the Workbench Data Flow module (#327) — appears to be unreachable for the only systems that can pass its archetype gate. Every capture produced so far carries zero SystemArchetypeTouchSummary rows, which leaves the Data Flow panel permanently empty.

Found while verifying #618 (F5) and #619 (F6) against a live database: both features join a trace bar to database storage, and neither could be exercised end-to-end because there are no bars to click.

Observed

Harness: scratch/mkcapture.cs — SWG schema, cluster-native Character archetype with a populated cluster (the same database whose File Map shows Cluster Character at 72 pages), a MovementSystem declared .Parallel(), 123 ticks captured with the full trace gate on.

  • SystemArchetypeTouchSummary rows in the capture: 0
  • entitiesProcessed reported by every system on every one of the 123 ticks: 0

The zero entity count is the more interesting half. A parallel query system over a populated cluster archetype processing nothing for 123 consecutive ticks is either the harness misusing the API or the runtime under-reporting.

The two gates

TyphonRuntime.EmitSchedulerSystemArchetypeIfActive (src/Typhon.Engine/Runtime/public/TyphonRuntime.cs:2270-2299) requires both:

Gate Line Passes only when
_systemArchetypeIds[sysIdx] != ushort.MaxValue :2277 the system is IsParallelQuery and bound to an ArchetypeClusterState with ActiveClusterCount > 0 (:503-521)
metrics.EntitiesProcessed > 0 :2285 the system's view materialized a non-empty EntityId list (:2197)

Hypothesis (not yet proven — needs a repro before anyone changes code)

The two gates may be structurally antagonistic:

  • EntitiesProcessed comes only from entities is PooledEntityList pel ? pel.Count : 0 (:2197), fed by BuildFullViewEntitySet (:948), which returns PooledEntityList.Empty the moment view.Count == 0 (:951).
  • ViewBase.Count is _entityIds.Count (src/Typhon.Engine/Querying/public/ViewBase.cs:117) — the materialized entity-id map.
  • Binding a cluster state switches the system to cluster-RANGE dispatch, which is precisely the path that avoids materializing a per-entity id list — that is the point of cluster-native storage.

If that holds, gate 1 selects exactly the systems for which gate 2 is structurally 0, and the emission is dead code as written. This is a hypothesis built from reading the two paths, not a confirmed root cause — the alternative (the harness fails to populate the view, or ActiveClusterCount is 0 and gate 1 is what actually fails) has not been ruled out, and the fix differs completely between them.

Why it matters

Suggested first step

Write an engine test that ticks a cluster-native archetype through a .Parallel() QuerySystem and asserts GetCurrentSystemMetrics(sysIdx).EntitiesProcessed > 0. That single assertion separates the two hypotheses without touching the Workbench at all: green ⇒ the harness is wrong and wants documenting; red ⇒ the runtime under-reports and gate 2 needs to source its count from the dispatched cluster range rather than the view.

Acceptance criteria

  • An engine test pins the expected EntitiesProcessed for a .Parallel() system over a populated cluster-native archetype
  • Root cause identified with evidence (runtime under-report vs. harness misuse) — not assumed
  • If a runtime bug: fixed, with the touch summary emitted for cluster-native parallel systems
  • If harness misuse: the required system/view shape documented where a user would look for it
  • A capture from scratch/mkcapture.cs carries a non-zero SystemArchetypeTouchSummary row count
  • F5 — Structural correlation bridges #618 §4.3 and F6 — Physical lens: performance → storage #619 AC1/AC7 verified in the browser against that capture

References

  • Emission site: src/Typhon.Engine/Runtime/public/TyphonRuntime.cs:2266-2299
  • Cluster-state binding: src/Typhon.Engine/Runtime/public/TyphonRuntime.cs:498-525
  • Entity-count source: src/Typhon.Engine/Runtime/public/TyphonRuntime.cs:2195-2202, :948-986
  • Design: claude/design/Apps/Workbench/10-database-and-profiles.md §1.6, §4.2, §4.3

Activity

  1. added theissue type on Aug 1, 2026
  2. updated Area Runtime, Priority P1-High, Estimate M, Product Engine and Bug status New on Aug 1, 2026
  3. moved this to Todo in Typhonon Aug 1, 2026
  4. nockawa commented on Aug 8, 2026

    @nockawa
    CollaboratorAuthor

    Fixed in PR #719. The hypothesis in this issue is refuted, and the real cause was somewhere else entirely.

    The hypothesis, tested

    The suggested first step was exactly right, so I built it: SystemArchetypeTouchTests ticks a .Parallel() QuerySystem over a populated cluster-native archetype and asserts on both gates.

    Both gates pass, together, at 1 and 4 workers. EntitiesProcessed is not merely non-zero — it equals the entity count the walk actually visited, which is what the test asserts (an over-reporting gate would fill the Data Flow panel with numbers nobody did). So gate 1 does not select systems for which gate 2 is structurally 0.

    The two system-end hook fixes that would have explained it both landed in the #327 PR itself (7741eef3, 2026-05-10), long before this was filed. Neither was ever the cause.

    What was actually broken

    The binding is resolved once, in the TyphonRuntime constructor, and was gated on ActiveClusterCount > 0. That reads a transient condition to make a permanent decision: build the runtime before loading data — the order every sample, and scratch/mkcapture.cs, uses — and _systemArchetypeIds[i] stays ushort.MaxValue for the rest of the session.

    Gate 1 being shut is the smaller half. The same resolution sets _systemClusterStates, which is what switches a parallel system to cluster-RANGE dispatch. Left null, the system silently falls back to materializing a per-entity id list from its view — a permanent, silent regression on precisely the storage mode cluster dispatch exists for.

    Dropping the count is safe: a bound state whose count is zero was always reachable (nothing un-binds a drained archetype), and both dispatch paths read the count live per tick.

    A second copy of the same defect turned up next door and is fixed in the same PR — BuildTierIndexesAtTickStart's late-spawn recovery took the first cluster-eligible archetype rather than the system's own, which is the pre-#662 binding bug left behind in the recovery path.

    What made the capture empty

    Neither gate: #718. An unfiltered Query<T>().ToView() is frozen at construction, so a system fed one processes only the entities that existed when its view was built. A harness that builds views before loading data gets entitiesProcessed = 0 on every system on every tick — exactly what was reported — and gate 2 is then honestly reporting zero work.

    That is a P0 in its own right, filed separately with two quarantined regression tests.

    Acceptance criteria

    The last two are deliberately left open; closing them needs a browser session and a capture this fix alone cannot make non-empty.

  5. moved this from Todo to In Progress in Typhonon Aug 8, 2026
  6. added a commit that references this issue on Aug 8, 2026
  7. moved this from In Progress to Done in Typhonon Aug 8, 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

    Fields

    Priority

    P1-High

    Estimate

    M

    Area

    Runtime

    Start date

    None yet

    Target date

    None yet

    Bug status

    New

    Product

    Engine

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions