Skip to content

fix: honor fresh provider catalog discovery - #130412

Merged
steipete merged 2 commits into
mainfrom
codex/catalog-cache-lifecycle-r9
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/catalog-cache-lifecycle-r9

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users refreshing an existing llama.cpp server's model discovery could receive the previous anonymous catalog instead of a fresh response. The shared cache reused a warm entry even when the caller explicitly disabled caching. Expired catalog loads could also remove a newer replacement entry when they subsequently failed or were rejected by their cache predicate.

Why This Change Was Made

Resolve the existing cache-expiry policy before reading any cache entry. Uncached loads now run independently and never read, write, or remove a cached entry. Cached loads use one cleanup path bound to the exact entry they created, so late completion cannot discard newer work, even when loaders reuse the same Promise.

This repairs the shared owner instead of restoring a llama.cpp-only bypass. No SDK exports, signatures, configuration, auth policy, positive TTL defaults, or persistent storage change. Production LOC: +18/-19 (net -1); tests: +122/-13 (net +109). The old cold-cache mocked credential test is replaced by stronger real HTTP ordering coverage.

User Impact

Explicit catalog refreshes and credential-scoped llama.cpp discovery fetch their own current model list. Ordinary cached discovery still reuses its original entry; late failures no longer cause unnecessary reloads.

Evidence

Reviewed head: 09c4c344530e6a1f84d51358eea60d8bfde20b59.

  • Against unchanged main 0569c6ea6b401ac15cbffa171be664d8dcf08f52, seven new shared-cache regressions failed: warm-cache bypass with success, rejection, or synchronous throw; and expired-entry cleanup after rejection, predicate rejection, predicate throw, or a replacement reusing the same Promise.
  • Three real localhost HTTP regressions also failed before the repair: anonymous discovery followed by API-key discovery, authorization-header discovery, or an explicit refresh returned the old model list without fetching again. All three now fetch the current list and preserve the ordinary anonymous cache entry. These use a controlled HTTP fixture; no real model was loaded or inference performed.
  • 211 tests passed across 10 files, including shared live-catalog consumers, llama.cpp external-server discovery/setup/auth/model/stream paths, and Ollama discovery.
  • Exact changed source and tests passed the canonical type-aware lint wrappers. OPENCLAW_OXLINT_SKIP_PREPARE=1 avoided regenerating unrelated package-boundary artifacts; it did not disable lint rules. Hosted CI must still verify full selected type/build gates.
  • Fresh structured Codex review through P2: no actionable findings, confidence 0.95. Two independent code reviews also found no blocking issues.
  • Hosted test types caught an unsupported direct Promise.withResolvers use in the new test fixture. The follow-up uses the existing shared deferred helper without changing production code or assertions. All 26 focused cache/discovery tests, typed lint, formatting, fresh P2 review (0.96), and independent review passed after correction. The owning local test-type shard no longer reports that error, but still fails on unrelated shared-install dependency-version drift; full local types are not claimed green. Fresh exact-head hosted CI is required.
  • Landing check: full CI run 33026918426 passed on the reviewed head, including openclaw/ci-gate; all 203 check runs are terminal without failures. The latest ClawSweeper rank-up request is addressed by a fresh clean merge-tree against main at 35adcc6c6f3b and confirmation that the touched owner/caller/test paths have not changed since the reviewed base. No rebase is needed solely for behind-main drift. Its stored-data warning is not applicable: the change affects an in-memory Map and test fixtures, not persisted state or a schema. Its live-proof excerpt reports all five tests passed, although the outer harness marked its output assertion failed; our independently completed loopback runs are the behavior proof.

Commands:

env -u LM_API_TOKEN -u OLLAMA_API_KEY OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-r9-catalog-sibling-cache node scripts/run-vitest.mjs src/plugin-sdk/provider-catalog-shared.test.ts src/plugin-sdk/provider-catalog-live-runtime.test.ts extensions/llama-cpp/src/external-server extensions/ollama/src/discovery-shared.test.ts --configLoader runner
OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/plugin-sdk/provider-catalog-shared.ts src/plugin-sdk/provider-catalog-shared.test.ts
OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/llama-cpp/src/external-server/discovery.test.ts
git diff --check

Provenance: the generic cache ordering predates stable v2026.7.1; the external llama.cpp path was not present in that tag. Its explicit bypass was removed in #126434 (0135046830ae6887996dc35e91594077cfbe5745, authored and merged by @steipete on August 19, 2026), exposing the older shared-cache defect. The shallow history does not establish the original introduction of the generic defect.

AI-assisted.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 26, 2026 21:10
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:34 PM ET / August 27, 2026, 00:34 UTC.

ClawSweeper review

What this changes

The PR makes explicit uncached provider-catalog discovery fetch independently and prevents stale cache work from removing a newer replacement entry.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer landing: the shared cache repair is coherent and has no discrete source-level finding, but exact-head CI and a current-main merge refresh remain outstanding.

Priority: P2
Reviewed head: 09c4c344530e6a1f84d51358eea60d8bfde20b59

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with behavior-level coverage, pending exact-head merge and CI confirmation.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies this as a member-authored PR, so the external-contributor proof gate does not apply; its body nevertheless describes a loopback HTTP after-fix regression run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies this as a member-authored PR, so the external-contributor proof gate does not apply; its body nevertheless describes a loopback HTTP after-fix regression run.
Evidence reviewed 5 items Shared cache owner: The helper resolves expiry before reading the map; an uncached call returns directly, while cleanup deletes only the exact entry it created.
Affected caller and real transport coverage: llama.cpp deliberately requests zero TTL for credential-scoped or explicit-refresh discovery, and the added test exercises the production discovery function against a loopback HTTP server.
Sibling consumers: Other provider paths use the same helper with keys that include their relevant endpoint and credential scope, so centralizing the lifecycle repair avoids a llama.cpp-only workaround.
Findings None None.
Security None None.

Live Verification

Command: pnpm test extensions/llama-cpp/src/external-server/discovery.test.ts

Result: FAIL (failed) — step 1 run pnpm test extensions/llama-cpp/src/external-server/discovery.test.ts: previous terminal command was still running after 30 seconds: "pnpm test extensions/llama-cpp/src/external-server/discovery.test.ts"

$ node --import tsx scripts/test-projects.mts extensions/llama-cpp/src/external-server/discovery.test.ts
[test] starting test/vitest/vitest.extensions.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130412-lvMuco/target

 ✓  extensions  extensions/llama-cpp/src/external-server/discovery.test.ts (5 tests) 592ms
     ✓ fetches 'API key' discovery after an anonymous catalog was cached  532ms

 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  00:35:13
   Duration  11.18s (transform 8.31s, setup 976ms, import 9.24s, tests 592ms, environment 0ms)

[test] passed 1 Vitest shard in 17.82s

Assertions:

  • FAIL expect_output: fetches API key discovery after an anonymous catalog was cached

How this fits together

Provider plugins use the shared live-catalog cache while discovering models from endpoints. Discovery results feed plugin setup and model selection, including existing llama.cpp servers.

flowchart LR
  A[Provider discovery request] --> B[Shared catalog cache]
  B --> C{Caching enabled?}
  C -->|No| D[Fresh endpoint request]
  C -->|Yes| E[Cache entry lifecycle]
  D --> F[Discovered models]
  E --> F
  F --> G[Plugin setup and model selection]
Loading

Before merge

  • Resolve merge risk (P1) - The checkout cannot materialize the supplied current-main SHA or PR base because the promisor remote cannot resolve; refresh the clean merge result and exact-head checks before landing the shared cache semantic change.
  • Complete next step (P2) - No repair lane is needed; a maintainer should refresh the merge result and await exact-head CI before landing.
Agent review details

Security

None.

PR surface

Source -1, Tests +109. Total +108 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 18 19 -1
Tests 2 122 13 +109
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 140 32 +108

Review metrics

Metric Value Why it matters
Production versus tests production -1 net; tests +109 net The reported diff absorbs the behavior change in the shared cache owner and adds ordering and loopback-discovery regression coverage.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/llama-cpp/src/external-server/discovery.test.ts, persistent cache schema: src/plugin-sdk/provider-catalog-shared.test.ts, serialized state: extensions/llama-cpp/src/external-server/discovery.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh merge and checks (recommended)
    Rebase or merge current main, then require the selected checks on the exact resulting head before landing the shared provider-cache behavior.

Technical review

Best possible solution:

Retain the owner-level cache lifecycle repair and land it once the rebased or merged exact head has green selected checks.

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

Yes, source-reproducible: the added deterministic loopback HTTP test warms anonymous discovery, changes the endpoint model, then verifies credentialed and explicit-refresh calls fetch anew. This read-only partial clone did not execute that test.

Is this the best way to solve the issue?

Yes, subject to exact-head validation: repairing the generic cache owner is more maintainable than restoring a llama.cpp-only bypass, and the stale-entry identity check covers replacement work.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0b60846fa421.

Labels

Label justifications:

  • P2: This is a bounded provider-discovery correctness repair with limited blast radius.
  • merge-risk: 🚨 compatibility: The shared helper governs existing provider catalog discovery, so its cache semantics can affect installed plugin behavior.
  • 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: The repository context identifies this as a member-authored PR, so the external-contributor proof gate does not apply; its body nevertheless describes a loopback HTTP after-fix regression run.

Evidence

What I checked:

Likely related people:

  • steipete: Current-head blame attributes the shared-cache repair to this author, and the related merged llama.cpp provider refactor is also attributed to them in the supplied PR context. (role: recent feature owner; confidence: medium; commits: 09c4c344530e, 0135046830ae; files: src/plugin-sdk/provider-catalog-shared.ts, extensions/llama-cpp/src/external-server/discovery.ts)

Rank-up moves

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

  • Refresh the merge result against current main and obtain green selected checks for that exact head.

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-26T21:17:47.953Z sha f9aab4d :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 4c4c06a into main Aug 27, 2026
209 checks passed
@steipete
steipete deleted the codex/catalog-cache-lifecycle-r9 branch August 27, 2026 00:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* fix: honor fresh provider catalog discovery

* test: use compatible deferred catalog fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: llama-cpp maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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