Repository navigation
Conversation
The quota hint re-rendered byte-identical content on EVERY prompt. Observed
live on 2026-09-21: the same one-liner on every turn of a long session,
costing context on each turn while changing no decision. Repeating an
unchanged number is a tick, not a delta.
Adds a 15-minute freshness gate keyed on the ledger's own mtime: if nothing
has metered a window recently there is no new pressure to report. A dispatch
touches the ledger, so the next prompt renders fresh numbers again.
Stateless BY DESIGN. mr-hook writes no state in production and that invariant
is preserved -- the signal is the ledger file's existing mtime, not a new
cache. Fail-open stays absolute: a stat error yields "".
THE GLM HARD-STOP LATCH IS EXEMPT, and that exemption is the point of the
regression guard below.
The first cut placed the stat before the rows were built. The GLM latch is
deliberately ledger-INDEPENDENT -- it renders with no buckets and with no
ledger file at all -- so the stat failed and the gate silently swallowed a
1313 account-protection warning. TestHookMismatchKeepsQuotaHintE2E caught it.
The gate now runs after row construction and never applies when the latch is
set: that signal is account protection, not quota reporting.
Tests (TDD, red before green):
TestQuotaHintStaleLedgerSuppressed 30m-old ledger -> "" (was: rendered)
TestQuotaHintFreshLedgerRenders control arm: 1m-old ledger still
renders WITH its signal, so the gate
cannot pass by suppressing everything
TestQuotaHintGLMLatchExemptFromStaleness regression guard, no ledger at all ->
latch must still render
The guard is mutation-proven: replacing `if !glmLatched` with `if true`
turns it RED ("got: \"\""), and restoring the exemption turns it green.
Gates: full cmd/mr-hook suite ok (11.2s) · go vet exit 0 · gofmt clean on
LF-normalized copies of both touched files · semgrep exit 0, 0 findings,
131 rules.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The B12 complexity ratchet refused the previous commit at exactly +29 non-test Go LOC, which is precisely the size of the change. Raised consciously here, as the canary's own message instructs, rather than by trimming the comments that document the bug. The bulk of the +29 is the GLM exemption and its rationale, which is the part worth keeping in the source: the first cut of the gate stat'd the ledger BEFORE rows were built, and because the GLM hard-stop latch is deliberately ledger-independent -- it renders with no buckets and with no ledger file at all -- the gate silently swallowed a 1313 account-protection warning. A future reader moving that stat back would reintroduce it; the comment and the mutation-proven guard are what stop that. _note history preserved via the file's append-only PRIOR: convention. Verified: canary green, whole repo green uncached (go test -count=1 ./...). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Closing unmerged — the gate does not achieve its goalA Why the mtime gate fails
My tests set mtime directly with Why "skip unchanged writes in
|
The problem
The quota hint re-rendered byte-identical content on every prompt. Observed live 2026-09-21: the same one-liner on every turn of a long session — costing context each turn while changing no decision.
Repeating an unchanged number is a tick, not a delta.
The change
A 15-minute freshness gate keyed on the ledger's own mtime. If nothing has metered a window recently there is no new pressure to report. A dispatch touches the ledger, so the next prompt renders fresh numbers again.
Stateless by design.
mr-hookwrites no state in production and that invariant is preserved — the signal is the existing mtime, not a new cache file. Fail-open stays absolute: a stat error yields"".The GLM hard-stop latch is exempt — and that is the interesting part
The first cut placed the stat before rows were built. The GLM latch is deliberately ledger-independent: it renders with no buckets and with no ledger file at all. So the stat failed, and the gate silently swallowed a 1313 account-protection warning.
TestHookMismatchKeepsQuotaHintE2Ecaught it — the existing E2E seeds onlyglm-alert.json, no ledger.The gate now runs after row construction and never applies when the latch is set. That signal is account protection, not quota reporting.
Tests — TDD, red before green
TestQuotaHintStaleLedgerSuppressed""(previously rendered)TestQuotaHintFreshLedgerRendersTestQuotaHintGLMLatchExemptFromStalenessThe guard is mutation-proven: replacing
if !glmLatchedwithif trueturns it red (got: ""); restoring the exemption turns it green.B12 ratchet
Refused at exactly +29 non-test LOC — precisely the size of this change. Raised consciously to 30578 in the second commit, as the canary's own message instructs, rather than by trimming the comments that document the bug. A future reader moving that stat back would reintroduce the swallowed warning; the comment and the guard are what prevent it.
_notehistory preserved via the append-onlyPRIOR:convention.Gates
go test -count=1 ./...(whole repo, uncached)go test -count=1 ./cmd/mr-hook/go vet ./cmd/mr-hook/gofmt--config=autoNote on
gofmt -l: it lists 12 files incmd/mr-hook/, including ones untouched here. That is the Windows CRLF working-tree artifact —main.goisw/crlfand formats clean once LF-normalized. Both files in this PR arew/lfand clean.🤖 Generated with Claude Code