Repository navigation
fix(#2601): model-switch lineage — churn-tolerant chain continuity + persona-fork routing follow - #2719
Merged
Conversation
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2972-pr.2719.79f60e7This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2719.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
ranxianglei
force-pushed
the
2026-10-11_2601-model-switch-lineage
branch
2 times, most recently
from
October 11, 2026 03:08
6a1a187 to
988183a
Compare
…persona-fork routing follow A model/provider switch mid-conversation re-serializes the same history (thinking inlined vs structured blocks, provider re-minted tool ids, image placeholder appended/stripped). Byte-exact chainContinues then fails, resolvePersonaKey forks the main lane onto <raw>|sub:<fp>, and the host keeps stamping the RAW id on its management calls — compression state strands on a frozen parent and the kernel's stale-ref circuit breaker trips (#2601). Layer A — churn-tolerant continuity (prefix-affinity): - every noted chain also stores a NORMALIZED tail fingerprint (churn keys dropped, role kept as a marker, content-length leaves only, sorted so block reordering is invisible, placeholder lines filtered, normalizeMessageText fold — the #2636 discipline); - chainContinues gets a second chance after the exact+depth gates: a re-serialized tail with equal normalized fingerprint continues the chain, so resolvePersonaKey MIGRATES the anchor on a model switch instead of forking. Different content still forks; shorter histories never continue (#2668 poison discipline); - snapshots round-trip normTailHash (restart keeps the second chance). Layer B — persona-fork lineage follow (plugin routing): - when a fork still legitimately happens, host-stamped (nativeCaller) management calls naming the stale parent follow the live |sub: descendant (fresher lastSeen, recent traffic), by their own id or via a lineage witness in the conflict branch; - legacy unflagged callers keep #2016 fail-closed; foreign witnesses keep #2024 native-honor; switch-back self-heals (parent live again → routing goes home). Tests: tests/issue2601-persona-fork-lineage.test.ts — 4 unit legs (second chance, content gating, anchor migration, snapshot round-trip) + e2e through the real proxy (fork minted, lineage follow, 409 control, foreign witness control, switch-back self-heal). Full suite vs base at the same commit: identical pre-existing local-env failures, zero new.
ranxianglei
force-pushed
the
2026-10-11_2601-model-switch-lineage
branch
from
October 11, 2026 03:29
988183a to
80eec4f
Compare
Review-time supplement: the USER_IMAGE_PLACEHOLDER filter in the normalized tail fingerprint had no test where the placeholder sits on the TAIL message itself (the only position the projection compares). Mutation-checked: removing the filter fails this test.
…nchor A model switch landing in the same window as an unannounced history rewrite (dsh local compaction) still satisfies the fork conjunction even with #2719's churn-tolerant continuity: fp changed AND chain discontinuous. dsh declares its model target on every request via x-bili-plugin-model — consume both host declarations: the header model changed AND the system line-diff is confined to lines naming the old/new model (folded) => absorb the fp half (migrate-model, raw key). No host-specific phrasing hardcoded; anything less keeps the fork.
… split (#2601 review nit, pre-existing on master)
…-absorption fix(#2601): absorb header-corroborated model-drift into the persona anchor
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.255-master.6dafceb # this exact build
npm install -g billion-context@master # always the newest merged build
|
This was referenced Oct 11, 2026
antclt
pushed a commit
to antclt/billion-context
that referenced
this pull request
Oct 11, 2026
…lei#2601/ranxianglei#2676) Scenario A pins the model-switch contract: a dsh model switch (system model line + x-bili-plugin-model header) landing in the same window as an unannounced history rewrite is ABSORBED — raw key kept, no |sub: fork, kernel machinery (compress → decompress) still works on the same session; the uncorroborated control still forks. Scenario B pins the fork contract: a fork with context COPIES the parent's state — inherited blocks (ids + summaries + originals, child decompress round-trip), seeded raw→ref map equal to the parent's, the durable-guard lane adoptable (null wire refs, BLOCKED never in byRef), parent untouched. A/B teeth: pre-ranxianglei#2719 master mints the fork (scenario A red); master without ranxianglei#2625 fails scenario B with 409 raw/ref mapping inconsistent — the ranxianglei#2676 silent degrade.
antclt
pushed a commit
to antclt/billion-context
that referenced
this pull request
Oct 11, 2026
…ponses wires (ranxianglei#2601/ranxianglei#2676) The ranxianglei#2729 proof pinned scenario A (model switch = one session) and scenario B (fork copies state) on the chat wire only, but the persona wiring is per-call-site in src/server/handle.ts (anthropic :811 / openai :821 / responses :843,:880) with a different system-text extractor per lane — correct-in-one-lane is not correct-in-all (ranxianglei#377). Parameterize the harness over chat/anthropic/responses: per-wire request builders (system message vs top-level system vs instructions), per-wire mock upstream responses, identical session-state assertions. google is deliberately absent (no persona call site, issue ranxianglei#2730). Teeth (A/B @ 4ecd82f pre-ranxianglei#2719): scenario A mints the |sub: fork on all three wires; scenario B 409s (ranxianglei#2676); controls still fork on all three — the persona path is engaged per wire, not vacuous.
ranxianglei
pushed a commit
that referenced
this pull request
Oct 11, 2026
…es (#2806 review) fork-adoption-wires + issue2033-anonymous-anchor drive ANONYMOUS clients whose identity rides prefix-affinity.json in the shared default state dir. Without isolation they hydrate foreign chains written by sibling test files running concurrently in the same CI job and co-write the file underneath each other; once this stack added four more test files (incl. heavy multi-proxy e2e) the interference flipped both suites' assertions on all four CI nodes while every parent tree stayed green. Isolate with the established #2719 idiom.
ranxianglei
added a commit
that referenced
this pull request
Oct 13, 2026
v2.1: fragment-tail guard for truncation/reanchor (tail window 8) and |sub:task:<skel8> keys for tag-less strangers (mixed-traffic probes: subagent short replay and cross-session key collisions closed). v2.2: personaTag + declaredModel inputs; wired into all four prepares through personaConversationOrder (replaces the personaNamespace ladder call sites; ladder module kept for characterization tests). - same tag: persona owns the id — ride/continue/reanchor through truncation, compaction rewrites, diverged or shorter replays (old fp-equal semantics, byte-identical lane keys) - tag change: migrate on head continuity (#2241/#2250) or on a header-corroborated model switch (#2601/#2719/#2817); otherwise stable |sub:<fp16(tag)> persona lane (self-recording) - tag-less: shallow rides the raw key (old non-anchoring path); strict |sub:aux only for virgin ids; deep strangers fork to |sub:task:<skel8> (#150-class protection) - empty incoming tag never counts as a persona change Tests: issue2944 corpus + dsh persona families + 2601/2817 continuity 50/50; crosswire/side-lane/subagent/dsh-native/title 25/25; goldens 10/10.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复 #2601:模型/供应商切换的会话血统
问题(两层)
A. 重序列化导致链断裂 → 误 fork:模型/供应商切换时,dsh 重放同一段历史但换了一种序列化(thinking 内联 vs 结构化 block、工具 id 重铸、图片占位行增删)。字节级
chainContinues失配 →resolvePersonaKey把主线 fork 到<raw>|sub:<fp>,压缩状态滞留在冻结的父会话上。B. 管理调用落在陈旧父会话:dsh 原生压缩转发始终盖 RAW id +
nativeCaller:true(#2024),fork 后调用仍路由到父会话 → kernelevery ref is unknown to this session→ stale-ref 熔断。根因修复
Layer A — 抗扰动链连续性(src/prefix-affinity.ts)
note()时额外存归一化尾部指纹:丢弃 churn key(signature/id/cache_control/tool_use_id/…)、role 保留为标记、只取内容长度(≥32 字符)叶子、排序(块顺序无关)、过滤图片占位行、normalizeMessageText折叠([Bug] pi lane: switching models mid-session replays the full history and drops fold state — cross-model re-serialization churn defeats fold-reconcile anchors #2636 纪律);chainContinues在 exact+depth 门之后获得第二次机会:归一化投影相等 → 续链 → 切换时 anchor 迁移而非 fork;Layer B — persona-fork 血统跟随(src/plugin.ts)
nativeCaller)的管理调用点名陈旧父会话 → 跟随活跃的|sub:后代(更新 lastSeen + 近期流量,10 分钟窗口):|sub:或 base 本身)优先解析;涉及文件
测试
安全边界
nativeCaller盖章调用开放 — 模型转写的 id 永不跟随;Closes #2601