Skip to content

[PR] feat(dsh): emit compression coverage readout on the first routing request (#6770) | feat(dsh): 在首个路由请求上输出压缩覆盖读数 (#6770) - #6772

Closed
OMSociety wants to merge 2 commits into
ranxianglei:masterfrom
OMSociety:2026-11-15_compaction-coverage-note
Closed

OMSociety wants to merge 2 commits into
ranxianglei:masterfrom
OMSociety:2026-11-15_compaction-coverage-note

Conversation

@OMSociety

@OMSociety OMSociety commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

问题

#6770:#3962 的覆盖读数只挂在 profile-bundle note 上,而那条 note 需要 profileContext.startedBundles 有值才发。实测桌面 dsh 与 dsh-go 宿主两端都读不到这个值(手机 bili.log 1.85 MB、桌面 8.5 MB,profile bundles 与 Overlay coverage so far 均 0 命中),于是读数在两端都没有出口。

改动

  • src/agent/dsh-compaction-disable.ts:新增纯函数 compactionCoverageText(),把覆盖读数收敛到一处。记录为空时如实说「本进程还没改写任何 preset 条目」并附延迟解析的说明,不写「0 条」以免被读成「确实不需要改写」。
  • src/agent/dsh-native.ts:gateCoverageSuffix() 改为调用该函数,输出与原来逐字节相同(既有 note 行为不变)。attributionOf() 内新增一条进程内一次的输出:bili-native-dsh: compaction overlay coverage — … (#6770);另补 _resetCompactionCoverageNoteForTest() 测试钩子(与 _resetDshNewerBuildNoteForTest 同族)。

影响面

纯日志。不改 wire、不改配置面、不加 env;不读 profileContext,因此不受该探测缺口影响。

验证

  • tests/issue6770-compaction-coverage-text.test.ts:4 用例钉住格式化(空记录措辞、单复数、空 covered 列表、默认参数读实时记录)→ 4/4 通过。
  • tests/dsh-llm-stream-attribution.test.ts:新增 1 用例钉住发声接线本身——用真实 takeover gate 走一次首个路由请求,断言读数写出恰好一次、第二个请求不再重复 → 该文件 7/7,两个文件合计 11/11 通过。
  • npm run typecheck(tsc --noEmit)exit 0。
  • 未在真机安装本轮构建;最终判定以远端 CI 为准。

Fixes #6770

相关:#6588(dsh-go 宿主识别)、#3962(覆盖读数来源)、#6778(根因汇聚单 observability;本 PR 只覆盖其中的 #6770 一半,#6729 未触碰)

@ranxianglei ranxianglei changed the title feat(dsh): 在首个路由请求上输出压缩覆盖读数 (#6770) [PR] feat(dsh): emit compression coverage readout on the first routing request (#6770) | feat(dsh): 在首个路由请求上输出压缩覆盖读数 (#6770) Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。本 PR 针对 #6770(#3962 覆盖读数缺口的后续),与既有 issue/PR 无重叠。

结论: 可合 (approve) — 高质量外部贡献,无需重构。

结构化八问

  1. 是什么问题: dsh.bundle.patch.yml gates four preset ids that may not exist — the miss is only visible in the loader log #3962 的 compaction overlay 覆盖读数此前只挂在 profile-bundle note 上,而那条 note 依赖 profileContext.startedBundles 有值才发。实测桌面 dsh 与 dsh-go 两端都读不到该值,导致覆盖读数在两端都没有出口——用户无法知道 overlay 实际改写了哪些 preset 条目。

  2. 什么原因导致的: 读数的唯一出口(profile-bundle note)被 profileContext.startedBundles 的读取缺口卡死。根因不在 overlay 本身(overlay 正常工作、telemetry 正常记录在 dshCompactionGateTelemetry),而在读数缺少一个不依赖 profileContext 的出口。

  3. 影响范围与严重程度: 纯可观测性/日志问题,不触碰 wire、配置面、压缩行为。触发面:所有 dsh 宿主(桌面 + dsh-go)。严重程度:体验瑕疵(p3)——用户看不到覆盖读数,但压缩功能本身正常。

  4. 怎么修复的: 把覆盖读数的格式化逻辑收敛为一个纯函数 compactionCoverageText()(src/agent/dsh-compaction-disable.ts:138),在 attributionOf()(src/agent/dsh-native.ts:1285,gate 主路径、每个模型请求必经)里加一条进程内一次的日志,于首个路由请求输出读数。gateCoverageSuffix() 改为调用该纯函数(输出逐字节不变)。关键:新出口不读 profileContext,因此不受该探测缺口影响。

  5. 是否有回归问题: 无。

    • gateCoverageSuffix() 重构后逐字节相同(手工核对空记录分支与非空分支的字符串拼接均与原实现一致)。
    • 新增日志纯增量(进程内一次),不改变既有行为。
    • attributionOf() 新增副作用由 compactionCoverageNoted 标志守护、幂等,与同函数内既有 noticedScopedAttribution 模式一致。
    • 既有测试全绿:dsh-compaction 系列 41/41、dsh-native 76/76。
  6. 是否破坏缓存: 不涉及。纯日志,不触碰缓存/重试/增量游标/去重键。

  7. 是否改了设计方向: 不涉及。无架构/边界/数据流转向,仅给既有 telemetry 增加一个出口。

  8. 是否引入了新的配置: 不涉及。不加 env、不改配置面。

代码质量(逐项过⑤b硬标准)

测试有效性(④)

  • 4 用例断言有牙(精确匹配格式化输出,非恒真/非 tautology)。
  • 第 4 用例驱动真实 overlay middleware(非 mock),验证 telemetry 被正确填充且读数如实反映——是真测试,bug 回归时抓得住。
  • finally 正确重置 verdict + telemetry,无跨用例污染;确定性(无端口/网络/时序)。
  • 轻微缺口(非阻塞):attributionOf 里那条进程内一次日志行本身未被直接测试(只测了 formatter)。驱动完整 plugin 生命周期成本高,且 formatter 是核心逻辑、已被钉住,故可接受。

CI 与基线

  • CI 绿:59 success / 29 skipped / 0 failure(head a43596e30f)。
  • 分支基线与 master 同步(merge-base = master head f21b601893,behind 0)。
  • 本地定向验证(非全量):新增测试 4/4 通过、tsc --noEmit 通过、既有 dsh 系列全绿。全量回归以远端 CI 为准。

判定

可合。 解决 #6770 的读数出口缺失:代码整洁、注释到位、核心逻辑有真测试、无回归、CI 绿、基线最新。外部贡献达到项目标准,无需对齐重构。

@OMSociety
OMSociety force-pushed the 2026-11-15_compaction-coverage-note branch 2 times, most recently from 3e49cb3 to 7f57b51 Compare November 15, 2026 08:13
@OMSociety
OMSociety force-pushed the 2026-11-15_compaction-coverage-note branch 2 times, most recently from 4f518a2 to 08f704a Compare November 15, 2026 13:02
ranxianglei pushed a commit that referenced this pull request Nov 15, 2026
The #6772 formatter tests never exercised the emission path (first
routed request through takeoverGate -> exactly one [dsh-client] line
in bili.log, once per process). Add the once-per-process flag reset
hook and a wiring test on the #1772 paradigm (drive apply + gate,
read bili.log, assert count + exact line).
@OMSociety
OMSociety force-pushed the 2026-11-15_compaction-coverage-note branch 2 times, most recently from ba26388 to 50584be Compare November 16, 2026 07:27
ranxianglei pushed a commit that referenced this pull request Nov 16, 2026
The #6772 formatter tests never exercised the emission path (first
routed request through takeoverGate -> exactly one [dsh-client] line
in bili.log, once per process). Add the once-per-process flag reset
hook and a wiring test on the #1772 paradigm (drive apply + gate,
read bili.log, assert count + exact line).
@OMSociety
OMSociety force-pushed the 2026-11-15_compaction-coverage-note branch from 50584be to cd6c615 Compare November 17, 2026 10:15

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

APPROVE — independent review of head cd6c61597 (2 commits, +154/−8 across 4 files; base = current master, 0 behind).

Direction. Issue #6770's diagnosis holds: the #3962 coverage readout's only exit was the durable profile-bundle note, which stays silent wherever profileContext.startedBundles cannot be read (observed on both desktop dsh and dsh-go) — so the reading had no reachable exit at all. The PR implements the issue's own proposal: one [dsh-client] line on the first routed request, pure logging, no wire/config/env changes. The startedBundles root cause is explicitly left to #6778. Correct layer, correct scope.

What I verified:

  • gateCoverageSuffix() refactor (src/agent/dsh-native.ts:296) is byte-identical to the old inline strings in BOTH branches — the two profile notes (src/agent/dsh-native.ts:2921, :2930) are unchanged.
  • The new block in attributionOf() (src/agent/dsh-native.ts:1341–1352) is a once-per-process log write guarded by compactionCoverageNoted, set before the write (no double-emit); it precedes the scoped-store logic and cannot alter the return value or control flow. Same pattern as the existing noticedScopedAttribution flag.
  • compactionCoverageText() (src/agent/dsh-compaction-disable.ts:138) is pure over the record; the empty frame honestly says "no preset entry rewritten in this process (preset configs resolve lazily…)" instead of a bare zero that could be misread as "nothing needed rewriting".
  • The removed dshCompactionGateTelemetry import has no remaining references in src/agent/dsh-native.ts.
  • Tests: ran both files locally — tests/issue6770-compaction-coverage-text.test.ts 4/4 (case 4 drives the REAL overlay middleware through the public API, not a mock) and tests/dsh-llm-stream-attribution.test.ts 8/8 (the new wiring test pins the emit itself: exactly one line on the first gate-routed request, none on the second). tsc --noEmit exit 0.
  • CI on head cd6c615: 52/52 check runs completed — 38 success, 14 skipped, 0 failed.
  • No kernel/ changes, no kernel-change declaration → no human-tier gate applies.

The new wiring test also closes the gap noted in the 2026-11-14 review round (at the old head a43596e the once-per-process line itself was untested; only the formatter was).

结构化八问

  1. 是什么问题: #3354/#3962 的 compaction overlay 覆盖读数(overlay 实际改写了哪些 preset 条目)此前唯一出口是 profile-bundle note,而该 note 依赖 profileContext.startedBundles 有值才发声;实测所有宿主(桌面 dsh、dsh-go)都读不到该值,读数因此没有任何可用出口。
  2. 什么原因导致的: 读数的出口与一个当前 dsh 构建上探测不到的值(profileContext.startedBundles)耦合——出口被探测缺口卡死。overlay 本身与 telemetry 记录都正常,缺的只是一个不依赖该探测的出口。探测缺口本身的根因另由 #6778 跟踪,不在本 PR 范围。
  3. 影响范围与严重程度: 纯可观测性。受影响面:所有 dsh 宿主上「overlay 覆盖了哪些条目」不可见;压缩功能、wire、配置面均不受影响。严重程度:观测缺口(p3 级)——无数据丢失、无可用性影响。
  4. 怎么修复的: 把读数格式化收敛为单一纯函数 compactionCoverageText()(旧 note 与新出口共用,旧 note 输出逐字节不变);在 attributionOf()(dsh 车道 gate 主路径必经,模型请求/headersFor/命令路径均经过)打一条进程内一次的 [dsh-client] 日志。选这个点:preset config 延迟解析,首个被归属请求是改写已可能发生的最早可靠观测点;命令路径理论上可先于首个模型请求触发,但 preset 在会话建立时已解析,且行内措辞(lazy-resolution 说明)已覆盖该边界。
  5. 是否有回归问题: 无。逐项过了触碰路径的既有行为:(a) gateCoverageSuffix() 两个调用点(profile note)——空/非空两分支重构后逐字节一致;(b) attributionOf() 返回值与控制流不变,新增块只写日志;(c) 移除的 import 无残留引用。无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化;唯一行为变化是每进程新增一条日志行(PR 正文已披露)。
  6. 是否破坏缓存: 不涉及。不触碰缓存、重试、增量游标、去重键。
  7. 是否改了设计方向: 不涉及。纯增量观测出口;startedBundles 根因留给 #6778。
  8. 是否引入了新的配置: 不涉及。无新 env/config/默认值。

Verdict: mergeable. Note: feat: scope → not an auto-merge candidate per §7.4; human merge.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

审核完成:APPROVE 已提交(head cd6c61597,基线与 master 同步 0 behind;CI 52/52 完成——38 success / 14 skipped / 0 failed;本地定向验证:新增测试 4/4 + 接线测试 8/8、tsc --noEmit 通过;gateCoverageSuffix() 重构逐字节一致;无 kernel/ 触碰、无 kernel-change 声明;无顺手修项)。Review: #6772 (review)

@OMSociety
OMSociety force-pushed the 2026-11-15_compaction-coverage-note branch from cd6c615 to 1d304fc Compare November 17, 2026 12:35

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

APPROVE — re-review of the rebased head 1d304fcda.

