Repository navigation
fix(gateway): attribute prepared session-row stalls - #180239
Conversation
Carry code-owned task names across readiness waits and label synchronous selection, preparation, consumption, and roster batches. Keep phase strings separate until a stall is recorded. Operators can identify the enclosing RPC or background task without changing read budgets or scheduling.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis PR preserves operation names across waits and attributes slow synchronous session-row and agent-roster work to those operations. Example: A sessions.list request awaits readiness, then spends 300 ms selecting session rows.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it addresses a source-visible diagnostic gap with maintainer-approved direction, and review found no actionable correctness or security defects. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway RPCs and scheduled jobs enter the prepared-row owner, which combines current session selection and placement facts before synchronous consumption; the shared stall monitor records bounded diagnostic labels and durations. flowchart TD
A[RPC or scheduled job] --> B[Operation name context]
B --> C[Prepared session rows]
C --> D[Readiness and placement waits]
D --> E[Synchronous selection and consumption]
E --> F[Agent roster batch]
E --> G[Shared stall monitor]
F --> G
Technical reviewBest possible solution: Keep task identity and synchronous timing in the existing stall owner, preserving current session-read scheduling and authorization. Do we have a high-confidence way to reproduce the issue? Current-main source shows task scopes ending when callbacks return promises and resumed prepared-row phases lacking explicit scopes; the PR reports focused regressions failing on the base, but this read-only review executed no target code. Is this the best way to solve the issue? The patch is a focused repair using the existing monitor and preparation owners; the added tests cover resumed attribution, exclusion of readiness waits, overlapping callers, and synchronous owner-context reentry. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 317f9399d9b0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +40, Tests +86, Docs +6. Total +132 across 6 files. Added test files: 0. View PR surface stats
LabelsLabel 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 Reviewed October 21, 2026, 11:29 PM ET / October 22, 2026, 03:29 UTC. |
|
Landing the reviewed head The two non-aggregate failures in run 39715651391 are inherited:
Other non-aggregate checks passed or were intentionally skipped. No CI rerun, review waiver, or security waiver was used. |
Carry code-owned task names across readiness waits and label synchronous selection, preparation, consumption, and roster batches. Keep phase strings separate until a stall is recorded. Operators can identify the enclosing RPC or background task without changing read budgets or scheduling.
What Problem This Solves
Prepared session-row reads and agent roster batches can produce
task=unattributedmain-thread stall warnings after their enclosing operation has awaited readiness. Related: #179929 (attribution extracted without its rejected read budget).User Impact
Operators can identify the RPC method or scheduled task behind a slow synchronous read. Examples:
gateway:rpc:sessions.list:session-rows:selectandscheduler:maintenance:session-refresh:agent-roster. Session selection, queueing, budgets, and response behavior are unchanged.Why This Change Was Made
The existing stall owner now carries the code-owned operation name across awaits and times the select, prepare, consume, and roster scopes synchronously. It keeps the phase separate and constructs the combined label only when recording a stall. There is no per-row instrumentation, new queue, configuration, or schema. Runtime code is net +40 lines: carrying task identity across waits and timing the previously unnamed phases requires new diagnostic coverage. Existing timing, queue, and selection owners remain in place.
Evidence
Independent review through P2 found no actionable issues. All 55 focused tests passed (stall monitor, prepared-row lifecycle, event-loop health, and roster configuration); both new prepared-row regressions failed on the original code with an empty stall report. Changed-file formatting/lint and the native core typecheck passed. The export-name collision guard and both source-closure files passed (22 cases). All three paired measurements pass the acceptance rule below; the result is neutral.
The focused test command took 32.73 seconds including worker preparation; the changed test files themselves took milliseconds. No Testbox lease or production Gateway mutation was used.
Measurement acceptance, recorded before running: two concurrent baseline/candidate pairs with identical synthetic 5,000-session/6,000-run fixtures, CPU placements swapped in pair 2, one shared measurement lock, and the shared production guard. Warm real WebSocket
sessions.listrequests use the same operation count per side. Measure RPC mean/p95/p99, sampled main-isolate allocation per RPC, total GC time per RPC, promotion, and event-loop delay; report sample counts and each side's maximum GC pause.Decision rules: stop for a mean paired regression of at least 20%, or at least 10% adverse in both pairs. Opposite delta signs or baselines differing by more than 5× are inconclusive; report absolute and relative deltas, run a third pair for a gating metric, and decide on its absolute mean. p95 requires 200 samples per side; p99 requires 1,000; major GC requires 50 collections. Per-collection pause tails are context when collection counts fall at least 20% and total GC does not rise, except a maximum single pause above max(50 ms, twice baseline). Guard-interrupted pairs are discarded. This explicitly requested diagnostic change may land with neutral performance.
Paired measurements: neutral
Three concurrent baseline/candidate pairs used identical synthetic 5,000-session / 6,000-retained-run fixtures and real WebSocket
sessions.listcalls. Each side completed 240 warmup requests and 2,400 measured requests returning 200 sidebar rows. The first two pairs changed sign for allocation, promotion, total GC, and minor-GC p95, so they were inconclusive for those metrics under v5.2; the third pair resolves them using the absolute mean. No eligible metric reaches a +20% mean regression or is at least +10% adverse in both initial pairs. Pair 3's RPC p99 is +10.98% on its own; the three-pair absolute mean is −0.295 ms (−1.04% of mean baseline). This is neutral evidence, not a speedup claim.Mean absolute deltas: RPC latency −0.054659 ms; sampled allocation +3,941.99 bytes/RPC (+0.153%); total GC +0.000528612 ms/RPC (+0.359%); promotion −2,060.54 bytes/RPC (−2.477%). Minor-GC p95 is +0.077333 ms (+3.955%). Event-loop p99, minor-GC p99, and major-GC tails are context-only because their per-side sample counts are below the required thresholds. The candidate's maximum single GC pause is below
max(50 ms, 2 × baseline max)in every pair.Method: Linux x64, Node 26.12.1, source Gateways with the three changed owners substituted at their canonical module URLs. Baseline is
34a4e3bf238e1ebcb0c110d6b912f71bbeceed22; candidate owner hashes match this PR head. The intervening rebase changes were UI-only; the measured owners and lockfile are unchanged. Both variants used the same resolver wrapper and verified source-package routing. Slot A held one exclusive lock per pair; baseline used even CPUs 96–126 in pairs 1/3 and odd CPUs 97–127 in pair 2, with candidate on the other interleaved set. Each side verified 16 available CPUs,MemoryMax=16G,CPUWeight=10, andIOWeight=10. Preparation used CPUs 0–63 with nice 19. The shared guard ran unchanged before and during each pair; no accepted pair had a guard violation. Setup-only failed attempts were excluded before measurement.There were no diagnostic drops, collection errors, or lost histogram samples. All 20 captured filter/sort/paging responses matched in each pair, after canonical
expandSessionRowFactsexpansion and normalization of the documented timestamps, process-localrowsRevisionUUIDs, and synthetic fixture paths. No row content, ordering, or count was removed.Each pair cell is baseline → candidate; absolute delta (relative delta). Tail sample counts are baseline/candidate. Means use all three accepted pairs; absolute means retain their sign.
Live log proof
A separate isolated source Gateway served a real WebSocket
sessions.listrequest (200 rows, totalCount 5,000). A task-only overlay injected one 350 ms synchronous pause intoselectRows, guarded to fire only forgateway:rpc:sessions.list; this overlay was never used in the paired measurements. The existing event-loop logger emitted:The controller exited 0 and the owned Gateway shut down. The shared guard reported no failure. The committed regression additionally proves background-task attribution after readiness waits (
scheduler:maintenance:session-refresh:session-rows:select) and nested roster attribution (...:agent-roster).CI attribution
Exact-head CI run 39715651391 completed with two inherited non-aggregate failures; the aggregate CI gate remains red. No CI rerun was requested.
check-test-types-core-3:chat-details-output-intent.test.tsx:27,53still suppliesartifactsLoadingafter refactor(ui): observe workspace reads with Solid boundaries #180031 replaced that property withartifactRead. Independent job 119618113966 has the identical TS2353 errors. Both offending file blobs match this head, that job's actual merge checkoutb61ce93b0f6b775060b326d222a48c6bff31eb3a, and its main parent4611232730583082f5c49bd79f1f68dfbfbd1b60.checks-node-changed: the pinned-Bunx-publication-owner-composition.e2e.test.ts:944anonymous read returned 503 instead of 200. fix(test): X publication e2e returns 503 on the public read under Bun #177556 diagnoses the existing fixture race: a second completion write can invalidate a public representation after the fixture's controller-settlement checkpoint. #179939's baseline proof reproduced the identical failure on both unchanged main399a360fdfbb15546498a97886cef41fd8cac66band its candidate on their third focused invocations. The six causal public-cache/response and registry-completion modules are byte-identical here, and the fixture still has the old checkpoint. This fixture never starts the stall monitor, so the added task scopes call through synchronously. Our head and exact-parent focused Bun replays each passed once; those passes are context, not a claim that the race is fixed.The focused replay used
OPENCLAW_E2E_SKIP_BUILD=1 node scripts/run-vitest.mjs src/gateway/x-publication-owner-composition.e2e.test.ts --maxWorkers=1, the supported path for this source-composition fixture. An initial invocation started automatic E2E build preparation and was stopped before running the test to respect the local compute limit. All other non-aggregate CI jobs passed or were intentionally skipped. Independent review remains clean; no review or security requirement is being waived.