Skip to content

refactor(plugins): extract ClawHub plugin archives once - #156246

Merged
steipete merged 2 commits into
mainfrom
codex/fs-safe-clawhub-extraction-20260923
Sep 23, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fs-safe-clawhub-extraction-20260923

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Related: #154370

What Problem This Solves

ClawHub plugin archives without a whole-archive hash are currently decompressed for file verification and then extracted again for installation.

User Impact

These installs now extract once and verify the complete extraction before selecting a package root or starting installation. Integrity refusals, archive limits, transaction authority, cleanup, and existing plugin configuration remain enforced.

Why This Change Was Made

The existing installer owns extraction and its temporary workspace. ClawHub keeps a metadata-only ZIP preflight and supplies verification of the resulting files to that owner. The preflight inventory remains authoritative for entries that extraction cannot materialize, so unsupported records cannot disappear from integrity verification. Hashing uses the existing bounded file-digest owner and fs-safe handles instead of a second custom ZIP stream implementation.

The verification hook runs before package-root selection can hide sibling files. Typed ClawHub failures pass back through the installer, and success events are emitted only for successful installs. Filesystem access and directory walking use OpenClaw's existing policy owners. This removes 48 production lines; no dependency, configuration, or stored-format change is included.

Evidence

  • The actual extraction/installer tests cover valid archives, corrupt payloads, raw ZIP names, unsupported records, complete-root verification, typed refusals, cleanup, and transaction authority loss. Real installation accepts ./extra.txt and repeated separators. The unsupported-record comparison proves refusal after real extraction; the final source-install step is mocked in that specific case.
  • node scripts/run-vitest.mjs src/plugins/clawhub.test.ts src/infra/install-flow.test.ts src/plugins/install.work-deadline.test.ts --maxWorkers=1 --reporter=dot: 113 tests passed in 172.37 seconds wall time, including 79.385 seconds of worker preparation.
  • Core production typechecking passed in 14.24 seconds. All 25 test type graphs passed; the affected plugin-test graph passed again after the type-inference correction. All selected check components passed across the original and resumed runs; the final segment completed 11/11, exit 0, in 578.60 seconds. Formatting and git diff --check passed, and retired helpers have no remaining references.
  • Initial CI caught a direct fs-safe import that bypassed OpenClaw's policy facade. The exact boundary test reproduced that failure. The correction uses the existing filesystem facade and bounded directory-walk owner; 136 focused tests then passed in 45.44 seconds and all seven affected checks passed in 125.42 seconds. Fresh independent scoped review found no actionable findings.
  • The lead also inspected the type-only NoInfer adjustment and equivalent property access. The assertion-safety baseline shrinks exactly from 10 to 7.
  • Proof uses synthetic archives with the actual local installer on macOS. No live ClawHub or Windows execution is claimed. Literal ~/ entries remain an existing fs-safe 0.18.1 extraction limitation in both native modes; this change adds no policy exception.

@clawsweeper

clawsweeper Bot commented Sep 23, 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.

@steipete
steipete marked this pull request as ready for review September 23, 2026 05:55
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 2:03 AM ET / 06:03 UTC.

ClawSweeper review

What this changes

ClawHub plugin installs reuse one archive extraction for file verification and installation, preserving typed failures and cleanup.

Merge readiness

✅ Ready for maintainer review

Keep open: this useful consolidation is absent from current main and the latest release. No blocking correctness or security defect was found in the introduced changes.

Priority: P3
Reviewed head: b4c13287d2ded0b6f0230b0e67ba1c40b4150037

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with meaningful production-boundary coverage and no actionable introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Reported macOS filesystem runs exercise the actual extraction and installer owners, including installed-file readback, hash refusal, cleanup, and authority-loss rejection. Mocked registry inputs do not replace the changed filesystem boundary; live ClawHub and Windows behavior are not claimed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Reported macOS filesystem runs exercise the actual extraction and installer owners, including installed-file readback, hash refusal, cleanup, and authority-loss rejection. Mocked registry inputs do not replace the changed filesystem boundary; live ClawHub and Windows behavior are not claimed. No stored-data contract changes.
Evidence reviewed 10 items Pinned introduction and merge scope: Reviewed the merge-base-to-head changes. The recorded test merge has the pinned base followed by the exact PR head as parents; unrelated base changes were excluded from ownership claims.
Current main still performs separate verification: Current main calls verifyClawHubArchiveFiles before installPluginFromArchive and retains the separate streaming decompression helpers. The central simplification remains necessary.
Latest release check: The published v2026.9.5 source also retains separate streaming file verification followed by archive installation. No release implementation supersedes this PR.
Findings None None.
Security None None.

How this fits together

The plugin installer receives downloaded archives and registry integrity metadata. It verifies the archive, selects the package, and passes approved contents to the existing installation and publication machinery.

