Repository navigation
improve(plugins): speed up capture while preserving dependency resources - #166955
Conversation
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesPlugin preparation copies small ordinary POSIX files faster while preserving complete dependency resources, independent snapshots, and guarded copying for other files. Review scores
ProductKind: Performance · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains useful beyond main’s batching work and is not fully superseded by the overlapping proposal. No actionable correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherBefore running an external plugin, OpenClaw captures its package and dependencies into files owned by the plugin instance. Gateway and Doctor preparation consume these verified snapshots. flowchart TD
A[Plugin package and dependencies] --> B[Admit and pin source file]
B --> C{Small ordinary POSIX file?}
C -->|Yes| D[Bounded descriptor copy]
C -->|No| E[Batched guarded copy]
D --> F[Verify source and captured contents]
E --> F
F --> G[Gateway or Doctor uses snapshot]
Technical reviewBest possible solution: Keep the measured optimization in the existing capture owner while preserving complete resources and treating asynchronous scheduling as separate work. Do we have a high-confidence way to reproduce the issue? Not applicable as a new bug report: supplied matched production-capture measurements establish the performance opportunity, and current-main source retains the targeted guarded-copy overhead. Is this the best way to solve the issue? Yes: it improves the measured cost in the existing copy owner while retaining snapshot and publication checks. It accurately leaves synchronous capture and broader scheduling work unresolved. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 05f7473e9ddb. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +97, Tests +228. Total +325 across 4 files. Added test files: 2. View PR surface stats
Review metrics
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 (10 earlier review cycles; latest 8 shown)
Reviewed October 9, 2026, 6:18 PM ET / 22:18 UTC (Revision 11). |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ces (openclaw#166955) * improve(doctor): avoid capturing unused plugin dependency trees * perf(plugins): preserve dependency resources while reducing copy admission * test(plugins): remove redundant copy helper call assertions * test(plugins): fix copy safety lint and assert failed retries --------- Co-authored-by: Dallin Romney <[email protected]>
What Problem This Solves
Gateway and Doctor preparation can take minutes to capture external plugins with many small dependency files.
User Impact
Plugin preparation copies small ordinary POSIX files faster while retaining complete packages, dependency resources, independent snapshot bytes, and existing capture safeguards. Large files, native binaries, Windows, and aliased output directories retain guarded cloning. Capture remains synchronous.
Why This Change Was Made
Optimize the existing file-copy owner using pinned source descriptors, exclusive outputs, bounded transfers, identity checks, and receipt verification. Automatic dependency deferral was removed because Doctor callbacks can read dependency resources without importing their modules. No configuration, schema, receipt format, or stored-data contract changes.
Evidence
Conflict repair
b757d63f841integrates main6eacab6c294, preserving the batched guarded-copy API and small-file descriptor path. Streaming tests now intercept the batch API; batching fixtures remain above the small-file threshold. Fresh AutoReview found no actionable P0–P2 findings, and the PR diff passesgit diff --check. The earlier CI below applies to45d4ef71c93; replacement-head CI passed. Fresh ClawSweeper review ofb757d63f841rates it platinum hermit with no findings.Matched 60-package / 2,400-payload fixture: capture decreased from 13.435 s to 3.117 s, retaining all 9,830,400 payload bytes, independent files, modes, and the same artifact digest. These are isolated measurements on a loaded host.
Contributor proof covers compiled Gateway diagnostics, Doctor repair, repaired Gateway readiness, and a successful unchanged published
2026.9.5updater against an existing npm lossless-claw installation. This does not prove steady-state throughput or LCM compaction.Maintainer cleanup
45d4ef71c93: fixed all eight CI brace-style errors and made the disk-full retry assertion fail if no rejection occurs. Production source is unchanged. Fresh independent AutoReview found no actionable P0–P2 findings;git diff --checkpassed. Exact-head CI run passed: all selected test shards, formatting/lint, production/test types, architecture/source guards, and security checks. Fresh ClawSweeper review of this head rates it platinum hermit with no findings.The prior head passed all test shards, type checks, guards, and security checks; its only failing job was
check-lint-core-3for the eight corrected errors. Isolated AWS validation could not allocate because the fleet active-lease limit was exceeded; final verification uses the attached secretless fork CI.Original contributor proof and qualification details
What Problem This Solves
Gateway and Doctor preparation can spend minutes capturing large external plugin trees. Repeated guarded pathname admission during small-file cloning accounts for much of that cost.
User Impact
Capture still includes the complete plugin package and all declared dependency resources. Small ordinary POSIX files use a pinned source descriptor and an exclusively created output; native binaries, larger files, Windows, and aliased output directories retain the existing guarded clone path. This reduces capture work while preserving resource-only filesystem reads and immutable snapshots.
Why This Change Was Made
The earlier automatic dependency deferral broke Doctor callbacks that read dependency resources without importing their modules. That finding was reproduced and the deferral change is removed. The replacement optimizes the existing file-copy owner and retains source containment, source/output identity checks, exact byte bounds, independent copied bytes, receipt hashing, and final source verification.
The ownership contract introduced by #144252 remains: the managed instance keeps complete captured source and dependencies through admitted work and cleanup. The dependency sibling-resource availability protected by #153546 is retained. No manifest option, persistent schema, receipt format, or serialized data contract changes. Failed acquisitions remain unpublished and unavailable for alternate imports or recovery.
Evidence
2ac9769; the three redundant helper-call-count cases were subsequently removed in test-only commit1e4ea3463c0, leaving 60 retained tests. The affected copy/streaming subset was rerun: 24 passed, 12.04 s wrapper wall time; formatting passed. Combined Doctor/resource/copy/streaming/sibling/setup tests before that removal: 53 tests, 24.22 s wrapper wall time. Native-reference/layout tests: 10 tests, 17.92 s wrapper wall time. New copy safety cases cover source growth/shrink/replacement/symlinks, output substitutions/hardlinks, ENOSPC, exact bytes/mode/identity, and existing capture-boundary clone coverage. The resource-only callback regression fails on the prior deferred revision and passes with complete capture while retaining the captured bytes after the installed resource changes. The previous cache-size test and three redundant helper-call-count branch cases were removed.pnpm buildpassed at runtime revision2ac9769(3m 4.6s build phase time), and the canonical self-contained package passed tarball inventory/import-graph integrity checks. The build emitted a UI startup gzip size warning; no UI inputs changed and its baseline was not compared.2ac9769: the invalid-config diagnostic owner read the own-package asset, required dependency, and dependency 1 resource without importing dependency 1, with callback PID matching the Gateway. It correctly refused invalid config with exit 78. Supported Doctor repair exited 0 and persisted the repair; the repaired Gateway reached readiness and passed ten HTTP health/readiness checks and authenticatedhealth/system.infocalls. Private fixtures/listeners were cleaned. Test-only follow-up1e4ea3463c0leaves the runtime source byte-identical; SHA-2563a67cd2bfbd36f943fe0d386df29be890fef6e6e83336343cc0c6d9b435479b2. This proves the resource path through actual Gateway/Doctor entry points, not steady-state performance or off-thread capture.OpenAiCompatibleImageProviderOptionstype in untouched image-generation code; the same finding reproduced on unmodified baseline318c60f2. No guard was skipped.2026.9.5CLI ranopenclaw update --tag <candidate.tgz> --yes --json --no-restartagainst an existing genuine npm lossless-claw0.12.0install in a private canonical-account fixture. Driver exit 0 in 495.527 s; durable ledgerfinished/succeeded, reason null, rune3a8a2e3-ad57-4fdc-a9d2-0216b5e3ede7. Installed build matches2ac9769and tarball SHA-256be39cd0128519fb0961c4b977dceac72d8ec523b7f35805d7da82f25cadb6165. All candidate gates passed, including actual Gateway canary startup (4.517 s), post-plugin Doctor lint (2.375 s), and final config validation. The authoritative install record still resolves the same LCM version; Doctor SHA-256 remains494b9efbc1bae0dc2e0dc5a11e9f3623b3347440fb35580f012f54d895d9eecf. Five observed canary contract reads include the actual staged Doctor and Gateway process, with three observed repaired-policy publications/readbacks. No plugin source overlay or replaced product method. LCM runtime activation was disabled; this qualifies existing-install/Doctor/update behavior, not LCM compaction or live Gateway throughput.Sanitized terminal evidence (real compiled entry points and unchanged published driver; private paths/auth omitted):
Related drafts #161456 and #161827 provide asynchronous capture resource admission and native-worker catalog capture ownership. At inspected heads
ecd429f1and35d1c1c7, neither offloads ordinary Gateway file/dependency copying, hashing, and source verification. They remain useful foundations for that separate runtime work; this PR reduces synchronous copy cost.