Skip to content

test(dsh-lane): post-fold prefix-stability backstop for the uncovered plugin/openai lane (#2997) - #3002

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-13_dsh-lane-postfold-seam-backstop
Oct 14, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-13_dsh-lane-postfold-seam-backstop

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Addresses the DSH-lane e2e-assertion ask in #2997 §4, and records the triage verdict for the reported post-fold follow-up excess.

What this adds

One hermetic regression test, tests/openai-plugin-postfold-seam.test.ts, on the ONE compression lane #2755/#2741 never covered: DSH-native = plugin mode over /v1/chat/completions (folds arrive via POST /__bili/plugin/tool; rebuild path prepare-openai). It drives a session, fires a multi-disjoint-range fold (production cadence), and asserts the cache-seam invariant §4 asks for:

  • the pinned first user message never moves (index stable across every request);
  • no summary ever precedes the pinned first user message;
  • consecutive steady-state post-fold builds are byte-identical except at the tail — i.e. the provider prefix cache cannot bust early.

Carrier-agnostic: holds whether the seam carries the kernel acp_summary or the client's compress tool pair, so it guards the lane under either host behaviour.

Triage verdict for #2997 (why the test PASSES)

A hermetic sweep over every fold shape I could construct — single, big-contiguous, multi-disjoint-range (up to 9 stacked blocks), and partial folds — shows the bili openai-chat plugin-mode rebuild is deterministic and prefix-stable: the pinned head is byte-identical across consecutive builds and no summary drifts ahead of the pin. The reported 12–17% follow-up hit therefore does not reproduce against the proxy's own output, which points the root cause OUTSIDE bili's rebuild:

Scope / non-goals

  • Test-only (test:). No source changes, no config surface touched.
  • Does not fix the production symptom (it is outside bili's rebuild); it adds the requested coverage and pins the invariant so any future bili-side regression that reintroduces early-prefix drift fails here.
  • The §5 PARTIAL-fold double-seam cost question is a distinct failure domain (commit-granularity tradeoff, needs a design decision) — tracked separately, not bundled here.

Relates to #2997 (addresses §4).

…ane (#2997)

#2755/#2741 and their regression tests cover only the Responses-wire / proxy-mode
lane. DSH-native is plugin mode over /v1/chat/completions (folds arrive via
/__bili/plugin/tool) and had no post-fold cache-seam coverage. Add a hermetic
backstop asserting that across a multi-disjoint-range fold the pinned first user
message never moves, no summary precedes it, and consecutive steady-state builds
are byte-identical except at the tail — the invariant whose violation produces
#2997's early-prefix cache miss. Carrier-agnostic (holds under either the
acp_summary or the client tool-pair carrier).
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-13_dsh-lane-postfold-seam-backstop (a0bd762)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3400-pr.3002.541c1e3

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-pr3002.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-3002(单 commit a0bd762,diff = 唯一新增文件 tests/openai-plugin-postfold-seam.test.ts +198 行,纯测试)并做了定向验证。

我做了什么(证据)

  • 本地定向运行:node --import tsx --test tests/openai-plugin-postfold-seam.test.ts → pass 1 / fail 0(2.2s,17 requests all head-stable)。
  • 变异验证(test 有效性,断言有牙):临时在 src/server/prepare-openai.ts:226 之后的重建结果里给第一条 user 消息注入逐次漂移 nonce(模拟 head drift),测试如预期失败:steady post-fold request[15] diverges from request[14] at item[1] (< 27) — head/summary drift busts the prefix cache —— item[1] 正是 pinned first user message。即该测试能抓住与 [cache] 0.1.196 (d64139f9) 仍复现 post-fold follow-up excess —— #2741/#2755 修复后 2/2 大折叠复发 #2997 同款的回归签名。已还原,工作树干净(git status 空)。
  • 源码核对重建路径与 PR 描述一致:src/server/prepare-openai.ts:201(stripKernelSummaries)→ :226(coreToOpenai/systemToUser)→ :234-243(静态 sysParts + injectOpenaiSystem;nudge 走尾部 user 消息保 system byte-stable);plugin fold 入口 POST /__bili/plugin/tool(src/server/admin.ts:459)。
  • 覆盖缺口声明成立:现有 seam 类测试(responses-fold-cache-seam、cache-seam-*、abort-rewind-cache-seam)全是 Responses-wire/proxy-mode;host-usage-postfold 直接驱动 loop adapter(unit 级,不经 server 重建);dsh-native.test 只覆盖 install/attach。openai-chat plugin-mode 的 server 级 post-fold seam 此前确实无人钉住。
  • CI:head commit 全部 19 个 check-run 绿(test ×4 矩阵 ubuntu/windows × node22/24、static-gates、kernel-guard、lane-guard、lock-sync、version-guard、config-surface-guard、pi-subagents-guard、build-artifact 等)。
  • 查重:与既有 seam/backstop 测试及 fix(kernel): fold summaries may never precede the pinned first user message (#2733) #2755/post-fold double prefix-cache penalty: the request AFTER a fold matches only the ~11K head (one-build wire drift after compress) #2741 后续无重复立项。

结构化八问

  1. 是什么问题:[cache] 0.1.196 (d64139f9) 仍复现 post-fold follow-up excess —— #2741/#2755 修复后 2/2 大折叠复发 #2997 报告 DSH-native lane(openai-chat wire 上的 plugin mode)折叠后首个请求缓存命中仅 11.7%~17.3%(应接近全前缀命中),§4 要求给这条 lane 补 e2e 断言。本 PR 补上该断言(proxy 侧不变量形式),并记录 triage 判定。
  2. 什么原因导致的:triage 判定为不在 bili 重建内——对全部可构造 fold 形态(single/big-contiguous/multi-disjoint/partial,最多 9 块堆叠)的 hermetic sweep 显示 openai-chat plugin-mode 重建是确定性且前缀稳定的,proxy 自身输出复现不出 12–17% 的 follow-up 缺口;嫌疑指向 proxy 输出之外:dsh 客户端侧重序列化(其日志中位数本就只有 96.6%)、dsh native compaction-basic 未应用 fix(dsh): profile 层 patch 其实可以关掉 web profile 的原生自动压缩(#1772 结论修正)+ 一个会静默清空整个 preset 的写法坑 #2474 override 仍 armed、provider 侧(opencode.ai/deepseek)cache keying/TTL/cap。我的独立核对(重建代码路径 + 定向运行 + 变异复现)支持该判断的合理性;生产症状本身需要真 dsh 二进制 + 真 upstream,hermetic 测试无法建模,PR 已如实声明此边界。
  3. 影响范围与严重程度:纯测试新增,零运行时影响;填的是覆盖缺口(DSH-native/openai-chat plugin lane 此前无 post-fold seam 回归守卫)。对用户无可见变化。
  4. 怎么修复的:一个 hermetic 回归测试——真实 server + mock upstream,x-bili-plugin header 驱动 plugin mode,经 POST /__bili/plugin/tool 打 multi-disjoint-range fold(生产节奏),随后钉三条不变量:pinned 首条 user 消息索引全程稳定、任何 summary 不得先于 pin、连续 steady-state post-fold 构建除尾部外逐字节前缀一致。Carrier-agnostic(acp_summary 或 client tool pair 承载都守得住)。端口用 listen(0)、XDG env 重定向到 tmpdir,均符合仓库既有纪律(fix: emit /acp panel as persistent custom message and strip it from the proxy model context (#359) #360)。
  5. 是否有回归问题:无。审过的既有行为:diff 不触碰任何源文件 ⇒ 不存在被改动的既有行为(语义漂移/fail-fast 变吞错/阈值时序/输出格式漂移各高危模式逐项过,均不适用)。CI 全绿。
  6. 是否破坏缓存:不涉及——未触碰任何 cache/retry/增量游标/去重键逻辑。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

两个非阻塞观察(记录在案,不拦合并)

  • 断言比较的是解析后的 .messages items 而非原始 body 字节(tools/system 字段不在比较内)。该 lane 的动态内容都在 messages 里,且 system prompt 按设计本来就 byte-stable(:228-233 注释),所以可接受;若未来想更严,可扩展到整 body 比较。
  • 断言 (3)(summary topic 顺序稳定)在逻辑上被 (2) 的前缀一致蕴含,保留的价值是失败时诊断更清晰——合理。

边界确认:§5 的 PARTIAL-fold double-seam 成本问题确属另一失败域(commit-granularity 取舍,需设计决策),PR 正确地没有捆绑进来,继续在 #2997 下跟踪即可。

判定:可合。 测试有牙(变异验证通过)、范围干净、CI 全绿、triage 判定证据链完整。

@ranxianglei
ranxianglei merged commit 026997b into master Oct 14, 2026
19 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.391-master.026997b (rolling master tag).

npm install -g billion-context@0.0.391-master.026997b  # 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.

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