Skip to content

Follow-up #345: Playwright e2e + post-review hardening on ChunksPerWorker - #347

Merged
nockawa merged 1 commit into
mainfrom
feature/345-followup
May 12, 2026
Merged

nockawa merged 1 commit into
mainfrom
feature/345-followup

Conversation

@nockawa

@nockawa nockawa commented May 12, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #345 / PR #346 — closes the two remaining acceptance-criteria boxes (Playwright /aggregate debounce spec + post-Phase-C 10-internal-data-api.md §9 rewrite) and lands the actionable findings from a post-merge code review.

What's in this PR

Closes the remaining #345 acceptance criteria

  • e2e/profiler-aggregate-debounce.spec.ts — new Playwright canary. Opens the with-access-declarations trace fixture, opens SystemDag via the View menu and reactivates the Profiler tab (so the TimeArea canvas is hit-testable), emits a 12-frame wheel burst, and asserts the post-burst /aggregate POST count is < WHEEL_BURST_FRAMES. The assertion intentionally targets the decoupling (count not proportional to gesture frames), not an absolute consumer-hook count — adding new /aggregate consumers won't silently weaken it.
  • useProfilerViewStore.transient.test.ts — new unit test cross-panel viewRange subscribers do NOT fire during a transient-write burst. Subscribes before the burst, proves transient subscribers fire N times but viewRange subscribers fire zero times mid-burst and exactly once after the debounce. This is the load-bearing fluidity invariant the refactor was built to establish.
  • TimeArea.tsx — added data-testid="profiler-time-area-canvas" so the Playwright spec can locate the canvas reliably.
  • TopSpansPanel.tsx — stale comment rewritten: the panel's stats no longer have an internal 150 ms debounce (that was removed in Workbench Profiler: time-window single-source-of-truth refactor (fluidity fix) #345 step 5); coalescing across pan/zoom bursts is handled upstream by the transient/committed slot split.

Post-review hardening for the ChunksPerWorker knob (separate concern, bundled)

A post-merge code review surfaced two real bugs in the just-merged scheduler knob plus a couple of test-coverage gaps:

  • RuntimeSchedule.cs — validation rewritten. Previously rejected only <= 0f and !IsFinite. Now requires chunksPerWorker ∈ [1.0, 64.0]:
    • Sub-1 values would reduce parallelism below the worker count — confusing for an "oversubscription" knob and not a use case the API was designed for.
    • Values above ~64 hit a real int * float → (int) cast overflow path: (int)MathF.Round(WorkerCount × 1e10f) collapses to int.MinValue, then Math.Max(1, MIN) = 1 silently produces one chunk — the opposite of the user's intent.
  • SystemDefinition.cs, SystemBuilder.cs — XML doc updated to reflect the new bounds and overflow rationale.
  • TyphonRuntime.cs:54 — stale [chunkIdx] comment on _partitionViews corrected to [workerId]. The bug-prone naming the patch killed was still in the comments inviting the next reviewer to reintroduce it.

Stronger tests around the per-worker pool indexing fix

The original fix in #345 patched two indexing sites (_partitionViews and _tierRangeViews) but only the first was end-to-end tested. The tier-filtered path (GetOrCreateTierRangeView) had no fixture; a regression would only have been caught by AntHill at runtime.

  • TierDispatchTests.cs — new TierDispatch_ChunksPerWorker_VisitsAllTierEntities regression test. Spawns 8 Tier0 entities across 8 cells, runs with WorkerCount=2 + ChunksPerWorker=2 (cap=4 chunks > 2 workers), asserts via HashSet equality that every entity is visited exactly once.
  • ChunksPerWorkerTests.cs —
    • Oversubscribed_AllEntitiesAreVisited tightened from >= entityCount to HashSet.SetEquals (catches double-visits that the old >= survived).
    • New WorkerCount1_TwoX_SingleWorkerHandlesBothChunks — the degenerate case where a single worker drains all chunks, regression-pinning the workerId vs chunkIndex distinction.
    • New TieRounding_BankersRound_ToEven — pins MathF.Round's ToEven behaviour at 2 × 1.25 = 2.5 → 2 (not 3). If anyone later switches to MidpointRounding.AwayFromZero, this test surfaces the deliberate decision.
  • ScheduleValidationTests.cs — 4 new tests for the tightened bounds: BelowOne_Throws, AboveUpperBound_Throws, AtBoundaries_Succeeds, PositiveInfinity_Throws.

Companion docs change (separate repo — not in this PR)

claude/design/Apps/Workbench/10-internal-data-api.md §9 has been rewritten on the local working tree to reflect the post-Phase-C shipped state (two-store split: useProfilerViewStore owns viewport, useSelectionStore owns stable dimensions). The claude/ repo commit + push is pending and lives in a separate repository.

Test plan

  • dotnet build clean (engine + tests)
  • dotnet test — 3605 / 3605 engine tests pass (33 skipped, unchanged from main)
  • npx tsc --noEmit clean (TS strict)
  • npx vitest run — 607 / 607 tests pass (+1 new subscription-fire test)
  • Updated 26 scheduler tests pass: 18 ScheduleValidationTests + 7 ChunksPerWorkerTests + 1 new TierDispatch_ChunksPerWorker_VisitsAllTierEntities
  • Manual: npx playwright test profiler-aggregate-debounce.spec.ts (needs /wb-dev start first)

Closes the remaining #345 acceptance criteria.

🤖 Generated with Claude Code

@nockawa
nockawa merged commit 93cfea7 into main May 12, 2026
6 checks passed
@nockawa
nockawa deleted the feature/345-followup branch May 12, 2026 15:03
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