Skip to content

fix: stop catalog renewal from stalling agent runs - #157459

Merged
steipete merged 5 commits into
mainfrom
codex/catalog-lifecycle-redesign
Sep 24, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/catalog-lifecycle-redesign

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #157107

What Problem This Solves

Fixes agent runs stalling behind catalog renewal when ordinary chat, status, or session reads repeatedly restart discovery on fleet Gateways.

User Impact

Selected native models can acquire metadata while provider discovery is busy. Ordinary observations stay passive; model-inventory requests can renew expired rows in the background. Healthy providers publish updates even if another provider or native catalog hook fails. Saved rows remain available with a refresh warning, and unresolved SecretRefs still fail closed. A scoped refresh also preserves other providers' freshly refreshed credentials.

No new settings, dependencies, or database migration are required. The shipped SDK getter retains background-renewal behavior. Database downgrade/pre-migration backups remain outside this repair, and the reporter's exact installation has not been reproduced directly.

Why This Change Was Made

The catalog owner batches provider renewal and publishes provider/native results independently. Workers share registrations for matching configuration, environment, metadata, and loader workspace while keeping credentials request-local. Per-task workspace reconstruction, the separate in-process worker execution path, duplicate auth preparation/coalescing, parallel draft/rollback state, and duplicate catalog getters are removed. Exact native observations are retained separately from API donor metadata; expired generations release their retained references.

Production changes are 1,261 additions / 1,270 deletions, net −9 lines (plus two lines declaring the test build prerequisite). Thanks @mmartoccia for the report and production trace.

Evidence

  • Real-worker tests cover multiple agents and expiry cycles, native admission while provider renewal is held, both publication orders, credential isolation, crash recovery, generation collection, and SecretRef provenance. Directory and SecretRef tests now use the actual worker transport, with positive observation controls.
  • After the final observer and recovery repairs, 115 tests across six files passed. The preceding worker/auth/publication run passed 150 cases and caught one recovery ordering regression; that was repaired and the entire pool suite rerun. An earlier broader sweep passed 510 tests across 35 files.
  • Negative controls reproduce the original native stall, read-triggered extra acquisitions, loss of a selected native model, loss of successful API results when native hooks fail, stale API transport, dropped untagged harness models, and an unrelated refresh reverting fresh CLI credentials to expired saved credentials.
  • Core and agent-test typechecking and targeted typed lint passed; independent review findings are resolved. The final real-worker fleet case passed three expiry cycles with eight completed tasks, zero failed tasks, and unchanged registrations. Native admission proceeded before blocked provider renewal was released.
  • Final changed-file checks passed, including all 25 core test type graphs, extension/script typechecking, dead-export scans, typed lint and structural guards. The final installed-package upgrade from [email protected] also passed the legacy-operator-state scenario: two existing agents, saved operator state and actual agent turns against a synthetic HTTP provider before/after upgrade. ClawRouter loopback E2E passed all three tests, and exact-head CI passed on 2f2d7aa81289ae954f6ff1c270114bae0ad36c82.

An already-running explicit full acquisition remains coalesced through native settlement. Expiry is demand-renewal metadata, not a strict maximum-age guarantee; selected-native acquisition uses its independent owner and does not suppress provider renewal.

Final-revision CI follow-through

The clean Node 24.19 fixture first reproduced a worker SDK load failure with no root build artifacts: its runtime-build prerequisite was missing from the test plan. Declaring that prerequisite makes the same clean environment pass all three cycles: eight HTTP requests, three registrations, eight completed tasks and zero failures. Test body 1.47s; cold runtime build 49.2s; build plus test wrapper 74.0s. Clean before/after run. Its verified source tree (8252309b2a0d017d4f4ef110d6d86b18708137e8) is the committed tree in 9a5a5bd2a5d5baec878b0add239df4c6ea1c3176. The test now runs in the runtime-artifact CI lane.

The auth helper composes in-memory profile snapshots; it changes no persistent writer, schema, version, or migration contract. The final installed-upgrade gate is now satisfied. CI also caught and corrected a test-file size violation, an HTTP fixture type annotation, lint issues, and an obsolete assertion that withheld provider publication until native completion.

Installed upgrade on the final source tree

