Skip to content

fix: break the nudge-decide × self-heal suppression deadlock (Closes #3004) - #3019

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-13_nudge-decide-selfheal-deadlock
Oct 13, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-13_nudge-decide-selfheal-deadlock

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

是什么问题

Session df251671(dsh profile dsh-tui,plugin v0.1.195)4h46m 内从 14K 长到 766K tokens,零压缩(state.blocks=0、tokensSaved=0),最后钉死在 765,712/984,464(77.78%)。完整取证包见 issue 附件。根因是三个各自合理的机制互相咬死:

  1. 决策 side call 被饿死 —— model-decided nudge gate 的 side call 以 {...parsed} 构造、只改 token budget;host 侧 reasoning 旋钮原样随行(dsh cordis patch 给默认模型设了 reasoningEffort: max)。200 token 默认预算下,reasoning 质量先把整个预算烧完,一行 JSON 判决都来不及产出 → message.content 为空 → "empty response" 硬失败 → ladder 计数为链路从未有过的原因累加(事故里 5 次 gate 中 3 次这样死)。
  2. 投递台账说谎 —— INJECT T1 日志标签和 self-heal idle streak 都信 pre-gate 的 willInjectNudge;异步 decide gate 随后否决时,什么也没送达,轮次却仍计「已 nudge」。5 个这样的轮次武装了 suppress-nudge。
  3. 循环等待 —— 抑制 gate 住 willInjectNudge,而它 gate 住的本就是能打破抑制的 ladder-fallback 分支;释放条件又等「压缩证据」——只有 nudge 才能引来的证据。锁存跑了 4h12m、零 blocks,直到会话死亡。

修法(一个机制族,四个协同改动)

改动 效果
decide-ladder fallback 凌驾于锁存的抑制之上(四条 prepare lane 一致) 失败恢复路径即使在抑制期也能到达模型;consumeFallback 保证每 3 连败只 punch-through 一次
新常量 SELF_HEAL_SUPPRESS_CAP_MS = 10 min(wall-clock) 抑制锁存最多存活 10 分钟;重新武装需再攒满 5 个 idle 轮次——噪声有界,基于证据的恢复路径不变
决策 side call 剥离 host reasoning 旋钮(reasoning_effort / thinking / thinkingConfig / reasoning,按协议) 小输出预算真正留给 JSON 判决;主请求不动
Prepared.nudgeOutcome post-gate 投递事实(+ INJECT-PENDING 标签 + 否决轮显式日志行) self-heal streak 只计真实注入;日志不再为模型可能否决的轮次宣称 INJECT

行为变更(old → new,必须披露)

  1. 抑制寿命:永久锁存(直到出现压缩证据)→ ≤10 分钟 wall-clock 封顶,且 ladder 耗尽期间允许一次性 legacy advisory punch-through。WHY:锁存可以活得比所有其他恢复通道都久(循环等待),事故实测 4h12m。
  2. 决策 side call wire shape:继承客户端 reasoning 参数 → 剥离(仅 side call;ephemeral,从不进客户端历史)。WHY:继承的 reasoning 质量饿死 200-token 判决预算。
  3. self-heal idle/zombie streak 记账:pre-gate arm 意图 → post-gate 实际注入。nudgeModelDecided OFF 的会话字节级不变(legacy 路径 armed 即注入);ON 时模型否决的轮次不再计入抑制。WHY:对模型从未收到过的通道武装抑制正是本事故的起点。
  4. 日志格式:nudge INJECT T1 → decide gate 未决时标 INJECT-PENDING T1(判决紧随既有 [acp-decide] 行);每个被否决的 arm 新增 [acp-decide] tier-1 nudge arm not injected (...) 行。
  5. 新内部面:Prepared.nudgeOutcome 字段、导出常量 SELF_HEAL_SUPPRESS_CAP_MS、导出函数 stripDecisionReasoningFields()。无新增 config key / env / CLI flag。

Config surface

无新增。全部改动骑在既有机制上(decide ladder、self-heal 状态机、既有 knobs);常量沿用 #2155 先例(代码常量而非配置)。

验证

  • 新回归套件 tests/issue3004-nudge-decide-selfheal.test.ts(7 测试):死锁复现(含 one-shot 语义 + cap 到期 + 通道重开)、starvation shape(side body 丢 reasoning 旋钮而主请求保留的 wire 断言)、false-ledger(否决轮永不武装抑制)、strip 函数 ×4 协议与 cap 语义单测。本地全绿(整文件 ×2 跑)。
  • 相邻套件本地全绿:nudge-model-decided(新功能:增加模型完全决策的压缩时机nudge触发 #2228 lane)、issue2155-self-heal、nudge-decide——与新文件合计 32/32。
  • npm run typecheck clean。
  • codex e2e core:本环境无法运行(需要 127.0.0.1:8199 活上游,此处不存在)——CI(.github/workflows/ci-e2e.yml)对本 diff 自动触发(触碰 src/server.ts + src/server/**)。
  • 未触碰 kernel/、pi-subagents/;无持久化格式、版本、release-flow 变更。

Review tier

ephemeral 决策 side call 的 wire-shape 变更 + fallback 默认行为变更 → 按 §7.4 留在 human-review tier(不满足 auto-merge)。

对 issue 取证的更正(逐条对照当前 master 验证后)

其余指控全部属实,两点更正:

Closes #3004

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-13_nudge-decide-selfheal-deadlock (6429766)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3410-pr.3019.492ed3b

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始 review。这是 agent 自己的 PR(head 8ffc44890,当前落后 master 233 个提交),按流程执行:① 读原 issue #3004 核方向 → ② rebase 到最新 master → ③ 定向验证(typecheck + issue3004 回归套件 + 相邻 nudge/self-heal 套件)→ ④ 逐文件精读 diff 做回归审查 → ⑤ CI 核对。结论稍后按八问体例补上。

Session df251671 pinned at 765K/984K tokens with state.blocks=0 for 4h12m:
the model-decided gate vetoed every tier-1 arm (decision side calls starved
by host-inherited reasoning knobs against a 200-token budget), the pre-gate
INJECT ledger armed suppress-nudge after 5 rounds that delivered nothing,
and the latched suppression then gated willInjectNudge — which gates the very
fallback branch that breaks it. Circular wait, no timeout, zero compression.

Four coordinated fixes (one mechanism family):

- decide-ladder fallback outranks latched suppression in all four prepare
  lanes (the failure-recovery path must reach the model); consumeFallback
  keeps it a one-shot punch-through per DECIDE_FALLBACK_THRESHOLD failures.
- SELF_HEAL_SUPPRESS_CAP_MS (10 min wall-clock) bounds the suppress-nudge
  latch; re-arming costs a fresh full SELF_HEAL_WINDOW of idle rounds.
- decision side calls strip host reasoning knobs (reasoning_effort /
  thinking / thinkingConfig / reasoning) so the tiny output budget reaches
  the one-line JSON verdict; main requests are untouched.
- Prepared.nudgeOutcome records post-gate delivery truth; self-heal streaks
  credit ACTUAL injections only, diagNudge labels pending-gate arms
  INJECT-PENDING instead of INJECT, vetoed arms log an explicit
  "nothing sent this round" line.

Regression tests: tests/issue3004-nudge-decide-selfheal.test.ts (deadlock
repro incl. one-shot semantics + cap expiry + channel reopen; starvation
shape asserting the side body drops reasoning knobs while the main request
keeps them; false-ledger asserting vetoed rounds never arm suppression).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成。分支已 rebase 到最新 master(原 head 落后 233+ 提交;期间 master 又前进 9 个 storage/web 提交,与本 PR 零文件交集,二次 rebase 后 behind=0),新 head 642976691(单 commit,基于 96f2f38bc)。本地 typecheck clean、定向套件 32/32;CI 全绿(14 个 workflow:全量 test 矩阵 ubuntu/windows × node22/24、static-gates、kernel-guard、version-guard、config-surface-guard、docs-sync、全部 e2e lane 含 real codex / dsh / opencode / pi / image-billing / registry),PR mergeable_state = clean。

① 原 issue 方向核对(#3004):取证三机制(decide side call 饿死、投递台账说谎、循环等待)在 reporter 版本 v0.1.195 上逐一核实存在,事故因果链成立;修的是循环等待这个根因而非「压缩没触发」的症状;PR 对取证的两点更正(recordDecision 本就有日志计数;"no" 按设计重置 ladder)与当前 master 代码一致。#7/#8 已按机制域拆出 #3016/#3017,符合一 issue 一机制域规矩。方向无问题。

八问结论:

  1. 是什么问题:model-decided nudge 开启的会话里,三个各自合理的机制互相咬死成循环等待——抑制锁存 gate 住 nudge 注入,nudge 注入 gate 住能打破抑制的 ladder-fallback 分支,而解除抑制又需要只有 nudge 才能引来的压缩证据 → 会话零压缩直到死亡(事故实测 4h46m、14K→766K)。
  2. 什么原因导致的:根本原因是无上限的循环等待(锁存永久化);两个放大器——(a) 决策 side call 以 {...parsed} 继承 host reasoning 旋钮,dsh 配置的 reasoningEffort:max 把 200-token 判决预算烧光 → empty response 硬失败喂大 ladder;(b) self-heal idle streak 信 pre-gate 的 arm 意图而非 post-gate 的投递事实,5 个模型从未收到的轮次武装了抑制。
  3. 影响范围与严重程度:仅影响显式开启 compress.nudgeModelDecided: true 的会话(配置可选字段,默认 OFF;事故 dsh profile 开启了)。触发条件:gate 连续硬失败/否决 + idle streak 攒满 5 轮 → 抑制锁存后完全无法使用(零压缩直至会话死亡),非体验瑕疵。legacy 路径(默认)字节级不受影响。
  4. 怎么修复的:一个机制族四个协同改动——ladder fallback 凌驾于锁存之上(consumeFallback 保证每 3 连败只 punch-through 一次);抑制锁存加 10 分钟 wall-clock 封顶;决策 side call 按协议剥离 reasoning 族字段(主请求不动);Prepared.nudgeOutcome post-gate 投递事实驱动 self-heal 记账与日志标签(PENDING/否决行)。
  5. 是否有回归问题:逐项审过既有行为——legacy decide-OFF 路径字节级不变(armed 即注入,记账等价,INJECT-PENDING 标签在 decide 未定义时不可能触发);degrade-to-proxy 动作不受 cap 影响(header 恢复通道独立);证据驱动的恢复路径不变;cap 到期后重武装需再攒满全新 5 轮窗口(同轮不可能立即重新锁存,噪声有界 ≤1 窗);四条 prepare lane 同构改动一致;无 fail-fast 变吞错、无阈值/时序/输出格式漂移(除已披露 BC#1–feat: OpenAI Responses API support (/v1/responses) #4)。未发现意外回归。
  6. 是否破坏缓存:不涉及。side call wire-shape 变更是 ephemeral 的(从不进客户端历史、fold state 或持久化);session metadata key(nudgeDecideFails/selfHeal)语义保持;prefix cache/重试/去重键均未触碰。
  7. 是否改了设计方向:不转向。全部骑在既有机制上(decide ladder、self-heal 状态机、prepare lane);新增面仅为内部字段 nudgeOutcome + 导出常量/函数,无架构边界变化。
  8. 是否引入了新的配置:无。无新 config key/env/CLI flag;SELF_HEAL_SUPPRESS_CAP_MS 是代码常量(沿用 会话卡死自愈机制:卡死模式检测与代理侧主动补救 #2155 先例)。Config surface 一节属实。

测试有效性:7 个回归测试断言有牙——死锁复现钉住 one-shot 语义(punch-through 消息内容差、ladder 归零、锁存自身穿透后仍存活、cap 到期清理、通道重开后 standing veto 仍生效)、starvation shape 做 wire 级断言(side body 丢旋钮而主请求保留 reasoning_effort:"max")、false-ledger 断言 6 个否决轮永不武装 selfHeal。bug 回归时抓得住。diff 整洁度:10 文件 +563/−32,每行都在死锁机制族内,TECHNICAL-NOTES D1 同步更新,无跑题改动。Review tier 自评正确(wire-shape + fallback 默认变更 → §7.4 human-review,未 claim auto-merge)。

判定:可合。 四个行为变更(BC#1–#4)均已在 PR 正文披露 old→new + WHY,无静默漂移。合并动作留给人工:#3019

@ranxianglei
ranxianglei merged commit f394b09 into master Oct 13, 2026
35 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.375-master.f394b09 (rolling master tag).

npm install -g billion-context@0.0.375-master.f394b09  # 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.

ranxianglei added a commit that referenced this pull request Oct 13, 2026
…pe docs (#3008)

Delta-only rebase onto master (#3019 merged the shared mechanisms):
- dropped from this PR (covered by #3019): stripClientReasoning (master has
  per-protocol stripDecisionReasoningFields incl. google nested
  generationConfig), SELF_HEAL_SUPPRESS_MAX_MS 30min cap (master has
  SELF_HEAL_SUPPRESS_CAP_MS 10min at top-of-evaluate + fallback punch-through
  + re-arm guard), TECHNICAL-NOTES D1 English hunks.
- kept, unique: codexCompactGatePre now reads the evidence-grade input
  baseline (statusInputBaseline) instead of raw stats.lastInputTokens — an
  estimate-grade phantom reading self-disabled the safety valve at >=0.9x
  limit (#1492/#1839 discipline); comment corrected (90% is bili's backstop
  line, not codex's own point — 78.7% observed, client point unobservable).
- kept: docs honesty — codexCompact interception covers explicit requests
  only; codex-tui auto-compaction is pure client-side and never transits the
  proxy (detect/rebase path #2372); conflict-watch remediation no longer
  claims 'intercepts native compaction by default'; zh D1 aligned with the
  merged 10-min cap.

Closes #3008
ranxianglei added a commit that referenced this pull request Oct 13, 2026
…pe docs (#3008)

Delta-only rebase onto master (#3019 merged the shared mechanisms):
- dropped from this PR (covered by #3019): stripClientReasoning (master has
  per-protocol stripDecisionReasoningFields incl. google nested
  generationConfig), SELF_HEAL_SUPPRESS_MAX_MS 30min cap (master has
  SELF_HEAL_SUPPRESS_CAP_MS 10min at top-of-evaluate + fallback punch-through
  + re-arm guard), TECHNICAL-NOTES D1 English hunks.
- kept, unique: codexCompactGatePre now reads the evidence-grade input
  baseline (statusInputBaseline) instead of raw stats.lastInputTokens — an
  estimate-grade phantom reading self-disabled the safety valve at >=0.9x
  limit (#1492/#1839 discipline); comment corrected (90% is bili's backstop
  line, not codex's own point — 78.7% observed, client point unobservable).
- kept: docs honesty — codexCompact interception covers explicit requests
  only; codex-tui auto-compaction is pure client-side and never transits the
  proxy (detect/rebase path #2372); conflict-watch remediation no longer
  claims 'intercepts native compaction by default'; zh D1 aligned with the
  merged 10-min cap.

Closes #3008
@ranxianglei
ranxianglei deleted the 2026-10-13_nudge-decide-selfheal-deadlock branch October 15, 2026 05:33
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上下文700K不触发压缩

1 participant