What changed since the previous review (cd6c61597): rebase only. The PR's own content is byte-identical — the diff against master is unchanged (4 files, +154/−8; verified by diffing the old and new PR diffs). The new base 77fe0b1d63 pulls in #7054 (attribution diagnostics topic, src/web/diagnostics.ts) and #6592 (docs/clients) — neither touches this PR's four files, so there is no semantic interaction. Branch is 0 behind master.

Fresh verification on this head:

  • Local: tests/issue6770-compaction-coverage-text.test.ts 4/4 + tests/dsh-llm-stream-attribution.test.ts 8/8, tsc --noEmit exit 0.
  • CI on head 1d304fcda: 52/52 check runs completed — 38 success, 14 skipped, 0 failed.
  • No kernel/ changes, no kernel-change declaration → no human-tier gate applies.

The substance review (pure formatter, byte-identical gateCoverageSuffix() refactor, once-per-process gating in attributionOf(), real-middleware + real-gate test coverage) stands exactly as in the cd6c61597 review — same bytes, same conclusions.

结构化八问

(内容与上一审核 head cd6c61597 逐字节一致,以下逐项重新核对本 head 后沿用结论)

  1. 是什么问题: #3354/#3962 的 compaction overlay 覆盖读数(overlay 实际改写了哪些 preset 条目)此前唯一出口是 profile-bundle note,而该 note 依赖 profileContext.startedBundles 有值才发声;实测所有宿主(桌面 dsh、dsh-go)都读不到该值,读数因此没有任何可用出口。
  2. 什么原因导致的: 读数的出口与一个当前 dsh 构建上探测不到的值(profileContext.startedBundles)耦合——出口被探测缺口卡死。overlay 本身与 telemetry 记录都正常,缺的只是一个不依赖该探测的出口。探测缺口本身的根因另由 #6778 跟踪,不在本 PR 范围。
  3. 影响范围与严重程度: 纯可观测性。受影响面:所有 dsh 宿主上「overlay 覆盖了哪些条目」不可见;压缩功能、wire、配置面均不受影响。严重程度:观测缺口(p3 级)——无数据丢失、无可用性影响。
  4. 怎么修复的: 把读数格式化收敛为单一纯函数 compactionCoverageText()(旧 note 与新出口共用,旧 note 输出逐字节不变);在 attributionOf()(dsh 车道 gate 主路径必经)打一条进程内一次的 [dsh-client] 日志。选这个点:preset config 延迟解析,首个被归属请求是改写已可能发生的最早可靠观测点。
  5. 是否有回归问题: 无。逐项过了触碰路径的既有行为:(a) gateCoverageSuffix() 两个调用点(profile note)——空/非空两分支重构后逐字节一致;(b) attributionOf() 返回值与控制流不变,新增块只写日志;(c) 移除的 import 无残留引用。无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化;唯一行为变化是每进程新增一条日志行(PR 正文已披露)。rebase 带入的 #7054/#6592 与本 PR 四文件零交集。
  6. 是否破坏缓存: 不涉及。不触碰缓存、重试、增量游标、去重键。
  7. 是否改了设计方向: 不涉及。纯增量观测出口;startedBundles 根因留给 #6778。
  8. 是否引入了新的配置: 不涉及。无新 env/config/默认值。

Verdict: mergeable. Note: feat: scope → not an auto-merge candidate per §7.4; human merge.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

复审完成(head 已 rebase 至 1d304fcda):APPROVE 已提交——PR 自身内容与上一审核 head cd6c61597 逐字节一致(仅 rebase 到新 master 77fe0b1d63,带入的 #7054/#6592 与本 PR 四文件零交集);本地定向验证 12/12 + typecheck 通过;CI 52/52 完成(38 success / 14 skipped / 0 failed);无 kernel/ 触碰。Review: #6772 (review)

@ranxianglei

Copy link
Copy Markdown
Owner

Your fix is merged — it landed via the wave-11 batch merge (#6827 → master a446a3c1c), which carried your commit verbatim (4f518a282).

GitHub did not auto-flip this PR to Merged because the head of the branch moved after the batch snapshot (a rebase onto newer master changed the commit object ids), so the PR's current tip is not literally an ancestor of master. A git range-diff between your snapshot and the current head shows all 11 hunks unchanged, 0 changed — the content on master is byte-identical to yours, and your original commit 4f518a282 is in master's history.

Closing as merged-via-batch. Thanks for the honest-log fix.

@OMSociety
OMSociety deleted the 2026-11-15_compaction-coverage-note branch November 18, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants