fix(server): gate the shutdown test on the boundary frame, not frame one - #21
Merged
mattwilkinsonn merged 5 commits intoJul 29, 2026
Merged
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
seal-agent
marked this pull request as ready for review
July 28, 2026 07:08
Greptile SummaryThe PR corrects and hardens the live-subscriber shutdown regression test.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| go/server/serve_pgtest_test.go | The updated test now follows the documented boundary-first stream protocol, reliably reaches the shutdown-drain assertion, and bounds cleanup waits. |
Reviews (5): Last reviewed commit: "test(server): trim review-thread archaeo..." | Re-trigger Greptile
TestServeShutdownWithLiveCommsSubscriberReturnsClean opens SubscribeComms(SinceSeq: 0) and read the FIRST frame as its seeded ChannelChanged. A since_seq=0 subscribe receives commsSnapshotBoundary before any event, so the gate was asserting on a control frame and reading its absent payload as an empty channel id. The test predates the boundary frame. It has been failing on main since that frame was added, and failing at the gate means it never reached the drain assertion it exists for - so the regression it names, that Serve must close commsBus or a live SubscribeComms handler wedges the drain, has been undefended while the test looked like it was doing its job. Consume the boundary and assert it IS the boundary rather than skipping one frame blindly: a bare skip re-breaks silently the next time the preamble grows. The frame is identifiable by construction - seq 0 with no payload, where the terminal resync is seq 0 WITH a CommsResyncRequired. Verified by two mutations. Removing commsBus.Close() from Serve's drain now reddens at the drain assertion (line 247, "want nil (drain must close commsBus)") - previously it died at the gate on line 213 and never got there. Dropping the boundary consume reproduces the original failure exactly, empty channel id and all. Closes SEA-1530 Co-Authored-By: seal <noreply@sealedsecurity.com>
Round-1 review found two self-referential defects in the comments the fix added, both against the standard those comments state. The header closed with "that is what the drain mutation below is checked against" - and there is no drain mutation below. The mutation was a transient check run by hand; nothing in the tree encodes it. A comment whose subject is that a red test must fail at the assertion it exists for ended by pointing the next maintainer at a check that does not exist to be found. It now states the verification as a reproducible recipe rather than a reference to something absent. The first Receive's error named a missing snapshot boundary, but all that branch observes is a stream that ended before any frame. The handler already has a clean early return on that path, so a future change there would be reported as a boundary defect. The message now describes the observable and leaves the cause to the reader. Also drops a paragraph restating commsSnapshotBoundary's own doc comment one file away, and switches three ASCII prose hyphens to the em-dash the rest of the package uses. Re-verified after the edits rather than relying on the earlier run: the line numbers moved, so the old proof no longer certified this code. Deleting the drain's commsBus.Close() still reddens at the drain assertion, now line 254. Full lane: skips 0, PASS 64, races 0. Refs SEA-1530 Co-Authored-By: seal <noreply@sealedsecurity.com>
…aths Every t.Fatalf ahead of the happy-path cancel() left Serve running against a live socket and pg pool for the rest of the binary. Adopted from the parallel sealed fix for the same test after comparing both: that lane caught a leak this one did not. Mutation-verified rather than inspected: deleting the drain's commsBus.Close() reds ONLY TestServeShutdownWithLiveCommsSubscriberReturnsClean, at the Serve-returns-nil assertion (line 261), while TestServeShutdownIsClean stays green. Full server + comms pgtest suites pass twice consecutively after restoring the mutated file. Refs SEA-1530, SEA-1423
seal-agent
force-pushed
the
compass-comms-sea-1530-subscribe-boundary-gate
branch
from
July 29, 2026 00:39
26d8caa to
525d024
Compare
seal-agent
changed the base branch from
compass-comms-sea-1355-agent-comms-tools
to
main
July 29, 2026 00:39
…final wait The comment justifying the boundary assertion claimed a bare skip re-breaks silently as the preamble grows. A reviewer ran both variants and falsified it: the seeded-event assertion is a hard backstop, so a skip is caught either way. Replace the claim with the measured 2x2 - the gain is attribution and 13s, not catch-vs-miss. Bound the final <-done on testTimeout, per helpers_test.go convention, so a tail loop that never ends fails by name instead of hanging to the package timeout. Proven live by mutation. Trim cross-repo provenance from the defer cancel() comment; it is unresolvable from inside this repo. Co-Authored-By: seal <noreply@sealedsecurity.com>
…omment Keep the durable boundary-vs-skip rationale and the measured attribution table; drop the self-referential note about a prior comment revision, which is PR-thread history rather than test explanation. Co-Authored-By: seal <noreply@sealedsecurity.com>
mattwilkinsonn
deleted the
compass-comms-sea-1530-subscribe-boundary-gate
branch
July 29, 2026 16:50
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.

