Skip to content

fix: converge the dsh desktop profile manifest spec after in-place updates (#2894) - #2897

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-12_dsh-desktop-manifest-sync
Oct 12, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-12_dsh-desktop-manifest-sync

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2894

修的是什么

desktop profile 里的 billion-context 是 bili 用 registry tarball 原地替换的(dsh CLI 不支持 --profile desktop,#1575),只换 node_modules——profile 的 package.json 里声明的版本 spec 和 pnpm-lock.yaml 的 pin 留在旧版本。dsh 应用内插件管理器下次对账(用户点安装)就按旧 spec/pin 把 store 里的旧版本装回来 = owner 观察到的「自动更新后被退回」。这是唯一走原地写入的 lane(普通 profile 走宿主通道 dsh plugin add、opencode 是带时间戳的缓存目录、pi 走 pi update),所以只有它有这个缺陷。

修法思路

在共享原语 installViaTarball 里(覆盖全部三个原地写入点:refreshDshDesktopCopy / self-update / advisory 强制安装)成功替换 desktop 副本后,调新 helper syncDshProfileManifestSpec 把 desktop profile package.json 的 billion-context spec 收敛到已安装版本:

  • 风格保持:^0.1.180 → ^0.1.194,exact 保持 exact;
  • 无条件收敛(含降级)——advisory rollback 降版后,下次对账不会把它顶回去;
  • link:/file: 本地 pin 尊重不动;dist-tag(latest)与非版本范围(>=、~)保持不动并返回原因;
  • 文件缺失 / JSON 损坏 / 未声明依赖 → 返回原因字符串,记 warn,绝不 fail 已落地的安装、绝不覆盖用户数据(fail-safe,非 silent-clobber);
  • 只改 dependencies["billion-context"] 一个键,其余字段逐字保留。

spec base 抬高后旧 lockfile pin 失效,pnpm 下次对账重新向前解析——退回路径从根因消除(修的是产生缺陷的机制,不是过滤症状)。

行为变更披露(old → new)

  • 旧:bili 原地替换 desktop 副本后,profile package.json 里的版本 spec 保持旧值(如 ^0.1.180)。
  • 新:替换完成后该 spec 被改写为已安装版本(如 ^0.1.194)。这正是本 fix 的目的——消除退回机制。manifest 其余字段不变;非 desktop profile、opencode/pi lane、所有读取路径不受影响。

验证

  • 新增单测:desktop 副本 e2e 替换 + manifest 收敛断言(其他 deps / bundles / name 保留);syncDshProfileManifestSpec 的风格保持、降级收敛、本地 pin、odd spec、no-dep / malformed / missing-file 分支。
  • 定向套件全绿:update-desktop-inplace / update-tarball / update-host-guard / dsh-refresh / update-dsh-converge / update-dsh-self-refresh(52 pass)+ advisory / plugin-update(31 pass);typecheck clean。全量回归与 build 交 CI。

诚实 caveat

若 dsh 应用内插件管理器记录已装版本用的是自己的 DB 而非读 package.json / pnpm-lock,则仅收敛 manifest 不足以阻止退回,需要 dsh 侧配合修复。owner 可在真机验证;若证实如此,我再开 dsh 侧的 issue。

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-12_dsh-desktop-manifest-sync (f983406)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3224-pr.2897.80d80da

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-pr2897.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始按 PR Review 规范审查 #2897(审原 issue → 回归审查 → 代码/测试/diff 五关)。已拉取分支核对 diff(3 文件,+181/-2),正在读 installViaTarball 上下文、跑定向测试并查 CI 状态,结论稍后按结构化八问给出。

ranxianglei pushed a commit that referenced this pull request Oct 12, 2026
…ence (#2894)

Review pass on #2897: the version match was anchored at the start only, so a
compound range ("^0.1.0 || ^0.2.0", "0.1.0 - 0.2.0") matched its leading
component and the whole declared spec was collapsed onto the installed
version. Full-spec match instead: simple caret/exact specs converge exactly
as before, anything compound is respected and left untouched.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2897 审查结论(审原 issue → 回归审查 → 代码 → 测试 → diff 五关全走)

① 原 issue(#2894)方向:查证通过。desktop profile 是唯一 bili 原地写 node_modules 而 pnpm 账本(profile package.json spec + lock pin)滞留旧版的 lane——普通 profile 走 dsh plugin add(manifest/lock/node_modules 由 dsh 一致更新)、opencode 是时间戳缓存目录、pi 走 pi update,均无此缺陷面。修的是产生退回的机制(spec/pin 滞留),不是过滤症状。✓

② 回归审查(既有行为清单):逐点核对 installViaTarball 全部调用方——

  • refreshDshDesktopCopy(src/update.ts:1175):目标即 desktop 副本,hook 触发 ✓(本 fix 的目标路径);
  • self-update 主路径(src/update.ts:1464):装的是 bili 自己的全局目录,isDshDesktopBiliCopy 为假不触发;成功后另调 refreshDshDesktopCopy 覆盖 desktop 副本,hook 在那里触发 ✓;
  • advisory 强制安装(src/update.ts:1983):同上,双保险覆盖 ✓。
    其余既有行为字节不变:hostManagedInstall 分类逻辑未动(hook 只读不写分类结果)、备份/验证/回滚链未动、bootSmoke 失败仍先回滚再返回(hook 在全部成功之后才跑,不会给失败安装打 manifest)。非 desktop lane、opencode/pi lane、所有读取路径(dshProfileDepSpec 等)不受影响。行为变更(old→new)已在 PR 披露且与代码一致。✓

③ 代码:helper fail-safe 方向正确——文件缺失/JSON 损坏/未声明依赖/local pin/dist-tag/非版本范围全部「返回原因 + warn,绝不 fail 已落地安装、绝不 clobber」;只改一个键;风格保持(caret/exact);降级也收敛(advisory rollback 不会被顶回)。发现并已顺手修掉一个小问题(commit 92d77c883,独立标注):版本匹配原来只锚定行首,复合范围("^0.1.0 || ^0.2.0"、"0.1.0 - 0.2.0")会命中前导版本后把整个声明坍缩成单版本——现改为整 spec 精确匹配,简单 caret/exact 行为不变,复合范围归入 respected,补了回归 case。已知残留(判定可接受,非缺陷):manifest 写入用普通 writeFileSync 而非 tmp+rename——与本模块既有写法一致(dsh-channel.ts:99 同),且崩溃窗口极小、损坏后走 malformed 分支只 warn 不 clobber。

④ 测试有效性:断言有牙——e2e 用例真跑 refreshDshDesktopCopy 完整替换链(含 stub registry + 完整性校验),断言 spec 收敛到 ^0.1.194 且 other-dep/bundles/name 逐字保留;单测钉住风格保持、降级收敛、local pin、odd spec、no-dep/malformed/missing-file 全部分支及「bytes unchanged」。我在本地 worktree 实跑:tests/update-desktop-inplace.test.ts 7/7 pass(修复合范围后复跑仍绿)。✓

⑤ diff 整洁度:3 文件 +181/-2,每一行都与本 PR 目的相关,无生成物/锁文件/空行噪音;我的顺手小修是 6 行的独立 commit。base 落后 master 86 提交,但三个触碰文件在 master 上零改动、GitHub 报 mergeable=true,无需 rebase。✓

CI 状态(重要):head 92d77c883 上除 4 个 test job 外全绿(static-gates×4、build-artifact、hermetic registry e2e×2、real dsh headless lane、kernel/pi-subagents/lane/version/config-surface guard、docs×2、unused-exports)。4 个 test job 全红不是本 PR 的问题:它们在跑任何测试之前就死于 master 侧缺陷——#2782 合入的 tests/issue2752-forward-partial-outcome.test.ts 会 spawn 进程但未登记进 #2848 调度器的 LIVE_FILES,门禁按设计 fail-fast,导致当前所有 open PR 的 test job 全红(master push 分支 skip test job 所以自己没炸)。已立项 #2901(带来源标记,含根因与建议修法)。

结构化八问:

  1. 是什么问题:dsh desktop profile 自动更新后,用户点一次应用内安装,pnpm 就按滞留的旧 manifest spec/lock pin 把旧版装回来,自动更新被静默退回。
  2. 什么原因导致的:desktop lane 是 bili 用 tarball 原地替换 node_modules(宿主 CLI 拒绝 --profile desktop,dsh 渠道把桌面应用独占的 profiles/desktop 当普通 profile 驱动 —— 第二写者冲突 #1575),只换包本体,profile package.json 的版本声明和 lockfile pin 停在旧值;pnpm 对账以账本为准 → 回退。唯一走原地写入的 lane,故仅此一处。
  3. 影响范围与严重程度:仅 dsh desktop profile 用户(含 advisory 降版场景);特定条件下有问题——更新后任意一次对账即回退,该 lane 自动更新形同虚设;非数据损坏。
  4. 怎么修复的:在共享原语 installViaTarball 成功路径末端(三个原地写入点全覆盖),把 desktop profile manifest 的 billion-context spec 收敛到刚安装的版本(风格保持、无条件含降级、本地 pin/非常规 spec 尊重不动、fail-safe 只 warn)。spec 抬高使旧 lock pin 失效,pnpm 下次向前解析——退回机制从根因消除。
  5. 是否有回归问题:无。三个调用方逐一核过(见上);备份/回滚/bootSmoke 链未动;非 desktop lane 字节不变;manifest 写入 fail-safe。
  6. 是否破坏缓存:不涉及(不动会话持久化、压缩缓存、更新节流/锁;唯一新副作用是 desktop profile package.json 一个键)。
  7. 是否改了设计方向:不涉及。desktop 副本写入者仍是 bili(Install-Lane 契约不变),只是让原地写入把账本一并收敛,不引入新写入者、不改 wire、不动 kernel。
  8. 是否引入新配置:无新 env/config/默认值。

判定:代码可合并(单模块纯 fix、回归测试有牙、定向套件本地实测绿、除 master 侧 #2901 外 CI 全绿)。唯一阻塞是 #2901 修完后的 test job 重跑变绿——建议等 #2901 落地后合并;若 owner 愿意承担「全量套件待重跑」的风险也可现在就合(本 PR 触碰面的定向覆盖已在本地实证)。另外 PR 里的诚实 caveat 仍然成立:若 dsh 应用内插件管理器用自己的 DB 而非 package.json/pnpm-lock 记录已装版本,仅收敛 manifest 不够,需要真机验证;证实如此我再开 dsh 侧 issue。

@ranxianglei
ranxianglei merged commit caab0e0 into master Oct 12, 2026
21 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.335-master.caab0e0 (rolling master tag).

npm install -g billion-context@0.0.335-master.caab0e0  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

@ranxianglei
ranxianglei deleted the 2026-10-12_dsh-desktop-manifest-sync branch October 15, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

插件自动更新后可能被dsh退回

1 participant