Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 29, 2026, 6:01 AM ET / 10:01 UTC. ClawSweeper reviewWhat this changesThe branch limits uncertain session category-write invalidation to the sessions selected during worker preparation and adds regression coverage for an unrelated in-flight read. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 2 items remain Current main still uses the store-wide uncertain-write fence reported in the linked issue. This PR has a coherent, narrowly scoped fix, and the prepared keys match the worker transaction’s possible write set. No blocking correctness defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway keeps session rows ready for list and detail requests while a SQLite worker owns category writes. After an uncertain write result, change notifications tell the Gateway which cached rows need a fresh worker read. flowchart LR
A[Category update request] --> B[Prepare session keys]
B --> C[SQLite worker write]
C --> D{Result certain?}
D -->|Yes| E[Publish category facts]
D -->|No| F[Fence prepared sessions]
F --> G[Refresh affected rows]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +113. Total +134 across 4 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the worker’s prepared plan as the single source of affected keys, reconcile only those rows after an uncertain result, and retain the current no-replay behavior. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence from source and the supplied regression: current main broadcasts a store-wide fence, and the controlled lost-acknowledgement case observes a second read of an unrelated session. I did not execute it in this read-only review. Is this the best way to solve the issue? Yes. The worker applies exactly its prepared category rows, so using those keys for uncertain-result reconciliation is a narrow repair that preserves the existing no-replay path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0c8e56cf9859. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
CI failure attribution on head |
|
Thanks @miorbnli for investigating this and adding the focused regression. This is already fixed on main by #160656 (dad8de7). I verified that commit is an ancestor of main at 2b0a8fe and checked the current path: category.prepare supplies publicationKeys, category.apply writes only those prepared keys, and unresolved settlement emits per-key invalidations through retainSessionEntryWorkerPublication. A surviving native commit receipt now also settles the write after ordinary reply loss. The existing worker-read regression checks that the unrelated session is read once, the changed category is current, and the mutation is not replayed. No additional change remains to lift from this PR. Closing as already fixed; thank you! |
Closes #160609
What Problem This Solves
When a committed session group-category write loses its worker acknowledgement (uncertain outcome), the uncertain-outcome fence invalidated every session row in the physical store (
{ all: true, scope: { storePath }, factsInvalidated: true }). A concurrent, unrelated session's in-flight exact-read reply was discarded and re-read from the worker — redundant work on every lost category ack, exactly as reported in #160609. The category transaction can only change the rows the prepare step selected (applySessionGroupCategoryMutationre-validates and rewrites exactly the prepared rows), so the store-wide fence over-covers by construction.Why This Change Was Made
The fence's authority and no-replay guarantees (#155620) are preserved; only its breadth is narrowed to the mutation's real blast radius:
runSessionCollaborationWrite'spreparehook may now return the affected session keys.updateSessionGroupCategoriesInWorkerreturns its preparedkeys(already captured in its closure).category.applynow emits one per-key{ sessionKey, storePath, factsInvalidated: true }event for the prepared rows, plusdiscardCommittedSessionEntryCacheexactly as before (the settled-worker cache cannot publish a trustworthy field patch). An empty prepared plan emits nothing (nothing was written); a prepare that never ran keeps the old conservative store-wide fence, because the write scope is then unknown.The uncertainty semantics are unchanged: the affected keys stay fenced (their cached facts are dropped and their in-flight reads still reconcile through the projection's read worker), and no write is replayed.
User Impact
Gateway hosts that lose a category-update acknowledgement (worker restart, transport hiccup at the settled boundary) no longer invalidate the in-flight reads of every unrelated session in the same store; only the sessions the write could have touched re-read. Reported frequency is unestablished (see the issue), but the fix removes an entire class of redundant worker reads on shared stores.
Evidence
Red-green regression (new case in
src/gateway/session-row-projection.worker-read.test.ts, instrumented worker replies counting every read, holding only the first):expected [ …(2) ] to have a length of 1 but got 2).Runtime probe (same instrumented commit-then-lose-the-reply scenario, verbatim):
Sibling suites:
session-sharing-store.worker.test.ts13/13 (itscategorycase's pinned store-wide expectation updated to the per-key event — same keys, samefactsInvalidated, same cache discard),session-membership-projection.test.ts+session-sharing-preparation.test.ts33/33.Gates:
pnpm tsgoexit 0,pnpm tsgo:testexit 0,run-oxlint0/0 on changed files,oxfmtclean, line-cap and assertion-safety ratchets OK againstupstream/main(54b1b1b),git diff --checkclean. Node v26.5.0 on Linux x64.Not tested: a live lost-acknowledgement produced by a real worker crash rather than the injected
outcome-unknownat the settled boundary (the issue's own fixture uses the same injection); production occurrence frequency. The membership projection's per-key invalidation path (store.facts.delete+dirty.add) is covered by its existing suite, not by a new dedicated test here.Authored with AI assistance (ZCode agent session); the investigation, fix, tests, and evidence above were produced and verified in that session per the current contribution rules.