Skip to content

[PR] Fully retire legacy |sub: fork ladder (post trust-stamped-id GA cleanup, #7525) | 彻底退役 legacy |sub: fork 阶梯(trust-stamped-id GA 后的清场,#7525) - #7564

Merged
ranxianglei merged 5 commits into
masterfrom
retirement/trust-stamped-id-ga-2026-11-23
Nov 23, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
retirement/trust-stamped-id-ga-2026-11-23

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

这是啥

#7525 把「信任客户端盖的 session id」提到 100% 之后,代码里那套「看内容猜会话、猜错就 fork 一个 |sub: 影子会话」的老机器已经没有任何决定权了——每个会话 key 要么就是客户端盖的原值,要么是 #5095 客户端声明的 lane-token。owner 2026-11-23 拍板:不留调试后门,整条链路彻底删干净。本 PR 就是那次清场。

删了什么

明确留住的

CLI 面移除(合并 master 时补删,merge commit 5202c49)

测试与数据

  • 删 16 个 pin legacy 行为的测试套件,9 个文件解除 pin,scripts/ci-shard-weights.json 同步减 9 条,reference/architecture.md 更新;architecture-docs / unused-exports / test-import-graph 三道门全绿,全部受影响套件本地全过。
  • 本地跑不动的:dsh-native / dsh-admin-relay 的 attach/apply/gate spawn e2e 在本机 VM 上会挂/超时——已在干净 master 基线 worktree 复现同样失败簇,属环境噪音,以 CI 为准。
  • 覆盖缺口(如实报告):[Bug] dsh 会话反复 model/provider 切换时主对话迁移到 |sub:<fp> persona fork,宿主盖章的 compress/decompress/acp_status 仍解析在陈旧父 id —— ref 跨空间不可解析直至熔断 #2601 birth-order follow(src/plugin.ts 的 livePersonaDescendant)代码保留(token-minted lane 还在用),但它原有的构造场景就是 legacy 内容 fork,两个专属 pin 套件(persona-fork-active-parent-guard、issue2948-aux-lane-lineage-guard)随之删除——这条路目前没有专门测试。
  • 遗留死数据(本 PR 不自动清):kv_store 里 namespace="session-order" key="v1" 那行、以及 stateDir 下 session-order.json 落盘文件,从此无任何代码读写。生产库那行建议合并后手动 DELETE FROM kv_store WHERE namespace='session-order' AND key='v1';(约 630KB)。

回归

GA 行为字节不变:#5095 lane-token 的 key 公式逐字节保留(<id>|sub:[<fp>:]t:<token>);#970 拆分、side-lane、prefix-affinity、plugin-conversations 未触碰。被删路径在 GA 默认下本来就不可达(flag percent:100 自 #7525 起)。

…7525)

With the client-stamped session id trusted on every lane (percent:100 since
#7525 GA), the content-forecasting fork machinery is write-only: every
reachable session key is either the stamped id verbatim or the #5095
declared lane-token key. Owner ruling 2026-11-23: remove it completely
instead of leaving a debug escape hatch.

Removed:
- src/session-resolve.ts rewritten to the GA shape: resolveSessionOrder(
  rawId, personaTag?, laneToken?) returns the verbatim id (action "raw")
  or the #5095 lane-token fork (action "derived-persona"). Gone: the
  skeleton map + record(), the |sub:aux / |sub:<fp> / |sub:task:<skel8>
  fork rungs, #5719 msgid rescue (tryMsgIdRescue / readStoredMsgIds /
  laneDiscriminator), model-drift absorption, persona re-anchor.
- src/order-persist.ts (the 630KB kv_store namespace "session-order"
  writer) and src/persona-anchor.ts (header-marked retired, kept only as
  a test pin) deleted; boot hydrate + shutdown/exit flush wiring removed
  from src/cli.ts, src/server.ts, src/restart.ts.
- src/rollout.ts: trustStampedId flag entry deleted; the
  BILI_ROLLOUT_TRUST_STAMPED_ID=0 env escape hatch no longer exists.
- src/session-id.ts: anthropicFirstUserFrag (only consumer was the D1-B
  discriminator rung) deleted.
- src/server/handle.ts: the six persona call sites drop their dead
  arguments (history / model / msgIds / storedMsgIdsOf); the observer
  now logs derived- (lane-token) resolutions only — the reanchor/claim
  noise of the retired rungs is gone.

Config-surface removals (declared per repo doctrine):
- rollout.features.trustStampedId (config key) — GA default moved into
  the code; setting it now has no effect.
- env BILI_ROLLOUT_TRUST_STAMPED_ID — read by nothing anymore.
- kv_store row namespace "session-order" key "v1" becomes dead data
  (nothing writes or reads it; left in place — delete manually if
  desired); stateDir()/session-order.json is a stale fallback file that
  nothing produces any more.
- telemetry: the [session-resolve][msgid-rescue] warn line (#5719 /
  #5865-P2) dies with its rung.

Kept (still load-bearing):
- #5095 declared lane-token fork (client-declared, survives GA) —
  tests/trust-stamped-id.test.ts reworked as the GA characterization,
  tests/issue5095-subagent-lane-token.test.ts un-pinned.
- #970 claude agent-header split, aux sidecar lanes, side-lane
  invariants — tests/side-lane-invariants.test.ts un-pinned, its
  (D)/(E)/(E2)/(L) fork assertions flipped to the GA verbatim contract.
- #2601 livePersonaDescendant birth-order follow in src/plugin.ts stays
  (it also serves token-minted lanes); its construction scenario was a
  legacy content-fork, so the two pin suites
  (persona-fork-active-parent-guard, issue2948-aux-lane-lineage-guard)
  are deleted and that path is now covered only indirectly.
- tests/session-continuity-proof.test.ts: scenario A control flipped
  (uncorroborated system drift now rides the raw key, no fork);
  scenario B (host-driven fork API + copy-on-fork) untouched.

16 legacy-pinning test suites deleted, 9 test files de-pinned,
scripts/ci-shard-weights.json re-trimmed (9 removed entries),
reference/architecture.md updated.
@ranxianglei ranxianglei changed the title 彻底退役 legacy |sub: fork 阶梯(trust-stamped-id GA 后的清场,#7525) [PR] Fully retire legacy |sub: fork ladder (post trust-stamped-id GA cleanup, #7525) | 彻底退役 legacy |sub: fork 阶梯(trust-stamped-id GA 后的清场,#7525) Nov 23, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到,这是 #7564 的 [PR] 镜像 issue。按「自己的 PR 不重做」纪律处理:核对代码 + 确认 CI + 报告结论,不重做。

当前状态(实时核对,非记忆):

我先把分支拉下来做代码审查(重点:src/session-resolve.ts 重写 + 配置面移除 + 16 个测试套件删除),CI 出结果后按八问汇报。

… ladder it rescued

master's #5844 (sessions reattach) exists to repair legacy persona forks
(the warning log that names the command is gone with the ladder, and tagHash
recording is gone, so the command could never have worked under GA): drop
the CLI subcommand, runReattach, and its test. order-persist.ts stays
deleted.
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: retirement/trust-stamped-id-ga-2026-11-23 (a24c711)

Latest build — install this exact version

npm install -g billion-context@0.0.11580-pr.7564.a68e3f7

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
a24c711 billion-context@0.0.11580-pr.7564.a68e3f7 build
528e367 billion-context@0.0.11575-pr.7564.ad72bc0 build
b65905f billion-context@0.0.11557-pr.7564.4aaa320 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

review结论

…both sides agree, fold the d904b4e GA drift pin into trust-stamped-id.test.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

收到。review 结论如下。

总体判定:PR 自身 diff 干净正确(GA 行为字节不变、测试重写到位、配置面声明合规、无悬空引用),但有一个 stale-base 阻断问题——#5844 在 PR 切出后落到 master,其 bili sessions reattach 命令依赖了 PR 要删的 order-persist.ts。直接 rebase 合并会构建失败,需 owner 先决策 reattach 功能的去留。

一、PR 自身 diff(干净,已逐项核验)

  • src/session-resolve.ts 重写为 GA 形状(90 行纯函数):stamped id 原样骑(action raw)/ Claude Code sub-agents of the same type share a single compaction lane: unrelated sessions bleed content into each other | Claude Code 同类型子代理共用一条压缩车道:无关会话互相串内容、折叠暂停;旧版共享父 id 的折叠块升级后仍残留在父会话 #5095 lane-token fork(action derived-persona),lane key 公式逐字节保留(<id>|sub:[<fp>:]t:<token>)。
  • 行为等价已验证:pre-PR resolver 的每个 fork 出口都被 featureEnabled("trustStampedId") 门控,percent:100 下每个可达返回都是 rawId(除 lane-token)= 新 resolver。GA 行为字节不变。
  • handle.ts 6 个调用点改 4 参签名匹配;onSessionResolveEvent 收窄到 derived- 事件。
  • 配置面移除(rollout.features.trustStampedId + BILI_ROLLOUT_TRUST_STAMPED_ID)按仓库规矩在 PR 正文声明。
  • 无悬空代码引用(trustStampedId/order-persist/persona-anchor/sub:aux 仅剩注释;anthropicFirstUserFrag 零引用)。
  • action 字段仅日志消费,不参与逻辑。
  • 测试重写正确:16 个 pin legacy 的套件删除、9 个文件解除 pin、trust-stamped-id/session-continuity-proof(scenario A control 翻转)/issue5095/side-lane-invariants 的断言都是真断言(非恒真),GA 契约钉死。
  • ci-shard-weights.json 与测试树交叉核验干净(无悬空引用、无指向不存在文件的条目);reference/architecture.md 同步删 order-persist.ts/persona-anchor.ts 行。

二、阻断性发现:#5844 stale-base 冲突

#5844(5b46ffb8b75,已在 master,PR 切出后落地)加了 bili sessions reattach 命令,动了 4 个文件:

  • src/cli.ts:sessions reattach 子命令分发
  • src/storage-maintenance.ts:import { reattachOrderSkeleton, readOrderTagHash, type OrderKvCarrier } from "./order-persist.js" + runReattach
  • src/order-persist.ts:reattach 后端(135 行:导出 orderFile、writeOrderEntriesTo、OrderKvCarrier、reattachOrderSkeleton)
  • src/session-resolve.ts:fork 路径加 7 行 warn 日志(提示用户跑 reattach)

PR 删 order-persist.ts + 重写 session-resolve.ts,但 PR 的 diff 切自 #5844 之前的 master,所以没碰 storage-maintenance.ts、也没删 reattach 子命令。

rebase 到当前 master 的后果:

  1. order-persist.ts:modify/delete 冲突(Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 改 135 行 vs PR 整删)——必须解。
  2. storage-maintenance.ts:无文本冲突(PR 没碰它),但 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的 import 指向已删模块 → tsc/tsup 构建失败(静默断:rebase 不标冲突,解完 order-persist 冲突后构建才红)。
  3. session-resolve.ts:Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的 7 行在已退役 fork 路径,PR 重写直接覆盖(好解)。

语义层面:reattach 恢复的是 GA 退役的 persona fork(|sub:<fp> orphan lane)。GA 下 stamped id 原样骑,不再产生这种 lane,所以 reattach 对新流量是孤儿功能——但 PRE-GA 产生的存量 orphan lane 可能仍需它清理。PR 正文"session-order 从此无任何代码读写"的断言在 #5844 落地后不成立(reattach 读/写它)。

三、需 owner 决策(rebase 合并的前置)

  • 选项 A(推荐,若 PRE-GA 存量 orphan lane 已清理/可丢弃):连 reattach 一起退役——删 cli.ts 子命令 + storage-maintenance.ts 的 runReattach/import + order-persist.ts 的 reattach 函数。清场彻底,order-persist.ts 可整删。代价:PRE-GA 存量 orphan lane 失去命令式恢复(只能手动 SQL 或接受丢失)。
  • 选项 B(若存量 orphan lane 仍需恢复):order-persist.ts 不整删——只删 skeleton 写入/读取路径,保留 reattach 函数 + OrderKvCarrier + orderFile。代价:留一个"只读+reattach"残壳,630KB 死数据仍在,清场不彻底。
  • (变体 C:把 reattach 函数抽到独立模块、order-persist.ts 仍整删——两者都要时走这条,工作量比 B 大。)

在决策前,这个 PR 不能 rebase 合并——无论选哪个,都需要在 rebase 时一并处理 #5844 的 4 个文件,不是简单 rebase 能过的。

四、其他发现(非阻断)

八问

  1. 是什么问题:PR 要彻底退役 GA 后已无决定权的 legacy |sub: fork 阶梯,但切出后 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 落到 master、其 sessions reattach 命令依赖了 PR 要删的 order-persist.ts。
  2. 什么原因导致的:stale-base——PR 切自 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 之前的 master,diff 不知道 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的存在;Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的 reattach 是 persona fork 的恢复机制,而 persona fork 正是本 PR 退役的对象,两者在 order-persist.ts 上正面相撞。
  3. 影响范围与严重程度:阻断级——rebase 合并后 storage-maintenance.ts import 已删模块,构建失败(tsc/tsup 红),PR 无法合并。不是"特定条件下有问题",是"合并即红"。
  4. 怎么修复的:PR 自身 diff 无需改(已验证正确)。修复在 rebase 阶段:按 owner 决策处理 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的 4 个文件(A:连 reattach 一起删;B:保留 reattach 函数、order-persist.ts 不整删)。
  5. 是否有回归问题:PR 自身无回归(GA 行为字节不变,被删路径在 GA 默认下本就不可达)。但 rebase 不处理 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 会引入新回归:删 order-persist.ts 会断掉 Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的 reattach(修 A 坏 B)。
  6. 是否破坏缓存:不涉及(纯会话身份解析 + 持久化清理,不碰缓存/重试/游标/去重键)。
  7. 是否改了设计方向:PR 方向正确(GA 清场),但需补一个决策:Resuming a long session fails with preflight 413 when persona fingerprint and replay shape change together (0.1.212) #5844 的 reattach(PRE-GA orphan lane 恢复)随 GA 一起退役,还是作为存量清理工具保留。
  8. 是否引入了新的配置:无新增;移除 rollout.features.trustStampedId + BILI_ROLLOUT_TRUST_STAMPED_ID(已声明,设置它们从此无效)。

收工判定:PR 自身 diff 可合(干净、正确、测试到位),但当前不能 rebase 合并——需 owner 先拍板 #5844 reattach 的去留(推荐 A,若存量 orphan lane 可丢弃),再在 rebase 时一并处理 #5844 的 4 个文件。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

🔶 需要决策

背景:PR #7564 要彻底退役 GA 后已无决定权的 legacy |sub: fork 阶梯,但切出后 #5844(bili sessions reattach)落到 master,其命令依赖 PR 要删的 order-persist.ts——直接 rebase 合并会构建失败(storage-maintenance.ts import 已删模块)。

待决问题:#5844 的 sessions reattach(PRE-GA orphan lane 恢复命令)随 GA 一起退役,还是作为存量清理工具保留?

选项(各带代价):

  • A(推荐):连 reattach 一起退役——删 cli.ts 子命令 + storage-maintenance.ts 的 runReattach/import + order-persist.ts 的 reattach 函数,order-persist.ts 可整删。代价:PRE-GA 存量 orphan lane 失去命令式恢复(只能手动 SQL 或接受丢失)。
  • B:order-persist.ts 不整删,保留 reattach 函数 + OrderKvCarrier + orderFile。代价:留"只读+reattach"残壳,630KB 死数据仍在,清场不彻底。
  • C:reattach 抽到独立模块、order-persist.ts 仍整删(两者都要时走这条,工作量比 B 大)。

推荐:A——reattach 恢复的 persona fork 在 GA 下已不再产生,若 PRE-GA 存量 orphan lane 已清理/可丢弃,选 A 清场才彻底。

不决定的默认行为:PR 保持 open、不 rebase 合并(当前 rebase 必红);#5844 的 reattach 功能维持现状(仍可用,直到本 PR 落地)。

详见上一条 review 结论(八问 + #5844 交互细节)。

@ranxianglei
ranxianglei merged commit 328fdeb into master Nov 23, 2026
99 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1293-master.328fdeb (rolling master tag).

npm install -g billion-context@0.0.1293-master.328fdeb  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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.

1 participant