Repository navigation
feat(#2408): declare claude --fork-session lineage for scoped resume inheritance - #2409
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2617-pr.2409.16ab1faThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2409.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 收到,开始按 PR Review 规范审查本 PR(方向关 → 回归关 → 代码关 → 测试关 → diff 整洁度)。初查:单 commit、基于 |
[bot] 🏷 Review 结论(结构化八问) ① 是什么问题:#1486 的 unscoped content scan 已覆盖 byte-exact replay-fork,但留了个歧义缺口——同 proxy 内存在多条相同内容链时,tie-break 取「最近见过」,fork 会被误挂到 interloper 链上。本 PR 为 claude ② 什么原因导致的:根因是声明信号缺失,不是匹配算法缺陷——没有显式 lineage 时,unscoped scan 无法在多条同内容候选间消歧, ③ 影响范围与严重程度:目标场景是 claude fork + 同 proxy 多同内容链(现状会误链)。 ④ 怎么修复的:三层机制——(a) hook 层: ⑤ 是否回归问题:逐项审过,既有行为无破坏——
⑥ 是否破坏缓存:不涉及。prefix-cache 相关路径(system message 字节、稳定前缀)未动;继承只 seed refs/blocks 元数据,wire shape 不变。 ⑦ 是否改了设计方向:未转向。不动 §8 full fork protocol,平行加一条更弱的 declaration lane(PLUGIN.md §8 段落写清了边界:无 dead-ref namespace / 无 nudge inheritance / 无 receipt verification);kimi/zcode/hermes/codex 按 #2408 survey 结论明确不收,理由成立。 ⑧ 是否引入新配置:无。复用既有 其他审查项:
判定:拦下(blocked)。server 侧机制(scoped match / stickiness / 排序)审毕正确,但 hook 侧声明因 stdin 时序 bug 整体失效,功能主路径不工作,不能按现状合并。修法最小(drain stdin + entrypoint 回归测试),owner 拍板后继续(回复「继续」即可推进修复)。 |
…inheritance claude --resume <parent> --fork-session mints a fresh session id and replays the parent's wire history. The SessionStart hook now parses the parent off the claude host argv (UUID-tight) and posts an identity register with parentConversationId; the parent declaration is sticky across parent-less re-registers (MCP shim). The server scopes the #1486 resume-inheritance content match to the declared parent's chain (findResumeParentWithin) — disambiguating duplicate replayed content — and runs the match BEFORE the #1333 link so a hit takes the richer refs/blocks inheritance while a miss links read-only on the same first request (pi RLM timing unchanged). kimi/zcode (anonymous) and hermes (no parent signal) stay as-is per the survey in #2408.
hookMain() called run(payload) synchronously while Node only emits 'data' asynchronously, so declareForkLineage always received an empty string — the lineage declaration never fired on the real wire. Rework to hookMainWithDeps(): collect chunks, fire once on 'end'/'error' or a HOOK_STDIN_DRAIN_TIMEOUT_MS (2s) safety net, then run the full payload. Pinned by three regression tests (partial chunks, never-closed stdin, empty stdin); verified against a real claude --resume <uuid> --fork-session run declaring parent 6e772aa4.
c1e950e to
828da1e
Compare
|
Fixed in 828da1e (branch rebased onto master 51a4eee first). Root cause — exactly as reviewed: Fix: new Regression pins (3 new tests, red on the old code):
Real-binary verification (beyond the mocked seams): ran actual Touched-family suite green (claude-fork-lineage 9/9, 1333/native-binding/resume-adoption/plugin-fork/prefix-affinity 94/94); typecheck clean. CI running on 828da1e. |
[bot] 🏷 Fix commit 828da1e 已核对(结构化八问) ① 是什么问题:上一轮阻断缺陷—— ② 什么原因导致的:根因是「读值时机」——accumulator 的读取发生在同步调用点而非 drain 完成点。修复没有改 payload 内容(堵),而是把读取点移到 drain 后(疏): ③ 影响范围与严重程度:修复后主路径恢复——真实 ④ 怎么修复的:机制三层核对过——(a) 单次触发: ⑤ 是否回归问题:逐项审过——
⑥ 是否破坏缓存:不涉及。wire shape、system 字节、prefix-cache 相关性均未变。 ⑦ 是否改了设计方向:不涉及——修复完全落在本 PR 既定的 hook-declares/server-scopes 设计内,未扩大 lane 边界。 ⑧ 是否引入新配置:无。 CI:828da1eb3 上 28 job 已启动,目前 5 success、其余 queued/in_progress,无红。 判定:修复验证通过,可合——待 828da1e 的 CI 全绿即可由人工合并;唯一遗留是上述可选微 nit(常量导出的用途),不构成阻塞。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.148-master.de338aa # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2408
What
claude --resume <parent> --fork-sessionmints a FRESH session id while replaying the parent's wire history. Master's #1486 already covers byte-exact replay-forks via the UNSCOPED content scan, but the survey in #2408 showed the remaining gap: no explicit declaration, so a duplicate same-content chain elsewhere wins the tie (most-recently-seen) and mis-links the fork.This PR adds the lineage-only declaration lane from the #2408 survey (option "hook declares, server scopes"):
source: "fork"it parses the parent off the claude host argv (--resume <uuid>,--resume=<uuid>,-r <uuid>; UUID-tight,--continueyields nothing) and POSTs an identity register withparentConversationId(postIdentityRegister, same call opencode/pi/omp already use). Best-effort, non-fatal, compression mode only.queuePluginRegisteridentity entries now merge parent-sticky: a later register WITHOUT a parent (the MCP shim re-registering the same session) must not erase the fork declaration.findResumeParentWithin(parentId, messages, selfSessionId): the Claude 上 resume 导致消息错乱 #1486 head-anchored byte-exact judgement scoped to the declared parent's single chain (same rules: strictly deeper, ≥ MIN_RESUME_PREFIX).findResumeParentWithin), a hit takes the richer refs/blocks/lineage inheritance and the link gate (derivedFromSessionIdset) skips the redundant link, a miss falls back to the read-only link ON THE SAME first request. No deferral: pi RLM children (empty history, no replay) link exactly as before — [pi plugin] Prime RLM inline 派生子会话在代理模式下零继承:搜不到也解压不了父会话压缩块(billion-context-pi#531 同场景) #1333/feat: extend derived-session inheritance to remaining lanes (opencode V1, omp) — follow-up to #1333 #1362 behavior unchanged.Why not the other lanes
Survey result (#2408): kimi/zcode are anonymous (no conversation header — register can never bind, the #629 anonymous content net already covers them); hermes has a seam but no parent signal in its context (no key to read — not inventing one); codex reuses the same id on resume (nothing to adopt). claude was the only actionable lane.
Tests
tests/claude-fork-lineage.test.ts(6 tests): argv parse matrix, parent-sticky register merge,findResumeParentWithinmatrix, and three end-to-end runs through the real server (startServerport 0, mock upstream): declared fork inherits parent refs+block+lineage on the first request; declared parent BEATS a same-content interloper chain (the scoping win); non-matching replay links read-only with zero state copied. Regression families all green: resume-ref-inheritance, issue1333-derived-inheritance, plugin-native-binding, resume-adoption-wires, plugin-fork, prefix-affinity, dsh-persona-fingerprint, claude-subagent-split, opencode-acp-command, subagent-sessions, fork-adoption family (430+ tests across batches; only environmental port-occupancy failures on this machine, live bili lane holds 18787).typecheck ✅