Skip to content

[PR] fix: payload-aware image identity in fold reconciliation (#6075) - #6082

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-10_image-fold-payload-identity
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-10_image-fold-payload-identity

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #6075

Problem

On v0.1.213, src/fold-reconcile.ts matched image cells on TEXT alone: two different images both parse to text: "[image]", so they got identical normalizedIdentity / positionalFingerprint. When message ids churned across a history resend, fold-coverage repair claimed the NEW image under the OLD folded block's coverage; later trimming then dropped the new image while its filename/size/hash metadata text stayed — the model saw metadata for an image it could no longer see.

Fix (payload-aware identity, host-side only)

All changes in src/fold-reconcile.ts; no kernel/ changes:

  • New private carriesReconciliationMedia() + mediaIdentity(): a media cell's identity mixes a sha256 over its payload (imageBase64 + media type, else the raw wire sidecars; split remote-image occurrences sharing one raw item additionally mix their occurrence id). Media identity strings carry a media: prefix so they can never collide with legacy text-only digests.
  • normalizedIdentity / normalizedIdentityNoToolCallId / identityWithText / positionalFingerprint mix the media factor in. Non-media messages hash byte-for-byte exactly as before (empty media factor, no prefix) — zero drift for text-only histories.
  • Reconciliation passes will not let a media cell be a claim TARGET, and will not CLAIM a covered old cell from a legacy (pre-fix, payload-blind) media sketch — positional, gap-pair, order and shape census paths all gated. Only an exact id match keeps media coverage.
  • Repair-mode self-heal for existing broken sessions: a covered media cell whose stored anchor does not match the current payload evidence has ONLY that cell's coverage withdrawn from the block id lists (block ids, summaries and the surrounding text fold stay intact); the next pass re-seeds the anchor with payload evidence. Warn mode does not mutate.
  • Media-cell anchors skip the simhash/word-bag text sketches (the text is just [image], useless as shape evidence).

Verification

  • New tests/fold-reconcile-images.test.ts (25 tests): distinct identities for distinct payloads (inline base64, sidecar-only, split remote images sharing one raw item); no inheritance across replacement / shared-tail-fenced / same-payload-independent-upload shapes; legacy-sketch bypasses closed (simhash, tool-call, byOrder, shape census); self-heal releases only the image's coverage without unfolding the text fold; positive controls (whitespace-only churn still reanchors; unchanged and duplicate-retained images keep coverage).
  • Local targeted runs on this head: new suite 25/25 pass; existing fold suites (fold-reconcile, -positional, anchor-doctrine, drift, images-archive, affinity-crosswire) 117/117 pass; perf test (fold-reconcile (#1924) 残留质量缺口:length-guard 分支未被测试触及 / 缺 8K 消息性能测试 / system-fingerprint 仅接 anthropic 站点 #1930-2 near-linear steady state) pass; npm run typecheck clean. Full-suite verdict = CI lanes on this head.

Behavior change disclosure (intended, per #6075)

Sessions that ALREADY contain a folded image cell anchored by a pre-fix text-only anchor: on the first repair-mode pass after upgrade, that image cell's coverage is released (the image returns to outbound requests) while the rest of the fold stays intact. Text-only sessions: zero change (identities byte-identical when no media is present). No config surface, wire protocol, or persistence format changes — identity strings are internal session-metadata state.

Image cores all carry the same "[image]" placeholder text, so
normalizedIdentity / positionalFingerprint were payload-blind: two
different uploads produced identical fingerprints, and planReconciliation
claimed a missing covered image id onto the new upload through the
normalized fallback and Pass-0 positional match. The new image then
inherited the old fold coverage and was trimmed from the outbound
request while its metadata text remained.

- mediaIdentity(): sha256 over the image payload ([mediaType, base64],
  or the raw sidecar blocks for sidecar-only images; split remote
  images disambiguated by occurrence id), namespaced with a "media:"
  prefix; folded into normalizedIdentity,
  normalizedIdentityNoToolCallId, identityWithText and
  positionalFingerprint. Pure-text signatures are byte-identical to
  before.
- Media messages are excluded from every cross-id heuristic claim path
  (candidates, missingMiddle, recordGap, head/tail positional scan):
  kernel ids are payload-addressed since #3767, so only an exact id can
  prove the same upload occurrence.
- anchorFrom no longer seeds simhash/word-bag sketches for media
  messages (the placeholder text is not content evidence).
- reconcileFoldCoverage repair mode releases coverage of wire-present
  media cells whose stored anchor evidence does not match the current
  payload-aware identity (legacy text-only anchors may already have
  claimed unrelated images); ids, summaries and the remaining text
  fold stay intact. warn/off modes untouched.

Known boundary (documented): sessions folded under pre-fix builds keep
legacy image anchors without payload evidence; their coverage is
released once on the first post-upgrade repair pass (images return to
the request until re-folded). A legacy image anchor whose cell is
replaced IN PLACE by a text cell at the same index, bracketed by
verified positional claims, could still be claimed through the gap-tier
order bracket — narrower than the pre-fix behavior, tracked in #6075.

Tests: new tests/fold-reconcile-images.test.ts (25 cases) pins both
directions of every gate plus self-heal, seeding and positive controls.
Local targeted suites green (fold-reconcile family 273/273); full
regression on remote CI.

Fixes #6075
@ranxianglei ranxianglei added bug Something isn't working image p1 scope/kernel labels Nov 10, 2026
@ranxianglei ranxianglei changed the title fix: payload-aware image identity in fold reconciliation (#6075) [PR] fix: payload-aware image identity in fold reconciliation (#6075) Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-10_image-fold-payload-identity (bd00d94)

Latest build — install this exact version

npm install -g billion-context@0.0.8878-pr.6082.bfd3184

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

Recent builds (commit → version)

commit version build
bd00d94 billion-context@0.0.8878-pr.6082.bfd3184 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6082.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

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 本单是 PR #6082(修 #6075)的 [PR] 跟踪单;在途 [PR] 里另有两条图片相关——#6089(image spill 修复)、#6086(rescale 缓存键)——机制不同(spill/rescale 缓存 vs fold reconciliation 身份层),无平行冲突。

标签: bug / dsh / p1 / scope/kernel(缺陷类;复现现场为 DSH Responses wire;属上下文管理/会话核心逻辑域;用户上传图片静默从模型视野消失 = 数据丢失类,按 2026-10-19 口径 p1)。GitHub PR 侧已有 bug/p1/scope/kernel/image,与我的独立判定一致。

本轮对既有 PR 做代码核对 + 状态确认(未重做),结论如下。

代码核对(独立 review)

本地验证(定向跑,PR head bd00d94)

  • 新 tests/fold-reconcile-images.test.ts:25/25 过(含正负双向门:替换图/共享尾栅栏图/同载荷独立上传均不被 claim;legacy sketch 经 simhash/tool-call/byOrder/shape census 四条旁路全堵死;自愈只放图片不放文本;空白 churn 仍正常 reanchor 的正向对照)。
  • 既有 fold 家族(fold-reconcile / -positional / anchor-doctrine / drift / images-archive / crosswire / perf):117/117 过;typecheck 干净。
  • 合并模拟(分支 + 当前 master 合并在临时 worktree 实跑——master 上 [Bug][DSH] Partial interior loss is classified as total drift despite surviving direct-ID majority, latching compression off #5715 系列有 4 个提交同改 src/fold-reconcile.ts,热文件竞争必须验):152/152 过,typecheck 干净,无文本冲突(GitHub mergeable=behind,无需 rebase)。全量套件判定以 CI 为准。

状态(live 核实)

八问

  1. 是什么问题:不同图片解析后文本都是 [image] 占位符,fold 身份比对只看文本 → 历史重发导致消息 id 漂移时,新图片被认作已折叠的旧图片纳入旧块覆盖,随后被裁剪掉——模型只剩文件名等元信息,看不到图。
  2. 什么原因导致的:host 侧 fold anchor 身份层为纯文本设计,image cell 的载荷(imageBase64/raw sidecar)从不参与身份计算 → 两张不同图片得到完全相同的 normalizedIdentity 与 positionalFingerprint,后续所有基于身份的匹配/claim 全部误判。
  3. 影响范围与严重程度:影响 Responses wire 上带图片且历史重发发生 id 漂移的会话(现场 DSH);p1 数据丢失类——用户上传静默丢失且元信息仍在,比直接报错更具误导性。
  4. 怎么修复的:身份层载荷感知(payload sha256 + media: 前缀)+ claim 路径对 media cell 全面收紧(仅 exact id 维持覆盖)+ repair 模式对存量坏覆盖做「只释放图片 cell」的定向自愈。疏不堵:修的是产生错误身份的地方,不是过滤症状。
  5. 是否有回归问题:逐项过——纯文本会话哈希逐字节不变、稳态性能保持(fold-reconcile (#1924) 残留质量缺口:length-guard 分支未被测试触及 / 缺 8K 消息性能测试 / system-fingerprint 仅接 anthropic 站点 #1930-2)、warn 模式不变、kernel/配置/wire/持久化不动;与当前 master(含 [Bug][DSH] Partial interior loss is classified as total drift despite surviving direct-ID majority, latching compression off #5715 同文件并发改动)合并模拟 152/152 绿。未见回归。
  6. 是否破坏缓存:不影响 prompt 前缀缓存路径——身份串是 session metadata 内部状态,不上 wire;唯一有意变化是存量坏态图片升级后回到请求(修复目标本身)。
  7. 是否改了设计方向:没有。仍是「msgid > 顺序 > hash」身份层级下的单一投影裁决,本次只是把 hash 维度对 media cell 做成 payload-aware,并对 claim 加保守门。
  8. 是否引入了新的配置:没有。

判定:代码与本地定向验证均通过,待 CI 转绿即可合并(人工合并)。CI 结果出来我会回帖跟进。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

CI 结果跟进(live 核实):head bd00d94 全绿。 全部 160 个 check run 终态:78 success / 42 skipped / 40 cancelled,0 failed。那 40 个 cancelled 是开跑数秒内被 re-trigger 自动取消的第一波(取消时间集中在 03:42:33–03:42:35Z),已逐一按名称核对——每一个都有对应的成功/跳过重跑,无一遗漏。

至此:代码核对 ✓、本地定向验证(含与当前 master 的合并模拟)✓、CI 全量 ✓、标签齐(PR: bug/p1/scope/kernel/image;镜像单: bug/dsh/p1/scope/kernel)、PR 正文已修复。PR #6082 可以合并了,等你人工合并。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant