Repository navigation
perf(gateway): avoid display-row waits in message subscriptions - #162013
Conversation
Authorize message observers from committed sharing and membership facts while retaining incognito preparation, session authority, and approval replay guards. Attribute slow subscriptions from router entry through observer commit with bounded phase timings.
|
🦞👀 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 30, 2026, 3:15 PM ET / 19:15 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch lets Gateway message subscriptions authorize from committed session facts while display rows refresh, adds slow-request timing and regression coverage, and adjusts Windows updater recovery after interruption. Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open. Current main still waits for display-row preparation during message subscriptions, and the merged related work addresses different bottlenecks. The remaining review gap is native Windows evidence for the added cancellation-recovery catch. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway authorizes a client's session subscription before registering an observer for live messages. Separately, the updater temporarily changes Windows Scheduled Task autostart and must restore it when an update is interrupted. flowchart LR
A[Client subscription] --> B[Gateway authorization]
B --> C[Committed session facts]
C --> D[Observer registration]
D --> E[Live messages]
F[Update interruption] --> G[Updater recovery]
G --> H[Windows task autostart]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +121, Tests +351, Docs +16. Total +488 across 16 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Subscriptions should acknowledge from current committed access facts with final observer authority checks; interrupted Windows updates should restore only the original task and settle cancellation under the retained executor. Do we have a high-confidence way to reproduce the issue? Yes, current-main source shows the display-row await and the branch contains a registered-router, real-worker regression with a reported failing baseline. This read-only review did not execute the test. Is this the best way to solve the issue? Yes for the Gateway path: committed sharing facts and final authority checks address the wait at its owner. The Windows catch has a narrow code shape, with native settlement proof still outstanding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e6d8dae5c200. 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
History |
Pull request was converted to draft
Keep the main-owned #162013 cleanup behavior without overriding it. The remaining three-path delta is failed-disable compensation and regression coverage; all three postimages match the qualified predecessor.
…claw#162013) * perf(gateway): avoid display-row waits in message subscriptions Authorize message observers from committed sharing and membership facts while retaining incognito preparation, session authority, and approval replay guards. Attribute slow subscriptions from router entry through observer commit with bounded phase timings. * test(gateway): enforce subscription integrity at observer admission * fix(update): retain restoration authority after interruption
What Problem This Solves
sessions.messages.subscribecould wait for a dirty session display row before entering its otherwise fast handler. The router joined the transcript worker's display refresh even when committed sharing facts were already available.The required CI run also exposed a deterministic, pre-existing updater bug: SIGINT during Windows task suspension made recovery settlement use the forward-work guard and fail with
requester-revoked.User Impact
Message subscriptions can acknowledge while display facts refresh. Visibility, membership, retained session/caller authority, incognito preparation, and authoritative approval replay remain enforced. Slow requests now report where they waited.
The bounded updater repair lets interruption finish owned autostart restoration and cancellation settlement, while preserving live executor, native task, and repair checks.
Why This Change Was Made
Subscription authorization now prepares committed access facts through their existing owner, without requiring display materialization. Approval replay still completes before acknowledgment and retains its retry and rollback checks.
slow session messages subscribeuses the shared one-second threshold andphaseDurationsMs, starting in the router. Phases cover access facts, projection readiness, handler preparation, retained-read admission, replay preparation, observer commit, response, and cleanup. It records no session keys or message contents.The updater repair forwards its existing
restorephase through recovery guards. The overlapping Windows task repair landed independently in #161990; this PR retains the additional service-maintenance compensation guard, with zero net production LOC. Initial disable, mutation admission, and handoff retain forward checks. This belongs to the running updater; older drivers already in progress retain their behavior.Evidence
The subscription regression uses the registered router/handler, a real SQLite transcript worker, an active turn writing a row, and plain plus approval observers. It holds delivery of display facts with a deferred signal. Both the one-session and 8,000-session fixtures failed on the old path and pass with this change.
projectionReadinessThe 1,500 ms interval is an injected clock measurement. Production tail latency remains unverified. Cold approval preparation remains: the corrected 8,000-session response pair took 927 ms wall time. The final warm 160k-token run measured 1.96 ms mean without approval replay and 10.97 ms with replay; wall samples varied under load.
Validation passed:
Final-head CI: success, head
df91ac87102f7592346755df02e32dc8880dc7ce. The superseded4828430d8d73run was cancelled after the conflict-resolution push; it is not claimed as passing CI.68 focused subscription, approval, visibility, retained-authority, and diagnostic tests across scoped runs.
Four canonical-validation cases. CI caught an old assertion against pre-dispatch timing; the updated test requires the actual registered subscription to reject corrupt storage before any observer registration.
All 52 focused updater lifecycle/recovery/authority cases. The existing SIGINT regression failed before the guard repair and passes afterward.
The exact original 36-file updater CI group: 772 passed after repair, versus 771 passed and the same SIGINT failure before it. Core and updater test types, targeted lint, runtime guards, and docs checks passed.
After resolving the overlap with fix(update): restore Windows task autostart after cancellation #161990 against main
8eadb661cdfb, all 102 tests across five Windows lifecycle, service-authority, maintenance, and recovery files passed in 153.44 s. The resolution uses main’s existing helper; subscription code is unchanged.Independent reviews through P2: scoped-clean, no actionable findings.
Full candidate build, SDK export checks, tarball integrity/import-graph checks, and the existing published
[email protected]→ candidate4828430d8d73Linux Docker upgrade cell. It verified preserved synthetic operator state, installed candidate payload, and Gateway readiness. The upgrade scenario passed in 369 s; build/package preparation took 525 s.The updater unit proof uses mocked Windows service APIs on Linux. Native Windows interruption was not exercised. No live operator Gateway was changed.
Test cost
Measured with
pnpm test <file> --maxWorkers=1:sessions.messages-subscribe-wait.test.tssessions.messages-subscribe-latency.benchmark.test.tsslow-request-diagnostics.test.tsserver-methods.canonical-validation.test.tsThe ordinary regression uses one session. The larger benchmark exercises the requested inventory and real worker dependency. The original canonical-validation file consumed 3.170 s in the first CI run, including its stale assertion.
Testbox commands, identities, and recovery
Every heavy command ran through
crabbox, providerblacksmith-testbox, profileopenclaw-check, with native sync and one active command per lease. All leases were stopped.tbx_01m3sj82qmqg8eg45skf6df42h(run)node scripts/check-changed.mjs, scoped lint/guard recovery, andpnpm check:docs. Initial missing dependencies were repaired with one frozen-lockfile install. All typecheck lanes passed; test-only lint issues were corrected and the affected lint/tests rerun clean. Docs: 14,646 links, zero broken links.tbx_01m3spf2wwhfbn25c7zaexk42x(run)tsconfig.core.test.gateway-server.json: passed.tbx_01m3sq4szsp3tg61bjkvs6ye52(run)tbx_01m3sryw91t6swtdae6dyqxfrntbx_01m3ssb8n9tpb5vyf65rydwkr2(run)tbx_01m3stsqkj7vnyrap1paxyhvyj(run)pnpm install --frozen-lockfilerepaired the lease. Focused command below: 102 passed, exit 0; 153.44 s test runner, 168.40 s command wall including installation and transport.Focused subscription command:
Conflict-resolution command:
Published-driver cell:
The baseline version, registry tarball, and integrity were verified before execution. No live model calls were selected.
Related: #161555.