Repository navigation
perf(plugins): memoize auto-enable fingerprints on process-stable snapshots - #118334
Conversation
|
Codex review: needs changes before merge. Reviewed August 2, 2026, 8:49 PM ET / August 3, 2026, 00:49 UTC. ClawSweeper reviewWhat this changesThis PR memoizes plugin auto-enable fingerprints and adds reference-equality fast paths in plugin runtime load-context resolution to reduce repeated fingerprint serialization during plugin tool construction. Merge readiness⛔ Blocked by patch quality or review findings - 6 items remain Keep this PR open, but do not merge it as written: the new process-lifetime identity memos make plugin auto-enable reuse stale results when an existing config, environment, discovery, or registry object mutates in place. Current main explicitly tests that those mutations invalidate auto-enable results, and the branch replaces that contract with a manual lifecycle-clear requirement. Priority: P2 Review scores
Verification
How this fits togetherPlugin runtime loading combines a config object, environment, discovery output, and manifest metadata to decide which plugins auto-enable before building the runtime registry and agent tools. The changed cache sits between those inputs and the resolved load context, so an incorrect cache hit can silently retain outdated plugin activation decisions. flowchart LR
A[Config and environment inputs] --> D[Plugin auto-enable evaluation]
B[Discovery candidates] --> D
C[Manifest metadata snapshot] --> D
D --> E[Auto-enable cache validation]
E --> F[Resolved plugin load context]
F --> G[Runtime registry and agent tools]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +40, Tests +85. Total +125 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep fingerprint checks content-sensitive for caller-provided config, environment, discovery, and registry inputs; memoize only facts that are actually lifecycle-owned immutable snapshots, then retain regressions for direct in-place mutation and load-context mutation. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current-main tests mutate the same config and process-environment objects between calls and require cache invalidation, while the branch’s object-identity memos return the original fingerprint until Is this the best way to solve the issue? No. The proposed lifecycle-owned cache is the wrong boundary for generic caller-supplied mutable inputs; a correct optimization must preserve the existing content-sensitive contract or restrict memoization to demonstrably immutable snapshots. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 18c9f27e2de3. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper moves reviewed. The mutation-sensitive recommendation is intentionally skipped for this performance change. The config, environment, discovery, and registry values on this path are treated as process-stable replacement snapshots. Their owner boundary is the shared plugin-metadata lifecycle seam ( Restoring a fresh content fingerprint for these caller values would restore the recursive serialization on every cache validation—the measured hotspot this PR removes. Narrowing the environment is also not sound because dynamic channel prefixes and public plugin auto-enable probes may inspect arbitrary keys. The branch therefore replaces the old in-place-mutation expectations with reference-replacement and lifecycle-clear regressions, while preserving the whole-input fingerprint within each lifecycle generation. The final reviewed head has the focused auto-enable/load-context proof (101 tests), changed-surface gates, full build, and the local N=8 A/B in the PR body; ClawSweeper also marks the real-behavior proof sufficient. The |
|
Merged via squash.
|
What Problem This Solves
Follow-up to #118027 (gateway event-loop ceiling). A CPU profile of the gateway under 8-way mock streaming load showed
stableFingerprintValue(src/config/plugin-auto-enable.apply.ts) at 931 ms self time — its module 1.36 s, 15.45% of total gateway CPU — because the plugin auto-enable cache VALIDATION recomputed full stable serializations of the config, the entire process env, discovery candidates, and the manifest registry on every call. Validating the cache cost as much as the miss, and the hot caller is per-attempt plugin tool construction.Why This Change Was Made
registerPluginMetadataProcessMemoLifecycleClear), so reload/install/doctor flows invalidate them exactly like sibling metadata memos.User Impact
No behavior change to which plugins auto-enable. Gateway turns stop paying recursive config/env/registry serialization per plugin-tool build: in a local N=8 mock-streaming A/B, total turn duration improved 20.3% (7.75 s → 6.18 s).
Evidence
turnsDurationMs7753 ms / delayP99 max 1706 ms; after 6178 ms / max 1224 ms.Part of the #118027 follow-up track. Production delta +40, tests +85.