Repository navigation
feat(update): bili owns the dsh desktop profile copy in place, end-to-end (#1575) - #1872
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1873-pr.1872.ff05de1This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1872.tgz
npm install -g packageInstall instructions are refreshed on each push. |
3e5f7a8 to
3190af9
Compare
[bot] 🏷 Review 进行中(先报进度,完整七问结论稍后): 已验证:拉取分支 方向关(①)通过:实现与 #1575 floor 4 的 owner 决定逐字一致(桌面副本 bili 就地接管、junction-safe 换链);分类边界正确(web profile 等其余形状仍归 pnpm-owned,有测试钉住);swap 机制正确(同目录 rename 原子、Windows junction 走 lstat isSymbolicLink、store 字节不变已测试);所有 pre-flight 拒绝都在 swap 之前,无泄漏路径。顺带修掉一个潜在旧缺陷:此前任何 bili-owned 的符号链接安装目录会被 fs.cp 跟随写穿到链接目标,现在换链后落真目录,严格更安全。 发现一个真实缺陷,正在 PR 分支上直接修(小问题直接修):swap 的「移开链接」与「拷贝完成」之间若进程崩溃,留下 install 入口缺失 + 孤儿 合并判定:仍需 human merge(§7.4 item 8,触碰 src/update.ts);发布时按 §5 惯例建议先 no-op 验证版本或盯紧首批 rollout。与 #1581 的合并顺序建议见后续完整回复。 |
…-end (#1575) Owner decision (recorded on #1575): the desktop app's dsh profile bundles billion-context and the dsh CLI refuses --profile desktop by design, so the lockstep refresh could never land there. Two halves close the loop: 1. hostManagedInstall() exempts the desktop profile copy from #991, and installViaTarball becomes junction-aware: a pnpm symlink/junction target is displaced as a link and replaced by the verified package as a real dir; the shared .pnpm store stays byte-identical. 2. refreshDshProfileBundles() skips the desktop profile (no more guaranteed CLI failures), and the new refreshDshDesktopCopy() drives the in-place refresh alongside every call site under the shared update lock.
3190af9 to
0825ff3
Compare
… test alive on Windows Two review nits from #1872: 1. refreshDshDesktopCopy() computes the flat path from its `env` parameter but installViaTarball() evaluated hostManagedInstall() against the default process.env — a latent inconsistency for callers that pass a relocated env. Add a trailing optional `env` parameter (default process.env, so every existing call site is unchanged) and thread it into the #991 guard; refreshDshDesktopCopy now passes its own env through. 2. The junction-displacement tests created plain directory symlinks, which skip with EPERM on Windows runners without symlink privilege — exactly the platform where the dsh desktop profile lives. Create the link as a directory junction on win32 (junctions need no SeCreateSymbolicLinkPrivilege) so the rename-the-link-itself path stays covered there instead of silently skipping. update-desktop-inplace / update-host-guard / update-tarball / update-integrity / update-dsh-self-refresh / update-dsh-converge / plugin-update: 42/42; typecheck clean.
…tall test
The hermetic registry e2e (local verdaccio, PR-gated) and the release
canary ran ubuntu-only, so the entire Windows install/update surface —
npm -g shims, NTFS junctions, USERPROFILE-mirrored npm config — had zero
CI coverage.
This PR ports the registry e2e suite to real Windows and adds a new
end-to-end test that exercises the real npm client:
- tests/e2e/crossplat.ts (new): shared cross-platform helpers.
- npmCliPath() runs npm via node npm-cli.js (no shell, no ENOENT on
npm.cmd); npmRunSync() falls back to shell+quoting.
- windowsSystemEnv() forwards SystemRoot/ComSpec/etc — a bare env
without SystemRoot breaks node child processes on Windows.
- npmHomeEnv() mirrors HOME to USERPROFILE/APPDATA (npm userconfig
reads USERPROFILE, not HOME, on win32).
- fakeVersionBin() writes a cross-platform fake CLI (.cmd on win32);
the product's detectOpencodeMajor already shells out for .cmd/.bat.
- registry-fixture.ts + both e2e suites use the helpers; hermetic env
isolation (HOME + XDG_* + win mirrors) now holds on both platforms
(paths.ts reads XDG_* on all platforms).
- New test "hermetic npm -g install e2e": the real npm client installs
billion-context@OLD --global into an isolated prefix (asserts the
platform-correct layout: <prefix>/node_modules + bili.cmd on win32,
lib/node_modules + bin/bili on POSIX), then `bili update` flips it in
place over the real chain, and the shim npm laid down reports the new
version. Fixture tarballs are published with dependencies stripped for
this test — the hermetic registry has no uplinks and dependency
resolution would 404; the flip mechanics under test don't involve it.
- ci-registry.yml: matrix ubuntu-latest + windows-latest (bash shell on
both; artifacts collected with an os suffix).
Validated on a real win10 VM (not just GH runners): junction unit tests
11/11 (from ranxianglei#1872 follow-up), hermetic registry e2e 10/10 including the
new npm -g test — self-update flip, advisory rollback, real npm -g
install + shim + in-place flip all behave on real Windows. Product code
is unchanged; every failure found on the VM was in test infrastructure.
What changed
Two halves, one owner for the lane (owner decision recorded on #1575, comment 5933573610):
Installer exemption (
src/update.ts) —hostManagedInstall()now treats the dsh desktop profile's billion-context copy as not managed, so the standard tarball installer may overwrite it in place; every other native模式下自动更新问题需要解决 #991 guard is untouched.installViaTarballis also junction-aware: when the install target is a pnpm symlink/junction into<profile>/.pnpm/, the link itself is renamed aside and the verified package is laid down as a real directory at the same path; backup/restore keep link semantics, and the shared, hardlinked, integrity-checked.pnpmstore stays byte-identical.Drive-path closure — the dsh CLI refuses
--profile desktopoutright ("managed exclusively by the Electron application") and the in-app plugin manager cannot be relied on, so nothing outside bili could ever move this copy, not even for the first hop. Now:refreshDshProfileBundles()skips the desktop profile instead of spawning a guaranteed CLI failure (src/dsh-channel.ts);refreshDshDesktopCopy(targetVersion, log?, env?, resolveProxy?)runs alongsiderefreshDshProfileBundles()at all four call sites — post-self-update success, up-to-date convergence (dsh boot crash on mixed copies: global >=0.1.176 bundle yml (bare name) + profile copy <=0.1.175 (exports["."]=CLI) — window opened by manual npm i -g, self-heal blocked by the crash itself #1803), standalone profile check (dsh plugin-market installs never auto-update: the refresh chain's only trigger is a global bili self-update #1196), advisory install — each already holding the shared update lock. It is silent while the copy is missing, in step, or ahead (never downgrades), fetches its own version doc only in the stale window, and is best-effort: failures log and retry next cycle, never throw.Net effect: once this build reaches any bili process on the machine (global or a profile proxy), the desktop copy converges within one check cycle (~3 min) plus a dsh restart — no app-manager hop at any point.
Why this shape
pnpm-lock.yamldrifting from the store (a future dsh store operation could rebuild the layout and roll back an in-place update — it re-converges on the next cycle).Config surface
Zero new config fields / env vars / CLI flags. Behavior is scoped by one code constant
DSH_DESKTOP_PROFILE = "desktop"exported fromsrc/dsh-channel.ts— deliberately named to match open PR #1581 so either merge order rebases cleanly onto the other.Relationship to #1581
#1581 proposed skipping the desktop profile from channel refresh because the CLI refuses it. This PR supersedes that direction: instead of merely skipping, bili directly owns the copy through the same lockstep machinery (skip line + drive path included here). Recommend closing #1581 as superseded — human decision. If #1581 lands first, its skip branches share intent and text with ours; rebase resolves to the union (one constant, one skip).
Pre-flight
tests/update-desktop-inplace.test.ts6/6: link-displacement integration + full drive path through a registry-doc fetch stub (store untouched, no displaced-link litter, success-line asserted) + in-step no-op + absent-profile silent return + deterministic channel-skip proof with a web-profile control whose CLI attempt visibly failsRelease note
Touches
src/update.ts→ human merge only (§7.4 item 8: load-bearing updater infra; no auto-merge). Updater-mechanism change → AGENTS §5 suggests proving the existing upgrade path with a no-op release before shipping this one. Release cadence left to the owner.Fixes #1575 (implements the owner-decided direction; sign-off lives in the issue thread).