Skip to content

improve: reduce plugin ownership allocations on large inventories - #167364

Merged
RomneyDa merged 1 commit into
mainfrom
fix/plugin-ownership-phase-paths
Oct 15, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/plugin-ownership-phase-paths

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Plugin ownership checks repeatedly canonicalize the same paths while checking installed packages, creating avoidable startup and status-command allocations on large inventories.

User Impact

Reduces transient allocations for plugin-heavy startup and status checks. Ownership, update, uninstall, and containment rules are unchanged; no configuration or migration is required. Gateway peak-RSS improvement is not established.

Why This Change Was Made

Prepare each root and install record once within the existing synchronous ownership phase. Reject impossible canonical POSIX prefixes cheaply, while leaving actual containment and all Windows path rules with the existing path owner. A new phase still gets a fresh resolver after updates or yields.

Evidence

  • Actual native CLI inventory verified 80 installed plugins before Gateway startup and plain status execution.
  • Native cumulative sampled allocations through the ownership owner fell from 288.25 to 10.12 MiB. These include collected objects and are not retained heap or qualification evidence.
  • One unprofiled local replay reduced status CLI process-tree peak from 904.2 to 854.0 MiB. Gateway peak increased from 1130.9 to 1151.1 MiB; no overall RSS pass is claimed.
  • Release source: 41 existing ownership/update/cohort tests passed. Final independent P0–P2 review is scoped-clean. Complete release and fresh-main changed-file gates passed; fresh-main tests passed all 39 existing cases (119.75 s including compiler preparation; no tests edited). Those earlier measurements and checks apply to their recorded source revisions.
  • Linux qualification outcome: run 37819859658 completed red under unchanged budgets. Its mock-provider lane tested 0b82c02587a301a6918856ad44d915122dbe6f77; the ownership module has the same SHA-256 (e643a2c7b4ca677f2e788cb227824269c8966cde170d9ac44325b8805a00d134) as the reviewed PR head a7320ff5da0b14231ec676d277806533113e8a7b. The run's workflow SHA is a different identity, 2b988ee83444f08ccaf37aa5e98f370726c75f6e.
  • The retained mock-provider report contains 3 PASS, 1 BLOCKED, and 1 FAIL. fresh-install/onboarded-user was blocked because the status CLI CPU confidence interval (116.8–204.2%) straddled its 200% ceiling. gateway-performance/many-bundled-plugins failed at 1,202 MiB peak RSS against the unchanged 1,177 MiB budget. The mock agent-turn scenario passed. The source-performance lane passed. No baseline comparison was recorded, so these failures cannot be attributed to this optimization or declared inherited. Linux/RSS qualification is not claimed, and no thresholds or baselines were changed.
  • Rebased onto current main to preserve the dormant bundled-plugin reload repair from fix(plugins): reload bundled plugins with dormant registry records #167647. The current fs-safe 0.26.5 containment implementation was inspected: canonical POSIX descendants still require the rejected prefix, and Windows still bypasses this optimization. On head 2984019b34229c55bc8a2f2fc5b10f01150732b5, five existing ownership/update/uninstall/service-reload files passed all 45 tests (pnpm test <five files> --maxWorkers=1, 168.16 s including 44.69 s compiler preparation; no new test/CI cost). The exact management reload subset, including bundled selection with a dormant install record, also passed 11/11 (pnpm test src/plugins/management-service.test.ts --maxWorkers=1 -t reload, 47.69 s; 8 unrelated cases excluded by the filter). Core typecheck, changed-file lint, formatting, and git diff --check passed.

No new tests, dependencies, cache lifetime, schema, retention, activation behavior, or public SDK changes.

Exact-head CI on 2984019b34229c55bc8a2f2fc5b10f01150732b5 passed: run 38666737090, including the trusted aggregate gate. Fresh ClawSweeper review is platinum, ready for maintainer review, with no findings or remaining checklist items.

@clawsweeper

clawsweeper Bot commented Oct 8, 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 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 Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR prepares plugin package paths once per synchronous ownership phase and skips impossible POSIX containment matches.

Example: Startup and status inspect an inventory of 80 installed plugins.

  • Before: Ownership scans repeatedly prepare the same paths; the PR reports 288.25 MiB of cumulative sampled allocations through this owner.
  • After: Paths are prepared once per phase; the reported sampled allocations fall to 10.12 MiB, without an established Gateway peak-RSS improvement.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving optimization supported by reported native allocation measurements and existing lifecycle coverage; broader performance qualification is explicitly unclaimed.
Proof confidence 🐚 platinum hermit (4/6) This MEMBER-authored PR is outside the ordinary contributor proof gate; its complete body reports native Gateway startup and status with 80 installed plugins, reduced sampled allocations through the changed owner, and explicitly unsuccessful Linux/RSS qualification.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Plugin-heavy startup and status checks allocate temporary objects while repeatedly preparing the same installed package paths.
Reason: Reported allocation savings justify the narrow optimization, and maintainer authorship establishes direction; broader RSS improvement is appropriately unclaimed.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR contains useful allocation reductions absent from main, with no actionable patch defect found; the previous review’s qualification clarification is addressed.

Priority: P3
Reviewed head: 2984019b34229c55bc8a2f2fc5b10f01150732b5

Before merge

None.

Findings

None.

Agent review details

How this fits together

The plugin ownership resolver consumes installed package records and discovered plugin roots, then supplies ownership, conflict, orphan, update, and reload decisions to inventory and lifecycle callers.

flowchart TD
  A[Installed package records] --> C[Synchronous ownership resolver]
  B[Discovered plugin roots] --> C
  C --> D[Prepared canonical paths]
  D --> E[Canonical containment guard]
  E --> F[Ownership and conflict results]
  F --> G[Inventory and package lifecycle]
Loading

Technical review

Best possible solution:

Keep path preparation within the existing synchronous resolver and limit performance claims to the measured allocation savings.

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

This is a performance improvement rather than a behavior defect; source confirms repeated path preparation, and the PR reports native startup and status measurements with 80 installed plugins.

Is this the best way to solve the issue?

Preparing paths within the existing resolver addresses repeated normalization without adding a competing containment owner or extending cache lifetime.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit feb2c06 adds src/plugins/installed-plugin-package-ownership.ts:67 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: feb2c06bca41; files: src/plugins/installed-plugin-package-ownership.ts)
  • ToToKr: Raw commit 9aa82b1 adds src/plugins/installed-plugin-package-ownership.ts:47 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 9aa82b18253b; files: src/plugins/installed-plugin-package-ownership.ts)

PR surface

Source +17. Total +17 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 38 21 +17
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 38 21 +17

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a focused internal allocation optimization with preserved behavior and no established urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-08T17:59:36.756Z sha a7320ff :: needs changes before merge. :: none
  • reviewed 2026-10-08T18:04:53.166Z sha a7320ff :: needs changes before merge. :: none

Reviewed October 14, 2026, 9:41 PM ET / October 15, 2026, 01:41 UTC (Revision 3).

@RomneyDa
RomneyDa force-pushed the fix/plugin-ownership-phase-paths branch from a7320ff to 2984019 Compare October 15, 2026 01:38
@RomneyDa
RomneyDa marked this pull request as ready for review October 15, 2026 01:38
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment @clawsweeper review. Please avoid repeated requests while a review is queued or running; agents should not request reviews automatically.

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@RomneyDa
RomneyDa merged commit 0b746fa into main Oct 15, 2026
207 of 210 checks passed
@RomneyDa
RomneyDa deleted the fix/plugin-ownership-phase-paths branch October 15, 2026 16:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant