Repository navigation
feat(context-guard): bands follow a lowered auto-compact window - #12855
Conversation
The percentage bands were percentages of the model's full window, so a lowered autoCompactWindow or CLAUDE_CODE_AUTO_COMPACT_WINDOW let auto-compact fire while the zone read smart. The mod already asks $.session.usage for the breakdown, whose rawMaxTokens is the window the engine settled on (env, settings, per-model). When it is smaller than the model's window, the module scales the percentage edges, thresholds and approach margin to it and publishes bands.auto_compact_window. Token bands and the shell resolver are unchanged. Refs: #12271 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #12855 (context-guard bands follow a lowered auto-compact window)I found no security issues. I read every hunk of all 6 changed files in What changed since the last review
Trust boundary and data flow
Controls and instruction surfaces
SpendThis change can cause no real charge. critical-findings: 0 |
|
claude-review reviewed Code review: context-guard bands follow a lowered auto-compact windowI found nothing new to block on, and both findings from the last round are fixed. I read every hunk of all 6 changed files. I also read the code around them in Last round's findings, both fixed at this head:
The prior-findings file marks the threshold entry Checked by hand:
Not counted:
Closing issue. The PR says Verification. The test counts (303/303), the No plugin manifests changed, no changed file matches a trusted path, and the PR context and thread text hold no embedded instructions. |
Conflict in plugins/context-guard/reference/reader-contract.md: keep the branch's paragraph on the module scaling the percentage bands, with main's "We read a firing diagnostically" wording and its PreCompact hook pointer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A threshold's edge now scales with the auto-compact window, so keying the once-per-cycle bookkeeping (fired set and approach key) on the scaled edge let a threshold fire again when the window changed mid-cycle. Key it on the unscaled zones.json at_percent; crossing still compares against the scaled edge. New test: a threshold that fired stays fired when the window changes mid-cycle. The changelog fragment becomes a major bump: under a lowered auto-compact window, zones.json percentages and thresholds[].at_percent now read as percentages of that window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous push reached the branch, but the pull request kept its old head, so CI did not run on it. This empty commit makes GitHub re-read the branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs: #12271
Summary
context-guard's percentage bands were percentages of the model's full window. A lowered
autoCompactWindoworCLAUDE_CODE_AUTO_COMPACT_WINDOWtherefore let auto-compact fire while the zone still read smart. The mod now scales its bands to the window the engine actually compacts at.Fix
hooks/register.tsx: reads the effective window from the usage breakdown'srawMaxTokens, whichrefresh()already requests, so no new call. When that window is below the model's, the percentage edges,thresholdsand approach margin scale by the ratio. The snapshot and status tool publish the scaled edges plusbands.auto_compact_window. Atsession.endthe breakdown is absent, so the bands stay unscaled there.hooks/zone.ts: an optionalfollowargument only; its fixture match with the shell resolver holds.reference/reader-contract.md: a lowered window needs no hand retune ofzones.json. The shell resolver does not follow the window yet, tracked in fix(context-guard): the shell zone resolver ignores a lowered auto-compact window #12854.zones.jsonby hand for a lowered window should undo it, or the mod scales the retune a second time.Why
rawMaxTokensand not$.settings.read/$.env.get: those return raw values only and resolve no precedence. A per-modelmodelSettingswindow reads undefined at the top-level key. Basis: the probe in #12271 (comment).Version bump: minor. Default sessions are unchanged (probe baseline:
rawMaxTokens1000000, sourcemodel-default), and the change acts only under an operator-lowered window.Verification
context-guard.test.ts: 4 new cases with hand-computed expectations. 3 fail on the oldregister.tsxandzone.ts; the 4th is the control (window at or above the model's) and passes either way.claude plugin test: 303 of 303 pass.scripts/check-affected.sh: 12 passed, 3 skipped.Remaining
cc-plugin-sec-defaultis seated. It has run only on melo-lap-001 WSL, where the guard reads not-seated. The run on the other lanes is still to do, so feat(context-guard): bands that follow a lowered auto-compact window #12271 stays open.Related
🤖 Generated with Claude Code