Skip to content

feat(update): bili owns the dsh desktop profile copy in place, end-to-end (#1575) - #1872

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-01_desktop-inplace-self-update
Oct 1, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-01_desktop-inplace-self-update

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

What changed

Two halves, one owner for the lane (owner decision recorded on #1575, comment 5933573610):

  1. 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. installViaTarball is 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 .pnpm store stays byte-identical.

  2. Drive-path closure — the dsh CLI refuses --profile desktop outright ("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:

    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

  • Not via the dsh CLI — it hard-refuses desktop profiles by design (deepseek-harness bin.js gate).
  • Not via the app plugin manager — observed unreliable on the field guest (dsh 渠道把桌面应用独占的 profiles/desktop 当普通 profile 驱动 —— 第二写者冲突 #1575 repro), and it cannot be driven from the updater pipeline.
  • Owner sign-off for in-place ownership, including explicitly accepted risks: write-race with the app's own manager, and the desktop profile's pnpm-lock.yaml drifting 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 from src/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

  • typecheck ✓ · build ✓
  • tests/update-desktop-inplace.test.ts 6/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 fails
  • update-family regression green locally: update-host-guard, dsh-refresh, update-channel, update-dsh-converge, update-dsh-self-refresh, update-proxy, update-restart-reminder, update-tarball, update-integrity, plugin-update (80+ cases)
  • local full-suite runs still trip the known dev-machine flake cluster ([tests] dsh-native attach-mode cluster (#1130/#1365) times out / stalls on dev host (suspected environmental) #1785, ~5 s timeouts under load) — CI is authoritative

Release 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).

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-01_desktop-inplace-self-update (2c4192a)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1873-pr.1872.ff05de1

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1872.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei force-pushed the 2026-10-01_desktop-inplace-self-update branch from 3e5f7a8 to 3190af9 Compare October 1, 2026 14:42
@ranxianglei ranxianglei changed the title feat(update): the dsh desktop profile copy updates itself in place (#1575) feat(update): bili owns the dsh desktop profile copy in place, end-to-end (#1575) Oct 1, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 进行中(先报进度,完整七问结论稍后):

已验证:拉取分支 2026-10-01_desktop-inplace-self-update,rebase 到当前 master(95a30be)干净无冲突——master 侧 #1588/#1596 对 src/update.ts 的改动与本 PR 不同区域。rebase 后 head:typecheck 干净;定向套件(update-desktop-inplace / host-guard / tarball / integrity / channel / dsh-converge / dsh-self-refresh / plugin-update / proxy / restart-reminder / dsh-refresh / dsh-native)118/118 通过。

方向关(①)通过:实现与 #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 入口缺失 + 孤儿 billion-context.pnpm-<ts> 链接的状态——此后每个检查周期都会 fail-closed 拒绝(backup cp 打 ENOENT),该 lane 永久卡死直到人工介入。修法:检测到该中断状态时自动把唯一孤儿链接换回原位再继续安装;多个孤儿则大声拒绝要求人工处理。补两个回归测试中,推上去后跟 CI 结果和完整结论。

合并判定:仍需 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.
@ranxianglei
ranxianglei force-pushed the 2026-10-01_desktop-inplace-self-update branch from 3190af9 to 0825ff3 Compare October 1, 2026 15:16
… 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.
@ranxianglei
ranxianglei merged commit d4746c4 into master Oct 1, 2026
12 checks passed
antclt pushed a commit to antclt/billion-context that referenced this pull request Oct 2, 2026
…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.
@ranxianglei
ranxianglei deleted the 2026-10-01_desktop-inplace-self-update branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dsh 渠道把桌面应用独占的 profiles/desktop 当普通 profile 驱动 —— 第二写者冲突

1 participant