Fixes SEA-1530.
TestServeShutdownWithLiveCommsSubscriberReturnsCleanhas been failing on cleanmain, and — the part that matters more than the red — it was failing before it reached the assertion it exists for.Retargeted onto
main(was stacked on #15). The stack was historical, not a dependency — verified rather than assumed:#15 is 8 TypeScript/harness files; this is one Go server test file. #15 carries a deliberately-open P1 that waits on another lane's entrypoint, and this fix is one of the two reds blocking #19's
pgtestjob — so gating a CI fix behind an unrelated open finding bought nothing.The bug
The test opens
SubscribeComms(SinceSeq: 0)and reads the first frame as its seededChannelChanged. Asince_seq=0subscribe receivescommsSnapshotBoundarybefore any event (go/internal/comms/subscribe.go:226), so the gate was asserting on a control frame and reading its absent payload as an empty channel id.I probed the frame rather than inferring it:
payload = <nil>, seq = 0is the boundary frame exactly.Why this is worse than a red
The test's subject is the shutdown drain:
connect'shttp.Server.Shutdowndoes not cancel an in-flight streaming handler's context, so the only thing that releases a liveSubscribeCommshandler isServeclosing the comms bus. The gate failure meant that assertion was never reached — so the regression the test names has been undefended for as long as the test has been red, while looking like it was doing its job.Its header comment claimed "either way the pre-fix drain is caught." That was false the whole time. The comment now records why, because the lesson generalizes:
The fix
Consume the boundary frame and assert it is the boundary, rather than skipping one frame blindly. The frame is identifiable by construction (
subscribe.go:218-225):seq 0with no payload, where the terminal resync is alsoseq 0but carries aCommsResyncRequired.Verification
Re-run in full after the rebase onto
main. The rebase minted new shas (3e054b2→525d024; the review round then minted4cc8b17, whose diff is comment-and-test-wait only, re-verified below), so every earlier measurement was bound to a tree that no longer exists — a green does not travel with a restack.Two mutations, because a test that goes green after a fix has proven nothing about whether it can still fail.
The
onlyis the load-bearing part: a mutation that reddens several tests proves coverage exists somewhere, not that this test works.The reviewer added two more the fix had not been proven against — a payload on
commsSnapshotBoundarywithseq = 0(fails on the payload clause alone, soGetPayload() != nilis live), and removing the boundarySendentirely (fails at:248in 11.8s naming the frame).The review falsified a claim this body made
An earlier version of both this section and the code comment claimed a bare skip "re-breaks silently" as the preamble grows. It does not. The reviewer ran both variants against both mutations and measured:
The seeded-event assertion below is a hard backstop either way: no control frame can satisfy
GetChannelChanged().GetChannel().GetId() == wantChannelID. So the assertion's gain is attribution and 13s, not catch-vs-miss — worth keeping, but not for the reason claimed. The claim was the justification for the change and was never measured, which is the same defect this PR exists to fix, reproduced in the prose arguing the fix. Corrected in4cc8b17; the comment now carries the table above instead.serve.gowas restored after each mutation and re-verified green — the cleanup step is itself a write to the artifact under test.Run at the scope #19's pipeline uses
#19's
pgtestjob isgo test -tags pgtest -race ./...; itsgatejob is repo-widemoon run :ci. Run at both packages rather than./server/alone, because the fix's subject is a comms-bus interaction and a green scoped to one package is not a green for the job.The two tests this PR turns on:
skips: 0and thePASScount are #19's own assertions (ci.yml:221), not mine —go testprintsokfor a fully-skipped tagged suite, sookalone is a vacuous green.Correction: the SEA-1541 red was MY ENVIRONMENT, not this PR and not a defect
Earlier revisions of this body reported a
waitListeningfailure and attributed it to cross-package Postgres contention. Both the failure and the attribution were artifacts of a broken DSN on my side. Recording it rather than deleting it, since the wrong numbers were published:Sourcing that parses
DSN=…pgcs-32431as a background job andsslmode=disableas a separate assignment, soDSNwas never set. Every run passed an emptyCOMPASS_TEST_DATABASE_DSN,pgtest.RequireDSNtook the no-DSN branch, and each test spawned its own podman Postgres.dsn len 72was in my own log output from the first probe and distinguishes the two paths in one line. The9.07scontainer spawn is the entire "fixed interval" I had described as the key insight — it isstartContainer's cost, not a schema cost and not contention.Every measurement in this section's earlier form is withdrawn: the 25.4-25.7s cluster, the contention mechanism, and a proposed
RequireDSNhoist that "fixed" a 10.9s self-inflicted delay. SEA-1541 carries the full retraction.The check that would have caught it before the first measurement:
[ -n "$DSN" ] || exit 1. A DSN contains&and?, so it is unsafe as an unquoted shell value, and the failure is silent — no error, an empty variable, and a suite that transparently falls back to a slower path which still mostly passes.Also in this branch: a Serve leak on every failure path
defer cancel()added to the shutdown test. Everyt.Fatalfahead of the happy-pathcancel()leftServerunning against a live socket and pg pool for the remainder of the binary. Adopted from the parallel sealed fix (sealed#973) after comparing both — that lane caught a leak this one had, and mine was the smaller diff without being the better one. That provenance lived in the code comment until the review;sealed#973is unresolvable from inside this repo, so it belongs here.Also in this branch: the final wait is now bounded
<-donewas the only unguarded blocking wait in the test, againsthelpers_test.go:23-27's convention thattestTimeoutbounds every stream wait so a broken handler fails fast. Unreachable today —Servereturning nil implies the drain rancommsBus.Close()— but it converts a future hang-to-package-timeout into a named failure, which is this PR's own defect class. Proven live rather than assumed:Re-verified at
4cc8b17No failures. An earlier revision reported one here; see the correction above — it was a podman-path artifact of an unset DSN, and with a real DSN the same two packages complete in 12.5s.
This repo has no CI today.
git ls-tree origin/main .github/workflows/is empty and #19 is still OPEN, so the above islocally-verified, neverCI-verified. The distinction is the point: it is evidence I produced about my own work, and #19's ownpgtestjob is the thing that would make it independent.Closes SEA-1530