Skip to content

[PR] fix(fork-adoption): inherit folds deactivated by the source's last short view - #5979

Closed
ranxianglei wants to merge 0 commit into
masterfrom
2026-11-09_fork-adoption-short-view-folds
Closed

ranxianglei wants to merge 0 commit into
masterfrom
2026-11-09_fork-adoption-short-view-folds

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

No description provided.

@ranxianglei ranxianglei changed the title fix(fork-adoption): inherit folds deactivated by the source's last short view [PR] fix(fork-adoption): inherit folds deactivated by the source's last short view Nov 8, 2026
@ranxianglei ranxianglei added bug Something isn't working p1 scope/kernel labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-09_fork-adoption-short-view-folds (60dba47)

Latest build — install this exact version

npm install -g billion-context@0.0.8694-pr.5979.6bdb2f9

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
60dba47 billion-context@0.0.8694-pr.5979.6bdb2f9 build
3f07752 billion-context@0.0.8693-pr.5979.a9d51c0 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5979.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)

查重:重复 —— PR #5970 与 #5979 是同一 issue #5968 的平行 PR(同症状+同机制+同修法)

标签:bug / dsh / scope/kernel / p1(缺陷类;源 issue 标注 dsh 客户端语境;fork 继承属会话核心逻辑;继承丢失→零折叠子会话,按 2026-10-19 口径为 p1)。

实时状态(已 live 核实,非旧评论记忆):

中间审核结论(机制层已验证通过):

  • 对照 kernel/src/sync.ts:141–172:块失活只有三种成因——consumed / expanded / 瞬态视图缺席。本修复恰好在「span 对子会话完整」时复活第三类,等价于一次正常全量重放的自然结果;两类有意停用保留为排除项。机制正确且穷尽;
  • 不改 kernel/、无新配置面、无 wire 形状变化;straddled 仅用于日志(语义从「active 但不完整」变为「eligible 但不完整」,无功能影响);
  • 四个调用点(匿名 fork / resume 继承 / derived fork / 启动对账)一致受益;adoption 的 id 判定比 syncBlocks 的在场判定更严格(无 summary/ledgerSeq 捷径),方向保守,只会少采纳不会错采纳。

下一步:把 #5979 的 3 个独有测试(深拷贝隔离、straddled 计数、refs 携带)移植进 #5970 分支(独立标注 commit),等 CI 出结果后给正式八问审核结论。

@ranxianglei ranxianglei added the dsh label Nov 8, 2026
ranxianglei pushed a commit to zouzh22/billion-context that referenced this pull request Nov 8, 2026
…-carry regressions

Ported from parallel PR ranxianglei#5979 (same fix for ranxianglei#5968; being consolidated into this PR): three unit cases not covered by this branch - applyForkAdoption deep-copy isolation (mutating the adopted child never leaks into the source session), the straddled counter for partial spans while the block is transiently inactive in the source, and covered-ref carry into the child numbering.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

审核结论(八问)——机制正确、可合入;但本 PR 与 #5970 平行重复,已完成合并协调:建议 owner 以 duplicate 关闭本 PR,改走 #5970(agent 无关闭权,等 owner 操作)。

  1. 是什么问题:来源会话最后一次请求若是短/无关视图,dsh 宿主重发完整原文做 fork/resume 时,继承不到任何已保存的压缩折叠——子会话变成「零折叠」,上下文从原始消息重新膨胀。
  2. 什么原因导致的:块失活(active=false)有两个成因被混为一谈——①有意停用(用户解压 expanded / 被高层块消费 consumed)与②瞬态视图缺席(短视图下 syncBlocks 找不到 span)。planForkAdoption 用 if (!b.active) continue 把 active 当「保留资格」判据,而模块头注释(src/fork-adoption.ts:23–33)自己声明的契约是集合语义(按 incoming id 判定),代码违反了自己的契约。根因在判定层(资格判据选错字段),不在数据层。
  3. 影响范围与严重程度:所有 fork/resume/derived-fork/启动对账四条继承路径,凡「来源最后一次视图 ≠ 完整 span」均触发(dsh persona/子代理场景常见)。严重度 p1:折叠丢失 = 会话压缩成果实质失效,子会话上下文永久回膨胀,不是体验瑕疵。
  4. 怎么修复的:判据从 active 换成三条件——非 expanded ∧ 非 consumed(未被任何块的 directBlockIds 引用)∧ span(effectiveMessageIds ∪ directBlockIds)完整落在子会话 incoming id 集合内。顶层采纳块以 ACTIVE 拷入子会话,tier 后代保持 INACTIVE(消费语义保留);块经 structuredClone 深拷贝,来源会话零改动;效果等价于一次正常全量重放的自然结果。
  5. 是否有回归问题:对照 kernel/src/sync.ts:141–172 逐一核过——失活只有 consumed / expanded / 瞬态缺席三种成因,前两类保留为排除项、第三类恰在 span 完整时复活,机制穷尽且方向正确。既有行为清点:blocks-disabled 门(includeBlocks=false)不变;adoptedActive===0→全新开始+血缘链路的分支逻辑不变(现在只是更少误触发);straddled 仅用于日志(:378/:578/:591),语义从「active 但不完整」变为「eligible 但不完整」无功能影响;adoption 的在场判定比 syncBlocks stillPresent 更严格(无 summaryMessageId/ledgerSeq 捷径)→ 只会少采纳、不会错采纳,保守方向;[PR] fix: recover retained compression blocks against fork replay #5970 的第 1 个测试直接断言了「fork 恢复结果 == 普通全量重放结果」的平价性。未破坏:wire 形状、消息 id/ref 编号、存储格式、kernel/(本 PR 不动 kernel)、配置面。
  6. 是否破坏缓存:不涉及。缓存/重试/增量游标/去重键均未触碰;ref 携带是既有行为(本次被测试钉住,不是新行为)。
  7. 是否改了设计方向:没有。是把实现拉回到文档已声明的契约上;[PR] fix: recover retained compression blocks against fork replay #5970 还同步更新了模块 doc 注释(en/zh technical-notes 各 +4 行,符合 §7.3 双语同步要求)。
  8. 是否引入新配置:无。

测试有效性:真测试。#5970 原有 2 个单测(恢复路径断言 adoptedActive/blocks[0].active/adoptedTokens + 来源状态 deepEqual 不可变;排除矩阵覆盖 expanded/consumed/missing/blocks-disabled 负向)+ CCR 真实压缩 fixture 参数化 shortView true/false 循环(该 bug 复发即红);我移植进来的 3 个补深拷贝隔离(applyForkAdoption 端到端)、straddled 计数、refs 携带缺口。负向断言齐全(Gate Test Discipline 双向)。

diff 整洁度:#5970 = 5 文件 +78/−6(base 82e2d53;已核实 master 侧自基线起未触碰这 5 个文件,预期无冲突)+ 我追加的 1 个标注 commit(1 文件 +35,纯测试移植,commit message 注明来源)。本 PR(#5979)自身 diff 干净但 body 为空(Closes #5968 只在 commit message,squash 不会自动关 issue)——并入 #5970 的理由之一。

实时状态(live 核实,18:11Z 镜像缓存):#5979 CI 全绿(14 success / 16 skipped / 0 failed @ 60dba47);#5970 在新 head b44e471 上重跑中(6 success / 0 failed / 14 pending);两 PR base 均为当前 master 848f59b 或其后代基线,无冲突预期。

建议动作(owner):

  1. 关闭本 PR [PR] fix(fork-adoption): inherit folds deactivated by the source's last short view #5979(注明 duplicate of [PR] fix: recover retained compression blocks against fork replay #5970:同症状+同机制+同修法,[PR] fix: recover retained compression blocks against fork replay #5970 创建更早且含文档/CCR 回归;其独有 3 个单测已带署名移植进 [PR] fix: recover retained compression blocks against fork replay #5970);
  2. [PR] fix: recover retained compression blocks against fork replay #5970:CI 绿后 undraft → 人工合并(合并权在 owner)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收工状态更新(全部 live 核实):

@ranxianglei
ranxianglei force-pushed the 2026-11-09_fork-adoption-short-view-folds branch from 60dba47 to 4dea18e Compare November 10, 2026 07:00
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