Repository navigation
fix(worker-runtime): reserve a class-0 lane for access checks - #199564
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR reserves priority admission and one additional worker slot for session access-fact reads. Example: An access check starts while 128 bulk tasks fill the session-store pool.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a concrete access-check availability failure that remains on main; source review found no actionable correctness defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway access preparation discovers session stores and reads exact membership facts through the shared worker scheduler, then supplies those facts to the existing authorization owner. flowchart TD
A[Gateway request] --> B[Session fact preparation]
B --> C[Priority worker admission]
D[Bulk reads] --> E[Bounded bulk admission]
C --> F[Existing worker scheduler]
E --> F
F --> G[Session store reads]
G --> H[Authorization facts]
Technical reviewBest possible solution: Keep priority admission in the existing scheduler and preserve the current authorization, cancellation, and cleanup owners. Do we have a high-confidence way to reproduce the issue? Main rejects the next ordinary task once 128 tasks are admitted, and access-fact preparation uses that pool; the PR supplies a focused saturation regression and reports its expected failure on the pinned base. Is this the best way to solve the issue? The change repairs admission at its existing owner, threads classification through the affected reads, and preserves ordinary callers without introducing another pool, cache, or authorization path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e5fcdedc3ab0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +57, Tests +72. Total +129 across 17 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 15, 2026, 5:36 AM ET / 10:36 UTC (Revision 2). |
Access checks read session facts through the shared session store worker pool. When bulk reads filled the pool's pending cap, the pool refused the access check with "worker task capacity reached", and the Gateway reported SessionMutationFactsUnavailableError for every request that needed it. The worker pool core now has two lanes. A task marked `pointRead` (class 0) is never refused by the pending caps, queues ahead of bulk work, skips the shared compute permit, and can use one worker above the bulk limit. A point read must carry every fact in its input, so the pool refuses one that asks for host callbacks. Session access fact reads (inventory, store target and exact entries) use this lane. Co-authored-by: obviyus <[email protected]>
|
@clawsweeper re-review |
d038058 to
9e406e1
Compare
|
🦞👀 Re-review progress:
|
|
Landed in 8f9bd10.
|
Merge main 8f9bd10 to resolve the three conflicts introduced by #199564. Keep the retired compaction-source module deleted and the request runner owned by the reader factory. Preserve main's options object, explicit trajectory timeout, transport-only pointRead classification, reserved-lane dispatch, and unrelated changes. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: jalehman <[email protected]>
Backport the P1 access-check starvation fix to beta.4 using its existing targetDiscoveryLane and boolean admission owner. Keep the retired compaction source deleted; do not import the main-only reader-pool or diagnostic migration. Preserve bulk caps, FIFO within point reads, and the callback prohibition. The real preparation boundary and pool regressions fail on the prior candidate. All 16 affected consumer suites pass (220 tests), as do core types, touched-file lint and the assertion ratchet. Local autoreview is unavailable and skipped under the release authorization; this is not independent review evidence. (cherry picked from commit 8f9bd10) Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Honor the explicit hosted runner choice in the aggregate source check introduced by #199836 after #199785. Verify refreshed workspace instructions in history while preserving the pinned prompt required by the approved prompt fixes. Drop a main-only diagnostic option from the #199564 regression fixture instead of importing its unrelated prerequisite. Proof: hosted/workflow and prompt boundary suites pass (109 executions); access preparation passes 23 tests; all core test-type shards and touched lint pass. Local autoreview unavailable and skipped under release authorization. Co-authored-by: RomneyDa <[email protected]>
…aw#199564) ## Problem Access checks read session facts through the shared session store worker pool. Bulk reads use the same pool. When bulk reads filled the pool's pending cap (128 tasks), the pool refused the access check with `worker task capacity reached`. The Gateway then failed the request with `SessionMutationFactsUnavailableError`. One production Gateway logged 2,455 of these refusals in one episode on 2026-11-11 (`sessions.messages.subscribe`, `sessions.viewers.set`, `progressCard.get`, `artifacts.download`, Web Push authority and others). The requests also waited up to about 20 minutes before the refusal. The pool had one FIFO queue and one cap. It had no caller class. ## Fix The worker pool core now has two lanes: - **Class 0 (`pointRead: true`)**: access checks and other point reads. - The pending caps never refuse it. - It queues ahead of all queued bulk work, in its own arrival order. - It does not wait for a shared compute permit. - It can use one worker above the bulk worker limit. Bulk work cannot use that worker. - Its input must carry every fact it needs. The pool refuses a point read that asks for host callbacks (`onRequest` or `onRequestSync`). - **Everything else**: no change. The session access fact reads use class 0: the store inventory read, the store target read and the exact entry read in `prepareSessionMutationFacts`. These reads already sent no host callbacks. The access check therefore no longer has an overload refusal path. Small related changes: - The session history request runner takes `{ timeoutMs, pointRead }` as one options object instead of a positional `timeoutMs`. - The `pointRead` field never goes to the worker. The transport removes it before it sends the request. This is step 1 of the runtime design (E2): a reserved class-0 lane. It does not add more classes or change other pools. ## Proof | Check | Tier | Base (`312d29fad005`) | Head | |---|---|---|---| | New: access check after 128 bulk reads fill the session store pool (`session-sharing-preparation.test.ts`) | vitest-source | Fails: `SessionMutationFactsUnavailableError` caused by `worker task capacity reached [task=sessionTranscript.session-target-inventory pool pending tasks: pendingTasks=128 maxPendingTasks=128]` | Passes in 674 ms; the pool call has `pointRead: true` | | New: point reads run on the reserved worker, ahead of queued bulk work, while the pool is full (`worker-task-pool.preparation.test.ts`) | vitest-source | Fails: `worker task capacity reached [... pendingTasks=2 maxPendingTasks=2]` | Passes | | New: a point read that asks for host callbacks is refused | vitest-source | Fails (the read runs) | Passes | | 27 affected test files: worker pool, worker runtime, session entry reads, store target inventory, session sharing, compaction source, startup | vitest-source | — | 380 tests pass | | `pnpm tsgo:core`, `pnpm check:test-types`, `pnpm tsgo:scripts`, `oxlint`, `oxfmt` | typecheck / lint | — | Pass | | Real Gateway, 32 clients, 1,000 access checks on uncached session keys plus 100 `sessions.list` reads | source (`ocx src`) | 0 capacity refusals, 929 correct `unknown session` answers, 72 `server is busy` | 0 capacity refusals, 932 correct answers, 69 + 6 `server is busy` | | Real Gateway from `dist/` on Node, 200 access checks | dist (after `ocx build --dts`) | — | 200 correct answers, 0 capacity refusals | | `ocx build --dts`, then `npm pack` with the bundled channel entry smoke | full | — | Pass | Note about the real Gateway run: the Gateway request admission refuses extra RPCs (`server is busy`) before they can fill the session store pool. So RPC load alone does not reproduce the refusal on base. In production, internal work filled the pool. The run shows that the head has no regression on the real Gateway. The vitest proof shows the fix. Known unrelated failure: `src/config/sessions/session-transcript-worker-lanes.test.ts` ("releases pressure subscriptions after native settlement and rearms reopened lanes") fails and then hangs on the base too. ## Net lines `git diff --stat origin/main...HEAD`: 17 files, +151 / −21. - Source: +77 / −20. - Tests: +74 / −1. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Access checks read session facts through the shared session store worker pool. Bulk reads use the same pool. When bulk reads filled the pool's pending cap (128 tasks), the pool refused the access check with
worker task capacity reached. The Gateway then failed the request withSessionMutationFactsUnavailableError.One production Gateway logged 2,455 of these refusals in one episode on 2026-11-11 (
sessions.messages.subscribe,sessions.viewers.set,progressCard.get,artifacts.download, Web Push authority and others). The requests also waited up to about 20 minutes before the refusal.The pool had one FIFO queue and one cap. It had no caller class.
Fix
The worker pool core now has two lanes:
pointRead: true): access checks and other point reads.onRequestoronRequestSync).The session access fact reads use class 0: the store inventory read, the store target read and the exact entry read in
prepareSessionMutationFacts. These reads already sent no host callbacks. The access check therefore no longer has an overload refusal path.Small related changes:
{ timeoutMs, pointRead }as one options object instead of a positionaltimeoutMs.pointReadfield never goes to the worker. The transport removes it before it sends the request.This is step 1 of the runtime design (E2): a reserved class-0 lane. It does not add more classes or change other pools.
Proof
33a1413e7be4)session-sharing-preparation.test.ts)SessionMutationFactsUnavailableErrorcaused byworker task capacity reached [task=sessionTranscript.session-target-inventory pool pending tasks: pendingTasks=128 maxPendingTasks=128]pointRead: trueworker-task-pool.preparation.test.ts)worker task capacity reached [... pendingTasks=2 maxPendingTasks=2]pnpm tsgo:core,pnpm check:test-types,pnpm tsgo:scripts,oxlint,oxfmtsessions.listreadsocx src)unknown sessionanswers, 72server is busyserver is busydist/on Node, 200 access checksocx build --dts)ocx build --dts, thennpm packwith the bundled channel entry smokeNote about the real Gateway run: the Gateway request admission refuses extra RPCs (
server is busy) before they can fill the session store pool. So RPC load alone does not reproduce the refusal on base. In production, internal work filled the pool. The run shows that the head has no regression on the real Gateway. The vitest proof shows the fix.Known unrelated failure:
src/config/sessions/session-transcript-worker-lanes.test.ts("releases pressure subscriptions after native settlement and rearms reopened lanes") fails and then hangs on the base too.Net lines
git diff --stat origin/main...HEAD: 17 files, +151 / −21.