Skip to content

perf: avoid plugin discovery for core config paths - #170270

Merged
steipete merged 1 commit into
mainfrom
perf/config-secret-target-gate
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/config-secret-target-gate

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Ordinary config paths such as gateway.mode paid for the full plugin secret-target registry, including metadata discovery and every channel secret contract.

User Impact

Core config paths now avoid plugin secret-target discovery. Plugin config paths try the named plugin's manifest targets, then its channel contract on a miss. Channel paths retain direct lookup and broader discovery for external or multiple owners. Configured discovery skips unrelated bundled contracts, and runtime collection returns immediately for empty plugin entries.

No migration or operator action is required. Core credentials, manifest and channel-declared plugin config secrets, disabled-plugin auditing/configuration, external channels, and unknown-channel handling retain their supported behavior. Channel contracts cannot extend core config schemas, but can declare credentials under their own plugin config schema; that shipped behavior is preserved.

Why This Change Was Made

The secret-target query owner now gates by config-path ownership. Concrete CLI target selection uses that scope, and configured discovery reuses supplied manifest records. Broad target enumeration retains the full registry because channel contracts may also declare plugin config credentials. Discovery also uses the broader index after falling back from an incomplete direct contract.

Cold metadata snapshot selection still scans before projecting to selected plugin IDs on this base. This change narrows target/contract construction; it does not redesign metadata bootstrap, config-schema loading, or deferred migrations.

Release-note context: speed up config and secret-target resolution by avoiding unrelated plugin/channel registry work for core paths and configured subtrees.

Evidence

Owner-seam regressions prove non-plugin paths never invoke plugin metadata discovery; selected plugin, bundled channel, external/multiple channel owner, disabled plugin, unknown-channel, and prepared-manifest paths are covered. The non-plugin lookup regression failed against the baseline at the metadata-discovery boundary. Additional compatibility regressions caught and fixed candidate gaps before publication.

The final source passed all 20 owner tests. Earlier validation passed 70 distinct sibling tests, and the plugin-contract compatibility follow-up reran 45 affected sibling tests successfully before the final target-family guard repair. That last repair is directly covered by the new owner regression; unchanged sibling proof is reused. Each changed test file was measured with pnpm test <file> --maxWorkers=1:

File Tests Local command wall CI reported shard wall
src/secrets/target-registry.path-scope.test.ts 20 54.362s 4.19s
src/secrets/target-registry.fast-path.test.ts 5 328.455s 4.83s
src/secrets/runtime-config-collectors-plugins.test.ts 9 156.647s 6.92s

CI timing is the test wrapper’s reported per-file shard elapsed time; shared CI setup is amortized across files. The final owner suite used about 2s of local test execution.

The final 20-case owner suite covers direct lookup, plan target-family fallback, scoped discovery, and disabled owners. The three external-owner compatibility cases failed against the earlier candidate because the supported target was absent from path lookup and configured discovery; a fourth caught a target-family path miss preventing contract fallback. The older suites spent 99% and 92% of their Vitest duration transforming code; the cold compiler prepared 15,274 inputs / 19,579 outputs. The earlier 12-file sibling batch passed 70 tests, including real external CJS channel artifacts, registry snapshots, plan/configure, runtime command secrets, and CLI target selection.

The earlier 12-file sibling wall time was 762.837s.

The six-file compatibility sibling follow-up passed 45 tests in 651.682s.

pnpm check:changed passed (core types, all 28 affected test typecheck graphs, core/extension lint, formatting, docs, boundaries, ratchets, dead exports, import cycles, and runtime/auth guards). It reported only two non-blocking max-lines warnings in untouched extension files. The final compatibility and target-family follow-ups also passed core types, their owning test-project types, changed-file lint, formatting, and diff checks. pnpm build passed, followed by pnpm build:runtime for the final compatibility follow-up. Independent Codex review identified a target-family fallback gap, which was repaired with a failing regression. The final complete-diff review found no actionable P0–P2 issues.

