Skip to content

[PR] fold anchoring doctrine: order over hash — shape churn, image offload, host truncation stop reading as destruction (#3641) - #3644

Merged
ranxianglei merged 15 commits into
masterfrom
2026-10-18_unresolved-anchor-placement
Oct 18, 2026
Merged

ranxianglei merged 15 commits into
masterfrom
2026-10-18_unresolved-anchor-placement

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Fixes #3641. Fixes #3588. Fixes #3640. Fixes #3642.

What was broken

Three real-world defect classes, one shared root — fold identity keyed coverage to content hashes, so any transformation that re-mints ids WITHOUT removing content read as destruction:

The fix (snapshot-as-session doctrine, Stage A+B+C one-shot)

  1. Shape tier (planReconciliation): prose cells re-anchor on loose word evidence (wordbag digest equal + simhash hamming ≤ 8 + role/length guards); evidence-less cells (image families) re-anchor through a flanked k-th discipline — contiguous runs in the previous wire order, paired with unclaimed candidates strictly between the same two VERIFIED flanks, counts exactly equal. Both flanks mandatory: a run touching either end of the wire order is unpairable (guessing, not evidence).
  2. Residual census: still-unmatched class-carrying ids classify as transformed (near-duplicate evidence exists) vs absent-everywhere (content truly off the wire).
  3. Verdict classifier: transform churn and wire-suffix-continuation truncation (surviving wire = tail of the episode baseline, inbound = its continuation) never accrue the collapse streak — one benign info latch each per session instead.
  4. Episode witness: the wire order is frozen at episode start and persisted; a foreign conversation sharing nothing with the witness can never quietly become the truncation baseline mid-episode.
  5. Epoch confirmation: a genuine total collapse latches foldEpochConfirmPending and pauses folding — verbatim passthrough, snapshot kept, nothing deleted — until the histories realign (automatic) or the user confirms a new epoch. The old "compression substrate appears destroyed" error becomes "fold epoch confirmation required: …". Detection itself stays intact ([Bug] 旧版账本里的遗留锚被当作漂移证据,长会话被永久判为「折叠基底打穿」(0.1.194 / 0.1.195) #2903 honesty tests unchanged).
  6. Kernel placement (prune.ts): unresolved summary anchors clamp ahead of the newest user turn instead of the array tail — the [Bug] User questions are silently ignored — unanchored fold blocks land after the latest user turn (0.1.197 / 0.1.199) #3640 "stale summary after the question" shape dies at the source.

What deliberately did NOT change

Verification

  • tests/fold-anchor-doctrine.test.ts 6/6 — each defect class as a pinned behavior (protocol switch, offload family, truncation, epoch-confirm + auto-recovery on realignment, honesty gate, preflight gate).
  • Families: fold-drift 7/7, fold-reconcile 66/66, fold-reconcile-positional 24/24, issue2915 15/15, perf 2/2, round2-shape 1/1, 1908/1987/2033/2601/1595/1820/1569/images-archive/refold all green; kernel state-prune 22/22 (kernel rebuilt).
  • Two positional-test expectations were updated ON DOCTRINE (sanctioned compaction no longer starts the streak; the compacted case now expects the benign truncation latch) — noted here for review visibility.
  • tsc clean, unused-export gate clean.

kernel-change: unresolved summary anchors clamp ahead of the newest user turn instead of the array tail (#3640) — kernel/src/prune.ts placement only, no state-shape or protocol change; kernel/tests/state-prune.test.ts +2 tests, 22/22.


Scope note (post-#3658 merge)

PR #3658 (protocol-stable core identity, #3642) was merged INTO this branch (its base), so this PR now carries BOTH bodies of work: the fold anchoring doctrine AND the canonical cross-protocol identity — plus the four review follow-ups pushed directly to the branches (opening-run multimodal pin, leading/trailing opaque parts, non-array content tolerance, warn-once image-index visibility). Merging this single PR lands everything; full-matrix CI ran green on the combined head (23 pass / 0 fail, run 39115262095) and the master (v0.1.200) merge conflict was resolved and re-verified locally (tsc 0, 130 tests across the touched families).

…3640)

Three real-world defect classes shared one root: fold identity keyed
coverage to content hashes, so id re-mints without content loss were
read as destruction.

- shape tier in planReconciliation: loose word-evidence pairing for
  prose cells (wordbag equal + simhash hamming <= 8 + role/length
  guards), flanked k-th discipline for evidence-less cells (image
  families, #3588) — claims require BOTH flanks verified on the wire
- residual census: unmatched class-carrying ids classify as
  transformed (near-dup evidence exists) vs absent-everywhere (content
  truly off the wire)
- verdict classifier: transform churn and wire-suffix-continuation
  truncation (host compaction/windowing, #2695) never accrue the
  collapse streak; one info latch each per session
- episode witness: wire order frozen at episode start; a foreign
  conversation can never become the truncation baseline mid-episode
- total collapse now latches foldEpochConfirmPending and pauses
  folding (verbatim passthrough, snapshot kept) until realignment or
  explicit user epoch confirmation, replacing the destroyed-escalation
  misdiagnosis; detection intact (#2903 tests)
- unresolved summary anchors clamp ahead of the newest user turn
  instead of the array tail (#3640 "model answers stale summaries")
- single genuine edits below the mass bar still report drift honestly

Tests: tests/fold-anchor-doctrine.test.ts 6/6; families green
(fold-drift 7, fold-reconcile 66, positional 24, issue2915 15, and
the 1908/1987/2033/2601/1595/1820/1569/images-archive/refold set).
@ranxianglei ranxianglei changed the title fold anchoring doctrine: order over hash — shape churn, image offload, host truncation stop reading as destruction (#3641) [PR] fold anchoring doctrine: order over hash — shape churn, image offload, host truncation stop reading as destruction (#3641) Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-18_unresolved-anchor-placement (284d678)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4353-pr.3644.972b930

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重结论:不重复(同家族、不同机制)。 正在做独立全量 review(正文无 ework-agent-pr 标记,按外部 PR 从严审)。

⚠️ 两个先摆到台面的关注点(详审后给八问结论):

  1. 热文件争用:本 PR 与在途 [PR] fix: re-anchor folded history across host wire-shape flips (#3301) #3316 都改 src/fold-reconcile.ts,存在语义交互/合并冲突风险,需确认两者 reconcile 改动是否正交。
  2. 方向一致性:owner 在 [PR] fix: re-anchor folded history across host wire-shape flips (#3301) #3316 里明确否掉了「运行时形态猜测」。本 PR 的 shape tier(wordbag digest + simhash hamming≤8 + flanked k-th)我要逐行核对它是「顺序为主的分类佐证」还是变相把被否的猜测捡回来。
  3. kernel 门禁:正文尾部 kernel-change: unresolved 看起来是占位符而非真实理由——kernel-guard CI job 大概率会红,且 kernel 变更需 owner 事前专门 issue 批准。这点我会核实。

完整八问结论稍后发。

… change (#3644)

CI-fix additive commit: the kernel-guard job enforces that any change under
kernel/src/** carries a kernel/package.json version bump (Kernel Boundary
rule 2, AGENTS.md). The placement fix in kernel/src/prune.ts landed without
it, so kernel-guard failed and the test matrix was skipped.
@ranxianglei ranxianglei added the ci:full Run the FULL CI matrix (all e2e lanes + 12-leg test matrix) on this PR label Oct 18, 2026
…3644 kernel version bump)

The a9fe72f kernel bump moved kernel/package.json to 0.0.131 but left the
file:./kernel resolution in package-lock.json at 0.0.130, so the lock-sync job
(npm install --package-lock-only && git diff --exit-code) drifted red and gated
the test matrix. Regenerate the lock record so it matches.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

(ai: vllm-qwen/qwen3.8-27b) 完整独立审核完成(不是复读 issue 结论)。先交代我已做的事,再给结构化八问 + 发现的问题清单。

我已经做的动作


结构化八问

  1. 是什么问题:PR 把 fold 身份从「内容哈希为覆盖键」改为「顺序优先、哈希为辅」,让三类真实缺陷——[dsh 0.2.0-rc.2] image-offload history rewrite breaks fold refs, triggering false “substrate destroyed” verdicts (bili 0.1.197) | [dsh 0.2.0-rc.2] image-offload 改写历史内容导致 fold ref 失配 → compression substrate appears destroyed(bili 0.1.197) #3588 图片卸载占位替换、[Bug] User questions are silently ignored — unanchored fold blocks land after the latest user turn (0.1.197 / 0.1.199) #3640 中途协议切换重铸 id、[Bug][proxy] unframed host-side history deletion leaves zombie fold blocks rendering carriers forever — one carrier flaps in/out every turn (persistent prefix-cache churn) #2695 宿主截断——不再被误判成「压缩底座被摧毁」。本次是审这个 PR。
  2. 什么原因导致:fold 覆盖率以前按消息内容哈希 id 记账;任何「重铸 id 但不删内容」的转换(占位替换、协议重序列化、截断)都让旧哈希对不上 → reconcile 判 totalDrift → 累积 collapse streak → 误报 destroyed。修法方向正确:加 shape 层做松散重锚 + 给 verdict 加两个 benign 类(shape churn / wire-suffix-continuation truncation),真·全毁才进 epoch-confirm 暂停折叠。
  3. 影响范围与严重程度:影响所有走 proxy 压缩、且会话中途发生 id 重铸/截断的用户面。属「特定条件下严重」——尤其 [Bug] User questions are silently ignored — unanchored fold blocks land after the latest user turn (0.1.197 / 0.1.199) #3640 有个致命次生症状:未锚定摘要落到 insertAt=messages.length(数组尾、骑在用户最新问题之后),模型连答五轮过期摘要。
  4. 怎么修复的(机制层):(a) planReconciliation 加 shape 层:prose 用词袋摘要相等 + simhash hamming≤8 + role/长度守护,image 家族用 flanked k-th(两侧必须是已验证 flank、计数精确相等);(b) verdict 分类器把 shape/truncation 归 benign,不进 streak;(c) episode witness 冻结基线,防外来对话冒充截断基线;(d) 真·全毁 latch foldEpochConfirmPending → preflight passthrough 暂停折叠,直到重新对齐或用户确认新纪元;(e) kernel/prune.ts 未解析摘要锚点钉在最新用户消息之前而非数组尾。
  5. 是否有回归问题:逐项核过既有行为——[dsh] 原生压缩拦截门的 SHAPE 信号(≤4 条消息)在 dsh-compaction-basic 0.2.0-rc.2 上恒假 → 压缩静默落地 → 1510 条 fold 锚点永久失配,连刷 166 条 no-anchor-match 且面板仍报 netSaved 355.9M #2193/[Bug] #1001 归因缺口:客户端原生压缩落地后只剩「未确认档」——bili 已记录的 17 次拒绝(dshCompactionRefusals)与 10 次 DIRECT 旁路未被用于归因 #2709 升级机器保留(只是 totalDrift 输入多两个排除项;issue2915/positional 测试只改了报错字符串、没改语义);honesty gate 有测试钉住(低于 mass bar 的单条编辑仍诚实报 drift);dshLedgerFloorTokens 未动;z-suppression 健全(真正的外来替换过不了 wireContinuity,reap 仍会触发)。三处行为变更 PR 正文都已披露(见 Q7)。未发现无意回归。
  6. 是否破坏缓存:不涉及 prefix-cache / 重试 / 增量游标 / 去重键。新增的几个都是内部 metadata key(foldEpochConfirmPending 等),不在缓存失效面。
  7. 是否改了设计方向:是,两处。(一)从「哈希为覆盖键」转向「顺序为主、哈希为辅」(KDD#11 的延伸,符合 Snapshot as session reconstruction: identity claim order takes priority, message hash demoted to reference signal (root- | 快照即会话重构:身份认领顺序优先,消息哈希降级为参考信号(根治 #3588/#3640 一类误判) #3641 定的 doctrine)。(二)引入新终局行为:真·全毁原来继续报错,现在改为暂停折叠 + passthrough 等确认——这是产品级行为变化,PR 已披露。⚠️ 范围标签夸大:PR 自称 "Stage A+B+C one-shot",但实际只做了 Stage A + shape 层扩展 + verdict/witness/epoch;Stage B(seq 重键)没做(coverage 仍按重铸后的哈希 id 记账,测试断言 effectiveMessageIds.some(id.startsWith("g1_")) 就是证据),Stage C(对齐前门)也没做(现有 tier 仍是原顺序跑、shape 层追加在最后,而非降级为佐证)。请 owner 确认这是有意收敛还是漏项,剩余 B/C 是否单独跟踪。
  8. 是否引入新配置:无。没有新 env/config/CLI flag;新增均为内部 metadata key,config-surface-guard 已通过。

发现的问题(按优先级)

[质量·最高] #3640 旗舰测试没咬住头条机制。 该测试是「协议切换不再误报 destroyed」的回归测试,但它的断言(不升级 + coverage 重键 + 下一轮安静)在没有 shape 层的情况下也会全绿。机制:fixture 的 reshape 把每个空格换成 \n(奇数 i)或 (偶数 i);而 normalizeMessageText(src/fold-reconcile.ts:451-460)会把水平空白串折叠回单空格、但保留 \n。于是偶数 i 的格子规范化后字节相同 → 被既有的 normalized-identity 通道认领;奇数 i 的格子 covered 里只有 idx 1/3/5/7 共 4 个,低于 FOLD_DRIFT_ESCALATE_MIN_UNMATCHED=10,且 byNorm 保住 claims.size>0 使 totalDrift=false。⇒ 最坏情况下整段删掉 shape 层,这个测试照样绿。它无法区分「shape 层在 / 不在」。修法:断言 r.byShape > 0,并放大 fixture 让「仅 shape 层能救」的格子数超过升级阈值(这样只有 shape 层在才能避免 destroyed 判定)。这是 §7「测试有效性」的硬伤——头条缺陷的回归测试没钉住头条机制。

[质量] 贪心配对有误配风险。 prose shape 配对是贪心取「第一个未占用的 loose 候选」(wordbag 相等 + simhash≤8)。真实大规模 churn 下,重复样板会共享 wordbag 摘要,可能交叉错配。KDD#11 明说误配是最贵的失败。目前缺一个对抗性回归用例(构造两个 wordbag 摘要相同但内容不同的 cell,验证不会跨配)。

[治理] kernel-change 声明是占位符。 body 结尾 kernel-change: unresolved 不是真理由——Rule1 的 grep 机械通过了,但失去了声明的本意。建议改成引 #3641 Stage A①(它字面指定了这个 unresolved-anchor placement)。owner 预批准基本满足(#3641 四条已拍板边界 + Stage A①)。

[小] 注释与实现不符。 epochConfirmPending 的 doc comment 说消费者含 "status panel",但本 PR 只接了 preflight。要么接上面板,要么把注释收窄。

[CI·已处理] 见上:kernel-guard(作者已修)→ lock-sync(我已 push 0825bdea8 修)。


收工判定

方向正确、机制扎实、行为变更披露充分、无发现无意回归。可合的前提:① 人工合并(§7.4:触 kernel/ 一律不能 auto-merge);② CI 在 0825bdea8 上全绿;③ 强烈建议合并前补 #3640 测试的 byShape>0 断言 + 对抗性 wordbag 用例(否则头条机制没有真正的回归兜底);④ 澄清 Stage A/B/C 范围标签(Q7)。

要我把第③点的测试加固直接推到 PR 分支吗?我可以写断言 + 扩 fixture(本地无 tsx 装不了没法先验跑,会以 CI 为准验证 byShape>0 成立)。你点头我就动手。

@pkuqiuning

Copy link
Copy Markdown

Correction to two numbers quoted in the PR description (they originate from my own earlier comment on #3640 — my measurement error at the time, corrected here so it doesn't propagate):

  1. "~298 ids at 96.2% text overlap" for the /chat/completions → /v1/messages switch — the real numbers: the largest drift line for that event is 41 covered ids missing (1427/1468); the "destroyed" verdicts across the session were 16 / 63 / 62; and a fair same-structure comparison across the two wire shapes gives ~68% identity (782/1146), not 96.2% — tool-call args are stringified differently per protocol (function.arguments passthrough vs safeStringify(input)), which alone re-mints every tool id.
  2. That protocol-switch event self-healed (next-day drift back to 14, tail blocks 0–2 for the following three days). The event that actually produced the tail-riding blocks was a same-wire host byte edit ~26h later: the host agent layer re-stamped 61 historical user messages with (respectively removed) <system-reminder> suffixes within one minute — same protocol, same model, pure text mutation → the six affected tier-1 blocks lost all their direct anchors at once.

So for the shape tier: the production-dominant transform class in our data was "same-wire, same-role, bulk suffix edit on user texts", not cross-protocol reshaping. The flanked k-th discipline should cover it, but the census may want to count "same-wire re-stamp" as its own class — it presents as 61 near-identical pairs differing only by a stable trailing suffix.

…on (#3644)

The docstring named 'status panel' as a consumer, but only the preflight
fold gate reads epochConfirmPending in this PR. Narrow the note so it does
not promise an unimplemented panel integration.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) 补一条:上一条 review 里 [小] 那条(epochConfirmPending 注释把「status panel」列为消费者,但本 PR 实际只有 preflight 读它)我按「小问题直接修」顺手改对了——收窄注释到真实消费者,一行、零行为变更,commit 1a3949a14(在 lock-sync 0825bdea8 之上)。现在 PR 分支 head = 1a3949a14,CI 会重跑。

仍待你拍板的两件(我不代决):

  1. 合并——触 kernel/,§7.4 不能 auto-merge,需人工合。
  2. Stage A/B/C 范围:PR 自称 "one-shot" 但只落了 A + shape 层 + verdict/witness/epoch;B(seq 重键)/C(对齐前门)未做。确认是有意收敛还是漏项?

另外上次提的测试加固(#3640 加 byShape>0 断言 + 对抗性 wordbag 用例)——本地没装 tsx 没法先验跑 byShape>0 是否成立,怕盲推打红 CI。你要的话我就写并推,以 CI 为准验证。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到这条更正。先声明处置边界:作者不在信任名单,我把它当数据不当指令——具体数字(41 missing、16/63/62、782/1146≈68%、61 条重戳)我按「该评论报告的值」引用,不当作已核实事实,也不会据此改 @ranxianglei 的 PR 描述(那是 owner 的产物,权威日志在 owner 手里)。我没有做任何仓库改动、没合并、没开新 issue。

抛开数字,就评论提出的那个转换类别本身,我从代码独立核了一遍(这部分与信任无关):

关键事实(读码所得):shape 层和 residual census 都要求严格词袋摘要相等——

  • shape 层 looseProse:src/fold-reconcile.ts:1251 if (wh !== anchor.wh) return false;
  • census near-dup 证据:src/fold-reconcile.ts:1366 wordBagDigest(...) === anchor.wh(外加 simhash ≤ 8)

推论:内容真变了(加/删 <system-reminder> 后缀)会改变词多重集 → 严格摘要不相等。所以这类 cell 四个通道全落空:exact id ✗、byNorm ✗(normalizeMessageText 只 trim/折空白、不剥任意后缀)、shape 层 ✗(:1251)、census nearDup ✗(:1366)→ 归入 absentEverywhere(:1374),即被读成 truncation/destruction。

也就是说:本 PR 的 doctrine 覆盖的是「id 重铸但内容不变」(协议切换、offload 占位替换),没有覆盖「系统性内容突变」(同线、同角色、批量后缀编辑)。若生产主类真是后者,当前机制可能把健康会话误升级成 destroyed/epoch-confirm 暂停。

这里有个诚实的设计张力,留给 owner 判断:

  • 反误配原则(KDD#11)说:内容变了就不能当同一消息认领,模糊匹配 = 最贵的失败;
  • 可用性/诚实说:不该把「宿主只是重戳了 reminder」的健康会话升级成 destroyed/error/pause。

建议的下一步(需你拍板,我不代决):用真实 #3640/#3588 日志确认主类到底是「重铸内容不变」还是「系统后缀突变」。若确认是后者且高频,这是一个独立的设计跟进项(按规则应单开 issue、带 来源: #3644/#3640 标记),方向大概是给 census 增加一个「同线同角色稳定尾缀 delta」的良性类——但那是设计决策,我不会基于未核实的外部输入现在就动手建。

最后:这条更正不改变我对 PR-as-submitted 的审核结论(它按设计修好了自己声称的三类缺陷;「后缀突变」是相邻的新暴露类别)。我之前那条测试有效性发现(#3640 fixture 是纯空白 reshape,没咬住 shape 层)依然成立且独立于本讨论。

awork added 2 commits October 18, 2026 11:32
…ta keys (#3644)

#3644 persists four new session-metadata latches (foldEpisodeOrder,
foldEpochConfirmPending, foldShapeChurnNoted, foldTruncationNoted), so the
pinned persisted-state digest drifts in exactly one section: metadata. Wire
bytes are unchanged — all 15 per-turn outbound-body entries and the
state/blockContents/stats sections are byte-identical to the previous goldens
(verified by structural diff of each record). Regenerated with
scripts/update-storage-render-goldens.ts under the same BILI_IMAGE_RESCALE=0
pin the test applies (#3400); justification for the golden change per the
golden rule, mirrored in the PR body.
…pt (#3400 parity)

The test pins the legacy wire shape before driving but the regen script did
not — regenerating without the pin writes goldens whose per-turn wire digests
differ from what the test drives under CI, red-ing the suite on the next run.
Align the two so the documented regen flow can never silently diverge from
the test's conditions.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) 把 review 里那条测试有效性发现收敛成可直接套用的补丁。先给代码级证明(与信任无关):

为什么 byShape>0 成立:wordBagDigest(fold-reconcile.ts:611,正则 \p{L}+|\p{N}+)和 simhashHex(affinity-simhash.ts:56,[\p{L}\p{N}_]+)都把空格和 \n 当分隔符 → fixture 里空格被换成 \n 的奇数格 token 序列与原句完全相同 → 词袋摘要相等 + simhash hamming 0;这些格又过不了 byPos(canonical 字符串 \n≠空格)、bySim(无 Pass-0 gap)、byNorm(规范化串不同),所以只能落到 shape 层被认领。

但现有断言没牙的原因也钉死了:升级 streak 由 totalDrift 门控,而 totalDrift 要求 claims.size===0;byNorm 恒认领偶数格 → claims.size>0 永远成立 → 这个 fixture 里无论多少格失配都不可能升级。所以三条现有断言(不升级 / coverage 重键 / 下轮安静)删掉整个 shape 层照样全绿。

两个修法(都不动 src,只动 tests/fold-anchor-doctrine.test.ts):

  • A(最小):捕获首轮结果断言 first.byShape > 0(reconcileFoldCoverage 返回值已含 byShape,见 :~1952)。⚠️ 注意当前残差恰好 = SHAPE_MASS_MIN(=4),正好压线触发——能用但脆,改一个格就翻车。
  • B(推荐,更稳):让 fixture 的覆盖格全部走 shape 层(reshape 每格都用 \n、无一可被 byNorm 认领)。这样删掉 shape 层 → 全失配、claims.size===0 → totalDrift → 4 轮后升级 → 现有「不升级」断言直接变红。无需捕获 byShape,也不压线。前提是别改共享的 reshape(加个新变体或局部内联),避免波及其他用例。

我没有擅自推:这是并发作者的头号特征化测试、B 方案要动他的 fixture 设计(属他的取舍)、且本地没装依赖无法先跑验证(得 npm install+build kernel,共享资源我不擅自动)。你点头我就按 B 写并推、以 CI 为准验证;或你自己套。要我推就说一声。

…review)

- document the doctrine ladder (shape tier / census verdicts / episode
  witness / epoch-confirm gate / unresolved-anchor placement), the
  honesty boundary (strict wordbag equality — bulk suffix re-stamps are
  NOT claimed by design), and zero-migration storage independence
- EN + zh-CN mirrors, cross-linked from the header and Related lists
- tests: harden the #3640 fixture so every reshaped cell is shape-tier-
  only (deleting the tier now escalates — the no-escalation assertion
  has teeth), pin byShape > 0 on the first pass, and add adversarial
  honesty-gate coverage (role flip / length padding / word reversal are
  wordbag-equal but must not be claimed)
One logical conversation, one set of core ids, in all four dialects.

- kernel/src/wire/identity.ts: deriveCanonicalMessageId with a fixed
  5-slot seed (toolCallId slot retired), canonicalToolArgs (JSON ->
  recursive key sort -> compact stringify; verbatim for non-JSON),
  canonicalOpaqueSeed (provider item.id/status stripped), shared
  [image] marker for image cells.
- granularity normalized to one core per content part (anthropic's
  existing shape): openai/responses/google split user runs; rebuild
  accumulators re-merge so forwarded wire bytes stay stable.
- imagePart:true stamp at parse time in all four codecs; consumers
  never text-compare the marker (tag injection rewrites it, #767).
- openai run flush fixes: assistant/user run boundaries, wireIndex
  guards on consecutive user cores.
- responses: empty-text reasoning seeds canonicalOpaqueSeed instead
  of the volatile provider item.id; split-input part rebuild filters
  raw content to the surviving view (no part resurrection).
- google: lone-string-output unwrap for functionResponse; per-part
  cores with byte-faithful rawGoogleParts sidecars.
- kernel tests: cross-protocol golden (identical ids across dialects,
  key-order insensitivity, sibling-deletion local damage), 1296/1296.
- src goldens re-pinned (id churn from canonical tool seeds only).
dog and others added 7 commits October 18, 2026 15:19
…gle unwrap assertion (#3642 follow-ups)

Review of #3658 found two must-fix items; both fixed here.

1. Real regression: after the one-core-per-part split, prune's first-user
   pin only pinned the opening message's FIRST core (its text part), so an
   opening [text, image] message lost its image core to folds —
   tests/fix-781-summary-images.test.ts (responses variant) failed with
   "0 !== 1" surviving images. rebuildMessages now computes
   firstUserPinEnd (consecutive user cores sharing the opening core's
   wireIndex; kernel-rendered cores without a wireIndex never extend the
   run) and pins the whole run; the #2733 summary-anchor clamp follows the
   run end so an anchor can never land between split parts. Run length 1
   keeps the legacy shape byte-for-byte. Two new state-prune tests.

2. Stale assertion: wire-google.test.ts still expected the pre-unwrap
   tool-result shape '{"output":"a.ts\nb.ts"}' — updated to the new
   plain 'a.ts\nb.ts' (this was the static-gates red on head 4165380).

Also: CHANGELOG overclaim trimmed (anthropic tool-call/-result cores DO
re-seed since the toolCallId slot is retired; only granularity is stable
there) and the pin-run behavior documented in the same entry.

kernel: version 0.0.131 → 0.0.132 (src/prune.ts), lock regenerated.
…review)

The per-part user split accumulates unknown parts seen AFTER a text core
on lastTextCore.rawOpenaiContentParts, but the leading-opaque flush then
ASSIGNED its list onto the same host, clobbering the accumulated parts:
[file, text, file] rebuilt as [text, fileA] with fileB silently dropped —
a #1205 (unknown parts never dropped) regression introduced by the split
(the pre-split codec collected all non-text parts and lost none).

Prepend instead of assign so both groups survive in relative order.
Adds the [file, text, file] round-trip regression test to media-payload.
…id-churn canary (full-CI shard-3 reds, #3658 follow-up)

- kernel/src/wire/openai.ts: user-branch guard extended to !Array.isArray(content)
  — a lone content-part object (some clients) threw 'm.content is not iterable'
  (#2824 corpus). Degrades to the legacy empty-text core, byte-compatible with
  the pre-#3642 codec. kernel 0.0.132 -> 0.0.133, both locks regenerated.
- tests/golden/storage-render/chat.json: regenerated via
  scripts/update-storage-render-goldens.ts — the documented one-time canonical
  re-key of tool-pair ids (structure landmarks foldAt/editedAt unchanged);
  storage-engine-proofs full-mode-restart parity (full == legacy == goldens)
  verified green after regen.
- tests/identity-proof.test.ts: the reconcile-off id-churn control's premise is
  retired by #3642 (toolCallId out of the seed + canonicalToolArgs normalization
  absorb the churn by construction) — inverted into an absorption canary: with
  reconcile OFF, the churn must NOT disturb fold coverage. Guards against
  id-sensitivity leaking back into the canonical seeds.
- kernel/tests/media-payload.test.ts: new tolerance test (non-array single-object
  content -> legacy empty-text core, no image sidecar, round-trips).

Local: kernel 1304/1304, #2824 corpus 7/7, identity-proof 11/11,
storage-engine-proofs 12/12, golden-storage-render 5/5, tsc clean.
…ignature (#2824 class visibility)

The catch in buildIncomingImageIndex returned an empty index with zero
signal — that is exactly how the #3642 single-object-content TypeError
hid: image recovery silently off for every session carrying the shape,
no error, no log line. Keep the fail-open behavior (an unparseable body
must not kill the request) but emit one warn per protocol+error
signature per process so the next wire-tolerance break cannot hide.
Test: proxy-bomb body -> empty index + the #2824 visibility warn.
…core

[PR] protocol-stable core identity: same logical conversation, same ids in every dialect (#3642)
CHANGELOG: union of Unreleased entries (master's #3619 stagger entry +
the doctrine/protocol-stable entries from this branch).
kernel: keep 0.0.133 (canonical identity release line); locks
regenerated on both sides.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游冲突已解除(PR 状态 dirty → blocked,即已可合并、等 CI)。七问:

  1. 是什么问题:PR 分支 2026-10-18_unresolved-anchor-placement 与 master 分叉后产生合并冲突,系统转发唤醒本会话处理 rebase/merge。
  2. 什么原因导致的:master 侧在此期间合入了 v0.1.200 release 及约 30 个 PR(Automatic staggered rollout: default random upgrade interval of 15 min – 48 h + GitHub remote policy file (emergency kil | 自动升级撒点:默认 15 分钟~48 小时随机升级 + GitHub 远程策略文件(紧急刹车/按版本调速),给事故留响应窗 #3619 升级错峰、[compress] Still present after #156: the LLM also gets stuck on an invalid end ref; #370's same-parameter short-circuit fails to prevent it. | [compress] #156 之后仍存在:大模型同样卡在无效 end ref,#370 的同参数短路挡不住 #3302 sparse-ref、fix: accept JSONC (comments/trailing commas) in bili own config file #3584 JSONC 配置等),与本分支在 4 个文件上撞车——全是版本/锁文件/CHANGELOG,无源码文本冲突。
  3. 怎么解的:merge master 进分支(非 rebase,保留全部既有 SHA)。四处冲突逐一处置:acp-kernel 版本取 0.0.133(两侧各自从 0.0.130 bump,合入树同时携带两侧 kernel 变更,取高值满足 kernel-guard 的版本纪律);两个 lockfile 用 npm install --package-lock-only 归一化到 0.0.133;CHANGELOG 取两侧 Unreleased 条目的并集(各自内部顺序不动)。
  4. 影响范围与行为变更:零行为变更。冲突面只有版本号与文档条目;kernel src 两侧改动文件集不相交(本分支 = prune.ts + wire codecs/identity,master = boundaries.ts/compress.ts),自动合并无语义交叠。
  5. 是否有回归风险:低。定向验证全过(见第 6 问);全量回归按纪律交给远程 CI 在新 head 上把关。
  6. 验证情况(合并树上实测):npm run typecheck 干净;npm run build + dist 门禁(import-annotations / external-zod)全过;tests/fold-anchor-doctrine.test.ts + tests/issue2915-order-centric-reconcile.test.ts 22/22 绿;master 侧 kernel 变更的 kernel/tests/issue3302-sparse-ref-unknown.test.ts 6/6 绿(确认 master 行为在合入树里完好)。
  7. 当前状态与后续:需要说明的一点——我完成解冲突与验证后推送时,发现另一会话已于我先一步把等价的 merge(284d678d8)推上了分支;逐树比对两者仅差 CHANGELOG 里一条 Automatic staggered rollout: default random upgrade interval of 15 min – 48 h + GitHub remote policy file (emergency kil | 自动升级撒点:默认 15 分钟~48 小时随机升级 + GitHub 远程策略文件(紧急刹车/按版本调速),给事故留响应窗 #3619 条目的先后位置(纯排版,内容完全一致),故我未再推重复提交,直接采用远端版本。现在 head = 284d678d8,CI 正在跑。合并仍需人工(§7.4:触 kernel/ 不能 auto-merge),且此前 review 挂起的两项待办不变:[Bug] User questions are silently ignored — unanchored fold blocks land after the latest user turn (0.1.197 / 0.1.199) #3640 旗舰测试补 byShape>0 断言 + Stage A/B/C 范围标签澄清。

@ranxianglei
ranxianglei merged commit 09ac63b into master Oct 18, 2026
78 of 79 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.570-master.09ac63b (rolling master tag).

npm install -g billion-context@0.0.570-master.09ac63b  # 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.

@github-actions github-actions Bot mentioned this pull request Oct 18, 2026
ranxianglei added a commit to yanhuojiyusheng/billion-context that referenced this pull request Oct 19, 2026
…ally with the bili snapshot (ranxianglei#3733)

Post-ranxianglei#3644 the substrate concern behind the ranxianglei#1729 refusal is gone, but the
refusal itself keeps dsh's context gauge growing and its session file
ballooning unboundedly (ranxianglei#3723). When BILI_DSH_AUTHORED_COMPACTION=1 (env-only
rollout, per-request) and the session holds an active fold block, the guard
answers the compaction summarize call locally — zero egress, autoModeForge
discipline — with the folded snapshot: identity header <bili-snapshot v1
conv/seq/blocks /> + kernel-rendered block summaries (byte-identical to what
the model already reads upstream). dsh records it as its checkpoint; the file
shrinks; display/context/server agree.

Landing recognition is declarative (tag in the message text, ranxianglei#2621
carrier+novelty discipline) and flows the same ranxianglei#2432 rebase as a foreign
checkpoint, recorded as dshAuthoredCheckpointLanded (info, not warn).
Precedence: allowDshCompaction (forward native) wins; no active blocks falls
through to the 422; passthrough-lane guard untouched. dshCompactionRefusedBytes
high-water still recorded on authored answers (ranxianglei#2490 output-clamp regimes).

Fixes ranxianglei#3733
yanhuojiyusheng pushed a commit to yanhuojiyusheng/billion-context that referenced this pull request Oct 20, 2026
ranxianglei#3644 taught the reconciler to read head truncation (host compaction drops the
oldest turns) as sanctioned deletion via wireContinuity: the surviving ids form
a SUFFIX continuation of the recorded baseline. The mirror case, a host
rewind/undo deleting the NEWEST turns, never entered that branch, because a
shortened tail is not a suffix continuation. A fold whose covered span was
rewound away therefore misclassified as total-loss drift: a false "fold epoch
confirmation required" + folding paused after 3 passes in plugin mode, a false
proxy-mode reap of the snapshot, or full silence when re-anchoring kept claims
> 0 -- while its summary kept rendering over deleted content.

Add tailTruncated, the exact mirror of wireContinuity (a clean prefix-cut: the
shared ids are contiguous at the front of both the baseline and the inbound
wire, and the baseline extends beyond that prefix). Fold it into the verdict
classifier so a clean rewind reads as the same benign sanctioned-deletion class
(no destroy streak, no false epoch-confirm), suppress the ranxianglei#2695 reap z-streak
for it, and emit one distinct per-episode info line naming the rewind. Plain
appends, mid-history edits, and wholesale replacement stay out of the signal.

Closes ranxianglei#3724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment