Repository navigation
[PR] fix: isolate ZCode project_memory_extract onto a per-run child compression lane (#4952) - #4965
ranxianglei wants to merge 8 commits into
Conversation
…ssion lane (#4952) ZCode's background project_memory_extract loop reuses the parent conversation id (x-session-id) while appending worker-only tool messages, so both branches landed on one mutable compression session. When the main conversation resumed without the worker-only messages, the worker's blocks were orphaned and reaped. Split the worker onto a stable per-run child key derived from its explicit attribution (x-zcode-query-source=project_memory_extract + x-query-id): each extraction run gets an isolated lane while the raw parent key stays owned by the main session and upstream cache affinity is unchanged. The child adopts the parent's refs/blocks via copy-on-fork at birth (read-only lineage, no ongoing mutable sharing). Detection is explicit-attribution-only - it never classifies arbitrary requests or inspects prompt wording.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.7369-pr.4965.4185653This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4965.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) PR #4965 审核结论(八问)审核独立性:以下结论由我独立通读全 diff(3 文件 +415/-3)并逐路径核对代码得出;PR 正文仅作需求背景,未照抄其结论。 1. 是什么问题:ZCode 后台记忆抽取 worker 复用父会话 2. 什么原因导致的:身份绑定层缺口——既有分裂谓词不认 ZCode 的显式归因头,worker 落回父原始 key,与主会话共享 usage 基线 / 消息快照 / ref 分配 / orphan 计数器。根因 = 可变状态共享,reap 只是症状。修复方向(分裂到独立车道)打的是根因。✓ 3. 影响范围与严重程度:仅当三个归因头同时具备( 4. 怎么修复的(逐项核实):
5. 是否有回归问题:逐项清点既有行为——①非 ZCode 客户端谓词恒 undefined,零改动;②ZCode 主对话(无归因头)保持父原始 key;③#388 side-request 判定顺序不变(getSession 之后),其 body-shape 启发式被显式归因有意压过——注意:side 形态的带归因子调用会分裂到子车道(然后在那里 verbatim passthrough),test 3 钉住的正是这一点,与正文八问③一致;原「怎么修复的」一节写「side request 不分裂」与代码/测试事实矛盾,我已直接修正 PR 正文该句(PATCH 已生效,披露于此);④上游亲和不变;⑤无阈值/时序/输出格式漂移;⑥无 kernel/ 改动。未发现无意回归。 6. 是否破坏缓存:否。转发给模型的 7. 是否改了设计方向:否。沿用 KDD#9 copy-on-fork / persona-fork 机制,新增一条窄谓词 + 一个与 8. 是否引入了新的配置:无。完全头驱动,不加 env/config/CLI 面(符合 #2030)。 测试有效性:断言有牙——核心回归钉是「worker 回合后主会话 stats.requests 与 byRaw ref 集合前后逐字相等」(直接否定 reap 前提);另有负向/边界行(大小写、空 qid、缺父 id、array 形态、trim)+ e2e 对照(非归因保持原 key;归因压过 #388 启发式)。可接受缺口:copy-on-fork 收养(块继承)与 derivedFrom link 未在本套件直接断言(rig 历史太小触发不了压缩;两机制均既有且有各自覆盖)。 CI:head 判定:代码与行为审核通过、无回归、测试有牙;CI 红已定性为 flake 并重跑中。rerun 转绿后即可合并(合并动作留给人工)。 |
|
(ai: vllm-qwen/qwen3.8-27b) Merge-guard sync done: merged master @ 7f2e119 into this branch — clean, no conflicts (handle.ts changes from both sides touch disjoint regions); new head 985df8f, PR is now up-to-date with master (no longer behind); CI re-running on the new head with all guard gates green so far. |
…c to 30ec63b) # Conflicts: # src/server/handle.ts
[bot] 🏷 Why I stopped instead of resolving the conflictThe merge conflict in What I found
Why a mechanical merge is wrong here
So the branch cannot merge cleanly without a decision on which key scheme / detection wins. Options
RecommendationOption A. Master's fix is already merged and is the canonical, shipped solution; it uses the established Default if undecidedIf no decision is made, my default is Option A: resolve the merge keeping master's Please pick A / B / C (or direct a different path); I'll apply the chosen resolution and re-run the merge once you decide. |
[ework] auto-fix stalled: test (windows-latest, 22, 3), test (ubuntu-latest, 22, 2), test (ubuntu-latest, 24, 2) — stopping for human review |
[bot] 🏷
No code changes pushed — I'm holding for your A/B/C decision (A recommended: master's mechanism wins, PR superseded). Once you pick, I'll apply the resolution and re-run the merge. |
[ework] auto-fix stalled: test (windows-latest, 22, 3), test (ubuntu-latest, 22, 2), test (ubuntu-latest, 24, 2) — stopping for human review |
[bot] 🏷 Re-verified live this run — the situation is unchanged and still blocked on your A/B/C call (full options at the What I checked this run
So the conflict is exactly as before — two independent #4952 fixes (master's State
Holding for your pick — A (recommended: master's 八问(中文,供人工审核)
判定:本轮为状态复核 + 决策等待,无代码改动、无 push;冲突为设计决策,等 owner A/B/C 拍板后一次完成。 |
[ework] auto-fix stalled: test (windows-latest, 22, 3), test (ubuntu-latest, 22, 2), test (ubuntu-latest, 24, 2) — stopping for human review |
1 similar comment
[ework] auto-fix stalled: test (windows-latest, 22, 3), test (ubuntu-latest, 22, 2), test (ubuntu-latest, 24, 2) — stopping for human review |
(ai: vllm-qwen/qwen3.8-27b)
是什么问题
ZCode 后台的
project_memory_extract记忆抽取循环复用父会话 id(x-session-id)却往自己的历史快照里追加临时工具消息。billion 把两个分支都 key 到同一个可变压缩会话上——主会话恢复时没有这些 worker-only 消息,worker 的压缩块就成了孤儿被 reap(#4952)。什么原因导致的
身份绑定层的缺口:
src/session-id.ts只有 dsh persona / claude subagent / codex turn / instructions fingerprint 四条分裂谓词,没有任何一条认 ZCode 的显式归因头。ZCode worker 骑在父x-session-id上落回父原始 key,和主会话共享同一份 usage 基线 / 消息快照 / ref 分配 / orphan 清理计数器。根因是「可变状态共享」,reap 只是它的一个症状(不是去修 reap 本身)。影响范围与严重程度
仅当 ZCode 发出带
x-zcode-query-source=project_memory_extract+x-query-id+ 父x-session-id归因头的后台抽取请求时触发。本次事故只丢了 worker-local 块、主历史无损、缓存很快恢复(47%→87%→97%)→ 定为 p2。但机制面与 #4769(Claude subagent 反向 orphan-reap,p1)同属「辅助循环共享主身份」失败域——本 PR 只处理 ZCode 这一条 wire(OpenAI-compatible + 显式归因),不碰 #4769 的 Anthropic system-text 路径。怎么修复的
把 worker 分裂到一个稳定的按运行子 key
<parent>|zmem:<query-id>:x-zcode-query-source=project_memory_extract+ 非空x-query-id+ 客户端提供的父会话 id),绝不给任意other请求分类、绝不读 prompt 措辞(§2 KDD#9 evidence-per-client 纪律)。affinityToken继续消费 RAW client-provided 值 → 转发给模型的x-session-id仍是父原始值,child key 只用于内部会话路由,永不出现在 bili↔模型线上。一个已钉进回归测试的设计前提:
x-query-id在一次抽取运行内稳定、跨运行不同(见 issue 里向 reporter 确认的开放项)。若真实 ZCode 行为改成每模型调用铸新 query-id,child key 会按请求碎片化——此时每个 worker 回合各占一个极小子车道,不再共享状态(比现状 bug 安全),只是失去 run 内 fold 复用。优雅降级,不破坏正确性。是否有回归问题
审过的既有行为逐项:①非 ZCode 客户端(dsh/opencode/pi/codex/claude)——新谓词对它们恒返回 undefined,零改动;②ZCode 主对话(无 project_memory_extract 归因头)——保持父原始 key,不变;③#388 side-request passthrough——判定顺序在 getSession 之后,行为不变,且被显式归因有意压过(见上);④upstream affinity——不变(child key 不上线);⑤personaNamespace / split-canary——child key 无
|sub:子串且 stamppersonaNamespace=true,双重安全,不误报 drift。定向测试 52/52 绿(新套件 11 + dsh-persona-fingerprint / subagent-namespace / fork-side-request-lane / side-lane-truth-table / side-lane-invariants),typecheck 干净,基于当前 master rebase 后复验通过。是否破坏缓存
否。转发给模型的
x-session-id仍是父原始值,前缀缓存亲和连续;worker 块落在自己的子会话,不再污染主会话的缓存基线(这正是本 PR 要消除的副作用)。是否改了设计方向
否。沿用既有 copy-on-fork / persona-fork 机制(KDD#9),只新增一条 ZCode 专属窄谓词 + 一个与既有
|sub:并列的|zmem:命名空间。无架构转向。是否引入了新的配置
否(config surface):无新 env、无新 config 字段、无 CLI flag。分裂完全由请求头驱动,符合 env-var discipline(#2030)——不需要任何旋钮。
Kernel boundary:无
kernel/**改动(kernel-guard 不触发)。Review tier:人工审核——触碰 session-binding / message-ref 逻辑(§7.4,不可 auto-merge)。
Local test:仅跑定向测试(§7.2 本地测试纪律),全量回归交给 CI
test车道;pushed head =3f833f6d9,base = masterc499b1450。Closes #4952