refactor(compass): drop the unauthorized Store.UpdateMessageBlocks - #30
Conversation
|
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. |
Greptile SummaryThis PR removes the unused exported message-block update wrapper while retaining the existing internal transactional update helper.
Confidence Score: 3/5The message-update refactor appears sound, but the PR should not merge while the previously reported orphaned-container failure remains and the other prior blockers are unresolved. ProvisionAgentWorkspace still returns after durable mapping failure without rolling back the workspace already created on the Runner; the current evidence also does not establish that the prior runner-scoping and migration findings have been fixed or invalidated. Files Needing Attention: go/server/service.go, go/internal/store/agent_placements.go, go/internal/store/migrations/0004_agent_placement.sql
|
| Filename | Overview |
|---|---|
| go/internal/store/messages.go | Removes an unreferenced exported wrapper while leaving the internal update implementation and AnswerAsk path unchanged. |
| go/internal/store/messages_test.go | Repoints the existing block-update behavior tests to the unexported helper without changing their assertions. |
| apps/ui/src/live/comms-state.ts | Rewords a comment to avoid naming the removed Store method; runtime behavior is unchanged. |
Reviews (4): Last reviewed commit: "docs(store): decouple the boundary comme..." | Re-trigger Greptile
644f1a7 to
03697e4
Compare
|
Force-pushed a correction: the first push of this branch contained 37 files / +3699/-329 instead of this PR's 3 files / +30/-33. Cause was mine and mechanical, not a content change — I ported the five branches in a loop that applied each patch and committed with Caught by diffing each ported branch against its sealed-original patch and comparing normalized hunks: four matched byte-for-byte, this one didn't. Rebuilt from a verified-clean Re-verified on the corrected branch: Note the integration transcript in my earlier comment was run on the merged tree of all five, so its result stands — but it could not have caught this, because a union-of-all-five commit merges into that same tree cleanly. Only the per-branch fidelity check found it. |
Reconciling the three open Greptile P1 threads — all obsoleteGreptile posted three P1 review comments against commit
None applies to this PR. This PR's diff is exactly three files — The cited concerns are real for the PRs that actually own those files (agent_placements / the 0004 migration / the placement rollback are #33's territory, where they were reviewed on their own merits), but they are not this refactor's. Resolving the three threads as obsolete. This PR's own review (mandatory |
Store.UpdateMessageBlocks was an exported message write with no membership and no authorship check, and zero production callers. AnswerAsk does not use it -- it calls the unexported updateMessageBlocksExec directly against its transaction. So it was a test-only exported method with no authorization sitting beside authorizing writes: the unauthorized one is shorter to call and passes every test, so the next person reaching for "update a message's blocks" finds it first and it works. A doc comment is not a guard. Its three tests now call updateMessageBlocksExec directly, preserving every assertion. updateMessageBlocksExec and AnswerAsk are byte-identical. Found by the comms lane. Co-Authored-By: seal <noreply@sealedsecurity.com>
Review found the ListMessages snapshot-boundary comment naming AnswerAsk as *the* in-place blocks writer. Accurate on this branch alone, but it silently under-enumerates the moment the sibling write-through branch lands a second in-place writer -- and because the two edits sit in different hunks, git will never flag it. Says "a blocks update" instead, which is merge-order-independent. Same decoupling this PR already applies to the TS comment. Also drops "or any other execer" from updateMessageBlocksExec's doc: after this PR the only non-test caller is AnswerAsk's transaction, and the clause softly re-advertised the unauthorized affordance the paragraph below it exists to discourage. Co-Authored-By: seal <noreply@sealedsecurity.com>
9259aef to
9180562
Compare

Deletes
Store.UpdateMessageBlocks— an exported message write with no membership check and no authorship check, and zero production callers.Why it had to go rather than be documented
The method took a bare
MessageIDand rewrote that message's block set. No check that the caller is a member of the channel, no check that they authored the message. Its only references were its own definition and three tests.AnswerAskdoes not use it — it calls the unexportedupdateMessageBlocksExecdirectly against its transaction (messages.go:368), where the row has already been resolved through a membership JOIN and lockedFOR UPDATE.So it was a test-only exported method with no authorization, sitting beside authorizing writes. That is the trap worth removing: the unauthorized one is shorter to call and passes every test, so the next person reaching for "update a message's blocks" finds it first and it works. A doc comment saying "do not call this on a path fed by external input" is not a guard — and prose mistaken for a guard is the failure this codebase has hit repeatedly.
Deleting it is cheap precisely because nothing calls it. There is no migration and no caller to update; the exported surface simply loses a method that should never have been exported.
What changed
The wrapper is gone. Its three tests now call
updateMessageBlocksExecdirectly (same package), preserving every assertion:TestUpdateMessageBlocksReplaces— block set is replaced, verified throughListMessages.TestUpdateMessageBlocksRejectsEmptyAskID—ErrInvalidArgument, the rejected update does not persist, and a non-empty ask id still round-trips.TestUpdateMessageBlocksUnknownNotFound—ErrNotFoundfor an unknown id.The wrapper's substantive documentation (empty-set and unknown-message rejection, the ask-id immutability rationale) moved onto
updateMessageBlocksExecrather than being deleted with it, plus a line stating it performs no membership or authorship check and is therefore deliberately unexported. Three stale comments that named the removed method as a live mutator were corrected.The test function names are unchanged: they name the behavior under test — updating message blocks — which still exists. Renaming them would say something false about what disappeared.
updateMessageBlocksExecandAnswerAskare byte-identical tomain, verified by extracting each function body from both refs and comparing checksums, not by reading the diff. The only non-comment change inmessages.gois the three deleted wrapper lines.Verification
go build,go vet(including-tags "pgtest unix", since an untagged vet would not analyze the changed test file at all),gofmt -lempty,-racesuite green, andgolangci-lintwith the same build tags reporting zero findings in hand-written code.Real-Postgres pgtest run with
-vagainst a live DSN: the three repointed tests PASS, and the fullinternal/storepackage shows 96 literal--- PASSlines with zero SKIP. That last part matters here —pgtest.RequireDSNskips rather than fails when no container runtime is available, so a bareokcan mean the entire suite silently skipped. These were confirmed executing.Credit
Found by the comms lane, which spotted that the exported wrapper had no callers while I was adding an authorizing variant beside it. Matt ruled the deletion.
Spec-impact: none
Removes an unexported-in-effect internal method with no callers; no externally-visible behavior changes.
Targets
mainfor review; lands insealedsecurity/compassafter the port.Ported from
sealedsecurity/sealed#1000, 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.