Skip to content

fix: narrow dsh-context host-plugin notice to segment composition/timeline (#3303) - #3312

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-16_host-plugin-notice-scope
Oct 16, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-16_host-plugin-notice-scope

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #3303

What & why

The host-plugin notice introduced by #2865 told users dsh-context's "displayed/recorded context figures are the pre-compression local meter … so they are not accurate". #3303 measured a real session at the same instant and showed this overreaches: dsh-context's headline "current context" size equals bili's contextTokens — it is anchored on provider usage (last.prompt + Δtotal), not the lossless local log. Only its per-segment composition / timeline derives from the local store (folds happen outside the DSH event stream, storage: shadow, so dsh-context's mt() never fires). The old notice made users chase a size deviation that does not exist.

This narrows the notice to the range where it actually holds.

Behavior change (disclosed)

Web-UI dsh-context notice text, old → new:

  • zh: 「它显示/记录的上下文为压缩前的本地口径…数值不准确;显示有效尺寸需其对 billion-context 做适配。」 → 「它的分段构成/时间线按压缩前的本地口径估算…各段比例可能与实际发送内容不符;头部上下文尺寸跟随实际发送量。」
  • en: "Its displayed/recorded context figures are the pre-compression local meter … so they are not accurate …" → "Its segment composition / timeline is estimated from the pre-compression local meter … so the per-segment proportions may not match what is actually sent; the headline context size tracks the real sent volume."

The authoritative-size hint line (/acp or contextTokens) is unchanged and remains the escape hatch. Wording/scope change only — no detection, rendering, or dismiss logic touched.

Scope

  • src/web/i18n.ts — zh + en hostplug.desc narrowed.
  • src/host-plugin-notice.ts — two comments corrected to match the measured fact (split is pre-compression; headline is usage-anchored). Comment-only.
  • tests/issue2861-host-plugin-notice.test.ts — regression test pinning the narrowed scope.

Detection logic, rendering, dismiss endpoint, and the i18n key set are untouched. CLIENTS.md's #2854 general-principle doc is intentionally left as-is: it states a general property of log-derived meters, and dsh-context's usage-anchored headline is the exception, not a refutation.

Out of scope (issue item 2, optional)

Emitting compaction/summary into the host event stream on fold is deliberately not done: it would have bili inject synthetic events into dsh's log semantics, crossing the shadow-storage boundary ("bili never writes the host session log"). It mirrors dsh-context#143 refusing to read bili routes. Recorded as a decision point in the thread; if pursued it warrants its own issue + design review rather than riding in this bugfix.

Verification

  • typecheck clean; build green (dist-import-annotations: OK).
  • targeted tests/issue2861-host-plugin-notice.test.ts: 18/18 pass.
  • Full-suite verdict: remote CI on this head.

…eline (#3303)

#3303 measured (real session, same-instant three-way comparison) that
dsh-context's headline "current context" size equals bili's contextTokens —
it is anchored on provider usage, not the lossless local log. Only its
per-segment composition / timeline derives from the local store, so under
active compression the SPLIT (not the headline size) is the pre-compression
distribution. The #2865 notice claimed every displayed figure was inaccurate,
making users chase a size deviation that does not exist.

Scope the notice text plus the module/entry comments to what actually holds:
the segment composition / timeline is a pre-compression estimate, the headline
tracks the real sent volume, authoritative size via /acp or contextTokens.
Add a regression test pinning the narrowed scope.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-16_host-plugin-notice-scope (40416cf)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3862-pr.3312.e000585

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

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 本 PR 是 #3303(host-plugin notice 文案过宽)的直接修复;检索 open+closed 相关条目只有原功能 #2861/#2865(引入该 notice)与外部 dsh-context#138/#143(已关闭、方向相反/机制不同),无其他同症状+同机制的在途条目。

本条是 [PR] 唤醒(正文带 ework-agent-pr 标记),对应 PR #3312 —— 前一会话已完成开发并在 #3303 侧给出八问结论。按规范不重做,改为独立 PR 审核:拉分支核对代码、回归审查、测试有效性、diff 整洁度、CI 状态,审完按结构化八问回复。

审核起步事实:分支 2026-10-16_host-plugin-notice-scope(40416cf56),base = 当前 master(merge-base 6ee4a2a == origin/master,无 stale base);diff 收敛到 3 文件 28+/13-(src/web/i18n.ts、src/host-plugin-notice.ts、tests/issue2861-host-plugin-notice.test.ts)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

独立 review 结论。声明独立性:以下结论全部由本审核自己产出——逐文件通读了 PR 分支上的三个改动文件、本地重跑了目标测试套件、并把 CI 失败签名与 master 同 base 的 job log 逐一比对过;没有复制 #3303 侧已给出的分析或八问作为审核依据(#3303 只作需求背景读)。

结构化八问

  1. 是什么问题:web UI 的 dsh-context 提示(feat: web UI notice when a known host-side metering plugin (dsh-context) reports pre-compression context #2865 引入)笼统地告诉用户"dsh-context 显示/记录的上下文数值不准确",但 [Bug] host-plugin notice 文案过宽:实测 dsh-context 头部与 contextTokens 相符(14 ms 内),只有分段构成条是压缩前口径 #3303 实测证明它的头部上下文尺寸锚定 provider usage、与 bili 的 contextTokens 相等(同一采样点差 14 ms)——"有效尺寸不准"这半句是误报,只有分段构成/时间线才是压缩前本地口径。
  2. 什么原因导致的:写文案时把两种口径混为一谈了——dsh-context 的头部尺寸走 usage 锚定(last.prompt + Δtotal,准确),分段构成则来自 dsh 无损本地日志(fold 发生在 DSH 事件流之外、storage: shadow,dsh-context 的 mt() 永不触发,所以分段停留在压缩前分布)。真正失真的只有后者,旧文案却把整体判为"数值不准确"。
  3. 影响范围与严重程度:所有装了 dsh-context 且开启压缩、打开 web UI 的用户都会看到这条横幅。体验瑕疵级:不丢数据、不影响压缩本身,但会误导用户去追查一个不存在的尺寸偏差。
  4. 怎么修复的:把 hostplug.desc(zh/en)收窄到"分段构成/时间线按压缩前本地口径估算、各段比例可能与实际发送内容不符;头部上下文尺寸跟随实际发送量";同步修正 src/host-plugin-notice.ts 两处注释使其与实测事实一致(引用 [Bug] host-plugin notice 文案过宽:实测 dsh-context 头部与 contextTokens 相符(14 ms 内),只有分段构成条是压缩前口径 #3303);新增一条回归测试钉住新口径。权威提示行(/acp 或 contextTokens)原样保留,仍是逃生门。
  5. 是否有回归问题:对提示链路的全部既有行为逐项清点——检测三重门(直依赖 + bundles 选中 + bili-lane 门)、disabled: true patch 覆盖、banner 渲染与 HTML 转义、slot 接线、dismiss 端点与服务端持久化、i18n key 集(5 keys × zh-CN/en 双 locale,key 集一致性与非空有既有测试钉住)——diff 未触碰任何逻辑行(仅 2 个字符串值 + 2 处注释块 + 1 条新测试),既有 17 条 + 新增 1 条 = 18/18 我在本地重跑通过。高危模式逐项过:无语义漂移、无阈值/时序/输出格式变化、无 fail-fast 变吞错。唯一用户可见变化即横幅文案本身(见下方披露)。CLIENTS.md:134-143 的原则性文档(dsh context 适配 #2837:"从本地日志算出的 meter 测的是展开面")有意不动——它描述的是"本地日志衍生 meter"这一类的性质,dsh-context 的 usage-anchored 头部不属于该类,是例外不是反例;该段结尾"有效尺寸以 proxy 为准:读 /acp"依然成立。
  6. 是否破坏缓存:不涉及。未触碰任何缓存、重试、增量游标、去重键。
  7. 是否改了设计方向:不涉及。检测机制、single-writer 契约、shadow-storage 边界均未动。issue 请求项 2(fold 时向宿主事件流补发 compaction/summary)明确不做且理由成立:那会让 bili 往 dsh 日志语义里写合成事件、越过 shadow 边界("bili 从不写宿主会话日志"),并与 dsh-context#143 拒绝读 bili 路由形成对称;要做需独立 issue + 设计评审,不搭这个 bugfix 的车。
  8. 是否引入了新的配置:不涉及。

行为变更披露(与 PR 描述一致,我逐字对照 diff 核实过 old→new 无误):

  • zh:「它显示/记录的上下文为压缩前的本地口径…数值不准确;显示有效尺寸需其对 billion-context 做适配。」→「它的分段构成/时间线按压缩前的本地口径估算…各段比例可能与实际发送内容不符;头部上下文尺寸跟随实际发送量。」
  • en:"Its displayed/recorded context figures are the pre-compression local meter … so they are not accurate …" → "Its segment composition / timeline is estimated from the pre-compression local meter … so the per-segment proportions may not match what is actually sent; the headline context size tracks the real sent volume."
  • 原因:[Bug] host-plugin notice 文案过宽:实测 dsh-context 头部与 contextTokens 相符(14 ms 内),只有分段构成条是压缩前口径 #3303 实测证明头部尺寸 = 有效尺寸,旧文案在"有效尺寸"上是误报;收窄后误报消除,真实存疑的部分(分段比例)仍被如实告知。

测试有效性:新测试是真测试——直接断言"zh 不得再含『数值不准确』/ en 不得再匹配 not accurate|inaccurate"(旧文案回归立刻变红)+ "必须含分段/构成类 scoping 词"。它钉的是性质而非精确句子,对措辞类修正是对的粒度;配合既有 17 条检测/渲染/dismiss 测试,行为面全覆盖。

diff 整洁度:3 文件 28+/13-,每一行都服务于收窄措辞这一个目的;无无关改动、无空行 churn、无生成物混入。代码整洁硬标准逐项过:无死代码、无重复、注释与实测事实一致且带 #3303 出处、风格与仓库一致。

CI 状态(关键):PR head 上 9/12 test 分片红——不由本 PR 引起。证据链:① 抽样的失败 job log(PR head 与 master @ 同 base 6ee4a2a 各一份)失败测试名完全相同,均为 storage-render golden (chat/anthropic/responses/google) 四条,各 log 中仅有的 "not ok" 就是这四条;② 两轮红分片集合逐一对应(同为 9 红 3 绿、相同组合);③ 这是已知红风暴——#3313([no-dispatch] 记录:金标快照未随 #3295 重新生成,master 与所有在途 PR 分片全红)、#3314(rebaseline 修复 PR 在途)、#3315/#3319(相关记录)。本 PR diff 完全不触碰任何失败路径。其余 lane 全绿:static-gates ×4(含 typecheck)、build-artifact、kernel/lane/pi-subagents guard、docs-sync、全部 real-client e2e lane。

合并判定:代码层面可合——方向正确(修的是措辞过度断言这一根因而非症状)、无回归、测试有牙、diff 干净;当前 blocked 完全来自已知的存量 storage-render golden 红风暴。建议等 #3314(或等价 rebaseline)落地、分片转绿后再合并,或由你拍板是否先行合并。按 red-storm 防线纪律我不另开重复的修复 issue/PR(已有 #3313/#3314 跟踪)。

@ranxianglei
ranxianglei merged commit 00ea555 into master Oct 16, 2026
30 of 39 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.473-master.00ea555 (rolling master tag).

npm install -g billion-context@0.0.473-master.00ea555  # 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 pushed a commit that referenced this pull request Oct 16, 2026
…3312-#3320 batch)

- keep #3298 changes on master's post-absorb shapes: relay round-2 rebuild
  and all four prepare* paths keep withProjectAttribution; absorb imports/
  sections dropped with #3309
- storage-render goldens: metadata-section drift after the merge (absorb
  fields gone from session metadata) — regenerated via
  scripts/update-storage-render-goldens.ts, wire-body sections unchanged
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.

[Bug] host-plugin notice 文案过宽:实测 dsh-context 头部与 contextTokens 相符(14 ms 内),只有分段构成条是压缩前口径

1 participant