Skip to content

[PR] test: pin the D2 fit-forward estimate-only warn (#5414, post-#5409 supplement) - #5423

Open
ranxianglei wants to merge 9 commits into
masterfrom
2026-11-01_d2-pin-followup
Open

ranxianglei wants to merge 9 commits into
masterfrom
2026-11-01_d2-pin-followup

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Closes #5413

Post-merge supplement for #5409: the D2 stale-view guard (FIT_FORWARD_ESTIMATE_ONLY_MARGIN = 0.85, src/preflight.ts) shipped in #5409 without its regression pin. The pin was prepared as an additive commit on #5409's branch but #5409 merged first (1ef7bd2), so per house rules it lands here as a small follow-up PR referencing the original.

What this pins

When the #4288 fit-forward exit judges on ESTIMATE ONLY (no usage baseline) at >= 85% of the hard window limit, a WARN must fire exactly once (observability only — the forward still happens). tests/issue5413-fit-forward-estimate-only-warn.test.ts adds:

  1. e2e positive — anonymous fresh prefix-affinity session (the fork 会话 lastInputTokens=0 时 preflight 退化为字符估算,大载荷被低估后不压缩直接裸转上游 #553 unknownBaseline regime: trigger arm judges on the char-count upper bound, fit judgments on the optimistic CJK-aware estimate), payload sized so the judged estimate lands inside [0.85*window, window): asserts the walk ran, the D2 warn fired EXACTLY once with provenance refs and an in-band quoted estimate, (baseline ~0) (no usage backing), zero folds, zero summarization calls.
  2. e2e negative — identical shape just under the margin: same walk, ZERO warns (with the non-vacuity proof that preflight actually ran).
  3. unit boundary — direct preflightCompress at ~90% vs ~80% of the window with the margin constant deliberately re-stated (not imported) so the pin breaks if the source constant moves.

The e2e fixture uses many SMALL messages (each below the emergency-truncate keep window / min-output gate) so the kernel's truncate node cannot clip+latch a shrunken view under the margin and mask the guard — the header documents the derivation, including why the issue's usage-baseline sketch cannot reach the guard through the classic trigger.

Verified: targeted file green locally, typecheck clean, mutation-checked (raising the margin to 0.999 turns both the e2e positive and the unit boundary red).

Behavior change: none — test-only additive file. No config surface, wire, persistence, or kernel changes.

ework-agent and others added 7 commits October 31, 2026 18:03
Converging master's red gates onto ci-fixes. lifecycle-ledger-guard is already fixed here (LIFECYCLE.md entries for BILI_SESSION_CONTENT_STORE_PIN / BILI_SPAWN_FINGERPRINT from the prior sentinel pass, preserved through the master merge); this commit clears the other two.

docs-sync: #5319 documented the new 'chat' builtin prompt pack in CONFIGURATION.md/.zh-CN.md but never updated the single-source seed, so regeneration dropped it and the gate failed. Add 'chat' to the compress.promptPack seed (type/desc_en/desc_zh) and regenerate website/docs/index.html to match.

unused-exports: CodexWindowSource (src/codex-models.ts) and PackInstallOptions (src/pack-install.ts) are referenced only inside their own modules and imported nowhere else; drop the leading export (INTERNAL_ONLY) as the guard prescribes.

Verified locally: lifecycle-ledger-guard OK, check-unused-exports clean, gen-config-docs regenerate matches committed artifacts (zero drift).
…safe family gate)

pack-install.ts took the last 3 npm stderr lines via split+slice(-3), tripping the #816/#1615 family gate in tests/text-safe.test.ts even though the receiver is an array of lines (code-unit-safe). Use a non-negative computed start index so the literal negative-slice token is gone; output is identical (last up-to-3 lines clamped to 300 chars). Inherited from #5340, which shipped without satisfying the gate.
Inherited red resolved by convergence, not rewrite: ci-fixes was 12 commits
behind master and its two unique fix commits (cbdd67d negative-slice, 701688d
docs-sync/unused-export) are strict subsets of what master already merged
better (e030d3b+4a12c1a4 safePrefix+windows npm shim, 3491e2d dead export,
b76f0c9 lifecycle reconcile). Both failing shards were inherited from master's
own newer commits that ci-fixes lacked:
  - #5103 refusal-remedy test -> pinned by 892a378
  - flushAll dirty content store -> fixed by 1f209ff (src/store.ts adopt)
Conflicts (codex-models.ts, pack-install.ts) resolved toward master = superset.
Resulting ci-fixes tree is byte-identical to origin/master (git diff empty).
@ranxianglei ranxianglei changed the title test: pin the D2 fit-forward estimate-only warn (#5414, post-#5409 supplement) [PR] test: pin the D2 fit-forward estimate-only warn (#5414, post-#5409 supplement) Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-01_d2-pin-followup (fe346ef)

Latest build — install this exact version

npm install -g billion-context@0.0.7691-pr.5423.7a4666b

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
fe346ef billion-context@0.0.7691-pr.5423.7a4666b build
6d5f1aa billion-context@0.0.7687-pr.5423.832f670 build
6d3543e billion-context@0.0.7682-pr.5423.c79984f build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5423.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 就是 #5414(D2 fit-forward estimate-only WARN 缺回归钉)的实现本体——按失败签名(fit-forward / estimate-only / margin pin 变体)检索 open+closed issue 与 PR,无其他针对该守卫的 pin 条目,也无同目的在途 PR;相关线程只有 #5409(交付守卫的 PR)与 #5414(本 pin 的来源 issue),两者均非重复。

标签: bug + scope/kernel + p3 —— 守卫随 #5409 上线却缺正负双向断言,违反 #3617 gate discipline,属交付完整性缺陷而非功能请求;preflight 折叠判定面归 scope/kernel;纯测试增量、无行为变化,p3。(已打:pr, bug, scope/kernel, p3)

审核进行中(先报结构面):分支相对当前 master 仅一个 commit 6d3543eb2,单文件新增 tests/issue5414-fit-forward-estimate-only-warn.test.ts(328 行),diff 干净、无顺带改动。已把测试断言逐条对照 src/preflight.ts:2207-2208 源码核实:warn 文案 "fit-forward on estimate only"、provenance refs (#5408/#4288)、(baseline ~0) 格式、~N tok vs window M 正则全部与源码一致;非空性证明行对应 src/server.ts:3756 的 "reached preflight target … preflight compressing before forward"(每次请求恰一条)。常量镜像设计(MARGIN=0.85 有意重写不 import)语义正确:源常量上移→正向红,下移→负向红,双向都有牙。

接下来做本地定向验证(单文件运行 + 变异检查:margin 改 0.999 应使正向与单元边界同时变红),CI 结果出来后按八问给最终结论。

The pin was drafted against a mirror-side issue number (#5414); on GitHub that number is an unrelated open PR, while the D2-pin issue is #5413. Renames tests/issue5414-* -> tests/issue5413-* and updates the six in-file references so cross-references resolve on GitHub. Test content unchanged.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

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)

Verdict: APPROVE (posted as a comment: GitHub's API refuses a formal approval from the PR's own author account) — the pin is real and toothed in both directions; the one defect I found (a mirror/GitHub issue-number mix-up) is already fixed on this branch.

Independent verification (re-derived from source, not taken from the PR text)

  • Diff vs master (c78ecb4b5): exactly one additive test file (+328 lines). No src/, kernel/, config, wire, or persistence changes.
  • Assertions cross-checked against source: constant at src/preflight.ts:147; guard at src/preflight.ts:2207-2208 (condition !armedBaseline && baselineFloor < textTarget && payloadEstimate >= MARGIN * limit; warn text incl. ~N tok vs window M, (baseline ~N), provenance (#5408/#4288)) — every substring/regex the test asserts matches. The guard sits inside the fit-forward exit (src/preflight.ts:2197-2211), so the forward still happens — warn is observability-only, as claimed. The non-vacuity line ("reached preflight target … preflight compressing before forward") exists at src/server.ts:4084.
  • Local run at head: 3/3 pass (~8 s).
  • Mutation checks, both directions (the PR claimed only the first):
    • margin → 0.999: e2e-positive + unit-boundary RED, negative stays green (as claimed);
    • margin → 0.5: e2e-negative + unit-boundary RED, positive stays green (extra verification — the sub-margin control also has teeth).
  • Gate discipline #3617 satisfied: positive AND negative directions, each with proof the walk actually ran.

Defect found & fixed during this review (disclosed)

The PR was drafted against an internal mirror issue number (#5414); on GitHub that number is an unrelated open PR (blog pipeline), while the D2-pin issue is #5413. Left as-is, merging would have auto-closed the unrelated open PR via Closes #5414.

  • PR body edited: Closes #5414 → Closes #5413 (+ the test-filename reference in the body).
  • Additive commit 6d5f1aacd: renamed tests/issue5414-* → tests/issue5413-* (repo convention: filename = GitHub issue number, cf. issue532/issue564/…) and updated the six in-file references. Re-ran after rename: 3/3 green; test content otherwise unchanged.
  • Residual, cosmetic only: the PR title and the original commit message still carry "(#5414)" — the title is system-owned (not renamed per policy) and the original commit is not rewritten under the additive-commit rule.

Regression audit (existing behaviors carried by touched paths)

The diff touches no existing path — new file only. Adjacent behaviors the new tests EXERCISE (the D2 warn itself, the fit-forward exit, the preflight walk) are asserted unchanged: warn fires exactly once in-band, zero folds, zero summarization calls, forward returns 200. No threshold/default/timing/output-format drift, no fail-fast→swallow change, no cache/retry/cursor impact, no new config surface, no kernel change. Note: my rename commit triggers a fresh CI pass on head 6d5f1aacd (pure rename, content-identical assertions).

Structured eight questions

  1. 是什么问题: #5409 上线的 D2「estimate-only 近窗 WARN」守卫没有任何回归钉——守卫若退化(阈值错、分支错、静默丢失)无人察觉。
  2. 什么原因导致: 交付完整性缺口——pin 原本备在 #5409 分支上,#5409 先合入,按仓库规则以 follow-up PR 形式补交。
  3. 影响范围与严重程度: 无用户直接影响(纯观测性 WARN);严重度 = 防御性信号缺回归覆盖(内部实现面)。
  4. 怎么修复的: 三枚钉——e2e 正向(恰好一次 WARN、引用估计值落在 [0.85·window, window)、baseline ~0)、e2e 反向(同形状低于 margin → 零 WARN,带非空证明)、单元边界(直接 preflightCompress ~90% vs ~80%,margin 常量有意重写不 import,源常量一动即断)。
  5. 是否有回归问题: 无。diff 只新增测试文件,未触碰任何既有路径;新测试对 D2 守卫/fit-forward 出口/预检走查的既有行为做了只读断言且全部保持。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。
  8. 是否引入新配置: 无。

判定:可合入(mergeable),待人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

审核完成:APPROVE(已发至 GitHub PR #5423,以 review comment 形式——GitHub API 拒绝作者账号自批正式 approval,结论与完整八问写在评论里)。

审中发现并直接修复一处缺陷:PR 正文按内部镜像编号写了 "Closes #5414",而 GitHub 上 #5414 是另一个无关的 open PR(blog pipeline),合并会误关它;D2 pin issue 的 GitHub 真实编号是 #5413。已改正文 Closes 行 + 文件名引用,并按仓库惯例把测试文件重命名为 tests/issue5413-fit-forward-estimate-only-warn.test.ts(含文件内 6 处引用,增量 commit 6d5f1aacd,改名后复跑 3/3 绿)。标题里的 (#5414) 属系统所有未动。

技术面独立核验:断言逐条对照 src/preflight.ts:147/2207-2208 源码(常量、守卫条件、warn 文案、provenance refs)一致;本地定向跑 3/3 通过(~8s);双向变异检查——margin→0.999 正向+单元边界红、margin→0.5 反向+单元边界红,正负两侧都有牙(比 PR 声称的单向更强)。纯测试增量,无 src/kernel/配置/线上行为变化,无回归。

标签判定:bug + scope/kernel + p3(镜像 shim 未实现 labels API,未能落标,仅记录)。待人工合并;新 head 6d5f1aacd 会触发一轮新 CI(纯改名,无内容变化)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

审核结论:PASS——代码就绪,等新 head 的 test 车道绿灯后由 owner 合并

八问:

  1. 是什么问题:[PR] fix: frozen compression state becomes visible, diagnosable, and healable (#5408) #5409 落地的 D2 stale-view guard(fit-forward 在无 usage 实测基线、仅凭乐观估算判定时,≥85% 窗口即发一次 WARN)没有配套回归钉——该守卫目前无任何测试覆盖,Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 门禁纪律要求正负双向成对。本 PR 补的就是这颗钉。
  2. 什么原因导致的:非缺陷,是流程遗漏——钉原本备在 [PR] fix: frozen compression state becomes visible, diagnosable, and healable (#5408) #5409 分支上作增量提交,[PR] fix: frozen compression state becomes visible, diagnosable, and healable (#5408) #5409 先合了(1ef7bd2),按 house rules 转为本 follow-up PR。
  3. 影响范围与严重程度:无(纯新增测试文件,零行为面)。缺钉的代价:未来任何改动弄坏 D2 guard(常量漂移/warn 被删/条件弱化)都会静默通过 CI——这正是钉要堵的洞。
  4. 怎么修复的:三层钉——① e2e 正例:unknownBaseline 匿名新会话,48×2700 字符载荷使 judged estimate 落入 [0.85·window, window),断言 walk 真跑了、WARN 恰好一次且带 provenance refs([Bug][dsh][storage] Compression permanently fails for a session: frozen ingest watermark, requests no longer observed, and no warning until the host dies with CONTEXT_WINDOW_EXCEEDED #5408/The symptom is that switching models causes a hang, suspected to be triggered by dsh native compression. | 症状是切模型卡住疑似触发 dsh 原生压缩 #4288)、in-band 引用估算值、(baseline ~0)、零 fold 零 summarization;② e2e 负例:同形状刚好低于 margin,walkRan==1 做非空证,WARN 必须为零;③ unit 边界:直调 preflightCompress,~90% 触发 vs ~80% 不触发。MARGIN=0.85 在测试里刻意不复用源码导入而是重新声明——源码常量一动钉就断。双向 mutation 我本地都验过:margin→0.999 使正例+unit 变红,→0.5 使负例+unit 变红。
  5. 是否有回归问题:无。diff 相对 master = 单个新增测试文件(+328),不触碰任何生产代码路径,wire/config/persistence/kernel 全零变更;既有行为清单为空(没有可破坏的面)。
  6. 是否破坏缓存:不涉及(无运行时改动)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

独立验证(未采信 PR 自述,全部自己复跑/比对):

  • 断言逐条对源:src/preflight.ts:147(FIT_FORWARD_ESTIMATE_ONLY_MARGIN = 0.85)、:2207-2208(round-boundary forward 判定后触发、随即 break → 每次调用 ≤1)、warn 文案字节、walk 证明行 src/server.ts:3756 —— 全对上;
  • 全部 import/签名存在(setLogCapture、_setStoreForTest、getSession、PreflightDeps、PreflightResult 等);
  • 定向本地跑 3/3 绿(~7s);
  • 双向 mutation check 通过(见第 4 问)。

CI 处置说明(为什么我动了分支):

顺带发现两处:

  1. 审核期间远端分支新增 commit 6d5f1aa:测试文件与 6 处引用从 [PR] Blog pipeline: every post gets its own bilingual GitHub Discussion automatically #5414 改名为 D2 fit-forward near-window WARN has no regression test (#5409 gate without its pin) #5413——钉起初按镜像侧编号 [PR] Blog pipeline: every post gets its own bilingual GitHub Discussion automatically #5414 起草,而 GitHub 上该号是不相关的 open PR,真正的 D2-pin issue 是 D2 fit-forward near-window WARN has no regression test (#5409 gate without its pin) #5413。改名正确、内容不变,我已在新文件名下复跑 3/3 绿。但 PR 正文仍写 "Closes [PR] Blog pipeline: every post gets its own bilingual GitHub Discussion automatically #5414"——在 GitHub 上 auto-close 会打错线程,建议 owner 把正文改为 Closes D2 fit-forward near-window WARN has no regression test (#5409 gate without its pin) #5413。
  2. e2e 正例的 judged estimate 距区间两端各约 3k——未来 tool-schema 漂移把它推出 [0.85·window, window) 时测试会响亮地失败(逼着重新调参),不会静默放行。作为 pin 可接受。

判定:满足 §7.4 自动合入标准(纯 fix/test 增量、单模块、clean diff、引用 issue、无行为面变更),行为变更:无;合并动作留给人——新 head 的 test 车道绿灯后即可合。

标签:pr / bug / scope/kernel / p3(内核域回归钉缺失,严重度低——影响仅限可观测性守卫,无用户可见行为)。

This branch has not been deployed

No deployments
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.

D2 fit-forward near-window WARN has no regression test (#5409 gate without its pin)

1 participant