Skip to content

[PR] fix: count below-floor cache-seam pairs instead of dropping them silently (#3837) - #4005

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-20_seam-floor-observability
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-20_seam-floor-observability

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Refs #3837 · post-merge supplement to #3850 (same issue thread).

What

detectSeam's substantive gate (tr > 8192 && tr > 0.3*input) dropped unexplained cache breaks under the warn floor silently — the #3837 field case billed 5,701 full-price tokens with zero log lines. Below-floor pairs are now counted and surfaced:

  • agg.seamFloored / agg.seamFlooredMissed counters (legacy persisted ledgers normalize in place, same pattern as nbSamples/clientInserts)
  • one-time info log per session: [cache-seam] unexplained break under the warn floor (unexplained=N tok, input=M) — counted in seam.floored, not warned
  • additive report field seam.floored { count, missed } + a formatSeam section line

Behavior change

None. Warn thresholds, suspect flagging, forensic events and every existing bucket are untouched — strictly additive observability. Flagged (above-floor) pairs never touch the floored counters (asserted by the negative control).

Tests & regression surface


Fixes #3837

(孤儿认领:标题本已指向 #3837,补上关闭关键字 —— 第三批清理)

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-20_seam-floor-observability (5af11fa)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.5182-pr.4005.80a20c3

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-pr4005.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 是 #3837 线程里承诺的 seam 地板可见性补充(#3850 的 post-merge supplement,修 #3837 §10.1「低于 8,192 tok 的未解释断点被静默丢弃」)。与同域在途项机制不同:#4053/#4056 处理的是 client-origin 归因证据误判(thinkingTokens 被当成客户端改写),#3809 是 reasoning-effort flip 的命名归因——都不碰「地板下计数」这条路径。

标签:bug / dsh / scope/ui / p2(修的是观测缺陷:小断点零日志行;证据病例在 dsh 车道;改动面纯日志+报告字段;有绕行手段即手工 diff 出站体,非可用性缺陷)。

状态:独立复审中,发现一处真缺陷,正在分支上修。 我没有照抄原 PR 描述,而是把 detectSeam 的完整前置守卫链(missed>0 → nb≠1 → 已归因早退)和 kernel 侧 decomposeSample 的分解语义(missed = nc + cr + tr)重新推了一遍,并用真实代码跑了探针,结论:

  • 原实现把健康回合也计进 seam.floored:一个 provider 每轮完整命中前缀的正常会话(tr=0、miss 全由新内容解释),每个回合都会 seamFloored += 1,且首回合就打出 [cache-seam] unexplained break under the warn floor (unexplained=0 tok …) —— 日志语义是错的(根本没有断点),/acp-cache 的新段落会在每个健康会话出现,把「dsh durable-demote 每轮漏 5–6k」这类真信号彻底淹没。探针实测输出已留存。
  • 其余声明逐条核验通过:warn 阈值/suspect/取证事件/既有桶均未触碰;flagged(地板上)对不碰 floored 计数器(负向控制成立);持久化归一化沿用 nbSamples/clientInserts 同款模式;report 字段纯增量。

修法(几行级,按「小问题直接修」在 PR 分支补 commit):地板分支只在 tr > 0 时计数(tr=0 ⟺ miss 全由新内容解释 ⟺ 健康,维持旧版静默返回),并补上 #3617 门规缺的那条负向用例(健康回合不计数、不打日志)。随后 rebase 到当前 master、定向测试+typecheck、push,CI 绿后给八问结论。

@ranxianglei ranxianglei added bug Something isn't working dsh p2 scope/ui labels Oct 23, 2026
awork added 2 commits October 23, 2026 12:07
review finding: the below-floor branch counted EVERY pair that failed the substantive gate, including perfectly healthy turns whose miss is fully explained by new content (tr === 0). A healthy append-only session would show seam.floored count>0 with 0 tok volume and fire the one-time 'unexplained break' info log with unexplained=0 tok -- factually wrong in every healthy session, and it drowns the real signal this feature exists to surface.

Fix: count only pairs with a real residual (tr > 0) below the floor. decomposeSample guarantees missed = nc + cr + tr exactly, so tr === 0 means no unexplained break exists. Warn thresholds, suspect flagging and forensic events are untouched; above-floor pairs still never touch the floored counters.

Test: third gate case per #3617 discipline -- healthy fully-cached turn (tr=0) asserts NOT counted (agg + report), alongside the existing positive floored case and the above-floor negative control.
@ranxianglei
ranxianglei force-pushed the 2026-10-20_seam-floor-observability branch from d65178a to 5af11fa Compare October 23, 2026 04:09
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

中间状态:审核完成,发现并修掉了一个真实缺陷,已 rebase 推送新 head,等 CI。

独立审核结论(逐条重新验证,非复读 PR 描述)

  1. PR 声称的行为面全部属实:warn 阈值 / suspect 标记 / forensic event / 既有 bucket 均未触碰;above-floor(被 flag)的 pair 不碰 floored 计数器;持久化归一化沿用 nbSamples/clientInserts 同一模式;报告字段与 formatSeam 行纯增量。
  2. 但发现一个真实缺陷(已修):原实现把所有低于地板的 pair 都计入了 seam.floored——包括完全健康的轮次。kernel decomposeSample 保证 missed = nc + cr + tr,所以 tr === 0 ⟺ miss 完全由新内容解释 ⟺ 健康轮次。健康会话(provider 每轮完整命中前缀)会稳定产出 tr=0 的 below-floor pair,导致:每个健康会话的 /acp-cache 报告都会出现 seam.floored > 0,并打出「unexplained break under the warn floor (unexplained=0 tok)」这种事实错误的日志行——恰好把本 PR 要建立的观测信号污染掉。用真实代码探针复现确认(健康 append-only 会话 → seamFloored=2、日志行 firing;轻微劣化 200 tok → 正确计数 1)。
  3. 回归清点:diff 仅触碰 src/cache-ledger.ts(detectSeam 地板分支 + agg 归一化 + 报告/格式化增量字段)与新测试文件。未触碰 wire/message-shape、config schema、kernel/、src/update.ts、identity/session-binding。既有行为逐项保持:warn 阈值不变、suspect/forensic 路径不变、报告旧字段不变(新增字段纯 additive)。

验证状态

  • 本地定向套件全绿:cache/seam/ledger 相关 22 个测试文件共 160 个测试(含新 gate 测试)+ rebase 后复跑子集 75/75。
  • npm run typecheck clean、npm run build 成功(rebase 后的 head 上)。
  • 已 rebase 到当前 master(v0.1.204 时代,e98ccda98 → fba2d13),无冲突;force-with-lease 推送到 PR 分支(仅 feature 分支,master 未动)。PR head 现为 5af11fa35(rebased 原 commit bb2f26ffa + 审核修复 5af11fa35)。
  • CI:push 后 27→30 个 check run,guard/build 已过(success/skipped),其余(含 sharded test lanes)在排队——共享 runner 池拥塞,12 分钟内 15 个 lane 一直 queued。全量判定以 CI 为准,绿了我立刻补八问结论回复。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

审核结论(独立重审,非复读 PR 描述)— 八问

  1. 是什么问题:cache-seam 检测器的实质地板(tr > 8192 && tr > 0.3·input)把低于地板的未解释缓存断点整个丢弃——OpenAI/Codex channel: Per-request body rewriting causes the prefix cache to periodically reset to zero (degenerate foldi | OpenAI/Codex 通道:每请求改写请求体导致前缀缓存周期性归零(退化折叠 foldPoint=m00001 + abort 后 stamped 漂移),单会话 66.7% 计费为全价输入 #3837 现场案例 5,701 tok 全价计费、零日志行。本 PR 把这类断点变为可见:计数器 + 每会话一次性 info 行 + 报告字段。
  2. 什么原因导致的:地板分支设计目的是抑制 warn 噪音,但 return 之前什么都没记——地板以下 = 完全不可见。深层依赖:kernel decomposeSample 的恒等式 missed = nc + cr + tr(新内容 + 压缩偿还 + TTL 重付),所以「未解释残差」就是 tr,而 tr === 0 ⟺ 完全由新内容解释 ⟺ 健康轮次。
  3. 影响范围与严重程度:纯观测面,无用户行为变化;严重度 p2 级诊断盲区——凡出现 <8,192 tok 未解释断点的会话(dsh runtime-context 快照插入这类小断点是常态形状),此前日志与 /acp-cache 报告都看不到。
  4. 怎么修复的:地板下且 tr > 0 的 pair 计入 seamFloored/seamFlooredMissed(旧账本加载时原位归一化,同 nbSamples/clientInserts 模式),首次触发打一次性 info 行,报告加 additive 字段 seam.floored {count, missed} + formatSeam 段落行。审核中发现并修掉一个真实缺陷:原实现把地板下的所有 pair 都计数——包括健康轮次(tr=0)。后果是每个健康会话的报告都会出现 seam.floored > 0 和事实错误的「unexplained break (unexplained=0 tok)」日志行,恰好污染本 PR 要建立的信号。用真实代码探针复现确认后,在地板分支加了 tr > 0 门 + 第三个 gate 测试(Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 双向纪律的第三向)。修复后复探两向均正确:健康会话 → 0 计数无日志;200-tok 真实残差 → 计数 1 + 日志。
  5. 是否有回归问题:无。diff 触碰路径的既有行为逐项清点:warn 阈值(不变)、suspect 标记(above-floor 路径字节级未动,负控断言钉住)、forensic event(不变)、既有 agg bucket(不变)、持久化加载(仅 additive key 归一化)、/acp-cache 与报告旧字段(不变,新增纯 additive)、abort-correlation / sw|pw|uw|rs / cause / foldSeq 各提前返回臂(顺序与语义未动)。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及——未触碰任何 prefix cache / 重试 / 游标 / 去重逻辑,对上游缓存行为零影响。
  7. 是否改了设计方向:不涉及——架构/边界/数据流无转向,严格 additive 观测性,全部落在既有 ledger 模块内。
  8. 是否引入了新的配置:不涉及——无新 env/config/CLI 面(符合 env-var discipline:观测性不需要新旋钮)。

测试有效性:三个 gate 方向都有真断言——正向(floor 下真实断点被计数、不 flag、无 forensic event、跨样本累积、报告+API 可见)、负控(above-floor 断点照旧精确 flag)、gate 负向(健康 tr=0 轮次完全不计数)。每个断言在本 bug 回归时都会红(如去掉 tr > 0 门 → 健康会话测试的 seamFloored===0 立即失败)。

验证状态:rebase 到当前 master(v0.1.204 时代)无冲突;本地定向套件全绿(cache/seam/ledger 相关 22 文件 160 测试 + rebase 后复跑子集 75/75);npm run typecheck clean、build 成功。最终 diff:2 文件 +129/-5,每行都与本 PR 目的相关。CI 状态:guard/build 类 lane 已过,其余 lane(含 sharded test)因共享 runner 池被其他 5 个在途 PR 占满而排队(30+ 分钟 in_progress=0),全量判定待 CI 出结果——红了我会定向排查并跟进回复。

判定:可合入(待 CI 绿)。PR head 5af11fa35 = rebased 原 commit + 审核修复 commit,force-with-lease 已推送 feature 分支(master 未动)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

收尾清理:issue #3837 的修复已随合并 PR 落地。关单;误判请 reopen。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dsh p2 scope/ui

Projects

None yet

1 participant