Skip to content

fix(hooks): avoid false admission timeouts during runtime reload - #128975

Merged
steipete merged 1 commit into
mainfrom
steipete/youthful-leakey-981a3f
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/youthful-leakey-981a3f

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where authenticated agent hooks could return 503 hook agent run did not start before admission timeout during Gateway startup or hot reload even after the run had acquired its canonical session lane, hook-dispatch lane, and placement owner. The later prepared-model-runtime wait was incorrectly counted as admission time, so valid work was aborted and ended with paired lane errors plus message processed ... outcome=error.

Why This Change Was Made

The embedded lane controller now publishes its existing waiting: false fact exactly once at authoritative placement admission, after lifecycle/writer validation and run-context claim. Hook HTTP admission consumes that owner-produced fact while retaining runner-entry fallback for direct execution paths; the 15-second deadline, typed 409/502/503 failures, idempotency, same-session ordering, abort fence, and shared cron/hook capacity remain unchanged.

AI-assisted: yes.

User Impact

Post-restart and hot-reload hook catch-up no longer fails merely because the admitted run is waiting for the replacement model runtime. 200 now means canonical session/global placement admission succeeded; genuine pre-admission failures remain visible and timed-out work still cannot start later.

Evidence

  • RED before the fix: the lane regression observed waiting: false before placement; the HTTP regression remained pending after placement instead of returning 200.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/lane-controller.queue-liveness.test.ts src/agents/embedded-agent-runner/run/lane-controller.group-wait.test.ts src/agents/embedded-agent-runner/run/lane-controller.lifecycle.test.ts src/agents/embedded-agent-runner/run/lane-controller.writer-claim.test.ts src/agents/session-placement-admission.test.ts src/cron/service/timer.timeout-watchdog.test.ts src/gateway/server.hooks-admission.test.ts src/gateway/server/hooks.agent-trust.test.ts — 85 tests passed.
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/gateway-hook-concurrency.e2e.test.ts — real isolated Gateway concurrency/fairness E2E passed.
  • node scripts/check-changed.mjs -- docs/automation/cron-jobs.md docs/gateway/configuration-reference.md src/agents/embedded-agent-runner/run/lane-controller.queue-liveness.test.ts src/agents/embedded-agent-runner/run/lane-controller.ts src/gateway/server.hooks-admission.test.ts src/gateway/server/hooks.ts — selected core, core-test, and docs gates passed.
  • Independent focused rerun: 53 tests passed; mandatory autoreview reported no actionable findings.
  • Production LOC: +13/-16 (net -3). Tests: +49/-1. Docs: +5/-5.
  • Proof used isolated local Gateway/test state only; no live fleet state was changed.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 02:46
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 11:34 PM ET / August 25, 2026, 03:34 UTC.

ClawSweeper review

What this changes

Moves hook HTTP success from agent-runner entry to canonical session/global placement admission so model-runtime preparation during reload does not cause a false admission timeout.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open: current main still reports admission before writer and placement validation, while this patch moves the signal to the authoritative placement boundary. No blocking correctness defect was found; the documented public HTTP-success milestone needs normal maintainer acceptance before merge.

Priority: P1
Reviewed head: 65bf3331a1fe1715be892867b1a8759d84da326a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative owner-boundary repair with targeted ordering coverage; the remaining item is acceptance of the public response milestone.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this is maintainer-authored; the PR body additionally reports an isolated Gateway concurrency E2E and focused regression runs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this is maintainer-authored; the PR body additionally reports an isolated Gateway concurrency E2E and focused regression runs.
Evidence reviewed 7 items Current-main defect: Current main emits waiting:false immediately after global-lane dequeue, before writer claim and placement admission, so the hook can receive an admission-success signal too early.
Authoritative owner boundary: The placement helper invokes its callback once only when the local or remote execution path has acquired the placement claim.
PR timing change: The branch emits waiting:false only inside the placement-admitted callback, after abort and lifecycle checks, queue-context release, and run-context claim.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/server.hooks-admission.test.ts

Result: FAIL (partial) — step 2 expect_output gateway hook admission: expected terminal output was not visible within 30 seconds: "gateway hook admission"

