Skip to content

feat: hermetic local npm registry e2e infra — real self-update chain coverage (#1153) - #1161

Merged
ranxianglei merged 3 commits into
masterfrom
wt-1153-ework-daemon
Sep 25, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
wt-1153-ework-daemon

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1153

What

Test infra for the self-update chain that previously had zero coverage (all existing update tests inject fake fetch/resolveVersion, so only "decisions" were testable, never the real chain):

  • tests/e2e/registry-fixture.ts — brings its own verdaccio instance: random loopback port via listen(0) readback (fix: emit /acp panel as persistent custom message and strip it from the proxy model context (#359) #360), isolated storage/config/HOME, local user + token (verdaccio $anonymous publish is anonymous-only → authenticated npm CLI gets 403; fixture uses $all), readiness polled via GET /-/ping, crash-safe teardown (SIGTERM → SIGKILL fallback).
  • tests/e2e/e2e-registry.test.ts — gated by ACP_TEST_REGISTRY=1 (skips by default; the npm test glob doesn't cover tests/e2e/ anyway). Republishes this repo's own files at synthetic OLD/NEW versions, extracts OLD under <work>/global/node_modules/<pkg>, then runs the REAL chain in a child process with fully isolated HOME/XDG_*: dist-tag resolve → tarball download → sha512 verify → staged extract → in-place install → disk flip. Asserts the real [update] log lines, on-disk version flip, no staging/backup leftovers, lock release; then post-update plugin install opencode (master semantics: bare-name entry stays idempotent).
  • Two env seams in src/update.ts (default-invariant, documented): BILI_UPDATE_REGISTRY (registry base URL override) and BILI_UPDATE_CHECK_INTERVAL_MS (check period override).
  • CI job .github/workflows/ci-registry.yml: ubuntu-latest, every PR, zero secrets, zero tokens — npm ci + build + gated suite.
  • Docs: AGENTS.md E2E section, CONFIGURATION.md (+ zh-CN mirror), tests/e2e/README.md.

Why

#1153: the full self-update chain (src/update.ts — explicitly load-bearing per §7.4) had no end-to-end coverage. Real npm can't be touched (no publish / no dist-tag rm) and CI must not carry external tokens, so per the issue spec the fixture brings its own registry instance and never depends on any external (even internal) service.

Pre-flight

  • npm run typecheck ✓
  • npm test ✓ (2162 pass / 0 fail / 2 skipped)
  • npm run build ✓
  • Gated suite: ACP_TEST_REGISTRY=1 node --import tsx --test tests/e2e/e2e-registry.test.ts → 4/4 green in ~12s (real registry doc fetch, real tarball download + integrity verify + install)
  • Default-skip verified (no env → 1 skipped)

Behavior-change disclosure (Deliverables #4)

None in production. Both new env vars are default-invariant when unset: REGISTRY_BASE still resolves to https://registry.npmjs.org and the check period stays 180000ms. No wire / config / persistence changes. ⚠️ src/update.ts is load-bearing (§7.4/§5): this change is test seams only, but flagging for the owner's call on whether the no-op-release dance applies before it ships (my read: no behavior delta under defaults ⇒ regular release is fine; PR #1143's updater changes will need the no-op flow separately).

Scope notes

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: wt-1153-ework-daemon (92dce5e)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1161

Each push to this PR publishes a new version under the pr-1161 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1161.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] 🏷 开始 review。本 PR 是 agent 完成的工作(无重做),按规范执行:核对代码 → 回归审查(src/update.ts 载重区,逐项确认既有行为) → 本地实跑 pre-flight(typecheck / 全量测试 / build / ACP_TEST_REGISTRY=1 gated suite)→ 对照当前 master 确认新鲜度。结论稍后贴出。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成:可以合并。 全部检查在 rebase 后的新 head 77414b6 上实跑通过,CI 全绿。

Diff 整洁度(第一道关)— 干净

10 个文件全部与本 PR 目的相关;+4544/-173 中 ~4238 行是 verdaccio devDep 的 lockfile 树(已披露,npm ci 实测可复现)。无跑题文件、无空格/重排噪音。

回归审查(src/update.ts 载重区,逐项既有行为)

既有行为 结论
REGISTRY_BASE(L41)默认解析 → registryUrlFor(L50) 保持。unset/空串/纯空白 → https://registry.npmjs.org,与改前字节级一致;现有 tests/update-channel.test.ts 的默认 URL 断言在 unset 下继续通过(隐式回归护栏)
CHECK_INTERVAL_MS(L52-60)→ throttle(L545)、日志(L899)、timer(L905) 保持。unset → Number(undefined)=NaN → 回退 180000ms;≤0/非数值同样回退。三处消费点逐一核对
dist-tag 文档/tarball 下载路径 未触碰。tarball URL 来自 registry doc 自身(绝对地址),不经 REGISTRY_BASE 拼接
测试断言真实性 三条 [update] 日志正则逐一对上 src/update.ts:574/624/635 的真实字符串;BILI_CLIENT_BIN(plugin-install.ts:761)、"plugin present"(plugin-install.ts:984)均存在;seed 用 plugins(复数)正确——fake opencode 报 2.4.0,pickPluginKey(plugin-install.ts:750)对 major≥2 返回 "plugins",子测试 3 测的是真幂等路径而非空转
CI workflow ubuntu-latest、零 secret、回环 only;artifact 收集只匹配 tmp/e2e-registry-*,与新 suite 的 mkdtemp 前缀一致

Reviewer 直接修的(已补 commit 到分支并 force-push)

  1. Rebase 到当前 master(原 base 9c01dbe 落后 e28fdfa 约 25 个 commit,含 v0.1.138 release)——零冲突,符合 §7.2「rebase 后重新全量验证」。
  2. 小问题:BILI_UPDATE_REGISTRY 尾斜杠——原实现 trim() || default 不处理尾斜杠,设成 http://host:port/ 会拼出 //pkg/latest。npm 自身对 registry URL 做同样的归一化,所以提取为导出纯函数 normalizeRegistryBase()(与 normalizeUpdateTag 同模式)+ 7 条单测覆盖 unset/空/多斜杠。默认行为不变(unset 路径字节级一致)。

Pre-flight 证据(全部我在 rebased head 实跑,非引用 PR 描述)

  • npm ci(380 包含 verdaccio 树)✓ / npm run typecheck ✓
  • npm test:2246 pass / 0 fail / 2 skipped ✓
  • npm run build ✓
  • Gated suite:ACP_TEST_REGISTRY=1 → 4/4 绿,~14s(真 verdaccio publish/download/sha512 verify/install);无 env → 1 skipped ✓(修完尾斜杠后又重跑一次,仍 4/4)
  • GitHub CI @ 77414b6:9/9 全绿,包括新的 hermetic registry e2e job 首跑即过 + 四平台 test 矩阵 + version-guard/build-artifact/codex 两 job

§5 no-op release 问题(PR 作者请你拍板)

我的判断与作者一致:本 PR 可走普通 release。理由:两个 seam 在 unset 下字节级等价(上面逐项核过),不存在「坏 updater 锁死升级路径」的风险面——no-op 流程防的是 updater 代码本身的行为变更,而这里没有任何生产路径行为变化。CI 矩阵(含真实 bili update 决策路径的单测)全绿进一步佐证。#1143 的 updater 改动届时单独走 no-op 流程,与本 PR 无关。此点最终由你确认。


中文一句话:搭好了自带 verdaccio 的 hermetic e2e 基建并跑通自更新全链路最小验收场景,review 确认 src/update.ts 仅加两个默认值不变的 env seam(逐项核对无生产行为漂移),已在分支上补了 rebase 和尾斜杠归一化修复,本地+CI 全绿,可以合并。

…stry + native-lane + #1297 CI wording), lock regen (verdaccio subtree only)
@ranxianglei

Copy link
Copy Markdown
Owner Author

Rebased onto current master (head 92dce5e, was 142 commits behind). Conflict resolution + review notes:

Conflicts resolved

Review of the seams (src/update.ts, the load-bearing file)

  • BILI_UPDATE_REGISTRY → normalizeRegistryBase(): absent/blank → production default; trailing slashes stripped. Env unset = byte-identical behavior.
  • BILI_UPDATE_CHECK_INTERVAL_MS → finite >0 gate, else 3-min default. Same neutrality.
  • Both documented in CONFIGURATION.md/zh-CN per the docs-mirror rule. Unit-covered in tests/update-channel.test.ts (6/6 here).
  • Release discipline note: per AGENTS §5 any src/update.ts change rides the no-op-release rule. These seams alter decision inputs only (env unset in every prod environment), but the next release after this lands should still keep that discipline in mind.

Gates on the merged tree

  • typecheck ✓ / full suite 2548 tests, 0 fail (10 e2e-gated skips) / build ✓

  • Registry e2e NOT run locally on purpose: this host's npm shim allowlists loopback publishes only on the fixed port 4873 (dog/tasks#20), while the fixture correctly uses a random port (fix: emit /acp panel as persistent custom message and strip it from the proxy model context (#359) #360). No rule was bent — the suite's own ci-registry.yml (loopback, zero secrets) runs the real self-update chain on this push; treat that check as the authoritative green for this PR.

  • ci-registry.yml reviewed: concurrency group + cancel-in-progress, artifacts on failure, no secrets — consistent with the repo's newer workflow conventions.

Merge once its own e2e-local-registry check is green. Closes #1153.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 条件已满足,但合并我执行不了:

I can't merge PRs — system rules forbid it. Please merge yourself: #1161

我对新 head 92dce5e7 的独立核验(全部实查,非引用你的描述)

  • README union ✓:tests/e2e/README.md 同时含 ## Hermetic local npm registry(L84)、## Native-lane suite(L144)两节,heading 层级一致
  • seams 完整 ✓:src/update.ts 的 normalizeRegistryBase()(含尾斜杠归一化)与 checkIntervalMs() 原样在位,单测文件在 diff 中(+12 行)
  • lockfile ✓:diff stat 显示 verdaccio 子树为唯一新增依赖面,与"master lock + --package-lock-only 重加"的描述相符
  • 可合并性 ✓:GitHub API mergeable: true,无冲突。分支现在落后 master 3 个 commit(feat: acp_rule delete/clear — wire kernel removeRule/clearRules (#1177) #1178 acp_rule delete/clear,触碰 CONFIGURATION.md 的不同区域)——不影响直接合,无需再 rebase

CI @ 92dce5e7:11/11 全绿

包括你指定的权威检查 hermetic registry e2e (local verdaccio): success,外加四平台 test 矩阵、version-guard、build-artifact、codex/pi 两条零 token e2e。你等的那个条件已经成立。

两点回应

  1. 本机 npm shim 只放行固定端口 4873(dog/tasks#20):理解,没绕规则是对的——fixture 用随机端口(fix: emit /acp panel as persistent custom message and strip it from the proxy model context (#359) #360)是硬约束,CI job 就是为此存在的,本地跑不了该套件不构成缺陷,无需在本仓库立项(那是 dog 侧的事)。
  2. Release discipline:与你和与我上轮结论一致——本 PR 的 seam 在 unset 下字节级等价,不触发 no-op 流程;后续任何真正改 updater 行为/决策路径的 release(如 fix: pin opencode plugin entry to an exact version so boots resolve from local cache (#1108) #1143)才需要走 §5 的 no-op 先验证序列。

中文一句话:已独立核验你的 rebase/冲突解决(README 并集、lockfile 仅 verdaccio 子树、seams 完整)且 CI 11/11 全绿含权威的 hermetic registry e2e,合并条件已满足,但系统规则禁止 agent 合并 PR,请你自行点合并:#1161

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.

test: 自带本地 npm registry 的 hermetic 测试基建——解锁自更新/钉版本/解析全链路 e2e

1 participant