Repository navigation
fix: attribute incremental-turn acks by per-request turn id, not URL (#3329) - #3340
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4100-pr.3340.c90dca1This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3340.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) PR 审查结论(独立审核,非复读 issue 侧分析)八问:
测试有效性:三个新测试断言有牙、层次正确——opencode/omp 套件钉住「迟到的同 URL 响应必须记到携带其 turn id 的会话、绝不记到另一个」(正是 #3329 的 bug field),native-intercept 套件钉住逐 dispatch 的头传递(含 Request-object 形态)。缺口:dsh-native 的 armed-flag 路径无单元测试;交错/双规划场景无测试(与上面两条残留对应,已在 #3329 清单跟踪)。 CI 状态:head 审查中发现的新问题处置:
判定:rebase 到当前 master 后可合(同时清掉唯一红 shard)。按 §7.4 不可自动合并(跨 5 个模块、并发语义行为变更、guard 移除属回退行为变更)——请人工合并。 |
rahul05ranjan
left a comment
There was a problem hiding this comment.
I filed #3329, so I went through this against the exact sequence described there rather than just the diff summary — this fixes it, and cleanly.
What I verified:
- Attribution mechanism.
onResponsenow receives this dispatch's outgoing headers as a third argument at all four send sites in native-intercept (first/retry × routed/rewrite), and each adapter keys its pending map by a freshx-bili-turn-idstamped at plan time. I checked the runtime semanticsoutgoingHeadersOf()depends on with a standalone Node script against a local server:init.headersdoes win over a Request-object input's own headers, pre-stamped Request-object headers do ride the wire, andHeadersiteration yields lowercase names — so the lowercase-record mirror matches what fetch actually sends and theheaders?.[INCREMENTAL_TURN_ID_HEADER]lookup can't miss on casing. - The #3329 sequence, old vs new. Old: A plans at t0 (URL slot → A), B plans at t+31s (A's entry aged out, slot now holds B), A's late response lands at t+32s with
x-bili-applied-seq→incPending.get(url)returns B's entry → B's watermark advances on A's seq. New: A's response carries A's own turn id, whose entry was already swept → lookup misses → nothing is attributed; B seeds untouched and A reseeds honestly. The regression tests in the opencode/omp suites pin exactly this (one shared URL, 31s clock jump), including that B later rides its own seq of 7. - Retry restamps.
withHeadersmerges rather than replaces, so a turn id stamped on the first pass survives the retry restamp even after dsh'sincTurnIdArmedflag is consumed — a retried dispatch still correlates back to its pending entry. - Transition. The pending maps are in-process only and the shared helper state machine (
noteIncrementalAck, keyed by conversation id) is unchanged, so there's no in-flight migration concern. pi.ts staying untouched is right — its ack channel already carries session context.
Two small things:
- dsh-native.ts:
sweepStaleruns after theprobeIncrementalTurnsbail-out, so once the probe is off the pending map isn't swept until the next planned turn. Harmless now that the TTL is memory-hygiene-only, but omp and opencode sweep before the probe check — the placement differs across adapters for no obvious reason. - Confirming I read the omp behavior change right: dropping the single-in-flight-per-URL guard means a same-session double-dispatch (hosts shouldn't, but if one did) now plans two turns against one conversation state instead of falling back to full resend. The 409 → sticky-dead → resync backstop covers it, just noting it's a real behavior delta beyond the concurrent-sessions win.
One caveat: I couldn't run the new suites on my machine (no dev deps available here), so the test-level claims are from reading them; everything above I either traced in the code or ran directly.
2e1e939 to
a496227
Compare
a496227 to
ae50b02
Compare
…3329) The pending-ack maps in opencode-native, omp-native and dsh-native were keyed by request URL. Two conversations sharing one provider URL could cross-attribute x-bili-applied-seq when a response arrived late or the slot was evicted, poisoning both watermarks and killing incremental turns for both via the sticky dead flag. - native-intercept: thread each dispatch's outgoing headers into state.onResponse (new third arg); outgoingHeadersOf() covers all four fire sites (routed/rewrite x first/retry). - incremental-client: x-bili-turn-id header, newIncrementalTurnId(), generic sweepStale(). - opencode/omp/dsh adapters: stamp the turn id on the outgoing request, key the pending map by it, attribute responses by it; drop the single-in-flight-per-URL guard (concurrent conversations now run their own turns - the server lane's per-conversation lock already makes that safe); TTL becomes memory hygiene only. dsh gains a TTL (it had none). - regression tests: same-URL late-response cross-attribution for opencode and omp; per-dispatch header threading in native-intercept.
ae50b02 to
31d0f3f
Compare
|
Rebased onto latest master (fa41483 → 31d0f3f) — this absorbs the three follow-ups that landed since the last head:
Conflict resolution was mechanical (parallel import lines). Full CI green on the new head, all e2e lanes green; incremental suites pass locally (omp 4/4, opencode 6/6, native-intercept 59/59, dsh |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.514-master.f054c9d # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3329
What is broken
The pending-ack maps of the incremental-turn feature (#3248) in opencode-native, omp-native and dsh-native were keyed by request URL. Two conversations sharing one provider URL could cross-attribute
x-bili-applied-seqwhen a response arrived late (or its slot was evicted): the true owner's ack was lost, both watermarks got poisoned, and the sticky dead flag killed incremental turns for BOTH conversations permanently (both fall back to full resend forever).Fix
Per-request correlation id; zero server-side changes:
state.onResponse(new optional third arg) at all four fire sites (routed/rewrite × first/retry);outgoingHeadersOf()normalizes string+init and Request-object inputs.x-bili-turn-idheader, anewIncrementalTurnId()generator, and a genericsweepStale().x-bili-*extras).pi.ts was already immune (its ack channel carries session context) — untouched. The server lane (
incremental-lane.ts) is untouched too: its per-conversation lock already makes concurrent same-URL turns safe, so the probe protocol stays 1.Behavior change (disclosed)
Config surface
None — no new env/config/flag; the feature stays behind the existing
pluginIncrementalTurnsrollout gate (default off).Tests