Repository navigation
[PR] fix(fastpath): exclude id from watermark head check for pinned sessions (#7345) - #7352
ranxianglei wants to merge 2 commits into
Conversation
…ns (#7345) The watermark fastpath head check compared a.id !== b.id between the fresh head cores (content-hash ids minted by openaiToCore, h_…) and the stashed seed cores. In a pinned session (pluginLaneServerHistory + pluginMsgIdIncremental — the 2x2 traffic the fastpath exists to accelerate) prepare-openai rebinds originalMessages to the POST-PIN cores before finalizeWatermarkTurn, so the seed carries host/ledger msgids while a fresh openaiToCore parse mints content-hash ids. The two id namespaces differ structurally on every turn, so the comparison could never pass: every turn of a pinned session logged fastpath miss (head-prefix-drift) and fell back to the full legacy parse. The id is not a content signal: exclude it from the head comparison (content and role inequality are still caught, and a remint with identical bytes is not a rewrite). Non-pinned traffic keeps content-hash ids on both sides, so when a.id === b.id the full-JSON equality holds iff the id-stripped equality holds — existing behavior is unchanged. Regression test plays the field sequence: seed with a host-id list, then a tail-only growth turn must HIT (was head-prefix-drift) and an in-place head edit must still drift. Fixes #7345
[bot] 🏷 Review of PR #7352 — fix(fastpath): exclude id from watermark head check for pinned sessions I pulled the branch, verified the code against the production path, and ran the targeted checks. The fix is correct and minimal. What I verified
Why the fix is correct I also confirmed the test faithfully reproduces the production seeding path: 标签: 结构化八问
判定:修复正确、最小、测试充分(含 RED→GREEN 回归测试)。CI 跑绿后即可合并(合并由人来,我不合)。 |
[bot] 🏷 Follow-up: the PR head moved while I was reviewing — new commit The earlier "cancelled" |
[bot] 🏷 CI landed green. On head Final status
The PR is ready to merge — merging is human-only, so it's in your hands: #7352 |
🔶 需要决策 build-artifact red = npm publish permission 404 — not a code issue, needs owner to fix NPM_TOKENBottom line: this PR's code builds successfully. The red is an Diagnosis (each point verified live this run)
Options (need owner action)
Default (if undecided): go with A — it's the only path that restores build-artifact, and it doesn't touch this PR's code. Impact on this PR
八问
收工判定:本 PR 代码侧 ready(构建成功、无代码改动);build-artifact 红为 NPM_TOKEN 权限基础设施问题,已打 |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
The #7352 absorption (cherry-pick of ba4d5a6) carried the original PR's wrong issue reference: the pinned-session id-namespace issue is #7345 ("Watermark fastpath never hits on 2x2 pinned sessions"); #7347 is the unrelated storage-poison-row-isolation root-cause issue. Comment and test name only — no behavior change.
Summary
The watermark fastpath (full-resend watermark, KDD #15) never hits on 2x2 pinned sessions (
pluginLaneServerHistory+pluginMsgIdIncrementalon) — exactly the traffic it was designed to accelerate. Every turn logsfastpath miss (head-prefix-drift)and falls back to the full legacy parse.Root cause
src/server/fastpath.tshead check compareda.id !== b.idbetween the fresh head cores (content-hash ids minted byopenaiToCore,h_…) and the stashed seed cores. In a pinned session,prepare-openairebindsoriginalMessagesto the POST-PIN cores beforefinalizeWatermarkTurn(the pin re-keys every id to the host/ledger msgid), so the seed carries host msgids while a freshopenaiToCoreparse mints content-hash ids. The two id namespaces differ structurally on every turn of a pinned session, so the comparison can never pass. Pre-pin (no 2x2) traffic keeps content-hash ids on both sides and hits fine — which is why the existing unit tests (rollout flags off, no pin) stayed green.Fix
Exclude the
idfield from the head comparison. The id is not a content signal: content and role inequality are still caught (id-stripped JSON equality), and a remint with identical bytes is not a rewrite. Non-pinned behavior is unchanged — whena.id === b.id, full-JSON equality holds iff the id-stripped equality holds.Behavior change
None to the final cores. This restores the fastpath's intended behavior for pinned sessions: previously they always missed (full parse + re-anchor every turn); now they hit the O(window) fastpath. The final cores are identical to the legacy path (the head check still verifies content/role equality; only the id-namespace difference is now ignored, which is correct because the id is derived from the content or stable with it). No wire change, no config change, no data-loss.
Tests
tests/fastpath.test.tsplays the field sequence: seed with a host-id list, then a tail-only growth turn must HIT (washead-prefix-drift), and an in-place head edit must still drift.Fixes #7345