Skip to content

fix(agents): recover catalog worker after generation mismatch - #127712

Merged
obviyus merged 4 commits into
openclaw:mainfrom
kiranvk-2011:fix/catalog-worker-fingerprint-mismatch-fail-open
Sep 3, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
kiranvk-2011:fix/catalog-worker-fingerprint-mismatch-fail-open

Conversation

@kiranvk-2011

@kiranvk-2011 kiranvk-2011 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A transient prepared model catalog fingerprint mismatch can permanently wedge one worker. Every later catalog or authentication request on that owner then repeats the cached preparation failure.

The failure reaches Gateway catalog and authentication reads used before agent dispatch.

Root cause

The worker caches one preparedGeneration promise for its lifetime. A fingerprint mismatch rejects that promise. The parent receives the failure as a normal worker result, so it keeps the same worker and reuses the same rejected promise.

Fix

  • Return a typed generation-mismatch result before any catalog or authentication facts leave the worker.
  • Reject that result in the pool validator so the pool closes before queued work can dispatch.
  • Drop only the mismatched pool and let the same lifecycle owner create a new worker on the next request.
  • Keep crashes, timeouts, and superseded generations permanently closed.
  • Isolate the real-worker regression from ambient Codex authentication.

A persistent mismatch still rejects one request per cold worker. This bounded fail-closed behavior is intentional: it preserves the owner generation and avoids publishing foreign facts while the separate environmental drift remains under diagnosis.

Production change: +90/-33 lines, net +57. The remaining growth defines the typed mismatch result and the mismatch-only pool replacement. The maintainer pass removed the second terminal-error cache and the test-only error export.

The separate owner-publication race from #127710 has already landed through #130856. This pull request stays focused on the catalog-worker wedge.

Evidence

Current main baseline: 5778f39cc39737ce63a7cfd9e2c254e26fc52293

Red:

node scripts/run-vitest.mjs src/agents/prepared-model-catalog-worker.wedge.proof.test.ts
1 failed, 1 passed
recovery on the same owner failed with:
prepared model catalog worker reconstructed a different runtime generation

The control case created a fresh owner from the unchanged plan and passed. This proves the fixture was valid and the existing worker was wedged.

Green on 90900cfcdc5e2affa5217ed06bf5d3558da09d57:

node scripts/run-vitest.mjs src/agents/prepared-model-catalog-worker.integration.test.ts src/agents/prepared-model-catalog-worker.mismatch.integration.test.ts src/infra/worker-task-pool.test.ts
3 files passed, 34 tests passed

The transient case uses the real catalog owner, WorkerTaskPool, and worker thread. It proves queued work does not run on the retired worker, then proves worker 2 serves catalog and authentication facts on the same owner.

Original diagnosis and repair by @kiranvk-2011.

CI note

Exact-head CI passed all selected jobs except checks-node-compact-small-6. Its unchanged agent-exec service-relay timing test failed twice while waiting for a fake CLI process ID. Current main commit c3a495d198fe16e5a698132983ee1d7f7117d91a removes that test, and this pull request does not touch its file or wait helper, so the squash merge cannot restore the failure. The latest PR context and evidence run passed after the required headings were restored.

@clawsweeper

clawsweeper Bot commented Aug 22, 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 agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 22, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 22, 2026
@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 7:44 AM ET / 11:44 UTC.

ClawSweeper review

What this changes

The PR makes catalog-worker generation mismatches typed, retires the affected worker pool before queued calls run, and allows later catalog or authentication requests to use a rebuilt worker.

Merge readiness

⛔ Blocked before merge - 4 items remain

The branch correctly converts a cached worker-preparation failure into a typed owner-boundary rejection, fences queued requests before they dispatch, and permits a later worker rebuild. Current main still permanently closes this pool on the same failure; the remaining blocker is resolving or classifying the two failed exact-head checks.

