Skip to content

fix: dsh 增量标记与 body 原子落位,补单飞行守卫——并发会话不再可能裸发增量体丢历史 - #3378

Merged
ranxianglei merged 2 commits into
masterfrom
fix/dsh-incremental-marker-race
Oct 16, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
fix/dsh-incremental-marker-race

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

ai: zhipuai-lb/glm-5.3

什么坏了(#3370)

dsh 把增量转换(beforeSend,在 native-intercept 里被 await)和标记盖章(headersFor,稍后另一次调用)拆在一个进程级共享布尔的两端。同一进程里两个并发模型请求(两个聊天窗口,或聊天+后台标题生成)跨过这个微任务边界就会交错:R1 置位 → R2 置位(仍 true)→ R2 的 headersFor 消费掉(false)→ R1 的 headersFor 看到 false → R1 的增量体不带标记直发。代理端标记分流要求 x-bili-plugin-turn 存在(handle.ts:146-152),没有它,只含新消息的 delta 被当普通请求原样转发——模型在零历史状态下静默答错,不是报错。

修复(向 omp/opencode 模式收敛)

  1. 原子盖章:标记头在转换发生的同一个 init 上盖(new Headers(init.headers).set(marker),紧挨 init.body 交换),同一钩子调用内完成;withHeaders 只在 init.headers 之上叠加 headersFor 自己的键,标记与 body 再无分家可能。headersFor 的消费分支删除。
  2. 单飞行守卫:同一 URL 有带标记请求等 ack 期间,后续请求走普通管线(否则它们的 ack 会撞上按共享模型端点 URL 为键的 pending 条目)。pending 条目带时间戳,30s 过期(与 omp/opencode 一致)。
  3. 顺带(fix: 一次瞬时 409/503 不再把增量压缩会话永久打回全量重发 #3377 已铺):200 无 ack 头不再误消费 pending。

测试

Stacked on #3377(409/503 恢复重写了本测试同样驱动的 onResponse 分支),合并顺序:#3377 → 本 PR。

Closes #3370。来自 #3331 区间审查(D-H1)。

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/dsh-incremental-marker-race (1ccb554)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3997-pr.3378.d106b03

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

Install instructions are refreshed on each push.

ranxianglei pushed a commit that referenced this pull request Oct 16, 2026
…ending incremental entry (#3378 align)

The PR's own comment promised 'keep the pending entry for the marker'd response still in flight', but all four ack collectors deleted the entry unconditionally right after the lookup. A concurrent full-resend request's plain 200 (no seq header) arriving first would consume the entry, so the marker'd response's ack was lost: the client's sinceSeq lagged, the next turn replanned already-applied messages into the delta, the server answered 409, and #3377's recovery reset to a full resync — self-healing degradation, but it defeats the single-flight design this PR adds.

Invariant relied on: src/incremental-lane.ts installs a writeHead wrap that stamps x-bili-applied-seq on every diverted response that reaches forward(); every lane-written rejection (400/409/503) is emitted before that wrap and therefore never carries the header. So 200-without-seq is provably a foreign response: keep the entry (bounded by the existing 30s TTL); every other status keeps its previous consumption semantics. Regression test: dsh seam test step 2b feeds a foreign 200 before the marker'd response and asserts the next turn still plans a clean delta.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。本 PR(原子盖章+单飞行,closes #3370)与它 stack 其上的 #3377(409/503 恢复,closes #3369)、以及并行的 #3340(per-request turn-id 键控 pending map,closes #3329)是三个不同修复。但本 PR 第 2 部分(单飞行守卫)与 #3340 命中同一根因,存在机制交叠与合并顺序问题——见文末「重点提示」,这是本次 review 最需要你拍板的地方。

结构化八问

  1. 是什么问题:dsh 增量压缩把「转换 body」(beforeSend)和「盖标记头」(headersFor)拆在两个钩子调用之间、靠一个进程级共享布尔传递标记意图。同一进程里两个并发模型请求跨过这个 await 微任务边界会交错:R2 的 headersFor 消费掉本该属于 R1 的置位,R1 就带着无标记的 delta 体(只含新消息)直发。代理端只在有 x-bili-plugin-turn 时才走增量分流(handle.ts:146-147),没标记的 delta 被当普通请求原样转发给模型 → 模型在零历史状态下静默答错,不报错。
  2. 什么原因导致:根因是「标记」与「body」的绑定被拆到两个不同调用点(beforeSend 改 body / headersFor 盖 header),中间隔着 await 边界和一个被所有会话复用的可变布尔。并发请求交错时,后到的请求会消费掉先到的请求的置位——典型的「可变状态放在错误的粒度(进程级共享标志)上被跨请求复用」。
  3. 影响范围与严重程度:触发条件=dsh 原生插件下、同进程两个并发模型请求(两聊天窗口,或聊天+后台标题生成)恰好跨 beforeSend→headersFor 边界且都走增量转换。严重度=高但条件性:命中即静默丢历史、模型答错(数据正确性事故,用户难察觉);未命中完全正常。
  4. 怎么修复的:把盖章从「稍后 headersFor 消费共享标志」改为「就在转换 body 的同一个 init 上原子盖上」(new Headers(init.headers).set(marker),紧挨 init.body 交换),让标记与 body 物理上无法分离;headersFor 只叠加自己的键(x-bili-plugin 等)、不再出标记。收敛到 omp/opencode 既有模式(omp-native.ts:124-128 逐行一致)。另加单飞行守卫:同 URL 有带标记请求在途时后续走全量管线,避免撞同一 URL 键的 pending 条目(pending 带时间戳 30s 过期)。
  5. 是否有回归:审了 dsh 增量路径既有行为逐项过——(a) 标记最终仍落在出站请求上:string/URL input 经 withHeaders 的 Headers-instance 分支合并保留(native-intercept.ts:291-294),Request-object input 经 init 覆盖同样保留;代理分流要的 x-bili-plugin(headersFor)+ x-bili-plugin-turn(init.headers)齐备 → 无回归;(b) headersFor 不再出标记,唯一消费者是 withHeaders 合并,净效果不变 → 无回归;(c) 单飞行守卫是新增行为:重叠窗口内请求从「各自尝试转换(旧竞态)」变为「走全量重发」,最坏是那一轮少点压缩效率、不影响正确性 → 有意变更,已披露;旧值=可能裸发增量体丢历史,新值=该轮退回全量重发。
  6. 是否破坏缓存:不涉及缓存/重试/游标失效策略本身;单飞行让个别重叠轮次退回全量重发,前缀仍完整,不破坏 prefix cache。
  7. 是否改了设计方向:向 omp/opencode 既有的「标记随 init.headers」模式靠拢,是收敛不是转向。但单飞行部分与 fix: attribute incremental-turn acks by per-request turn id, not URL (#3329) #3340 交叠(见下)。
  8. 是否引入新配置:无新 env/config/flag;功能仍在既有 pluginIncrementalTurns 灰度门后(默认关)。

重点提示(需你拍板):与 #3377 / #3340 的协调

建议(按此顺序推进,请确认):① 先合 #3377(base);② 合本 PR——原子盖章是 #3370 真正修复(静默丢历史,高优先)、单飞行作 #3340 落地前的过渡止损;③ 把 #3340 修绿合入,其 turn-id 键控取代单飞行守卫,届时用一个 follow-up 小 PR 删掉 dsh 里已冗余的单飞行检查(或并入 #3340 rebase)。三个 PR 都落在 dsh/omp/opencode 的 onResponse + pending-map 同一批热文件上,属热文件竞争,需显式排好顺序再逐个合。

已做的动作

  • CI 全绿(head commit c82744f):test 各分片 ubuntu/windows × node22/24 全 success,全部 static gate(kernel/lane/version/config-surface/unused-exports/docs…)通过,e2e 车道按非 e2e PR 惯例 skip。
  • 顺手修一处 diff 整洁度缺陷:dsh onResponse 里 } 与 if (response.status === 409) { 两语句被挤到一行(fix: 一次瞬时 409/503 不再把增量压缩会话永久打回全量重发 #3377 重写 onResponse 时带入),拆回两行,纯格式无行为变更,已 push 到 PR 分支(c82744f)。

判定

原子盖章部分成立、测试有牙(CI 全绿),可在 #3377 之后合入——它修的是静默丢历史的高优先缺陷。单飞行守卫作为过渡止损可保留,但须待 #3340 定去留后再决定删/留,不建议在未定 #3340 之前把整 PR 当作最终闭环合入。等你对上面三步顺序点头。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Review 完成:可合(待 CI 绿);合并顺序 #3377 → #3378(stacked,祖先关系已验证)。

独立重走了完整机制链(两个 PR 的 diff 逐行读 + 服务端 src/incremental-lane.ts 交叉验证)。审核发现 1 个真实缺陷,已直接修复并推送(commit 098cabfdb,见下)。

结构化八问

1. 是什么问题
dsh 两个并发模型请求(两个聊天窗口,或聊天 + 后台标题生成)跨钩子边界交错时,一个请求的增量体(只含新消息)可能不带 x-bili-plugin-turn 标记发出——代理当普通请求转发,上游模型拿到无会话历史的 messages,静默答错(损坏类,不是报错)。stacked #3377 修同一条 ack 管线上的第二个缺陷:一次瞬时 409/503 永久杀死该会话的增量轮次。

2. 什么原因导致的
dsh 把「转换 body」(beforeSend)和「盖标记」(headersFor)拆成隔微任务边界的两个钩子,靠进程级共享布尔(incMarkerArmed,apply() 每进程只跑一次)传递状态。交错序列:R1 置位 → R2 置位 → R2 消费 → R1 看到 false → R1 的 delta 裸发。根因是两步之间的非原子状态交接——omp/opencode 都在同一个请求对象上原子盖标记,只有 dsh 拆开了。

3. 影响范围与严重程度
触发条件:rollout 开启 + unified sidecar 存活 + anthropic 字符串 body + toolsReady + ≥2 并发。当前 pluginIncrementalTurns 默认 0%(暗),今天零用户可见影响;一旦开启即 blocker 级——静默答错是数据损坏类(#1039 家族),无任何报错信号。409 永久死亡面是性能退化(退回全量重发),进程重启可恢复。

4. 怎么修复的

  • 标记盖进写 body 的同一个 init(完全对齐 omp 模式),删掉 incMarkerArmed;
  • incPendingAcks 加 per-URL 单飞行守卫(fresh <30s → 后来的请求走全量重发),TTL 30s 与其他两 lane 一致;
  • 附带修掉同一竞态的第二张脸:rewrite 路径的代理死亡重试会第二次调用 headersFor(native-intercept.ts:935)——旧设计第一次调用就消费掉布尔,重试请求变成「已转换 body + 无标记」;新设计标记在 init 上,天然活过重试;
  • fix: 一次瞬时 409/503 不再把增量压缩会话永久打回全量重发 #3377:拒绝电路——单次 409 → 下一轮全量 resync 重播种;连续 3 次 409 无 ack → dead;503 → 保留会话状态、清 probe、下一轮重新探测。

5. 是否有回归问题
逐项审过的既有行为:wire 格式(lane body 形状 + 标记值)不变;服务端两个 PR 均未触碰;native-intercept 两条 dispatch 路径未触碰;headersFor 照常盖 x-bili-plugin/conversation/model-info;409/503/其他状态的 ack 消费语义保持,唯一例外是 200-无-seq 这一例(它本身就是缺陷,见下)。缓存/重试/游标策略未变。未发现回归。

6. 是否破坏缓存
不。wire 上 system 消息与消息内容字节不变;ack 水位只影响下一次请求带哪些消息,不影响前缀缓存键。

7. 是否改了设计方向
没有——把 dsh 对齐到 omp/opencode 既有的原子模式,没有引入新架构。

8. 是否引入了新的配置
没有。复用既有 pluginIncrementalTurns rollout 门(默认 0%,不变)。

行为变更清单(旧 → 新,全部在 rollout 门后,当前暗)

行为 旧 新
dsh 标记传输 共享布尔,headersFor 消费(可被并发请求偷走) 与 body 一起原子盖在 init.headers
重试时的标记 丢失(重试请求 = 已转换 body + 无标记) 保留(标记在 init 上)
200-无-seq 响应 无条件消费 pending 条目(缺陷) 保留条目,30s TTL 兜底
单次 409 会话永久退回全量重发 下一轮全量 resync 重播种
连续 3 次 409 (概念不存在) dead(sticky fallback)
503 永久死亡 保留状态,下一轮重新探测
同 URL 并发请求 各自转换(ack 互相腐蚀) 只有第一个转换,其余走全量重发

审核发现并已直接修复的缺陷(commit 098cabfdb)

四条 lane(dsh/omp/opencode/pi)的 ack collector 都在查表后无条件 delete(key)——与本 PR 自己的注释("keep the pending entry for the marker'd response still in flight")矛盾。交错序列:R1 转换(存条目 E1)→ R2 并发被单飞行跳过 → 走全量重发 → R2 的普通 200(无 seq)先到 → E1 被删 → R1 的带标响应到达时 pending===undefined → ack 丢失 → 客户端 sinceSeq 落后 → 下一轮把已应用消息重放进 delta → 服务端 409 → #3377 resync。自愈合的性能退化(不是损坏),但它恰好废掉了本 PR 引入的单飞行设计。PR 正文声称的「200 无 ack 头不再误消费 pending」在四个 lane 里都不成立。

修复依赖一个已验证的服务端不变量:src/incremental-lane.ts 成功路径装了 writeHead wrap,凡到达 forward() 的分流响应都盖 x-bili-applied-seq;所有 lane 自己写的拒绝(400/409/503)在 wrap 之前写出、从不带该头 ⇒ 200-无-seq 可证明是外部响应。修法:确认是自己的响应(200 带合法 seq / 409 / 503 / 其他状态)才删条目;200-无-seq 提前 return 保留条目。409/503/其他状态的语义完全不动(那些响应可证明不带 seq、无法区分归属,保持旧行为避免引入新风险)。dsh seam 测试补了回归用例 2b:带标响应之前先喂一个外部 200,断言下一轮仍规划干净 delta(缺陷回归时第 3 步的 delta 断言直接红)。

本地验证:typecheck 干净;定向套件全绿——dsh-native 54/54(含新 #3370 测试 + 2b)、incremental-client-recovery / omp-native-incremental / opencode-incremental 均过。全量判定以 pushed head 上的 CI 为准。

测试有效性

seam 测试用生产闭包(经 _state*ForTest 钩子拿真实的 beforeSend/onResponse/headersFor,不是对受测逻辑打桩);断言有牙:回退到 armed-flag 设计时「标记在 init 上」「headersFor 不再吐标记」两条立刻红;单飞行与「ack 推进 delta」被钉住。recovery 测试钉住 mode/resync/sinceSeq/消息数/电路恰在 3 次跳闸/ack 重置。

边界注记(非阻塞)

marker-on-init 假定 dsh 以 (urlString, initObject) 形式调 fetch。若 dsh 某处传 (Request 对象, init),按 WHATWG 规范 init.headers 会整体替换 Request 原头(auth 丢失)。这是 issue 指定的设计、omp 同款模式已在跑、dsh 流量是 string-URL 形态——作为已核实的假设记录,不阻塞。

其余小注:INC_PENDING_TTL_MS 在三处重复定义(保持现状,与另两 lane 一致);pi.ts 的 pending 按 sid 为键且其转换本就是原子的(before_provider 钩子里直接返回替换载荷),从未有本竞态——加同款 200-无-seq 守卫只为一致性。

结论:可合。 合并顺序 #3377 → #3378。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

跟进(接上一轮 review):我上一轮标记的那个残留——「单飞行守卫本身不充分:onResponse 顶部无条件 delete(url),一个被放行的并发全量请求的外来 200(无 seq)若在带标记请求响应前到达,会偷删 pending 条目、丢掉真正的 ack」——已在分支上修复,我逐行核对过,修法是对的。

核对了 098cabf(刚推到分支上,标题 "...must not consume the pending incremental entry (#3340 align)")。它把四个 ack collector(dsh/omp/opencode/pi)里 x-bili-applied-seq 的提取挪到 delete() 之前,新增早退守卫:200 && seq 缺失/非数字 时保留 pending 条目不删。依赖的不变量成立且写进了注释:src/incremental-lane.ts 的 writeHead wrap 会给每个到达 forward() 的分流响应盖 x-bili-applied-seq,而 lane 自写的拒绝(400/409/503)在该 wrap 之前发出、永远不带这个头——所以「200 无 seq」可证明是并发的外来全量重发响应,保留条目(有既有 30s TTL 兜底)。这正是我担心的「A 请求的 ack 被 B 的外来 200 偷删」场景,现已堵住。回归测试 step 2b(先喂外来 200、再喂真响应,断言下一轮仍是干净 delta)有牙。该残留关闭,并入本 PR,不单独立项。

一处可选小 nit(功能无差,不强求):seq 校验口径不一致——dsh 用 /^\d+$/.test(seq),omp/opencode 用 Number.isFinite(Number(seq));仅对空字符串 seq 行为不同,真实 HTTP 头不会出现空值,实际等价。要统一我可以顺手推一个,但这条分支正被并行改动,我先不抢,避免撞车。

#3340 协调点仍成立:本分支仍是「URL 键控 pending map + 单飞行守卫」;#3340(per-request turn-id 键控,closes #3329)落地后会取代单飞行守卫、让整类 URL 串号问题消失。#3340 当前 CI 红(test ubuntu/node22/shard2 失败),未就绪。三步顺序建议不变:#3377 → 本 PR(#3378)→ 修绿并合 #3340(届时用一个 follow-up 删掉已冗余的单飞行检查)。

现状:PR head = 098cabf,mergeable = true,新 head 的 CI 跑中(暂无失败)。上一轮结论更新为:原子盖章 + 单飞行守卫 + ack 消费修正三者都已就位且方向正确,待新 head CI 转绿、你对合并顺序点头即可推进。PR 由你合(人工动作,我不会合)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

更新:pushed head 098cabfdb 的 CI 已全绿——29 success + 13 skipped(常规门控 e2e lane),无失败。本地定向验证与 CI 一致。可合。

ranxianglei and others added 2 commits October 16, 2026 17:39
…flight + TTL on the ack stash

native-intercept.ts:698-700) and marker stamping (state.headersFor, called
at :705) across a single closure-level boolean shared by EVERY session in
the process. Two concurrent model requests crossing that microtask
boundary interleaved: R1.beforeSend armed the flag -> R2.beforeSend ->
R2.headersFor consumed it -> R1.headersFor found it disarmed and R1's
delta body shipped with NO marker. The proxy forwarded the delta-only
messages verbatim (incrementalTurnBodyShape is only consulted under the
marker, handle.ts:146-152), so the model answered with no conversation
history — silent wrong answers, not an error.

- The marker now rides init.headers from the conversion itself (omp
  pattern): new Headers(init.headers).set(x-bili-plugin-turn, "1") right
  where init.body is swapped, atomic in the same hook invocation. withHeaders
  merges headersFor's own stamps on top, so the marker and the body can
  never part ways. headersFor's armed-flag branch is gone.
- Single-flight guard (omp-native.ts:104-106 pattern): while a marker'd
  request for the same URL awaits its ack, later requests ride the normal
  pipeline — their acks could otherwise collide with the pending entry
  keyed by the shared model endpoint URL. Pending entries carry at:
  Date.now() and expire after 30s (matches omp/opencode).
- Test seams: _stateBeforeSendForTest/_stateOnResponseForTest exposed
  alongside _stateHeadersForTest; the dsh mock proxy serves the
  /__bili/plugin/turn feature probe (turnEnabled flag).

Tests: new #3370 dsh test drives the seams end-to-end — marker+body
atomic on the same init, headersFor carries no marker, single-flight
leaves an overlapping request untouched, ack advances the next plan to a
real delta. Existing suites re-run green: native-intercept 58/58,
incremental-lane 17/17, opencode/omp incremental + recovery suites, tsc
clean. The dsh test nulls BILI_PROVIDER_REWRITES/BILLION_CONTEXT_PLUGIN
(hermetic pattern from the #1772 suite) so it runs on hosts whose shell
is itself behind a bili proxy.

Stacked on #3377 (409/503 recovery rewired the onResponse arms this test
also drives).

Closes #3370
…ending incremental entry (#3378 align)

The PR's own comment promised 'keep the pending entry for the marker'd response still in flight', but all four ack collectors deleted the entry unconditionally right after the lookup. A concurrent full-resend request's plain 200 (no seq header) arriving first would consume the entry, so the marker'd response's ack was lost: the client's sinceSeq lagged, the next turn replanned already-applied messages into the delta, the server answered 409, and #3377's recovery reset to a full resync — self-healing degradation, but it defeats the single-flight design this PR adds.

Invariant relied on: src/incremental-lane.ts installs a writeHead wrap that stamps x-bili-applied-seq on every diverted response that reaches forward(); every lane-written rejection (400/409/503) is emitted before that wrap and therefore never carries the header. So 200-without-seq is provably a foreign response: keep the entry (bounded by the existing 30s TTL); every other status keeps its previous consumption semantics. Regression test: dsh seam test step 2b feeds a foreign 200 before the marker'd response and asserts the next turn still plans a clean delta.
@ranxianglei
ranxianglei force-pushed the fix/dsh-incremental-marker-race branch from 098cabf to 1ccb554 Compare October 16, 2026 09:52
@ranxianglei

Copy link
Copy Markdown
Owner Author

ai: zhipuai-lb/glm-5.3

Rebase 完成(#3377 已并入 master 后的冲突已解),现 HEAD = 1ccb554f,mergeable = true,CI 重跑中。

冲突解法:dsh onResponse、omp/opencode/pi 三个 ack collector 的冲突块全部取本 PR 最终形态(098cabfd 的「seq 提前提取 + 200-无-seq 早退保留 pending」结构);c82744f3 那条 style 拆行在 master 侧已存在,rebase 后自然吸收为空,无重复提交。tsc --noEmit 干净;origin/master...HEAD 只含本 PR 5 个文件(dsh/omp/opencode/pi + dsh 测试),无夹带。

对「单飞行 vs #3340」阻塞的立场(按 reviewer 三步顺序执行,供 owner 拍板):

  1. ✅ fix: 一次瞬时 409/503 不再把增量压缩会话永久打回全量重发 #3377 已合;
  2. 本 PR 按现形态合入——原子盖章是 dsh 增量轮次:标记竞态可让增量体不带标记直发,模型在无历史状态下静默答错(需开启 rollout 才触发) #3370 的真修复,单飞行守卫是 fix: attribute incremental-turn acks by per-request turn id, not URL (#3329) #3340 落地前的过渡止损,保留;
  3. fix: attribute incremental-turn acks by per-request turn id, not URL (#3329) #3340 修绿合入后,用 follow-up 删掉 dsh 单飞行检查(或并入 fix: attribute incremental-turn acks by per-request turn id, not URL (#3329) #3340 rebase),不留死代码。

合并仍留给人类;CI 绿后即可按顺序推进。

@ranxianglei
ranxianglei merged commit cfe5769 into master Oct 16, 2026
42 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.493-master.cfe5769 (rolling master tag).

npm install -g billion-context@0.0.493-master.cfe5769  # 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 17, 2026
ranxianglei added a commit that referenced this pull request Oct 26, 2026
opencode-native.ts had the same claim-before-guard order as dsh/omp
(planIncrementalTurn with the harvested msgIds at :979, the #3378
single-flight guard below it). A guard-blocked turn burned its
harvested ids the same way; hoist the guard above the planning call.
alignedMsgIdsForWire() is a pure read of the harvest map, so it is
safe to keep inline in the (now post-guard) plan call.

Regression test mirrors the dsh one: blocked attempt must not burn
the ids; after the seed acks, the retry still pins them
(pre-fix: actual undefined).
ranxianglei added a commit that referenced this pull request Oct 26, 2026
…he turn

A turn that the guard discards had already claimed its msgIds
client-side (all-or-nothing, #4491). The burned ids were never
released, so the host's retry of the same turn lost the whole
msgIds field and the server pinned those rows to content-derived
identity — the exact host/server divergence #4834 just fixed,
self-inflicted here by the client lanes themselves.

Hoist the #3370/#3378 single-flight guard above planIncrementalTurn
in both native lanes (dsh, omp). The guard only reads the pending-ack
table, so the reorder changes nothing for the guard itself; planning
now only happens for turns that will actually be dispatched.

Regression test: a guard-blocked delta attempt must not burn its ids
— after the seed acks, the retry still pins msgIds (pre-fix: the
field is silently dropped).
ranxianglei added a commit that referenced this pull request Oct 26, 2026
opencode-native.ts had the same claim-before-guard order as dsh/omp
(planIncrementalTurn with the harvested msgIds at :979, the #3378
single-flight guard below it). A guard-blocked turn burned its
harvested ids the same way; hoist the guard above the planning call.
alignedMsgIdsForWire() is a pure read of the harvest map, so it is
safe to keep inline in the (now post-guard) plan call.

Regression test mirrors the dsh one: blocked attempt must not burn
the ids; after the seed acks, the retry still pins them
(pre-fix: actual undefined).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dsh 增量轮次:标记竞态可让增量体不带标记直发,模型在无历史状态下静默答错(需开启 rollout 才触发)

1 participant