Skip to content

pr-4168-archive-pre-revert

@LaZzyMan LaZzyMan tagged this 20 May 03:25
R12.1 critical (sibling sweep of R11.1): R11.1 added Number.isFinite
to `lastCandidatesTokenCount`, but `lastPromptTokenCount` (assigned
3 lines above) and `cachedContentTokenCount` had no guard. Also,
Number.isFinite(-1) is true — a negative value would still poison
arithmetic. Factored `coerceUsageCount(value)` enforcing
(finite ∧ >= 0) and routed all 4 API-value capture sites through it.
RED-first via Infinity/NaN/-1/-1e9 injection test.

R12.2 critical (computeThresholds NaN propagation): a provider
returning `"context_window": null` surfaces as `contextWindowSize:
NaN`. Pre-fix, NaN propagated to all 4 thresholds, every downstream
`tokens >= NaN` comparison evaluated false, and the entire three-tier
gate silently disabled. Guard with `!Number.isFinite || <= 0` →
return Infinity thresholds (gate falls through to NOOP) + 0
effectiveWindow. RED-first against NaN/0/-1/-Inf inputs.

R12.3 critical (R8.7 self-inflicted undercount): pure scaling
collapses on extreme scratchpad/snapshot ratios. Example: 200K
scratchpad + 5K snapshot with 15K API tokens scaled to ~375 tokens.
Floor by `estimateContentTokens` on the persisted summary — `Math.max(
scaledApi, charBased)` keeps API tokenizer fidelity when scratchpad is
reasonable, clamps when it isn't. RED-first via 200K/5K extreme test.

R12.4 critical (disabled NOOP observability): the R11.4 disable-knob
NOOP returned silently, leaving oncall unable to distinguish "user
disabled" from "system broken". Added once-per-process warn (module-
level flag because `ChatCompressionService` is per-call). Symmetric
with R7.9 `breakerWarningEmitted` / R8.4 `budgetExhaustedWarningEmitted`.

R12.5 critical (test gap for R11.4 source gate): R11.4's hard-rescue
source-level disable check had no regression guard. Added test
mocking `getChatCompression: { disabled: true }` + lastPromptTokenCount
above hard threshold; asserts no force=true call to tryCompress.
Test passes against current code — pins the contract against future
refactor removing the source gate.

R12.6 (deprecation text contradiction): the R11.4 commit added
`disabled: true` but left the deprecation warning saying
"auto-compaction cannot currently be disabled". Updated to mention
the new field.

R12.7 declined-design: `imageTokenEstimate: 0` silently clamping to
100 violates user intent on a user-configurable knob. The reviewer's
concern (user accidentally disabling image weight) is real but the
fix is wrong shape — silent override of explicit values is filter-5
defensive bloat. Users explicitly setting 0 are signaling intent;
config-validation warnings at load are a future enhancement if
real-world complaints surface.

R12.8 (locale baseline): the 8+ new t() keys in /context output
(`Compaction thresholds`, `Effective window`, `Warn/Auto/Hard
threshold`, `Current tier`, tier names, `window − {{reserve}}
reserve`) had no entries in en.js. Added as baseline; other locales
fall back to the literal key (existing Used/Free behavior).
Not flagged in mustTranslateKeys.ts — would force breaking-CI on
locale maintainers; same precedent as existing Used/Free which also
aren't flagged.

R12.9 + R12.10 (discoverability): added `model.chatCompression.disabled`
and `model.chatCompression.imageTokenEstimate` rows to settings.md;
updated the REMOVED row for `contextPercentageThreshold` to mention
the new `disabled: true` migration path per gpt-5.5's exact suggested
text. Schema entry in settingsSchema.ts deliberately NOT changed —
adding nested sub-properties for chatCompression would require
rewriting the schema design for ALL existing sub-fields
(imageTokenEstimate) and is out of scope for this round; TypeScript's
ChatCompressionSettings interface already provides IDE-side autocomplete.

2405 core + 43 CLI tests in touched files passing. Pre-existing
serve/* import resolution failures in CLI workspace unaffected.
Assets 2
Loading