Skip to content

[PR] fix: name the session-binding inconsistency in the beyond-frontier compress receipt (#5151) - #6812

Open
ranxianglei wants to merge 2 commits into
masterfrom
2026-11-15_5151-binding-drift-receipt
Open

ranxianglei wants to merge 2 commits into
masterfrom
2026-11-15_5151-binding-drift-receipt

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Related to #5151 — stop-the-bleeding, layer 1 of 3 (decision-free)

What

Three independent reporters (Claude Code 0.1.197; omp/OpenAI 0.1.209 + 0.1.212) hit the same production defect: the compression nudge offers refs from a long-lived conversation view, but the compress call resolves to a DIFFERENT (near-empty) session view, so every offered ref sits far above the target's high-water and fails stale-ref. The model then has no safe recovery — the receipt only steered it to "request refs ≤ hi", which in the drift case means folding the WRONG session's few refs (one reporter correctly avoided that, but had no guidance telling it why or what to do instead).

This PR makes the beyond-frontier receipt (which already fires for this all-refs-above-frontier shape) name the session-binding inconsistency, forbid probing/guessing other refs (they may belong to another conversation; folding them corrupts it), and give the safe recovery (start a fresh conversation).

Behavior change (flagged)

  • Old beyond-frontier receipt ended with: ...NO superset of them can ever compress. Request only refs ≤ mNNNNN, or call acp_status for the live ranges.
  • New appends: If the ranges your compression nudge offered sit far above this session's ref space, the nudge and this compress call resolved to DIFFERENT conversation views (a session-binding inconsistency): do NOT probe or guess other refs to force a fold — they may belong to another conversation, and folding them would corrupt it; the safe recovery is to start a fresh conversation.

Scope: failure-receipt wording only (the compress tool's model-visible failure message). No change to session resolution, nudge timing/cadence, happy path, config, persistence, wire shape, or kernel/. Mode-agnostic (the receipt is shared across plugin + proxy modes).

Why this is the decision-free slice

This is the 止血 (stop-the-bleeding) part: it removes the harmful "request refs ≤ hi" steering in the drift case and gives a safe recovery, with zero behavior change to resolution or nudge. The remaining two layers are owner-gated and tracked in #5151:

  • Layer 2 (owner decision): on detected drift, suppress the actionable nudge ranges + provide a safe-recovery path (touches the nudge surface).
  • Layer 3 (owner decision): root fix — resolve nudge/acp_status/compress to one canonical session+generation (identity semantics).

A follow-up PR will add the precise cross-request "nudge issued under session A, compress landed under B" self-diagnostic (record the nudge's session + ref-span at inject, compare at the next compress/acp_status, write the mismatch into the failure receipt + bili.log). This PR is the immediate, safe slice that ships now.

Tests

  • tests/issue5151-binding-drift-receipt.test.ts (new): asserts the note carries the binding-inconsistency warning + anti-probe + fresh-conversation recovery for the all-above-frontier shape, and stays empty for the in-frontier / no-mapped-refs negatives.
  • Existing tests/issue2146-compress-loop-breaker.test.ts (which exercises beyondFrontierNote) still passes unchanged — it matches on the (mNNNNN) frontier substring and the "" negatives, both preserved.

Typecheck clean; targeted suites green (11/11 across the two files). Full-suite verdict = the CI test lanes on the pushed head.

@ranxianglei ranxianglei changed the title fix: name the session-binding inconsistency in the beyond-frontier compress receipt (#5151) [PR] fix: name the session-binding inconsistency in the beyond-frontier compress receipt (#5151) Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-15_5151-binding-drift-receipt (f66bce0)

Latest build — install this exact version

npm install -g billion-context@0.0.10159-pr.6812.6c89dfa

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
f66bce0 billion-context@0.0.10159-pr.6812.6c89dfa build
63fea3a billion-context@0.0.10151-pr.6812.c2fafd3 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6812.tgz
npm install -g package

Install instructions are refreshed on each push.

…ft receipt test

The test file and its three internal references cited a number that resolves
to a different thread on GitHub. The source bug is #5149, and the repo
convention (tests/issue<N>-*.test.ts) uses the GitHub issue number — the
previous name would mislead anyone grepping for the source issue.

Also correct the m00009 comment: the test mints 3 refs (a scaled-down version
of the reporter's near-empty shape), not 9.

Refs #5149
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 — 检索 open+closed 的 issue/PR:无其他在途 PR 触碰 beyond-frontier receipt 文案;相关在途 PR(#5546 / #5590 / #6712)机制不同(notice 面 / 其他车道),已关闭的 #4308 / #2742 / #2147 是 loop-breaker 与 generation 诊断,与本 PR 的 receipt 文案止血是不同面。本 PR 是源 bug #5149 三层修复的 layer-1(止血),方向正确。

我做了什么(已验证 + 已推 1 个代码侧修复 commit)

  • 本地 checkout PR head,npm ci && npm run build 通过;定向跑 tests/issue5149-*.test.ts + tests/issue2146-compress-loop-breaker.test.ts = 11/11 绿(2 新 + 9 既有),PR 声称的 11/11 属实。
  • 读了 src/stream.ts 的 beyondFrontierNote(424 行)、调用点(1471 行)、loop-breaker 段落(259-291 行)、stale-ref scrub(1497-1503 行),以及 kernel 侧对应文案(kernel/src/boundaries.ts:251,258)。
  • 已推 commit f66bce0c 到 PR 分支(小问题直接修,见 F1):测试文件 + 3 处内部引用改为源 bug 的 GitHub 编号 [Bug] Two Claude Code sessions in one folder (+ native /compact): compress always stale-ref, nudge lists refs compress rejects #5149;顺手修正 m00009 注释(测试实际铸 3 个 ref,不是 9 个)。PR 现 head = f66bce0,2 commits,仍 mergeable。

发现(按严重度)

F1 镜像编号泄漏(代码侧已修 / 元数据侧待 owner):PR 标题 (#5151)、正文 Related to #5151 / tracked in #5151、分支名、测试文件名全部用了内部镜像编号 5151;在 GitHub 上 #5151 = 另一条 thread(dsh inspector 文档 PR),正确源 bug 编号 = #5149(已核对标题+正文一致)。测试文件我已改;PR 标题/正文/分支名属源 PR 元数据,按 2026-11-12 规则我不改,请 owner 处理。

F2 正文范围夸大:正文 "What" 说三位 reporter 都是「offered refs 全部高于 target high-water」形态。核对源 thread:原始 CC 0.1.197 reporter 模型可见 ref 到 m00990,而 proxy target hi=m01559(/compact 剪枝后 live span m01366–m01559)——offered refs 在 frontier 之下,beyondFrontierNote 对该形态不触发。本 PR 只覆盖 2 个 omp 案例(francis-io:target hi=m00009,requested m01411–m01935;kaijianding:target hi=m01092,requested m05160+)。合并本 PR 不改变原始 CC reporter 的体验。建议正文改为「覆盖 above-frontier 形态(2/3 案例);CC below-frontier 形态仍在 #5149 跟踪」。

F3 正文措辞夸大 + 残留矛盾:正文说本 PR「removes the harmful 'request refs ≤ hi' steering in the drift case」。但 diff 没有删除该句——Request only refs ≤ ${hi}, or call acp_status for the live ranges. 仍无条件保留,新句只是追加在其后。drift 场景下 receipt 同时含两条矛盾指令:「request refs ≤ m00009」(危险:引导折叠 target 会话=可能另一条对话的 ref)与「do NOT probe or guess other refs… start a fresh conversation」。代码在缺 nudge-span 状态时无法区分 #2146 generation-reset(≤hi 正确)与 drift(≤hi 有害),只能双指令 + 让模型靠新句条件从句自选——这是合理近似,但正文「removes」是过度声称;真正移除要等 follow-up PR(记录 nudge 的 session+span)。另按 #4812 结论「同一 receipt 里两条矛盾指令会被当作零条执行」,drift 场景这对矛盾指令可能净合规为零——loop-breaker(3 次失败后 armed)硬停段是真正兜底。建议正文改「removes」→「overrides with an explicit conditional warning」;是否现在就条件化 ≤hi 从句留 owner 定(不阻塞,现状严格优于改前)。

F4 正文「mode-agnostic」不准确:正文称「the receipt is shared across plugin + proxy modes」。实际该 receipt 在 src/stream.ts(proxy 侧 compress 执行路径),plugin 模式用 kernel 自己的文案(kernel/src/boundaries.ts:251,258,本 PR 未改)。缺陷本身结构性地只在 proxy 模式(plugin 模式 nudge/compress/acp_status 共享 agent 本地 session view,不会 drift),所以修复位置正确,但正文措辞应更正为「proxy-mode receipt」。

F5 版本归因未证实:正文「omp/OpenAI 0.1.209 + 0.1.212」。thread 证据:francis-io = 0.1.212;kaijianding = 未报版本;0.1.209 是 agent 自己的复现构建(floor 9),非 reporter 版本。建议改「0.1.212 + 一例未报版本的 omp/OpenAI」。

F6 测试注释小疵(已修):原注释「refs minted only up to m00009」但测试只铸 3 个 ref(frontier m00003)。已在 f66bce0 修正。

F7(可选,不阻塞):缺一条 #2146 形态(nudge 在 frontier 内、requested ref 在 frontier 外)的定向行钉住「note 触发 + 新句存在」;现有 #2146 测试已钉住触发与 (mNNNNN) frontier 子串,故非必需。

8 问(结构化审核)

  1. 是什么问题:长会话里 nudge 给的 ref 与 compress 实际解析到的 session view 不一致(绑定漂移),模型收到「request refs ≤ hi」却无安全出口,可能误折另一条对话的 ref。
  2. 什么原因导致的:nudge 请求与 compress 请求各自独立解析 session,未保证解析到同一 session+generation;drift 时 compress 落到一个 ref 空间远小于 nudge 所见的 view,所有 offered ref 都高于其 high-water → stale-ref。
  3. 影响范围与严重程度:proxy 模式、且 nudge 与 compress 解析到不同 session view 时触发(3 个独立生产案例:CC + 2 omp,多版本)。严重度:模型无安全恢复路径,可能折叠错误会话的 ref(跨会话数据损坏)——p1 级缺陷的止血层;本 PR 只改失败 receipt 文案,不改变解析/触发,自身无新增风险面。
  4. 怎么修复的:在已对该「全 ref 高于 frontier」形态触发的 beyond-frontier note 里,点名 session-binding 不一致、禁止探测/猜其他 ref(可能属另一条对话,折了会损坏它)、给出安全恢复(开新会话)。纯文案,零行为变更。
  5. 是否有回归问题:审过既有行为——① dsh内部问题 出现这个错误后,重启dsh可以发消息 但陷入无限压缩失败 #2146 loop-breaker 测试(匹配 (mNNNNN) frontier 子串 + "" 负例)保持通过(本地 11/11 核实);② stale-ref scrub(1497-1503)只替换 requested 端点,新句无 mNNNNN 模式,不受影响;③ loop-breaker armed 段落(259-261)与新句兼容(都指向「别再 compress,继续任务」);④ 无阈值/时序/输出格式/缓存/重试漂移。残留:drift 场景下「request refs ≤ hi」与新句矛盾(F3),现状靠模型自选 + loop-breaker 兜底,真正消除待 follow-up。
  6. 是否破坏缓存:不涉及(纯失败 receipt 文案,不碰缓存/游标/去重键)。
  7. 是否改了设计方向:不涉及(不碰 session 解析/nudge 时序/架构;layer-2/3 的解析统一仍在 [Bug] Two Claude Code sessions in one folder (+ native /compact): compress always stale-ref, nudge lists refs compress rejects #5149 由 owner 拍板)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

CI 状态(实时):我的 rename commit 已重触发 CI;新 head f66bce0 上 0 失败,多数 test lane 仍 queued(2 完成/2 skip)。PR 落后 master 92 个 commit(merge-base 3858b69,2026-11-14),该区间仅 1 个 commit 触碰 src/stream.ts(185042e「perf: index covered timestamps」,不同区域),GitHub 报 mergeable 无冲突,但合并前需 rebase 到当前 master,以 rebase 后 head 的 CI 为最终判定。

结论:可合(rebase + 元数据编号修正后)。代码本身干净、最小、测试本地核实。合并前请 owner:① rebase 到 master;② 修 PR 标题/正文/分支名的编号引用(→5149);③ 酌情按 F2/F3/F4/F5 更正正文措辞(不阻塞)。F3 的「是否现在就条件化 ≤hi 从句」留你定——我的推荐是不在本 PR 改(保持止血最小面),由 follow-up PR 用 nudge-span 状态精确化。

(按 2026-11-12 规则,我未改动源 PR 的标题/标签/正文,仅推了代码侧的编号修正 commit。)

This branch has not been deployed

No deployments
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.

1 participant