Skip to content

[PR] fix: self-heal idle streak now resets on any-round compression evidence (#4578) - #6194

Open
ranxianglei wants to merge 3 commits into
masterfrom
2026-11-11_4578-self-heal-idle-reset
Open

ranxianglei wants to merge 3 commits into
masterfrom
2026-11-11_4578-self-heal-idle-reset

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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

Closes #4578

What & why

The self-heal hook (evaluateSelfHealRound) runs on every main request round — the kernel emits a NudgeDecision whether it injects or not, and only injected/gated rounds carry nudgeActive=true. But the idle-streak reset/increment was gated entirely inside if (inputs.nudgeActive).

A fold lands BETWEEN injections: its new block is first observed by an ordinary non-nudge round, which consumed the reduction fingerprint key WITHOUT resetting idleStreak. The next injected round then saw reduction=false and kept climbing. On plugin-route hosts whose lanes never echo bili tool calls in history (code-execution lanes; biliToolUses forever 0), exactly the 5th injected nudge armed nudge idle for 5 rounds suppression even though compressions had landed in every window in between — matching the field log in #4578 (each false arming on exactly the 5th injection since last lift, every window containing tool compress executed via plugin … outcome=applied).

Fix

Evidence (reduction-fingerprint change OR visible bili tool use) now resets idleStreak whenever it is seen on any round; only nudge-carrying rounds earn idle credit. Zombie-streak (D2 lane-degrade) semantics are byte-identical to before — still nudge-gated, so a dead-lane session surviving on preflight refolds still degrades.

Behavior change (disclosed)

  • idleStreak reset condition: old = evidence observed during a nudge round only → new = evidence observed on any round. This is the intended fix; the observable difference is exactly the elimination of the false armings. Suppression of genuinely ignored nudges is unchanged (still arms after 5 nudge-carrying rounds without evidence).
  • No config surface change. No kernel change. No wire/protocol change.

Tests (both directions, #3617 discipline)

New tests/issue4578-self-heal-idle-reset.test.ts, pure state-machine:

  1. inject → fold-in-next-ordinary-round, cycled 5× ⇒ must NEVER arm (old code arms on cycle 5 — regression pin);
  2. bili tool use seen on a non-nudge round also resets;
  3. non-nudge rounds WITHOUT evidence are neutral (neither reset nor credit) — 5 ignored nudges with quiet rounds between them still arm;
  4. 5 consecutive injected rounds without evidence still arm + log line asserted (over-correction guard).

Existing tests/issue2155-self-heal.test.ts (13 tests incl. D2 degrade/recovery integration) passes unchanged.

…4578)

The hook runs on every main request round (the kernel emits a NudgeDecision
whether it injects or not), but the idleStreak reset was gated on nudgeActive.
A fold lands BETWEEN injections and its new block is first observed by an
ordinary non-nudge round, which consumed the reduction key without resetting —
so the next injected round saw reduction=false and kept climbing. On
plugin-route hosts (code-execution lanes where bili tool calls never echo in
history, biliToolUses forever 0) exactly the 5th INJECTED nudge armed
'nudge idle for 5 rounds' suppression even though compressions had landed in
every window in between.

Evidence (reduction fingerprint change or visible bili tool use) now resets
idleStreak whenever it is seen on ANY round; only nudge-carrying rounds earn
idle credit. Zombie-streak semantics are byte-identical (still nudge-gated).
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-11_4578-self-heal-idle-reset (7e1cd50)

Latest build — install this exact version

npm install -g billion-context@0.0.9134-pr.6194.0ddcedb

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
7e1cd50 billion-context@0.0.9134-pr.6194.0ddcedb build
3e556bd billion-context@0.0.9083-pr.6194.1133687 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: self-heal idle streak now resets on any-round compression evidence (#4578) [PR] fix: self-heal idle streak now resets on any-round compression evidence (#4578) Nov 11, 2026
ci-check added 2 commits November 11, 2026 19:37
The original suite's end-state asserts pass under BOTH old and new code:
under the old gate the 5th injected round arms suppress-nudge and the
following evidence round lifts it inside the same loop iteration, so
nudgeSuppressed() reads false at every assert point. Verified by running
the suite against master's session-self-heal.ts (4/4 pass pre-fix).

Add a log spy asserting the 'nudge idle' arming line never appears across
five obeyed cycles — the exact field symptom from #4578. The strengthened
suite now fails 2/4 on master and passes 4/4 on the fix.
…he self-heal hook

The hook runs on EVERY main round (the kernel emits a NudgeDecision whether
it injects or not) — that fact is the premise of the #4578 fix itself, but
both the evaluateSelfHealRound doc comment and the handle.ts call-site
comment still said 'nudge-carrying rounds only' / 'the hook no-ops inside'.
Comment-only clarification; no code change.
@ranxianglei ranxianglei added bug Something isn't working p2 scope/kernel labels Nov 11, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 — 检索了 open+closed issue/PR:本 PR(#6194)是唯一针对 #4578 的修复;其余 open PR(#5092/#5935/#4691/#4773 等)均不触碰 src/session-self-heal.ts,无并行修复、无文件重叠。

Review verdict: mergeable (CI on the updated head still running)

I independently re-derived the mechanism instead of trusting the PR text, and it holds up:

One real defect found and fixed in-place (pushed to this PR branch)

The new test file did not actually pin the regression. All 4 tests pass identically against master's pre-fix code — I verified by running the suite against origin/master:src/session-self-heal.ts (4/4 pass) and by an instrumented trace: under the old gate, cycle 5's injected round DOES arm suppress-nudge, but the very next evidence round lifts it inside the same loop iteration, so every end-state assert reads false either way. The claimed "old code arms on cycle 5 — regression pin" was not true as shipped.

Fixed with two additive commits on 2026-11-11_4578-self-heal-idle-reset:

  1. c4b685dc2b — test(#4578): pin the regression via the arming event, not just end state: tests 1–2 now spy on logs and assert the "nudge idle" arming line never appears across five obeyed cycles (the exact field symptom from [bug] self-heal counts injected nudges, not ignored ones: a compress in a non-nudge round never resets idleStreak → false "nudge idle for 5 rounds" suppression | self-heal 误判:非 nudge 轮的压缩不会清零 idleStreak,每第 5 次注入都误压制 nudge #4578). The strengthened suite fails 2/4 on master and passes 4/4 on the fix; tests 3–4 (over-correction guards, unchanged behavior) pass on both, as intended.
  2. 7e1cd50cdb — docs(#4578): correct stale 'nudge-carrying rounds only' comments: the evaluateSelfHealRound doc comment and the handle.ts call-site comment both said the hook runs on "nudge-carrying rounds only / no-ops inside" — precisely the stale assumption this PR fixes; comment-only clarification.

Local gates on the pushed head: targeted suites 17/17 green, npm run typecheck clean.

Labels (judged on this PR's own diff, previously unlabeled): bug, p2, scope/kernel — false nudge suppression is a real user-visible defect (nudge channel goes dark up to the 10-min cap per false arming + scary warn spam) but compression itself keeps landing, so it's "usable with a clear problem", not p1.

CI (live-checked just now): prior head 3e556bd was fully green (30 checks, 0 failed). Updated head 7e1cd50cdb is still running — 0 failures so far, the test shards are queued/not-yet-reported in the mirror cache. My additions are one test file + two comments, low risk, but the merge verdict below is conditional on the usual green.


八问(结构化审核结论)

  1. 是什么问题:self-heal 的 idle 计数把「注入了 nudge」当成「nudge 被忽略」——压缩实际发生在两次注入之间(由普通轮先观察到),旧代码在普通轮消费了 reduction 指纹却不清零 idleStreak,导致每第 5 次注入都误触发 nudge idle for 5 rounds 压制。
  2. 什么原因导致的:streak 的清零/累加整体被关在 if (inputs.nudgeActive) 里,而该 hook 每个主请求轮都会执行(kernel 每轮都产出 NudgeDecision,只是普通轮 nudgeActive=false)——证据观察点与计数门控不同轮次,指纹被提前消费。
  3. 影响范围与严重程度:plugin-route 宿主且历史中不回显 bili 工具调用(biliToolUses 恒 0,代码执行类车道)的会话必现;每次误压制使 nudge 通道静默至多 10 分钟(dsh上下文700K不触发压缩 #3004 cap)+ 误导性的 warn 日志。能用但体验受损 → p2。
  4. 怎么修复的:证据(reduction 指纹变化或可见 bili 工具使用)在任何一轮观察到即重置 idleStreak;只有携带 nudge 的轮才累积 idle 信用;zombie streak(D2)保持 nudge 门控不变,死车道靠 preflight refold 存活时仍会降级。
  5. 是否有回归问题:逐条核过既有行为——nudge 轮证据重置、nudge 轮信用、无证据普通轮的中性、zombie 信用:前三者语义不变(zombie 字节级一致),仅 idle 重置条件按披露变更;dsh上下文700K不触发压缩 #3004 时间上限、恢复路径、arm 路径未触碰;既有 issue2155 套件 13/13 不变通过。原测试文件不构成回归钉(新旧代码下全绿)是本次 review 发现并已在分支上修掉的真实缺陷。
  6. 是否破坏缓存:不涉及——纯状态机计数逻辑,无缓存/游标/去重键改动。
  7. 是否改了设计方向:不涉及——self-heal 双形态(D1/D2)架构不变,只修正 D1 的证据归因时机。
  8. 是否引入了新的配置:无——无新 env/config/默认值。

判定:可合入——待更新 head(7e1cd50cdb)的 CI test 车道转绿即可合并;行为变更已按规范披露(旧值→新值+原因),无隐藏漂移。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Closing status update (the full structured review with the 八问 is the comment above — not duplicating it here):

CI verdict is now final. Live-checked GitHub check-runs for the updated head 7e1cd50cdb (my two additive commits on top of 3e556bd): all 45 distinct jobs latest-generation = success or skipped, 0 failures, 0 pending. The mirror cache still showed 11 lanes "queued" — that cache was stale; the direct check-run data is authoritative here.

So the single condition from my review verdict is met: ready to merge — owner merges (agents don't).

Recap of what this session delivered on the PR:

  1. Independent mechanism verification (call site src/server/handle.ts:3123 + kernel per-round NudgeDecision emission + byte-identical zombie-streak semantics) — fix direction confirmed correct.
  2. Found & fixed a real defect the PR shipped with: the new test file passed identically under pre-fix master code (verified by running it against origin/master:src/session-self-heal.ts + instrumented trace), i.e. it did not pin the regression. Pushed c4b685dc2b strengthening tests 1–2 via arming-event log assertions (now fails 2/4 on master, passes 4/4 on the fix) and 7e1cd50cdb correcting two stale "nudge-carrying rounds only" comments.
  3. Labels set on the PR judged from its own diff: bug, p2, scope/kernel.
  4. Duplicate screening: [PR] fix: self-heal idle streak now resets on any-round compression evidence (#4578) #6194 is the only PR for [bug] self-heal counts injected nudges, not ignored ones: a compress in a non-nudge round never resets idleStreak → false "nudge idle for 5 rounds" suppression | self-heal 误判:非 nudge 轮的压缩不会清零 idleStreak,每第 5 次注入都误压制 nudge #4578; no other open PR touches src/session-self-heal.ts.

Nothing further outstanding on this thread.

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

bug Something isn't working p2 scope/kernel

Projects

None yet

1 participant