Skip to content

test: add replay coherence characterization harness (#5) - #15

Merged
Chinmay-KB merged 17 commits into
mainfrom
cursor/replay-characterization-harness-0912
Jul 25, 2026
Merged

test: add replay coherence characterization harness (#5)#15
Chinmay-KB merged 17 commits into
mainfrom
cursor/replay-characterization-harness-0912

Conversation

@Chinmay-KB

@Chinmay-KB Chinmay-KB commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements #5 from the SDK replay correctness milestone: deterministic characterization coverage for known navigation/frame races, with no production capture behavior changes.

What’s included

  • Test-only controller seams (debugNow, debugDelay, debugExecuteCapture, debugSeedFrame, debugFreezeStateAnchor, route/capture debug getters)
  • Reusable harness: ControllableScheduler, ControllableCaptureExecutor, ReplayCoherenceHarness, CoherenceInvariants
  • Characterization scenarios covering:
    • coherent same-route tap settle
    • noVisibleChange before delayed route_change
    • destination tap carrying origin-route frame while capture pending
    • rapid route-epoch cancellation without queue hang
    • modal push/pop/replace ordering
    • signature-only changed with unchanged frame
    • capture failure / blocked capture waiter completion
  • Version bump 0.4.00.4.1

Review follow-ups

Addressed Copilot comments:

  • _delay preserves Future.delayed(Duration.zero) yielding (and always routes through debugDelay when set)
  • debugExecuteCapture path refreshes state + emits inventory like production capture

Test plan

  • flutter test test/replay_coherence_characterization_test.dart
  • flutter test test/sdk_version_test.dart test/replay_coherence_characterization_test.dart test/tugboat_replay_test.dart

Follow-ups: #6#10 can flip the CoherenceInvariants expectations to isTrue as behavioral fixes land.

Open in Web Open in Cursor 

Fixes #5.

Add deterministic, advanceable scheduler/capture test seams and
characterization coverage for known navigation/frame races without
changing production capture behavior. Bumps tugboat to 0.4.1.

Co-authored-by: Chinmay Kabi <chinmay@blend.to>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a deterministic, advanceable test harness to reproduce and characterize known replay coherence races (navigation vs capture vs tap settlement), plus test-only controller seams to control time/delays/capture execution and seed frames. This supports the “SDK replay correctness” milestone by locking in today’s broken-but-observed sequences so follow-up fixes (#6#10) can flip invariants without rewriting the harness.

Changes:

  • Introduces a reusable replay coherence harness (ControllableScheduler, ControllableCaptureExecutor, ReplayCoherenceHarness, CoherenceInvariants) and characterization scenarios covering known ordering/frame attribution races.
  • Adds test-only controller seams (debugNow, debugDelay, debugExecuteCapture, debugSeedFrame, debugFreezeStateAnchor) to make controller timing/capture deterministic without wall-clock sleeps.
  • Bumps SDK/package version 0.4.0 → 0.4.1 and updates changelog + tugboatSdkVersion.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/tugboat/test/replay_coherence_characterization_test.dart Adds characterization tests for known replay coherence race sequences and invariant checks.
packages/tugboat/test/helpers/replay_coherence_harness.dart Adds deterministic scheduler/capture executor harness and invariant helpers for replay coherence testing.
packages/tugboat/pubspec.yaml Version bump to 0.4.1.
packages/tugboat/lib/src/sdk_version.dart Keeps SDK version constant in sync with pubspec bump.
packages/tugboat/lib/src/controller.dart Adds test-only seams for deterministic timing/capture and frame seeding; routes/capture waits now use overridable delay/clock.
packages/tugboat/CHANGELOG.md Documents the new characterization harness/seams.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/tugboat/lib/src/controller.dart
Comment thread packages/tugboat/lib/src/controller.dart
Keep zero-duration waits yielding via Future.delayed/debugDelay, and
refresh state plus emit inventory on the debugExecuteCapture path so
the test seam matches production capture semantics.

Co-authored-by: Chinmay Kabi <chinmay@blend.to>
@cursor

cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown

Addressed both Copilot review comments in eee3d26:

  1. _delay zero-duration yielding — always routes through debugDelay when set, otherwise Future.delayed (including Duration.zero), so production no longer sync-completes. Harness mirrors with a microtask yield for ≤0.
  2. debugExecuteCapture semantics — override path now calls _refreshStateAnchor() before capture and _maybeEmitSceneInventory() after, matching the production capture path.

Tests still green on the characterization suite + tugboat_replay_test.dart.

Chinmay-KB and others added 15 commits July 25, 2026 12:12
Replace content-hash frame families with explicit harness route+epoch
provenance so actionFrameMatchesRoute requires destination attribution.

Co-authored-by: Cursor <cursoragent@cursor.com>
Require an exact destination route event id and tap-relative ordering in
navigationTapHasNoEarlyNoVisibleChange harness checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
Mirror package widget tests with MaterialApp/Scaffold, RepaintBoundary, and
a keyed FilledButton target mounted under the harness boundary key.

Co-authored-by: Cursor <cursoragent@cursor.com>
Assert stable widget-backed target anchors and compare tap state signatures
against scene_inventory rather than hard-coded synthetic values.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise the controller swipe classification seam and assert tap/swipe
subsequence ordering without requiring an exact full event list.

Co-authored-by: Cursor <cursoragent@cursor.com>
Require tap/settle before and after frames to share route+epoch provenance
without forcing afterFrame to equal the origin capture id.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add a harness-only auto-release seam that cancels blocked captures with null
instead of seeding a success frame, keeping manual completion separate.

Co-authored-by: Cursor <cursoragent@cursor.com>
Apply dart format to the replay coherence harness and characterization tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve captured-frame route provenance from the frozen state anchor and
dispose widget-backed harness sessions cleanly to avoid semantics leaks.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Chinmay-KB
Chinmay-KB marked this pull request as ready for review July 25, 2026 08:09
@Chinmay-KB
Chinmay-KB merged commit d5992b7 into main Jul 25, 2026
2 checks passed
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.

[Replay] Add deterministic characterization tests for event/frame coherence

3 participants