Repository navigation
[PR] fix: compaction deadlock caused by restamp after restart — the re-granted ref is the current number, should not be rejec | fix: 重启后 restamp 导致的压缩死锁——被重新授予的 ref 是现行号,不该拒 (#4797) - #4799
Conversation
…rseded numbers are live refs again (#4797) The one-time cold-load re-stamp targets seq+1, which overlaps the old counter space, so most superseded numbers become live refs of DIFFERENT messages again. supersededRefRejection refused every cited superseded number, so acp_status kept advertising ranges the submit gate refused forever — compression permanently dead on sessions with ref/seq drift after a host restart. - stream: refuse only superseded numbers with NO current owner (genuinely stale); re-granted ones pass and resolve to their current owner downstream. - persist: register vacated-and-unregranted numbers in state.deadRefs (#3302 discipline) so the suggestion engine splits groups at the holes and acp_status names them in DEAD REFS. Test: tests/issue4797-restamp-suggested-refs.test.ts (S-A..S-E, incl. a dual-world reproduction of the production deadlock on a cold-loaded store). Behavior change (disclosed): compress calls citing re-granted (currently owned) refs are no longer refused; restamp now appends vacated numbers to the persisted deadRefs list (one-time, bounded by row count).
(ai: vllm-qwen/qwen3.8-27b) 结论先行:修复正确、根因定位准确、测试有牙(红→绿已本地验证)、无无意回归。建议可合;唯一提醒是本改动落在 ref 引用安全面(§7.4 message-ref/id 域),按仓库规则需人工点头,不走自动合。 查重:不重复——#4797 独有此 restamp 死锁;近期无其他在途 PR 修同一机制(#4316 PR3/3 是引入方,本 PR 是其后续修正)。 八问
行为变更披露(owner policy 2026-09-22 第 4 条):compress 拒绝面收窄——旧行为=引用任何 superseded 号即拒;新行为=仅拒无主 superseded 号。被拒集合严格变小,原被拒的现行号引用现在会执行折叠(正是修复目的)。残留风险(低,PR 已披露):重启前冻结历史里的旧号引用若恰好落在被复用的号上,会折叠到该号的当前主人(错段但无损,decompress 可恢复);概率远低于原死锁,p1 权衡下接受。 验证证据:本地 npm ci + build kernel 后,定向 8 文件 41/41 绿;把 src/stream.ts + src/persist.ts 回退到 base(e22a57b) 再跑新测试 → S-A/S-C/S-E 红(证明测试真有牙、能抓原 bug),恢复后全绿。typecheck 与全量回归交 CI。 判定:代码正确、根因到位、测试合格、行为变更已披露、diff 干净(3 文件 +219/-8,无无关改动)。可合;因触及 ref 引用安全面(§7.4 message-ref/id 域),建议人工确认后再合,非自动合。 |
|
(ai: vllm-qwen/qwen3.8-27b) duplicate of #4807 — 同症状、同机制:#4807 修的是同一个碰撞带(restamp 的 seq+1 目标号与旧计数器空间重叠,superseded 键同时是现行活号),且是严格超集——kernel 层剪枝保护所有 superseded 消费方(本 PR 只收窄了守卫一个消费方)、对真旧号引用做保义翻译而非拒绝、另覆盖 clone 丢 独立审核结论(含我在 #4807 分支上补的一个 deadRefs 有机 tombstone 缺口修复 b72c291)已发到 #4797 线程。关闭与否等你定。 |
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7328-pr.4799.f8846e7This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4799.tgz
npm install -g packageInstall instructions are refreshed on each push. |
… declaration for lockfile-only churn kernel/package-lock.json is generated state, not kernel source. Agents' test prep (npm install inside kernel/, sweep-bot merges of stale lockfiles) churns it without any intent to change the kernel — 8 PRs (ranxianglei#4823 ranxianglei#4808 ranxianglei#4802 ranxianglei#4800 ranxianglei#4799 ranxianglei#4794 ranxianglei#4790 ranxianglei#4785) tripped the human gate on lockfile-only diffs, and the previous stopgap (bots appending kernel-change: declarations to PR bodies) was correctly rejected by the owner as bypassing the approval step. The human gate exists to protect kernel SOURCE. Rule 1 now ignores kernel/package-lock.json when deciding whether a PR 'touches kernel/'; real source/build-config changes still require the declaration + owner approval, and lockfile CONSISTENCY stays enforced by the separate lock-sync job (which fails on genuine drift — the ranxianglei#4725 merge red being today's live proof).
(ai: vllm-qwen/qwen3.8-27b) 又收到一次冲突唤醒(同一状态的第 3 轮)——结论、证据、待办全部不变,详见楼 12 / 楼 15。本轮核验:PR 分支 head 仍 为避免每轮唤醒烧一次调度,本车道在此明确停发节奏:#4865 拍板前,冲突唤醒不再逐轮回帖——决策条目 #4865(p1)是唯一跟踪点,该条已有独立会话在维护状态,标签 superseded 已挂在本题。我也刻意不动分支:任何 rebase/force-push 都是在替 owner 做处置决定(会把「关闭 vs 保留」的选择题变成既定事实),这不属于冲突修复车道的权限。 唯一需要的动作不变:owner 在 #4865 选 A → 直接关闭本 PR,冲突标记与唤醒循环随之终止。若状态发生变化(分支有新提交 / #4807 相关回滚 / owner 指示 B 或 C),本车道会重新介入。 |
# Conflicts: # src/stream.ts
(ai: vllm-qwen/qwen3.8-27b) 已合并 origin/master 并推送(head 23f4626):冲突只在 src/stream.ts——master 上 a07090c 已经用更完整的方案修了同一个 #4797(kernel 侧 restamp map 剪枝 + guard 改为 live-first 解析/翻译),本 PR 的 stream.ts/persist.ts 改动被其完全覆盖,故两处均取 master 版本;本 PR 保留的唯一增量是冷启动死锁形状的回归测试(tests/issue4797-restamp-suggested-refs.test.ts,已适配现行 guard API,本地 typecheck + 定向测试通过)。push 后状态:冲突已解、mergeable,CI 运行中。 |
[bot] 🏷 收工汇总:已把 origin/master 合并进 PR 分支并推送(head 23f4626)。唯一冲突在 src/stream.ts——master 的 a07090c 已用更完整方案修了同一个 #4797(kernel restamp map 剪枝 + guard live-first 翻译),本 PR 的 stream.ts/persist.ts 改动被其覆盖,故取 master 版本;PR 保留的唯一增量是冷启动死锁形状回归测试(已适配现行 guard API,本地 typecheck + 定向测试全绿)。push 后 GitHub 状态:mergeable=true,CI 运行中零失败。后续守卫再次报 conflict 经两次复核均为滞后误读——上游无冲突(master 未动、分支已含其全部提交),等 CI 收尾即转 clean。另:a07090c06 两个 kernel hunk 疑似未进 master,已在 #4797 报告待 owner 定夺。 |
(ai: vllm-qwen/qwen3.8-27b)
Closes #4797
根因(与 issue 猜测不同)
不是「某一面没迁移」——restamp 之后所有面读的都是同一份重排后的 map。真因:restamp 的目标号 seq+1 与旧计数器编号空间大面积重叠,于是大部分 superseded 键(旧号)同时是重排后的现行 byRaw 值(新主人)。守卫
supersededRefRejection的谓词「cited ref ∈ superseded」因此把现行号判成 stale;而建议面(recommend.ts 的byRaw[msg.id])吐的恰恰就是这些现行号 → status 建议什么就被拒什么,死循环。生产数据印证:kept=185/restamped=1421/blocked=16 的会话里,seq+1 空间与旧计数器空间都稠密在 [1,~1622],重叠是结构性的,漂移越重命中率越高。
修法(两个面,同一机制)
superseded.has(ref) && byRef[ref] === undefined。只有无当前主人的 superseded 号才算真 stale(它的旧标签指向空气);被重新授予的现行号放行,下游按当前主人解析。After model switch / client-side history rewrite, all message identities (content hashes) are replaced: ACP numbers re-m | 切模型/客户端重写历史后,消息身份(内容哈希)全部更换:acp 编号重铸、折叠覆盖大规模重挂、死 ref、churn 区临时膨胀重折 #4316 PR3/3 的原始意图(拒绝指向空气的旧引用、防错段折叠)完整保留——S-B/S-C 钉住。state.deadRefs(沿用 [compress] Still present after #156: the LLM also gets stuck on an invalid end ref; #370's same-parameter short-circuit fails to prevent it. | [compress] #156 之后仍存在:大模型同样卡在无效 end ref,#370 的同参数短路挡不住 #3302 tombstone 纪律,数值升序、空⇒undefined)。效果:建议引擎(markNoMergeAcrossDeadHoles)在洞处分段,不再建议跨洞 span;acp_status 的 DEAD REFS 段点名这些号;stale 引用分类一致。被重新授予的号不登记(有主即可无歧义解析)。行为变更披露(owner policy 2026-09-22 第 4 条)
state.deadRefs一次性追加 vacated 无主号(有界 ≤ 行数),后续 save 落盘。不改变 deadRefs 既有语义(唯一/升序/空⇒undefined)。测试
新增
tests/issue4797-restamp-suggested-refs.test.ts(S-A~S-E):守卫语义四象限(复用号放行/无主号仍拒/混合 span 一票否决/新会话不受影响)+ 全链路冷加载复现(SessionStore 统一存储 → restamp → 双世界对照:pre-fix 世界「每个建议 span 都被 gate 拒」= 生产死锁的进程内复现;post-fix 世界「每个建议 span 都可提交」+ acp-status 同款排除后不变量)。本地定向:本文件 + seq-ledger-pr3/seq-ledger/issue3302/dead-ref-range-filter/issue4164/issue3204/compaction-archive 共 41 项全绿;typecheck 干净(rebase 到 master e22a57b 后复验)。全量回归交 CI。
未动 kernel/(无需 kernel-change);未动配置面。