Skip to content

[PR] fix: name permanent resident-eviction compress refusals and keep progressing preflight exhaustion retryable (#3918) - #3943

Merged
ranxianglei merged 6 commits into
masterfrom
2026-10-20_resident-eviction-honest-refusal
Oct 21, 2026
Merged

ranxianglei merged 6 commits into
masterfrom
2026-10-20_resident-eviction-honest-refusal

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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

Addresses part of #3918 — the two lying verdicts in the incident chain where a healthy 93%-compressed image session became permanently uncompressible. The remaining expected behaviors (eviction policy, snapshot-based compression) need an owner decision and are tracked in the issue thread; Phase 2 (attribution loss) is #2975's mechanism.

What was broken

1. compress refused forever, with advice to retry. When a session's live footprint cannot fit the resident pool alongside other open sessions, releaseInFlight's discharge evicts it after EVERY model request, so the empty-view refusal (#3126) repeats identically forever — yet its receipt promised "the view self-heals on the next model request" and told the user "after the next turn you can compress the same ranges again". Incident: a ~444 MiB image session ping-ponging against an ~87.5 MiB peer under the 512 MiB default budget; every retry failed exactly as predicted, with no exit named anywhere.

2. Preflight exhaustion reported terminal while making progress. A preflight walk that exhausts its summarization budget AFTER committing real folds was reported 502 retryable=false ("doomed") although the folds persist in the session and the next attempt starts from a smaller baseline and continues folding. Incident: 64 effective folds (2,012,855 → 914,731 tokens), every round declared terminal.

Fix

  • src/session.ts: stamp each eviction with the session's LIVE weight (measurable only at that moment — a disk reload under-measures by exactly the transient mass that made the eviction necessary); new export residentPressure(id) reporting whether weight + other residents exceed the byte budget. Advisory-only, bounded to 256 entries.
  • src/stream.ts: when that condition holds, the refusal receipt AND the operator log name the PERMANENT case and give the exits (close another open session, or raise sessions.residentMaxBytes above the measured sum); otherwise the original transient wording stands byte-for-byte.
  • src/server.ts: non-deterministic budget exhaustion with compressedRanges > 0 → retryable=true plus a progress note (ranges folded, tokens short of the window). Zero-progress and deterministic paths unchanged.

Behavior changes (old → new)

Surface Old New Why
Empty-view compress refusal, permanent case "wait for the next turn" advice NOT-TRANSIENT diagnosis + exits; operator log gains a PERMANENT marker with measured numbers the old advice was unreachable for budget-evicted sessions
Empty-view compress refusal, transient case unchanged unchanged —
Preflight fail-fast, non-deterministic budget exhaustion always retryable=false retryable=true + progress note ONLY when compressedRanges > 0 folds persist across turns; retrying makes real progress
Preflight fail-fast, zero-progress / deterministic exhaustion unchanged (incl. the #3461 413 path) unchanged retries are genuinely doomed there

Config surface: none added. sessions.residentMaxBytes / BILI_SESSION_RESIDENT_MAX_BYTES are PRE-EXISTING knobs (CONFIGURATION.md en+zh), now merely named in user-facing text.

Tests

New: tests/issue3918-resident-eviction-refusal.test.ts (pressure mechanics + positive/negative receipt directions) and tests/issue3918-preflight-progress-verdict.test.ts (progress → retryable + note; zero progress → terminal, negative direction). Targeted local runs green: both new files plus issue3126-no-visible-context, bounded-storage, preflight-multi-range, issue3461-overlimit-exits, preflight-fail-fast, issue1841-preflight-futility, preflight-empty-summary, issue2847-doomed-nonretryable-status, preflight-stream-summary-config — 60 tests. Full-suite verdict = CI on this head.

Out of scope (tracked elsewhere)

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-20_resident-eviction-honest-refusal (bd84a36)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4894-pr.3943.09d8bef

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-pr3943.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: name permanent resident-eviction compress refusals and keep progressing preflight exhaustion retryable (#3918) [PR] fix: name permanent resident-eviction compress refusals and keep progressing preflight exhaustion retryable (#3918) Oct 20, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 —— 本 PR 是 #3918 线程里「无决策依赖部分先修」的交付(见该票 floor 3/4 的处置计划),检索 open+closed 无其他同机制条目(失败签名:resident-eviction 拒收回执文案 + preflight progress retryable,均无在途重复)。与 #3859/#3863(空视图守卫绕过)、#3137(空视图标 DEAD)、#3461(413 终局路径)相邻但机制不同:本 PR 只改判决的措辞与可重试性,不动守卫/驱逐行为本身。

标签: pr, bug, dsh, scope/kernel, p1(沿用 #3918 定级——核心承诺失灵的部分修复,严重度随母票)。

开工状态:正在按 PR review 规范独立审这个分支(diff 逐段读 + 既有行为清点 + CI 核对)。当前 head 8d85efe 的 CI 有一处红:unused-exports(src/session.ts 导出的 ResidentPressure 类型未被外部引用);test lane 显示 skipped,正在查明原因。审完给八问结论。

@ranxianglei ranxianglei added bug Something isn't working dsh p1 scope/kernel labels Oct 20, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Review 结论(独立审核,非复读 #3918): 两个修复都打到了机制层,回归清点干净,可以合并。审核过程中我推了一个小修 commit(见下),CI 状态见文末。

结构化八问

  1. 是什么问题:两处「判决书说谎」——① 会话太大、和其他常驻会话挤不进内存预算时,压缩拒绝回执一直承诺「下一轮模型请求会自愈」,实际它每个请求周期都被逐出,同样的拒绝永远重复;② preflight 明明已经落盘了真实折叠,却把本轮判成终局(retryable=false),宿主在「每次重试都有进展」的地方停手。
  2. 什么原因导致的:① 拒绝文案写于 [bug] 大会话 compress 持续失败:ctx has 0 message(s) 时所有 ref 被判悬空(cannot-anchor),报错归因误导 #3126,默认逐出是瞬时的,从不在当前池占用下校验「重载后还能不能活过两个请求之间」;② fail-fast 尾巴只按 status 启发式映射 verdict,不看本轮是否已提交折叠——判决度量的是「这一轮」,不是「轨迹」。
  3. 影响范围与严重程度:proxy 模式下活体足迹挤不进 sessions.residentMaxBytes(默认 512 MiB)的会话(典型:数百 MiB 图片会话)。refs 完好、无数据丢失、有绕行(关对端会话/调预算),但文档化建议永远失效且误导重试循环——核心承诺(可压缩)对该类会话不可用,故维持 p1。
  4. 怎么修复的:① 逐出时给会话打上活体重量(256 条上限的 FIFO 表,纯咨询性、不承重),拒绝时实测「本体重+其他常驻 vs 预算」:挤不进 → 回执/日志/repeat-guard 三处明确说 PERMANENT 并给出两个出口(关另一个会话 / 调高 sessions.residentMaxBytes 后重启);挤得进 → 原瞬时文案逐字节不变。② 非确定性耗尽且 compressedRanges>0 → retryable=true,detail 追加进展句(N 个 range 已持久化、下次从小基线继续、缺口 token 数)。
  5. 是否有回归问题:无。逐项清点触碰路径的既有行为:
  6. 是否破坏缓存:不涉及。prompt-cache/prefix-cache 路径未触碰;新表仅咨询性且有界;折叠持久化语义未变(折叠本来就落盘,变的只是判决)。
  7. 是否改了设计方向:不涉及。在既有驱逐机制上加诊断诚实层;驱逐策略本身(LRU vs 按需逐出)仍留在 [dsh] A healthy 93%-compressed image session becomes permanently uncompressed by ordinary usage: quota → model switch → attribution loss → 413 → rewind → 3,455 dead refs → compress REFUSED forever (0.1.202) | 一个健康压缩率 93% 的图片会话被普通操作永久废掉:额度→换模型→丢归因→413→撤回→… #3918 的 owner 决策项,本 PR 正确地没有越界。
  8. 是否引入了新的配置:不涉及。只引用既有的 sessions.residentMaxBytes(env twin BILI_SESSION_RESIDENT_MAX_BYTES);config-surface guard 绿。

行为变更披露(旧 → 新 + 原因)

面 旧 新 原因
拒绝回执/日志(挤不进池的 case) 「下一轮模型请求恢复视图,别重试」 PERMANENT 明示 + 两个可行出口 原建议在该场景必然失效,继续承诺即误导(#3918 事故的 444 MiB 会话)
preflight 非确定性耗尽且已有折叠 502 retryable=false(终局) 502 retryable=true + 进展句 折叠已持久化,重试从更小基线继续,每轮有真实进展;零进展/确定性/上游路径判决不变
新增进展句措辞(我的修复合并前发现) 「~N tokens short of the window」 「~N tokens short of the target」 limit 在 #3450 completion-reserve 生效时是「窗口−预留」,称其为 window 会把 #3663 的混淆类带进全新字符串;target 是本子系统既有措辞(preflight.ts 的 futile-round detail)。我已在 PR 分支补 commit 0c7626724(单词,独立标注)

另:首个 head 8d85efe 红在 unused-exports gate(ResidentPressure 接口多余 export),已由并行会话的 af0956b5e 去掉 export 修好——接口现仅在 session.ts 内部被返回类型引用,无外部消费者,安全。

测试证据

  • 本地定向(非全量,纪律内):af0956b5e 上 7 个相关文件 36/36 绿(issue3918×2 新文件、issue3126、preflight-fail-fast、preflight-multi-range、issue3461、issue2189);0c7626724 上受影响文件 2/2 绿。
  • 新测试质量:两个方向都钉了(永久/瞬时、有进展/零进展),断言有牙(具体字符串、权重阈值、block 持久化、调用计数),端口走 listen(0),fixture 前后复位干净。
  • CI:af0956b5e 完整 core 矩阵全绿(6 test legs + 2 static legs + 全部 guard);0c7626724 的 core run 进行中(与 af0956b 的差异仅为上述一个词)。注:该分支上另有一次 labeled 触发的 skip-scoped run 显示 success 但 test legs 全 skipped——那是 ci.yml plan job 对非 ci:full 标签事件的正常行为,不构成证据,真正证据是 push 触发的 core run。

判定:可合并(等 0c7626724 的 core run 转绿即可;按纪律我不代合)。驱逐策略与快照压缩两项决策仍在 #3918 等 owner 拍板,与本 PR 正交。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 收尾确认: 最终 head 0c7626724 的 core 矩阵已全绿——6 个 test leg 全部真实执行且 success(0 skipped)、2 个 static-gates + 全部 guard 绿,该 head 上所有 check runs 无红无挂起。过程中一个 windows shard 的 runner 卡死(ci.yml 未设 timeout-minutes,卡住会无限占着合并门禁),已 cancel+rerun 解决;rerun 即上述全绿 run。

上一条八问结论不变:可合并,等人工合并。PR 分支最终三个 commit:两个修复 + 我补的措辞小修(window→target)。驱逐策略与快照压缩两项决策仍在 #3918 等拍板,与本 PR 正交。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 结论:当前 head 全绿,无需再推。 转发的失败是旧 head 8d85efe0b1 的 unused-exports 门;分支上已有修复提交 af0956b5e(该失败运行之后推入),我在最新 head 0c7626724 上逐项核对了全部 check runs:所有非 skip 的 check(含 unused-exports)均为 success。

门失败根因与修法:PR 在 src/session.ts:971 新增 export interface ResidentPressure,但没有任何模块按名字导入它——它的唯一跨模块角色是 residentPressure() 的推断返回类型(src/session.ts:983),所以 gate 判为 INTERNAL_ONLY。修复 = 去掉前导 export(接口变为模块私有),不需要 waiver。我另行 grep 了 src/、tests/、kernel/src、pi-subagents/src、scripts:除 src/session.ts 外零引用,修法成立。

结构化八问:

  1. 是什么问题:unused-exports 静态门拦截——新导出的类型没有任何具名消费者。
  2. 什么原因导致的:接口导出时其消费方只靠类型推断拿到它,从不按名字 import,导出即死面。
  3. 影响范围与严重程度:仅 CI 门禁层面,无运行时行为、无外部影响。
  4. 怎么修复的:去掉前导 export,类型保持模块内可见(编译期经推断照常跨模块工作),不加 waiver。
  5. 是否有回归问题:无——纯类型可见性收窄;head 0c7626724 上 ubuntu/windows × node 22/24 全量测试分片 + 全部静态门(test-import-graph、config-surface-guard、lane-guard、docs-sync 等)均绿。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

备注:分支相对 master 为 behind(master 已前进),GitHub 不因此阻止合并;所有检查在当前 head 通过,可交人工合并。

awork added 4 commits October 20, 2026 21:40
…3918)

The empty-view compress refusal (#3126) promised the view self-heals on the next model request. That promise holds only when the reloaded session survives between requests: releaseInFlight's discharge evicts any session whose live weight plus the other residents exceeds the byte budget, so a large image session ping-pongs out after every cycle and the identical refusal repeats forever - the incident's 444 MiB session under the 512 MiB default against an 87.5 MiB peer.

Stamp each eviction with the session's live weight (measurable only at that moment; a disk reload under-measures by exactly the transient mass) and export residentPressure(). When weight + other residents > budget, the receipt and the operator log name the permanent case and give the exits (close the peer / raise sessions.residentMaxBytes) instead of advising an impossible retry. The transient case keeps the exact original wording. The map is advisory-only, capped at 256 entries.
…#3918)

A preflight walk that exhausts its summarization budget AFTER committing real folds was reported 502 retryable=false - 'doomed' - although the folds persist in the session and the next attempt starts from a smaller baseline and continues the fold (the incident ran 64 effective folds, every round declared terminal). Non-deterministic exhaustion with compressedRanges > 0 now reports retryable=true and appends a progress note (ranges folded, tokens short of the window). Zero-progress exhaustion keeps today's terminal verdict and dead-end cooldown; deterministic exhaustion keeps its 413 path byte-identical.
The interface is only consumed as the inferred return type of residentPressure() across modules; no importer names it. Dropping the export satisfies the unused-exports CI gate without a waiver.
…t wall, not the window (#3918)

Review fix-up for the new ffDetail sentence: limit can be window minus
completion reservation (#3450), so naming the gap "short of the window"
would repeat the #3663 confusion class in a brand-new string. Uses the
subsystem's own term ("gap to the target", src/preflight.ts).
@ranxianglei

Copy link
Copy Markdown
Owner Author

Rebased onto current master (picks up #3958/#3948; zero conflicts, kernel dist was stale locally — rebuilt, tsc clean, resident-refusal + preflight-fail-fast suites 8/8). PR is mergeable on the rebased head.

@ranxianglei
ranxianglei force-pushed the 2026-10-20_resident-eviction-honest-refusal branch from 0c76267 to cafb493 Compare October 20, 2026 13:42
ranxianglei added a commit that referenced this pull request Oct 20, 2026
[PR] Batch-B integration: fold budget/eligibility — merge #3353 #3943 #3952 #3867 #2660 #3677 (#3916)
Zhishulo pushed a commit to Zhishulo/billion-context that referenced this pull request Oct 20, 2026
Zhishulo pushed a commit to Zhishulo/billion-context that referenced this pull request Oct 20, 2026
…estimate demotion cannot reopen oversized forwards (ranxianglei#3846)

Conflict resolution: kept both the ranxianglei#3918 progressContinues verdict (from ranxianglei#3943)
and the ranxianglei#3846 noteLocalRefusal persistence on status===413 — complementary:
status 413 fires only for deterministic exhaustion (!progressContinues).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Rebased head cafb49391 went red on 4 test shards after your rebase — root cause checked, not this PR's code. Fixed by merging current master into the branch: pushed ed40dea9c.

八问

  1. 是什么问题: rebase 后 CI 四个分片挂,两个不同的测试失败:issue3769-upgrade-compat(record hydrates before the upgrade turn)和 issue1839-ghost-denominator G3(overflow rejection passes through, 200 !== 400)。本 PR 自己的 [dsh] A healthy 93%-compressed image session becomes permanently uncompressed by ordinary usage: quota → model switch → attribution loss → 413 → rewind → 3,455 dead refs → compress REFUSED forever (0.1.202) | 一个健康压缩率 93% 的图片会话被普通操作永久废掉:额度→换模型→丢归因→413→撤回→… #3918 套件全绿。
  2. 什么原因导致的: 两处失败都来自 rebase 基点(74090ac)之后才修好的 master 侧问题——[Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769 的 pooled-envelope flake 由 [PR] fix: bare-id loadSync hydrates pooled envelopes without the unified index (master CI flake, #4014) #4015(765abe369)修复,任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 G3 的期望值由 [PR] Truncate at boundaries when a compression range spans protected messages rather than punching holes (#3953) | 压缩区间跨越受保护消息时在边界截断,不再挖洞 (#3953) #3986(901c62e5f)更新。PR 是基于一个稍旧的 master rebase 的,把这两个「当时在 master 上就红」的测试带进了 CI 窗口。与本 PR 的改动无关。
  3. 影响范围与严重程度: 仅这个 PR 的 CI 门禁;无运行时影响、无用户面影响。
  4. 怎么修复的: 把当前 master(bc4a3f8)以 merge commit 并入 PR 分支(不重写你的提交历史)。唯一一处文本冲突在 src/server.ts fail-fast 路径:两边在同一位置各插了一段代码,按执行顺序取并集([dsh] A healthy 93%-compressed image session becomes permanently uncompressed by ordinary usage: quota → model switch → attribution loss → 413 → rewind → 3,455 dead refs → compress REFUSED forever (0.1.202) | 一个健康压缩率 93% 的图片会话被普通操作永久废掉:额度→换模型→丢归因→413→撤回→… #3918 的 progressContinues 判定在前,[Bug][preflight] Local 413 is forgotten when the baseline becomes an estimate, reopening oversized probes #3846 的 noteLocalRefusal 持久化在后),语义不变。
  5. 是否有回归问题: 冲突区域两侧逻辑独立、顺序保持原样;定向验证 13/13 全过——issue3769-upgrade-compat 1/1(原失败项)、issue1839-ghost-denominator 3/3(原失败项)、issue3918-resident-eviction-refusal 3/3、issue3918-preflight-progress-verdict 2/2、issue3846-local-refusal-evidence 4/4(覆盖冲突触碰的代码路径);build + typecheck 干净。全量裁决以远程 CI 在 ed40dea9c 上的结果为准。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。
  8. 是否引入了新的配置: 无。

结论: 分支已更新到 ed40dea9c(含全部当前 master),等远程 CI 转绿即可人工合并。

@ranxianglei
ranxianglei merged commit 2c8983c into master Oct 21, 2026
21 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.710-master.2c8983c (rolling master tag).

npm install -g billion-context@0.0.710-master.2c8983c  # 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.

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 p1 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant