Skip to content

perf(plugins): reuse provider ownership metadata - #127178

Merged
steipete merged 1 commit into
mainfrom
codex/perf-provider-ownership-current
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-provider-ownership-current

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where provider ownership checks without an explicit or current lifecycle snapshot repeated full plugin registry and manifest preparation: once for a direct-provider miss and again for the CLI-backend fallback. Explicit model-ref batches could repeat the same work for each model.

Why This Change Was Made

Provider and CLI-backend ownership now share one immutable manifest/metadata context per decision, and model-ref batches carry one prepared manifest across all lookups. Explicit manifests and current metadata retain precedence; aliases, disabled/workspace/config/env behavior, ambiguity classification, result ordering, and lifecycle freshness remain unchanged. No cache is added.

This is AI-assisted. No agent transcript is attached.

User Impact

Provider-selection and activation paths avoid duplicate plugin discovery work. In the same isolated 10-call harness, median cold-fallback wall time improved from 133.569 ms to 68.850 ms per call (48.5% lower), median CPU from 1415.651 ms to 741.814 ms per 10 calls (47.6% lower), and first-round RSS growth from 12.516 MiB to 7.676 MiB (38.7% lower). Prepared lifecycle-snapshot lookups remain effectively free.

Evidence

  • Exact-current-main pre-fix regression: 2 failed / 58 passed. A setup-only CLI-backend lookup rebuilt plugin metadata twice, and a two-model ownership batch rebuilt it three times.
  • Exact final-head focused and sibling tests:
    • node scripts/run-vitest.mjs src/plugins/providers.test.ts src/plugins/provider-runtime.test.ts src/plugins/providers.runtime.consult-current-snapshot.test.ts src/plugins/providers.setup-trust.test.ts --reporter=verbose
    • 4 files, 135 tests passed.
  • node scripts/check-changed.mjs -- src/plugins/providers.ts src/plugins/providers.test.ts passed formatting, core/core-test typechecks, lint, dead exports, database/schema guards, plugin boundaries, and import-cycle checks.
  • pnpm build passed on exact final main plus this commit, including all public Plugin SDK subpaths and Control UI budgets.
  • git show --check HEAD passed.
  • Fresh structured autoreview on exact final commit 191ee5e4d5b2c96f15b958a7acebd6158863b55b: TruffleHog clean; no accepted/actionable findings; patch correct confidence 0.97.
  • Exact live open PR/issue searches found no duplicate for resolveOwningPluginIdsForProviderRef; broader provider-ownership results were unrelated metadata validation, doctor-route, or model-alias work.

@clawsweeper

clawsweeper Bot commented Aug 21, 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 21, 2026 12:06
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 8:12 AM ET / 12:12 UTC.

ClawSweeper review

What this changes

The PR reuses one prepared plugin manifest and ownership-metadata context across provider and CLI-backend ownership lookups to avoid repeated plugin discovery.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The duplicate metadata preparation remains on current main, and this branch consolidates it without a concrete behavioral regression found. Keep this protected maintainer PR open for normal review and exact-head CI.

Priority: P3
Reviewed head: 191ee5e4d5b2c96f15b958a7acebd6158863b55b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused, net-reducing refactor and regression coverage are solid; normal exact-head CI remains before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body also records focused tests and benchmark results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body also records focused tests and benchmark results.
Evidence reviewed 5 items Current-main behavior: Current main materializes plugin metadata separately in the direct-provider and CLI-backend fallback paths when no compatible current snapshot exists.
Prepared owner context: The branch resolves one compatible snapshot or manifest registry, then uses it for both ownership branches while retaining explicit-manifest precedence.
Caller boundary: The runtime provider loader already passes its lifecycle-prepared manifest snapshot to explicit provider and model ownership resolution.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/plugins/providers.test.ts --reporter=verbose

Result: PASS (completed)

