Repository navigation
fix(gateway): admit hooks only on execution-lane entry, not cron session preparation - #175111
Conversation
…ion preparation #165310 added withCronSessionPreparation, which enters the per-session lane before the isolated run reaches its execution lane and reports onLaneWait({ waiting: false }) when it does. The HTTP hook dispatcher reads waiting:false as execution admission, so a hook beyond the shared hook/cron budget returned 200 as soon as its session preparation ran instead of the 503 admission-timeout back-off. Execution capacity itself was unaffected. Tag session-preparation lane signals with stage "session-preparation" and settle hook admission only on untagged (execution-lane) waiting:false. The cron timeout watchdog keeps consuming both signals unchanged, so preparation waits still pause and resume its setup budget. Fixes test/gateway-hook-concurrency.e2e.test.ts "bounds hooks and admits an older cron turn before a later hook" (expected 8 accepted, got 9).
|
🦞👀 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. What this changesDistinguishes cron session-preparation signals from execution admission so hooks receive accurate HTTP acceptance or backpressure. Example: Nine concurrent hook requests compete for eight shared execution slots.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current admission regression with a focused change, and I found no introduced code defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway dispatches authenticated agent hooks through isolated cron execution; lane callbacks determine HTTP acceptance while the cron watchdog uses them to track setup waits. flowchart TD
A[Authenticated hook request] --> B[Gateway hook dispatcher]
B --> C[Cron session preparation]
C --> D[Shared execution admission]
D --> E[Agent runner]
C --> F[Cron setup watchdog]
D --> G[HTTP acceptance]
B --> H[Admission timeout response]
Technical reviewBest possible solution: Land the stage distinction while preserving placement-based acceptance, session FIFO, watchdog timing, and the existing admission deadline. Do we have a high-confidence way to reproduce the issue? Current-main source directly connects preparation's waiting:false signal to HTTP acceptance before execution admission; the body supplies matching saturation failure results, but no code was executed during this review. Is this the best way to solve the issue? The producer tags the distinct preparation event and the HTTP consumer filters it, fixing the semantic mismatch without removing watchdog notifications or adding another admission owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6d578912da66. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +11, Tests +27. Total +38 across 5 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 17, 2026, 1:00 AM ET / 05:00 UTC. |
|
Admin-merge evidence (2026.10.5 release blocker): all failing checks (check-prod-types, check-test-types, check-test-types-core-1..5, check-additional-extension-package-boundary) fail only on |
…ion preparation (#175111) before the isolated run reaches its execution lane and reports onLaneWait({ waiting: false }) when it does. The HTTP hook dispatcher reads waiting:false as execution admission, so a hook beyond the shared hook/cron budget returned 200 as soon as its session preparation ran instead of the 503 admission-timeout back-off. Execution capacity itself was unaffected. Tag session-preparation lane signals with stage "session-preparation" and settle hook admission only on untagged (execution-lane) waiting:false. The cron timeout watchdog keeps consuming both signals unchanged, so preparation waits still pause and resume its setup budget. Fixes test/gateway-hook-concurrency.e2e.test.ts "bounds hooks and admits an older cron turn before a later hook" (expected 8 accepted, got 9). (cherry picked from commit 4af30f6)
…ion preparation (openclaw#175111) openclaw#165310 added withCronSessionPreparation, which enters the per-session lane before the isolated run reaches its execution lane and reports onLaneWait({ waiting: false }) when it does. The HTTP hook dispatcher reads waiting:false as execution admission, so a hook beyond the shared hook/cron budget returned 200 as soon as its session preparation ran instead of the 503 admission-timeout back-off. Execution capacity itself was unaffected. Tag session-preparation lane signals with stage "session-preparation" and settle hook admission only on untagged (execution-lane) waiting:false. The cron timeout watchdog keeps consuming both signals unchanged, so preparation waits still pause and resume its setup budget. Fixes test/gateway-hook-concurrency.e2e.test.ts "bounds hooks and admits an older cron turn before a later hook" (expected 8 accepted, got 9).
…ion preparation (#175111) before the isolated run reaches its execution lane and reports onLaneWait({ waiting: false }) when it does. The HTTP hook dispatcher reads waiting:false as execution admission, so a hook beyond the shared hook/cron budget returned 200 as soon as its session preparation ran instead of the 503 admission-timeout back-off. Execution capacity itself was unaffected. Tag session-preparation lane signals with stage "session-preparation" and settle hook admission only on untagged (execution-lane) waiting:false. The cron timeout watchdog keeps consuming both signals unchanged, so preparation waits still pause and resume its setup budget. Fixes test/gateway-hook-concurrency.e2e.test.ts "bounds hooks and admits an older cron turn before a later hook" (expected 8 accepted, got 9). (cherry picked from commit 4af30f6) (cherry picked from commit 461f4bd)
What Problem This Solves
HTTP hooks above the shared hook/cron budget no longer back off with HTTP 503. When the budget is full,
/hooks/agentnow returns 200 for a hook that has not been admitted to its execution lane.This blocks the 2026.10.5 stable release. In
test/gateway-hook-concurrency.e2e.test.ts, "bounds hooks and admits an older cron turn before a later hook" expects 8 accepted hooks and gets 9. 2026.10.4 passed it 12/12. Every 2026.10.5 candidate andmainhave failed it since c42bd6e (#165310).Why This Change Was Made
#165310 added
withCronSessionPreparation(src/cron/isolated-agent/run-session-state.ts). It enters the per-session lane before the isolated run reaches its execution lane, and sendsonLaneWait({ waiting: false })when it does. The hook dispatcher (src/gateway/server/hooks.ts) treats anywaiting: falseas execution-lane admission. So the extra hook was accepted as soon as its session preparation ran, before the 503 admission timeout could fire. Execution capacity itself was unaffected.The fix:
CronLaneWaitCallbackinfo gets an optionalstage?: "session-preparation". Session preparation tags all of its lane signals with it.waiting: false(the execution lane) or ononExecutionStarted.waiting: false.#165310's FIFO behavior and its waiting for the previous session to settle are unchanged.
User Impact
Evidence
release/2026.10.5, run against apnpm build:dockerdist:OPENCLAW_E2E_USE_PREBUILT_DIST=1 pnpm test:e2e:gateway test/gateway-hook-concurrency.e2e.test.tsexpected [...] to have a length of 8 but got 9(78s)src/gateway/server.hooks-admission.test.ts, "does not admit an HTTP hook when only cron session preparation enters its lane": without thehooks.tschange it fails withexpected 200 to be 409; with it, it passes. Checked on both the release line and this branch.src/cron/isolated-agent/run.session-lane.test.ts: the existing generation-preservation cases now also check that preparation tags its signals.pnpm test <file> --maxWorkers=1):src/cron/isolated-agent/run.session-lane.test.ts: 7/7, about 45s wall (Vitest reports 39.9s)src/gateway/server.hooks-admission.test.ts: 11/11, about 62s wall (Vitest reports 56.5s)oxfmt --checkandoxlint --type-awareon the touched files: clean.pnpm tsgo:coreandpnpm tsgo:core:test: the only error is inherited frommainand is in a file this PR doesn't touch:src/snapshot/local-repository.ts(1101,46): error TS2554: Expected 1 arguments, but got 2. The same error also blocksscripts/run-oxlint.mjsduring its plugin-SDK boundary step, so oxlint ran directly instead. Onrelease/2026.10.5, both tsgo lanes andscripts/run-oxlint.mjspass with this change.