Repository navigation
Assert replayed deletes classify as 'delete', not 'put', across every subscription replay variant - #3159
Merged
Conversation
…n replay variant harper#2735 reported single-record audit replay stamping every replayed entry as 'put', including genuine deletes, via an unconditional `if (getFullRecord) auditRecord.type = 'put'` in Table.ts. That line no longer exists on main: PR #2767 rewrote the path into eventFromAudit, which classifies a superseded-skip replay from the current entry's state (put/invalidate/delete) and only rewrites 'patch' to 'put' for the includeSuperseded/rawEvents paths when getFullRecord is set. Extends the existing create->patch->patch->delete regression test to also cover rawEvents (getFullRecord: false), the one variant not previously asserted for type. Confirmed red by temporarily reintroducing the unconditional `type = 'put'` stamp (reverted before this commit) — it failed exactly the default and includeSuperseded delete assertions, never rawEvents, matching the issue's own description of which paths the bug touched. No production code change: eventFromAudit already types every variant correctly on main. This closes #2735 with the regression test it was missing. Dispatch-Task: harper-2735 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F7P8KyqX84mj6E3ToSmSYi
…ally asserts Pre-push review (adjudicated nit): the comment claimed "any replay variant" but only checks default, includeSuperseded, and rawEvents — not previousCount replay or rawEvents+includeSuperseded:false. Dispatch-Task: harper-2735 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F7P8KyqX84mj6E3ToSmSYi
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds a test case and explanatory comments to unitTests/resources/subscriptionSuperseded.test.js to verify that a replayed delete is never reported as a 'put' event when using raw events. Specifically, it asserts that subscribing with rawEvents: true correctly preserves the event types as ['put', 'patch', 'patch', 'delete']. There are no review comments to evaluate, and we have no additional feedback to provide.
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.
⊙ Problem
harper#2735 reported that single-record audit replay (a subscription with
startTime, history backfill) stamped every replayed entry asput, including genuine deletes, via an unconditionalif (getFullRecord) auditRecord.type = 'put'. That line no longer exists on main: Skip superseded subscription updates during catch-up rewrote the path intoeventFromAudit, which classifies a superseded-skip replay from the current entry's own state (put/invalidate/delete) and only rewritespatchtoputwhengetFullRecordis set. The fix shipped with no regression test, so nothing proves it holds or would catch a reintroduction.💡 Solution
Extends the existing create→patch→patch→delete delete-replay test to also assert the
rawEvents: truecase — the one replay variant the suite checked for value but not for type. The comment above it names the three variants the test now covers.✅ Verification
npx mocha unitTests/resources/subscriptionSuperseded.test.js— 29 passing, including the newrawEventsassertion for both the collection and single-record scopes.type = 'put'stamp ineventFromAudit, rebuiltdist/, reran — the default andincludeSupersededdelete assertions failed with'put'where'delete'was expected;rawEventswas unaffected, matching the issue's own description of which paths the bug touched. Reverted before committing.subscriptionReplay,subscriptionSuperseded,subscribeResume,subscriptionPreviousCountScanBound,subscribeProgress,subscriptionBufferedState) for regression confidence: 113 passing, 9 pending, no failures.Fixes #2735. Refs #2767 (the production fix this test covers). Refs #2439 — a different mechanism (the live-subscription listener recomputing event type at dispatch time, not the replay/backfill path) and intentionally not touched here.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01F7P8KyqX84mj6E3ToSmSYi
Release target: main — test-only regression coverage for a defect PR #2767 already fixed in production code; no v5.4 branch exists yet, so there is nothing to backport
Related PRs: #2767 independent (supplies the production fix this test covers; merged before this branch, nothing to reconcile), #2826 independent (unrelated fixture/CI-timing change)
Complexity: easy
Origin — the dispatch brief this PR was written from
Verify and lock in correct event types on single-record audit replay (#2735)
harper#2735 reports that single-record audit replay (a subscription with startTime, history backfill) stamped every replayed entry as type 'put', including genuine deletes, because of an unconditional
if (getFullRecord) auditRecord.type = 'put'in resources/Table.ts. That line no longer exists on main: PR #2767 ("Skip superseded subscription updates during catch-up", commit 63f1615) rewrote the path intoeventFromAudit(resources/Table.ts ~7349-7372). There, the default path classifies from the current entry (INVALIDATED ? 'invalidate' : value ? 'put' : 'delete'), and the includeSuperseded/non-mutation path only rewrites 'patch' to 'put' when getFullRecord is set. The issue looks fixed but has no regression test. Your job: (1) prove on current main, with a test, that a create → update → delete sequence on one record replays with true event types (the delete arrives as 'delete', never as a 'put' with no record) on every replay variant: default (superseded skipped), includeSuperseded, and rawEvents (getFullRecord false). Compare against the live stream of the same sequence where useful. (2) If any variant still mis-types an event, fix it in eventFromAudit and keep the fix local to that function. (3) Open a PR that adds the regression test and closes #2735.Acceptance
A new test that would fail if a replayed delete were reported as 'put' (show it red by temporarily reverting to the unconditional overwrite), covering default, includeSuperseded, and rawEvents replay. Test passes on the PR head. PR body states whether #2767 already fixed the defect or what remained. Don't touch the live-subscription listener (#2439).
Dispatch: task
harper-2735· queued by kris-session · ran by claude/sonnet/xhigh · worker kzyp-xps-1Review-Coverage: authored=claude; ran=gemini,codex; adjudicated=domain; declined=cursor-grok,cursor-composer,cursor-kimi,cursor-muse; rounds=2; full=1 @ 186ff48
Review-Attention: skim ~2m (decisions: delete-assertion-placement) @ 186ff48