Priority: P1
Reviewed head: 90900cfcdc5e2affa5217ed06bf5d3558da09d57

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned worker-boundary repair with convincing before/after proof; only exact-head CI resolution remains before merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies an after-fix terminal trace for the changed production owner: a real catalog owner, WorkerTaskPool, and worker thread receive an injected mismatch, fence concurrent work, retire worker 1, then have worker 2 return catalog and authentication facts on the same owner. The source test at the exact head matches that scenario; its temporary CODEX_HOME prevents ambient Codex auth from affecting the fixture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies an after-fix terminal trace for the changed production owner: a real catalog owner, WorkerTaskPool, and worker thread receive an injected mismatch, fence concurrent work, retire worker 1, then have worker 2 return catalog and authentication facts on the same owner. The source test at the exact head matches that scenario; its temporary CODEX_HOME prevents ambient Codex auth from affecting the fixture.
Evidence reviewed 6 items Current-main failure path: Current main throws while preparing a reconstructed generation whose fingerprint differs, then converts that error into a failed worker result; its owner catches the result error and closes the single pool permanently.
Owner and transport boundary: The branch rejects a typed mismatch in the pool validator before normal resolution; WorkerTaskPool closes queued and active work after validator failure, while the owner clears only that pool and retains permanent closure for other failures.
Boundary regression coverage: The added integration test uses the actual catalog owner, WorkerTaskPool, and worker thread; it verifies queued auth/catalog requests receive the typed mismatch without running the catalog hook, then verifies the same owner rebuilds and returns catalog and auth facts.
Findings None None.
Security None None.

How this fits together

Prepared model catalog workers rebuild provider, plugin, and authentication facts for one agent generation. Gateway catalog and authentication reads use this owner, which serializes requests through a worker thread before publishing facts to later agent dispatch.

flowchart LR
  A[Gateway catalog or auth read] --> B[Prepared generation owner]
  B --> C[Single-worker task pool]
  C --> D[Worker rebuilds catalog facts]
  D --> E{Generation matches?}
  E -->|yes| F[Return catalog or auth facts]
  E -->|no| G[Fence and retire worker pool]
  G --> H[Later request starts fresh worker]
Loading

Before merge

  • Resolve merge risk (P1) - A persistent environmental cause of fingerprint drift still rejects one request per newly started worker; that is safer than publishing foreign generation facts, but the underlying drift remains tracked by prepared-model-runtime fails closed on transient generation churn: one fingerprint drift permanently wedges the gateway; owner-commit race silently drops messages #127710.
  • Resolve merge risk (P1) - Two exact-head checks are reported failed and one is still in progress; their causes are not included in the review context, so they must be resolved or confirmed unrelated before merge.
  • Resolve merge risk (P1) - This bug repair adds net 57 production lines alongside 206 test lines; the separate typed result and pool-reset lifecycle are justified because the previous permanently closed pool had no mismatch-only recovery boundary.
  • Complete next step (P2) - Resolve or confirm unrelated the failed exact-head PR context and compact checks, then wait for the in-progress exact-head check before merge.
Agent review details

Security

None.

PR surface

Source +57, Tests +206. Total +263 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 90 33 +57
Tests 1 206 0 +206
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 296 33 +263

Review metrics

Metric Value Why it matters
Production versus regression coverage production +57 net; tests +206 The new lifecycle boundary is materially larger than the original permanent-close path, while the focused integration suite covers mismatch, queued-call fencing, and same-owner recovery.

Merge-risk options

Maintainer options:

  1. Accept bounded mismatch failure (recommended)
    Keep the scoped fail-closed mismatch result and land the recovery once exact-head checks are resolved, while the environmental drift continues under the linked issue.
  2. Pause for root-cause diagnosis
    Defer this PR if maintainers require a remedy for persistent fingerprint drift rather than recovery from its permanent worker wedge.

Technical review

Best possible solution:

Keep the typed mismatch plus owner-scoped lazy pool: the former permanently terminal pool has no mismatch-only reset point, so a net-neutral alternative would weaken the permanent-close behavior for crashes and supersession. Merge after exact-head checks are green or their failures are shown unrelated, and retain the broader drift investigation in #127710.

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