CLI measurements

Three-run medians in seconds, using built dist/entry.js, Node 26.11.1 and Bun 1.4.3 on arm64. Every case uses synthetic isolated HOME/config/state; reused cases are primed once. The after column is a fresh run on the final runtime build. Cells show before → after.

Runtime Command State Wall User CPU System CPU
Node config set fresh 33.937 → 21.346 4.257 → 3.878 5.608 → 7.581
Node config set reused 11.016 → 10.394 3.404 → 2.918 2.967 → 3.352
Node config get fresh 8.612 → 4.926 1.829 → 1.588 1.717 → 1.553
Node config get reused 8.711 → 6.498 2.170 → 2.294 1.399 → 1.709
Node config validate fresh 1.634 → 1.500 1.140 → 1.143 0.623 → 0.545
Node config validate reused 38.210 → 11.931 7.196 → 5.693 9.150 → 5.607
Bun config set fresh 14.841 → 3.499 3.147 → 2.325 15.774 → 14.330
Bun config set reused 9.078 → 6.109 2.899 → 2.550 11.148 → 10.418
Bun config get fresh 5.363 → 5.589 1.368 → 1.455 6.124 → 7.802
Bun config get reused 4.915 → 5.972 1.573 → 1.607 5.755 → 5.297
Bun config validate fresh 3.671 → 5.193 1.211 → 1.266 6.941 → 6.871
Bun config validate reused 21.726 → 11.202 5.120 → 4.470 29.517 → 29.486

The host was shared and heavily loaded (load1 ranges: before 26.01–76.56; after 39.94–71.05). These wall times are noisy and do not establish a controlled speedup ratio. The preliminary pass before the final follow-ups included a 101.5s Bun set outlier; no samples were discarded from either pass.

Profile evidence

Bun --cpu-prof --cpu-prof-md on isolated config set gateway.mode local; this table uses the main process profile, not the launcher. Values are inclusive sampled time, not pure instruction CPU time.

Frame/subtree Before After
resolveConfigSecretTargetByPath 5569.2 ms 0.0 ms
loadSecretTargetRegistryFromPluginMetadata 2461.7 ms 0.0 ms
loadBundledChannelSecretContractApi 3104.6 ms 0.0 ms

Exact-head CI: run 38311971521 completed successfully on 0c6b281e8a2d4c00f640053f287e8aada493e755: 38 jobs passed and 25 were skipped by the plan. The native pinned-head watcher reported GREEN, with no pending checks. GitHub’s raw aggregate still includes 87 superseded check runs; those are not failures of this active run. The PR remains ready for review and unmerged.

@clawsweeper

clawsweeper Bot commented Oct 12, 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.

@steipete
steipete marked this pull request as ready for review October 12, 2026 21:39
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 0c6b281e8a2d4c00f640053f287e8aada493e755
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/secrets/runtime-config-collectors-plugins.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/target-registry-data.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/target-registry-query.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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: L labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR scopes secret-target discovery to the relevant config owner and skips plugin metadata work for ordinary core paths.

Example: Run openclaw config set gateway.mode local.

  • Before: Secret-target lookup falls through to plugin metadata and channel-contract discovery.
  • After: Secret-target lookup rejects the non-secret core path without discovering plugins.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Useful owner-scoped optimization with shipped CLI evidence, compatibility coverage, successful exact-head CI, and no identified merge blocker; persisted formats and defaults are unchanged.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied final-build CLI measurements and profiles exercise config set gateway.mode local through the shipped entry point on isolated Node/Bun setups and show unrelated registry work disappearing; focused regressions support plugin and channel compatibility, without establishing a controlled overall speedup ratio.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Ordinary config operations spend time discovering unrelated plugin credential contracts.
Reason: The maintainer-authored change removes evidenced unnecessary work while retaining the supported credential surfaces and existing operator behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR delivers a useful, maintainer-directed performance improvement that current main lacks, with relevant CLI evidence and no actionable defects found.

Priority: P2
Reviewed head: 0c6b281e8a2d4c00f640053f287e8aada493e755

Before merge

None.

Findings

None.

Agent review details

How this fits together

The secret-target registry sits between config and CLI callers and credential contracts, translating concrete paths or configured subtrees into supported secret targets.

flowchart TD
A[Config and CLI callers] --> B[Secret target query owner]
B --> C[Static core targets]
B --> D[Selected plugin manifest]
B --> E[Direct channel contract]
E --> F[Broader registry fallback]
C --> G[Resolved secret targets]
D --> G
F --> G
Loading

Technical review

Best possible solution:

Use the existing registry owner to avoid unrelated discovery while preserving manifest targets, channel fallback, and disabled-owner auditing.

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

Current-main source shows gateway.mode falling through to the full registry, and the supplied built-CLI profile exercises that path; no target code was executed during this review.

Is this the best way to solve the issue?

The change addresses unnecessary discovery at its existing owner, preserves direct-contract precedence and broader fallback, and accurately limits its performance claims because cold metadata bootstrap remains unchanged.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Core and channel path matching keeps the original intent (9c1bf99: Reuse the existing matcher while preserving core-first resolution, channel precedence, typed paths, and provider/account checks.)
  • Configured and external-owner discovery keeps the original intent (improve: speed up secrets audit test shard #122504: Avoid broad initialization for simple configs while retaining complete config-scoped discovery for external and multiple channel owners.)
  • External channel contracts keeps the original intent (fix(secretrefs): resolve external channel contracts #76449: Resolve externalized channel SecretRefs through plugin sidecar contracts instead of bundled-only discovery.)
  • Registry construction and load errors keeps the original intent (cf2ede2: Use the canonical artifact loader and preserve strict generation errors while runtime discovery isolates unavailable owners.)
  • Concrete CLI credential selection keeps the original intent (2416de1: Infer registered SecretRef targets for provider-backed commands.)
  • Plugin runtime collection keeps the original intent (694bc08: Materialize supported plugin config SecretRefs and preserve inactive or stale-plugin handling.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +117, Tests +343, Docs +14. Total +474 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 171 54 +117
Tests 3 345 2 +343
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 530 56 +474

Review metrics

Metric Value Why it matters
Production versus test changes Production +171/-54; tests +345/-2 Production growth implements owner scoping and compatibility fallback; test growth covers distinct core, plugin, channel, and configured-discovery contracts.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Avoids unnecessary plugin discovery in ordinary config operations without an urgent availability or data-integrity incident.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-12T21:45:44.997Z sha 0c6b281 :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 6:00 PM ET / 22:00 UTC (Revision 2).

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 12, 2026
@steipete
steipete merged commit 7499b3f into main Oct 12, 2026
208 of 212 checks passed
@steipete
steipete deleted the perf/config-secret-target-gate branch October 12, 2026 22:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
Ordinary core config paths paid for the full plugin secret-target registry, including metadata discovery and unrelated channel contracts.

Gate secret-target resolution by config-path ownership. Core paths avoid plugin discovery; plugin paths use their manifest targets and channel-contract fallback; channel paths retain broader discovery for external or multiple owners. Reuse supplied manifest records during configured discovery and return immediately for empty plugin entries.

Preserve core credentials, plugin-config credentials declared by manifests or channel contracts, disabled-plugin auditing/configuration, external channels, and unknown-channel behavior. No migration or operator action is required. Metadata bootstrap, config-schema loading, and deferred migrations remain outside this change.

Release-note context: speed up config and secret-target resolution by avoiding unrelated plugin/channel registry work for core paths and configured subtrees.

Validation: final 20-case owner suite, recorded 70-test sibling coverage and 45-test compatibility follow-up, targeted checks, build/runtime build, and independent review. Exact-head CI run 38311971521 passed on 0c6b281; detailed timings and profile evidence remain in the PR.
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed size: L 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