Blacksmith Testbox run, lease tbx_01m3afxysfgxq14pje7svd6k3x: [email protected] OPENCLAW_UPGRADE_SURVIVOR_SCENARIOS=legacy-operator-state pnpm test:docker:published-upgrade-survivor passed. The source/tree was verified before execution; the full package build and tarball validation passed (1,263s), followed by the installed-state scenario (349s). Command exit 0; total command time 29m53s. The one-shot lease is verified completed; its Actions run may show cancelled during successful lease cleanup.

Commit 2f2d7aa81289ae954f6ff1c270114bae0ad36c82 only refreshes CI after the unrelated main wrapper inventory fix 5b210a8eea75; its source tree is identical to tested commit 9a5a5bd2a5d5baec878b0add239df4c6ea1c3176. This evidence exercises an installed upgrade with existing multi-agent state. It does not reproduce the reporter's exact installation or change database downgrade/backup policy.

Final validation and review disposition

Changed checks and ClawRouter E2E completed on the same verified source tree: all changed checks passed, cold runtime build passed (22m53s), and all three ClawRouter cases passed (39.44s test runner; cold build plus test wrapper 24m22s). After those completed, the subsequent standard upgrade rebuild was intentionally stopped because the separate preserved-state installed upgrade above had already passed; no result is claimed for that redundant scenario.

ClawSweeper revision 4 has no code or security findings. Its requested final installed upgrade and rank-up move are now covered above. The auth snapshot helper does not change persisted data, and the published upgrade supplies the requested compatibility evidence. No code changed after the independently reviewed and tested tree; the last commit only refreshed the CI merge context. The reporter's database downgrade/backup concern remains a separate follow-up in #157107.

Keep observation passive, batch provider discovery, and acquire selected native
models independently. Reuse worker registrations while preserving request-local
auth and exact publication ownership. Remove duplicate worker execution, auth
preparation, lookup, and draft publication paths.

Retain exact native observations and scoped credential provenance across
renewals; release superseded generations and join shared worker recovery.
No configuration, dependency, or database migration changes.

Refs #157107. Thanks @mmartoccia for the report and production trace.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL labels Sep 24, 2026
@steipete
steipete marked this pull request as ready for review September 24, 2026 17:57
@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 2f2d7aa81289ae954f6ff1c270114bae0ad36c82
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/prepared-model-runtime-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/prepared-model-runtime.catalog-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/prepared-model-runtime.synthetic-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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. 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. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 4:24 PM ET / 20:24 UTC (Revision 4).

ClawSweeper review

What this changes

The branch makes model-catalog observations passive, renews provider inventory through a shared worker, and lets selected native models load while provider renewal is busy.

Regression provenance