node scripts/run-vitest.mjs src/gateway/server.hooks-admission.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128975-5t8iaD/target$ node scripts/run-vitest.mjs src/gateway/server.hooks-admission.test.ts
node scripts/run-vitest.mjs src/gateway/server.hooks-admission.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128975-5t8iaD/target

[vitest] still running with no output for 30000ms.











































Assertions:

  • FAIL expect_output: gateway hook admission

How this fits together

Gateway hook requests start an isolated agent turn and wait for an admission signal before replying. The embedded runner acquires session/global placement, then prepares the model runtime and enters the agent runner.

flowchart LR
A[Hook HTTP request] --> B[Gateway hook handler]
B --> C[Isolated cron turn]
C --> D[Embedded runner lanes]
D --> E[Canonical placement admission]
E --> F[HTTP success response]
E --> G[Model runtime preparation]
G --> H[Agent runner entry]
Loading

Decision needed

Question Recommendation
Should hook HTTP 200 formally acknowledge canonical placement admission even when model-runtime preparation is still pending? Accept placement admission as success: Adopt the documented earlier 200 milestone so admitted reload work is not aborted while waiting for model runtime preparation.

Why: The branch deliberately changes a documented Gateway response milestone; source supports the repair, but accepting that public contract is maintainer intent.

Before merge

  • Resolve merge risk (P1) - This intentionally changes the documented hook HTTP 200 milestone from runner entry to placement admission, so integrations that relied on the former milestone will observe success earlier.
  • Complete next step (P2) - No mechanical repair is indicated; the remaining action is maintainer acceptance of the public hook acknowledgement contract and normal exact-head validation.
Agent review details

Security

None.

PR surface

Source -3, Tests +48, Docs 0. Total +45 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 13 16 -3
Tests 2 49 1 +48
Docs 2 5 5 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 67 22 +45

Review metrics

Metric Value Why it matters
Production versus test delta production +13/-16 (net -3); tests +49/-1 The bug fix moves an existing signal to its owner boundary with net-negative production code and focused boundary coverage.

Merge-risk options

Maintainer options:

  1. Confirm the new acknowledgement contract (recommended)
    Accept placement admission as the hook success milestone and merge with the accompanying documentation update.
  2. Retain runner-entry semantics
    Pause this approach if existing hook consumers require 200 only after model-runtime preparation and runner entry.

Technical review

Best possible solution:

Land the placement-owned signal after confirming that the documented earlier HTTP 200 acknowledgement is the intended public hook contract, while retaining the abort fence and runner-entry fallback.

Do we have a high-confidence way to reproduce the issue?

Yes — holding remote placement after lane dequeue reproduces the source-proven premature waiting:false signal on current main; the branch’s focused tests encode that ordering.

Is this the best way to solve the issue?

Yes — placement admission owns the fact the hook needs, so moving the existing signal there is narrower and safer than extending timeouts or adding a downstream workaround.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 70e6aa135a54.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The documented public meaning and timing of hook HTTP 200 changes from runner entry to placement admission.

Label justifications:

  • P1: The patch addresses hook requests that can return a visible 503 during gateway reload despite eventually acquiring canonical placement.
  • merge-risk: 🚨 compatibility: The documented public meaning and timing of hook HTTP 200 changes from runner entry to placement admission.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is maintainer-authored; the PR body additionally reports an isolated Gateway concurrency E2E and focused regression runs.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the placement-admission block to this contributor’s earlier implementation, and the proposed fix extends that same boundary. (role: current implementation owner and PR author; confidence: high; commits: 9e98229678c4, 65bf3331a1fe; files: src/agents/embedded-agent-runner/run/lane-controller.ts, src/gateway/server/hooks.ts)
  • joshavant: Recent current-main history includes owner-native lifecycle work touching the hook-side surface. (role: recent adjacent lifecycle contributor; confidence: medium; commits: 2e9c8f8d3f21; files: src/gateway/server/hooks.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm that placement admission, rather than runner entry, is the intended documented HTTP 200 contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T02:50:56.722Z sha 65bf333 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 25, 2026
@steipete steipete self-assigned this Aug 25, 2026
@steipete
steipete merged commit e901771 into main Aug 25, 2026
317 checks passed
@steipete
steipete deleted the steipete/youthful-leakey-981a3f branch August 25, 2026 05:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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