Skip to content

refactor: isolate scheduler state and condense code comments - #211

Merged
glennawatson merged 11 commits into
mainfrom
refactor/deterministic-tests-and-concise-docs
Sep 12, 2026
Merged

glennawatson merged 11 commits into
mainfrom
refactor/deterministic-tests-and-concise-docs

Conversation

@glennawatson

@glennawatson glennawatson commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

  • Refactoring, concurrency fixes, and documentation changes.

What is the new behavior?

We removed the tests’ dependence on live sequencer state and timing because it was nondeterministic, causing the same code to pass on some runs and fail on others. Tests now control time and state transitions explicitly, making those cases repeatable and removing that source of flaky failures.

  • Cancellation cleanup takes ownership of returned resources before disposing them. Cancelling after publication and then running final cleanup releases the resource once.
  • Continuation delivery and release complete a handoff without blocking a worker thread. Tests control both event orders, stale observer snapshots, replacement races, and late timer callbacks.
  • Production comments describe inputs, outputs, ordering, and ownership. Verbose summaries and implementation narration are removed; retained remarks explain contracts the signatures cannot express.
  • WinUI test projects skip PRI generation and native manifest packaging on non-Windows hosts, using the same settings as the WinUI libraries.

What is the current behavior?

  • Some tests depend on real threads, dispatcher pumps, or system timing. State decisions are mixed with runtime dispatch, making competing updates difficult to reproduce.
  • Result cleanup can dispose the same resource twice after cancellation. Continuation handoffs use a barrier and background work; many comments narrate those implementations.

What might this PR break?

  • Scheduling order, cancellation, and handoff completion are sensitive to these changes. Public signatures remain unchanged; API baselines record coverage and inlining attribute changes.
  • Native Windows, Android, and Apple execution still requires the corresponding platform.

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

  • Full solution build: 0 warnings and 0 errors. All 76 test assemblies passed across .NET 8–11: 13,038 passed, 0 failed; this includes 24 Windows-platform placeholder checks.
  • The six actual Windows test projects cross-compiled with 0 warnings and 0 errors on Linux, without MakePri or native manifest packaging. Native Windows tests were not executed.
  • The source audit covers all 253 concurrency candidate files. Coverage from 14 .NET 10 suites confirms execution of the extracted state methods.
  • Documentation audit: 7,354 production summaries, none over 30 words or one sentence. All 176 retained remarks have individual contract justifications; all 218 initially flagged summaries have before/after evidence.
  • The dependency audit found no Verify-family or Simon Cropp-authored packages among 207 resolved package versions. PublicApiSharp remains enabled.

- Replace delays, polling and thread rendezvous with awaited completion
  sources, virtual clocks and ordered calls into internal seams.
- Add seams for stepwise dispatch: WasmScheduler.QueueReady and
  RunReadyBatch, so enqueue, dispose and drain are explicit steps.
- Assert per-item dispatch counts where a total was checked before.
- Trim documentation to the contract: concise summaries, inline notes at
  the confusing line, and remarks only for non-obvious behaviour.
- Correct exception docs to the type thrown rather than the guard helper.
- Reduce internal operator and helper summaries to a single line of behaviour.
- Drop allocation and deadlock rationale from field and method summaries.
- Keep remarks for public contracts a caller cannot infer from the signature.
@glennawatson glennawatson changed the title chore: Update benchmarks and fix tests refactor: isolate scheduler state and condense code comments Sep 12, 2026
- Scale between ticks and monotonic timestamps without a double round trip, so
  a duration representable on both grids survives unchanged.
- A 50-tick delay converted at a 10 MHz timestamp frequency no longer lands a
  tick late, which left scheduled work undue at its own due time.
- Replace placeholder parameter text with the role the argument plays.
- Say which window a sequencer times, and which side an observer receives.
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.77%. Comparing base (cb8fb40) to head (38138a2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #211      +/-   ##
==========================================
+ Coverage   99.10%   99.77%   +0.66%     
==========================================
  Files         711      714       +3     
  Lines       22078    22219     +141     
  Branches     2703     2733      +30     
==========================================
+ Hits        21881    22169     +288     
+ Misses        196       49     -147     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@glennawatson
glennawatson merged commit 6dab874 into main Sep 12, 2026
13 checks passed
@glennawatson
glennawatson deleted the refactor/deterministic-tests-and-concise-docs branch September 12, 2026 16:18
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