fix(rules): a shortened rule line must not decide what it says about holding (#3851)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 8s
CI & Build / integration (push) Successful in 40s
CI & Build / TypeScript typecheck (push) Successful in 52s
CI & Build / Python tests (push) Successful in 1m24s
CI & Build / Build & push image (push) Successful in 26s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 8s
CI & Build / integration (push) Successful in 40s
CI & Build / TypeScript typecheck (push) Successful in 52s
CI & Build / Python tests (push) Successful in 1m24s
CI & Build / Build & push image (push) Successful in 26s
CI run 6485 was red. Six failures, three causes, and only one of them was a stale test. THE REAL DEFECT. The compact branch dropped the `seen` TAIL along with the trigger, so a rule the session had already been told rendered exactly like one it had not. #3750's whole argument is that those are different claims — a repeat is rendered precisely because the session may no longer HOLD what it was told — and the tail is the entire difference a reader can act on. test_a_rule_the_session_already_holds_is_referenced_not_re_offered caught it within one commit, which is that guard working as intended. Fixed by keeping the tail and dropping only the trigger, which is both the cheaper and the safer cut: a trigger runs 300-400 characters after #3855, a tail about 100. Re-measured on the real renderer — top-full-plus-references is ~299 tokens against ~568 for five full lines, so about 2x the old single line rather than the 1.4x claimed before, for four more rules and no lost information. The comments carrying the old figure are corrected rather than left to read as a decision nobody made. THE FIXTURE THAT STRADDLED THE BAND. `_THREE_HITS` spanned 0.81-0.74 against a 0.05 band, so the act arms dropped its lowest hit and four cases of test_both_recorders_report_the_same_rules_for_one_call failed reporting a count mismatch — under a message blaming the exclusion filter. A guard pointing confidently at the wrong subsystem costs more than no guard, because it is believed. Scores retightened to 0.81/0.80/0.79 and the precondition is now asserted by a named test, so a future band change is told where the problem is instead of through four confusing failures. THE STALE CONSTANT GUARD. test_the_rule_arm_asks_for_one_rule_not_two pinned RULEHINT_LIMIT == 1 — a real decision, correctly guarded, for a world with a resident set. Rewritten to pin what replaced it, as relationships rather than values (rule 115): the arm can return several, and rules are narrowed HARDER than the notes menu because they measured flatter, not sharper. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011cPyzNnegXHr5iRMzzy5KJ
This commit is contained in:
@@ -124,11 +124,11 @@ def test_the_leading_line_carries_the_trigger(seen):
|
||||
def test_a_later_line_cites_its_rule_without_quoting_the_trigger(seen):
|
||||
"""Rank > 0 is a reference: identity and pointer, no trigger.
|
||||
|
||||
The trigger is the expensive half — it is what made a full line ~143
|
||||
tokens — and the leading line has already demonstrated the shape. Both
|
||||
assertions matter: dropping the trigger is the saving, and keeping
|
||||
`get_rule(id)` is what makes the saving safe, because a cited rule the
|
||||
reader cannot pull is just noise.
|
||||
The trigger is the expensive half — 300-400 characters after #3855 — and
|
||||
the leading line has already demonstrated the shape. Both assertions
|
||||
matter: dropping the trigger is the saving, and keeping `get_rule(id)` is
|
||||
what makes the saving safe, because a cited rule the reader cannot pull is
|
||||
just noise.
|
||||
"""
|
||||
line = _rule_hint_line(
|
||||
fake_rule(id=4, title="dev is home", when_to_apply=_TRIGGER),
|
||||
@@ -139,14 +139,48 @@ def test_a_later_line_cites_its_rule_without_quoting_the_trigger(seen):
|
||||
assert "get_rule(4)" in line
|
||||
|
||||
|
||||
def test_shortening_a_line_does_not_decide_what_it_says_about_holding():
|
||||
"""A reference still tells a repeat from a first surfacing (#3750 x #3851).
|
||||
|
||||
This is the regression the first cut of #3851 actually shipped: the
|
||||
compact branch dropped the tail along with the trigger, so a rule the
|
||||
session had already been told read exactly like one it had not. #3750's
|
||||
whole argument is that the two are different claims — a repeat is rendered
|
||||
precisely because the session may no longer HOLD what it was told — and
|
||||
the tail is the entire difference a reader can act on.
|
||||
|
||||
`compact` and `seen` are independent axes. How much room a line gets is a
|
||||
fact about its rank; whether the session holds it is a fact about the
|
||||
ledger; and neither may be allowed to answer the other's question.
|
||||
"""
|
||||
rule = fake_rule(id=4, title="dev is home", when_to_apply=_TRIGGER)
|
||||
seen = _rule_hint_line(rule, where="here", seen=True, compact=True)
|
||||
fresh = _rule_hint_line(rule, where="here", seen=False, compact=True)
|
||||
assert seen != fresh
|
||||
assert "no longer hold it" in seen
|
||||
assert "not in this session's loaded set" in fresh
|
||||
|
||||
|
||||
def test_a_compact_line_is_materially_shorter_than_a_full_one():
|
||||
"""The cost claim, asserted rather than asserted-in-a-comment.
|
||||
"""The cost claim, asserted rather than left in a comment.
|
||||
|
||||
Not a token count — that would pin the tokenizer. Half the characters is
|
||||
the property that makes widening the arm affordable, and it is what fails
|
||||
if a later edit reintroduces the trigger into the compact branch.
|
||||
if a later edit puts the trigger back into the compact branch.
|
||||
|
||||
Measured against a REALISTIC trigger, because that is where the saving
|
||||
lives: the rules this arm carries run 300-400 characters of trigger after
|
||||
#3855, and a toy one-line trigger would make this pass on a compact branch
|
||||
that had stopped saving anything.
|
||||
"""
|
||||
rule = fake_rule(id=4, title="dev is home", when_to_apply=_TRIGGER)
|
||||
long_trigger = (
|
||||
"Opening or merging a `dev`->`main` pull request, running "
|
||||
"`git push origin main`, `git tag`, or minting a release, image tag "
|
||||
"or other public artifact. Also whenever CI has just gone green and "
|
||||
"the next step feels like shipping it, and whenever an earlier merge "
|
||||
"this session reads like standing permission for the next one."
|
||||
)
|
||||
rule = fake_rule(id=4, title="dev is home", when_to_apply=long_trigger)
|
||||
full = _rule_hint_line(rule, where="here", seen=False, compact=False)
|
||||
compact = _rule_hint_line(rule, where="here", seen=False, compact=True)
|
||||
assert len(compact) * 2 < len(full)
|
||||
|
||||
Reference in New Issue
Block a user