Skip to content

perf(plugins): prepare catalog source references once per filter - #138312

Merged
steipete merged 1 commit into
mainfrom
codex/perf-sep04-catalog-source-refs
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-sep04-catalog-source-refs

Conversation

@steipete

@steipete steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Official plugin listing, package lookup and distribution classification repeatedly reconstruct the same source-reference sets while validating one catalog batch. This adds avoidable work to catalog-backed management operations.

Why This Change Was Made

Prepare the allowed source references once at the synchronous filter boundary, then validate every candidate against that snapshot. Remove the unused private error-array builder. The public validation helper retains its existing result and ordering, and empty batches remain lazy. Nothing is cached across calls: later configuration mutations are still observed.

Production: 24 additions / 38 deletions, net −14 lines. Tests: 42 additions / 7 deletions, net +35. No schema, configuration, network, persistent-store or public API change.

User Impact

Catalog-backed operations do less repeated preparation without changing which entries are accepted, their order, identity or validation errors. This is a focused local improvement; it does not establish faster Gateway startup or model turns.

Evidence

  • The same 118 cases in three complete test files passed before and after: official-external-plugin-catalog, official-external-plugin-repair-hints and management-service. Coverage retains mixed-source rejection, a valid later entry, list order/reference identity and changed configuration between loads.
  • The full changed-file gate passed, including core/type checks, formatting, lint and dead-export checks, without bypasses.
  • Independent source/contract review and managed Codex review found no actionable issue. A separate numerical audit rederived all 340 comparisons and all 34 adverse entries from the retained raw measurements.
  • Selected owners, callers, catalog data and tests remain byte-identical to the baseline on main at 6ceb2020; the existing dependency update is separately acknowledged, not treated as a whole-tree equivalence claim.

Whole-export source measurement on Node 26.8.1: one fixed before/candidate/candidate/before cohort, eight rows, 846,088 calls and 512 measured batch means. It uses the normal repository source loader and actual exported operations, with full boundary/control readback. No copied implementation or private-helper-only timing.

Operation Forward median change Reverse median change
Full 95-entry listing −26.56% (−4.05 μs) −24.53% (−3.66 μs)
Known package lookup −31.02% −29.96%
Unknown package lookup −30.40% −29.20%
Matching package/plugin identity −30.81% −30.23%
Known package, wrong plugin id −29.78% −29.53%
Foreign package, known plugin id −30.47% −30.18%
Explicit external-distribution metadata −31.21% −29.98%
Blank package lookup +1.85% (+0.20 ns) +5.49% (+0.58 ns)

The tradeoffs remain in the evidence. All 34 adverse entries are retained: 27 blank-path observations, three first-call observations and four RSS observations. Listing p95 batch means improve only about 4.1%; blank-path p95 rises 73.2–93.4% (9.7–11.9 ns). Known lookup has one +22 μs first observation; explicit metadata has +9.0/+7.4 μs first observations. Kernel RSS rises 0.85–1.40%, and sampled process-tree peak rises 1.38–1.98%; no memory reduction is claimed.

These are fixed-order local batch measurements, not confidence intervals. With 16 means, p95 is the largest batch mean, not individual-call p95. Row-first observations follow controls and exclude cold imports. Setup, hosted catalogs, persistence, built distribution, Linux, Gateway startup and whole turns are outside the measured claim. All four processes exited successfully and their recorded process groups were verified closed. No aggregate threshold was invented after observing the results.

Retained measurement report SHA-256: b031ce1b3c26d29b8da9aa8ebad6edb9d14b0937ef40686650855ebd48fbc6ba.

Focused proof commands:

node scripts/run-vitest.mjs src/plugins/official-external-plugin-catalog.test.ts src/plugins/official-external-plugin-repair-hints.test.ts src/plugins/management-service.test.ts --reporter=verbose
node scripts/check-changed.mjs --base 8ef56e23c9d2bc21f155b6ccd5fb10a218959378 -- src/plugins/official-external-plugin-catalog.ts src/plugins/official-external-plugin-catalog.test.ts

