Repository navigation
fix(clawhub): prevent failed archive staging from leaking temporary files - #127065
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready proof for exact head The actual acquisition owner reproduced all five pre-fix partial-write leaks: its 17 existing cases passed, while each new ClawPack/package/skill/resolver/GitHub Direct docs, types, installed distribution, immutable lock, and disposable-filesystem proof verify Fresh mandatory Codex autoreview and the independent adversarial review of this exact committed head both report zero findings. Native exact-head review artifacts validate as Exact-head required CI is green: https://github.com/openclaw/openclaw/actions/runs/32455625580. CodeQL is green: https://github.com/openclaw/openclaw/actions/runs/32455625560. Dependency Guard is green: https://github.com/openclaw/openclaw/actions/runs/32455625614. ClawSweeper's latest exact-head comment currently reports |
|
Merged via squash.
|
Closes #127057
AI-assisted: Codex; the implementation and evidence were independently reviewed.
What Problem This Solves
Fixes an issue where users installing ClawHub plugins or skills would retain a private temporary directory and partially written archive when staging failed with a filesystem error such as
ENOSPCbefore the caller received a cleanup handle. ClawPack packages, legacy package archives, versioned skills, resolver-backed skills, and GitHub-backed skills were all affected. The defect is also present in stablev2026.7.1under the earliersrc/infra/clawhub.tsowner.Why This Change Was Made
One private archive-staging owner now allocates the existing temporary target, writes and constructs the unchanged download result while it still owns cleanup, and performs best-effort identity-checked workspace cleanup before rethrowing the exact original failure. Successful downloads continue transferring the existing cleanup handle to their callers; their filenames, bytes, SHA-256 integrity values, and all ClawPack SHA-512/SHA-1/header metadata are unchanged. ClawPack reuses its already-validated SHA-256 digest, and ordinary archives hash their bytes once through the existing shared helper before deriving both integrity representations.
Rejected alternatives: caller-side cleanup cannot work because failed acquisition never returns a target; five independent
try/catchblocks preserve the duplicate lifecycle bug surface; unlinking a pathname directly could delete a replacement path and would bypass the existing workspace identity contract.User Impact
Failed ClawHub plugin and skill downloads release their own partially staged archive and temporary directory immediately, keep unrelated files and replacement paths intact, and still report the original filesystem error. Successful installs, preflight behavior, verification metadata, public result shapes, and caller-owned cleanup remain unchanged.
Evidence
4b48c0b2786b0a17d28bdebb156c192462a7fd60.ENOSPCfailures, five complete success/result/cleanup contracts, preservation of a renamed-workspace replacement, and cleanup/logger-failure error precedence.@openclaw/[email protected]cleanup outcomes:removed,missing, andidentity-mismatch; a preexisting replacement marker and unrelated sibling survive. The identity check is not claimed to be atomic against a replacement during the cleanup call.node scripts/check-changed.mjs -- src/infra/clawhub-artifacts.ts src/infra/clawhub-artifacts.test.ts, targetedoxfmt --check, andgit diff --checkpass.+47/-60(net-13); tests:+202/-4(net+198). No new file, dependency, exported helper, Plugin SDK change, config surface, persistence change, install-flow change, orCHANGELOG.mdedit.