Skip to content

[PR] fix(session): migrate tag changes onto continuing derived-persona lanes instead of minting siblings (#6114) - #6124

Open
ranxianglei wants to merge 2 commits into
masterfrom
2026-11-10_persona-lane-tag-change-continuation
Open

ranxianglei wants to merge 2 commits into
masterfrom
2026-11-10_persona-lane-tag-change-continuation

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #6114

What

A conversation riding a derived-persona lane (<id>|sub:<fp(tag)>[:<fp(disc)>]) forked a NEW sibling lane on every system-text change — even when the incoming history was a strict byte-level continuation of the lane. Root cause: the tag-change ladder in src/session-resolve.ts reads skeletons.get(rawId) only; every continuation rung judges the RAW skeleton, while the lane's own skeleton (recorded at fork exit, grown on every later request) was never consulted back. A host upgrade that rewrites the system prompt therefore re-keyed the whole conversation onto an empty sibling and orphaned the lane's fold blocks.

Two field triggers, one mechanism:

  1. Host update ([Bug][session] 0.1.213: a conversation on a derived-persona lane forks a new sibling lane on every system-text change, orphaning its folds #6114, @Maziar123): ~2400-message omp session (~8.5MB text, 9 active fold blocks keeping input ~126–130K tok); host update changed the system text 50.4KB→46.5KB; the next request resolved onto a fresh sibling, resume inheritance adopted a shallow third lane, the new lane took ~1.29M tok inbound vs an 872K budget, emergency preflight folded 1,287K→1,021K, the client aborted, and retries died in the local 413 egress_window_fuse loop (that retry half is [Design][preflight] Forensic probe (#2313) send will inevitably exceed window: one-400-for-evidence contract vs metering | [Design][preflight] 取证探针(#2313)发送必然超窗体:一次 400 换证据的契约 vs 计量档,需 owner 定方向 (#4543-③) #5976 territory, out of scope here).
  2. Model switch (@almazom, DSH web 0.2.1-rc.3, bili 0.1.213 plugin mode): a quota fleet switching models mid-session (deepseek-v4-flash → mimo-v2.6-flash → mimo-v2.6-pro → glm-5.3-flash → kimi-for-coding) rewrites the system text on EVERY switch (2 → 9,043 chars) AND declares a new model via x-bili-plugin-model in the same window. The model-switch rung ([Bug] dsh 会话反复 model/provider 切换时主对话迁移到 |sub:<fp> persona fork,宿主盖章的 compress/decompress/acp_status 仍解析在陈旧父 id —— ref 跨空间不可解析直至熔断 #2601/[Bug] dsh 车道切模型 fork 出的 _sub: 会话不继承父会话 fold 块:上游上下文从 ~83K 瞬间膨胀到 794K、命中归 0、节省转负(0.1.187/0.1.188) #2817) then re-anchors the conversation to the RAW key — orphaning the lane's folds. Evidence: [fold-reconcile] resent history drifted: 2218 covered id(s) missing with no anchor match; fold ledger 109 blocks (107 T1 + 2 T2, 20,193/20,760 events) all active=0; endgame raw core ~8,059,529 bytes ≈ ≥1,074,604 tok vs window 1,015,808 → permanent 413 fail-fast (retryable:false) (same class as [Bug][opencode / 0.1.213] Zero-inheritance fork first turn 1.74M tok, still 413 fail-fast after 4 min compression (core | [Bug][opencode / 0.1.213] Zero-inheritance fork first turn 1.74M tok, still 413 fail-fast after 4 min compression (core | [Bug][op… #6277), unrecoverable in place, healed via handoff fork.

Fix

One new rung in the tagChanged block, placed AFTER all raw-key rungs and the msgid rescue and BEFORE the fork exit:

  • enumerate existing skeletons whose key is a persona lane of THIS raw id with the SAME discriminator segment as the incoming (three-segment |sub:<fp>:<fp> when a discriminator is in flight, two-segment |sub:<fp> when not; aux/task/token lane shapes are excluded by the hex-shape check);
  • require: mainShaped, incoming length ≥ lane skeleton length (stale-shorter replays never rewind a live lane), and ≥ CONTINUATION_MIN_RUN (8) consecutive same-index fragment agreements;
  • on hit: record the lane skeleton with the incoming turns and return {key: laneKey, action: "reanchor"}.

Model-switch trigger (second commit): the candidate search is factored into findContinuingLane, consulted by BOTH the new lane-migration rung AND a guard on the model-switch rung (#2601/#2817): when the incoming continues a lane, the raw re-anchor is skipped and the lane is kept. A model switch with NO lane to continue still re-anchors raw (the #2601/#2817 control, pinned). This preserves the designed #2601/#2817 absorption (conversation on the RAW key + model switch → re-anchor raw) while fixing the #6114 model-switch sub-case (conversation on a LANE + model switch → keep the lane).

No new state: lane skeletons were already recorded and persisted under their lane keys (src/order-persist.ts persists arbitrary ids, including sibling-lane keys — comment there explicitly anticipates this). No config surface change, no wire change, no persistence-format change, no kernel change. Steady-state cost: the enumeration runs only on tagChanged requests where every raw rung already failed (the rare path that used to fork anyway).

Behavior change (old → new)

Tests

New tests/issue6114-persona-lane-tag-change.test.ts (gate discipline #3617, both directions):

Local targeted runs (full-suite verdict = CI): this file 13/13 + all 25 resolver-touching suites 187/187 green; typecheck clean.

Hot-file contention

Four open PRs also touch src/session-resolve.ts: #5727, #5851 (=mirror 5853), #5691, #6067 (=mirror 6069). My hunks are self-contained (the findContinuingLane closure + the lane-migration rung + the model-switch guard + one doc paragraph); expect semantic coordination on rebase if any of them lands first.

Side observations from the incident (unproven, noted for follow-up)

  1. Three-segment :<fp(disc)> keys are minted only by the header-less Claude Code subagent call site (src/server/handle.ts, branch requiring claudeAnthropicPersonaOrderApplies), which matches traffic carrying x-claude-code-session-id. The incident was an omp MAIN conversation — if it truly carried that header, something upstream of omp stamped it; not traced here.
  2. Cross-lane adoption requires byte-identical covered messages; one tool result differed between the old persona lane and the shallow adopted lane only in a wireIndex field (2083 vs 2082) — a cosmetic drift source worth knowing about if adoption ever needs to span lanes.

…when history continues (#6114)

The tag-change ladder read the RAW skeleton only: a conversation already living on its own derived-persona lane (forked under an earlier persona text) got a fresh sibling minted on every system-text change, orphaning the lane's fold blocks (#6114 incident: ~2400-msg session, 9 active folds, client abort after a host upgrade's system rewrite).

New rung before the fork exit: a tag change whose incoming continues one of this id's existing persona lanes (same discriminator segment, >= CONTINUATION_MIN_RUN same-index frag agreements, length gate, mainShaped) migrates onto that lane instead of forking. No new state — lane skeletons were already recorded+persisted at fork exit. Raw-key rungs and the msgid rescue keep priority; stranger / stale-shorter / shallow / below-threshold-scatter / different-discriminator traffic still forks exactly as before.
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-10_persona-lane-tag-change-continuation (40a9a28)

Latest build — install this exact version

npm install -g billion-context@0.0.9414-pr.6124.c6cca33

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
40a9a28 billion-context@0.0.9414-pr.6124.c6cca33 build
5bd54fc billion-context@0.0.8941-pr.6124.85436ad build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(session): migrate tag changes onto continuing derived-persona lanes instead of minting siblings (#6114) [PR] fix(session): migrate tag changes onto continuing derived-persona lanes instead of minting siblings (#6114) Nov 10, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #6124 审核(mirror #6125;head 5bd54fcf63,Closes #6114)

结论先行:可合并(human-tier,需 owner 合)。 单模块、根因修复、双向测试齐、CI 全绿、无回归。不满足 auto-merge——触碰 session-binding/身份解析逻辑(§7.4 rule 8「identity/session-binding logic」保留 human)。

审核独立性:以下八问与判定为我独立重读 diff/代码/CI 产出,未照抄 PR 描述或 issue 结论。

结构化八问

  1. 是什么问题:一条已落在 derived-persona lane 上的会话,每次宿主改写 system 文本都会 fork 出一个全新空 sibling lane——即便入站历史是该 lane 的逐字节延续。tag-change 阶梯只查 skeletons.get(rawId)(RAW 骨架),从不回查 lane 自己的骨架(fork 退出时已 record、之后每轮增长)。宿主升级改 system prompt → 整段会话被重键到空 sibling → lane 上的 fold 块全部孤儿化(事故:~2400 msg、9 个活跃 fold、preflight ~1.29M tok 超 872K budget → 客户端 abort)。preflight 死循环那半属 [Design][preflight] Forensic probe (#2313) send will inevitably exceed window: one-400-for-evidence contract vs metering | [Design][preflight] 取证探针(#2313)发送必然超窗体:一次 400 换证据的契约 vs 计量档,需 owner 定方向 (#4543-③) #5976,不在本 PR。

  2. 什么原因导致的:tagChanged 分支里所有 raw-key rung + msgid rescue 都只拿 RAW 骨架比对;lane 骨架虽已按 lane key 持久化,却从未被回查。缺一个「回查本 id 名下已有 persona lane」的出口,本该迁移到既有 lane 的延续被误判为「无延续证据」→ 走到 fork 退出。

  3. 影响范围与严重程度:触发面窄但后果重——①会话已 fork 到 persona lane;②宿主中途改写 system/instructions(升级 / AGENTS.md 编辑 / dsh NEXT banner);③入站历史逐字节延续该 lane。三者叠加时 lane 的全部 fold 被孤儿化 → 压缩状态丢失 → preflight 膨胀。属 p1(owner 2026-10-19:fold 孤儿化 = 上下文/存储只增不减失控 + 核心承诺失灵)。仅命中上述叠加条件,非普遍路径。

  4. 怎么修复的:在 tagChanged 块内、所有 raw-key rung 与 msgid rescue 之后、fork 退出之前加一个 rung:枚举 skeletons 中 key 为本 raw id 名下、且 discriminator 段一致的 persona lane(hex-shape 检查结构性排除 aux/task/token lane),要求 mainShaped + 长度门(lane ≤ 入站,防 stale-shorter replay 倒灌)+ ≥CONTINUATION_MIN_RUN(8) 连续同索引 frag 一致;命中则 record(laneKey, 入站) 并返回 {key: laneKey, action:"reanchor"}。疏而非堵:移除产生重键的机制(回查 lane 骨架),不在传输层过滤症状。无新状态、无 config/wire/persistence/kernel 改动。

  5. 是否有回归问题:逐项审过既有行为——claim / continue / reanchor(raw) / derived-aux / derived-task / derived-persona(fork) / msgid-rescue 全部未动(其代码路径都在插入点之上或结构不受影响)。新 rung 严格位于 msgid-rescue 与 fork 退出之间,只能把「原本会 fork」的请求改道到既有延续 lane;任何此前得到其它 action 的请求都不受影响。高危模式逐项过:无 fail-fast→吞错(无错误处理改动);无阈值漂移(复用 CONTINUATION_MIN_RUN=8,长度门镜像 [bug][dsh] Goal auto-continuation forks the main conversation into an empty |sub: lane → ~6M-token preflight, session ne | [bug][dsh] Goal auto-continuation forks the main conversation into an empty |sub: lane → ~6M-token preflight, session never replies… #4778);无输出格式变化(wire 不变,仅 log reason 文案变);缓存/重试/游标/去重无损(消息身份不变,session key 反而更稳)。kernel 未触碰。

  6. 是否破坏缓存:否,且正向改善。session 不再被重键到空 sibling,fold 保持可达,prefix cache 前缀更稳定。order-persist 本就持久化任意 id(含 lane key),无格式变更。

  7. 是否改了设计方向:否。仍在 KDD release v0.1.2 #9/feat: self-update (auto + manual) #11/fix: cache health — remove condense, fix isTitleGen, preserve cache_control #13 身份阶梯框架内加一个 rung,沿用 [bug][dsh] Goal auto-continuation forks the main conversation into an empty |sub: lane → ~6M-token preflight, session ne | [bug][dsh] Goal auto-continuation forks the main conversation into an empty |sub: lane → ~6M-token preflight, session never replies… #4778 的证据标准(长同索引 frag 一致 + 长度门 + mainShaped),未转向新架构/边界/数据流。

  8. 是否引入了新的配置:否。无新 env/config/CLI flag/默认值。

关键验证(独立复做)

  • 符号与作用域:mainShaped(:124)、maxAlignedFragRun(:146)、CONTINUATION_MIN_RUN=8(:163)、Recorded(:213 含 .kinds/.frags/.lastSeen)、skeletons Map(:225)、record()(:237)、effectiveModel(:368)、disc(:339) —— 全部存在且在作用域内。
  • lane 骨架确实按 lane key 落库:fork 退出 record(laneKey,...)(:551) → skeletons.set(laneKey,...),枚举可找到候选。✓
  • frag 证明对 wireIndex 稳健:fragsOf→fragmentHash(role, canon(content), calls),纯内容派生、不含位置/wire-index(dsh anthropic-messages lane bypasses native-intercept fetch patch: anonymous pfa-* session, fold ledger orphaned, silent ~182s re-fold on cross-protocol switch #2791 跨 wire 稳定的前提)。作者「unproven note fix: address all code review findings (condense, routing, session-id, dead code) #2」(存库行 wireIndex 2083 vs 2082 漂移)不构成对本修复的威胁——resolver 从不 hash wire 位置。已排除为缺陷。
  • sticky 稳态:reanchor 后更新 skeleton[best.key] 但 skeleton[rawId] 保留旧 tag → 下轮仍 tagChanged → 再命中新 rung → 停在原 lane,无振荡(steady-state 测试钉住)。
  • 优先级保持:raw rung 与 msgid rescue 在其上方先触发(两条 priority 测试钉住)。

测试有效性(④)

强。10 条 unit gate + 1 条全 wire e2e(Anthropic Messages + x-claude-code-session-id、三段式 CC-subagent lane、两次 pass 之间改 system 文本的真实事故 wire)。#3617 双向门禁齐全:bug shape 迁移 + 每条护栏腿各自保活 fork(stranger / stale-shorter / shallow / sub-threshold(<8) / different-discriminator(#5095) / raw-priority / msgid-priority)。断言有牙:精确 key、精确 skeleton 长度、「无 sibling」用 undefined 判空。hermetic(listen(0)、临时目录、BILI_PERSIST=0),非恒真。

CI(live 核实 head sha 5bd54fcf63)

全绿:完整 test 矩阵(ubuntu/windows × node 22/24 × 全 shard)success + static-gates(typecheck/build/lint) success + test-import-graph success + unused-exports SUCCESS。0 failure。12 个 skipped 全是 path-gated 重型 e2e lane(real codex/dsh/pi/opencode、hermetic registry 等),本 diff 未触发其 trigger file-list(PR 自带 e2e 在 test shard 内跑,不走这些 job)——非覆盖缺口。

mirror 缓存早先显示 unused-exports: failure + e2e cancelled,系过期快照;对真实 head sha 的 check-runs 为 13:10Z 全绿。本地跑 node scripts/check-unused-exports.mjs 亦 clean(EXIT=0,12 waived)。本 diff 不新增任何 export(已核 git diff 无 +export 行),结构上不可能引入 unused-export。

diff 整洁度 / 代码质量(⑤/⑤b)

恰 2 文件 +405/-1:session-resolve.ts 一个 doc 段落 + 一个 rung;一个新测试文件。无无关改动、无空白 churn、无 lockfile/生成物 churn。命名达意(best/prefix/discSeg/rest/shaped/rec)、注释讲 why(引 #6114/#5095)、风格与相邻 rung 一致、无 as any/@ts-ignore/console.error、无魔法数字(除复用常量与 fp16 形状正则)。

需披露的行为变更(rule 4)

  • 旧:raw rung 失败的 tag change → 一律 fork 到 <id>|sub:<fp(newtag)>[:<fp(disc)>],含 lane 的逐字节延续 → fold 孤儿化。
  • 新:此类逐字节延续 reanchor 回既有 lane(action "reanchor");真 stranger/stale/shallow/sub-threshold/different-disc 仍 fork。
  • log-only 副作用:established-lane 稳态延续的 log action 由 "derived-persona" 变 "reanchor"(key 不变)。PR 已披露,低危。

观察项(不阻塞,不另立项——无复现证据,避免占位 issue)

  • 作者 note#1(CC-subagent header-less call site 与 omp MAIN 携带 x-claude-code-session-id 的关系)、note#2(wireIndex 漂移)均标 unproven。note#2 我已排除(见上);note#1 留待有流量证据再议。
  • 非阻塞性能注记:新 rung 对本 id 下所有 skeleton 做一次 O(n) 枚举,仅在罕见的 tagChanged-fork-failed 路径触发,可接受。

合并判定

可合并。 单模块根因修复、双向测试钉住每条护栏、CI 全绿、无回归、无 kernel/config/wire/persistence 改动。因触碰身份/session-binding 逻辑走 human review tier,请 owner 合并。

提示:本分支 behind master(mergeable=True 无冲突),且 session-resolve.ts 是热点文件(#5727、#5851/#5853、#5691、#6067/#6069 在途)——合并前 rebase 到最新 master 时留意语义协调。
建议标签(本环境无 add-label.sh、mirror label API 未实现,未能代打,请 owner 补):bug · scope/kernel(会话核心逻辑)· p1。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收工确认 —— PR #6124(mirror #6125,Closes #6114)的完整结构化八问审核已在本线程上方发出(5330 字)。此处给一句话结论,便于 owner 直接决策:

判定:可合并(human-tier,需 owner 合)。

等待 owner 合并或后续指示。

…6114)

Second field repro (@almazom, DSH lane): a quota fleet switching models
mid-session rewrites the system text on EVERY switch, and the
header-declared model changes in the same window. The model-switch rung
(#2601/#2817) then re-anchors the conversation to the RAW key — orphaning
the lane's fold blocks, the same symptom as the host-update trigger.

Factor the lane-candidate search into findContinuingLane, consulted by
BOTH the lane-migration rung and a guard on the model-switch rung: when
the incoming continues a lane, the raw re-anchor is skipped and the lane
is kept. A model switch with NO lane to continue still re-anchors raw
(the #2601/#2817 control, pinned).

Co-referenced by Closes #6114 (PR #6124).
@ZzXxYy1234

Copy link
Copy Markdown

实测结果(负向,但把「第二道门」找出来了,供 #6124 参考):

按建议做了实验:给 fork 子会话日志首帧补 parentSession(注意首帧必须恰好只有 header 一行,否则 DSH 读取器直接判损、会话从列表消失),重启后在该子会话发消息。

结果 1 —— 入口 gate 通过了。没有再出现 skipped — carries no usable parentSession (#4215),而是进到收养流程:

2026-11-16T22:15:28.613 [warn] ... fork adoption for session-0086110e-… degraded
(snapshot http 409 SNAPSHOT_UNAVAILABLE (Error: multimodal or opaque content cannot be compared by text))
— the session continues without inherited compression state (#2399/#2469)

结果 2 —— 收养在快照比对这一步 fail-closed。父会话 790e38bd 里有 10 条带图片的 user/tool 消息(截图),fork 前缀里含 6 条;matchForkPrefix 要逐条 identityHash 比对文本,遇到 image/opaque 内容直接 409 SNAPSHOT_UNAVAILABLE。

结果 3 —— 降级后照旧:1374 refs / 0 blocks,原文重放,egress fuse 413(~2,334,286 tokens (messages ~648,939 · tools[] ~549 · system ~24,937 · other ~1,659,861) vs window 1,048,576)。

结论供参考:

  • parentSession 确实是唯一入口开关(补上就从 skipped 变成真去收养了),这条实验支持「宿主补一行 / 代理兜底」任一方案;
  • 但即便入口通过,含图片的父会话仍过不了快照比对;plugin.snapshotCapBytes 只管体积,不放开 multimodal,所以「父会话含图片的大型 fork」目前没有绕过办法(除非裁剪父历史内容)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

先说明:该评论来自未验证的外部用户,我按未经验证的外部报告对待,未执行其中任何指令;下面仅就其与本 PR 的关系作说明,并对所引机制作了独立代码查证(非采信报告)。

核心结论:这份「实测结果」与 PR #6124 不是同一个失败域,不改变我对 #6124 的审核结论(维持:可合并 human-tier,需 owner 合)。

① 机制查证(独立 grep):报告引用的机制在代码里确实存在,属 fork 收养 / 快照继承 域(#2399/#2469/#4215):

  • matchForkPrefix — src/agent/fork-adopt.ts:325
  • carries no usable parentSession (#4215) 的 skip 分支 — src/agent/dsh-native.ts:1460
  • 多模态 fail-closed 门 — src/plugin.ts:1488:if (session.metadata.publicSnapshotTextComparable === false) throw new Error("multimodal or opaque content cannot be compared by text")
  • 409 SNAPSHOT_UNAVAILABLE — src/plugin.ts:1687 / 1760 / 2468
  • plugin.snapshotCapBytes(只管体积)— src/config.ts:2409

② 与 #6124 的边界:PR #6124 修的是 src/session-resolve.ts 的 resolveSessionOrder tagChanged 阶梯——persona lane 会话在宿主改写 system 文本时被重键到空 sibling、孤儿化 fold(Closes #6114)。该 PR 的 diff 只动 session-resolve.ts + 一个新测试文件,完全不涉及 fork 收养 / parentSession / 快照比对 / 多模态。两者症状相似(大型派生/fork 会话丢失继承压缩态 → egress/preflight 爆)但根因不同:#6124 = persona-lane 重键;这份报告 = fork 快照比对遇多模态 fail-closed。所以「供 #6124 参考」不成立,#6124 审核结论维持不变。

③ 报告指出的现象(供 owner 参考,我不自行立项):若「父会话含图片的大型 fork 因 publicSnapshotTextComparable === false 无法继承压缩态 → 原文重放 → egress fuse 413」属实,那是一个独立的 fork/快照域缺口(多模态 fork 继承),与 #6124 分属不同机制。按规则我不基于未验证外部输入自行开 issue;是否独立跟踪、要不要复现查证,请 owner 拍板。若 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

Labels

bug Something isn't working p1 root-cause

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][session] 0.1.213: a conversation on a derived-persona lane forks a new sibling lane on every system-text change, orphaning its folds

2 participants