Repository navigation
The de-hardcode guard was blind to floats — and something was already through it (#124/#441) - #2342
Merged
Merged
Conversation
…culative interface, zero callers (#441) Landed and removed the same day. Three defects in one small addition: 1. MAGIC CONSTANT. `WINDOW_COMPARABILITY_FACTOR: f64 = 2.0` was invented. Nothing derives it. The doc rationalised 2x after the fact. 2. ZERO PRODUCTION CALLERS. `comparable_at()` was never called anywhere in the tree. A predicate built for consumers that do not exist. 3. A LYING COMMENT, which is the worst of the three. Each of the three seed rows carried "consumers get `comparable_at() == false` rather than a silent assumption" — asserting a reader that was never written. Same class as #151/#357, authored while fixing that class. ARCHITECTURALLY it was also the wrong shape (Joel): whether two operating points are comparable is a CONSUMER's judgement, made against the lease/handle it already holds. It is not a rule a data struct asserts for every caller in the tree. We have consumer/handle interfaces for this; I bolted on a bespoke free predicate instead of using them. `measured_at_window` STAYS. It is provenance — it says what the number describes, and its absence caused a real live mis-attribution. A field that records a fact is not the same as a predicate that judges one. cargo check 0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…hing was already through it (#124) THE HOLE. The guard fires on `const NAME: <int> = <literal>` when NAME says WINDOW/CONTEXT/CTX/TOKEN/PROMPT/CHARS. Its type list stopped at the integers, so ANY window-relative constant typed `f32`/`f64` walked straight past it. Found the hard way: `WINDOW_COMPARABILITY_FACTOR: f64 = 2.0` (mine, #2339) matched the name rule, WAS a bare literal, and sailed through on the type. A guard against invented numbers that a float annotation defeats teaches exactly one lesson — type your magic number as a float. A ratio over the window is as much a fresh guess as a count of its tokens. Now caught the same way: f32/f64 added, and the literal detector accepts a decimal point (one only, digit-led, so `1.5` matches and `A.b`/`1..2` do not). WHAT IT CAUGHT ON THE FIRST RUN — not mine, and pre-existing: recall_faculty.rs:70 — const RECALL_WINDOW_FRACTION: f32 = 0.10 10% of every citizen's served window, spent on recall, invented and never derived. Exactly the shape the guard exists to stop, sitting inside the guard's blind spot. That is the positive control: the hole was real and occupied. THE FIX is the one the guard's own failure message prescribes — express it as a fraction on ContextBudget, where it SCALES with the served window instead of being a 4k-shaped slice a 1M-context model inherits. `ContextBudget:: recall_tokens()` over `RECALL_DENOM`; recall_faculty derives from it via the existing `from_window` constructor and no longer owns a float. MIN_RECALL_TOKENS stays as-is — it carries a real `context-budget-exempt:` receipt saying it only ever RAISES a budget, never caps one. cargo check --tests 0; context_budget + recall suites 0 (read by exit code). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits, one theme: magic numbers I wrote, and the guard that should have stopped me.
1. Remove
comparable_at+ its invented2.0(#441)Landed and removed same day. Three defects: the constant was invented; the method had zero production callers; and each of three seed rows carried a comment promising "consumers get
comparable_at() == false" — asserting a reader that was never written, the same lying-receipt class as #151/#357.Architecturally wrong too: whether two operating points are comparable is a consumer's judgement against the lease/handle it holds — not a rule a data struct asserts for every caller.
measured_at_windowstays: recording what a number describes is provenance; judging it is not the struct's job.2. Close the hole that let it through (#124)
The guard fires on
const NAME: <int> = <literal>when NAME says WINDOW/CONTEXT/TOKEN/…. Its type list stopped at the integers, soWINDOW_COMPARABILITY_FACTOR: f64 = 2.0matched the name rule, was a bare literal, and sailed through on the type alone. A guard that anf64annotation defeats teaches one lesson: type your magic number as a float.Now covers
f32/f64, with a digit-led single-decimal-point literal test (1.5matches;A.b/1..2don't).Positive control — it caught a real one on the first run, not mine:
10% of every citizen's served window, spent on recall, invented and never derived. Fixed the way the guard's own message prescribes:
ContextBudget::recall_tokens()overRECALL_DENOM, so it scales with the served window instead of being a 4k-shaped slice a 1M-context model inherits.MIN_RECALL_TOKENSuntouched — it carries a realcontext-budget-exempt:receipt (only ever raises a budget, never caps one).cargo check --tests 0; guard + context_budget + recall suites 0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo