Repository navigation
fix(replay): a counter that stood for work, and a comparison that ran (#833, #817) - #857
Merged
Merged
Conversation
Three defects of one kind — a number or a comparison standing for work that never happened. A skipped event was counted as a success. replayEvent incremented SkippedEvents and returned nil, and the driver read the nil error as a success, so a skip incremented both. IncludeBodies defaults to false, so no event on a default-configured stream carries a request: every event was skipped, and a replay reported total=N success=N having executed none of them. replayEvent now reports whether it executed the event, separately from the error, and the three counters partition the stream. A recorded refusal that replayed as a success reported no difference. The error comparison ran only when the replay itself errored, and the status comparison could not stand in for it because a pre-plugin refusal records with a nil response — so event.Response is nil for exactly the refused events. A recorded 403 replaying as a 200 was no difference at all. It is now critical, matching the reverse case: a replay that grants what the recording denied is the divergence that makes a passing test meaningless. ValidateState was inert. IncludeStateHashes was declared, plumbed and defaulted, and never read, so both comparisons were guarded on a field nothing wrote. The server and the stack deployer now record both hashes when the store keeps them, taken before the first refusal point so a refused request records the same hash on both sides. One function produces the recorded and the replayed hash, for the reason #826 established for ARNs. StartTestServer gains WithRecordedBodies and WithRecordedStateHashes. The first is why the flagship e2e journey passed while replaying nothing, and there was no option to change it; that test now asserts events were executed, and reads the object back to prove it. Recorded, not fixed: isReplaying is dead at three sites, not one, and a replay never freezes the clock — so #817's premise that simulated-clock timestamps compare equal is false. Both need #856 first. Part of #833. Part of #817.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three defects in replay's reporting, all the same kind as this release's other groups: a number or a comparison that stood for work that never happened.
Part of #833 and part of #817 — their reporting halves. Both issues stay open; the execution halves need a shared request pipeline and a protocol-aware body differ, and both are blocked on #856. Deliberately no closing keyword.
A skipped event was counted as a success
replayEventincrementedSkippedEventsand returned a nil error for an event with no request; the driver read the nil error as a success and incrementedSuccessEventstoo. SinceIncludeBodiesdefaults to false, no event on a default-configured stream carries a request — so every event was skipped, and a replay of such a stream reportedtotal=N success=Nwhile executing none of them.replayEventnow returns whether it executed the event, separately from the error, because a skip is neither a success nor a failure and both return nil. The three counters now partition the stream, stated as an invariant onReplayResults, and the completion log reports the skipped and difference counts —total=N success=Nandtotal=N skipped=Nare the same stream with and without bodies, and only one of them verified anything.SuccessEventsis documented as "re-executed without returning an error", not "matched the recording".A recorded refusal that replays as a success reported no difference
The error comparison sat inside the
err != nilarm, so a successful replay never consultedevent.Error; and the status comparison could not stand in for it, because every pre-plugin refusal records with a nil response, soevent.Responseis nil for exactly the events that were refused. A recorded 403 replaying as a 200 was reported as no difference at all — and, before the counter fix, as a success.Classed critical, matching the reverse case already there: a replay that grants what the recording denied is the divergence most likely to make a passing test meaningless, because it is the one that lets a request through.
ValidateStatewas inert on every recorded streamIncludeStateHasheswas declared, plumbed through config and defaulted, and never read;StateHashBefore/StateHashAfterwere never written outside a hand-built test event. Both comparisons were guarded on a field that was always empty —AttachmentCount's defect (#847) in another subsystem.ServerandStackDeployernow record both hashes when the store keeps them, taken before the pipeline's first refusal point so that a refused request records the same hash on both sides rather than leaving the field empty and having the replay skip the check.EventStore.RecordRequestgainsWithStateHashes(before, after); the caller supplies both because only the caller knows when "before" was, and the store's config stays the authority on whether the event keeps them.The recorded hash and the replayed hash come from one function,
stateSnapshotHash, for the reason #826 established for ARNs: two implementations of "hash the state" would be two answers, and the comparison would report a difference on every event.Hashing is routed through the server and the deployer rather than by giving the store a state manager, deliberately:
NewEventStorestarts a background snapshot goroutine whenSnapshotInterval > 0 && stateRef != nil, and the default interval is 100 — so that wiring would have started a goroutine in every test server.Enabling this on a stream containing a create now reports a mismatch. That is the honest answer, not a defect: substrate mints most identifiers from
crypto/rand, so the minted value differs between a recording and its replay and lands in the state being hashed (#856). Making the comparison run is what surfaces it.StartTestServercan record bodies and hashesWithRecordedBodies()andWithRecordedStateHashes(), both off by default. The first is what any replay test needs, and its absence is why the flagship end-to-end journey passed while replaying nothing —IncludeBodiesdefaults to false and there was no option to change it.TestJourney_RecordAndReplayis rewritten accordingly. It now assertsSkippedEvents == 0andSuccessEvents == TotalEvents, and reads the object back afterwards —Replaywipes state first, so an object readable after the replay can only have been written by the replay. A counter cannot make that claim, which is the whole reason the old version passed.Recorded, not fixed
Both were narrower in the issues than in the tree, and both are now on the issues:
isReplayingis dead at three sites, not one —quota.go:87,consistency.go:85,consistency.go:127— because a replay callsRouteRequestdirectly and never enters the pipeline that would set it.SetScaleis called nowhere on that path andTimeController.Now()isbaseline + (wall elapsed × scale), so Replay: deep-compare response bodies during verification #817's premise that simulated-clock timestamps in a body compare equal across a recording and its replay is false. WithLastModifiedformattedRFC3339Nano, everyListObjectsV2body diverges.Two prerequisites filed rather than folded in: #855 (
substrate replaybuilds an empty registry and a nil state manager, so every routed request answersServiceNotAvailable) and #856 (deterministic identifier minting, which is what unblocks both replay issues).Verification
Each new test was checked against the defect it exists for, by reverting that one behaviour and confirming the test fails:
true(old semantics)ASkippedEventIsNotCountedAsASuccess—SuccessEventswas 2, want 0event.Error != ""differenceARecordedRefusalReplayingAsSuccessIsCritical— 0 differences, want 1recordedStateHashreturns""StateHashesAreRecordedandValidateStateReportsADivergenceWithRecordedBodies()dropped from the e2e journeyTestJourney_RecordAndReplay— skipped 2 of 2, andGetObject404sEach defect test has a negative twin, so neither direction is vacuous: a stream with nothing refused reports no
errordifference, a server that did not ask for hashes records none, andValidateStateon a stream without hashes reports nothing. All eight tests record over the wire throughStartTestServerand replay that stream — theputTest*helpers are not extended (#765), and a hand-built event can carry a hash nothing would have recorded, which is how the existing coverage passed while the feature did nothing.Full nine-command gate green:
gofmt/build/vet,golangci-lint,make test,GOTOOLCHAIN=go1.26.6 make test, coverage (emulator 83.8%, total 83.2% — baseline held), docs reference + version + authz checks,npm --prefix docs run build, and e2e vet + tests.