flowchart TD
  A[Downloaded archive and registry metadata] --> B[ZIP metadata preflight]
  B --> C[Single bounded extraction]
  C --> D[Verify complete file inventory and hashes]
  D -->|Rejected| E[Typed failure and cleanup]
  D -->|Verified| F[Select package root]
  F --> G[Existing policy and publication guards]
  G --> H[Installed plugin and cleanup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -51, Tests +178, Other 0. Total +127 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 134 185 -51
Tests 3 402 224 +178
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 7 537 410 +127

Review metrics

Metric Value Why it matters
Production versus test delta Production −51 lines; tests and test support +178 lines The consolidation removes a custom decompression owner while adding coverage for the shared verification boundary.

Technical review

Best possible solution:

Keep one bounded extraction owner, with complete archive verification before package selection and existing guarded publication.

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

Not applicable as a defect reproduction: source inspection confirms the redundant decompression on current main, and the PR reports direct filesystem validation of its replacement.

Is this the best way to solve the issue?

Yes. Reusing the existing extraction workspace removes duplicate ownership while retaining complete-inventory verification and downstream installation guards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7f50ce061649.

Labels

Label changes:

  • add P3: This is a bounded internal installation cleanup without an established urgent user-facing regression.
  • add proof: sufficient: Contributor real behavior proof is sufficient. Reported macOS filesystem runs exercise the actual extraction and installer owners, including installed-file readback, hash refusal, cleanup, and authority-loss rejection. Mocked registry inputs do not replace the changed filesystem boundary; live ClawHub and Windows behavior are not claimed. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a bounded internal installation cleanup without an established urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient. Reported macOS filesystem runs exercise the actual extraction and installer owners, including installed-file readback, hash refusal, cleanup, and authority-loss rejection. Mocked registry inputs do not replace the changed filesystem boundary; live ClawHub and Windows behavior are not claimed. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge scope: Reviewed the merge-base-to-head changes. The recorded test merge has the pinned base followed by the exact PR head as parents; unrelated base changes were excluded from ownership claims. (b4c13287d2de)
  • Current main still performs separate verification: Current main calls verifyClawHubArchiveFiles before installPluginFromArchive and retains the separate streaming decompression helpers. The central simplification remains necessary. (src/plugins/clawhub.ts:1374, 7f50ce061649)
  • Latest release check: The published v2026.9.5 source also retains separate streaming file verification followed by archive installation. No release implementation supersedes this PR. (src/plugins/clawhub.ts:1430, 7f50ce061649)
  • Verification precedes package selection: The shared workspace owner awaits verification before resolving the package root or calling installation work. ClawHub seeds verification from the preflight inventory, so unsupported records omitted by extraction remain detectable. (src/infra/install-flow.ts:87, b4c13287d2de)
  • Dependency boundary: The changed verifier directly imports fs-safe root handles and uses sha256File through the existing durability facade; archive extraction is also delegated to fs-safe. These contracts, rather than any Codex runtime contract, determine the changed behavior. The dependency remains pinned to 0.18.1. (src/plugins/clawhub.ts:748, b4c13287d2de)
  • Released extraction contract inspected: Verified v0.18.1 resolves to this dependency commit. Its ZIP extraction enforces byte budgets and integrity checks, rejects symlinks, and can skip unsupported records; this supports retaining the preflight inventory in the consumer. (src/archive.ts:192, fb70418d8cbd)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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

Copy link
Copy Markdown
Contributor Author

Corrected-head CI 35826268422 passed on 21925fdf1811c4793dd1427ae5fbb94a5c10431a, including the previously failing filesystem import-boundary job.

Measured CI test cost:

  • src/plugins/clawhub.test.ts: 97/97 cases passed in its single-file shard, with 5.82 seconds Vitest duration and 7.21 seconds wrapper wall time.
  • src/infra/install-flow.test.ts: 10/10 cases passed, with 164 ms aggregate logged case time. CI does not emit isolated file wall time for this file; its containing 34-file shard took 16.26 seconds in Vitest and 17.87 seconds wrapper wall time (658 passed, 1 skipped).

The original CI failure, owner-routing correction, and local focused proof remain recorded in the PR body.

@steipete
steipete enabled auto-merge (squash) September 23, 2026 06:54
@steipete
steipete merged commit 1b2616a into main Sep 23, 2026
213 of 214 checks passed
@steipete
steipete deleted the codex/fs-safe-clawhub-extraction-20260923 branch September 23, 2026 07:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

vincentkoc added a commit to ycmjbot-bot/openclaw that referenced this pull request Sep 23, 2026
* commit '3ab93b4ea59804b34d02a696382db16dc95189bb': (80 commits)
  fix(gateway): keep session refreshes moving during unrelated writes (openclaw#156286)
  chore(deps): update fs-safe to 0.18.2 (openclaw#156262)
  refactor(plugins): extract ClawHub plugin archives once (openclaw#156246)
  improve(llm-core): avoid unnecessary tool validation sets (openclaw#152066)
  fix(backup): verification accepts archives missing captured databases (openclaw#156211)
  fix: cancel Guest work when its original access is revoked (openclaw#156106)
  fix(test): classify drained legacy migration refusals
  fix(anthropic): finish Opus 5.5 defaults and thinking display (openclaw#156093)
  refactor(agents): share native harness tool execution (openclaw#154217)
  fix(ui): carry typed ownership through short-route resolution
  test(worktrees): accept additive gc result fields (openclaw#156127)
  test(tasks): close sqlite borrowers before registry reload (openclaw#156131)
  chore(autoreview): sync Astra high defaults (openclaw#156175)
  refactor(node-host): await prepared workspace storage (openclaw#149519)
  improve: speed up cold Node test planning (openclaw#156234)
  fix(doctor): avoid slow legacy ownership repair in source checkouts (openclaw#156238)
  improve: speed up native build artifact validation (openclaw#156219)
  fix(ui): preserve short-route resolution ownership
  fix(doctor): name retained session metadata conflicts (openclaw#156162)
  perf(tasks): bound creation selection to matching runs (openclaw#156183)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
)

* refactor(plugins): extract ClawHub plugin archives once

* fix(plugins): keep ClawHub reads behind filesystem policy owners
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant