Skip to content

[PR] test: pin preflight escape-hatch × local-refusal edges + calibration boundary (#3977) - #4009

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-20_preflight-evidence-pins
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-20_preflight-evidence-pins

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

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

Step 0 of #3977 (先打桩 — pin before migrating): regression pins for the four preflight edges #3977's checklist names as uncovered. Tests only — zero production code changes.

What is pinned (tests/issue3977-preflight-escape-pins.test.ts, new file)

Each gate is pinned in BOTH directions per gate discipline (#3617): fires without a covering local-refusal record, closes with one.

  • P-DIV — 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 divergence forward-once (src/server.ts:3658) × local refusal. Unit-level direct call to the exported preflightCompressIfNeeded: the real walk folds the large message so its relaxed view fits under the window, while the rebuild stand-in measures the original payload over-window ⇒ exactly the divergence region. No refusal → forward-once log line; covering refusal → NO forward, fail-fast verdict per the existing contract (generic 502 here because the walk succeeded).
  • P-FRESH — [Bug] 新会话(无 usage 基线)preflight 把字符数当 token——折叠其实成功(2263796→1111212)却 fail-fast 502,上游实际只计费 540828 #3146 fresh-session forward-once (src/server.ts:3712-3730) × local refusal. Anonymous + zero baseline (the unknownBaseline regime), oversized SYSTEM-head mass. The fixture deliberately answers summary draws with an 11-char summary (kernel minSummaryLength is 50) because the system head IS foldable in the preflight walk — a usable summary would fold it away via the fits-forward path and never reach the gate. No refusal → forward-once log; covering refusal → no forward (log NOT re-forwarding for size arbitration (#3846)) + refusal-record idempotency (one record survives the fall-through re-note).
  • P-IMG unit — image-arbitration IMMEDIATE gate (src/server.ts:3360) × local refusal. Bytes-billed image reserve (22K) alone clears the window (20K) on estimate; all text below minCompressRange ⇒ zero viable ranges. No refusal → immediate forward, zero folds; covering refusal → deterministic exhaustion ⇒ 413, zero folds.
  • P-IMG e2e — image-arbitration POST-FOLD gate (src/server.ts:3691) × local refusal, through the real prepare/nudge state: a refused session (seeded with a genuine 413 from the same origin/model at the same window) gets the deterministic futility verdict (foldable mass × 1.2 slack < image-driven deficit ⇒ nothing to spend draws on) and stays 413 with zero extra forwards; a clean session forwards once for upstream arbitration. The route entry must carry imageBilling: "bytes" — under the default pixels pricing the synthetic PNG costs ~0 tokens and silently switches off the whole regime (learned the hard way while writing this pin).
  • P-LEARN — the calibration-loop boundary that step 4 flips: an overflow-400 carrying stated token counts arms the emergency shrink (positive control: overflow-arm source, overflowArmTokens = stated window) but does NOT move k̂ today — calibratedEstimate{Origin,Model} + calibrationRing + lastUsageGradeTokens are deep-equal before/after. When learnFromOutcome(overflow-400) lands in migration step 4, this pin is the deliberate flip target.

Why the base is the integration branch

The local-refusal store (#3867: localRefusals metadata + noteLocalRefusal/localRefusalCovers) exists ONLY on 2026-10-20_batch-b-fold-budget (PR #3971); on master these gates have no refusal dimension to pin. Per #3977's plan this work stacks on the integration branch and retargets master after #3971 merges (expected conflict-free: one new test file).

Acceptance (per #3977 step 0)

  • Targeted suite green locally: 8/8, ~26s (node --import tsx --test tests/issue3977-preflight-escape-pins.test.ts); typecheck clean.
  • Full-suite verdict: the CI lanes on this head.
  • Zero behavior change: tests-only file; existing issue3846 / issue3918 / issue2660 suites untouched.

查重: 不重复 — fills exactly the coverage gaps named in #3977's checklist (P-IMG / P-DIV / P-FRESH / P-LEARN); adjacent existing pins: tests/issue3846-local-refusal-evidence.test.ts (probe × refusal), tests/issue3918-preflight-progress-verdict.test.ts (verdict classification), issue2660 dead-ranges/three-way backoff suites.


Fixes #3977

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

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 独立检索 open+closed issue/PR(preflight / local-refusal / escape-hatch pin / calibration boundary 主题),无同主题在途条目;相邻既有钉(issue3846 probe×拒签、issue3918 verdict 分类、issue2660 死段/三路退避)钉的是不同边,与本 PR 的 P-DIV/P-FRESH/P-IMG/P-LEARN 四边无重叠。与 PR 正文自带的查重声明一致。

标签: pr(既有)+ bug、scope/kernel、p1(缺陷族根治的打桩步骤;preflight 折叠判定属上下文管理核心域;所属 #3977 吞并族含 #3900 会话不可用场景,按 2026-10-19 修订判 p1)。

本 [PR] 是 agent 已完成的工作(#3977 步骤 0,纯测试零生产代码),按规范不重做——现在做的是独立审核:拉分支核对代码、核 CI、过回归面。审核中发现一个状态变化,先报:

  1. base 分支已失效 → 已按计划 retarget。 [PR] Batch-B integration: fold budget/eligibility — merge #3353 #3943 #3952 #3867 #2660 #3677 (#3916) #3971(B 类集成分支 2026-10-20_batch-b-fold-budget)已经合入 master,原 base 分支被删;PR 描述自己声明了「[PR] Batch-B integration: fold budget/eligibility — merge #3353 #3943 #3952 #3867 #2660 #3677 (#3916) #3971 合入后 retarget master,预期零冲突(只加一个测试文件)」,我已执行:PR base 改为 master(现 head = 7681e2f),CI 在新 base 上重跑中。
  2. 窗口漂移需要重新验证,不是走过场。 b9f439e → 当前 master 之间走了 297 个提交,其中 src/server.ts(±194 行)、src/preflight.ts、src/session.ts、relay/prepare/snapshot-render 等 preflight 邻域都有改动,还有一批同失败域的修复([PR] Failed compression calls become collapsible regular messages, no longer permanently occupying the context. | 失败的压缩调用变成可折叠的普通消息,不再永久占着上下文 #4291/[PR] Refused compress exchanges become foldable like failed ones, no longer permanently stuck on the wire | 被拒绝的压缩调用像失败的一样可折叠,不再永久占着上下文 #4310 refused/failed-compress unprotect、[PR] Fix #4311: Block summary and compress call parameters rendered twice — no longer duplicated when the call is present | 修复 #4311:块摘要与 compress 调用参数双份上线 — 调用在场时不再重复渲染 #4314 duplicate-summary-render)+ kernel 升到 0.0.159。四个钉是按旧 base 的 preflight 行为写的,必须在新 base 上重验仍然成立——本地定向跑 + CI 全量判定,结论按八问跟进。

@ranxianglei ranxianglei added bug Something isn't working p1 scope/kernel labels Oct 23, 2026
awork added 2 commits October 23, 2026 12:04
The #3146 forward-once and #3846 refusal-closure log lines gained a
/#4185 suffix when #4185 extended the fresh-session escape to identified
zero-evidence sessions (merged to master after this pin's base b9f439e).
Behavior of the pinned anonymous-zero-baseline path is unchanged — every
other assertion in both tests passed; only the two exact-substring pins
were stale. Also align the P-FRESH negative test title with its 502
assertion (the title said 413).
@ranxianglei
ranxianglei force-pushed the 2026-10-20_preflight-evidence-pins branch from b7a116f to 439bb39 Compare October 23, 2026 04:12
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-20_preflight-evidence-pins (439bb39)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.5183-pr.4009.81acd13

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-pr4009.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] 🏷 (ai: vllm-qwen/qwen3.8-27b)

进度汇报(进程曾被强制重启,恢复后继续):

审查已完成,发现并修复了一处桩漂移,已推送。

  1. retarget:PR [PR] Batch-B integration: fold budget/eligibility — merge #3353 #3943 #3952 #3867 #2660 #3677 (#3916) #3971(集成分支)已合入 master,按 PR 描述里写好的计划把 base retarget 到 master。
  2. 漂移发现与修复:pin 的基线(b9f439e)与当前 master 之间,413 Deadlock: When an authenticated session exceeds the reservation window with zero collapsibles, the #3146 forwarding | 413 死锁:带身份会话超预留窗口且零可折叠时,#3146 转发门因 anonymous 条件不触发,会话从首条消息起永久不可用 #4185 的前置提交([PR] fix: identified sessions escape the preflight 413 dead-end (#4185) #4188)把 preflight 两条日志文案从 ...before failing fast (#3146) / NOT re-forwarding for size arbitration (#3846) 改成了带 /#4185 后缀的版本(该 regime 扩到了 identified 会话)。P-FRESH 两个测试钉的是匿名会话路径,行为未变,只有精确子串断言失配——本地复跑确认其余断言(状态码、refusal 记录数、forward 次数)全部成立。已在 PR 分支补一个 commit(test: re-pin P-FRESH log strings after the #4185 regime rename)更新两处子串 + 一个与 502 断言矛盾的旧测试标题,未动任何行为断言。
  3. 本地验证:重推后 head = 439bb39aa;定向跑 tests/issue3977-preflight-escape-pins.test.ts 8/8 通过,typecheck 干净。
  4. CI 现状:head 上 9 条辅助/e2e 车道(e2e-native-pi/dsh/opencode、e2e-codex-persona、e2e-pi-codex-ws、e2e-local-registry、e2e-fake-codex、Windows codex overlay、PR Build Artifact)全部 success;主 CI(gate + test 分片)那条 run 在 07:34Z 被取消且没有新 run 接力(分支无新推送,取消原因不可见)——正在触发 rerun,出结果后给最终八问结论。

另注:后续迁移步骤 1 的堆叠 PR #4012 里含旧的 pin commit,轮到它时需要 rebase 到本 PR 的新 head(会带上这次的重钉)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

收尾清理:issue #3977 的修复已随合并 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 p1 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Root fix: server-side size-evidence ledger + preflight verdict state machine (fold-budget/eligibility B-class family)

1 participant