Possible regression — suspected (failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this PR open. Current main still couples catalog renewal to reads and native selection, while the branch has credible real-worker evidence for the repair. The final revision still lacks the installed-upgrade check needed for the reported v2026.9.6 fleet failure.

Priority: P0
Reviewed head: 2f2d7aa81289ae954f6ff1c270114bae0ad36c82

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-level repair has strong real-worker fault coverage and no established patch defect, with published-upgrade safety still unresolved.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed production catalog owner is exercised through a real worker, plugin discovery, and a loopback HTTP client with provider discovery held; the reported after-fix run admits native loading, completes eight requests over three renewals, and observes agent-specific Authorization headers. The linked CI run ended cancelled and its logs were inaccessible through this review proxy, so the reported trace could not be independently inspected. No stored-data contract changes were identified; final installed-upgrade proof remains a separate compatibility gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed production catalog owner is exercised through a real worker, plugin discovery, and a loopback HTTP client with provider discovery held; the reported after-fix run admits native loading, completes eight requests over three renewals, and observes agent-specific Authorization headers. The linked CI run ended cancelled and its logs were inaccessible through this review proxy, so the reported trace could not be independently inspected. No stored-data contract changes were identified; final installed-upgrade proof remains a separate compatibility gate.
Evidence reviewed 8 items Current main still has the renewal coupling: At the fetched main revision, the catalog access path still invokes expiry renewal from its read path and routes native selection through full catalog acquisition. The PR changes both paths, so its central repair remains necessary.
Provider and native acquisition have separate owners: Provider work publishes its accepted result before optional native discovery; selected native discovery has its own pending operation and merges against the latest provider publication.
Credential boundary in the worker: Each worker request restores its own configuration and synthetic-auth facts, refreshes the selected agent’s auth store, and builds credentials for that request before provider discovery.
Findings None None.
Security None None.

How this fits together

The prepared model catalog turns plugin discovery and each agent’s configuration and credentials into published model and authentication facts. Agent runs, Gateway model listings, and chat metadata consume those facts.

flowchart LR
A[Agent config and credentials] --> B[Catalog owner]
B --> C{Inventory request or observation}
C -->|Renew| D[Shared provider worker]
C -->|Read| F[Published catalog]
B --> E[Selected native loader]
D --> F
E --> F
F --> G[Agent runs and model views]
Loading

Before merge

  • Resolve merge risk (P1) - An existing v2026.9.6 multi-agent installation could still stall during or after upgrade into the shared worker lifecycle; the final revision has no recorded installed-upgrade result using preserved operator state.
  • Complete next step (P2) - Record a final-revision installed upgrade from published v2026.9.6 using preserved multi-agent operator state, showing prompt agent-run admission, inventory renewal, and correct credential ownership.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -9, Tests +1003, Docs +13, Other +2. Total +1009 across 62 files.

View PR surface stats
Area Files Added Removed Net
Source 20 1261 1270 -9
Tests 38 1265 262 +1003
Docs 3 25 12 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 62 2553 1544 +1009

Review metrics

Metric Value Why it matters
Production versus test footprint production +1261/−1270 (net −9); tests and support +1265/−262 (net +1003) The runtime redesign does not grow production code overall; most added lines exercise worker and renewal boundaries.

Stored data model

Persistent data-model change detected: serialized state: src/agents/prepared-model-runtime.catalog-auth.ts, unknown-data-model-change: src/agents/prepared-model-runtime.catalog-auth.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify the published upgrade (recommended)
    Upgrade a preserved multi-agent v2026.9.6 installation to this final revision and record agent-run admission, renewal, and credential ownership before merge.

Technical review

Best possible solution:

Keep one catalog publication owner, retain request-local credentials and passive observations, and land after a published-version upgrade shows prompt run admission and correct renewal on existing multi-agent state.

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

Yes, for the controlled failure path: current-main source couples expiry renewal and native selection, and the PR reports negative controls against a real-worker fleet fixture. The reporter’s exact installation was not rerun.

Is this the best way to solve the issue?

Yes in direction: the existing catalog owner handles renewal and publication while selected native loading proceeds independently. Published-version upgrade safety remains to be shown.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The linked release report describes a Gateway that connects channels but cannot admit agent runs.
  • merge-risk: 🚨 compatibility: The changed shared-worker lifecycle still needs a final-revision upgrade from the published release with existing operator state.
  • merge-risk: 🚨 availability: An upgrade regression in catalog renewal could again hold runtime leases and make agent runs unavailable.
  • 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 (linked_artifact): The changed production catalog owner is exercised through a real worker, plugin discovery, and a loopback HTTP client with provider discovery held; the reported after-fix run admits native loading, completes eight requests over three renewals, and observes agent-specific Authorization headers. The linked CI run ended cancelled and its logs were inaccessible through this review proxy, so the reported trace could not be independently inspected. No stored-data contract changes were identified; final installed-upgrade proof remains a separate compatibility gate.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production catalog owner is exercised through a real worker, plugin discovery, and a loopback HTTP client with provider discovery held; the reported after-fix run admits native loading, completes eight requests over three renewals, and observes agent-specific Authorization headers. The linked CI run ended cancelled and its logs were inaccessible through this review proxy, so the reported trace could not be independently inspected. No stored-data contract changes were identified; final installed-upgrade proof remains a separate compatibility gate.

Evidence

What I checked:

  • Current main still has the renewal coupling: At the fetched main revision, the catalog access path still invokes expiry renewal from its read path and routes native selection through full catalog acquisition. The PR changes both paths, so its central repair remains necessary. (src/agents/prepared-model-runtime.catalog-access.ts:261, 3fadd8c3f74f)
  • Provider and native acquisition have separate owners: Provider work publishes its accepted result before optional native discovery; selected native discovery has its own pending operation and merges against the latest provider publication. (src/agents/prepared-model-runtime.catalog-access.ts:383, 2f2d7aa81289)
  • Credential boundary in the worker: Each worker request restores its own configuration and synthetic-auth facts, refreshes the selected agent’s auth store, and builds credentials for that request before provider discovery. (src/agents/prepared-model-catalog.worker.ts:219, 2f2d7aa81289)
  • Real-worker fault scenario: The new fleet integration test holds provider HTTP discovery, starts native selection before releasing it, exercises both publication orders over three renewals, and checks that every received Authorization header belongs to the requesting agent. The PR body reports eight completed tasks and zero failures from its after-fix run. (src/agents/prepared-model-catalog-worker.native-renewal.integration.test.ts:28, 2f2d7aa81289)
  • Published SDK behavior is retained: The shipped SDK getter is redirected to the renewing inventory operation while internal catalog observations become passive; the branch also retains a focused SDK contract test. (src/plugin-sdk/agent-runtime.ts:37, 2f2d7aa81289)
  • Upgrade gate remains outstanding: The captured PR body says two earlier snapshots passed installed upgrades but explicitly leaves the final-revision upgrade from published v2026.9.6 pending. The previous completed ClawSweeper review identified the same concrete rank-up move; the final product tree is unchanged from that review’s source commit, but no final installed-upgrade result was supplied. (2f2d7aa81289)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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.

  • Record an installed upgrade from published v2026.9.6 to the final revision using preserved multi-agent operator state.

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 (3 earlier review cycles)
  • reviewed 2026-09-24T18:06:32.152Z sha 99284d3 :: blocked before merge. :: none
  • reviewed 2026-09-24T18:23:57.321Z sha a2e4c2b :: blocked before merge. :: none
  • reviewed 2026-09-24T19:34:30.219Z sha 9a5a5bd :: blocked before merge. :: none

Regenerate the PR merge context after 5b210a8 repaired the unrelated wrapper inventory omission. Product tree remains 8252309; the source reviewed and validated for the catalog lifecycle redesign is unchanged.
@steipete
steipete merged commit 11d36eb into main Sep 24, 2026
226 checks passed
@steipete
steipete deleted the codex/catalog-lifecycle-redesign branch September 24, 2026 20:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@goslingmanagment

goslingmanagment commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Adding independent validation of the final PR head 2f2d7aa81289ae954f6ff1c270114bae0ad36c82, now merged. This follows the two-agent released-build evidence in #157107 and the separate worker-budget issue #157575.

Isolated CI run passed on Ubuntu 24.04 / Node 26.7.0, with empty home/state directories and no user/provider credentials:

  • Unmodified PR tests: 6 files / 31 tests passed, Vitest duration 110.08 s. The suites cover native renewal, scope, pool behavior, directory handling, secrets and mismatches.
  • A second run of the existing native-renewal fixture, with test-only capture-identity instrumentation, passed in 20.43 s. No production source was changed; the carrier verifies that against the exact PR head before execution.
  • Two synthetic agents completed 8/8 expected provider requests, retaining their own request-local credentials.
  • Across the baseline and three expiry cycles, the same three registration records remained: two in the calling test isolate and one in a distinct catalog WorkerThread. Every captured entry retained its filename, realpath, device/inode and byte size; the worker entry came from an actual openclaw-plugin-build-* capture directory. The checks therefore exercise a real worker and captured code, rather than a mocked registration counter alone.
  • The entry barrier verified that native selection could start while provider renewal was blocked; the fixture also exercised both completion orders.

The test-only overlay and runner are in the diagnostic commit; the run's catalog-validation artifact contains the complete log and per-cycle identities.

This supports capture/registration reuse for unchanged synthetic plugin inputs across these agent/expiry cycles. It is not a long-duration retained-heap measurement of the external Codex plugin, nor a macOS physical-footprint comparison. The running 2026.9.6 Gateway was not modified. The whole-file allocation burst and ineffective managed-service worker limits remain separate issues (#155728 and #157575).

@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime 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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed size: XL 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