You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keep page metadata history monotonic by observation timestamp.
Ignore delayed or duplicate navigation snapshots that are not newer than the current row.
Cover older retries, exact duplicate event IDs, and chronological handling of an out-of-order batch.
Root cause
The history write ran after the event upsert but queried only the current metadata hash. A delayed retry with different metadata could close a newer row at an older timestamp and replace it as current.
P1 extension/db/migrations/page_metadata_history_atomic.sql:46 still lets a stale, different snapshot replace metadata observed later. The function compares an incoming timestamp with valid_from_ts, but a newer observation with the same hash returns at lines 50-51 without advancing any watermark. Starting with current A@100, processing A@300 leaves the comparison timestamp at 100; a delayed B@200 then passes the timestamp check, closes A at 200, and becomes current even though A was observed at 300. Store a separate latest-observation timestamp and advance it for same-hash observations, then reject every incoming snapshot at or below that watermark.
P2 extension/worker/src/__tests__/ingest.test.ts:189 tests serialization implemented by the mock instead of the SQL function. The mock itself applies the monotonic timestamp rule, so the assertion cannot validate the advisory lock, transaction, or database behavior and conflicts with the project rule against tests of mocked behavior. Exercise concurrent calls against real PostgreSQL/Supabase, or narrow this unit test to request/RPC plumbing without claiming it verifies serialization.
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
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.
Summary
Root cause
The history write ran after the event upsert but queried only the current metadata hash. A delayed retry with different metadata could close a newer row at an older timestamp and replace it as current.
Validation
bun run testinextension/worker(45 tests)