Skip to content

[PR] fix(stream): keep requested ref numbers in stale-ref compress receipts - #6714

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
sx4im:fix-6712-compress-receipt-stale-refs
Nov 15, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
sx4im:fix-6712-compress-receipt-stale-refs

Conversation

@sx4im

@sx4im sx4im commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What broke

When every requested ref sits above the session frontier (the usual aftermath of a mid-conversation model switch), the compress failure receipt scrubbed the endpoints to a bare [stale-ref]. The range ...: line read range [stale-ref]..[stale-ref], so the caller could not tell which refs it used and could not self-correct.

What changed

How verified

  • New tests failed before the fix and pass after.
  • Targeted suites green locally: issue2146, issue2360, issue2432, issue2592, plus a compress-receipt sweep (76 tests). Typecheck and build clean. Full suite is for CI.

Note: the issue's secondary point (startId throws where endId clamps above the frontier) lives in kernel/src/boundaries.ts, so it needs the kernel-side process and is not in this PR.

Fixes #6712

When every requested ref is above the session frontier, the failure
receipt scrubbed the endpoints to a bare [stale-ref], so the caller
could not tell which refs it used. Emit a number-preserving marker
([stale-ref:00010]) instead: the range diagnostic stays readable while
the bare mNNNNN token never reaches the client-persisted receipt, so
the ranxianglei#2146 echo channel stays dead.

Fixes ranxianglei#6712
@ranxianglei ranxianglei changed the title fix(stream): keep requested ref numbers in stale-ref compress receipts [PR] fix(stream): keep requested ref numbers in stale-ref compress receipts Nov 14, 2026
@ranxianglei ranxianglei added bug Something isn't working p3 scope/kernel labels Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 — PR #6714 is the only open PR targeting #6712; no other open PR touches this scrub path (searched open PRs for the issue number and for stale-ref titles — the only adjacent work, #2742/#5985, is closed and different in focus).

Review of PR #6714 (head 42fd2ff7, 1 commit on current master):

