Repository navigation
[PR] fix: persona conversation keys survive proxy restarts; management calls follow the fork holding cited refs (#3397) - #3405
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4296-pr.3405.2855801This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3405.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本 PR 是 #3397 的修复交付(单 commit,head 开始 review:拉分支核对代码 → 定向测试 → CI 状态 → 按八问给结论。注意:改动落在 persona/会话身份路由(load-bearing,§7.4 human-only merge 域),我只审不合。 |
… redundant parse (#3405 review) Review clean-up on #3405: hydrateOrderSkeletons() assigned a JSON.parse result to an unused var whose only effect was throwing on a corrupt file (surfacing the warn via the catch). Route through readDiskEntries()' null-vs-empty contract so the corrupt-file warn is explicit and the file is read once instead of twice. No behavior change: missing=no-op, corrupt=warn+empty (next flush heals), valid=import.
(ai: vllm-qwen/qwen3.8-27b) 结论:可合(人工合)。 代码正确、两个机制都打到根因、无回归;唯一红是 Windows 上一个与本 PR 无关的已知抖动测试(#3259),新 head CI 正在重跑确认。我已在本 PR 分支补了一个已验证的清理 commit( 审核独立性声明:以下八问是我独立读 PR head 的 diff、跑定向测试、查 CI 得出的,不是照抄 #3397 的结论;#3397 只作需求背景读。 ① 审原 issue(方向) #3397 = 长 dsh 会话 compress 永久失败、新会话没事。作者定位 F1/F2 两个复合机制,方向对:F1 是根因(persona 锚点只在进程内存,重启后冷启动竞态翻转主对话的 key → 积累的 refs/blocks 被孤儿化),F2 是放大器(#2601 无 witness 兜底按「最近活跃」挑 fork,dsh 高频 sidecar 永远赢)。修的是根本原因,不是表面现象。✓ ② 回归审查(既有行为逐项)
③ 代码审查 逻辑正确:持久化复刻 affinity-persist 全套机制(debounced atomic fsync-before-rename、LRU+字节预算、fresher-wins 合并避免跨进程整文件覆盖);tag→sha256 让记录不随 system 文本长度膨胀,lane key 仍用 fp16(tag)(纯 tag 函数→重启稳定)。错误处理完整(坏文件降级+下次 flush 自愈)。无 ④ 测试有效性 真测试非假测试:F1 走真实持久化往返(flush→模拟重启→hydrate),含 pre-fix flip 特征刻画;F2 用真实 proxy rig 镜像 #2601 suite,断言 cited→owner fork / uncited→recency fallback(带 ⑤ diff 整洁度 6 文件每行都服务 F1/F2,无跑题文件、无锁文件 churn、无大段空行重排。干净。✓ 我的补充(commit CI: 原 head 八问:
收工判定:可合。 代码正确、根因到位、回归安全、测试有牙、diff 干净;唯一红是无关已知 flake(新 head 重跑中)。按 §7.4 属身份/会话绑定 load-bearing,由人工合——等 windows-22-1 那片转绿即可合(预期绿)。 |
(ai: vllm-qwen/qwen3.8-27b) CI 更新(新 head 结论维持:可合(人工合)。 代码/回归/测试/diff 均过审,CI 实质全绿。按 §7.4 身份/会话绑定 load-bearing 由人工合即可。 |
(ai: vllm-qwen/qwen3.8-27b) 交叉备注(来自 #3648 审核):#3648(「active parent 门禁」,已审核可合)把 |
…route management calls to the fork that holds the cited refs (#3397) The session-order resolver's recorded skeletons were process memory, so every proxy restart re-ran the cold-start race: whichever lane arrived first under the host id (the main conversation vs a tagged shallow sidecar request, e.g. dsh's auto-review blob) claimed the raw key, and the winner FLIPPED across restarts. When the main conversation lost, all accumulated compression state (refs/blocks) stayed under the key it lost; resends then cite refs that exist only in the orphaned generation and compress fails forever while brand-new sessions work fine (#3397). F1: persist the recorded skeletons to session-order.json using the affinity-persist mechanics (debounced atomic write with fsync, merge-with-disk fresher-wins, LRU + byte budget, hydrate on boot, flush on shutdown/in-process restart). Tag comparisons move to sha256 hashes so persisted records stay small regardless of system-text length. F2: #2601's no-witness management-call follow picked the MOST RECENTLY ACTIVE |sub: descendant. dsh's chatty sidecar persona fires every few seconds while the owner conversation idles, so the follow chased the sidecar's small ref space and died there. When tool args cite refs (mNNNNN), prefer a descendant whose minted ref space can contain them; no citation or no fit keeps the recency pick (byte-identical pre-fix behavior in those cases). Behavior changes (disclosed): - persona/conversation key resolution is now restart-stable (was: cold-start race decided it per boot) - management-call fallback routing: raw-recency pick -> ref-space-fit pick when args cite refs (identical otherwise) - new persistence file <state>/billion-context/session-order.json; no new config/env surface Tests: tests/issue3397-persona-restart-stability.test.ts — restart-stability through the real persistence round trip, aux-lane isolation across restart, snapshot hygiene (fresher-wins merge, corrupt-file degradation), and an e2e ref-fit routing rig mirroring #2601.
… redundant parse (#3405 review) Review clean-up on #3405: hydrateOrderSkeletons() assigned a JSON.parse result to an unused var whose only effect was throwing on a corrupt file (surfacing the warn via the catch). Route through readDiskEntries()' null-vs-empty contract so the corrupt-file warn is explicit and the file is read once instead of twice. No behavior change: missing=no-op, corrupt=warn+empty (next flush heals), valid=import.
70b4c32 to
274470b
Compare
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved. Rebased The one conflict hunk ( Verification on the rebased head: 结构化八问
判定:冲突已清,PR 恢复可合并状态;等 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.641-master.78e5b58 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3397
Problem
A long dsh session's compress calls failed forever ("every ref is unknown to this session" / "All requested refs are above this session's highest ref") while brand-new sessions worked fine. The reporter's v0.1.197 log shows two mechanisms compounding into one symptom family:
F1 — restart race orphaned the accumulated compression state (root cause). The session-order resolver's recorded skeletons (
src/session-resolve.ts) were process memory. Every proxy restart re-ran the cold-start race: whichever lane arrived first under the host id — the main conversation or a tagged shallow sidecar request (dsh's auto-review blob carries its own system) — claimed the raw key, and the winner FLIPPED across restarts. When the main conversation lost, all refs/blocks minted while it lived on its|sub:lane stayed there; post-restart it ran on the near-empty raw key, resends cited refs that existed only in the orphaned generation, and every compress failed forever. New sessions had no orphaned state → "新会话反而没事".F2 — #2601's no-witness follow chased the chattiest fork. When a host-stamped management call resolved to a stale parent with no outbound witness,
livePersonaDescendantpicked the MOST RECENTLY ACTIVE|sub:descendant. dsh's review persona fires every few seconds while the owner conversation idles, so the follow landed on the sidecar's small ref space (log: 01:43:24 + 02:05:24 routed to…|sub:1ee4…— highest ref m00313, 0 blocks → FAILED; 01:56:51 routed to the owner via lineage witness → SUCCESS).Fix
<state>/billion-context/session-order.jsonusing the affinity-persist mechanics (debounced atomic write with fsync, merge-with-disk fresher-wins per id, LRU 1024 entries + 8 MiB byte budget, hydrate at boot, flush at shutdown and both in-process restart paths). Tag comparisons move to sha256 hashes so persisted records stay small regardless of system-text length. Resolution is now restart-stable: the main conversation keeps its key, sidecars keep their lanes; deep records still keep aux blobs off the raw key.mNNNNN), the no-witness follow prefers descendants whose minted ref space can contain them; no citation or no fit → the recency pick (byte-identical pre-fix behavior in those cases). Content-blind, no per-client special cases.Behavior changes (disclosed)
|sub:descendantsession-order.json(warn-only on I/O failure)No config/env surface added. No wire/protocol change. No
kernel/change.Verification
tests/issue3397-persona-restart-stability.test.ts: F1 pinned through the REAL persistence round trip (flush → simulated restart → hydrate), including a characterization of the pre-fix flip; aux-lane isolation across restart; snapshot hygiene (fresher-wins merge, corrupt-file degradation); F2 e2e through a real proxy rig mirroring the [Bug] dsh 会话反复 model/provider 切换时主对话迁移到 |sub:<fp> persona fork,宿主盖章的 compress/decompress/acp_status 仍解析在陈旧父 id —— ref 跨空间不可解析直至熔断 #2601 suite (cited refs → owner fork; uncited → recency fallback).npm run typecheckclean;npm run buildgreen. Full-suite verdict = CI on this head (§7.2).Out of scope (tracked separately)
The same log also contains
[storage] unified shadow DIGEST DRIFT … migration parity brokenerrors (the reporter runs BILI_STORAGE_UNIFIED shadow mode, so severity is telemetry-only). Different symptom AND different mechanism (unified-storage migration parity, not persona identity) → filed as its own issue with a 来源 marker rather than bundled here.