node scripts/run-vitest.mjs src/plugins/providers.test.ts --reporter=verbose
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127178-kydomF/target$ node scripts/run-vitest.mjs src/plugins/providers.test.ts --reporter=verbose
node scripts/run-vitest.mjs src/plugins/providers.test.ts --reporter=verbose
[test] starting test/vitest/vitest.plugins.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127178-kydomF/target

 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › does not treat cli backend ids as provider owners 57ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › maps setup-only cli backend ids to explicit provider refs via manifests 2ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › maps explicit provider refs to provider or cli-backend owners 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › marks explicit provider refs with multiple owners as ambiguous 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › maps explicit cli-backend model refs to owning plugin ids 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › reuses one registry snapshot across explicit model ownership lookups 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › maps manifest model catalog provider aliases to owning plugin ids 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › uses the current metadata owner maps before loading plugin metadata 2ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › uses current metadata owner maps for cli backend provider refs 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › keeps normalized case-variant owners from current metadata maps 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › keeps explicit manifest registries ahead of current metadata owner maps 0ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › maps manifest provider auth aliases to the target provider owner 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › reflects provider ownership manifest changes on the next lookup 0ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › forwards an explicit env to plugin loading 3ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › keeps bundled provider plugins enabled when they default on outside Vitest compat 12ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › does not answer explicit registry lookups from current metadata snapshots 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › loads catalog augment hooks only for declarative runtime catalog manifests 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › loads bundled Ollama catalog augment hooks from the manifest runtime flag 0ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › loads usage hooks only for manifest-declared providers 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › resolves external auth hook plugin ids from manifest contracts without runtime loading 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › filters bundled provider plugins through restrictive allowlists 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › treats explicit empty provider scopes as scoped-empty in provider helpers 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › loads only provider plugins on the provider runtime path with ordinary env 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › loads only provider plugins on the provider runtime path with Vitest env 1ms
 ✓  plugins  src/plugins/providers.test.ts › resolvePluginProviders › ignores every bundledProviderVitestCompat value without changing loader input 1ms
 ✓  plugins  s
… output truncated …

Assertions:

  • PASS expect_output: Test Files

How this fits together

Provider selection asks the plugin subsystem which installed plugin owns a provider or CLI backend. That ownership result feeds activation and model-reference routing while respecting explicit manifests and lifecycle snapshots.

flowchart LR
  A[Provider or model request] --> B[Ownership lookup]
  B --> C[Prepared manifest and metadata]
  C --> D[Direct provider decision]
  D --> E[CLI-backend fallback]
  E --> F[Plugin activation and routing]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind main and required exact-head checks are still in progress, so it needs a rebase or review refresh before landing.
Agent review details

Security

None.

PR surface

Source -25, Tests +25. Total 0 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 84 109 -25
Tests 1 26 1 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 110 110 0

Review metrics

Metric Value Why it matters
Production vs test delta production -25, tests +25 The refactor reduces production code while adding focused ownership-reuse coverage.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/plugins/providers.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the single manifest-first ownership context after the branch is current and required checks are green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the single manifest-first ownership context after the branch is current and required checks are green.

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

Yes — current main independently prepares metadata in both fallback branches when no compatible snapshot exists; the focused tests cover the shared-preparation path.

Is this the best way to solve the issue?

Yes — a request-scoped immutable manifest/metadata context is the narrowest solution and follows the plugin subsystem’s manifest-first snapshot contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 498471396fed.

Labels

Label changes:

  • add P3: This is a bounded internal performance refactor with no demonstrated user-facing outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body also records focused tests and benchmark results.

Label justifications:

  • P3: This is a bounded internal performance refactor with no demonstrated user-facing outage.
  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its body also records focused tests and benchmark results.

Evidence

What I checked:

Likely related people:

  • Shakker: Current-main blame attributes the provider and CLI-backend ownership flow to the introducing commit. (role: feature introducer; confidence: high; commits: 69fa1a8eab55; files: src/plugins/providers.ts)

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.

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 191ee5e4d5b2c96f15b958a7acebd6158863b55b:

  • Exact-head CI: run 32480300530 completed green (node scripts/watch-pr-ci.mjs 127178 191ee5e4d5b2c96f15b958a7acebd6158863b55b).
  • Repository-native hosted/Testbox prepare: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 127178 passed with gates_mode=hosted_exact_or_recent_parent; the remote PR head and local prepared head are identical. No separate Testbox run URL was emitted.
  • Exact-final local proof: 135 focused/sibling tests passed; changed-file checks and full pnpm build passed; TruffleHog was clean; final-commit autoreview found no actionable issue (patch is correct, confidence 0.97).
  • Real cold-fallback benchmark: wall 133.569 → 68.850 ms/call (−48.5%), CPU 1415.651 → 741.814 ms/10 calls (−47.6%), first-round RSS +12.516 → +7.676 MiB (−38.7%).
  • ClawSweeper review found no implementation, behavioral, or security defect and independently passed the provider-owner suite.

Rank-up move disposition:

  • “Resolve merge risk”: satisfied without rebasing. Required exact-head CI is complete, the native prepare gate is green, GitHub reports the PR mergeable, and current-main drift is disjoint. Rebasing solely for drift would invalidate the exact-head proof without changing this two-file patch.
  • The review detail’s vector/embedding metadata storage classification is a false positive from the provider metadata source file: this patch changes no stored schema, migration, vector/embedding record, persistence path, or disk format.

This is an internal, net-zero two-file refactor with no cache, protocol, SDK, persistence, config, security, or provider-output change. No agent transcript is attached or posted.

@steipete
steipete merged commit 085044c into main Aug 21, 2026
298 checks passed
@steipete
steipete deleted the codex/perf-provider-ownership-current branch August 21, 2026 12:21

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

2 participants