Repository navigation
[PR] perf: Batch 2+3-1 consolidated — fingerprint change detection + ledger zero-hash inheritance + persona deprecation annot | perf: 批次二+三-1 合订 — 指纹变化探测 + 台账零哈希继承 + persona 退役标注 (#7149) - #7191
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10871-pr.7191.11724d8This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7191.tgz
npm install -g packageInstall instructions are refreshed on each push. |
ranxianglei
left a comment
There was a problem hiding this comment.
模型 qwen3.8-27b(provider sglang-gpu0)。自审记录(3 笔提交 + 2 项侦察负结果):
改动评审
632fdeccpersona 退役标注:纯注释。核查过生产引用面(session-resolve/plugin/side-request 均只有注释提及,零 import)+ 3 个特征化测试 pin(issue2944/issue2601×2),标注与事实一致,"删除需先拆 pin"的前提写明。bb95aaa9系统提示词变化探测:探针条件 =prev.fp !== "-" && 长度相等 && prev.head === 前256字节,命中复用、未命中全文算。核查点:(a) 消费方 cache-ledger.ts:1807/2019 只读.fp松散 cast,新增head字段无影响;(b) 旧格式元数据(无 head)自动走全文路径,无崩溃面;(c) 文档化权衡(256 字节后同长改写不观测)写进代码注释;(d) 有→null 从"不记日志"变为"记一条"是有意行为变化,测试与 PR 说明均已注明。41a5acd1台账零哈希继承:sameBytes要求字节数相等 +prior.full存在 +Buffer.equals纯字节比较。关键正确性核查:继承的 digest 必然等于独立全文哈希(同字节同摘要),所以bd地面真相语义、:2052的 be 判定、msgs/keyFp/effFp继承链全部等价;变化体仍走全文哈希路径,#2131 证明能力不受影响。新增测试直接断言"继承值 == 独立算的 sha256"。
负结果复核
- 插件 wireHash:重新跟了一遍
preparePluginWireMetadata→handle.ts:3608(唯一生产调用方)→publicSnapshotWireHash的引用相等短路链,确认每请求一次哈希;重哈希分支确实只服务测试/未来调用方。 - 验章 JCS:
evaluateChain的 digest MATCH 是多实例防篡改的恒等证明(源码注释原话已引在 PR 描述),换任何"只看结构不看全文"的摘要都会削弱它;且打戳/验证双门控在 chainArtifacts 车道。结论:不改是正确的。
验证:tsc 0 错;7 个相关测试文件 132/132 绿。与 #7151 无文件交集冲突面(fold-reconcile.ts 本分支只动两个 note* 函数)。
…nned only (#7149 batch2)
…size+head change (#7149 batch2) noteSystemPromptFingerprint (#1921) and noteCanonicalSystemFingerprint (#2867) now keep a 256-char head probe in session metadata. Unchanged prompt (size + head match) reuses the stored fp instead of re-hashing the full JSON.stringify'd text each request; changed / first-turn / legacy-shape stored values fall through to the full hash, so the stored fp is always a true full-hash value whenever it is computed. Semantics preserved: #1921 change ledger log, #2867 silent-twin pairing, "-" sentinel for absent prompts. One new observable: a prompt WITHDRAWAL (prev non-"-" -> null) now logs as a change (the projection dropped). Documented tradeoff: an edit beyond byte 256 that preserves length+head stays unobserved — the probe is a detection signal, not a boundary. Tests: fold-reconcile.test.ts +5 cases (probe hit / tail-only documented contract / visible change / legacy {fp,size} compat + head backfill / null sentinel delta counts); 92/92 across fold-reconcile + both cache-ledger prompt-switch consumer suites.
…st (#7149 batch3-1) The non-streaming settle path re-notes a byte-identical wire body; detect that with a pure byte compare (prior.full.equals) and inherit the prior digest — zero hashing on the common path. Changed/new bodies keep the full-body sha256: bd is the #2131 ground-truth equality proof and the only equality proof once the payload exceeds BODY_FULL_CAP (no retention), and tests pin bd to the full digest. The send chokepoints hold the wire string, not the stored canonical views, so view-ID anchoring is not available here; the delta-anchoring value is the hash-free identity inheritance.
…ysFp now persist the 256B change-probe head (#7149 batch2) Persisted-state digests only; every per-turn wire sha is byte-identical to the previous goldens. Field-level diff (master vs branch, anthropic drive): state/blockContents/stats identical; metadata.systemFp gains { head: <first 256 chars of the JSON-stringified system prompt> } with fp/size unchanged (verified by dumping both states and diffing).
41a5acd to
f357310
Compare
…etion prerequisites (#7149 batch2) The RETIRED header added in 632fdec named only 2 of the 4 test files that import this module (issue2944-neutral-skeleton, issue2601-model-drift-absorption). tests/issue2601-persona-fork-lineage. test.ts and tests/dsh-persona-continuity.test.ts also import it — a future deleter following the header would break those two suites. Drive-by fix found during review of the rebased head.
[bot] 🏷 查重: 不重复 — 本 PR 是 #7149 提案的批次二+三-1 实现;批次一(R1/R6 重复哈希)在 #7151,与本 PR 无文件交集(fold-reconcile.ts 本分支仅动两个 note* 函数)。 审核结论: 可合 — 新 head 结构化八问
审核期间的动作
判定: 可合 —— 代码审核(3 个内容提交通读)+ 本地验证(黄金套件 17/17、PR 目标文件 204/204、typecheck 0 错误)+ CI(37 success / 13 skipped / 0 failed)全部通过。合并留给 owner。 |
…nder golden conflict Master's hash-cleanup batches + kernel 0.0.200 bump (#7149/#7151/#7191/#7281) regenerated the storage-render goldens; the PR's lastFoldDrift field also touches them. Regenerated from the merged code so the snapshots reflect both; golden suite 5/5, PR test 3/3, typecheck clean. Built on the concurrent comment-fix commit 0cae5a0.
性能清理 · 批次二+三-1 合订(#7149 提案)
模型
qwen3.8-27b(providersglang-gpu0)实现,提案见 #7149 。批次一(重复哈希 R1/R6)在 #7151。改动(4 笔独立提交,可单独回退)
1. persona-anchor 退役标注(
docs(persona))2. 系统提示词指纹 → 变化探测(
perf(fold-reconcile))noteSystemPromptFingerprint(Fold-state reconciliation: classify resent-history divergence (edit/fork/new/system-only) and make compression blocks re-anchorable chain units #1921 变更台账)/noteCanonicalSystemFingerprint([Bug] Responses self-heal 切换投影规则后,提示词指纹变化被误归因为宿主改写 #2867 自愈配对):长度 + 前 256 字节没变 → 复用上次指纹,跳过全文 SHA-256;变了/首次/旧格式元数据 → 全文算fp仍是每次实算时的真值;Fold-state reconciliation: classify resent-history divergence (edit/fork/new/system-only) and make compression blocks re-anchorable chain units #1921 变更日志、[Bug] Responses self-heal 切换投影规则后,提示词指纹变化被误归因为宿主改写 #2867 成对指纹消费方(cache-ledgercanonicalSysFpForSettle/ [cache-ledger] fold-reconcile 检测到宿主侧系统提示词改写但未接入归因:prompt 改写被误归入未归因 TTL 残差 #2350 baseline)只读.fp,不受影响3. 台账出站体 digest → 相同重复 note 零哈希(
perf(cache-ledger))noteForwardedBody:字节相同的重复 note(非流式结算路径的文档化常见场景)→ 纯字节比较继承上次 digest,热路径零哈希bd是 大量缓存接缝事件导致缓存命中率大幅度降低 #2131 的字节相等性证明、超 8MiB 不保留全文时唯一的地面真相(测试钉死)4. 黄金快照再生(
test(golden),见下节论证)侦察负结果(2 项,逐行验证后确认不改,记录防重复讨论)
插件车道 wireHash(第三-1 的其中一处):生产路径每请求只哈希一次(
handle.ts:3608唯一调用方传预制备的元数据;重哈希分支是测试/未来调用方兼容)。"视图 ID 结构锚定"落不了地:输入是原始入站 body,该时点规范视图不可得且变换不同。chain-checkpoint 验章 JCS(第三-1 的另一处):digest 是整段 body 字节身份证明(多实例中继/重放防篡改:"a digest MATCH proves identity… never trust a newer forged timestamp over a verified digest"),换结构化摘要会削弱证明本身;且打戳/验证都在
chainArtifactsEnabled配置门控的专用车道,非主流量。tag 已带v=版本字段,将来真要做有现成兼容机制。黄金快照再生的正当性(f357310e,已 rebase 到最新 master a446a3c)
CI 首跑 5 个分片红,两族黄金测试(storage-render golden ×4 wire + storage-engine-proofs "full-mode restart is invisible" ×4 wire)。定位:master 在基线之后合并了 #6827 并把黄金快照再生到
75a45380(本分支基线之前没有),merge ref 上"master 的新快照 vs 本分支代码"失配。本地用正确 kernel 复现后形状干净:四条 wire 只有 metadata section 漂移。字段级实证(anthropic drive,master 基线 vs 本分支完整状态 dump diff):
state/blockContents/stats三段完全相同metadata.systemFp仅多一个字段:{fp: "f1c4e23132875dea", size: 27, head: "\"You are a test assistant.\""}← fp/size 逐位相同,head(JSON 序列化 system prompt 的前 256 字符)是变化探测(b18d5967)的设计内新增再生 diff:4 个文件各 3 行(stateDigest / stateDigestAligned / metadata section digest),所有 per-turn wire sha 字节级不变——与 master 侧
75a45380同模式("wire shas unchanged, persisted digests only")。实现级偏差(相对提案"视图 ID+差值"表述,如实记录)
提案里"哈希输入 MB→KB"对三处的适用性侦察后修正:台账这处调用点在发送 chokepoint(手里只有 wire 字符串,规范视图在存储层入库、时点不可得),落地为"相同重复 note 零哈希继承 + 变化体保留地面真相哈希";插件与验章两处如上述负结果。真正兑现"视图 ID 引用化"需要把台账/快照/验章的输入从 raw body 切到存储层视图——属于批次三-2 级别的方案对齐范围,本 PR 不做。
验证
tsc --noEmit0 错误明确不动