fix(compass): SEA-1423 assert the snapshot-boundary frame before the seeded event - #29
fix(compass): SEA-1423 assert the snapshot-boundary frame before the seeded event#29seal-agent wants to merge 1 commit into
Conversation
…seeded event TestServeShutdownWithLiveCommsSubscriberReturnsClean has failed against a live Postgres since the since_seq=0 snapshot boundary was ratified, and it was recorded as a suspected shutdown-drain defect. It was never one. The test read frame 1 as the seeded ChannelChanged. Frame 1 is the snapshot boundary, sent unconditionally ahead of any event on since_seq=0, so the id compare saw "" and the gate fataled. The drain half of the claim was never in question -- which matters, because anyone acting on the recorded diagnosis would have hunted a bug that does not exist. The fix asserts the boundary rather than skipping it: a bare Recv() discarding frame 1 would also go green against a server that stopped sending the boundary entirely. It is checked on two real discriminators (nil payload, seq == 0) plus two weaker checks labelled in the code as *not* discriminators so a later reader does not overtrust them. Every drain assertion is byte-for-byte unchanged, so a genuine ordering defect still reddens the test. Co-Authored-By: seal <noreply@sealedsecurity.com>
Greptile SummaryUpdates the live-Postgres shutdown regression test to:
Confidence Score: 5/5The PR appears safe to merge. The change is confined to test assertions and cleanup, correctly accounting for the unconditional snapshot boundary while retaining the seeded-event and clean-shutdown checks.
|
| Filename | Overview |
|---|---|
| go/server/serve_pgtest_test.go | The revised test matches the stream’s boundary-first contract and preserves the existing shutdown-drain assertions without introducing an actionable defect. |
Reviews (1): Last reviewed commit: "fix(compass): SEA-1423 assert the snapsh..." | Re-trigger Greptile
|
Cross-branch integration verified locally. This repo has no CI yet, so this is the only integration evidence there is — and it is the check that caught a real defect in the sealed copies of these same diffs (a deleted symbol still cited by a sibling branch, invisible to any single-diff review). Merged all five of this lane's branches together onto All five merge clean, no conflicts. On the combined tree, against a live Worth stating plainly: A per-package throwaway Postgres container also starves under this suite's parallelism (the store package hit its 600s timeout four times over); one shared database runs the same suite in ~30s. Relevant when CI is set up here. |
|
Closing as a duplicate of #21, which is the better fix and got here first. I ported this from sealed#973 without checking for an existing compass PR on the same test — my mistake. #21 covers the same single file and the same
Deleting the branch. SEA-1423 is already closed as a duplicate of SEA-1530, which tracks #21 — so no tracker change needed either. |
TestServeShutdownWithLiveCommsSubscriberReturnsCleanhas failed against a live Postgres since #825 ratified thesince_seq=0snapshot boundary. It is the known blocker recorded in the Compass test-strategy record (#740), gating that lane to reporting-only.It was never a shutdown-ordering defect
The test read frame 1 as the seeded
ChannelChanged. Frame 1 is the snapshot boundary, sent unconditionally ahead of any event onsince_seq=0(subscribe.go:72-80), so the id compare saw""and the gate fataled. The observed failure is exactly that:The old test encoded a two-part claim: the wire starts with the seeded event and shutdown drains clean. #825 falsified the first. The second was never in question — which matters, because the record previously carried this as a suspected drain defect, and anyone acting on that would have hunted a bug that does not exist.
The fix asserts the boundary rather than skipping it
Read frame 1, assert it, then gate on the event. A bare
Recv()discarding frame 1 would also go green against a server that stopped sending the boundary entirely — the regression #825 pinned. So the frame is checked for:Two discriminators, both documented as such by the frame's own contract (
subscribe.go:220-224— "discriminates it from a positioned event by its zero seq and absent payload"):seq == 0— the boundary is a control frame atcommsResyncSeq, never positioned in bus-seq space, where a real event carries the seq stamped at publish (events.go:169-172, off anextSeqthat starts at 1 —events.go:155— so no event is ever seq 0).Two weaker checks, labelled in the code as not discriminators so a later reader does not overtrust them:
instance_epoch, checked twice — on the boundary alone it can only be a field-stamping check (!= 0), since every event carries the epoch too (subscribe.go:201); what it catches is a boundary built with a literal0instead ofsub.Epoch. Against the seeded event it becomes an equality check: both frames come from oneBusand carry one per-boot nonce (events.go:174,:242,:288), so a boundary stamped from any other source reddens — which the!= 0form passes silently.snapshot_seq == 0— a no-drift check on the empty-store head, explicitly not a presence check. See below.Every drain assertion is byte-for-byte unchanged, so a genuine ordering defect still reddens the test. This is strictly more coverage than before: the boundary contract now has a serve-level assertion it did not have.
One deviation from the ruled shape, forced by the code
The ruling asked to assert
GetSnapshotSeq()/GetInstanceEpoch()are set.snapshot_seqisCOALESCE(MAX(seq), 0)overmessages(messages.go:134-142), and this fixture seeds a channel, never a message — so0is the correct head, and asserting it nonzero would red-bar on a value the fixture cannot produce.Asserted
== 0instead, and the code says plainly what that is and is not: the getter returns0for an unset field and the true head is also0, so a server that dropped theSnapshotSeqassignment entirely would still pass. This is a no-drift check, not presence. Presence is pinned where it can be —subscribe_test.go:243-244, against a populated store. Seeding a message here to force a nonzero head would publish aMessagePostedonto the bus and reorder frame 2, complicating the registration gate this test exists for.Verification
Against a live
postgresql-17.10:main)ok ./server 3.743sframe 1 carries payload *SubscribeCommsResponse_ChannelChanged, want the payload-less snapshot boundarySeq: 42snapshot boundary seq = 42, want 0 (control frame, not positioned)0notsub.Epochsnapshot boundary instance_epoch = 0, want the per-boot nonceinstanceEpoch + 1— nonzero but wrongseeded event instance_epoch = …, want the boundary's …(only the cross-frame equality catches this)Each mutation reddens with its own message, so the assertions are independently load-bearing rather than one check carrying the rest. The first is what makes this added coverage rather than a swallowed frame; the second catches a defect class the old test could not see at all.
Refs SEA-1423
Spec-impact: none — the boundary frame's shape and ordering are already ratified (SEA-1333 OQ4) and already what
subscribe.go:72-80does; this PR pins that behavior in a test rather than changing it. No observable behavior moves.Ported from
sealedsecurity/sealed#973, unchanged in content — Compass code now lives here, so this is where it ships. The sealed PR is closed in favour of this one.Verification (this repo has no CI yet, so a local run is the only evidence there is):
go build ./...,go vet -tags "pgtest unix" ./...,gofmt -lclean,go test -race ./internal/... ./server/..., and thepgtestsuites for./internal/store/,./internal/comms/,./server/against a livepostgres:17— all green on this branch.