Skip to content

fix(gateway): admit hooks only on execution-lane entry, not cron session preparation - #175111

Merged
RomneyDa merged 1 commit into
mainfrom
fix/hook-admission-cron-preparation
Oct 17, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/hook-admission-cron-preparation

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

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/agent now 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 and main have 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 sends onLaneWait({ waiting: false }) when it does. The hook dispatcher (src/gateway/server/hooks.ts) treats any waiting: false as 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:

  • CronLaneWaitCallback info gets an optional stage?: "session-preparation". Session preparation tags all of its lane signals with it.
  • The hook dispatcher accepts a hook only on an untagged waiting: false (the execution lane) or on onExecutionStarted.
  • The cron timeout watchdog still receives both kinds of signal, unchanged. Preparation waits still pause and restart its setup timer. That is why preparation keeps sending its signals (tagged) instead of dropping waiting: false.

#165310's FIFO behavior and its waiting for the previous session to settle are unchanged.

User Impact

  • When the hook budget is full, operators and webhook producers get HTTP 503 ("hook agent run did not start before admission timeout") again, so their redelivery and back-off work.
  • Cron and hook execution concurrency and cron watchdog timeouts are unchanged.

Evidence

  • E2E on release/2026.10.5, run against a pnpm build:docker dist: OPENCLAW_E2E_USE_PREBUILT_DIST=1 pnpm test:e2e:gateway test/gateway-hook-concurrency.e2e.test.ts
    • Before: 1 failed / 1 passed, expected [...] to have a length of 8 but got 9 (78s)
    • After: 2/2 passed in two consecutive runs (about 69s each)
  • New regression in src/gateway/server.hooks-admission.test.ts, "does not admit an HTTP hook when only cron session preparation enters its lane": without the hooks.ts change it fails with expected 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.
  • Unit wall times on this branch (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)
    • The new hooks test adds one case using the existing suite fixture, with no timers or polling.
  • oxfmt --check and oxlint --type-aware on the touched files: clean.
  • pnpm tsgo:core and pnpm tsgo:core:test: the only error is inherited from main and 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 blocks scripts/run-oxlint.mjs during its plugin-SDK boundary step, so oxlint ran directly instead. On release/2026.10.5, both tsgo lanes and scripts/run-oxlint.mjs pass with this change.

…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).
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Distinguishes 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.

  • Before: Session preparation can cause all nine requests to receive HTTP 200.
  • After: Eight requests are accepted; the request still awaiting execution admission receives HTTP 503 after the existing deadline.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent, with useful reported integration results and no actionable code findings.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is exempt from the ordinary contributor proof gate; its body reports built-Gateway HTTP saturation and fairness runs on the release branch, plus a branch-local HTTP regression negative control.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Webhook producers receive HTTP 200 for work that has not acquired execution capacity, preventing appropriate retry and backoff.
Reason: The maintainer-authored correction restores the documented acceptance contract while retaining the earlier FIFO and reload fixes.

Regression provenance

Possible 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
Reviewed head: 8a27774b3713f6cd3c9fffd0e3699ff4ff26869d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Built-Gateway saturation results are reported for the release branch, but no directly inspectable current-head runtime capture is supplied.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Cron preparation notifications keeps the original intent (c42bd6e: Serialize preparation and wait for predecessor settlement without blocking the execution lane or changing FIFO order.)
  • Hook admission notification consumption keeps the original intent (e901771: Accept after canonical placement admission rather than waiting for model-runtime preparation or runner entry; the later diagnostic refactor carried this condition forward.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e901771 adds src/gateway/server.hooks-admission.test.ts:249 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e9017714c2d6; files: src/gateway/server.hooks-admission.test.ts)
  • Dallin Romney: Raw commit 5f604dd adds src/gateway/server/hooks.ts:540 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5f604ddd8095; files: src/gateway/server/hooks.ts)

PR surface

Source +11, Tests +27. Total +38 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 17 6 +11
Tests 2 27 0 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 44 6 +38

Labels

Label changes:

  • add P1: A current webhook regression falsely acknowledges queued work and prevents producers from applying the documented backpressure behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: A current webhook regression falsely acknowledges queued work and prevents producers from applying the documented backpressure behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 17, 2026, 1:00 AM ET / 05:00 UTC.

@RomneyDa

Copy link
Copy Markdown
Member Author

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 src/snapshot/local-repository.ts(1101,46): error TS2554, inherited from current main and untouched by this PR. The change's own tests pass (run.session-lane 7/7, hooks-admission 11/11; new test fails with the fix reverted) and the release-line e2e flips from 8-vs-9 failure to 2/2 pass.

@RomneyDa
RomneyDa merged commit 4af30f6 into main Oct 17, 2026
111 of 121 checks passed
@RomneyDa
RomneyDa deleted the fix/hook-admission-cron-preparation branch October 17, 2026 05:05
RomneyDa added a commit that referenced this pull request Oct 17, 2026
…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)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…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).
RomneyDa added a commit that referenced this pull request Oct 27, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant