feat(response): reload persisted snapshots after restart - #151
Draft
cursor[bot] wants to merge 4 commits into
Draft
feat(response): reload persisted snapshots after restart#151cursor[bot] wants to merge 4 commits into
cursor[bot] wants to merge 4 commits into
Conversation
A completed two-item prefix must rebuild the same ResponseSnapshot that ScoringRequest::from_snapshot already accepts, keeping server order even when a later event identity sorts first. Stored sequence lies, blank identities, and noncanonical digests fail closed. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Reconstruct the unique completed prefix from response_snapshot and response_snapshot_entry under READ COMMITTED. Server snapshot_sequence order is preserved so a later event identity cannot hide the first answer, and ScoringRequest::from_snapshot still accepts the reload. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Contributor
Author
There was a problem hiding this comment.
Review — PR #151 d63f023 (response-snapshot reload)
This slice does what a buyer needs after a completed two-item path and a process restart: reconstruct the unique frozen prefix and keep it acceptable to ScoringRequest::from_snapshot.
What holds
ResponseSnapshot::from_persistedrebuilds the same valuefreeze_asproduced, including server order when a later event identity would sort first.load_response_snapshot/load_response_snapshot_for_sessiontakeFOR SHAREon the header, requireREAD COMMITTED, and order entries bysnapshot_sequence ASC.- Missing snapshot is absent. Header/entry count mismatch, gapped sequences, noncanonical stored digests, blank/numeric aliases, stronger isolation, and missing relations fail closed.
- Physical objects are unchanged (
response_snapshot/response_snapshot_entryalready on protected main). No HTTP scoring, no invented scores, no historical rewrite.
Residuals (not merge blockers for this slice)
- Domain reconstruction does not re-check unique
event_ref; the table already hasUNIQUE (snapshot_ref, event_ref). - A persisted scoring request still cannot be reloaded after restart. That is a later worker-pin slice, not this snapshot freeze.
- Independent last-push review and exact-head required checks remain the merge gate. Do not self-approve.
Do not fold into this head
Keep consent reload on #140, result reload on #137/#119, session HTTP on #149, and response-event persist on #53. Do not start scoring HTTP here.
Sent by Cursor Automation: Fix Issues
This was referenced Aug 16, 2026
This was referenced Aug 16, 2026
Protected-main #81 requires claim_deadline_at on processing integration_consumption rows. Recovery fixtures that omit the column fail constraint integration_consumption_claim_deadline_shape.
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.


Why
Protected main can persist one immutable completed response prefix per session, but it cannot reconstruct that prefix after process restart. Scoring dispatch after a crash would have no durable snapshot to pin, so a buyer who finished a two-item path would not get a score.
This is independent of Active PR #140 (consent-ledger reload), #137/#119 (result reload), and #149 (session HTTP). Do not fold those slices into this head.
What
ResponseSnapshot::from_persistedrebuilds the same freeze thatScoringRequest::from_snapshotalready accepts.load_response_snapshotandload_response_snapshot_for_sessionreconstruct the unique prefix fromresponse_snapshot/response_snapshot_entryunderREAD COMMITTEDafterFOR SHAREon the header.snapshot_sequence ASC, so a later event identity cannot hide the first answer.This does not change response bodies, invent scores, add HTTP transport, or mutate historical snapshots.
Verification
cargo test --test response_snapshot_persisted --test response_ledgercargo test --lib postgres_response_snapshotcargo test --test postgres_response_snapshot_reload --test postgres_response_snapshot_error_contractcargo clippy --all-targets -- -D warningsNext after this lands: keep session HTTP on #149 and result reload on #137. Do not start scoring HTTP on this branch.
Independent non-author approval and required checks on the unchanged exact head remain merge gates. Never self-approve.