Skip to content

ci: release canary — automated no-op self-update verification (#1811) - #1814

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-01_ci-release-canary
Oct 1, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-01_ci-release-canary

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Implements #1811 (维护者自实现,ework 勿接手).

What

A CI lane that runs only when a release is published (plus workflow_dispatch for manual runs against any tag/branch). It verifies the receive path of the updater — the pipe every user's fleet rides at publish time — using a loopback verdaccio, zero secrets, fully offline.

How

checkout release tag → npm ci → npm run build
pack SAME tree twice: A@N-1, B@N   (content identical, version differs)
local verdaccio: publish A → install A as global tree
boot live proxy on A (BILI_UPDATE_REGISTRY=loopback, CHECK_INTERVAL=1s)
  ├─ pre-update: stale dsh profile (@N-2) converges to N-1   (#1804 path, fake dsh bin)
  ├─ publish B → live proxy flips itself: "installed N-1 → N. Restart to finish."
  ├─ case-3 dsh profile refresh to N
  ├─ profile seeded stale AFTER the flip converges without an update event, then silence
  ├─ live (old-memory) proxy keeps serving requests through the swap window
restart at N:
  ├─ bili --version = N
  ├─ ACP smoke: model turn → plugin compress fold → post-fold turn
  └─ plugin install opencode: entry present in config after update

Files

  • .github/workflows/ci-release-canary.yml — trigger release: published + manual dispatch (ref input defaults to latest release tag); failure artifacts under tmp/e2e-canary-*.
  • tests/e2e/e2e-release-canary.test.ts — the whole scenario, gated ACP_TEST_CANARY=1.
  • tests/e2e/registry-fixture.ts — pass NPM_ALLOW_DANGEROUS through to the fixture's npm child so guarded dev machines can publish to the loopback registry (CI runners have no guard; no behavior change there).

Verification

  • Local (clean env): 2× stable green, ~18s per run.
  • ACP_TEST_REGISTRY=1 e2e-registry suite: 4/4 pass with the fixture change.
  • npm run typecheck clean.

Why this shape (lessons from 0.1.176/0.1.177)

The updater is self-referential: its only delivery path is the code being fixed, so a broken updater wedges the fleet with no rollback. Manual canary on one real machine (today's 4-point run) proved the concept; this automates it on every release. Linux-first per #1811; multi-host lanes can extend the matrix later.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-01_ci-release-canary (40afa0e)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1797-pr.1814.13a6b21

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-pr1814.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

收到。角色确认:按 #1811 分工,这条由你自实现,我不接手写码,本次只做 PR review(对照 #1811 验收标准 + 我在 #1811 floor 2 的设计评审逐条核对)。

正在做:拉分支核对三处文件(workflow / canary test / registry-fixture 改动)、查重、CI 状态、本地跑 typecheck + e2e-registry 套件(fixture 被改)+ canary 本体。结论稍后按结构化七问给出。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成(review-only,未重做 — 维护者自实现)。分支与 master 同步无 stale-base;三个文件逐行审完并与源码对照验证。

验证记录

  • 查重:open+closed 全搜,无重复(CI: 发版触发的 no-op 自更新验证系统(私有 npm registry · 多宿主通道 · 更新后 ACP/压缩冒烟 · 混合宿主) #1811 是设计来源,非重复项)。
  • 断言的每条路径都对照了真实代码:convergeDshProfileBundles(phase 2/4)周期调用点 src/update.ts:791;case-3 refreshDshProfileBundles(phase 3)src/update.ts:1154;in-step skip 的 "silent and spawn-free" 语义(src/update.ts:661 起,stale 列表为空即静默返回,与 phase 4 的 spawn-count 断言吻合);BILI_DSH_BIN 注入缝 src/dsh-channel.ts:214;首查 10s 硬编码延迟 src/update.ts:1166-1171(各 waitFor 超时均覆盖)。
  • 本地:typecheck clean;build OK;ACP_TEST_REGISTRY=1 e2e-registry 4/4(fixture 改动回归);ACP_TEST_CANARY=1 canary 2× green(23.9s / 23.5s,确定性成立)。
  • CI:head commit 上 13 个 check 全绿(test 矩阵 ubuntu 22/24 + windows 22/24、build、version-guard、hermetic registry、codex/pi/dsh/opencode 各 lane)。

结构化七问

  1. 是什么问题:updater 自指——它唯一的交付通道就是被修复的代码本身,升级管道一坏整个 fleet 卡死且无回滚(0.1.176/0.1.177 教训)。本 PR 把此前手工 4 点 canary 自动化为每次 release 发布必跑的接收路径端到端验证。
  2. 什么原因/为何此方案:缺的是对「接收路径」的验证,不是 payload 质量(那是常规 CI 的职责)。同树双 pack(N-1/N,内容相同版本不同)+ N-1 活体代理(1s 检查周期)翻转到 N + 重启后 ACP smoke,是最小闭环且真实行使生产升级链的关键在「用旧内存里的代码安装新版本」——这正是自指风险所在。离线、零密钥、确定性,形状正确。
  3. 怎么构建的:单一共享全局树场景(比 4 并行 lane 更贴近真实机器布局,也回应了我 CI: 发版触发的 no-op 自更新验证系统(私有 npm registry · 多宿主通道 · 更新后 ACP/压缩冒烟 · 混合宿主) #1811 floor-2 里对 mixed-host lane 易抖动的顾虑——正确延后);断言全部观测化(磁盘版本 + fake-dsh 调用日志 + updater 日志行正则 + flip 窗口内活体 HTTP + 静默窗口 spawn 计数);fake shim 走既有 BILI_DSH_BIN/BILI_CLIENT_BIN 缝,产品代码零特判;完全 hermetic(隔离 HOME/XDG、自带 verdaccio、listen(0) 端口,fix: emit /acp panel as persistent custom message and strip it from the proxy model context (#359) #360 纪律)。触发 release published + workflow_dispatch(任意 tag 可回填)。
  4. 是否有回归问题:审过的既有行为及结论——
    • e2e-registry 套件(fixture 唯一消费者,已跑 4/4 绿);diff 是条件 spread,NPM_ALLOW_DANGEROUS 未设时默认不变量,CI runner 无 guard 零行为变化;
    • 常规 npm test:新测试文件在 glob 之外且 ACP_TEST_CANARY=1 双重门控,不受影响(CI 全矩阵绿佐证);
    • 既有 CI lane:新 workflow 触发器(release published / 手动 dispatch)与 push/PR 事件不相交,独立 concurrency group;
    • updater 运行时(src/update.ts):零改动,canary 只在隔离 HOME/XDG 里以子进程驱动,不碰宿主;
    • version 字段未动(符合 release 流程规则);wire/持久化/config schema:无任何 src 改动,不可能回归。
      高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。结论:无回归。
  5. 是否破坏缓存:不涉及(缓存/重试/增量游标/去重键均未触碰,零 src 改动)。
  6. 是否改了设计方向:未改。纯新增一条 CI lane,反而把 dsh plugin-market installs never auto-update: the refresh chain's only trigger is a global bili self-update #1196/native模式下自动更新问题需要解决 #991/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 的 install-lane 契约钉进了 CI。相对 CI: 发版触发的 no-op 自更新验证系统(私有 npm registry · 多宿主通道 · 更新后 ACP/压缩冒烟 · 混合宿主) #1811 floor-2 提案做了合理缩减(单场景、mixed-host 延后、Linux 先行),与 PR 正文「matrix 后续可扩展」一致。
  7. 是否引入新配置:无用户侧配置。复用既有缝(BILI_UPDATE_REGISTRY/BILI_UPDATE_CHECK_INTERVAL_MS 来自 test: 自带本地 npm registry 的 hermetic 测试基建——解锁自更新/钉版本/解析全链路 e2e #1153、BILI_DSH_BIN);仅新增测试门控 env ACP_TEST_CANARY(与 ACP_TEST_E2E/ACP_TEST_REGISTRY 同构)。零 secret(仅 GITHUB_TOKEN)、loopback-only。

非阻塞发现(4 项,不拦合并)

  1. 失败 artifacts 可能为空(最重要的一条):t.after 里的 rmrf(work) 先于 workflow 的 if: failure() 收集步骤执行(node:test 的 after hook 失败时也跑)→ 普通断言失败时 tmp/e2e-canary-* 已被删,cp -r 收不到东西;只有进程被硬杀才留得下目录。最关键的失败模式(phase 3 flip 超时)在 CI 里只会看到 "timed out waiting for: global tree flipped to …",没有 proxy stderr。此模式继承自既有 ci-registry.yml(同结构同样缺陷),非本 PR 新引入,故不拦;建议后续修:失败时跳过清理,或在 t.after 内先把 proxy.output() + verdaccio 日志落进 artifact 目录再清理(covers ci-registry + canary,同一根因,一个后续 issue 即可)。
  2. prerelease 处理:patchMinus 对不匹配 ^\d+\.\d+\.\d+$(如 0.1.179-beta.1)或 patch==0 直接 throw,而 workflow 对任何 release published 都触发 → dev/prerelease 发布会产生红 canary。建议非 stable 版本优雅 t.skip(带原因),与 CI: 发版触发的 no-op 自更新验证系统(私有 npm registry · 多宿主通道 · 更新后 ACP/压缩冒烟 · 混合宿主) #1811「stable-only 起步」精神一致。
  3. bootstrap(已知,CI: 发版触发的 no-op 自更新验证系统(私有 npm registry · 多宿主通道 · 更新后 ACP/压缩冒烟 · 混合宿主) #1811 floor-2 已记录):release 事件从 tag 树读 workflow 定义 ⇒ 本 lane 从合并后的下一个 release 起才生效;更早的 tag 用 workflow_dispatch 回填。在此明示一次,避免下次发布后疑惑。
  4. 文档缺口:tests/e2e/README.md 与主 AGENTS.md 均未收录 canary 套件(现有两套 e2e 各有 Running/Environment/Mechanics/CI 小节),建议补一小节。另附一个微点:phase 5 的 fold 断言(ok:true + 非空 result)在单 user-message 会话落在 kernel 保护区时可能空转仍通过——该 phase 的真实价值是「更新后树存活 + plugin 通道响应」,后续可加 ≥1 compressed block 断言收紧,不计入正式发现。

**判定:可合。**方向正确、断言有牙、hermetic 且确定、零回归,本地 + CI 证据齐备。上述 4 条走后续处理(第 1 条建议尽快,它决定这条 lane 在最需要诊断的时刻有没有料可看)。

ranxianglei pushed a commit that referenced this pull request Oct 1, 2026
…1/2/4)

- keep failure artifacts: the finally block now dumps proxy output into
  <work>/diagnostics.txt and keeps the whole tmp/e2e-canary-* dir on
  failure (rmrf only on success), so the workflow's if:failure() upload
  actually has material — previously t.after deleted the dir before the
  artifact step ran.
- stable-only guard: prerelease/dev tags or patch < 2 now skip loudly
  (need N-1 and N-2) instead of throwing a red canary.
- tests/e2e/README.md: document the canary suite (Running/CI semantics,
  the bootstrap note that the lane takes effect from the first release
  AFTER the workflow lands).
@ranxianglei

Copy link
Copy Markdown
Owner Author

Review 后续已落(bac66b8):

  • 发现 1(canary 侧):finally 里失败时先写 <work>/diagnostics.txt(proxy stdout+stderr)并保留整个 tmp/e2e-canary-* 目录,成功才 rmrf — workflow 的 if: failure() 上传现在有料了。本地验证过两条路径:成功清理干净;强制失败保留目录 + diagnostics.txt。
  • 发现 2:非 stable 版本(如 0.1.179-beta.1)或 patch < 2 现在带原因 t.skip,不再红(需要合成 N-1 和 N-2,所以阈值是 patch ≥ 2)。
  • 发现 4:tests/e2e/README.md 补了 canary 套件小节(Running/语义/CI 触发/bootstrap 说明)。
  • 发现 3(bootstrap 生效时机)已写进 README;发现 1 的 ci-registry.yml 同根因半边 + 微点(折叠断言收紧)按 review 建议走后续 issue,不在本 PR 扩面。

复验:本地 canary 1/1 绿(成功路径清理验证 + 失败路径 artifacts 保留验证),CI 重新排队中。

dog added 2 commits October 1, 2026 11:44
Runs only when a release is published (or via workflow_dispatch). Packs
the released tree twice with identical content at N-1/N into a local
verdaccio, boots a live proxy on N-1, and drives the full receive path:

- pre-update dsh profile convergence (#1803/#1804 path, fake dsh bin)
- in-place flip to N: 'installed N-1 → N. Restart to finish.'
- case-3 refresh + post-flip convergence of a profile seeded stale
  after the flip, then silence (no redundant dsh plugin spawns)
- live proxy keeps serving during the swap window
- restart at N: ACP smoke — model turn, plugin compress fold, post-fold
- 'plugin install opencode' entry survives the update

registry-fixture: pass NPM_ALLOW_DANGEROUS through to npm so guarded
dev machines can publish to the loopback fixture (CI is unaffected).
…1/2/4)

- keep failure artifacts: the finally block now dumps proxy output into
  <work>/diagnostics.txt and keeps the whole tmp/e2e-canary-* dir on
  failure (rmrf only on success), so the workflow's if:failure() upload
  actually has material — previously t.after deleted the dir before the
  artifact step ran.
- stable-only guard: prerelease/dev tags or patch < 2 now skip loudly
  (need N-1 and N-2) instead of throwing a red canary.
- tests/e2e/README.md: document the canary suite (Running/CI semantics,
  the bootstrap note that the lane takes effect from the first release
  AFTER the workflow lands).
@ranxianglei
ranxianglei force-pushed the 2026-10-01_ci-release-canary branch from bac66b8 to 40afa0e Compare October 1, 2026 03:44
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 复验完成(bac66b8)。三个发现按约定关闭,一个延后项确认归属。

复验记录

  • diff 逐行审(workflow 未动;README +27;canary 测试重构为 try/catch/finally):
    • 发现 1:清理从 t.after 移入 try/catch/finally,失败写 <work>/diagnostics.txt(proxy stdout+stderr)并保留整个工作目录,成功才 rmrf。两条路径我本地独立复现:成功路径 1/1 绿(28s)、工作目录无残留;用 PATH shim 强制 npm pack 失败 → 测试红、tmp/e2e-canary-* 完整保留(diagnostics.txt / packs / registry / fixtures 俱在)、日志打出 "keeping work dir"。workflow 的 if: failure() 收集现在有真料了。附带一点比预期更好:两个 proxy 实例共享同一 XDG_STATE_HOME,保留目录里磁盘上的 state/billion-context/bili.log 还含 flip 前旧实例的完整日志——比内存 buffer(只覆盖当前绑定实例)更富。
    • 发现 2:非 stable 或 patch < 2 → 带原因 t.skip;注释说明了阈值为何是 ≥2(需同时合成 N-1 和 N-2)。patchMinus 的 throw 退化为防御性兜底,门控路径不可达。符合建议。
    • 发现 4:tests/e2e/README.md 补了 canary 小节(gate/语义/失败 artifacts/CI 触发),bootstrap 生效时机按约定写入 README。
  • typecheck clean;CI 在 bac66b8 上 13/13 全绿(test 全矩阵 ubuntu 22/24 + windows 22/24、build、version-guard、hermetic registry、codex/pi/dsh/opencode lanes)。
  • 延后项确认:ci-registry.yml 同根因半边 + 折叠断言收紧 → 后续 issue,不在本 PR 扩面。同意,范围控制正确。

结构化七问

  1. 是什么问题:同前轮——本提交是 review 非阻塞发现的收尾(失败 artifacts 为空、prerelease 会红、文档缺口),不改变 lane 本身语义。
  2. 什么原因:原发现根因分别是「无条件清理先于 artifacts 收集」「版本编排缺 stable-only 门控」「文档惯例缺口」;修法对症:让清理感知失败、入口门控、补齐文档。
  3. 怎么修复的:清理逻辑从 t.after 移入测试体的 try/catch/finally(failed 标志决定保留/清理,teardown 错误不再二次报告);版本判定前移到模块顶层(stableVersion 决定 skipReason);文档按既有套件小节体例。
  4. 是否有回归问题:审过的既有行为——成功路径清理语义不变(本地验证无残留);常规 npm test 不受影响(文件在 glob 外 + 双重门控,CI 全矩阵绿);e2e-registry fixture 本次未动(上轮 4/4 结论仍有效);零 src 改动,wire/持久化/config/缓存均不涉及;「失败保留工作目录」本身是有意变更且已披露(README 写明)。高危模式逐项过:无语义漂移、无吞错引入(stop().catch 只作用于结果已定的 teardown)、无阈值/时序/输出格式变化。结论:无回归。
  5. 是否破坏缓存:不涉及。
  6. 是否改了设计方向:未改。
  7. 是否引入新配置:无(用户侧零变化;ACP_TEST_CANARY 上一提交已引入)。

微小残留(不拦):try 块之前的 setup 阶段失败(如 startRegistry 自身挂掉)不走 finally,不写 diagnostics.txt 也不显式清理——但工作目录仍会留存供 artifacts,且进程随即退出,影响可忽略。

**判定:可合。**三项发现带证据关闭(含我对失败路径的独立复现),延后项归属明确,CI 全绿。

@ranxianglei
ranxianglei merged commit 9613797 into master Oct 1, 2026
13 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 1, 2026
antclt pushed a commit to antclt/billion-context that referenced this pull request Oct 1, 2026
…anxianglei#1811)

The release canary computed OLD_VERSION/STALE_VERSION via patchMinus() at
module load, BEFORE the stableVersion guard. patchMinus() throws on any non
x.y.z input, so a prerelease/dev tag (0.1.x-dev.N, 0.1.x-beta.N) — or a patch
part < 2 — made the whole test file fail to import instead of skipping
gracefully. The workflow triggers on release.published, which release.yml also
emits for dev releases, so every dev release would red-light the delivery-pipe
check with a false alarm rather than a clean skip.

Compute stableVersion first and guard both patchMinus() calls on it; when the
version is out of range the consts fall back to NEW_VERSION (unused, since the
test then skips via skipReason). Behavior for a stable x.y.z with patch >= 2
is byte-for-byte unchanged.

Verified locally: typecheck green; prerelease 0.1.179-dev.1 now skips with a
clear reason (fail 0); full stable-path run at 0.1.178 green end-to-end (~26s).

Supplements the merged canary in ranxianglei#1814; review finding raised in ranxianglei#1811.
@ranxianglei
ranxianglei deleted the 2026-10-01_ci-release-canary branch October 15, 2026 05:32
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.

1 participant