Skip to content

[PR] fix: acp_status after eviction — serve the stored view, or say the view is unreadable (#4975) - #5284

Open
ranxianglei wants to merge 3 commits into
masterfrom
2026-10-30_status-view-recovery
Open

ranxianglei wants to merge 3 commits into
masterfrom
2026-10-30_status-view-recovery

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4975

What this fixes

After a resident-pool eviction + cold-load, an ordinary session retains refs/blocks but has NO readable message view (transient is dropped on eviction; pluginSnapshot persists for fork sessions only). Both acp_status entry points read only that in-memory view, so the panel/tool reported "0 tool / 0 text" + max-compressible 0 — indistinguishable from a fresh session — while upstream kept billing the full history (the incident's 6.6× billed/est divergence). The #3982 store-recovery net existed only in the compress lane.

Changes

  1. ACP tool endpoint (handlePluginTool, src/plugin.ts): when tool === "acp_status" and the live view is empty while the session retains refs/blocks, serve the unified store's raw tail rows (peekStoredTailView) as the status view — the same net as compress-from-store (compress-from-store: evicted sessions compress against the unified-store view instead of refusing forever (#3918 P4 root fix) #3982), gated so every other tool keeps its exact current path.
  2. /acp panel (handlePluginStatus, src/plugin.ts): same recovery before the nudge recompute; unprunedTokens/applyView follow the recovered view (the raw client view IS the apply class, [Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报 #2627/[Bug] recommend/apply 对同一区间的 turn-integrity 判定永久不一致:acp_status 反复推荐的区间被 apply 侧整段拒绝(0.1.196,Range would split N turn(s) at the protected-zone boundary) #3236).
  3. Unreadable residual state (store absent / legacy mode / corrupt rows): explicit markers instead of silent zeros —
    • tool: ⚠️ LIVE MESSAGE VIEW UNAVAILABLE — … retains N ref(s) and M active block(s) … Any model request restores the view (#3126) (src/acp-status.ts);
    • panel: ⚠️ LIVE VIEW UNREADABLE: … pre-footer line.
  4. Misleading notes suppressed exactly when the view is unavailable: the 长会话中token用量被系统性低估(CJK 文本),导致agent误判上下文压力、进入「小收益折叠」循环 #2366 CJK/tokenizer divergence note (its attribution is wrong there — the divergence IS the missing history) and the PRESSURE NOTE ("little left to fold" — its maxPending=0 premise is uncomputable with no view).

Behavior changes (old → new)

surface old new
acp_status (tool), evicted session with readable store zeros + max-compressible 0 real breakdown/ranges from the stored view (byte-identical to the resident-session receipt in tests)
acp_status (tool), no readable store copy zeros read as "nothing to compress" explicit ⚠️ marker naming retained refs/blocks + the #3126 recovery path
#2366 ratio note always blamed tokenizer/CJK gap at ≥1.5× suppressed in the view-unavailable case (the marker explains instead)
PRESSURE NOTE could fire on the artifact maxPending=0 suppressed in the view-unavailable case
/acp panel, evicted session no nudge section, zeros nudge from the stored view when recoverable; ⚠️ pre-footer line otherwise
all other tools on the plugin endpoint unchanged unchanged (deliberate scoping — compress already self-recovers via #3982)
fresh sessions (no refs/blocks) baseline output byte-identical (the gate requires retained state)

No kernel/, config-surface, wire, persistence-format or version changes. The eviction policy itself is untouched — the ping-pong frequency question stays in #5111's decision domain.

Tests

tests/issue4975-status-view-recovery.test.ts (8 tests, both directions per #3617): marker + note suppression with retained refs; fresh-session negative gate; #2366 note preserved on a live view; panel recovered-vs-resident parity (modulo the wall-clock stamp); panel unreadable + null ranges; tool recovered-vs-resident byte-identity; tool unreadable through the endpoint; tool fresh-session negative. Targeted local runs green: issue2366, compress-from-store, issue3126, issue3918×2, issue2029, issue1875, issue3204. Full-suite verdict = CI on this head.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-30_status-view-recovery (220b865)

Latest build — install this exact version

npm install -g billion-context@0.0.8931-pr.5284.42d8cfb

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
220b865 billion-context@0.0.8931-pr.5284.42d8cfb build
4f95fba billion-context@0.0.7296-pr.5284.0c0174c build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5284.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: acp_status after eviction — serve the stored view, or say the view is unreadable (#4975) [PR] fix: acp_status after eviction — serve the stored view, or say the view is unreadable (#4975) Oct 31, 2026
…port union

Both branches edited the same persist.js import line: this PR added
peekStoredTailView (the #4975 eviction fix), master added
CORRUPT_SIBLING_CAP/pruneCorruptSiblings/kvStore. Resolved as the union of
both specifier sets; all six symbols verified present in persist.ts and used
in plugin.ts.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Merge conflict on PR #5284 (fix #4975) — resolved & pushed. This run was the conflict-resolution lane (attempt 1/3). I merged origin/master into the PR head branch 2026-10-30_status-view-recovery, resolved the single textual conflict, and pushed a fast-forward (no force-push — the remote head hadn't moved, no concurrent writer). Pushed: 4f95fbac7a..220b8656a1.

What actually conflicted: one line only — src/plugin.ts's ./persist.js import. The PR added peekStoredTailView (the #4975 eviction-recovery symbol) to that import; master independently added CORRUPT_SIBLING_CAP / pruneCorruptSiblings / kvStore to the same line. Both sides touched the identical line → git couldn't auto-merge it. I took the union of both specifier sets and verified all six symbols are exported by the post-merge persist.ts and all six are actually used in plugin.ts (nothing extra, nothing missing). Every other file auto-merged from master. Chose merge over rebase per this repo's established conflict-handling convention and to avoid force-pushing into a branch other agents may touch concurrently.

Verified live at the git level (the mirror's upstream-checks cache was still stale — old sha / behind, fetched 2026-10-31 — so I did not read state from it): git merge-tree --write-tree origin/master HEAD reports zero conflicts between current master (4dea18eabf) and the new PR head (220b8656a1), and origin/2026-10-30_status-view-recovery == my pushed commit. GitHub will re-evaluate mergeable state and re-trigger CI on the new head automatically; the fresh CI suite has not finished yet, so I am not asserting CI green here — only that the blocking conflict is cleared. If the fresh run surfaces a real code red (not an inherited master red), that is out of scope for this mechanical-conflict lane and belongs to a separate fix.


八问(中文,供人工评审)

  1. 是什么问题:PR [PR] fix: acp_status after eviction — serve the stored view, or say the view is unreadable (#4975) #5284([bug] DSH native plugin 0.1.208: eviction/cold-load 后 acp_status 显示 0 tool/0 text,但近期 billed input 为 173069 #4975 acp_status 驱逐后回退存储视图的修复)与目标分支 master 合并冲突(merge state = dirty),PR 卡住无法合入。
  2. 什么原因导致的:PR 分支与 master 各自独立改写了 src/plugin.ts 同一行对 ./persist.js 的 import——PR 侧新增 peekStoredTailView,master 侧在同一行新增 CORRUPT_SIBLING_CAP/pruneCorruptSiblings/kvStore。两边都动同一行 → 文本冲突,git 无法自动合并。
  3. 影响范围与严重程度:仅阻塞该 PR 合入,不影响任何线上/已发布功能;不修则 PR 一直卡在 dirty 状态合不进去。属「发布流程被卡」级别,非用户可见缺陷。
  4. 怎么修复的:按本仓既有惯例把 origin/master 合进 PR 头(merge 而非 rebase——免 force-push、对并发 agent 更安全),冲突行取两侧的并集保留全部六个符号,其余文件由 git 自动合并;push 为 fast-forward(远端未动、无并发写入)。
  5. 是否有回归问题:无。我手动解的仅一行 import 并集,已逐一核验六个符号在 post-merge persist.ts 均有导出、在 plugin.ts 均被使用;PR 自身只动 acp-status.ts/plugin.ts/新测试文件、未碰 persist.ts(peekStoredTailView 本就存在于 master);git merge-tree 实测 master × 新 PR 头零冲突。高危模式逐项过:无语义漂移、无 fail-fast→吞错、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及。纯 import 合并,不触及任何缓存/重试/增量游标/去重键逻辑。
  7. 是否改了设计方向:不涉及。纯机械性冲突消解,无架构/边界/数据流转向。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:阻塞性合并冲突已解除并推送(fast-forward,无需 force-push),git merge-tree 实测对当前 master 干净可合;本次交付完成,待 CI 在新 head 上重跑 + owner 合入。

@ranxianglei

Copy link
Copy Markdown
Owner Author

8问

@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)

APPROVE —— 干净、边界清晰的真实可见性缺陷修复。已对照原 issue #4975、完整 diff(3 文件,+350/-9)、全部三个 peekStoredTailView 调用点、以及所有 handleAcpStatus 调用方逐一核过。CI 在本 head(220b8656a)绿:30 checks,0 failed/pending。PR 落后 master 4 个 commit(#5983/#5974,preflight/futility 域),但这 4 个 commit 不触碰本 PR 任一文件,无跨 base 语义冲突风险。

它做了什么:resident 池驱逐 + 冷加载后,普通会话保留了 refs/blocks,但内存里的消息视图丢了(transient 被丢;pluginSnapshot 只为 fork 会话持久化)。两个 acp_status 入口都只读那个空视图,于是报「0 tool / 0 text」+ 最大可压 0——和一个全新会话一模一样——而上游仍在按完整历史计费(事故里 billed 173069 vs est 26239,6.6×)。修复在 live 视图为空但 refs/blocks 尚存时,从统一存储窄读原始尾行(peekStoredTailView)作为状态视图——和 compress-from-store(#3982)同一道网;store 读不出可读副本时,给出显式「视图不可用/不可读」标记(点名保留的 refs/blocks 数 + #3126 恢复路径),不再静默报零;并恰好在视图不可用时抑制两条前提无法计算了的注记(#2366 CJK/tokenizer 归因、PRESSURE NOTE)。以 acp_status + 空视图 + 保留状态为门控,其它工具与全新会话输出逐字节不变。

为什么正确(逐项核过):

  • 恢复路径镜像 #3982 的 recoverEvictedView 网;peekStoredTailView(src/persist.ts:4363)全有全无(任何一行不可解析 / 零行 / 存储禁用都返回 null,绝不给半份视图),内部吞错安全。
  • 覆盖所有 handleAcpStatus 调用方:插件工具路径在出面前先恢复;proxy 模式路径(stream.ts / loop/core.ts)在一轮内带 live 客户端视图运行,标记不会误触发;fork 会话保留 pluginSnapshot(跳过恢复);全新会话无 refs/blocks 被门控排除。
  • compressMessages 重构对非 acp_status 工具行为保持(初值相同);只有 acp_status 遇空视图时分流。
  • 测试按 #3617 钉双向:标记出示 / 恢复后与 resident 逐字节一致;全新会话负例;live 视图会话保留 #2366 CJK 注记(钉住不回归);断言与实现字符串逐字对齐,真能抓住回归。
  • 无 kernel/、config-surface、wire/message-shape、persistence-format、version 变更;驱逐策略本身未动(ping-pong 频率留在 #5111)。行为变更已在 PR 表格里 old→new 披露。

八问(中文):

  1. 是什么问题:resident 池驱逐 + 冷加载后,普通会话保留了 refs/blocks 但内存消息视图丢了;两个 acp_status 入口只读这个空视图,报「0 tool / 0 text」+ 最大可压 0——和全新会话无法区分——而上游仍按完整历史计费(事故:173069 vs 26239,6.6×)。
  2. 什么原因导致:驱逐丢掉 transient 视图、冷加载只重建已持久化的 ledger/blocks;pluginSnapshot 仅为 fork 会话持久化,所以普通被驱逐会话没有任何可读视图;两个 acp_status 入口都只读内存视图(#3982 的 store 恢复网此前只在 compress 车道有)。
  3. 影响范围与严重程度:影响 DSH 原生插件(及任何走插件端点)的长会话在两次请求间被 resident 池驱逐的用户。严重度 p2——状态面误导 agent 以为没东西可压,从而不去折叠一个仍在线、仍在计费的活会话;属可见性/正确性缺陷,非数据丢失,下一轮模型请求即恢复。
  4. 怎么修复的:桥接 compress 车道已有的那道网(#3982)——live 视图为空但 refs/blocks 尚存时,从统一存储窄读原始尾行(peekStoredTailView)作为状态视图;store 读不出可读副本时给显式「视图不可用/不可读」标记(点名保留 refs/blocks 数 + #3126 恢复路径),不再静默报零;并恰好在视图不可用时抑制两条前提无法计算了的注记(#2366 CJK 归因、PRESSURE NOTE)。以 acp_status + 空视图 + 保留状态为门,其它工具与全新会话输出逐字节不变。
  5. 是否有回归问题:无。逐一核过既有行为——全新会话(无 refs/blocks)因门控逐字节不变;fork 会话(pluginSnapshot 非空)不走恢复不受影响;插件端点上其它工具(recovery 门控在 tool==="acp_status")路径不变;live 视图会话保留 #2366 CJK 注记(测试钉住不回归);proxy 模式 acp_status 在一轮内带 live 视图运行,标记不会误触发;peekStoredTailView 全有全无且吞错安全。高危模式(fail-fast 变吞错、阈值/时序/输出格式漂移)逐项过,除披露的标记外无漂移。
  6. 是否破坏缓存:否——对统一存储只读 peek,不动任何缓存/重试/增量游标/去重键;驱逐策略本身未动。
  7. 是否改了设计方向:无架构转向——把既有的 #3982 store 恢复网复用到新的消费方(状态面);刻意收窄,compress 自恢复与其它工具保持原样。
  8. 是否引入新配置:无——没有新增 env/config/旋钮/默认值。

判定:可合(APPROVE)。CI 绿 + 双端点双向测试钉住 + 无内核/配置/wire/版本变更。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

完整 review(含逐项正确性核对)已提交到本 PR 的 review 区。判定:可合(APPROVE)。八问如下:

  1. 是什么问题:驱逐+冷加载后普通会话保留了 refs/blocks 但内存消息视图丢了,两个 acp_status 入口只读空视图报「0/0」——与全新会话无法区分,而上游仍按全量历史计费(事故 173069 vs 26239,6.6×)。
  2. 什么原因导致:驱逐丢 transient 视图、冷加载只重建 ledger/blocks;pluginSnapshot 仅为 fork 会话持久化,普通被驱逐会话无任何可读视图;两个入口都只读内存视图(compress-from-store: evicted sessions compress against the unified-store view instead of refusing forever (#3918 P4 root fix) #3982 store 恢复网此前只在 compress 车道)。
  3. 影响范围与严重程度:DSH 原生插件长会话在两次请求间被 resident 池驱逐的用户;p2——状态面误导 agent 以为没东西可压、不去折叠仍在计费的活会话;可见性/正确性缺陷非数据丢失,下一轮模型请求即恢复。
  4. 怎么修复的:桥接 compress 车道已有的 compress-from-store: evicted sessions compress against the unified-store view instead of refusing forever (#3918 P4 root fix) #3982 那道网——live 视图为空但 refs/blocks 尚存时从统一存储窄读原始尾行(peekStoredTailView)作状态视图;读不出可读副本时给显式「视图不可用」标记(点名 refs/blocks 数+[bug] 大会话 compress 持续失败:ctx has 0 message(s) 时所有 ref 被判悬空(cannot-anchor),报错归因误导 #3126 恢复路径),不再静默报零;并恰好在视图不可用时抑制两条前提算不了的注记(长会话中token用量被系统性低估(CJK 文本),导致agent误判上下文压力、进入「小收益折叠」循环 #2366 CJK 归因、PRESSURE NOTE)。以 acp_status+空视图+保留状态为门,其它工具与全新会话逐字节不变。
  5. 是否有回归问题:无。全新会话/fork 会话/其它工具/live 视图会话/proxy 模式逐项核过均不受影响;高危模式(fail-fast→吞错、阈值/时序/输出格式漂移)除披露标记外无漂移。
  6. 是否破坏缓存:否——对统一存储只读 peek,不动缓存/重试/游标/去重键;驱逐策略未动。
  7. 是否改了设计方向:无架构转向——复用既有 compress-from-store: evicted sessions compress against the unified-store view instead of refusing forever (#3918 P4 root fix) #3982 恢复网到新消费方(状态面),刻意收窄。
  8. 是否引入新配置:无。

CI 绿(30 checks,0 失败);PR 落后 master 4 commit(#5983/#5974 preflight 域)但不触碰本 PR 文件,无跨 base 冲突。无人工决策项、无内核变更,可直接合。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) ✅ review-worker-r1 完成:PR #5284 端到端审毕,判定可合(APPROVE)。完整 review(含逐项正确性核对 + 八问)见本 PR review 区评论与上一条回复;无顺手修项、无人工决策项、无内核/配置/wire/版本变更;CI 绿 30/30,待 owner 合入。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] DSH native plugin 0.1.208: eviction/cold-load 后 acp_status 显示 0 tool/0 text,但近期 billed input 为 173069

1 participant