Skip to content

[PR] Payload-addressed image message IDs: seed adds media fingerprint slot (#3751) | 图片消息 id 按载荷寻址:种子增加媒体指纹槽(#3751) - #3767

Merged
ranxianglei merged 5 commits into
masterfrom
2026-10-19_image-fingerprint-seed
Oct 19, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-10-19_image-fingerprint-seed

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

问题(#3751)

图片 core 的规范文本是常量 [image],所有图片哈希出同一个共享 base id,全靠 ClusterCounter 的 _N 序号区分——而序号是位置敏感的:一张图变化(offload 占位、重编码、删除)把全族序号整体位移,每轮把整个家族的 id 重铸一遍。这是每轮 fold 断缓存的直接喂数机,也是 #3748(17.8GB/天写放大)的放大器之一。

修法(与讨论定案一致:m36538)

deriveCanonicalMessageId 增加第六槽 mediaFingerprint,仅媒体 core 有:

图片形状 指纹来源
数据图(四协议主流) sha256(imageBase64)——字节在 codec sidecar 与内容 CAS 两边都已有
URL 引用图(wire 无字节) URL 字符串
legacy 复数 sidecar core(openai 未知部件回退) 各部件指纹的有序串(无图则不加槽,legacy id 原样保留)

不变量(金桩钉死)

kernel/tests/cross-protocol-identity.test.ts 新增 4 测试:

  1. 一张图变化只重铸它自己,sibling id 逐字节稳定,族内无序号;
  2. 字节相同的重复图共享 base,第二个得 _1;
  3. URL 图同 URL 同 id、异 URL 异 id、URL 图与同名数据图不碰撞;
  4. responses legacy 单图形状 == 拆分形状 id。

跨协议金桩(同图四方言同 id)原 4 测试在指纹化后依然全绿——所有方言对同一份字节算出同一指纹。

存量会话影响

图片会话一次性 re-key(图片 core 的 id 变化),由已落地的两层吸收:

非图片会话零影响(种子逐字节不变)。

文档

  • MESSAGE-IDENTITY.md(+zh-CN)新增「图片按载荷寻址」章节(哈希公理代价节之前);
  • CHANGELOG Unreleased 条目。

kernel-change: identity.ts 媒体指纹槽 + 四 codec 图片位点;kernel 0.0.136(0.0.135 为 #3756 测试缝,已发布)。

Image cores now seed their id with the image's own fingerprint (bytes
hash for data images, URL string for URL references, ordered join for
the legacy plural shape). One image changing re-mints only its own
core instead of shifting the whole family's _N ordinals; the ordinals
return to their #459/#463 role of disambiguating true duplicates.
Text/tool seeds are untouched (non-image ids stay byte-identical);
cross-protocol same-image-same-id and responses legacy/split shape
equivalence are pinned in the cross-protocol golden.

kernel-change: image media fingerprint slot in canonical identity
(deriveCanonicalMessageId options.mediaFingerprint + 4 codec sites);
kernel 0.0.136.
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-19_image-fingerprint-seed (4c9123f)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4464-pr.3767.2f800bd

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-pr3767.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title 图片消息 id 按载荷寻址:种子增加媒体指纹槽(#3751) [PR] Payload-addressed image message IDs: seed adds media fingerprint slot (#3751) | 图片消息 id 按载荷寻址:种子增加媒体指纹槽(#3751) Oct 19, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复——本 PR 是 #3751(图片 id 按成员集合重铸、每 fold 断前缀缓存)的唯一实现;近 7 天 open PR/issue 检索无第二份「图片载荷指纹种子」方案。同家族近亲 #3642/#3658(切协议 churn → canonical 种子)机制不同且已合入,#3748 是存储侧下游症状、互链各自管理。

标签: bug, dsh, scope/kernel, p2(缺陷修复;生产证据来自 dsh 车道;kernel 身份层;p2 与 #3751 定级一致——图片会话每 fold 一次前缀缓存断点,属性能/成本劣化,非不可用)

审核开工:分支 2026-10-19_image-fingerprint-seed(单 commit 8265424,+244/-22,11 文件:identity.ts + 四 codec + 金桩测试 + 双语文档 + CHANGELOG + kernel 0.0.136 bump)。按规范走方向关(对 #3751)→ 回归关(非图片 id 逐字节稳定是核心承诺)→ 代码关 → 测试有效性关,定向本地跑 kernel 身份测试,CI 状态以远端为准,结论按八问给。

@ranxianglei ranxianglei added bug Something isn't working dsh p2 scope/kernel labels Oct 19, 2026
ranxianglei and others added 3 commits October 19, 2026 11:28
…ixed 60ms nap

The first #3767 full run tripped the D-lane tests on loaded CI runners:
the save→ingest roundtrip outlived the nap, the D engine degraded to the
legacy path (surface asserts still passed — prune renders the same anchor),
and only the snapshotRenderTurns latch exposed the miss. Poll until the
session's tail view CHANGES (not grows — a rewind turn legitimately
net-shrinks the pointer sequence) before the next turn.
… decoded bytes

Review nit on #3751 (no behavior change): imageMediaFingerprint() hashes
the base64 string carried on the wire (design m36538: sha256(imageBase64)),
but four code comments described the input as decoded bytes. Wording only —
identity.ts, openai.ts, responses.ts, google.ts.
Review nit on #3751 (no behavior change): imageFingerprintsOfParts was
inserted between two import groups. Move it below the imports so the file
matches the repo's all-imports-first convention.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #3767 审核结论(第二轮,覆盖新 head f296b0e0d + 我补的两个小修 commit)

审核动作:全量 diff 逐文件精读(identity.ts / 四 codec / 金桩测试 / 文档 / CHANGELOG / 版本号)、仓库级 grep(旧共享 base id 字面量、指纹函数使用面、host src/ 耦合面)、本地定向测试(kernel identity 8/8 + wire/media/reid 批次 115/115,修后复跑 60/60 全绿)。CI:head f296b0e0d 快速门禁 17 项全绿(kernel-guard / version-guard / lane-guard / config-surface-guard / docs-sync / lock-sync…),test 分片在跑;我推了下面两个小修 commit(5ee2586f8)后全套将在新 head 重跑。

审核中发现并已直接修复的两处小问题(独立标注 commit,零行为变更):

  1. docs(kernel): image fingerprint comments hash the base64 payload, not decoded bytes——四处代码注释说「hash decoded bytes / its bytes」,实际哈希的是 wire 上的 base64 字符串(设计定案 m36538:sha256(imageBase64))。注释与代码事实不符 = 缺陷,identity.ts / openai.ts / responses.ts / google.ts 同族一并修正。
  2. style(kernel): keep openai.ts import block contiguous——imageFingerprintsOfParts 插在两组 import 之间,移到 import 块之后(ESM hoisting 下行为不变)。

第二 commit(snapshot-render harness settleRows)审核:这是对本 PR 首轮 CI 在负载 runner 上触发的 D-lane flake 的修复(#3756 既有测试,非本 PR 引入):固定 60ms nap 改为轮询 store tail view 变化(不是增长——rewind 轮合法地净收缩)+ 5s 超时 fail-fast。审过:轮询条件正确、超时抛错优于静默降级、仅动 tests/snapshot-render.test.ts 不碰生产代码、属「CI 红顺手修」合规处置。✓


结构化八问

  1. 是什么问题:图片 core 的规范文本恒为 [image],全会话所有图片哈希出同一个 base id,靠位置敏感的 _N 序号区分——一张图变化(offload 占位/重编码/删除)就把全族序号整体位移,每轮把整个图片家族的 id 重铸一遍。
  2. 什么原因导致的:身份种子五槽(role|contentType||toolName|text)对图片的内容维度为零(文本恒同),base id 不携带「这是哪份内容」的信息,身份退化到位置序号——_N 实例纪律(fix(#457): strip model-emitted render tags from plugin-mode openai/anthropic wires #459/plugin 模式 openai SSE:混合文本字段 chunk 因单字段纯标签 echo 被整体丢弃(丢失同 chunk 真实输出) #463)的前提被破坏。这是喂数机:每轮 fold 断缓存 + Shadow ingest mints a new CAS key on every re-ingest: one image payload recorded 56x, 11.06x redundancy, 88.6% of content bytes are refcount=0 orphans #3748 写放大(17.8GiB/天)的放大器之一。
  3. 影响范围与严重程度:所有含图片的会话(dsh 图片 offload、截图分析等)。修复前:每轮图片族全体重铸 → 每轮 fold 断前缀缓存、存储写放大。能用但性能/成本持续受损 → p2。
  4. 怎么修复的:规范种子加第六槽 mediaFingerprint,仅媒体 core 有:数据图取字节的 sha256(base64 载荷,wire 上现成)、URL 引用图取 URL 字符串(wire 无字节,URL 是唯一身份)、legacy 复数 sidecar core 取各部件指纹有序串(无图不加槽,legacy id 原样保留)。_N 回归本职:仅区分字节完全相同的重复图。
  5. 是否有回归问题:逐项清点触碰路径的既有行为——① 文本/工具消息 id:种子构造保证(mediaFingerprint 为 undefined 时槽位不追加)逐字节稳定,跨协议金桩钉死 ✓;② ClusterCounter 语义未变,同 base 实例仍走 _N(issue1476-reid 套件绿)✓;③ 跨协议同图同 id 原 4 金桩指纹化后仍全绿(四方言对同一份字节算同一指纹)✓;④ responses legacy 单图形状(content 长度 1 不拆分)== 拆分形状:新金桩钉死,且我核过 userDisplayText 对纯图内容返回 [image],两路径种子确实相同 ✓;⑤ google codec 仅 inlineData 生成图片 core,fileData 等走 sidecar 附着,无图片形状逃逸指紋化 ✓;⑥ CAS/sidecar/wireIndex/存储路径 diff 零触碰 ✓。有意变更(已披露):存量图片会话一次性 re-key(图片 core id 变一次),由 Snapshot as session reconstruction: identity claim order takes priority, message hash demoted to reference signal (root- | 快照即会话重构:身份认领顺序优先,消息哈希降级为参考信号(根治 #3588/#3640 一类误判) #3641 判决分类 + Snapshot rendering: proxy-lane outbound is now rendered authoritatively server-side; existing sessions are immune to ker | 快照渲染:proxy 车道出站从服务端正史渲染,存量会话对内核升级免疫(#3752 根治) #3756 快照渲染兜底吸收——这是修法的设计意图,非回归。
  6. 是否破坏缓存:本修复消除的正是「每轮图片族重铸」这个断缓存源(原病)。一次性 re-key 使升级后首轮付一次前缀 miss(与 The intermediate message (core) is not protocol-agnostic: switching protocols/models causes identity churn; cross-protoc | 中间消息(core)没有做到协议无关:切协议/切模型制造身份 churn,补齐跨协议映射 #3642/Snapshot rendering: proxy-lane outbound is now rendered authoritatively server-side; existing sessions are immune to ker | 快照渲染:proxy 车道出站从服务端正史渲染,存量会话对内核升级免疫(#3752 根治) #3756 同类升级代价),随后逐轮稳定。CAS 去重键(content-addressed)与增量游标策略不受影响。
  7. 是否改了设计方向:没有。消息身份教义(hash 公理 + order-centric reconcile + 快照渲染)不动,只补上图片身份缺失的内容维度;MESSAGE-IDENTITY.md(en+zh)新增章节已落在 hash 公理代价节之前。
  8. 是否引入了新的配置:无。kernel-change 声明齐备,kernel 版本 0.0.135→0.0.136 合规,CHANGELOG Unreleased 条目准确。

判定:审核通过,建议 CI 全绿后合入(kernel/** 变更属 human-only review tier,合并由你执行:https://github.com/ranxianglei/billion-context/pull/3767)。CI 若在新 head 上有红我再跟进。

CI-red fix (labeled, unrelated to #3751): the 'unmarked lane'd spawn
against a LIVE same-build twin' live test pinned exitCode === 1, but
since #3654 a twin-collision loser exits TWIN_ADOPT_EXIT_CODE (3) as
the spawner's adopt signal (src/listen-policy.ts) — every other listen
failure keeps 1. Which code surfaces depends on a socket-level race
(clean EADDRINUSE + registry hit → 3; concurrent-bind-tolerant bind
losing at the post-bind claim → 1), so the pin flaked per tree on the
ubuntu shards (master run on this PR's exact base failed identically).
Both outcomes satisfy the test's invariant — lost loudly without
hopping — which the hop/port/twin-alive asserts keep carrying.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 红更新:新 head 的两个 ubuntu test shard(24/1、22/1)红了,查明与 #3751 无关——是 master 上既有的 flake:

修复已推(标注独立 commit,test-only,零行为变更):4c9123fc9 — 断言放宽为接受 {1, 3},附注释说明两个码各自合法的来源,防止将来被「简化」回 1 再次炸 CI。

关联:作者补的 f296b0e0d(snapshot-render harness 轮询 tail view 变化替代固定 60ms nap)正是 open issue #3771 建议方向 1 的实现——本 PR 合入后 #3771 的 harness 面随之解决。

CI 正在新 head 4c9123fc9 上跑,绿了在此报。

@ranxianglei
ranxianglei merged commit e3ddb4a into master Oct 19, 2026
49 of 53 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.591-master.e3ddb4a (rolling master tag).

npm install -g billion-context@0.0.591-master.e3ddb4a  # 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.

ranxianglei added a commit to yanhuojiyusheng/billion-context that referenced this pull request Oct 19, 2026
…t 0.0.133)

The 0.0.134→0.0.136 bumps (ranxianglei#3759/ranxianglei#3767) updated kernel/package.json and the
root lock's workspace entry but never regenerated kernel/package-lock.json —
the same dual-lock drift ranxianglei#3658 hit. npm ci inside kernel/ would refuse
(lock does not satisfy package.json). Regenerated with
npm install --package-lock-only; no source changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the FULL CI matrix (all e2e lanes + 12-leg test matrix) on this PR dsh p2 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant