Skip to content

[PR] feat(guardrail): soft-stop repeated calls, hard-abort at backstop (#5505) - #5514

Merged
ranxianglei merged 13 commits into
ranxianglei:masterfrom
growlf:fix/repetition-graceful-end
Nov 4, 2026
Merged

ranxianglei merged 13 commits into
ranxianglei:masterfrom
growlf:fix/repetition-graceful-end

Conversation

@growlf

@growlf growlf commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #5505 — adds an opt-in recovery mode to the pi/omp repetition guard: instead of the turn being abruptly killed by ctx.abort() on the first identical repeat after the final refusal, repeated calls are refused one at a time with a truthful stuck-report while the turn stays alive, and a hard backstop (abortThreshold + 5, default: call 10) retains the termination guarantee.

Behavior Changes

Default (repetition.recovery unset or false) — unchanged from master

Call Behavior
3-4 Warning appended
5 Final refusal (BLOCKED, no abort)
6+ BLOCKED + ctx.abort() — original notice text ("The turn has been aborted.")

Opt-in ("repetition": { "recovery": true }) — graceful ladder

Call Behavior
3-4 Warning appended (unchanged)
5 Final refusal (BLOCKED, no abort)
6-9 Soft stop: blocked + truthful stuck-report, no ctx.abort()
10 Hard abort: blocked + ctx.abort() + forced termination

Custom thresholds (e.g., abort=3): soft-stop calls 4-7, hard abort at call 8.

Technical Details

  • New config field guardrails.repetition.recovery (default: false, object form only, no env var — same file-only surface as its siblings enabled/warn/abort). recovery: true switches the whole escalation ladder to soft-stop mode; false keeps today's behavior byte-exact.
  • tracker.complete(e.toolCallId) is called before ctx.abort() in the hard-abort branch (so a throwing abort cannot skip cleanup) and added to the final-refuse branch (pendingStarts leak fix — blocked calls never fire a tool_result, so the map would accumulate entries forever without it).
  • All notices are truthful in the mode where they are delivered: the default path says "aborted" (it aborts); the recovery path promises forced termination exactly at the backstop (it does).
  • Escalation: none → warn → final-refuse → [soft-stop]* → hard-abort (*recovery mode only; the default path goes straight from final-refuse to abort).

Config surface

New key: guardrails.repetition.recovery (boolean, default false).

Behavior-change disclosure

None for existing deployments: the default remains kill-on-repeat-after-refusal (call 6 with default thresholds) with the original notice text restored verbatim. The new mode is strictly additive behind the opt-in flag. (An intermediate revision briefly shipped the new mode as the default; the alignment rework below keeps the agreed opt-in default — flipping it on fleet-wide is a one-character decision the owner can make explicitly later.)

Verification

  • 57/57 tests pass across tests/tool-guardrails-pi.test.ts + tests/issue5225-repetition-poll.test.ts (default-path pins restored byte-exact + explicit recovery-mode tests incl. custom thresholds + pendingStarts cleanup pinned through a typed accessor)
  • Typecheck clean (npm run typecheck); full-suite verdict = CI on the pushed head

Commits

  1. c6736eca — replace ctx.abort() with graceful turn end
  2. f80ff8a7 — backstop at abort+5 + pendingStarts leak fix
  3. 6e3d8feb — fix complete() order + add final-refuse cleanup
  4. 45122079 — test: verify pendingStarts stays empty for blocked calls
  5. ff975d85 — default backstopEnabled to true (retains termination guarantee)
  6. 339854b4 — alignment rework (reviewer): gate the whole ladder behind opt-in recovery, restore default-path abort + original notice text, restore lost try/catch around ctx.abort(), drop diff noise
  7. cbed9a02 — alignment rework (reviewer): restore byte-exact default-path test pins, add explicit recovery-mode tests, typed pendingCallCount accessor
  8. 5971355e — alignment rework (reviewer): register guardrails.repetition.recovery in config reference (process.yaml + regenerated CONFIGURATION docs)

@ranxianglei ranxianglei changed the title feat(guardrail): soft-stop repeated calls, hard-abort only at backstop (#5505) [PR] feat(guardrail): soft-stop repeated calls, hard-abort only at backstop (#5505) Nov 2, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 检索 open+closed 未见针对「重复调用防护 / soft-stop / backstop / 第 6 次 abort」的同类条目;本 PR 专修 #5505 的 abrupt-abort 缺陷,机制唯一。(PR base = 当前 master tip ee0dcc7,非陈旧;tool-guardrails.ts 自 base 起 master 侧无改动,无热文件冲突。)

下面按结构化八问给结论。核心一句话:修法方向对(治的是 #5505 的根因),但把唯一的强制终止机制做成了 opt-in 且默认关 → 出厂默认配置下,重复调用防护失去了「最终会终止」的保证。

结构化八问

  1. 是什么问题:把「重复调用第 6 次就 ctx.abort() 硬杀回合」改成「软停(拦截但不杀回合)+ 可选 backstop 硬中止」。但在默认配置(backstopEnabled=false,即出厂默认)下,第 6 次及以后所有重复调用都停留在软停、永不触发 ctx.abort() —— 该防护在默认配置下不再有终止保证。

  2. 什么原因导致的:修法本身打到了 Repetition guard detects degenerate loops but provides no recovery — needs repetitionRecovery mode #5505 的根因(abrupt abort 会打断 kernel 状态 / 被误判为用户中断 / 丢 eval cell)。因果链:根因(abrupt abort 副作用)→ 方案(用软停替代)→ 但把 hard-abort 设成默认关 → 结果(默认配置下彻底移除了 master 原本在第 6 次就有的终止保证)。问题不在机制,在默认值选择。

  3. 影响范围与严重程度:触发条件 = 跑 pi/omp 车道、模型陷入重复调用循环、且未显式开 backstopEnabled 的场景(= 所有出厂默认用户)。严重度:p1 级风险——非合规模型可无限循环,每轮一次完整模型往返 = 无界成本/延迟;master 至少第 6 次会终止,新版默认永不止止。属可用性/成本退化而非体验瑕疵。(另见第 5 问的文案虚报。)

  4. 怎么修复的(现状):新增 repetition.backstopEnabled(默认 false);true 时第 6–9 次软停、第 10 次(abort+5)硬中止;并修了 pendingStarts 泄漏(blocked 分支补 tracker.complete(),0ms 时长 < REPEAT_SLOW_CALL_MS=5000 不会误重置 run,正确)。机制合理,争议只在默认值。

  5. 是否有回归问题:有,一处行为回归。既有行为「第 6 次重复调用终止回合」在默认配置下被移除(旧:abort@6;新默认:永不 abort;新 opt-in:abort@10)——高危模式里的「默认值/时序漂移 + fail-safe 变 fail-soft」。逐项核对其余保持:warn@3-4、final-refuse@5、slow-call reset、pendingStarts 清理均不变。附加发现:stuck-report 文案在默认配置下会输出「The turn will be forcibly terminated if you reach 10 identical calls」,但默认根本不会终止 → 与 PR 自称的「truthful stuck-report」自相矛盾(该文案在 action==="abort" 软停分支同样被使用)。

  6. 是否破坏缓存:不涉及。纯 pi-lane guardrail 决策层,不碰 wire / 前缀缓存 / 账本。

  7. 是否改了设计方向:是——从「到阈值即硬终止」转向「默认只软停、硬终止需显式开启」。这是产品决策,需 owner 拍板(见下方 🔶 需要决策)。

  8. 是否引入了新的配置:是——新增布尔字段 repetition.backstopEnabled(默认 false)。未更新 CONFIGURATION.md(en/zh),也未按 config-surface 规范在 PR 正文写说明段(为何现有面表达不了 / 考虑过哪些既有机制 / 兼容迁移)。定稿时需补。

🔶 需要决策

背景:默认配置下,重复调用防护失去了「最终会终止」的保证(master 原本第 6 次硬杀)。
待决:backstopEnabled 默认取 true 还是 false?

选项 代价
A. 默认 true(推荐) 出厂即保留终止保证,只是从第 6 次推迟到第 10 次硬中止;#5505 要的「graceful 不 abrupt」仍满足(6–9 仍是软停)。代价:比 master 晚 4 次才硬杀,极端情况多几轮成本,但有界。
B. 默认 false(当前) 出厂不保证终止,依赖模型自觉/其它机制。代价:非合规模型可无限循环、无界成本;且 stuck-report 文案会虚报「将强制终止」。

我的推荐:A。 若坚持 B,必须同时:① 把 stuck-report 文案改成不含「将强制终止」的承诺;② 补一条默认路径测试,断言 count≥10 时仍为软停且 ctx.abort 未被调用(当前所有 wire 测试都通过改过的 wireRepetition 强制 backstopEnabled:true,没有一条覆盖默认 false 的第 6+ 次升级路径);③ CONFIGURATION.md 明确标注「默认不保证终止」。
不决定的默认行为:维持现状(false)= 默认无终止保证 + 文案虚报 —— 我不建议就此合入。

其它(非阻塞)

  • 8 条重复的 // SAFETY: Pi passes untyped event objects… 注释遍布各 handler——风格噪音(AGENTS「No comments unless absolutely necessary」),建议精简但可不强求。
  • 上述 3 个小修(CONFIGURATION.md 文档 / 默认下文案真实性 / 默认路径测试)我已想清,与默认值决策耦合,故先不 push;决策落地后一并推到本 PR 分支。
  • CI 我未本地全量跑(交给远程 CI,本地资源共享);以上判断基于逐行读 diff + 逻辑推演 + 测试有效性审查(enabled 路径的测试确有牙:断言 abortCalls 计数、block 标志、reason 正则 /forcibly terminated/i 与 doesNotMatch /turn ends on its own/i、新增 pendingStarts 清空断言)。

判定:拦下(暂不合) —— 等 owner 对 backstopEnabled 默认值拍板;拍板后我把耦合的小修一揽子补齐再放行。

@growlf

growlf commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Update: backstopEnabled default changed to true

Per maintainer feedback, the default backstop behavior was changed to retain the termination guarantee by default:

  • Before: backstopEnabled: false by default → no hard abort, non-compliant models could loop forever
  • After: backstopEnabled: true by default → hard abort at call 10 (graceful soft stop at 6–9, then forced termination)

Users who prefer unbounded soft-stop can explicitly set repetition: { backstopEnabled: false }.

1-line change: backstopEnabled !== false instead of === true (default flips from false→true when unset).

@growlf growlf changed the title [PR] feat(guardrail): soft-stop repeated calls, hard-abort only at backstop (#5505) feat(guardrail): soft-stop repeated calls, hard-abort at backstop (#5505) Nov 2, 2026
@ranxianglei ranxianglei changed the title feat(guardrail): soft-stop repeated calls, hard-abort at backstop (#5505) [PR] feat(guardrail): soft-stop repeated calls, hard-abort at backstop (#5505) Nov 2, 2026
ranxianglei pushed a commit to growlf/billion-context that referenced this pull request Nov 2, 2026
…efault-path abort (ranxianglei#5505)

Alignment rework of PR ranxianglei#5514 (agreed design from issue thread: option A,
opt-in single boolean under guardrails.repetition, default false = zero
drift from current behavior).

- The previous revision made the soft-stop UNCONDITIONAL: the 'abort'
  handler branch no longer called ctx.abort(), so with the flag off the
  turn was refused forever after call 6 and never terminated -- a silent
  change of the default behavior the thread explicitly ruled out. Now the
  whole ladder is gated: recovery off = master behavior byte-exact
  (call 6 still blocks AND aborts, original notice text restored);
  recovery on = calls 6..(abort+4) refused with a truthful stuck-report,
  hard backstop at abort+5 (default thresholds: soft 6-9, hard at 10).
- Renamed backstopEnabled -> recovery (the flag gates the ladder, not
  just the backstop).
- Restored the try/catch around ctx.abort() (mid-tool abort is
  best-effort; the block below guarantees the refusal) -- it was lost in
  the new hard-abort branch.
- New buildRepetitionSoftStopNotice: promises forced termination at
  abort+5, which is true in the mode where it is delivered; the default
  path keeps 'The turn has been aborted.' (also true there).
- Reverted diff noise: five SAFETY comments annotating pre-existing
  casts, behavior-neutral inputEvent rename.
Kept from the PR: pendingStarts leak fix (complete() on every blocked
path, behaviorally inert: blocked-call duration ~0ms << 5s long-poll
reset window), complete-before-abort ordering.
ranxianglei pushed a commit to growlf/billion-context that referenced this pull request Nov 2, 2026
…ed pendingCallCount (ranxianglei#5505)

Alignment rework of PR ranxianglei#5514 test suite:

- The wireRepetition harness auto-enabled backstopEnabled:true for every
  test, leaving ZERO coverage of the real default; removed the auto-merge
  so defaults exercise defaults.
- Restored the default-path pins byte-exact: call 6 blocks with the
  original 'has been aborted' notice and ctx.abort fires exactly once
  (pi harness level + ranxianglei#5225 rapid-loop harness level); custom-threshold
  variant kills at its own abort threshold.
- New explicit recovery-mode tests ({repetition:{recovery:true}}): soft
  stop 6-9 (no abort, /forcibly terminated/, doesNotMatch
  /has been aborted/) then hard abort at backstop 10; custom warn=2/
  abort=3 -> soft 4-7, hard at 8.
- Leak test now uses a typed RepetitionTracker.pendingCallCount getter
  instead of (t as any).pendingStarts.size; added a default-mode variant
  pinning cleanup on the final-refuse + abort paths too.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

已独立核验(不是采信描述):拉了新 head ff975d85e,本轮只加 1 个 commit、1 行改动:resolveRepetition 里 backstopEnabled === true → !== false。逐条跑通逻辑:

  • 默认路径:用户不配 guardrails.repetition → guardrailRepetition() 返回 true → resolveRepetition(true) → backstopEnabled = (undefined)!==false = true。出厂默认确实保留了终止保证(final-refuse@5 → soft-stop@6-9 → hard-abort@10)。上一轮我拦的核心回归(默认无终止)已消除。
  • repetition:false 仍正确整体关闭(g===false 早返回 enabled:false),无回归。
  • 全仓唯一生产调用点是 src/agent/pi.ts:905,传的就是这个布尔,所以真实用户拿到的就是上述默认行为。方向对、翻得也对,质量不错。

结构化八问(更新)

  1. 是什么问题:把「第 6 次重复即 ctx.abort()」换成软停 + backstop 硬中止;本轮把 backstop 默认 false→true。
  2. 什么原因导致的:方向治的是 Repetition guard detects degenerate loops but provides no recovery — needs repetitionRecovery mode #5505 的 abrupt-abort 副作用;上轮病灶是「默认关导致无终止保证」,本轮已按推荐翻正。
  3. 影响范围与严重程度:默认已回到「有终止保证」,不再 p1。剩余是文档/注释诚实性 + 一个配置面小决策,p3 级。
  4. 怎么修复的:一行 !== false 翻转默认,机制不变。
  5. 是否有回归问题:默认终止保证已恢复、repetition:false 关闭路径不变、无新增回归。但发现一处新问题(下方 A)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:默认策略已定为「保留终止保证」(与我上轮推荐一致)。
  8. 是否引入新配置:内部类型加了 backstopEnabled,但没接进用户可见的配置/env 面(见 A)——这正是要点。

合入前要处理(都不大;但我推不到你的 fork,见末尾)

A. [新发现·最关键] backstopEnabled 用户根本设不了,PR 正文的 opt-out 是假的。
src/agent/pi.ts:905 传 guardrailRepetition()(knobs.ts:339 返回 boolean),全仓唯一生产调用点也只传布尔;没有对象透传路径、也没有任何 BILI_GUARDRAIL_*BACKSTOP* env。后果:用户只能 repetition:true/false(整条开/关),没法表达「开防护但不要硬中止(无限软停)」;PR 正文那句 “Users … can explicitly set repetition: { backstopEnabled: false }” 在现有配置面下做不到。处置二选一:

  • ① 真要给这个逃生口 → 把它接进配置面(guardrails.repetition 支持对象 + 可选 env)并按 config-surface 规范补说明段。这属 owner 设计区,建议单独立项等拍板,别混进本 PR;
  • ② 不暴露(我的推荐:默认 true 已安全、全关也兜得住)→ 删掉 PR 正文那句假 opt-out 声明即可,字段留作内部默认。

B. [必改] CONFIGURATION.md 该行已过时。 CONFIGURATION.md:184 现写 “abort at 5” 且没提 backstop。建议改成如实描述现在的阶梯(示例措辞):

guardrails.repetition (boolean, default true, BILI_GUARDRAIL_REPETITION) — identical-call loop-breaker for pi/omp. Escalation on consecutive byte-identical calls: warn@3 → final refusal@5 → soft stop (blocked, turn kept alive)@6–9 → forced termination (ctx.abort) at the backstop = abort+5 (call 10 by default). Backstop is on by default; set false / env 0 to disable the whole breaker. Per-call threshold tuning is not a user-facing knob yet (#5514).

C. [必改·一行] 注释自相矛盾。 src/agent/tool-guardrails.ts 的 hard-abort 分支注释仍写 // when repetition.backstopEnabled = true (default: false). —— 默认已是 true。改成 (default: true)。(与代码事实不符的注释 = 缺陷。)

D. [建议] 测试钉住默认与边界。 现有 wire 用例经 wireRepetition 强制 backstopEnabled:true,恰好等于新默认,默认路径被顺带覆盖;但缺一条直接断言 backstop 边界:new RepetitionTracker({warn:3,abort:5,backstopEnabled:true}) 驱动到第 9 次应得 abort、第 10 次应得 hard-abort。这条最能钉住本 PR 的关键语义。

关于推送

本 PR head 在 growlf/billion-context:fix/repetition-graceful-end(fork),我这个身份没有你 fork 的写权限,push 不上去。上面 A②/B/C 都是几行级、已给可直接粘贴的文本,麻烦你 @growlf 补上(或给我临时写权限 / 让我在 ranxianglei 侧另备 patch 供你取)。A 若走①(暴露配置面)属 owner 配置面决策,建议单独提,别并进本 PR。

判定:核心回归已解决、方向正确、代码干净。合入前请落 B、C(诚实性/文档,硬要求)+ A 的处置(删假声明或立项暴露);D 建议一并。这些落地即可放行——我不再就默认值拦你。(默认值那个决策已经定了,needs-decision 现仅针对 A 是否暴露配置面这一可选小项,我推荐暂不暴露。)

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Round 3 — re-reviewed the new head 5971355e2 (3 commits: gate soft-stop behind opt-in recovery, restore default-path abort, register in config reference). I read the real code at the head, not just the commit messages. First the good part:

What improved (verified):

  • Default is now regression-free. With recovery defaulting to false, the ladder (src/agent/tool-guardrails.ts:228-234) gives warn@3 → final-refuse@5 → abort@6 (a real ctx.abort()), i.e. the original Repetition guard aborts legitimate read-only long polling inside Pi Codemode #5225 behavior. Existing users see zero change. That's actually more conservative than my round-1 ask (graceful-by-default); shipping the improvement as opt-in is the safer call. 👍
  • Clean rename (backstopEnabled→recovery, no stale leftovers), the soft-stop notice is now truthful where it fires (only in recovery mode, where the backstop really terminates), cleanup invariant documented on pendingCallCount, zh docs updated too.

The one blocker — the documented recovery opt-in is unreachable through the entire production config stack. Docs and tests were updated, but none of the actual plumbing was, so no real user can turn this on:

  1. Config schema src/config.ts:2261 — guardrails.repetition?: boolean. The type is a plain boolean; an object {recovery:true} isn't even representable in the typed config (parse rejects or drops it).
  2. Knob src/knobs.ts:342 — guardrailRepetition(): boolean returns loadConfigFile().guardrails?.repetition !== false, coercing to a boolean regardless.
  3. Caller src/agent/pi.ts:905 — repetition: guardrailRepetition() passes that boolean into wireToolGuardrails.

Only the internal type GuardrailOptions.repetition (tool-guardrails.ts:283) accepts boolean | {…recovery?} — but nothing in the production path ever builds that object from user config. So resolveRepetition(true) → obj = {} → recovery = false, always.

Net effect: a user who follows your new CONFIGURATION.md / website yaml and sets guardrails.repetition:{recovery:true} is silently ignored and still gets abort@6. The #5505 graceful mode is inert for everyone until the schema→knob→caller chain passes the object through. That's exactly the silent-config-drop anti-pattern this repo guards against.

Why CI is green while the feature is dead: your new tests call wireRepetition({ repetition: { recovery: true } }) / wireToolGuardrails(pi, {repetition:{recovery:true}}) directly — they construct the internal object and bypass all three layers above. That proves the engine logic works, not that the wiring works. Please add one regression test that goes through the real knob (set the config/env, assert recovery is active end-to-end) so this gap class can't ship green again.

Process note: introducing an object form for a currently-boolean field is a new config shape — that needs the "config surface" section in the PR body plus owner sign-off (AGENTS config-surface discipline). It's documented in three places now without either.

Concrete fix (I'd take A):

  • A — wire it end-to-end: widen src/config.ts:2261 to repetition?: boolean | { enabled?: boolean; warn?: number; abort?: number; recovery?: boolean }; make guardrailRepetition() return that raw value instead of boolean-coercing (keep BILI_GUARDRAIL_REPETITION=0|false as the on/off env; let the object live in the config file — optionally add BILI_GUARDRAIL_RECOVERY=1 to force it on, your call); update the pi.ts:905 call-site type to pass it through. Then add the through-the-knob regression test + the config-surface section.
  • B — or keep it internal for now: strip the object-form sentences from CONFIGURATION.md (en+zh) and website/config-reference/process.yaml so the docs don't promise a knob users can't reach, and leave recovery as an unexposed engine flag.

I can't push to your fork (no write access), so these are pointers rather than commits — and they're small. Happy to draft a patch on the ranxianglei side if you'd prefer.


八问(结论)

  1. 是什么问题:Repetition guard detects degenerate loops but provides no recovery — needs repetitionRecovery mode #5505 想把重复调用第 6 次从「立刻 ctx.abort() 杀回合」改成「优雅卡住报告、回合继续」,并在 backstop(abort+5=第10次)硬兜底。
  2. 什么原因导致的:原实现在第 6 次直接 abort,会打断 kernel 状态、把用户中断误判、丢 eval cell;本 PR 引入 recovery 开关做优雅模式。
  3. 影响范围与严重程度:默认(recovery=false)已恢复成 master 的 abort@6,存量用户零变化(无回归);但文档声称的 recovery:true 优雅模式对真实用户完全不可用——配置栈三层(schema 布尔类型 / knob 布尔强转 / pi.ts 传布尔)都拦住了对象形式,按文档设置会被静默忽略。p2:新广告功能失效 + 文档失实,但不破坏任何既有行为。
  4. 怎么修复的:优雅逻辑本身写得对(ladder、软停不 abort、backstop 硬停、清理不变量),只需把对象形式打通 schema→knob→caller 三处 + 加一条走真实 knob 的回归测试;或先撤掉对象形式的文档。
  5. 是否有回归问题:默认路径无回归(abort@6 与 master 一致);repetition:false 关闭路径正常。唯一问题是新 opt-in 没接通,属「功能未接通」而非回归。
  6. 是否破坏缓存:不涉及(纯 guardrail 决策路径,不碰缓存/游标/去重键)。
  7. 是否改了设计方向:方向合理且更保守(优雅改 opt-in,默认保持旧行为);但暴露新配置形状需 owner 拍板 + config-surface 说明。
  8. 是否引入了新的配置:是——文档新增了 guardrails.repetition 对象形式(含 recovery),代码侧未接通;需按 A 打通并补 config-surface 段,或按 B 撤回文档。

判定:设计扎实、默认零回归(比我一版的建议还稳),👍。合并前必须处理:recovery 配置三层不可达 + 补一条走真实 knob 的回归测试 + config-surface 说明/owner 确认。A 方案落地后即具备可合入条件。needs-decision 标签保留(等你对「现在就公开这个 knob 吗」拍板)。

@growlf

growlf commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Collaborator invitation sent to @ranxianglei for the fork. Check your email and accept the invite to gain write access to https://github.com/growlf/billion-context. Once accepted, you'll be able to push to the branch directly.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

独立复核(head 323c62e06) — 我没有采信前几轮结论,把整条链在真实 head 上重新拉通了一遍。先给结论:默认路径干净、无回归;但这个 PR 的核心卖点(recovery 优雅终止)在生产配置栈里根本够不着——它是死代码,文档却在宣传它。 另外补一个前几轮没抓到的隐患。

我独立验证了什么(不采信描述)

  • 全仓唯一生产调用点 src/agent/pi.ts:905:repetition: guardrailRepetition() —— 传的是布尔。
  • src/knobs.ts:339 guardrailRepetition(): boolean —— 只返回布尔;loadConfigFile().guardrails?.repetition !== false 会把任何对象强转成布尔,没有子字段透传、没有对应 env。
  • src/config.ts:2261 repetition?: boolean —— 类型化 schema 就是布尔,{recovery:true} 在这个面里表示不出来。
  • 于是 resolveRepetition(true) → obj = {} → recovery = false,恒为 false。即便用户在 config 文件里手写 "repetition": {"recovery": true},knob 也会把它压成布尔 true 丢掉对象。没有任何路径能让真实用户开起 recovery。

结构化八问

  1. 是什么问题:给 pi/omp 重复调用守卫加了一个 opt-in「优雅终止」模式(第 6–9 次软停、第 10 次 = abort+5 硬中止,替代原来第 6 次直接 ctx.abort())。但 recovery 只被内部类型 GuardrailOptions.repetition 接受,没接进生产配置链,所以没有真实用户能开启它——功能以死代码形式合入,而 CONFIGURATION.md(en/zh)+ process.yaml 却把它写成可用开关。
  2. 什么原因导致的:改动停在叶子层(tool-guardrails.ts 的类型 / resolve / handler / 文案 / 测试 / 文档),没动把用户配置送进守卫的三层管道:config.ts(schema) → knobs.ts(knob) → pi.ts(caller)。布尔一路传到 resolveRepetition(true) 就变空对象、recovery=false。根因=在决策层实现了新字段却没扩展 config→knob→caller 链(也没按 config-surface 规范为新字段写说明段)。
  3. 影响范围与严重程度:默认用户(repetition 未设 / false / true)零变化——阶梯仍是 warn@3 → final-refuse@5 → abort@6(真 ctx.abort()),已逐格验证,对今天所有用户无回归。真正受影响的是「想用 recovery 的人」:现在开不了→宣传的 opt-in 是坏的、文档在说谎。严重度不是 p1(默认仍保终止保证,无可用性/成本退化),属「功能不可用 + 文档误导」。若日后有人照文档天真地把接线补上,还会触发下面第 2 个隐患。
  4. 怎么修(推荐二选一,别停在半吊子状态):
    • (A) 让它成真:config.ts schema 扩成 boolean | {enabled?,warn?,abort?,recovery?};knobs.guardrailRepetition() 返回解析后的形状而非裸布尔;pi.ts:905 透传对象;并按 config-surface 规范补说明段 + owner 对新字段的签核。
    • (B) 不外露:把 CONFIGURATION.md / process.yaml 里关于 recovery 的描述撤掉,内部代码要么标注「预留、当前不可达」要么删掉,让本 PR 收敛到确实可达的部分。
      现在的病根就是「宣传了但够不着」的半状态,两个方向都能治好,不能维持现状。
  5. 是否有回归问题:默认路径逐项核对——warn@3-4 ✓、final-refuse@5(拦截不杀回合)✓、abort@6(真 ctx.abort() + 原文案 "The turn has been aborted.")✓、慢调用(≥5s)/改参/用户输入重置 ✓、repetition:false 整体关闭 ✓。新增的 tracker.complete() 只在 final-refuse/abort 分支按 key 清 pendingStarts 并把 lastCompleted 置 ≈0ms(< REPEAT_SLOW_CALL_MS=5000,不会误重置 run)——是泄漏修复、行为中性。一个新隐患(前几轮未提):recovery 模式下第 5 次(final-refuse)文案写「if the very next call is identical again, the entire turn will be ABORTED」,但下一次相同调用其实是 soft-stop(回合继续到 backstop@10)——与 PR 自称「各模式下文案都属实」自相矛盾。当前潜伏(模式够不着),一旦接线落地就会对用户发出;现有单测直接驱动 recovery 路径,所以现在就能钉住。
  6. 是否破坏缓存:不涉及——纯 pi-lane 守卫决策层,不碰 wire / 前缀缓存 / 账本。
  7. 是否改了设计方向:意图是从「到阈值即硬终止」转向「优雅软停 + backstop」,但因为挂在够不着的开关后面,实际出厂的设计方向没变(默认仍 abort@6)。recovery 要不要存在 / 要不要默认开 / 要不要外露,是 owner 的产品决策(#5505 也把文案可配性列为待定),不该被隐式拍板。
  8. 是否引入了新的配置:内部加了 GuardrailOptions.repetition.recovery?: boolean,但没有落到用户可见的 config/env 面(schema/knob/caller 全是布尔)——这正是它够不着的原因。若走方案 (A),guardrails.repetition.recovery 才成为真正的用户字段(需 config-surface 段 + 签核);目前没有任何对应 env。

探针证据(recovery 模式,逐调用)

call  5 -> final-refuse  block=true   文案声称「回合将被 ABORTED」 | 实际 ctx.abort() 次数: 0
call  6 -> soft-stop     block=true   (「下一次相同调用」其实只是软停,回合没死)
...
call 10 -> hard-abort    block=true   此时才第一次 ctx.abort()

即:final-refuse 对「下一次就 ABORTED」的承诺在 recovery 模式下为假。修法:让 buildRepetitionFinalRefuseNotice 感知模式——recovery 下把「the entire turn will be ABORTED」换成「identical calls will keep being refused and the turn will be forcibly terminated at {backstop}」,并加一条断言 recovery 下第 5 次 reason 不含 /will be ABORTED/i 的回归测试。

判定:REQUEST_CHANGES

默认路径质量高、无回归,这部分我没有异议。拦下的两点都在「可达性 / 诚实性」上:①核心功能够不着(必须二选一收口);②recovery 文案虚报(接线前先钉住)。两者都不大、都不需要重做机制,补齐即可合入。

(CI 依派发信息为绿;我的本地定向探针确认了上述逻辑,全量套件以远程 CI 为准。)

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

PR #5514(upstream)/ 内部 #5516 已审完 → REQUEST_CHANGES(正式 review 已提交:pullrequestreview-5733383345)。

独立复核(没采信前几轮,在真实 head 323c62e06 上把整条链重新拉通;本地树是旧的,已用 pull ref 取真实 head 审)。两点拦下:

  1. 核心功能够不着(主 blocker):recovery 优雅终止模式在生产配置栈里是死代码。全仓唯一调用点 src/agent/pi.ts:905 传的是布尔 guardrailRepetition()(src/knobs.ts:339 只返回布尔、会把对象强转掉),src/config.ts:2261 schema 也是 repetition?: boolean。于是 resolveRepetition(true)→obj={}→recovery=false 恒成立——即便用户手写 "repetition":{"recovery":true} 也会被 knob 压成布尔丢掉。但 CONFIGURATION.md(en/zh)+process.yaml 却把它写成可用开关。修法二选一:要么把它接进 config/knob/caller 三层 + 补 config-surface 说明段 + owner 签核;要么撤掉文档宣传、内部代码标注「预留不可达」或删除。别停在「宣传了但够不着」的半状态。
  2. 新隐患(前几轮未提):recovery 模式下第 5 次(final-refuse)文案写「the entire turn will be ABORTED」,但下一次相同调用其实只是 soft-stop(回合继续到 backstop@10)——与 PR 自称「各模式文案都属实」矛盾。已用探针证实;现有单测直接驱动 recovery 路径,现在就能加断言钉住。

默认路径干净、无回归(warn@3 → final-refuse@5 → abort@6 逐格验证,原文案保留;新增 tracker.complete() 只是按 key 清 pendingStarts 的泄漏修复、行为中性)。不碰缓存/wire。非 kernel、无 kernel-change 声明 → 不走 🔶 流程;两点都非「小问题」(跨文件配置接线 / 模型可见文案语义),故未在分支上顺手改,全部走进 REQUEST_CHANGES。CI 依派发为绿,本地定向探针确认了上述逻辑。

growlf added a commit to growlf/billion-context that referenced this pull request Nov 2, 2026
…onfig file (ranxianglei#5505)

Aligns with maintainer feedback on PR ranxianglei#5514 (request changes).

Changes:
- config.ts:2261 — repetition type: boolean | { enabled?, warn?, abort?, recovery? }
- knobs.ts:339 — guardrailRepetition() returns boolean | object shape
- tool-guardrails.ts:266 — text fix: "take stronger action" instead of "ABORTED"
- process.yaml — 4 sub-field entries + main entry type: "boolean | object"
- Auto-generated: CONFIGURATION.md, CONFIGURATION.zh-CN.md via gen-config-docs.mjs

Fixes maintainer review items:
1. Recovery mode now reachable (config → knobs → pi chain passes objects)
2. Final-refuse text truthful for both default and recovery modes

Verification:
- config-surface guard: ✓ (182 leaf fields, 34 CLI flags)
- npx tsc --noEmit: clean
- npm run build: success (ESM dist/index.js 5.57 MB)
- All 25 tests pass (11 tool-guardrails-pi + 14 issue5225)
@growlf

growlf commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@ranxianglei I've pushed the Option A changes that make mode reachable via config file:

Changes:

  • : type expanded to
  • : now returns shape (env var stays boolean-only)
  • : Text fix — 'take stronger action' instead of 'ABORTED' (truthful for both default and recovery modes)
  • : 4 sub-field entries added (enabled, warn, abort, recovery)
  • Auto-generated: , via gen-config-docs.mjs

Verification:

  • ✅ config-surface guard: 182 leaf fields, 34 CLI flags
  • ✅ npx tsc --noEmit: clean
  • ✅ npm run build: success (ESM dist/index.js 5.57 MB)
  • ✅ All 25 tests pass (11 tool-guardrails-pi + 14 issue5225)

Collaborator invite: I've sent a GitHub collaborator invite to your account () for write access to the fork so you can merge this PR. Please accept the invite at https://github.com/growlf/billion-context/invitations

This PR is now ready for your review. Thank you for the detailed feedback — Option A is exactly what was needed.

@growlf

growlf commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@ranxianglei I've pushed the Option A changes that make recovery mode reachable via config file.

Changes:

  • config.ts: repetition type expanded to boolean | { enabled?, warn?, abort?, recovery? }
  • knobs.ts: guardrailRepetition() now returns boolean | object shape (env var stays boolean-only)
  • tool-guardrails.ts: Text fix — "take stronger action" instead of "ABORTED" (truthful for both default and recovery modes)
  • process.yaml: 4 sub-field entries added (enabled, warn, abort, recovery)
  • Auto-generated: CONFIGURATION.md, CONFIGURATION.zh-CN.md via gen-config-docs.mjs

Verification:

  • config-surface guard: 182 leaf fields, 34 CLI flags
  • npx tsc --noEmit: clean
  • npm run build: success (ESM dist/index.js 5.57 MB)
  • All 25 tests pass (11 tool-guardrails-pi + 14 issue5225)

Collaborator invite: I've sent a GitHub collaborator invite to your account (ranxianglei) for write access to the growlf/billion-context fork so you can merge this PR. Please accept the invite at https://github.com/growlf/billion-context/invitations

This PR is now ready for your review. Thank you for the detailed feedback.

growlf and others added 10 commits November 2, 2026 13:43
…nxianglei#5505)

When the repetition guard hits the abort threshold (call 6), the guard
called ctx.abort() which killed the turn abruptly — the model received
no stuck-report and host kernel state was interrupted.

Replace the abrupt abort with a structured { block: true, reason }
return that:
  - Blocks the tool execution (same as before)
  - Delivers a model-visible refusal message
  - Lets the turn end through the normal host path

Also fix the contradictory message text that still said "The turn has
been aborted." despite the new graceful behavior.

Changes:
- Remove ctx.abort() from abort handler in wireToolGuardrails
- Update buildRepetitionAbortNotice to say "normal host path"
- Update tests: abortCalls 1 -> 0, add new graceful-end test
- Improve inline comment accuracy

Fixes ranxianglei#5505
…ngStarts leak fix

- Add backstopEnabled: boolean config (default: false, opt-in)
- Hard backstop count: abortThreshold + 5 (call 10 for default thresholds)
- Soft stop at calls > abort && < backstop: blocked, no ctx.abort (ranxianglei#5505)
- Hard abort at calls >= backstop: blocked + ctx.abort() (forced termination)
- Add tracker.complete(e.toolCallId) in both abort branches (pendingStarts leak fix)
- Rewrite buildRepetitionAbortNotice with truthful stuck-report text
- SAFETY comments on all 'x as unknown as T' casts
- Update all RepetitionTracker tests and wireRepetition harness
- Test: default thresholds soft-stop calls 6-9, hard-abort at call 10
- Test: custom (warn=2, abort=3) soft-stop calls 4-7, hard-abort at call 8
ranxianglei#5505)

- Replace ctx.abort() at call 6 with soft stop: { block: true, reason }
  without executing ctx.abort(), so the turn survives with a truthful
  stuck-report (no false claims about turn ending on its own).
- Add hard backstop at count >= abortThreshold + 5: refuses AND calls
  ctx.abort() (forced termination for non-compliant models).
- Call tracker.complete(e.toolCallId) in every branch that returns
  { block: true, reason } before any ctx.abort() (so a throwing abort
  cannot skip the cleanup; 0ms duration < 5s threshold, safe).
- Rewrite stuck-report text to be truthful and actionable.
- Add negative assertions: stuck-report must not claim 'turn ends on
  its own'.
- backstopEnabled: boolean opt-in (default: false).

Tests: merged into existing repetition tests; covers all escalation
levels, arg-change reset, custom thresholds, slow-call reset, and
truthful text assertions.
…anxianglei#5505)

Add a RepetitionTracker test that simulates the full escalation
ladder (warn → final-refuse → soft-stop → hard-abort) and verifies
that handler-initiated complete() calls keep pendingStarts empty
after each blocked call — no leaks.
…guarantee)

With backstopEnabled defaulting to false, non-compliant models could
loop indefinitely (only soft stop, no hard abort). The maintainer's
requirement that the termination guarantee be retained from the factory
is now met: soft stop at 6-9, hard abort at 10 by default.

Users who want unbounded soft-stop can set
repetition: { backstopEnabled: false }.

Signed-off-by: growlf <growlf@thenetyeti.com>
…efault-path abort (ranxianglei#5505)

Alignment rework of PR ranxianglei#5514 (agreed design from issue thread: option A,
opt-in single boolean under guardrails.repetition, default false = zero
drift from current behavior).

- The previous revision made the soft-stop UNCONDITIONAL: the 'abort'
  handler branch no longer called ctx.abort(), so with the flag off the
  turn was refused forever after call 6 and never terminated -- a silent
  change of the default behavior the thread explicitly ruled out. Now the
  whole ladder is gated: recovery off = master behavior byte-exact
  (call 6 still blocks AND aborts, original notice text restored);
  recovery on = calls 6..(abort+4) refused with a truthful stuck-report,
  hard backstop at abort+5 (default thresholds: soft 6-9, hard at 10).
- Renamed backstopEnabled -> recovery (the flag gates the ladder, not
  just the backstop).
- Restored the try/catch around ctx.abort() (mid-tool abort is
  best-effort; the block below guarantees the refusal) -- it was lost in
  the new hard-abort branch.
- New buildRepetitionSoftStopNotice: promises forced termination at
  abort+5, which is true in the mode where it is delivered; the default
  path keeps 'The turn has been aborted.' (also true there).
- Reverted diff noise: five SAFETY comments annotating pre-existing
  casts, behavior-neutral inputEvent rename.
Kept from the PR: pendingStarts leak fix (complete() on every blocked
path, behaviorally inert: blocked-call duration ~0ms << 5s long-poll
reset window), complete-before-abort ordering.
…ed pendingCallCount (ranxianglei#5505)

Alignment rework of PR ranxianglei#5514 test suite:

- The wireRepetition harness auto-enabled backstopEnabled:true for every
  test, leaving ZERO coverage of the real default; removed the auto-merge
  so defaults exercise defaults.
- Restored the default-path pins byte-exact: call 6 blocks with the
  original 'has been aborted' notice and ctx.abort fires exactly once
  (pi harness level + ranxianglei#5225 rapid-loop harness level); custom-threshold
  variant kills at its own abort threshold.
- New explicit recovery-mode tests ({repetition:{recovery:true}}): soft
  stop 6-9 (no abort, /forcibly terminated/, doesNotMatch
  /has been aborted/) then hard abort at backstop 10; custom warn=2/
  abort=3 -> soft 4-7, hard at 8.
- Leak test now uses a typed RepetitionTracker.pendingCallCount getter
  instead of (t as any).pendingStarts.size; added a default-mode variant
  pinning cleanup on the final-refuse + abort paths too.
…ence (ranxianglei#5505)

Config surface registration (house pattern per ranxianglei#5327: sub-behavior
documented in the parent entry desc, no separate seed key for object
sub-fields, no new env var -- file-only like enabled/warn/abort).
Regenerated CONFIGURATION.md/.zh-CN.md via tools/gen-config-docs.mjs.
…onfig file (ranxianglei#5505)

Aligns with maintainer feedback on PR ranxianglei#5514 (request changes).

Changes:
- config.ts:2261 — repetition type: boolean | { enabled?, warn?, abort?, recovery? }
- knobs.ts:339 — guardrailRepetition() returns boolean | object shape
- tool-guardrails.ts:266 — text fix: "take stronger action" instead of "ABORTED"
- process.yaml — 4 sub-field entries + main entry type: "boolean | object"
- Auto-generated: CONFIGURATION.md, CONFIGURATION.zh-CN.md via gen-config-docs.mjs

Fixes maintainer review items:
1. Recovery mode now reachable (config → knobs → pi chain passes objects)
2. Final-refuse text truthful for both default and recovery modes

Verification:
- config-surface guard: ✓ (182 leaf fields, 34 CLI flags)
- npx tsc --noEmit: clean
- npm run build: success (ESM dist/index.js 5.57 MB)
- All 25 tests pass (11 tool-guardrails-pi + 14 issue5225)
@growlf
growlf force-pushed the fix/repetition-graceful-end branch from 20fda18 to aa48eb7 Compare November 2, 2026 22:16
…iew)

guardrailRepetition() normalized file value false -> true, so the
documented opt-out (repetition: false in the config file) silently
RE-ENABLED the loop-breaker. Master's own contract test
tests/knobs-config-precedence.test.ts:423 ('file tier') fails on the
PR head without this fix. Pass boolean/object forms through untouched.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review 结论:一个真 bug(已在分支上直接修掉)+ 其余可合。修复提交:c7868ed9(已把 master 合回分支,新 head 0aac0cc8)。

修掉的 bug(小问题,按 house rule 11 直接修)

src/knobs.ts guardrailRepetition():

// 原码:文件里 repetition:false → 返回 TRUE → 循环破除器被静默【重新打开】
return val !== undefined && val !== false ? val : true;

文档(CONFIGURATION.md/zh + process.yaml)和 issue 都写着「false 或 env 0 关闭」,但对象形式落地时把布尔 false 的归一化写反了:配置文件写 repetition: false 的用户,守卫反而会被打开。master 自带的契约测试 tests/knobs-config-precedence.test.ts:423(断言 file tier 返回 false)在 PR head 上实测红(AssertionError: file tier,本地复现)。修法:undefined→true、boolean/object 原样透传,一行级改动。修后三个套件本地 73/73 全绿(knobs 优先级 + tool-guardrails-pi + issue5225-repetition-poll)。

实现本身的质量(没动的部分)

  • 决策阶梯正确:recovery 下 count>abort 且 <abort+5 = soft-stop(拒+卡死报告+回合保留),count≥abort+5 = hard-abort(ctx.abort),默认模式行为与旧版逐字节一致(阶梯前两条只在 recovery 时命中)。
  • 顺带修了一个真泄漏:所有 block 路径(final-refuse/soft-stop/hard-abort/旧 abort)补了 tracker.complete(e.toolCallId)——被拦的调用不会触发 tool_result,pendingStarts 原来会无限累积;注释论证了 0ms < REPEAT_SLOW_CALL_MS(5s) 不会误触发长轮询重置,成立。这条对默认模式也生效,是行为改善不是破坏。
  • 通知文案的真伪处理到位:软停不再谎称 "The turn has been aborted"(有 doesNotMatch 回归钉),硬停/默认 abort 保留 "has been aborted" 并有 match 钉住;final-refuse 改成中性的 "take stronger action"(recovery 下必须这样才为真)。
  • 测试覆盖够:tracker 层(pendingCallCount 不变式、recovery+默认两种模式的完整生命周期)+ wire 层(软停窗口不 abort、backstop 恰好一次 abort、自定义阈值 warn=2/abort=3→backstop 8)+ 通知文案真伪。
  • 配置面:recovery 子字段仅文件可用(env 只认布尔)是合理收窄,CONFIGURATION.md/zh 按仓库惯例从 process.yaml 种子再生成,新增行排序和 file-only 标记符合现有格式;docs-sync 检查会背书。

小观察(不构成阻塞,不动手)

  • env 表里 BILI_GUARDRAIL_REPETITION (boolean truthy/disabled only …) 把注解塞进了变量名列,略挤,但生成器输出就这样,无碍。
  • pendingCallCount getter 是为不变式测试暴露的类表面,无害且文档化了有界性承诺。

状态与建议

head 0aac0cc8 的 CI 正在重跑(synchronize 触发)。needs-decision 的两个点我认为都站得住:①recovery 默认 false(纯 opt-in,零存量影响)②backstop 固定 +5(窗口有限、终止保证不变)。CI 绿后可以直接合(已有「马上合并」label)。合并顺序建议:本 PR 独立,无依赖。

…anglei#5514 review)

The (boolean truthy/disabled only...) annotation sat in the process.yaml
env: field and was rendered verbatim into every table's env-name column;
tools/gen-config-docs.mjs check-coverage exact-matches that column against
the env names read in src/, so it reported BILI_GUARDRAIL_REPETITION as
UNDOCUMENTED and red the docs-coverage job on this PR head while master
stays green (reproduced locally both ways). The note is already carried by
the desc fields ('object sub-fields are file-only'), so the seed now names
the variable plainly and the artifacts regenerate clean.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第二个直修(docs-coverage 红):提交 a7beb0d3,新 head。

  • 现象:docs-coverage job 挂,tools/gen-config-docs.mjs check-coverage 报 UNDOCUMENTED env vars read in src/: BILI_GUARDRAIL_REPETITION。
  • 根因(本 PR 自带回归,master 本地实测绿、PR head 实测红,双向复现):website/config-reference/process.yaml 的 env: 字段被写成了 BILI_GUARDRAIL_REPETITION (boolean truthy/disabled only — object form is file-only)——生成器把这串原样渲染进四张表的"变量名列",而 check-coverage 对这一列做精确匹配代码里的 env 名,于是带注解的名字匹配不上,裸名反而变成"未文档化"。
  • 修法:注解信息 desc_en/zh 里本就有("对象子字段仅限配置文件(不通过环境变量暴露)"),seed 的 env 字段改回纯变量名,generate 重新生成全部产物(md EN/ZH 各两行)。本地验证:check-coverage → coverage ok: 195 env names + 59 top-level keys;generate → i18n ok、零漂移。
  • 至此两个直修齐了:c7868ed9(knobs false 归一化)+ a7beb0d3(docs seed),外加把 master 合回分支。等新头 CI 全绿即可合。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第三个红是 flake(非代码问题),已触发失败分片重跑:job test (windows-latest, 22, 3) → tests/issue3380-dsh-rereg-selflock.test.ts:285。

证据链:

  1. 断言原文:retryAt sits on the 80ms ladder step (got -13ms) —— retry 间隔是确定值(基线 20ms × 第 3 档 4 倍 = 80ms),断言拿墙钟 retryAt - Date.now() ∈ [30,95] 校验;差值 -13ms 说明 runner 在"设置 retryAt"和"读时钟"之间卡了 >93ms,纯环境抖动。
  2. 该测试属 DSH 注册自愈子系统(#3380),本 PR diff(守卫器/knobs/配置文档)与其零交集,不 import、不共享路径。
  3. 同一代码状态(上一轮 head 0aac0cc8,两轮之间只隔一个纯文档提交)在同一分片是绿的;本地 linux 跑该文件 6/6 全过。

已 rerun-failed-jobs(run 41656154138)。若重跑仍挂在同一行,再深查(那就是另一个故事了)。

@ranxianglei
ranxianglei merged commit b4fc024 into ranxianglei:master Nov 4, 2026
75 of 76 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repetition guard detects degenerate loops but provides no recovery — needs repetitionRecovery mode

2 participants