Repository navigation
fix(channels): revalidate lane policy before claiming ingress - #159197
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: needs maintainer review before merge. Reviewed September 26, 2026, 10:15 PM ET / September 27, 2026, 02:15 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch rechecks channel lane policy before queued messages become durable SQLite claims, adds worker-backed regressions, and prevents Gateway fixture reseeding from clearing active session write queues. Merge readiness✅ Ready for maintainer review Current main still has the reported stale-policy claim window. The branch has credible worker-backed proof, current-head CI passed, and this review found no actionable patch defect. Priority: P2 Review scores
Verification
How this fits togetherChannel plugins put inbound events in a durable queue. The Gateway selects a lane, asks a SQLite worker to claim an event, then dispatches the claim; a separate Gateway test fixture seeds session rows through their writer queue. flowchart LR
A[Inbound channel event] --> B[Durable queue]
B --> C[Lane selection]
C --> D[Worker admission]
D --> E[Live policy check]
E --> F[Durable claim]
F --> G[Channel dispatch]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +38, Tests +225, Docs +2. Total +265 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Preserve live lane-policy checks within the existing worker admission path, with FIFO and uncertain-write custody intact, and keep fixture queue clearing confined to quiescent setup and teardown. Do we have a high-confidence way to reproduce the issue? Yes. The current-main source retains the preclaim policy gap, and the PR reports failing native-stage controls on that baseline; this read-only review did not execute them. Is this the best way to solve the issue? Yes. Rechecking the channel-owned lane decision at the existing worker admission boundary is a narrow repair that leaves row freshness and claim settlement with their current owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 247258e3140e. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
Merged via squash.
|
…aw#159197) * fix(channels): revalidate lane policy before claiming ingress * test(channels): retain claim worker termination directly * test(gateway): preserve queued writes while reseeding fixtures
What Problem This Solves
Fixes queued messages being claimed under stale channel lane policy when that policy changes while a claim waits for its SQLite transaction or commit.
User Impact
Queued messages respect current lane eligibility before becoming durable claims. Existing installations need no schema migration, configuration change, or operator action; retention and SDK contracts stay unchanged.
Why This Change Was Made
The existing native admission owner rechecks the selector's ordered lane observations at transaction and commit. Native row fingerprinting still protects FIFO and database freshness, and callbacks receive freshly decoded inputs. Only a policy refusal with confirmed native rollback may prepare another claim; callback failures, retired authority, and uncertain native outcomes remain terminal.
Evidence
19c6ef8d9e02claimed the stale first row after policy changes at both native admission stages. Callback failure and owner-retirement controls also incorrectly committed. The candidate passes all 80 distinct tests across the claim, queue/FIFO, drain-lane, admission-receipt, and cleanup owners.pnpm test src/channels/message/ingress-queue.claim-ownership.test.ts --maxWorkers=1: 12 passed, 36.912 s wall, including 18.664 s worker preparation; Vitest 13.43 s. The five new cases cost 792 ms (transaction), 622 ms (commit), 631 ms (callback failure), 638 ms (owner retirement), and 1,238 ms (lost native rollback reply), 3.921 s combined. The lost-reply case intercepts the actual private lifecycle reply, joins the executing worker, and verifies no claim replay.A synthetic 100-row queue with 56-KiB payloads measured 10.170 ms median main-thread CPU using
process.threadCpuUsageover five claims after warmup. Retaining ordered observations avoided the 18.570 ms median of the initial full-rescan implementation while preserving both live policy checks. These were separate runs on a shared host; they do not establish a production latency gain. The temporary benchmark is outside the committed tests.The prior hosted run failed in the existing
server.private-completion.test.tsprovider-failure case: a 120-second test timeout followed by 180-second cleanup timeouts. An unchanged replay of its Gateway group passed, but restoring the preceding packed groups reproduced the hang on Node 24.19.0; all 228 infra and 214 cron tests passed before the provider-failure case timed out at 300.336 s. The bounded run joined every owned descendant.The shared Gateway fixture reseeding helper also cleared writer queues while accepted writes were still running. This change removes those two live clears and extends the existing connected-Gateway table with a reseed case. Its negative control rejects the second accepted write with
SQLite session store queue cleared for test; the repaired 14-case suite passes (60.218 s wrapper, new case 1.000 s). Quiescent startup and teardown clears remain.With the exact fixture repair and no phase instrumentation, the original three-group sequence now passes 50 files / 534 tests in 239.185 s, including the provider-failure case in 1.175 s. Source and dependency identities stayed fixed and all descendants joined. This strengthens the evidence but does not by itself establish the intermittent timeout's exact cause. Fresh P0–P2 repair review is clean; the owning Gateway type graph, exact-file lint, formatting, and diff checks pass on this combined candidate. Current-head hosted CI passed (131 successful / 20 skipped, no failed jobs). All 21 private-completion cases passed; the previously timing-out provider-failure case took 674 ms. The new reseed case's separate hosted timing was not available from the retained job output.
Full-file fixture wall comparison on Node 24.19.0, using the supported
node scripts/run-vitest.mjs src/gateway/test-helpers.server-rpc.test.ts --maxWorkers=1entry point: the original 13-case file passed in 113.096 s supervised wall (104.35 s Vitest); the repaired 14-case file passed in 60.218 s supervised wall (56.55 s Vitest), including the new 1.000 s case. Each used isolated compiler caches. These single-run timings document test cost, not a performance percentage; source restoration, dependency identity, and all descendant joins were verified.