From 97c4a1e37d8a5bd0cb759a7c1ec46455a7eff366 Mon Sep 17 00:00:00 2001 From: ci-check Date: Thu, 19 Nov 2026 01:47:15 +0800 Subject: [PATCH] fix: scope-gate (requireRecommendation) refusals no longer arm the compress breaker (#7197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⚠️ MODEL-FACING TEXT CHANGE: scope-gate refusal receipts no longer carry the 'COMPRESS CIRCUIT BREAKER: ARMED — STOP calling compress now: do not try other ranges, do not re-issue any previous range, and do not poll acp_status.' paragraph. The core refusal wording is unchanged. The model now sees the refusal + advice ('Call acp_status ... stay within them') and follows it with an in-recommendation retry — the recovery the removed paragraph forbade. No number/ref/position the model propagates moves. The out-of-recommendation scope gate is a range-correctness gate ('your span was wrong'), not a fold-feasibility signal. Its recovery (acp_status -> an in-recommendation retry) is always available and succeeds if followed, so arming the session-level breaker (which orders 'do not try other ranges ... do not poll acp_status') forbade the only recovery the code still allowed: an obedient model lost compression for the whole session while a disobedient one recovered on the next call. Remove noteCompressLoopFailure from the scope-gate branch; keep recordCompressFailure so the #6728 repeat-collapse still fires on identical re-submission. The nudge gate keeps the breaker charge (its recovery is 'wait for a nudge' - no self-recovery). Update tests/issue6728-policy-gate-ledger.test.ts: the requireRecommendation test now asserts the breaker stays disarmed and the repeat-collapse still fires. --- src/stream.ts | 20 +++++++++++++------- tests/issue6728-policy-gate-ledger.test.ts | 16 ++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/stream.ts b/src/stream.ts index bd38ae7d71..a427178ea5 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -1310,20 +1310,26 @@ export function applyRanges(parsed: ReturnType, ctx: if (offending.length > 0) { const listed = offending.slice(0, 3).join(", ") + (offending.length > 3 ? ` (+${offending.length - 3} more)` : ""); ctx.log(`[acp-proxy: refused out-of-recommendation compress — span(s) ${listed} outside the current recommendation set (compress.requireRecommendation)]`); - // #6728: charge the ledger (see the nudge gate above). The - // spec-repeat guard text recordCompressFailure returns is dropped - // on purpose (one counter, stated once — the collapse below says - // it); only the ledger charge matters here. + // #6728: charge the SPEC-REPEAT ledger (recordCompressFailure) so + // the repeat-collapse below fires on identical re-submission. + // #7197: do NOT charge the session-level breaker + // (noteCompressLoopFailure) — the scope gate is a range-correctness + // gate ("your span was wrong"), not a fold-feasibility signal; its + // recovery (acp_status → an in-recommendation retry) is always + // available and succeeds if followed, so arming the breaker (which + // orders "do not try other ranges … do not poll acp_status") would + // forbid the only recovery the code still allows. The nudge gate + // above keeps the breaker charge (its recovery is "wait for a + // nudge" — the model cannot self-recover). const specKey = normalizedSpecKey(ranges); recordCompressFailure(ctx.session, specKey); - const loopGuard = trackLoop ? noteCompressLoopFailure(ctx, specKey) : ""; const occurrences = compressFailOccurrencesOf(ctx.session, specKey); if (trackLoop && occurrences >= 2) { ctx.log( `[acp-proxy: out-of-recommendation receipt collapsed to one-liner (attempt ${occurrences})]`, ); return compressResult( - `[Compression REFUSED again — span(s) ${listed} have now been refused ${occurrences} time(s) the same way (compress.requireRecommendation); nothing was compressed. The full refusal and the current compressible ranges are in the FIRST refused receipt above — do not re-send this call verbatim.${loopGuard}]`, + `[Compression REFUSED again — span(s) ${listed} have now been refused ${occurrences} time(s) the same way (compress.requireRecommendation); nothing was compressed. The full refusal and the current compressible ranges are in the FIRST refused receipt above — do not re-send this call verbatim.`, "refused", 0, "out-of-recommendation", @@ -1339,7 +1345,7 @@ export function applyRanges(parsed: ReturnType, ctx: const advice = recommendedEmpty ? " No compressible ranges remain — the context is already at its minimum; continue the task without compressing. Compression happens again only when there is genuinely new content to fold." : " Call acp_status for the current compressible ranges and stay within them: subdividing a listed span into smaller chunks is fine, and re-folding an already-compressed block to update its summary is fine."; - return compressResult(`[Compression REFUSED: out-of-bounds compression is disabled on this route (compress.requireRecommendation) — span(s) ${listed} contain content bili does not currently recommend folding.${advice}${loopGuard}]`, "refused", 0, "out-of-recommendation"); + return compressResult(`[Compression REFUSED: out-of-bounds compression is disabled on this route (compress.requireRecommendation) — span(s) ${listed} contain content bili does not currently recommend folding.${advice}]`, "refused", 0, "out-of-recommendation"); } } if (ctx.messages.length > 0) { diff --git a/tests/issue6728-policy-gate-ledger.test.ts b/tests/issue6728-policy-gate-ledger.test.ts index 6a1b48be0c..a2306fe7fa 100644 --- a/tests/issue6728-policy-gate-ledger.test.ts +++ b/tests/issue6728-policy-gate-ledger.test.ts @@ -198,26 +198,26 @@ test("#6728: requireNudge refusals charge the ledger — breaker arms by the 3rd ); }); -test("#6728: requireRecommendation refusals charge the ledger — breaker arms by the 3rd identical refusal", () => { +test("#7197: requireRecommendation refusals do NOT arm the breaker (range-correctness gate, not fold-feasibility)", () => { const ctx = scopeGateCtx(); const first = runApply(ctx, SCOPE_CALL); assert.ok( first.startsWith("[Compression REFUSED"), `expected refusal, got: ${first.slice(0, 120)}`, ); + runApply(ctx, SCOPE_CALL); + const third = runApply(ctx, SCOPE_CALL); assert.ok( !compressBreakerArmed(ctx.session), - "breaker must not arm on the first refusal", + "#7197: scope-gate refusals must NOT arm the breaker — the recovery (acp_status + in-recommendation retry) is always available, so the stop wording would forbid the only recovery the code allows", ); - runApply(ctx, SCOPE_CALL); - const third = runApply(ctx, SCOPE_CALL); assert.ok( - compressBreakerArmed(ctx.session), - "breaker must be armed after 3 consecutive gate refusals", + !third.includes("COMPRESS CIRCUIT BREAKER"), + "scope-gate refusal must not carry the breaker paragraph:\n" + third, ); assert.ok( - third.includes("COMPRESS CIRCUIT BREAKER"), - "3rd receipt must carry the breaker paragraph:\n" + third, + third.includes("again"), + "the spec-repeat collapse must still fire on the 3rd identical call (#6728 protection preserved):\n" + third, ); });