Yes, from source: current main throws on a worker fingerprint mismatch and permanently closes its pool, while the branch’s real-worker integration fixture injects that mismatch and verifies same-owner recovery. This read-only review did not execute contributor code.

Is this the best way to solve the issue?

Yes. Returning the mismatch without publishing rebuilt facts, fencing it at the pool validator, and resetting only that pool preserves the generation boundary while removing the cached permanent wedge; the existing WorkerTaskPool already provides the required queue fencing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3a5fc8f663d2.

Labels

Label changes:

  • remove merge-risk: 🚨 message-delivery: Current PR review merge-risk labels are merge-risk: 🚨 availability.

Label justifications:

  • P1: The current-main failure can permanently disable catalog and authentication reads used by Gateway before agent dispatch.
  • merge-risk: 🚨 availability: The change alters failure and recovery behavior for a single-worker catalog owner; persistent fingerprint drift remains a bounded request-availability risk.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies an after-fix terminal trace for the changed production owner: a real catalog owner, WorkerTaskPool, and worker thread receive an injected mismatch, fence concurrent work, retire worker 1, then have worker 2 return catalog and authentication facts on the same owner. The source test at the exact head matches that scenario; its temporary CODEX_HOME prevents ambient Codex auth from affecting the fixture.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an after-fix terminal trace for the changed production owner: a real catalog owner, WorkerTaskPool, and worker thread receive an injected mismatch, fence concurrent work, retire worker 1, then have worker 2 return catalog and authentication facts on the same owner. The source test at the exact head matches that scenario; its temporary CODEX_HOME prevents ambient Codex auth from affecting the fixture.

Evidence

What I checked:

  • Current-main failure path: Current main throws while preparing a reconstructed generation whose fingerprint differs, then converts that error into a failed worker result; its owner catches the result error and closes the single pool permanently. (src/agents/prepared-model-catalog.worker.ts:150, 3a5fc8f663d2)
  • Owner and transport boundary: The branch rejects a typed mismatch in the pool validator before normal resolution; WorkerTaskPool closes queued and active work after validator failure, while the owner clears only that pool and retains permanent closure for other failures. (src/agents/prepared-model-catalog-worker.ts:221, 90900cfcdc5e)
  • Boundary regression coverage: The added integration test uses the actual catalog owner, WorkerTaskPool, and worker thread; it verifies queued auth/catalog requests receive the typed mismatch without running the catalog hook, then verifies the same owner rebuilds and returns catalog and auth facts. (src/agents/prepared-model-catalog-worker.mismatch.integration.test.ts:157, 90900cfcdc5e)
  • Gateway caller context: Gateway catalog loading obtains a published owner and optionally refreshes its prepared authentication facts; this establishes why a permanently closed catalog worker affects pre-dispatch control-plane reads. (src/gateway/server-model-catalog.ts:115, 90900cfcdc5e)
  • Current-main history: Recent current-main work repeatedly maintains this catalog-worker and prepared-runtime area, including commits by Peter Steinberger and Jason O'Neal; the PR’s behavior is not present in the current-main file blobs. (src/agents/prepared-model-runtime.build.ts:190, 6c446343df30)
  • Codex HOME isolation contract: The added test isolates CODEX_HOME. Direct sibling source inspection shows Codex treats CODEX_HOME as its user config and auth-file location, so an empty temporary directory prevents ambient Codex configuration or credentials from influencing this fixture; repository ownership of the local mirror could not be independently verified. (codex-rs/login/src/auth/storage.rs:39, 41e22fee981a63b3698df7ed36bad393cda24715)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason O'Neal: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Resolve or document as unrelated the failed exact-head “PR context and evidence” and “checks-node-compact-small-6” checks, then wait for the in-progress exact-head check.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-22T01:22:06.831Z sha 4f288981f9334c3fd6a1e1a5c87ae34899f56ef4 :: needs changes before merge. :: [P1] Reject mismatched catalog generations at the owner boundary
  • reviewed August 23, 2026, 1:11 AM ET / 05:11 UTC sha unknown :: needs changes before merge. :: [P1] Reject rebuilt facts that do not match the owner generation | [P3] Replace the incident narrative with the generation invariant
  • reviewed 2026-08-24T07:20:09.530Z sha 4f288981f9334c3fd6a1e1a5c87ae34899f56ef4 :: needs changes before merge. :: [P1] Preserve the catalog-generation boundary on mismatch | [P3] Replace incident narrative with the generation invariant
  • reviewed August 27, 2026, 6:59 PM ET / 22:59 UTC sha unknown :: needs changes before merge. :: [P1] Reject mismatched facts at the generation owner | [P3] Replace incident narrative with the generation invariant
  • reviewed 2026-08-27T22:59:57.185Z sha 4f288981f9334c3fd6a1e1a5c87ae34899f56ef4 :: needs historical verification review before merge. :: [P1] Reject mismatched facts at the generation owner | [P3] Replace incident narrative with the generation invariant
  • reviewed 2026-09-02T12:27:54.510Z sha 77548ca88f43104341cc7621e5523363b5ef8dc5 :: needs real behavior proof before merge. :: [P1] Retire the pool before resolving a mismatch request
  • reviewed 2026-09-02T12:54:21.394Z sha 77548ca88f43104341cc7621e5523363b5ef8dc5 :: needs real behavior proof before merge. :: [P1] Fence the pool before resolving a mismatch
  • reviewed 2026-09-02T17:27:18.854Z sha c19495d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@kiranvk-2011
kiranvk-2011 force-pushed the fix/catalog-worker-fingerprint-mismatch-fail-open branch from 4f28898 to 77548ca Compare September 2, 2026 12:20
@kiranvk-2011

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Both findings from the last review are addressed on the branch (rebased on current main):

  • [P1] Reject mismatched facts at the generation owner — the worker no longer proceeds (or throws) on a fingerprint mismatch. It returns a typed generation-mismatch outcome with both fingerprints and publishes no facts; ok replies exist only for the owner's generation. The owner (createPreparedModelCatalogWorker) retires that worker and throws PreparedModelCatalogGenerationMismatchError. Retirement is worker-scoped, so the next request rebuilds a worker from the same lifecycle plan instead of replaying a cached terminal error — the original wedge is gone without weakening the generation boundary.
  • [P3] Incident narrative replaced with short invariant comments at both sites.
  • Injected-mismatch regression added to prepared-model-catalog-worker.integration.test.ts: real worker, injected owner fingerprint → typed error carrying the true reconstructed fingerprint, catalog hook never ran, second request spawns a fresh worker. Fails on pre-fix main and on the earlier fail-open revision.

Acceptance criteria run locally: integration suite 23/23 passing; pnpm check:changed on the four changed files green.

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

kvk-code and others added 2 commits September 2, 2026 16:20
…ad of wedging the owner

A worker whose reconstructed fingerprint differs from its owner's generation
used to throw, and the worker cached that rejection for its lifetime, so one
drift killed every later request on the gateway until restart.

The worker now returns a typed `generation-mismatch` outcome carrying both
fingerprints and publishes no facts; `ok` replies exist only for the owner's
generation. The owner retires that worker and throws
PreparedModelCatalogGenerationMismatchError. Retirement is worker-scoped, so
the next request rebuilds a worker from the same lifecycle plan rather than
replaying a cached terminal error. Superseded, crashed and timed-out workers
keep their permanent-close semantics.

Adds an injected-mismatch regression on the real worker boundary.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HspGQJnLGMcam6jCottM9v
…ch resolves

A mismatch reply was handled only after pool.run() resolved, so with maxWorkers=1 a
queued auth or catalog request could dispatch on the retiring worker and then be rejected
through the generic catch, which latched terminalError and recreated the permanent wedge
under concurrent use.

