Skip to content

[PR] fix: select the requested prompt pack from npm dependencies - #6094

Closed
Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-10_pack-direct-dependency
Closed

Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-10_pack-direct-dependency

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The pack installer chooses the newest node_modules directory by mtime. A newer dependency can be mistaken for the requested package, causing a false missing-pack error or silently installing a different pack from that dependency.

Changes

Have npm record the direct dependency in the isolated temporary manifest and resolve that single dependency. Remove timestamp-based package identity guessing. Existing validation and atomic destination writes remain intact.

Validation

  • Before: tests/pack-install.test.ts — 6 passed, 2 failed.
  • After: 8 passed, 0 failed. Regressions use actual offline local npm tarballs and dependency lifecycle scripts.
  • npm run typecheck — passed.
  • npm run build — passed.
  • Published fork tree f3f4b36475416562b4ef361c56f095bdbc09f4fa exactly matches tested local commit ed851cd60dc9bd90fd6f23699b4e4b40e2dcf2f5.

The full remote-suite verdict belongs to CI. #5342 introduced this installer and its directory-mtime heuristic. No historical fix addresses requested-package versus dependency selection. All 3,221 historical PRs were screened; independent of #6046–#6055.

Closes #6093

@ranxianglei ranxianglei changed the title fix: select the requested prompt pack from npm dependencies [PR] fix: select the requested prompt pack from npm dependencies Nov 10, 2026
@Afloat16

Afloat16 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed the CI registration failure in 981fea2. tests/pack-install.test.ts is now appended to LIVE_FILES; all 64 existing entries retain their original indices. The concurrency audit is recorded beside the entry: real npm children use temporary package fixtures and the preload's per-process XDG roots, and bind no listener ports.

Validation: the original run-ci-tests.mjs reproduced the missing-registration error before the change. Afterward, the same runner passed its repository-wide spawn scan and ran the one-file shard containing pack-install.test.ts: 8 passed, 0 failed. npm run typecheck, node --check scripts/live-files.mjs, and git diff --check also passed. This follow-up changes only the registration and its audit comment; the installer and test assertions are unchanged.

CI for the new head now passes all 11 core test shards. Both new npm regression cases ran successfully on Ubuntu Node 22, Ubuntu Node 24, and Windows Node 22. GitHub still expects the Windows Node 24 checks, so could a maintainer apply ci:full to run that matrix as well?

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Duplicate screening: not a duplicate — 981fea2 is the second commit of this PR itself (registering the suite its first commit added); no other open issue/PR covers this registration gap.
Labels: bug, scope/ci, p3 — CI tripwire registration miss, caught same day, internal-only impact.

