feat(replay): Replay-Bypass side-effect guard (ADR-0027)#9
Merged
Conversation
…eliberate replay (ADR-0027) Backward-compatible capability upgrade: ReceivedMessage gains an additive Headers map; an optional HeaderPublisher interface (transports MAY implement) carries out-of-band headers; InMemoryTransport implements it. Redrive's new Bypass option stamps a bq-replay-bypass header; the runtime surfaces it to the handler's context; IsReplay + BypassExternalEffects let a handler re-run its idempotent core but skip effects that already fired. No envelope change (GR-1), no breaking Transport change. Concrete broker transports + other SDKs to follow.
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.
Closes ADR-0026's phase two: a deliberate replay re-runs the handler, and its external side-effects re-fire (a second charge, a duplicate email). Idempotency stops an accidental duplicate; this stops the intended reprocess from re-firing effects that already happened. Implements ADR-0027.
What (backward-compatible capability upgrade)
ReceivedMessage.Headers— additivemap[string]stringof out-of-band transport headers (nil-safe).HeaderPublisher— an optionalTransportinterface (PublishWithHeaders); transports that don't implement it just don't propagate headers. No existing transport changes to compile.InMemoryTransportimplements it.RedriveBypassoption — stamps thebq-replay-bypassheader on redriven messages (best-effort: a no-op,Bypassed=false, on a transport that can't carry headers).context;IsReplay(ctx)+BypassExternalEffects(ctx, fn)let a handler skip the external, non-idempotent side on a replay while still running the idempotent core.Tests
5 tests via
InMemoryTransportincl. the end-to-end path (redriveBypass→ header carried →dispatchsurfaces it →BypassExternalEffectsskips the effect) and the fallback when the transport isn't aHeaderPublisher. Coverage 93.8%,-raceclean; existing tests unchanged. Envelope frozen (GR-1).Rollout
Concrete broker transports projecting the header onto native metadata, and the other SDKs, follow — like the broker bindings themselves.
🤖 Generated with Claude Code