Skip to content

fix: recover catalogs after non-native preparation timeouts - #167693

Open
RomneyDa wants to merge 3 commits into
mainfrom
fix/catalog-preparation-recovery-20261009
Open

RomneyDa wants to merge 3 commits into
mainfrom
fix/catalog-preparation-recovery-20261009

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

CI retention repair — 2026-11-25

The actual CI heap failure was traced to the manifest model-row cache retaining a superseded hosted catalog solely as an identity key. The cache now retains that identity weakly, while keeping the existing snapshot/config identity checks and cached rows. No timeout, permission, dependency, or configuration contract changes.

The existing compiled-worker heap regression failed before this correction; all 11 existing worker heap cases and 26 model-catalog tests now pass. The earlier six custody/recovery cases remain valid unchanged-input proof. Final local ClawSweeper code/security review of 809a029ac296..436da4a0499d completed with no actionable findings. Its note that this small correction adds no new regression is covered by the existing failing CI regression, not a test-count waiver. Scoped lint/format pass. Current-head CI is pending; the prior failed head is not claimed green.

Current head: 436da4a0499d2a36a2c7c64f2d8d6bbaac2ba22d.

Current repair and validation (2026-11-25)

Ported onto main ba6d94ec1771 without restoring the retired native integration suite or deleted directory-verifier helper. The existing custody integration suite now covers both pre-verification and post-verification import stalls through the real compiled Gateway worker and replacement publication owners. Each regression failed on main; all six cases pass with the fix. Recovery is asserted on the new published snapshot, never the superseded failed snapshot. Existing terminal-stall and host-sleep cases remain intact.

Qualified touched-owner type-aware lint, formatting and diff checks pass. Historical Docker/Gateway evidence below is not a new-head live run; current worker integration proof is not full user-visible Gateway/channel end-to-end proof. Hosted CI and that remaining runtime qualification are still required before merge readiness.

Fresh local ClawSweeper finding disposition: its P2 asks to extend terminal handling to native namespace copying/hashing outside reference verification. The reported bug and existing progress channel concern reference verification only. The current recovery owner (prepared-model-runtime.refresh-scope.ts, recoverCatalog) publishes with catalogMode: "static"; it does not automatically replay the failed discovery. Retaining normal recovery for other preparation work is intentional, not an automatic hot retry loop. A persistent filesystem stall may recur on a later discovery demand; this accepted limitation is now documented. Expanding permanent terminal classification and lifecycle instrumentation to every native file operation is outside this repair. No authority, file-admission checks, timeout budgets, dependency versions or configuration were changed.


What Problem This Solves

Fixes: a Gateway model catalog stops recovering when a plugin import times out before native verification starts or after verification has finished.

User Impact

User impact: normal catalog preparation timeouts recover through the existing shared worker lifecycle, while stalled native verification remains terminal for that capture. No configuration, migration, or timeout-budget changes are required.

Why This Change Was Made

The native verifier reports entry, verified-member progress, and exit through one lifecycle owner. The catalog worker forwards start/end immediately and only classifies a timeout as stalled native admission while verification is active. Existing idle deadline renewal still requires new completed members.

Related: #166687. This follow-up does not establish resolution of the separately reported Windows MSIX startup starvation (#167406); preserved Windows replay and caller attribution remain unverified.

Evidence

  • Actual Gateway catalog-worker boundary: eight tests passed, covering imports blocked both before and after verification, ongoing verification progress, terminal verification stalls, and existing catalog refresh siblings. Wrapper wall time: 123.35 seconds.
  • Negative controls reproduced both original wrong terminal classifications before their fixes.
  • Fresh full-context independent P1 review: scoped-clean; no actionable findings.
  • node scripts/check-changed.mjs --staged is running; core typecheck passed and test graph checks are in progress. Cost measurement: pnpm test src/agents/prepared-model-catalog-worker.native.integration.test.ts --maxWorkers=1 passed all eight tests in 111.47 seconds wall; individual test durations totaled 65.15 seconds (86.99-second Vitest invocation including transformation/setup). This existing native-worker suite must exceed 30 seconds to prove the real compiled worker, import boundary, shared catalog recovery, and terminal native admission—not a helper substitute. Fake timers bound the existing preparation deadline and an explicit import barrier replaces real sleeps; no new per-test Gateway/process boot was added. Hosted CI seconds will be recorded once its selected run completes.

@clawsweeper

clawsweeper Bot commented Oct 9, 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 docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 9, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review October 9, 2026 07:45
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The Gateway’s model catalog, its list of available models, recovers after plugin preparation timeouts outside active native-file verification while preserving terminal handling for stalled verification.

Example: A plugin import stalls after native verification finishes.

  • Before: After 180 seconds, catalog preparation is treated as stalled native admission and automatic recovery stops.
  • After: The timeout follows normal worker recovery, and a replacement catalog can publish the native-admitted model.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with no actionable findings; confidence is supported by reported production-boundary tests rather than shipped-entry-point proof.