@clawsweeper

clawsweeper Bot commented Sep 4, 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: S maintainer Maintainer-authored PR labels Sep 4, 2026

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keeps the optimisation at the right snapshot boundary: one filter invocation owns one prepared source-reference set, but nothing survives into a later call, so configuration mutations remain observable. The mixed-source regression is the key one because caching only a manifest or first candidate would incorrectly admit partially unknown entries. Good that empty batches stay lazy too. No blocking issue from this diff.

@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head is c2938804e4f0b3af0fc41a7dc44feaef3cc5ab1f; its check rollup is green. The only review comment is the started placeholder whose lease expired at 15:09 UTC on September 4. Please complete the source review for this head.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 11:54 AM ET / 15:54 UTC.

ClawSweeper review

What this changes

This PR prepares configured catalog source references once for each catalog-entry filtering call and expands regression coverage for mixed and refreshed source configurations.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer PR open: current main and the latest stable release retain the old per-entry construction, while the introduced change preserves the source-validation predicate without adding a cross-call cache. No actionable regression was found.

Priority: P3
Reviewed head: c2938804e4f0b3af0fc41a7dc44feaef3cc5ab1f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with behavior-level regression coverage and no supported correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-neutral control-plane refactor is exempt from the external-contributor proof gate; its changed hosted-load test directly covers the preserved validation boundary.
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, behavior-neutral control-plane refactor is exempt from the external-contributor proof gate; its changed hosted-load test directly covers the preserved validation boundary.
Evidence reviewed 5 items Introduced filtering behavior: The introduced filter resolves configured source references once on its first nonempty synchronous callback, then applies the former missing-or-unknown source rejection to every feed and manifest candidate.
Call-boundary coverage: Bundled, snapshot, and fresh hosted catalog paths each invoke the filter independently, so the prepared set is per batch and cannot persist across loads.
Behavior-level regression coverage: The updated hosted-load test rejects unknown manifest and secondary candidates, retains a later valid entry in order with its original identity, and admits newly configured sources on a subsequent load.
Findings None None.
Security None None.

How this fits together

Official external plugin catalogs feed plugin listing and package lookup in the management service. The filter validates each feed entry’s declared installation sources before those entries are exposed to catalog consumers.

flowchart LR
  A[Hosted catalog feed] --> B[Catalog loader]
  C[Configured source profiles] --> D[Source reference snapshot]
  B --> E[Entry source validation]
  D --> E
  E --> F[Filtered catalog entries]
  F --> G[Plugin listing and lookup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -14, Tests +35. Total +21 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 24 38 -14
Tests 1 42 7 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 66 45 +21

Review metrics

Metric Value Why it matters
Production vs test LOC production -14, tests +35 The refactor removes a private error accumulator while the added test cases protect candidate validation, ordering, identity, and next-load configuration refresh.

Technical review

Best possible solution:

Retain one lazy source-reference snapshot per filter invocation, preserving complete candidate validation and fresh configuration evaluation on later catalog loads.

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

Not applicable: this PR is an internal performance refactor rather than a report of broken user-facing behavior.

Is this the best way to solve the issue?

Yes. A lazy per-call snapshot removes repeated preparation without an eager empty-batch read or a stale cross-load cache.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused internal performance refactor with preserved catalog acceptance behavior.
  • 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, behavior-neutral control-plane refactor is exempt from the external-contributor proof gate; its changed hosted-load test directly covers the preserved validation boundary.

Label justifications:

  • P3: This is a focused internal performance refactor with preserved catalog acceptance behavior.
  • 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, behavior-neutral control-plane refactor is exempt from the external-contributor proof gate; its changed hosted-load test directly covers the preserved validation boundary.

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)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • cxy: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete merged commit 74db4da into main Sep 4, 2026
184 checks passed
@steipete
steipete deleted the codex/perf-sep04-catalog-source-refs branch September 4, 2026 16:00
@steipete

steipete commented Sep 4, 2026

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

2 participants