Skip to content

[PR] e2e: Fix 5 client e2e lanes broken by pure SQLite defaults + advisory half-deletion race | e2e: 修好被纯SQLite默认击穿的5条客户端e2e泳道 + advisory半删除竞态 - #6572

Closed
ranxianglei wants to merge 5 commits into
masterfrom
fix/e2e-lanes-storage-default
Closed

ranxianglei wants to merge 5 commits into
masterfrom
fix/e2e-lanes-storage-default

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

现象

发布 v0.1.214(PR #6552)的 CI 里 5 条客户端 e2e 泳道全红(native-pi / native-dsh / native-opencode / pi-codex-ws / subagent-sessions),报 proxy must persist the session (got 0 sessions);另有一条 ubuntu "hermetic registry e2e" 偶发红(advisory-rollback 泳道)。

根因

  1. 纯SQLite存储默认(owner 决策 2026-11-13,commit 5a80e2b)让默认不再写 JSONL 会话信封(只写 index.db)。这 5 条 e2e 泳道的断言全部基于 JSONL 信封(sessionFiles() 扫描 sessions/<prov>/*.json),但 5a80e2b 只更新了单元测试,没动 e2e harness → 新默认下代理只落 index.db,JSONL 为 0 个 → 断言必挂。本地用 CI 同款 pi-stable@0.83.6 在 PR head 上确定性复现(7/8 子测试挂,磁盘上只有 index.db)。
  2. advisory 半删除竞态:updater 的 uninstall→reinstall 会先删 package.json 再删目录;waitFor 探针里 readPkgVersion 直接读文件 → 半删除窗口内 ENOENT 从 waitFor 抛出(该处无 try/catch)→ 子测试崩。本地可复现(npm -g uninstall 后目录残留、package.json 已消失)。

修复

  • 5 条泳道在 spawn 客户端的 env 里固定 BILI_STORAGE_JSON_WRITER=1(双写):这些泳道测的是代理/会话语义,不是存储默认;纯SQLite路径由单元测试 + 真模型 gate 覆盖。
  • e2e-advisory-rollback.test.ts 新增 pkgVersionOrAbsent():ENOENT 视为"还没到"(继续轮询,60s 超时仍会断言失败),非 ENOENT 照常抛。

验证

  • 本地(pi-stable 0.83.6 pinned + 本分支代码):e2e-native-pi 与 e2e-advisory-rollback 复跑通过(见 PR [PR] release v0.1.214 #6552 评审结论)。
  • 修复后 [PR] release v0.1.214 #6552 的 CI 泳道将真实执行(此前"绿"是 workflow gate 判定 skip,不是通过)。

…nstall dir

The pure-SQLite storage default (owner decision 2026-11-13, 5a80e2b) stopped
writing JSONL session envelopes by default. Five hermetic client e2e lanes
(native-pi / native-dsh / native-opencode / pi-codex-ws / subagent-sessions)
assert those envelopes and were not updated with the default flip: they now
fail with 'proxy must persist the session (got 0 sessions)' (reproduced
locally with the CI-pinned pi-stable 0.83.6 and on the PR head). Pin
BILI_STORAGE_JSON_WRITER=1 in the spawned-client env: these lanes cover
proxy/session semantics, not the storage default — the pure-SQLite path stays
covered by unit tests and the real-model gate.

Also: the advisory-rollback waitFor probes crashed with ENOENT when the
updater's uninstall->reinstall half-deletes the install dir (npm drops
package.json before the directory; reproduced locally). New
pkgVersionOrAbsent() helper treats that window as 'not there yet'; non-ENOENT
errors still throw. This was the ubuntu flake behind the 'hermetic registry
e2e' red on 16b8d9b (run 43454198949).
@ranxianglei ranxianglei changed the title e2e: 修好被纯SQLite默认击穿的5条客户端e2e泳道 + advisory半删除竞态 [PR] e2e: Fix 5 client e2e lanes broken by pure SQLite defaults + advisory half-deletion race | e2e: 修好被纯SQLite默认击穿的5条客户端e2e泳道 + advisory半删除竞态 Nov 13, 2026
The CI-only baseline preload (tests/preload-storage-baseline.mjs) pins
BILI_STORAGE_UNIFIED=legacy for the legacy-default corpus. The
sqlite-default notice test asserts the production default (absent
spelling => pure-sqlite), so without an explicit unpin it passes locally
(no preload) and reds every CI test shard carrying this file. Also unpin
BILI_STORAGE_JSON_WRITER for the same predicate.
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/e2e-lanes-storage-default (ad0616d)

Latest build — install this exact version

npm install -g billion-context@0.0.9676-pr.6572.0ef4314

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

Recent builds (commit → version)

commit version build
ad0616d billion-context@0.0.9676-pr.6572.0ef4314 build
cc47215 billion-context@0.0.9636-pr.6572.dcacfcc build
af49339 billion-context@0.0.9620-pr.6572.79b24f9 build

Download artifact

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

Install instructions are refreshed on each push.

ranxianglei and others added 3 commits November 14, 2026 01:50
tests/e2e/e2e-native-dsh-persona.test.ts asserts JSONL session envelopes
('the raw conversation key persisted a session') but its spawned env missed
the same pin as the other client lanes — red in the e2e-dsh lane.
…EBUSY)

The dual-write pins added with the pure-sqlite default flip make
persist-zstd and persist-metadata-fold-gate open index.db; the suites
never closed their stores, so the tmp-dir teardown raced a still-open
SQLite handle — Windows cannot unlink an open file, and the retry
budget in tmp-rm.ts lost deterministically (EBUSY unlink .../index.db
on windows 22/1, 22/3, 24/1, 24/3; same suites green on v0.1.213).

Close every store (closeQuietly: cancel pending writes + sidecar
close) before rmrf. closeQuietly is idempotent-safe where
flushAll already closed the sidecar.
…path)

The original comment asserted the updater 'uninstall→reinstall half-deletes
the install dir (npm drops package.json before the directory)'. Verified
against src/update.ts: there is no npm uninstall anywhere; every install
(normal self-update, advisory forceInstallVersion, manual) goes through
installViaTarball, whose success path overwrites package.json in place
(cp staging→installDir) and never deletes it. The only installDir deletion
is restoreFromBackup (failure path only, immediately restored). So the
stated mechanism does not exist. Reword the comment to describe the
observed behavior (transient ENOENT while the updater rewrites the install
dir) without asserting an unverified mechanism. The pkgVersionOrAbsent fix
itself is unchanged and remains correct: ENOENT→null→keep polling, timeout
still fails, non-ENOENT still throws.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重: 同家族但机制不同——与 #6567 高度重叠,建议合并。 #6567(先到,11-13 16:18)同样修 e2e-native-pi 泳道被 pure-sqlite 默认击穿,但用预写沙箱 config 文件(storage: { unified: "full", jsonWriter: "on" },单文件 +18 行);本 PR 用 spawn env 钉 BILI_STORAGE_JSON_WRITER=1(8 文件,覆盖 5 泳道 + advisory + notice-registry)。同根因(#6480/5a80e2b8e 纯SQLite默认)、同症状(native-pi 泳道 sessionFiles 断言 0 文件必挂),修法机制不同(config 文件 vs env 变量)、覆盖面包不同(单泳道 vs 5 泳道+2)。两者都合入则 native-pi 泳道双钉(冗余但无害);建议保留覆盖面更广的本 PR、关闭 #6567,或把 #6567 的 native-pi 修法并入本 PR 后关 #6567——请 owner 拍板。


审核独立性声明: 以下八问与结论系本人独立审 diff + 核代码 + 查 CI 后产出,未照抄 issue 侧分析。

① 审原 issue(方向关): issue 诊断的两条根因中,第一条(纯SQLite默认击穿 5 泳道)完全成立——已核 src/knobs.ts:1050-1075(resolveJsonWriterChoice 三态)+ src/persist.ts:665-675(jsonWriterOff 门)+ 各泳道 cleanEnv 先剥光 BILI*/BILLION_CONTEXT*/ACP_ 再只注入钉死的变量,断言 sessionFiles() 扫 sessions/<prov>/*.json 在纯SQLite下 0 文件必挂,因果链闭合。第二条(advisory 半删除竞态)的机制描述不成立——见第 4 问。方向判定: 修法方向正确(测试侧适配新默认,不改生产行为),但 advisory 的根因叙述需修正(已顺手修,见下)。

② 回归审查(整体关): 逐文件清点既有行为——

  • 6 条泳道钉 BILI_STORAGE_JSON_WRITER=1: 既有行为是「泳道跑在默认存储姿态」→ 有意变更为「泳道跑在显式双写姿态」。这是测试姿态变更,非生产行为变更;BILI_STORAGE_JSON_WRITER=1 是 src/knobs.ts:1068-1069 文档化的回滚路径,语义=显式双写,不改变生产默认。各泳道 cleanEnv 已先剥光所有 BILI 变量,钉死的变量是客户端拿到的唯一 BILI 变量,代理作为子进程/进程内插件继承——隔离性已核,无泄漏。
  • advisory pkgVersionOrAbsent: 既有行为是「waitFor 探针直接 readPkgVersion,ENOENT 崩子测试」→ 有意变更为「ENOENT 视为还没到,继续轮询,60s/90s 超时仍 assert.fail」。非 ENOENT 照常抛。语义收紧但安全——不会把真失败吞成通过。
  • notice-registry unpin: 既有行为是「CI preload 钉 BILI_STORAGE_UNIFIED=legacy」→ 该 suite 显式 delete 两个 storage knob 以断言生产默认(absent ⇒ pure-sqlite ⇒ SQLITE_DEFAULT_NOTICE_ID active)。已核 preload 接线(scripts/run-ci-tests.mjs:185 --import ./tests/preload-storage-baseline.mjs)+ sqliteDefaultNoticeActive 是 lazy 求值(src/notices.ts:72-74 active: () => ... 在调用时读 process.env,非 import 时),delete 在 import 前、active() 调用前生效,正确且必要([PR] fix: make full-mode storage tests deterministic (#4004) #4011 教训)。
  • 新增 commit ada04fd(persist 关 store sidecar): 双写 pin 使 persist-zstd / persist-metadata-fold-gate 打开 index.db 但没 close,tmp-dir teardown race 未关的 SQLite handle → Windows EBUSY。修法是 closeQuietly before rmrf,正确。
  • 既有行为结论: 无无意回归。全部改动为测试文件(现 10 个),零生产代码触碰。

③ 代码审查(主关): 逻辑、不变量、错误处理均过。pkgVersionOrAbsent 的 ENOENT→null→继续轮询、非 ENOENT rethrow 是正确的防御性探针语义;6 泳道 env 钉法一致且隔离;notice-registry 的 delete-before-import 时序正确。无 as any、无 @ts-ignore、无 console.error。

④ 测试有效性审查(质量关): 这些是 e2e 泳道,断言有牙(sessionFiles 长度、版本翻转、advisory 回滚落地)。pkgVersionOrAbsent 的回归兜底: 若 install 永远不到位,60s/90s 超时仍 assert.fail,不会假绿。但 advisory 的根因注释是假测试注释——原注释声称「updater 的 uninstall→reinstall 先删 package.json 再删目录」,经核 src/update.ts 无任何 npm uninstall,所有安装(正常自更新 :1763 / advisory forceInstallVersion :2292 / 手动)都走 installViaTarball(:1905-2159),成功路径 cp(staging→installDir,{recursive,force}) 就地覆盖 package.json 从不删除,唯一 rm(installDir) 在 restoreFromBackup(:2089)仅失败路径且立即 cp 回。所以注释描述的机制不存在。已顺手修正注释为描述观察到的行为(install 重写 install dir 窗口内 package.json 瞬时缺失),不 assert 未验证机制,commit ad0616d 已推 PR 分支。

⑤ diff 整洁度: 干净。全部测试文件,无跑题、无生成物、无锁文件连带、无纯空/缩进重排。每行都与本 PR 目的相关。

⑤b 代码整洁硬标准: 命名达意(pkgVersionOrAbsent 清晰)、无死代码、无重复、错误处理完整(非 ENOENT rethrow)、无魔法数字、注释讲为什么(修正后)、风格一致、不引入依赖、函数单一职责。全项过。

⑥ CI 证据(活核): 本 PR 自身 CI 的 e2e 泳道是 gate-skip(无 ci:full label,门在 .github/workflows/ci-e2e-native.yml:30-57 + ci-registry.yml:30-57,仅 ci:full/dispatch/30min cron 才真跑)——issue 自己也承认此前「绿」是 skip 不是通过。真实验证 = 发布分支 #6552(ci:full)的 CI: 已核 #6552 head(d252543,含同款 3 个 fix commit)的全部 e2e 泳道 GREEN(real pi package-native / dsh headless / opencode native / pi codex-responses WS / hermetic registry ubuntu+windows 全 success)。#6552 与 #6572 的 diff 仅版本文件(package.json / package-lock.json / 4 个 plugin manifest),测试文件内容逐字节相同。


结构化八问:

  1. 是什么问题: 发布 v0.1.214 的 CI 里 5 条客户端 e2e 泳道(native-pi / native-dsh / native-opencode / pi-codex-ws / subagent-sessions)全红,报 proxy must persist the session (got 0 sessions);另 advisory-rollback 泳道 ubuntu 偶发红。
  2. 什么原因导致的: (a) 纯SQLite存储默认(5a80e2b,owner 决策)让代理只落 index.db 不写 JSONL 信封,而 5 泳道断言基于 JSONL(sessionFiles 扫 *.json)→ 0 文件必挂;[PR] storage: pure-SQLite default — JSON envelopes stop being written unless dual-write is requested (#6479) #6480 只更新了单测没动 e2e harness。(b) advisory 安装窗口内 package.json 瞬时缺失,waitFor 探针直接读文件 → ENOENT 从 waitFor 抛出(该处无 try/catch)→ 子测试崩。注: issue 把 (b) 归因于「updater uninstall→reinstall 先删 package.json」,经核不成立——updater 无 uninstall 路径,成功路径从不删 package.json;真实机制未完全钉死,但防御性修复正确。
  3. 影响范围与严重程度: 影响 CI 的 e2e 验证(5 泳道必红 + advisory 偶发红),阻塞发布验证;非用户面缺陷——生产行为正确(纯SQLite是 owner 决策),只是测试断言没跟上新默认。严重度 = CI 红(阻塞发版),非 p1 用户可用性缺陷。
  4. 怎么修复的: (a) 6 条泳道(5 + dsh-persona)在 spawn 客户端 env 钉 BILI_STORAGE_JSON_WRITER=1(显式双写)——这些泳道测代理/会话语义非存储默认,纯SQLite路径由单测 + 真模型 gate 覆盖;(b) advisory 探针新增 pkgVersionOrAbsent(): ENOENT 视为「还没到」继续轮询,超时仍断言失败,非 ENOENT 照常抛;(c) notice-registry 显式 unpin 两个 storage knob 以断言生产默认;(d) persist 两 suite 关 store sidecar 防 Windows EBUSY。
  5. 是否有回归问题: 无。全部测试文件改动,零生产代码。高危模式逐项过: 无语义漂移(测试姿态变更已披露)、无 fail-fast 变吞错(pkgVersionOrAbsent 超时仍 fail)、无阈值/时序/输出格式变化、无缓存/重试策略静默失效。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。纯测试适配,不改架构/边界/数据流。
  8. 是否引入了新的配置: 不涉及。BILI_STORAGE_JSON_WRITER 是既有 knob,仅测试里显式 pin,非新配置面。

合并判定: 功能正确可合,但需先解决与 #6567 的重叠。 所有功能改动已独立验证正确,CI 真实验证(#6552 ci:full)全绿。唯一阻塞项是与 #6567 的同根因重叠——建议 owner 拍板合并策略(保留本 PR 关 #6567,或并入后关 #6567)。另: 我在 review 期间向 PR 分支补了两个 commit——ad0616d6b3(修正 advisory 假根因注释)+ 已 rebase 到作者新推的 ada04fd(persist 关 store sidecar,Windows EBUSY)之上。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

进度汇报(重启后确认): 审核工作已在重启前完成并投递,无阻塞。当前状态:

  1. 审核回复已发(上一条,含查重结论 + 结构化八问 + 合并判定)——核心结论:功能正确可合,唯一阻塞项是与 [PR] fix(e2e): pin dual-write storage in the native-pi sandbox (#6480 follow-up) #6567 的同根因重叠(native-pi 泳道双修,机制不同:config 文件 vs env 变量),请 owner 拍板合并策略。
  2. 已推 1 个 commit 到 PR 分支 ad0616d:修正 advisory 探针的假根因注释(原注释声称「updater uninstall→reinstall 先删 package.json」,经核 src/update.ts 无 uninstall 路径、成功路径从不删 package.json,改为描述观察到的瞬时 ENOENT 行为)。已 rebase 到作者新推的 ada04fd(persist 关 store sidecar,Windows EBUSY)之上。
  3. CI 真实验证 = 发布分支 [PR] release v0.1.214 #6552(ci:full)全绿;本 PR 自身 e2e 泳道是 gate-skip(无 ci:full label)。

无待办,等 owner 对 #6567 重叠的处置决定。

@ranxianglei

Copy link
Copy Markdown
Owner Author

本 PR 的全部 5 个修复(e2e 车道 dual-write 钉位 ×6 文件、advisory 探针 ENOENT 容忍、notice-registry env 泄漏、persist 套件 Windows EBUSY closeQuietly、注释修正)已随 #6552(release 分支合入 master)完整落在 master(c26e001b6 起,逐文件核对:6 个 e2e 文件的 BILI_STORAGE_JSON_WRITER 钉位、pkgVersionOrAbsent、两处 closeQuietly、notice-registry 的 delete 都在)。cherry-pick 到当前 master 全部冲突 = 内容已存在。此 PR 失去存在意义,关闭。

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