Repository navigation
perf(plugins): batch guarded copies in plugin capture - #167516
Conversation
Reuse guarded directory admission within each synchronous plugin capture while retaining per-file integrity checks and disposable ownership. Related: #166526.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Dependency graph guard clearedThis PR no longer has dependency changes awaiting review. A future dependency graph change from an external contributor requires a maintainer's
|
|
Codex review: needs maintainer review before merge. What this changesThe branch shares guarded directory admission across each synchronous plugin capture traversal while preserving individual file verification and cleanup. Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This PR retains a useful, bounded optimization absent from current main. No actionable defect was found, and the introduced files are unchanged since the previous reviewed head. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherOpenClaw captures plugin files into private snapshots for Doctor and Gateway loading. Source identity checks and content receipts verify those snapshots before plugin code uses them. flowchart TD
A[Doctor or Gateway startup] --> B[Plugin capture owner]
C[Plugin source files] --> B
B --> D[Traversal-scoped copy batch]
D --> E[Fresh directory and file checks]
E --> F[Private copied files]
F --> G[Content receipt verification]
G --> H[Plugin loading]
Technical reviewBest possible solution: Keep disposable traversal batching within the existing capture owner, preserving fresh file checks and independent instance cleanup while broader Doctor latency remains tracked separately. Do we have a high-confidence way to reproduce the issue? Yes: current source repeats single-file directory admission, and the recorded capture negative control isolates that overhead. This read-only review did not execute the scenario. Is this the best way to solve the issue? Yes for the scoped overhead: the dependency's existing disposable batch removes repeated admission work without introducing a competing cache owner or relaxing file checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e6ca676b02b6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +13, Tests +44. Total +57 across 3 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 9, 2026, 2:38 AM ET / 06:38 UTC (Revision 5). |
|
Merged via squash.
|
Reuse guarded directory admission within each synchronous plugin capture while retaining per-file integrity checks and disposable ownership. Related: openclaw#166526.
Align ENOSPC injection and native-copy observation with d1e15b4 (openclaw#167516), which moved plugin generation capture to the fs-safe batch API. Keep the real loader, error guidance, Doctor outcomes, and copy-budget assertions.
Related: #166526
What Problem This Solves
Plugin capture repeatedly resolves and admits the same directories when Doctor or Gateway startup copies many files from a package.
User Impact
Plugin capture performs less repeated filesystem work while preserving each file's source identity, path containment, hardlink policy, byte bound, permissions, content receipt, and cleanup guarantees.
Why This Change Was Made
Use
createRootFileCopyBatchSyncfor each synchronous capture traversal. Recursive copies share one bound callback, and the traversal disposes its batch before returning. Later acquisitions and native namespace copies retain independent ownership.The adoption preserves main’s capture-custody behavior: retained-source validation, native admission, retained content facts, and receipt checks. Both the batching and custody regressions exercise the combined implementation.
This PR contains only the two capture source files and the streaming test. It carries no dependency, lockfile, workspace, or Doctor-budget changes. Production LOC is +18/-5 (net +13) for the disposable batch lifetime and callback wiring; no integrity checks were removed to offset that growth.
Evidence
Validated head:
1927d181ddb876c92d3ad3aac200e0b5b91af35b, including main18cade08699b24ecfd0be142cdf16d90b3af9fbd.The streaming and Doctor custody suites passed together: 37 tests, 28.26 seconds wall. Core types, the covering plugin test-type graph, targeted lint/format, and the canonical package-preparation build passed. Fresh independent branch review found no actionable P0–P2 findings. ClawSweeper reviewed this exact head with no findings or required changes.
The regression exercises real captures: 16 sibling files require 802 directory metadata reads with batching versus 1,072 when only the two production files are reverted to integrated main, keeping fs-safe 0.25.0 installed. The negative control fails the intended 911.2-read bound (29.05 seconds wall). Candidate bytes were restored before publication.
Exact-head CI and CodeQL passed. The streaming CI file passed 28 tests with one APFS-only skip (3.26 seconds Vitest, 4.72 seconds wrapper, 5.09 seconds total; 42 ms for the batching regression). On the replacement AWS lease, all 18 module/Doctor files passed: 273 tests and one platform skip, 246.38 seconds wall. Core and the three covering test-type graphs passed, and the normal source build passed in 329.5 seconds.
The complete sqlite-volume published-upgrade survivor passed on this head, using baseline
[email protected]and the candidate built from source on AWS. Repeat Doctor completed in 175 seconds against the computed 717-second budget. The budget came from the measured state: 4,803 sessions, 23,893 events, 2,203 cron jobs, and 9 enabled plugin roots; computed and applied budgets were equal, with no override.The post-Doctor state assertion, Gateway restart and probes, restarted history checks, and final survival assertion all passed. Both real Gateway history probes verified eight conversations across two agents; all sampled message digests matched before and after restart. The final summary reports
status: passed,failure: null, candidate2026.9.9, andupdateOutcome: success. The command and wrapper both exited 0; the scenario took 1,161 seconds.This comparison is descriptive: the custody reference used
c7a.8xlargeand fs-safe 0.24.2; this run used an explicitly pinnedr7a.xlarge(4 vCPU, 30.6 GiB usable RAM) and fs-safe 0.25.0, with later main changes. Both used Node 24.21.0, pnpm 12.5.1, and Docker 29.8.2. The production-only negative control above separately isolates the batching change at fs-safe 0.25.0.AWS lease:
cbx_48da0cc83d58; run:run_679e106c17a85bfc3b1f00cbf6a12547. The fresh PR checkout verified the exact source SHA/tree, the trusted bootstrap verified the secretless instance boundary and pinned toolchain, and the normal source build/package integrity checks ran on the lease. No heap, resource, or Doctor-budget override was used. The earlier quota-downgraded 2 GiB allocation was OOM-killed during candidate installation; the explicitly pinned replacement completed successfully.Excerpts:
Validation commands:
The source build emitted the existing advisory Control UI startup-size overage (364.8 KiB versus 364.7 KiB); the build passed and no budget was changed. This PR remains partial work toward the broader Doctor issue.