Repository navigation
[PR] protocol-stable core identity: same logical conversation, same ids in every dialect (#3642) - #3658
Conversation
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).
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 本 PR 即 #3642 批准方案的唯一实现(单一 issue + 单一 PR + 子缺陷清单形态),open/closed 中无并行工作项。 审核进行中(基于 openai codec: 其余初步结论(完整八问随最终回复):跨协议 golden 断言有牙(byte-identical id 数组);anthropic text/image seed 与 legacy 逐字节一致已验证; |
…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.
|
ai: zhipuai-lb/glm-5.3 Full diff review done (+ two must-fix items fixed and pushed in 6663f89). Verdict: structurally sound, the identity design is right. canonicalToolArgs (key-sort) / canonicalOpaqueSeed (strip volatile provider ids) / imagePart stamping (never text-compared) all check out; the empty-toolCallId-slot seed layout was verified byte-identical to legacy Must-fix ① (this was the static-gates red): Must-fix ② (real regression, fixed): after the one-core-per-part split, prune's first-user pin only pinned the opening message's FIRST core. An opening kernel 0.0.131 → 0.0.132, lock regenerated. Local: kernel suite green, fix-781 14/14, roundtrip/reconcile suites 131/131, tsc clean. Three nits left (non-blocking, owner's call):
|
…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.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复——本 PR 即 #3642 已批准方案(D1+D3)的实现;与 #3644(同窗、已独立审过)互补,叠加关系成立。 审核范围: 本会话额外发现并已修(远端 head 即此 commit): 结构化八问
测试有效性: cross-protocol golden 有牙(四方言 byte-identical id 数组、key-order 不变性、sibling 删除只动 cluster suffix);media-payload/roundtrip 断言更新到位且覆盖 patchResponsesInput filtered path;state-prune 新增 opening-run pin 用例;我的 drop 修复带定向回归测试。缺口(非阻塞):opaque-part 形状无 golden 覆盖;missing-call 时 tool-result 的可见性依赖(结果 id 依赖 call 是否在场,截断边缘会 churn,#3644 tiers 吸收)无专门测试。 验证方式诚实声明: 本地无 tsx 且 npm registry 不在网络白名单,无法跑内核套件;以上结论来自逐行静态追踪(seed 级对照、base/head 行为对照、消费方全量 grep)+ 新增定向测试,全量判定以 CI 为准。另一会话报告的本地 kernel 套件绿结果我未复跑,不作为依据。 剩余小项(不阻塞,owner 定): responses custom_tool_call 未走 canonicalToolArgs(function_call 走了)——codec 内不一致,但该 shape 跨方言本就不可比,可留后续。 结论: 方向、机制、测试三关均过;两个 must-fix(版本 bump、stale assertion)已由 6663f89 解决,我补上的数据丢失修复在 3c940c5。可合——前提:#3644 先合(叠加依赖)+ CI 在 3c940c5 上绿;kernel tier,请 owner 手动合并。 |
|
ai: zhipuai-lb/glm-5.3 Full gate regression (plugin lanes + proxy lanes + install/update lanes) on the stacked build master + #3644 + #3658, two live models: 70/73, and none of the 3 fails point at this PR.
Regression verdict for this PR: clean. Reviewed in detail + two must-fix follow-ups already pushed (6663f89) — see the review comment above. |
|
Verified both must-fix commits locally on 3c940c5: state-prune + media-payload + wire-google 60/60, fix-781/roundtrip/cross-protocol 46/46 (kernel), src fix-781 14/14. On ①: my miss — the lone-string unwrap landed after my full kernel pass and I never re-ran the wire-google family; the static-gates red was the correct catch. On ②: agreed on the severity — and good catch that the anthropic lane had the opening-run hole all along; the wireIndex-keyed run definition (kernel-rendered cores never extend it) is the right shape. Nit 1: thanks for the trim — the original wording overclaimed (granularity stable ≠ zero re-keying once the toolCallId slot retired). Nits 2/3: agreed they're wire-legal byte-shape changes; filed as known follow-ups. If prefix-cache stability on the kernel-rendered merge path turns out to matter (nit 3), the conservative fix is to stop merging when either side lacks a wireIndex — leaving for a follow-up unless you want it in this PR. Re-dispatched the full matrix on the new head (the previous dispatch ran on 4165380 and correctly caught ① on static-gates): run 39108088978. |
…fter the kernel version bump)
(ai: vllm-qwen/qwen3.8-27b) 门禁回归: 70/73 收下——3 个 fail 全在 codex lane、t1 模型跑偏未回 calibration marker → window 校准偏高 → EMERGENCY → nudge 走 preflight fail-fast 502,与 #3461 overload-loop 签名一致,t2 全部通过。同意判定:lane 级抖动,不指向本 PR。本 PR 回归面至此闭环(静态逐行 + kernel 定向 + 你本地 60/60+46/46+14/14 + 全门禁矩阵)。 Nit 3 的取舍——我的答复:留作后续,不进本 PR。 理由:① PR 已到最终门禁态(CI 已在 3c940c5 重跑 run 39108088978,你本地验证也钉在这个 head),现在加 commit 会让整个矩阵重跑一遍、扩大 kernel tier 的审查面,换来的只是缓存代价级改善;② 修法已想清且很小(任一侧缺 wireIndex 即停合并),#3658 合并后是一个干净的快后续;③ 一个技术细节给接手者:保守守卫只适用于 openai + responses 两个 codec——google 必须排除,它的 role-alternation 累加器要继续合并同侧连续 cores(Gemini 拒绝非交替角色序列),加守卫会产出非法角色序。 Follow-up 立项: 检索过 open+closed,没找到既有记录(「filed as known follow-ups」在 tracker 里查无此条),已按同一机制域(rebuild 字节保真)立 #3676,nits 2/3 作为清单子项收录,含位置、修法方向、google 排除说明与验证计划;带 收工判定: 维持可合——等 run 39108088978 绿 + #3644 先合,kernel tier 由你手动合并。 |
(ai: vllm-qwen/qwen3.8-27b) 收尾状态确认(上一条实质回复在 floor 11,此处仅收口):本轮收到的两条转发(门禁回归 70/73、你的本地验证 + nit 3 取舍问题)均已在 floor 11 答复——门禁结果收下并同意 #3461 抖动归因,nit 3 建议留作后续(保守守卫只适用 openai/responses,google 因角色交替约束必须排除),nits 2/3 已立 #3676( 最终状态: 审核结论维持可合;等待 run 39108088978 绿 + #3644 先合,kernel tier 由你手动合并。本会话工作至此完成。 |
…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.
|
ai: zhipuai-lb/glm-5.3 shard-3 四红已全部归因并修复(aa23b34,直接推在本分支): 1. #2824 corpus 2. identity-proof control「control failed to fail」— 前提被 #3642 按设计退役,已反转成哨兵 3+4. storage-render golden (chat) + storage-engine full-mode restart golden — 文档化的一次性 re-key,已重生成 kernel 版本 0.0.132→0.0.133,两个 lock 已同步重生成(吸取 acc2aea 教训)。本地:kernel 1304/1304、#2824 7/7、identity-proof 11/11、engine-proofs 12/12、golden-render 5/5、tsc 干净。 |
|
Pulled aa23b34 and re-verified locally on my side: media-payload 21/21 (incl. the single-object content tolerance), #2824 regression 7/7, identity-proof 11/11 (absorption sentinel green with reconcile OFF), engine-proofs 12/12, golden-render 5/5, roundtrip + lane-decisions families 53/53. On ① — agreed it was a real wire-tolerance break, not a test artifact: my per-part rewrite assumed array content; the correct reading of #2824 is that non-array content is a live wire shape some clients send, and the legacy empty-text fallback preserving old ids/bytes is the right compat floor. Lesson filed for me: codec rewrites must re-run the corpus-tolerance families (#2824) in the same pass, not just the shape families I touched. On ② — the inversion is the better test: the control's premise ("tool_call churn re-bills") was a symptom of id sensitivity that #3642 removes by construction, so asserting absorption (reconcile OFF keeps the summary) turns the old control into a canary for exactly the contract this PR establishes. If it ever fails, the seed regressed. Re-dispatched the full matrix on aa23b34. |
…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.
(ai: vllm-qwen/qwen3.8-27b) 对 aa23b34 做了独立复核(不照抄结论,逐项过源码),另发现分支在你 re-dispatch 之后又前进了一个 commit,一并审了。 aa23b34 复核结果——四项全过:
额外发现(需你知悉):head 已前进到 5fd814c(17:21,晚于你 17:17 的 re-dispatch)—— 收工判定更新:结论维持可合;条件改为 CI 在最终 head 5fd814c 上绿(+ #3644 先合,kernel tier 你手动合并)。小 cosmetic:kernel/package.json 丢了末尾换行("No newline at end of file"),无害,不值得再推一个 commit 触发整轮矩阵,留待下次触碰时顺手恢复。 |
d64d85f
into
2026-10-18_unresolved-anchor-placement
The MAX_ANCHORS=16384 seed-loop cap (#2334) dropped every covered id past the window entirely, leaving the positional scan as their only recovery channel — and that scan dies after MAX_RESYNC_GAPS accumulated breaks. On long sessions with weeks of genuine drift, the 0.1.200->0.1.201 identity re-key (#3658) therefore mass-unfolded thousands of folded messages per session in both directions (upgrade and downgrade). Past-cap tool cores now persist a hash-free lite anchor ({r,c,t,b}): Pass 1's toolCallId channel consumes exactly those fields, so they re-anchor at any session length with zero added hashing and no new misattribution surface (claim discipline unchanged). Non-tool past-cap cores keep the positional-only status quo; the full-anchor cap and the #2334 zero-work steady-state contract are untouched (lite anchors reuse verbatim). FoldAnchor.n becomes optional (norm-keyed passes skip absent n); the seed loop continues past the cap for tool cores instead of breaking. Regression tests pin mint shape, the channel (via the reconciler's own counter), and the pre-fix-ledger convergence replay; all red without the fix, green with it.
The MAX_ANCHORS=16384 seed-loop cap (#2334) dropped every covered id past the window entirely, leaving the positional scan as their only recovery channel — and that scan dies after MAX_RESYNC_GAPS accumulated breaks. On long sessions with weeks of genuine drift, the 0.1.200->0.1.201 identity re-key (#3658) therefore mass-unfolded thousands of folded messages per session in both directions (upgrade and downgrade). Past-cap tool cores now persist a hash-free lite anchor ({r,c,t,b}): Pass 1's toolCallId channel consumes exactly those fields, so they re-anchor at any session length with zero added hashing and no new misattribution surface (claim discipline unchanged). Non-tool past-cap cores keep the positional-only status quo; the full-anchor cap and the #2334 zero-work steady-state contract are untouched (lite anchors reuse verbatim). FoldAnchor.n becomes optional (norm-keyed passes skip absent n); the seed loop continues past the cap for tool cores instead of breaking. Regression tests pin mint shape, the channel (via the reconciler's own counter), and the pre-fix-ledger convergence replay; all red without the fix, green with it.
…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.
…, R5 no-append, R6 projections, FIFO cap Five new cases in tests/fastpath.test.ts (suite now 27), encoding the v6 contract face in host-id space (#5403/#5418 v6; contract R4/R5/R6 + O1–O3 holds): 1. rewrite-passthrough (R4/O3): seed a world [s,a,b,c] with a hit whose list [h-b,h-c] grows the ledger, then send T=6 with slots ["h-c","X1","h-b"] — unknown real id BEFORE a still-known one. Width law len===T-K+1 still holds and slot K-1 keeps its id, so every cheap gate passes; the mid-list proof fires: ONE conservative legacy pass, CREDITED (parity with the pre-v6 credited catches so pathological cycles stay breaker-bounded), ids still enter the ledger. The next turn rides clean on the grown ledger → hit(no-count). Convergence in one pass, no speculative rebuild. 2. Same turn with BILI_ROLLOUT_WATERMARK_COMPACTION_PASSTHROUGH=0: the v6 layer is skipped entirely, the byte-compare covers only unchanged prefix positions ⇒ no warns, plain "hit" — exact pre-v6 behavior for that turn. 3. unidentifiable increment (R5): body grows but the increment slot is "?" (host minted no id) ⇒ hit WITHOUT ledger append + structured diagnostic "[pf-v6] unidentifiable-increment ... O1/O2"; the anonymous content still rides the replayed snapshot. 4. per-model projections share ONE logical ledger (R6): m-one hits, flip to m-two ⇒ ONE "seed-stale" legacy pass builds m-two's projection, then pure incremental; flipping back is symmetric. The ledger itself is model-independent. 5. FIFO cap: inflate the persisted lg to PF_LEDGER_CAP=2048 via ext, append one honest id ⇒ exactly the single oldest entry drops (oldest-first trim, newest kept) — bounded like the obs ≤4KB discipline. Geometry notes (cost hours to derive, kept here for the next maintainer): - shim lists span elements [K-1..T-1]; shape gate demands length T-K+1 where K = seed.stampT; slot[0] is the origin anchor (origin-pin vs last id of the previous turn's list, '?' neutral either side); - parseTailIds REJECTS duplicate real ids within one list ('?' may repeat), so a mid-insertion case needs TWO distinct known ids in play; - known-id re-emergence must sit at index ≥ 1 — index 0 can never be an unknown at this layer (the pin settles it first). Ref contract R4/R5/R6, owner rulings 2026-11-03 (m02699/m02725/m02730 line); #3756/#3658 alignment doctrine consumed as the id-fast-path domain per implementation guidance item 2.
Fixes #3642. Stacked on #3644 (merge that first).
What breaks today
Wire codecs bake dialect accidents into message identity, so the same logical conversation mints different core ids per protocol — switching dialect mid-session (opencode #3640:
/chat/completions→/v1/messages) churns ~20-68% of ids and trips the fold-destroyed misdiagnosis that #3641 just taught the reconcile pass to classify."[image]", openai deliberately""("switching the seed would move every pre-existing shape")toolCallIdbytes; raw JSON args hash verbatim (key order = new id)item.idThe fix
kernel/src/wire/identity.ts: canonical identity shared by all four codecs —deriveCanonicalMessageId(5-slot seed,toolCallIdslot retired; cluster suffixes disambiguate same-shape calls so deleting a sibling is local damage),canonicalToolArgs(JSON → recursive key sort → compact stringify, verbatim for non-JSON),canonicalOpaqueSeed(provideritem.id/statusstripped), shared[image]marker.imagePart: truestamp at parse time in all four codecs; consumers never text-compare the marker — tag injection rewrites markers mid-render, which previously made image cores render as text and lose the real image bytes ([Bug] #496 后续:旧 baseline 超窗时官方 Codex 图片估算持续误触发 502 #767 billing fallout).wireIndexguard between consecutive user cores.Verification
kernel/tests/cross-protocol-identity.test.ts): text/bash-tool conversation → byte-identical id arrays in all four dialects;{file,line}=={line,file}; sibling deletion moves only the cluster suffix.kernel-change: canonical identity module + per-part granularity in all four codecs (kernel/src/wire + tests); rebuild accumulators keep wire bytes stable.