Proof confidence 🦐 gold shrimp (3/6) This member-authored repair is outside the external-contributor proof gate. Its recorded boundary tests exercise the production catalog owner and worker transport with blocked imports and observe replacement catalog publication; no shipped Gateway run is supplied, and no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Available model choices stop recovering after a plugin import times out outside native verification.
Reason: The existing design distinguishes stalled native verification from ordinary worker failure. This focused repair restores that contract without adding settings or weakening verification.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a useful, source-supported repair that current main still needs, and no actionable patch defect was found. The member-authored item also requires explicit maintainer judgment before closure.

Priority: P2
Reviewed head: 955ad9cbb9432724f3278a0c86d270c4d6a992c4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied validation exercises the compiled catalog worker through a fixture rather than a shipped Gateway invocation.
Agent review details

How this fits together

The Gateway prepares model choices in a worker that loads provider plugins and verifies captured native companion files. The parent receives progress and catalog results, then either retains a terminal verification failure or replaces failed catalog owners.

flowchart TD
  A[Gateway catalog request] --> B[Catalog worker prepares plugins]
  B --> C[Native file verification]
  C --> D[Start, progress, and end notifications]
  D --> E[Parent preparation deadline]
  E --> F{Verification active at timeout?}
  F -->|Yes| G[Record terminal verification failure]
  F -->|No| H[Replace worker and republish catalog]
Loading

Technical review

Best possible solution:

Keep timeout classification at the existing catalog owner, using verifier lifecycle facts to preserve normal recovery and terminal native stalls.

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

Yes, source establishes a clear reproduction path: block plugin import before verification or after its completion until preparation expires, and current main selects the terminal admission error. The PR reports failing negative controls and passing boundary regressions; execution was not repeated during this read-only review.

Is this the best way to solve the issue?

Yes, explicit verifier start/end facts repair the incorrect classification at its existing owner while retaining member-based deadline renewal and the established recovery lifecycle.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 83c8fea9408f.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c19dc23 adds src/agents/prepared-model-catalog-worker.ts:250 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c19dc239d20b; files: src/agents/prepared-model-catalog-worker.ts)
  • matthematics1137: Raw commit 2e418fe adds src/agents/prepared-model-catalog-worker.ts:257 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 2e418fed16b1; files: src/agents/prepared-model-catalog-worker.ts)

PR surface

Source +27, Tests +67, Docs +1. Total +95 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 35 8 +27
Tests 1 70 3 +67
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 107 12 +95

Review metrics

Metric Value Why it matters
Production versus test LOC Production +35/-8; tests +70/-3 The production growth supplies verification lifecycle facts and timeout classification; the larger test delta protects recovery through the real worker boundary.

Labels

Label changes:

  • add P2: Incorrect preparation timeout classification prevents catalog recovery in a bounded plugin-import failure scenario.
  • 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:

  • P2: Incorrect preparation timeout classification prevents catalog recovery in a bounded plugin-import failure scenario.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 9, 2026, 3:53 AM ET / 07:53 UTC.

Copy link
Copy Markdown
Contributor

I ran an isolated foreground-Gateway comparison of parent 19c968701cb6203a4b2eefe5bb817b9ad5d117db and PR head 955ad9cbb9432724f3278a0c86d270c4d6a992c4 on Linux/WSL2 in Docker, using a synthetic catalog provider with native companion files (Node 24.22.1, pnpm 12.7.0).

Each version first published a healthy dynamic catalog. I then used actual SIGSTOP/SIGCONT on the Gateway PID twice: first during the provider catalog hook, then during replacement-worker import before native verification. File barriers established those phases and were removed while the process was stopped. Production clocks and the 180,000 ms deadlines were unchanged.

Version Measured process pauses Two fresh post-thaw models.list(refresh: true) calls
Parent 184.089 s / 184.129 s Both returned UNAVAILABLE with PreparedModelCatalogAdmissionStalledError and retryable: false.
PR head 184.099 s / 184.088 s Both succeeded and returned the newly discovered catalog-after-thaw model.

On the parent, the second timeout stopped automatic catalog recovery. With this PR, it followed ordinary worker-timeout recovery and a replacement worker published the fresh catalog without a plugin reload or Gateway restart. The new model ID was absent from static configuration and the previous catalog, excluding a stale-list success. I waited 15 seconds between the two fresh calls; the original long-running client request was excluded from the verdict.

Separate observation: both versions also logged data-store ownership warnings (OpenClaw state ownership … could not be verified) and Shared-state read and cleanup failed after suspension. Those remain separate from this catalog result; this run does not establish a fix for database ownership or overall Gateway health.

This covers Linux process suspension with a synthetic provider, not physical macOS sleep or suspension during active native verification. No external model requests or real provider credentials were used; external container networking was disconnected during both experiments.

@RomneyDa
RomneyDa force-pushed the fix/catalog-preparation-recovery-20261009 branch from 955ad9c to 809a029 Compare November 25, 2026 20:29

This branch has not been deployed

No deployments
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 P2 Normal backlog priority with limited blast radius. 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.

2 participants