Skip to content

perf(plugins): consolidate provider discovery planning - #133097

Merged
steipete merged 4 commits into
mainfrom
codex/perf-provider-discovery-plan-20260829
Aug 30, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/perf-provider-discovery-plan-20260829

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Provider discovery planned each effective manifest catalog twice, repeating overlay lookup, normalization, sorting and provider construction. Its outer resolver also repeated full-loader scope selection and dispatch.

The same owner could silently omit providers after a discovery entry failed: it discarded all executable entry results but still marked their owners covered. A retained static catalog then prevented the selected or credentialed discarded owners from reaching canonical registration. A direct full-registration control proves their full modules can recover.

Why This Change Was Made

Prepare static providers and runtime-owner IDs together from one effective catalog plan per selected plugin. Carry those facts into one full-loader decision. Delete three private scope wrappers, a single-use filter wrapper, an unused result field and repeated result assembly. Existing metadata, catalog planner and plugin loader remain the owners; no new cache or freshness mechanism.

At the existing all-or-nothing catch, retain only independently valid manifest coverage. The existing scoped loader can then recover discarded executable entries. Static-only owners remain covered even if their optional entry fails; mixed runtime/refreshable owners still load and replace their static descriptors. Successful empty exports retain their existing meaning. This repair adds no production lines to the refactor.

User Impact

Less repeated work in provider discovery, and missing providers recover after a sibling discovery failure. Explicit selection, registration ordering, synthetic auth, input ownership and entries-only behavior remain intact. Selective partial-coverage discovery remains credential-bounded when unscoped; the pre-existing all-empty/no-runtime path still delegates to the ordinary full loader unchanged. No configuration, schema, SDK or protocol change. Release-note context is included below for the release-owned changelog.

One failure-path timing change is deliberate: duplicate planning could incidentally retry a caught local overlay-read failure within the same invocation. One preparation uses the manifest row for that invocation; the unchanged overlay owner clears its failed cache and retries on the next invocation. Recovered content is identical. There is no new retry, network refresh policy or persistent-state change; the failing invocation is not claimed to return identical content.

Evidence

  • Before production edits, the new six-case regression fails four selected/credentialed cases with missing providers; both entries-only controls pass. With the change, all 211 tests across eleven suites pass, including the six regressions, synthetic auth, current snapshots, real catalog workers, auth provenance, planner and overlay behavior. A final test-table lint cleanup preserves every case; its complete 38-test owner suite and the full changed-file gate pass again.
  • Complete-owner real-loader proof rerun at final head 76bdb3566dab1439aa97eaa9ad5cc7e449995dc1: 1,280 cases, with 1,125 unchanged and 155 repaired omissions, plus nine unique direct registration controls. Covers failure first/middle/last, partial/discarded entries, explicit empty and unscoped requests, independent credentials, static/runtime/refreshable and mixed owners, same-owner static plus failed entry, and successful empty/invalid exports. Unchanged cases retain ordered payload equality; repaired cases use an independent scope/ownership oracle. All observations match the original evidence; 52 root inputs (including six tests) and 87 installed loader-package files stayed unchanged. No lightweight retry is introduced. This addresses ClawSweeper's requested exact-head real-loader rank-up proof.
  • The performance-only precursor passed 2,444 differential comparisons and 136 real-loader comparisons. Those establish the consolidation separately; they are not claimed as final equality counts for the intentional recovery fix.
  • Independent full-owner review and structured Codex review found no unresolved issue; the structured review uses its configured P0 threshold. Native model contracts were read directly from the pinned Codex source. Current main's thirteen direct discovery dependencies match the measured baseline.
  • Production +72/−151 = −79 lines; meaningful regression tests +58; no root changelog change. No generated/lockfile changes.

Two fresh final-source benchmark processes used opposite starting orders, seven alternating samples per workload, and all raw samples. Imports, fixture preparation, warmup and calibration were outside timing; complete uninstrumented owners used the actual planner and normalizer. All 20 recorded source/dependency/package hashes stayed unchanged.

Warm static discovery Before-first: before → final Candidate-first: before → final
1 plugin × 4 models 14.407 → 9.628 µs 14.878 → 9.147 µs
1 plugin × 128 models 0.23622 → 0.12704 ms 0.23549 → 0.12563 ms
32 plugins × 16 models 1.08881 → 0.60410 ms 1.08037 → 0.59909 ms
32 plugins × 64 models 4.10367 → 2.25962 ms 4.17557 → 2.28497 ms

That is 1.50–1.87× across these fixtures, with more variability in the smallest case. The separate final-source overlay probe also passes, including the disclosed next-invocation recovery. These measurements exclude cold startup, discovery-entry/full-runtime loading, network/model latency and memory behavior; no universal latency or memory improvement is claimed.

The full build passes (165.5 s) at 903af4fdb1680204ea31acbb7422f5cf90092b5a; later follow-ups change only one memory test and release-note placement, leaving production byte-identical. The built isolated Gateway passes 12 assertions across five RPCs, exactly matching baseline titles/previews, tool inventories and model catalog. Four fresh real OpenAI sessions return READY and execute sessions_list, web_fetch and native web search; terminal receipts and the native search completion event confirm execution without rerouting. The owned Gateway exits cleanly. Live timings are observational, not speedup evidence.

Hosted CI exposed an existing cross-process memory-test observation race: after publication releases its lease, a later reader may already have completed before the test checks an intermediate snapshot. The observed event order was correctly published then next-reader. Remove only that invalid intermediate assertion and explain the release ordering; initial contention, pre-release empty events, final exact ordering and cleanup remain. The seven-test canonical suite passes. An independent actual-process probe reproduces the old failure, passes 24 corrected runs (12 ordinary and 12 late observations), and detects a deliberately broken writer-intent implementation through the retained contention check. This is +1/−1 test lines, with no production, timer or lock change.

The final memory-only changed-file gate also passes. An earlier local attempt failed the topology guard while a native review checkout was changing; rerunning with checkout operations idle passed without relaxing the guard. A separate real-native fixture reproduces this failure mechanism, but the original invocation's complete before/after topology was not retained. The separate build-cache namespace issue is retained as a follow-up; no speculative exclusion is included here.

The reviewed fallback is accepted on this evidence: retain valid static rows, recover discarded selected/credentialed owners through existing canonical registration, and preserve the entries-only boundary. The exact-head real-loader matrix, synthetic-auth and prepared-worker suites, and real Gateway receipts cover the requested activation, ordering and authentication boundaries.

Changelog

Provider discovery prepares manifest catalogs once and recovers discarded discovery entries through the existing scoped loader, so a static catalog cannot hide another selected or credentialed provider after an entry fails.

The native landing workflow reserves root CHANGELOG.md edits for release automation; this ordinary PR carries the release note here. The initial prepare attempt correctly refused the root entry, which was removed without any production or test change. No release-only override is used.

@clawsweeper

clawsweeper Bot commented Aug 30, 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 size: M maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 05:27
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 1:45 AM ET / 05:45 UTC.

ClawSweeper review

What this changes

The PR consolidates manifest-catalog planning and, after a discovery entry fails, reloads selected or credentialed provider owners through the scoped full plugin loader.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking code finding. Keep this member-authored, maintainer-labelled PR open: it repairs a real owner-boundary omission that current main still retains, while exact-head validation must confirm the deliberately changed runtime-loading fallback.

Priority: P2
Reviewed head: 3cc1e8624a006eedb812285374a4675ed7da8c19
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary repair and focused regression cases are strong, with exact-head fallback validation still needed before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies this as a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply. The supplied body reports test evidence, but this read-only review did not execute it; exact-head validation remains the merge risk reducer.
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, maintainer-labelled PR, so the external-contributor proof gate does not apply. The supplied body reports test evidence, but this read-only review did not execute it; exact-head validation remains the merge risk reducer.
Evidence reviewed 7 items Prior failure path: At the merge base, an entry-load failure returned static manifest providers but retained every discovery-entry owner as covered; later selective loading therefore excluded a selected or credentialed discarded owner.
Owner-boundary repair: The proposed catch retains only static manifest coverage, and the outer resolver computes scoped full-loader IDs from uncovered records while preserving unscoped credential bounds.
Regression coverage: The new table-driven owner test covers selected, credential-bounded unscoped, and entries-only calls with failures in both positions, asserting the recovered full-loader scope and retained static entry.
Findings None None.
Security None None.