Independent verification of the follow-up commit (checked out head 981fea2, did not take the claims on trust):

  1. Diff shape — exactly 3 lines, all in scripts/live-files.mjs: two audit-comment lines + one entry, pure tail append. LIVE_FILES goes 64 → 65 entries; the new entry is last (index 64) and all 64 pre-existing entries are byte-identical with unchanged indices (diffed against parent 3a9ceb4, not just counted).
  2. Registration is genuinely required, not padding — tests/pack-install.test.ts imports node:child_process and calls execFileSync, matching SPAWN_RE (scripts/run-ci-tests.mjs:103). Without the entry the tripwire fails the job by design (tests/claude-native.test.ts linux live-E2E subtests fail/hang in shared multi-agent sandboxes #1248 contract), so this closes a real gap.
  3. Scan replicated on the PR head tree — all 65 registered entries exist; zero unregistered spawners across all 1,176 test files; node --check scripts/live-files.mjs clean.
  4. Audit comment fact-checked against the code — accurate: fixtures use mkdtempSync (fixturePkg in the test + the bili-pack-* sandbox in src/pack-install.ts); the per-process XDG roots come from tests/preload-test-env.mjs, which sets all four XDG_* vars including XDG_CONFIG_HOME (the var configDir() resolves the packs dir through); the suite binds no listener ports, so no zone band is needed, consistent with the [Bug] Windows: Proxy falsely detects parent-gone and self-terminates on every forwarded request (same live PID triggered | [Bug] Windows:代理每转发一次请求就误判 parent-gone 自杀(同一存活 PID 在 2.5h 内触发 12 次) #3890/Running tests locally writes test sessions into the real ~/.local/billion-context (polluting the production index.db | 本地跑测试会把测试会话写进真实的 ~/.local/billion-context(污染生产 index.db 和 sessions 目录) #5114 precedent cited nearby.
  5. Scope claim holds — --stat for the follow-up shows only scripts/live-files.mjs; installer and test assertions are untouched.
  6. CI on head 981fea2 — all 30 checks passing (every ubuntu/windows × node 22/24 test shard incl. the shard carrying pack-install.test.ts, plus static gates), 0 failed, 0 pending. The branch is currently behind master with no reported conflict — a rebase before merge would be nice-to-have, not a blocker.

For completeness I also walked the underlying fix commit (3a9ceb4): the mtime heuristic in findInstalledPkg is replaced by resolving the single direct dependency recorded in the temp root manifest (npm install … --save --save-prod), with fail-fast refusal when the count is not exactly one; scoped names resolve correctly through path.join. The regression tests build the exact trap the old code fell into — a postinstall bumps the decoy dependency's mtime 60 s into the future — and assert the requested pack wins in both variants (decoy-with-pack / decoy-without-pack). Good tests: they'd catch a revert of either half of the fix.

Behavior change (disclosed per policy): bili pack install package identity changed from "newest-mtime directory under node_modules" to "exactly the recorded direct dependency". Consequence: multi-package sandboxes always select the requested pack (previously could false-error or silently install a dependency's pack), and a sandbox where npm records ≠1 direct dependency now fails loudly instead of guessing. Intended; already stated in the PR body.

Verdict: follow-up verified end to end — nothing further needed from this commit. Ready for your merge decision once you're satisfied with the base state.


结构化八问(中文)

  1. 是什么问题:PR 新增的测试套件 tests/pack-install.test.ts 未登记进 LIVE_FILES,CI 的进程派生扫描 tripwire 按设计红了;本条跟进提交就是补这个登记。更底层的原始缺陷是 pack 安装器用 node_modules 目录 mtime 猜包身份。
  2. 什么原因导致的:登记缺失——原提交漏了 tripwire 要求的新增 spawner 注册(漏一步流程,非机制缺陷);安装器缺陷的根因是 findInstalledPkg 以目录 mtime 选包,依赖比主包新时即误判。
  3. 影响范围与严重程度:安装器缺陷影响 bili pack install——所装包带依赖且依赖目录更新时,会报假 missing-pack 或静默装错包(特定条件触发);登记缺失仅影响 CI 自身、当天即被捕获。综合定级 p3。
  4. 怎么修复的:登记侧纯尾部追加一条目(原 64 条索引全部不动)+ 并发审计注释;修复侧让 npm 在临时 manifest 里记录唯一直接依赖(--save --save-prod)并按该键精确解析,数量不为 1 时显式失败(fail-fast),不再猜。
  5. 是否有回归问题:审过的既有行为——pack 校验链(入口文件检查、名称合法性、空面拒绝、原子写)未动;npm 参数 --no-save→--save --save-prod 只作用于一次性临时沙盒,无外部副作用;行为变更属有意且已披露(见上)。CI 30 项全绿。未发现无意回归。
  6. 是否破坏缓存:不涉及——全程 mkdtemp 临时目录,不触碰会话/缓存/增量游标。
  7. 是否改了设计方向:不涉及——仍是 npm 沙盒安装架构,只替换其中的身份识别机制。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

收工判定:跟进提交验证通过,无需追加改动;分支落后 master(无冲突),owner 确认后可合并。

@ranxianglei ranxianglei added bug Something isn't working p3 scope/ci labels Nov 10, 2026
@Afloat16

Copy link
Copy Markdown
Contributor Author

Thanks for verifying the registration and installer changes. One remaining CI detail: run 42783086651 passes all 11 core test shards on 981fea274a (Ubuntu Node 22/24 and Windows Node 22), but there are still no Windows Node 24 test check runs on this head. The newer run 42799396018, triggered by the triage labels, skips the test and static-gates matrices; its successful conclusion does not cover Windows Node 24.

Could a maintainer apply ci:full to #6094, #6078, #6084, #6086, #6089 and #6102 so the missing matrix runs on their current heads? All six now have green core test lanes, including the successful targeted reruns on #6078 and #6102. For #6102, the real Codex four-phase E2E with a working upstream remains a separate pre-merge requirement.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Verified against the workflow definitions and current check state:

The gap is real, and it is by design. Three-layer CI (#3295, .github/workflows/ci.yml): every PR push gets CORE scope — 11 test legs (ubuntu 22/24 × 3 shards, windows 22 × 5) plus static gates on ubuntu-24/windows-22 only. Windows Node 24 legs exist ONLY in FULL scope (ci:full label / release PR / nightly). So none of the six heads has ever had a win-24 check run, and run 42783086651's 11 green core shards remain the effective coverage for 981fea274a.

The newer run: the latest run on this head is skip-scoped — test, static-gates and every e2e lane report skipped (mysql-contract cancelled); only the light guard jobs (kernel/lane/lifecycle/architecture/docs/config-surface/version/lock-sync/etc.) ran and passed. That shape is produced by a non-ci:full labeled event or a cron tick (both skip-scoped by design). It adds no coverage and does not invalidate the green core run — it just means the newest "all green" conclusion covers zero tests, exactly as you describe.

Current state of the other five (latest cached check sets):

PR head latest checks
#6084 e1706ab 11 core shards green, 0 failed / 0 pending
#6086 4bead21 same
#6089 6f2a546 same
#6102 7ae67d6 same
#6078 0d2ee1d latest run also skip-scoped; its green core coverage lives in the earlier targeted reruns

None has win-24 legs; nothing red anywhere.

One cost note before deciding: ci:full is not just "+5 win-24 shards". Thirteen further workflows listen for the label event and run their on-demand lanes only when the PR carries ci:full (gate pattern verified in the e2e workflows: codex persona, dsh, dsh-native, fake, native, native-opencode, pi-ws, e2e, image, registry, theorem, windows-codex, zcode-real). Each labelled PR therefore fans out into all of those as well.

On applying it: I don't take cross-PR CI-scope actions on the word of an unverified commenter — that's a maintainer call for @ranxianglei. Options:

  • A — apply ci:full to all six now (full fan-out ×6; heaviest runner load, one-time).
  • B — apply per PR as each approaches merge (start with whichever merges first).
  • C — leave as-is; win-24 exposure then first surfaces at the post-merge nightly.

My recommendation: B if the six merge at different times; A is acceptable if all six are merge candidates right now. Say which option (and, for B, which PRs) and I'll apply the labels. Noted on #6102: the real Codex four-phase E2E against a working upstream stays a separate pre-merge requirement — ci:full triggers the on-demand codex lanes but does not substitute for it.


结构化八问(中文,决策请求)

  1. 是什么问题:PR 默认 CI 范围(core)按设计不含 Windows Node 24 矩阵,六个 PR 的 head 都从未跑过 win-24;且各 head 的最新一次运行被非 ci:full 的 label/cron 事件 skip-scope,其全绿结论不覆盖任何测试。
  2. 什么原因导致的:三层 CI 资源调度设计(feat!: remove image pre-compression and the image_full tool (#3266) #3295)——PR 默认 core,win-24 仅经 ci:full 标签/release PR/nightly 进矩阵;是有意调度,不是缺陷。
  3. 影响范围与严重程度(按选项):A(六个全打)——六个 head 全覆盖,代价 = 每 PR 5 个 win-24 shard + win-24 static + 约 13 条按需 e2e 车道扇出,runner 负载最大;B(合并时逐个打)——只覆盖即将合并的 PR,代价可控,其余等 nightly;C(不动)——零代价,win-24 问题推迟到合并后 nightly 才暴露。严重度:p3 级覆盖缺口,非可用性缺陷。
  4. 怎么修复的(推荐修法):B——对临近合并的 PR 逐个打 ci:full(若 [PR] fix: select the requested prompt pack from npm dependencies #6094 先合则从它开始);owner 若判定六个都可立即合,A 一批也成立。批准后由我执行打标。
  5. 回归风险(按选项):A/B——纯 CI 触发操作,无代码改动,无既有行为回归风险;副作用 = runner 并发增加,可能拖慢其他 PR 的 CI 排队。C——无操作、无风险。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及——三层 CI 机制保持原样,只是使用其既有入口。
  8. 是否引入了新的配置:不涉及。

收工判定:待 owner 拍板(A/B/C);批准后我一次性完成打标,代码侧无需再改。

@Afloat16

Copy link
Copy Markdown
Contributor Author

My preference as the PR author is option B: start with #6084 (e1706ab8), then #6086 (4bead210) and #6089 (6f2a5464) as each reaches the merge step. All three have your approval and green core test lanes; the requested one-line correction on #6084 is already applied and verified.

Could a repository maintainer apply ci:full to #6084 first, then proceed through that queue as the full-matrix results become available? #6094 and #6078 can receive full coverage when their reviews reach the merge step. #6102 also still needs the real Codex four-phase E2E with a working upstream before merge.

@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6439 (merged) — closing as superseded.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Noted — closing as superseded. Verified the landing on master before acknowledging:

  • origin/master carries 873715d40a ("Merge pull request [PR] chore(batch): land 50 open Afloat16 fixes in one history-preserving batch #6439 from ranxianglei/afloat-dry").
  • Both commits of this PR are in the batch: d016f55284 "fix: select the requested prompt pack from npm dependencies" and ba57b829aa "test: register pack installer subprocess suite" (rebased copies of 3a9ceb48ef / 981fea274a).
  • On master: src/pack-install.ts:72 = "Find the directly requested package, never a hoisted dependency." and scripts/live-files.mjs:139 = "tests/pack-install.test.ts".

The fix and the CI registration are both live on master; nothing further is needed from this PR.

On the ci:full question: no labels were ever applied — the A/B/C choice was deferred to you, so there is nothing to undo. Your batch landing supersedes it, and the option-B queue noted earlier in this thread (start with #6084, then #6086/#6089) is likewise moot for this thread. If any of the sibling PRs (#6078/#6084/#6086/#6089/#6102) are still open and you want full-matrix coverage before they merge, name them and I'll apply ci:full. #6102's real Codex four-phase E2E against a working upstream remains a separate pre-merge requirement regardless.

Leaving the thread open for you to close — I don't close issues/PRs.


结构化八问(中文,收工)

  1. 是什么问题:本线程(PR [PR] fix: select the requested prompt pack from npm dependencies #6094:prompt pack 安装器按 mtime 误选依赖包 + 新测试套件漏登记 LIVE_FILES)的收尾确认——工作已通过批量 PR [PR] chore(batch): land 50 open Afloat16 fixes in one history-preserving batch #6439 合入 master,按 owner 决定以 superseded 关闭。
  2. 什么原因导致的:不涉及新缺陷;原缺陷根因(findInstalledPkg 以 node_modules mtime 猜包身份)的修复已随 [PR] chore(batch): land 50 open Afloat16 fixes in one history-preserving batch #6439 落地。
  3. 影响范围与严重程度:无残留影响——修复与 CI 注册均已在 master 生效(已逐行核验)。
  4. 怎么修复的:owner 以批量 PR [PR] chore(batch): land 50 open Afloat16 fixes in one history-preserving batch #6439(afloat-dry 分支)合入;我做了只读核验:合并提交 873715d 在 origin/master,两个 rebase 后 commit(d016f55284 / ba57b82)在批量分支中,master 上 src/pack-install.ts:72 与 scripts/live-files.mjs:139 关键行均在位。
  5. 是否有回归问题:不涉及——本次会话未改任何代码,只做了只读验证。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

收工判定:owner 已拍板(批量 PR #6439 合入、本线程 superseded 关闭);我未打任何 ci:full 标签(无需回滚)、未关闭线程,留待 owner 关闭。

@ranxianglei ranxianglei reopened this Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Status re-check on this re-trigger — no new comments in the thread, nothing new to address:

No further work on this thread. (The 8-question checklist was already posted in my previous reply.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p3 scope/ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt pack install can select a transitive dependency instead of the requested package

2 participants