DSH / Atlas
2026-09-06implementedbug-fix

Packed-install verification owns its npm cache

打包安装验证拥有独立 npm 缓存

The [packed-install verifier](../../../../scripts/release/verify-packed-install.ts) removes its temporary consumer but an npm install using the ambient cache leaves tarball content and logs outside that cleanup. Repeated release rehearsals can therefore grow the shared runner user cache even when every consumer is removed. A full root filesystem can fail unrelated CI jobs.

English

Problem

The packed-install verifier removes its temporary consumer but an npm install using the ambient cache leaves tarball content and logs outside that cleanup. Repeated release rehearsals can therefore grow the shared runner user cache even when every consumer is removed. A full root filesystem can fail unrelated CI jobs.

Decision

The verifier passes --cache <consumerRoot>/.npm-cache only to its npm install invocation. The explicit argument overrides npm environment and user-configuration cache settings without changing the environment of the installed executable. The existing finally removes this cache together with the consumer after success, an install failure, or an executable failure.

The release sequence decision still owns artifact selection and publication. This decision only adds cache ownership to the verifier; it does not change other npm consumers.

Alternatives considered

  • Delete the shared user cache: unrelated jobs also own its contents. The verifier must not delete shared host state.
  • Change global TMPDIR or npm configuration: that affects processes outside this invocation and is unnecessary when the consumer already has an owned temporary directory.
  • Keep a persistent verifier cache: that retains cross-run downloads but requires a separate retention policy. Invocation ownership accepts repeated downloads instead.

Consequences

This prevents this verifier from adding content to the ambient npm cache; it neither reclaims existing host cache contents nor guarantees that disk exhaustion from other producers stops. External dependencies can require fresh downloads on each invocation. A forced termination that prevents finally from running can leave the consumer and its cache behind; this change adds no crash-recovery cleanup.

Verification

The focused regression runs the real verifier and npm offline against a tiny local tarball. A lifecycle script records actual private _cacache files before cleanup. The tests verify consumer removal after success, npm install failure, and installed-entry failure, while inherited environment and user-config cache canaries remain unchanged. Removing the cache argument makes the private-cache assertion fail. The executable test follows the POSIX release runner path; it does not exercise Windows command-shim resolution.

中文

问题

打包安装验证器 会删除临时消费目录,但使用环境配置缓存的 npm install 会把 tarball 内容和日志留在清理范围之外。因此,即使每个消费目录均被删除,重复的发布演练仍可能扩大共享 runner 用户缓存。根文件系统满载会使无关 CI 作业失败。

决策

验证器仅向自己的 npm install 调用传入 --cache <consumerRoot>/.npm-cache。显式参数覆盖 npm 环境变量和用户配置中的缓存设置,不改变已安装可执行文件的环境。现有 finally 在成功、安装失败或可执行文件失败后将此缓存与消费目录一起删除。

发布序列决策 仍负责产物选择与发布。本决策仅为验证器增加缓存所有权,不改变其他 npm 消费方。

曾考虑的替代方案

  • **删除共享用户缓存:**其他作业也拥有其中的内容。验证器不得删除共享宿主状态。
  • **修改全局 TMPDIR 或 npm 配置:**这会影响本次调用之外的进程,而消费目录已有独立临时目录,因此没有必要。
  • **保留持久化验证缓存:**这能跨运行复用下载,但需要独立保留策略。调用级所有权选择接受重复下载。

后果

这会阻止该验证器向环境配置的 npm 缓存添加内容;既不会回收现有宿主缓存,也不保证其他来源导致的磁盘耗尽停止。外部依赖可能需要在每次调用时重新下载。若强制终止使 finally 无法运行,消费目录及其缓存仍可能残留;本改动不增加崩溃恢复清理。

验证

定向回归测试 使用微型本地 tarball 离线运行真实验证器和 npm。生命周期脚本在清理前记录私有 _cacache 中的实际文件。测试验证成功、npm 安装失败和已安装入口失败后消费目录均被删除,同时继承环境和用户配置指定缓存中的探针文件保持不变。移除缓存参数会使私有缓存断言失败。可执行测试沿用 POSIX 发布 runner 路径,不覆盖 Windows 命令垫片解析。