How this fits together

Plugin manifests provide lightweight catalog metadata to provider discovery before full plugin runtime activation. The resolver supplies ordered provider registrations to model configuration and startup catalog flows.

flowchart LR
  A[Plugin manifests] --> B[Catalog planning]
  B --> C[Discovery entry loading]
  C --> D{Entry loading succeeds?}
  D -->|Yes| E[Provider registrations]
  D -->|No| F[Scoped full plugin loader]
  F --> E
  E --> G[Model configuration and startup]
Loading

Decision needed

Question Recommendation
Should this PR land after exact-head validation confirms that the new fallback activation is acceptable for selected and credentialed provider owners? Validate and land: Run the existing exact-head provider-discovery coverage and accept the scoped full-loader recovery if activation and ordering remain as intended.

Why: The code repair is localized and source-supported, but the changed failure path intentionally crosses from lightweight discovery to runtime loading and needs maintainer acceptance of that compatibility tradeoff.

Before merge

  • Resolve merge risk (P1) - A failed lightweight entry now activates the selected or credentialed owner’s full runtime instead of silently omitting it; exact-head validation should confirm activation, ordering, and auth behavior on real manifests.
  • Complete next step (P2) - This protected maintainer PR has no mechanical repair finding; maintainer acceptance and exact-head validation of the changed fallback remain.
Agent review details

Security

None.

PR surface

Source -79, Tests +58, Docs +1. Total -20 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 72 151 -79
Tests 2 59 1 +58
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 132 152 -20

Review metrics

Metric Value Why it matters
Production versus test delta production +72/-151 (net -79); tests +59/-1 (net +58) The repair removes duplicated resolver logic while adding focused regression coverage; no production growth needs justification.

Merge-risk options

Maintainer options:

  1. Prove the changed fallback on exact head (recommended)
    Confirm the full-loader fallback preserves selected scope, credential-bounded unscoped behavior, ordering, and provider authentication handling.
  2. Accept the runtime-loading tradeoff
    Land with the understanding that a failed lightweight discovery entry may now load its selected or credentialed runtime owner.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run exact-head provider-discovery validation for selected, credential-bounded unscoped, static, runtime, and refreshable entry-failure recovery; attach redacted results.

Technical review

Best possible solution:

Retain the single manifest-planning flow and scoped fallback, then validate selected, credential-bounded unscoped, static, runtime, and refreshable failure cases on the exact PR head before merge.

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

Yes, source-reproducible: make one provider-discovery entry throw amid selected or credentialed owners; the merge-base catch retained their coverage despite discarding their results. The new focused table test encodes that scenario, but it was not executed in this read-only review.

Is this the best way to solve the issue?

Yes. The patch repairs coverage at the provider-discovery owner and delegates recovery to the existing scoped loader, rather than adding a consumer retry or a parallel loader path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7bd0903f7a23.

Labels

Label justifications:

  • P2: The change affects provider availability after an uncommon discovery-entry failure, with bounded but meaningful operator impact.
  • merge-risk: 🚨 compatibility: Existing discovery failure behavior changes from omission to scoped full runtime loading for selected or credentialed owners.
  • merge-risk: 🚨 auth-provider: The new recovery path can invoke provider registration for owners selected through environment credential metadata.
  • 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, maintainer-labelled PR, so the external-contributor proof gate does not apply. The supplied body reports test evidence, but this read-only review did not execute it; exact-head validation remains the merge risk reducer.

Evidence

What I checked:

Likely related people:

  • steipete: 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.

  • Complete exact-head validation of selected, credential-bounded unscoped, and mixed catalog recovery behavior.

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-30T05:33:53.387Z sha 903af4f :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the extensions: memory-core Extension: memory-core label Aug 30, 2026
@steipete
steipete merged commit 98fe750 into main Aug 30, 2026
240 checks passed
@steipete
steipete deleted the codex/perf-provider-discovery-plan-20260829 branch August 30, 2026 06:11
@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 31, 2026
* perf(plugins): consolidate provider discovery planning

* test(plugins): construct discovery scenarios directly

* test(memory-core): assert lease ordering after both readers finish

* docs: keep provider release note with the PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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: 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.

1 participant