Reject the typed generation-mismatch reply inside validateResult instead. The pool closes
before any successor dispatches, every queued request rejects with the same typed error,
and the owner drops the fenced pool without latching so the next request rebuilds a
worker from the same lifecycle plan.

The mismatch coverage moves to a focused suite
(prepared-model-catalog-worker.mismatch.integration.test.ts) with its own slim fixture,
keeping the main integration file at its max-lines budget. It adds a concurrent
auth+catalog regression that drifts the owner capture for the first spawn only and asserts
typed rejections, no successor dispatch, and full recovery on the rebuilt worker.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HspGQJnLGMcam6jCottM9v
@kiranvk-2011
kiranvk-2011 force-pushed the fix/catalog-worker-fingerprint-mismatch-fail-open branch from 77548ca to c19495d Compare September 2, 2026 17:19
@kiranvk-2011

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The remaining P1 and the proof ask are addressed on c19495d2f6 (2 commits, rebased on main f1ae53b736):

  • [P1] Fence the pool before resolving a mismatch: the typed generation-mismatch reply is now rejected inside validateResult, so the pool closes before any queued successor can dispatch on the retiring worker; that successor rejects with the same typed error and the owner's catch path drops the fenced pool without latching terminalError. The previous head's wedge (queued successor → generic catch → latched terminal error) is reproduced and fixed in a new concurrent auth+catalog regression that drifts the owner capture for the first spawn only and asserts recovery on the same owner. Mismatch coverage lives in a focused prepared-model-catalog-worker.mismatch.integration.test.ts; the main integration file is untouched.
  • Real behavior proof: the PR body now carries an after-fix boundary trace from the real owner + real worker thread on an isolated state dir (concurrent requests typed-rejected, one worker retired, the same owner rebuilds a worker and serves 231 catalog entries + auth), plus the same harness against the previous head showing the latched-error wedge.
  • Acceptance: both integration suites 24/24, worker-task-pool.test.ts 9/9, check-changed on the four files exit 0.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@obviyus obviyus changed the title fix(agents): catalog worker fails open on fingerprint mismatch (was: one transient drift permanently wedges the gateway) fix(agents): recover catalog worker after generation mismatch Sep 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 3, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Sep 3, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 3, 2026
@obviyus
obviyus merged commit e5647b5 into openclaw:main Sep 3, 2026
392 of 399 checks passed
@obviyus

obviyus commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks @kiranvk-2011!

Proof: Current main repeated one transient catalog fingerprint mismatch on every later request from the same owner. Exact head 90900cfcdc5e2affa5217ed06bf5d3558da09d57 passed 34 real catalog-worker, lifecycle, and pool tests. The recovery test retired worker 1, blocked its queued successor, then used worker 2 for catalog and authentication facts.

  • Bug: One mismatch left the worker reusing a rejected preparation promise, so later Gateway catalog and authentication reads kept failing.
  • Fix: The worker returns a typed mismatch without facts, the owner fences and retires that pool, and the next request creates a fresh worker.
Before After
One transient mismatch permanently wedged the owner. The mismatched request fails closed, and later requests recover on a fresh worker.

CI: Attempt 2 passed every selected job except an inherited service-relay timing test. Current main commit c3a495d198fe16e5a698132983ee1d7f7117d91a removes that test, and this PR did not touch its file or wait helper.

run: 33749598977 attempt: 2
failed: checks-node-compact-small-6 job=100636499901 conclusion=failure
check: openclaw/ci-gate

vincentkoc added a commit that referenced this pull request Sep 3, 2026
* commit '13b1f71c7010baaf2394555198e2fc04bef03586': (283 commits)
  fix(ui): retire stale MCP feedback across context changes (#128490)
  fix(agents): clarify set-identity workspace output (#126320)
  fix(auth): preserve OAuth metadata during session SDK refresh (#127988)
  fix(agents): recover catalog worker after generation mismatch (#127712)
  fix(memory-wiki): reject out-of-range claim confidence (#125656)
  ci: remove redundant contract runs and costly test work (#137220)
  fix(release): assert the Codex CLI pin the candidate declares (#137136)
  test(voice-call): reuse shared guards and deferred gates (#137262)
  fix(cron): isolate scheduler-disabled shared-store writes (#131733)
  fix(telegram): surface allowed custom reactions in react guidance (#129817)
  test(infra): reuse the shared npm call presence guard (#137254)
  fix: generated images disappear after failed tool calls (#131226)
  fix(docs): match source anchor checks to published sections (#137157)
  fix(backup): preserve audit capture across slow snapshots (#130962)
  fix(release): preserve legacy gh log reads (#137016)
  fix(memory-core): make forget rewrites atomic (#131383)
  fix(agents): write settings atomically (#131431)
  fix(plugins): keep the memory indexing runtime with the selected slot owner (#131779)
  fix(ci): pin iOS screenshot evidence to workflow revision (#136334)
  test(logging): remove redundant stderr spy casts (#137238)
  ...

# Conflicts:
#	scripts/e2e/lib/codex-release-package-assertions.mjs
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…aw#127712)

## What Problem This Solves

A transient prepared model catalog fingerprint mismatch can permanently wedge one worker. Every later catalog or authentication request on that owner then repeats the cached preparation failure.

The failure reaches Gateway catalog and authentication reads used before agent dispatch.

## Root cause

The worker caches one `preparedGeneration` promise for its lifetime. A fingerprint mismatch rejects that promise. The parent receives the failure as a normal worker result, so it keeps the same worker and reuses the same rejected promise.

## Fix

- Return a typed generation-mismatch result before any catalog or authentication facts leave the worker.
- Reject that result in the pool validator so the pool closes before queued work can dispatch.
- Drop only the mismatched pool and let the same lifecycle owner create a new worker on the next request.
- Keep crashes, timeouts, and superseded generations permanently closed.
- Isolate the real-worker regression from ambient Codex authentication.

A persistent mismatch still rejects one request per cold worker. This bounded fail-closed behavior is intentional: it preserves the owner generation and avoids publishing foreign facts while the separate environmental drift remains under diagnosis.

Production change: +90/-33 lines, net +57. The remaining growth defines the typed mismatch result and the mismatch-only pool replacement. The maintainer pass removed the second terminal-error cache and the test-only error export.

The separate owner-publication race from openclaw#127710 has already landed through openclaw#130856. This pull request stays focused on the catalog-worker wedge.

## Evidence

Current main baseline: `ef3a75f0d4a8eb2b75e4f1c20fdc4de7d8232b95`

Red:

```text
node scripts/run-vitest.mjs src/agents/prepared-model-catalog-worker.wedge.proof.test.ts
1 failed, 1 passed
recovery on the same owner failed with:
prepared model catalog worker reconstructed a different runtime generation
```

The control case created a fresh owner from the unchanged plan and passed. This proves the fixture was valid and the existing worker was wedged.

Green on `90900cfcdc5e2affa5217ed06bf5d3558da09d57`:

```text
node scripts/run-vitest.mjs src/agents/prepared-model-catalog-worker.integration.test.ts src/agents/prepared-model-catalog-worker.mismatch.integration.test.ts src/infra/worker-task-pool.test.ts
3 files passed, 34 tests passed
```

The transient case uses the real catalog owner, `WorkerTaskPool`, and worker thread. It proves queued work does not run on the retired worker, then proves worker 2 serves catalog and authentication facts on the same owner.

Original diagnosis and repair by @kiranvk-2011.

## CI note

Exact-head CI passed all selected jobs except `checks-node-compact-small-6`. Its unchanged `agent-exec` service-relay timing test failed twice while waiting for a fake CLI process ID. Current main commit `1324822b2242ad2a16ab29f7ade9cc9f527f8c97` removes that test, and this pull request does not touch its file or wait helper, so the squash merge cannot restore the failure. The latest PR context and evidence run passed after the required headings were restored.

Co-authored-by: kiranvk2011 <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

3 participants