Direction (issue #6712) — verified real. The scrub at src/stream.ts:1490–1496 (pre-fix) replaced each requested ref with the constant bare marker [stale-ref] whenever beyondFrontierNote fired (every endpoint above the frontier — the model-switch case), so the range …: line read range [stale-ref]..[stale-ref]. The PR takes the conservative variant of the issue's suggested fix: keep the number in the marker ([stale-ref:00010]) instead of un-masking the bare ref — the right call, because the bare mNNNNN token is exactly what the #2146 echo channel feeds; digits without the m prefix are not a valid ref token, so that channel stays dead.

Regression review — existing behaviors on the touched path, item by item:

  • dsh内部问题 出现这个错误后,重启dsh可以发消息 但陷入无限压缩失败 #2146 no-bare-ref invariant: preserved — the unchanged doesNotMatch(/m00010|m00014/) assertion still passes; the marker carries digits only.
  • [cause: stale-ref …] label and the acp_status verdict section (lastCause.startsWith("stale-ref"), src/acp-status.ts:274): they match the cause string, not the marker — unaffected.
  • beyondFrontierNote / frontierClampNote / rebaseNote text: unchanged; the clamp path is mutually exclusive with the scrub (beyond === "" guard).
  • Operator ctx.log line: still carries the real refs.
  • The only client-visible change is the disclosed marker format ([stale-ref] → [stale-ref:NNNNN]). Grep confirms no code parses the bare marker; the only consumer was tests/issue2146-compress-loop-breaker.test.ts:191, updated in this PR.

Code — staleRefMarker() is small, pure, and correctly documented: the bare-marker fallback is unreachable (verified — beyondFrontierNote requires every endpoint to match M_REF_NUM_RE), and the comment says so honestly. No dead code, no new deps, style matches the file.

Tests — teeth verified locally: both new tests FAIL against pre-fix src/stream.ts and PASS on the PR head. Targeted suites (issue2146/2360/2432/2592 + the new file: 29/29 pass) plus a 28-file compress-receipt sweep (207/207 pass); typecheck clean.

CI (live, mirror cache 12:21 UTC): 0 failures — 9 success, 12 skipped, 9 queued (guard lanes still running). mergeable_state: blocked pending those lanes + review.

Labels (judged on the PR's own diff): bug + p3 (diagnostic-quality defect on the failure path — compress still correctly refuses and the acp_status escape hatch is intact; availability untouched) + scope/kernel (compression/context-management surface). Applied.

Note: the issue's secondary point (startId throws where endId clamps above the frontier) lives in kernel/src/boundaries.ts and needs the kernel-side process — correctly out of scope here. It stays tracked in #6712 (same issue, same failure domain), so no new issue is warranted; the PR body discloses this.

八问 (PR 审核):

  1. 是什么问题: 当请求的所有 ref 都高于会话前沿(模型中途切换后的典型局面)时,compress 失败回执把请求的 ref 洗成裸 [stale-ref],range [stale-ref]..[stale-ref] 让调用方无法知道自己用了哪些 ref、无法自我纠正。
  2. 什么原因导致的: dsh内部问题 出现这个错误后,重启dsh可以发消息 但陷入无限压缩失败 #2146 的 echo 通道清洗(src/stream.ts:1490–1496)用常量裸标记替换请求 ref——清洗目标(裸 mNNNNN token)和诊断信息(ref 编号)被绑在同一个替换动作里,编号跟着一起被抹掉。
  3. 影响范围与严重程度: 仅 all-refs-above-frontier 失败路径的回执文本(边缘场景);compress 本身的拒绝行为正确,回执仍指向 acp_status。诊断质量缺陷,不损可用性 → p3。
  4. 怎么修复的: 清洗标记保留编号([stale-ref:00010])——裸 mNNNNN token 依然不进客户端持久化回执(dsh内部问题 出现这个错误后,重启dsh可以发消息 但陷入无限压缩失败 #2146 回显通道保持死亡,无 m 前缀的数字串不是合法 ref token),编号仍可诊断。是 issue 建议方案 1 的保守变体,方向正确。
  5. 是否有回归问题: 无。逐项审过: dsh内部问题 出现这个错误后,重启dsh可以发消息 但陷入无限压缩失败 #2146 无裸 ref 不变量(断言未动,仍过)、cause 标签与 acp_status 判决匹配(匹配 cause 串而非标记,不受影响)、beyond/clamp/rebase 三条 note 文本未动、clamp 路径与清洗互斥、operator 日志仍留真实 ref;唯一外泄变更即已披露的标记格式。
  6. 是否破坏缓存: 不涉及——未触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向: 未改——同一清洗机制,标记格式细化。次要问题(startId 抛错/endId 钳位不对称)在 kernel/src/boundaries.ts,需 kernel 流程,留在 compress receipt masks the offending ref as [stale-ref], making post-model-switch failures undiagnosable #6712 跟踪,本 PR 范围切分正确。
  8. 是否引入了新的配置: 不涉及。

判定: 可合(mergeable) — 方向对、无回归、测试有牙(修复前红/修复后绿已本地验证)、diff 干净(3 文件,+102/−2,每行都在目的内)。等 9 个排队中的 CI lane 全绿 + 人工 review;合并由人执行。

@ranxianglei
ranxianglei merged commit 8a70e1e into ranxianglei:master Nov 15, 2026
88 of 126 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Closes pair #6712 was auto-closed by the batch merge.

Superseded by #6765 (merged to master as 8a70e1e).

Your commit 42fd2ff is in master verbatim — same content, same authorship, only the object ID changed (the batch used a real git merge, no rebase or cherry-pick rewrite). Merged under a different branch name, so GitHub does not flip this PR by itself.

Thanks for the fix — it is live in master from 8a70e1e onward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p3 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compress receipt masks the offending ref as [stale-ref], making post-model-switch failures undiagnosable

2 participants