Skip to content

perf(secrets): skip plugin metadata for entries without config values - #206285

Merged
vincentkoc merged 2 commits into
mainfrom
perf/skip-empty-plugin-secrets-20261127
Nov 27, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
perf/skip-empty-plugin-secrets-20261127

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Problem

Preparing SecretRefs loads plugin manifests for entries that only set activation policy. The CLI can do this during command preflight and local resolution even though those entries have no configuration fields for a plugin contract to match.

User Impact

Local commands and secret preparation can skip this discovery when no plugin config contains a value. Plugins with config values keep their existing activation, stale-entry and warning behavior.

Why This Change Was Made

The collector and snapshot preparation use the same check for plugin config fields before requesting metadata. Channel, web-tool and exec-provider requests keep their own discovery conditions. Refresh records whether an origin inventory was observed, so a later config change can discover a newly configured plugin and resolve its credentials.

Evidence

On the frozen base with only the new tests applied, three cases failed. Policy-only entries, an empty config and the initial snapshot each triggered one metadata lookup. On the candidate all three triggered zero lookups. A later refresh that added a plugin credential discovered its owner and resolved the SecretRef.

Five focused suites passed all 20 tests, including bundled plugin manifests, disabled and stale entries, external-channel discovery, and snapshot cleanup. The production diff spans five files (+22/−17). There are no config or defaults changes. Device latency remains unmeasured.

An isolated run against the built JavaScript and normal CLI offline state owner prepared two snapshots with a core env SecretRef. An enable-only entry and an empty plugin config both produced zero manifest-helper imports and no recorded plugin inventory. Refresh added Tavily's webSearch.apiKey, loaded the real bundled manifest, and resolved the synthetic credential. The normal package build and integrity check passed.

The draft Bun Gateway config-patch job failed during native-worker teardown. The exact test passed on the frozen Linux base and in a focused Bun replay on the signed head. The draft dependency check matched the base’s three Knip findings. A separate npm install budget measured 47,950 entries against 47,500. An earlier source build also exceeded that budget. The exact base-to-head entry-count change is unmeasured.

@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR skips plugin metadata discovery for entries without config fields and preserves discovery on a later config refresh.

Example: An entry contains example: { enabled: true } while gateway authentication uses an environment SecretRef.

  • Before: Secrets preparation requests plugin metadata despite having no plugin config fields to collect.
  • After: Preparation skips that metadata request and can discover the plugin when a later refresh adds config.token.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-consistent, but required real-behavior proof is absent and failing CI remains unattributed.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Local commands preparing core SecretRefs can pay for plugin discovery when plugin entries contain activation policy but no config fields.
Reason: Removing provably unused discovery is worthwhile, and the maintainer-authored PR establishes direction without introducing configuration or public API changes.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored draft removes source-confirmed unnecessary discovery, and review found no definite introduced correctness defect.

Reviewed head: 56a2689dfac7ca9d681fe3a21c1c6d6467ed3245

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted shipped-CLI or Gateway evidence that policy-only and empty-config entries skip discovery with a core SecretRef, then resolve a newly added plugin SecretRef on refresh; base-failing/head-passing regression execution is also not shown.
Agent review details

How this fits together

The secrets runtime takes canonical config, environment values, auth stores, and plugin contracts and produces resolved in-memory snapshots for CLI preflight and Gateway activation.

flowchart TD
  A[Config and environment] --> B[Secrets preparation]
  B --> C[Plugin config value check]
  C --> D[Plugin metadata when needed]
  D --> E[Secret assignment collection]
  B --> E
  E --> F[Resolved runtime snapshot]
  F --> G[Config refresh]
Loading

Technical review

Best possible solution:

Keep the shared config-value predicate and preserve the distinction between an unobserved inventory and an observed empty inventory.

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

Source confirms that a policy-only plugin entry triggers unnecessary metadata discovery when a core SecretRef requires full preparation; no product execution was performed during this read-only review.

Is this the best way to solve the issue?

The change removes work at the existing preparation and collection owners without adding a competing registry, and retains explicit empty-inventory semantics for known stale plugins.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Plugin collector discovery eligibility keeps the original intent (7499b3f: Avoid unrelated plugin secret-target discovery while preserving supported plugin contracts and inactive-surface behavior.)
  • Plugin metadata preparation triggers keeps the original intent (5ae27df: Skip idle plugin-origin discovery; subsequent worker-backed preparation also protects web-tool and assignment-projection paths.)
  • Fast-path refresh inventory changes intended behavior with a stated reason (0177a4b: Keep plain Gateway startup lightweight while preserving cleanup and refresh semantics; this PR explains why an unobserved inventory must remain omitted for later discovery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced hunks share one config-value predicate between preparation and collection and retain an undefined origin inventory when discovery has not occurred. (src/secrets/runtime-secret-scan.ts:7, 56a2689dfac7)
  • Current main still performs the unnecessary work: Current main triggers metadata preparation for any nonempty plugin entries object; its collector likewise returns early only for an empty entries object. The fetched-main comparison contains no changes to this subsystem. (src/secrets/runtime.ts:95, 3ffd7660334a)
  • Refresh regression coverage: The added test starts with a policy-only entry and a resolved Gateway credential, then adds a manifest-declared plugin token and checks that refresh resolves it; metadata discovery is mocked. (src/secrets/runtime.loadable-plugin-origins.test.ts:36, 56a2689dfac7)
  • Existing discovery contracts: perf: avoid plugin discovery for core config paths #170270 established scoped discovery, and fix: let PostgreSQL Gateways start with plugin-backed secrets #201063 preserved worker-backed metadata preparation for web tools and assignment projections; those independent triggers remain intact. (src/secrets/runtime.ts:94, 56a2689dfac7)
  • Draft and proof evidence: The complete body reports formatting checks, pending focused tests/build, and no latency measurements; discussion contains only review-status bot comments. GitHub reports the reviewed head as draft and mergeable. (56a2689dfac7)
  • CI failures remain unattributed: The compact test shard annotations report retained native-worker resources during Gateway cleanup; the dependency check exposes only an exit-code annotation. Neither is established as diff-caused or external. Full job logs redirect to a host blocked by the review environment. (56a2689dfac7)

Likely related people:

  • Vincent Koc: Raw commit 5ae27df adds src/secrets/runtime.ts:168 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5ae27dfb5a35; files: src/secrets/runtime.ts)

PR surface

Source +5, Tests +50. Total +55 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 22 17 +5
Tests 2 56 6 +50
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 78 23 +55

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +22/-17; tests +56/-6 The small production increase shares the eligibility check and preserves refresh semantics; tests cover distinct empty-config inputs and the first plugin-config refresh.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed November 26, 2026, 8:59 PM ET / November 27, 2026, 01:59 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 27, 2026 02:18
@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: 56a2689dfac7ca9d681fe3a21c1c6d6467ed3245
  • Maintainer: @vincentkoc
  • 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/runtime-fast-path.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/runtime-secret-scan.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/runtime-state.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/runtime.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.

@vincentkoc
vincentkoc enabled auto-merge (squash) November 27, 2026 02:25
@vincentkoc
vincentkoc merged commit 5f0743a into main Nov 27, 2026
280 of 284 checks passed
@vincentkoc
vincentkoc deleted the perf/skip-empty-plugin-secrets-20261127 branch November 27, 2026 02:31
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…openclaw#206285)

* test(secrets): cover metadata discovery for plugin config values

* perf(secrets): skip plugin metadata for entries without config values
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#206285)

* test(secrets): cover metadata discovery for plugin config values

* perf(secrets): skip plugin metadata for entries without config values

(cherry picked from commit 5f0743a)

Companion audit: #200185 separates passive credential lookup; no dependency on entry-config scan or origin inventory lifecycle.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed 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