feat(7729): one assembler per hook — rule statements first, then the reply shape, then records, under a budget
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Plugin hooks (push) Successful in 17s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Python tests (push) Failing after 1m47s
CI & Build / integration (push) Failing after 2m0s
CI & Build / Build & push image (push) Skipped
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Plugin hooks (push) Successful in 17s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Python tests (push) Failing after 1m47s
CI & Build / integration (push) Failing after 2m0s
CI & Build / Build & push image (push) Skipped
A rule line on first mention now carries the rule's own statement, written as
a statement about the rule ("Rule 11 … may apply here; it binds: …") rather
than an instruction to go read it; a repeat or lower-ranked line is a
reference ("Also relevant: Rule 11 …"). Every line ends with where the session
stands with the rule and get_rule(id) for the full text.
services/hook_payload.py fits every injecting door's payload (prompt,
pre-tool rules, moment, write path) to the user's budget: parts in one order,
kept while they fit, dropped whole otherwise. A dropped part's ids leave the
response lists, so the plugin ledgers mark only what was shown, and rule
deliveries are buffered per request and written only for kept lines.
Budget: Settings, default 4,500 characters (the full core reply shape is
2,343 and a full rule line up to ~750, so 3,000 would have crowded the shape
out of most turns), clamped to 1,000-7,500 — under the lower of the two
recorded hook caps (10,000 in the docs, 8,000 read from an installed build).
check_plugin asserts the ceiling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -107,15 +107,13 @@ def test_the_band_is_computed_from_scores_not_from_the_ledger():
|
||||
assert [r.id for _s, r in kept] == [1, 2]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("seen", [False, True])
|
||||
def test_the_leading_line_carries_the_trigger(seen):
|
||||
"""Rank 0 gets the full rendering, on either tail."""
|
||||
line = _rule_hint_line(
|
||||
fake_rule(id=4, title="dev is home", when_to_apply=_TRIGGER),
|
||||
where="to this Bash call", seen=seen, compact=False,
|
||||
)
|
||||
assert _TRIGGER in line
|
||||
assert "get_rule(4)" in line
|
||||
def test_the_leading_line_carries_the_statement_on_a_first_mention():
|
||||
"""Rank 0 on a first mention says what the rule says; a repeat cites it."""
|
||||
rule = fake_rule(id=4, title="dev is home", when_to_apply=_TRIGGER)
|
||||
first = _rule_hint_line(rule, where="to this Bash call", seen=False)
|
||||
assert rule.statement in first and "get_rule(4)" in first
|
||||
again = _rule_hint_line(rule, where="to this Bash call", seen=True)
|
||||
assert rule.statement not in again and "get_rule(4)" in again
|
||||
|
||||
|
||||
@pytest.mark.parametrize("seen", [False, True])
|
||||
@@ -161,12 +159,12 @@ def test_shortening_a_line_does_not_decide_what_it_says_about_holding():
|
||||
assert len({fresh, named, held}) == 3, (
|
||||
"the compact branch collapsed two holding states into one line"
|
||||
)
|
||||
assert "not in this session's loaded set" in fresh
|
||||
assert "First mention" in fresh
|
||||
assert "not opened" in named
|
||||
assert "no longer hold it" in held
|
||||
assert "Opened earlier" in held
|
||||
# The claim that most needs to survive shortening: a line the session never
|
||||
# opened must not imply it did, however little room the line was given.
|
||||
assert "no longer hold it" not in named
|
||||
assert "Opened earlier" not in named
|
||||
|
||||
|
||||
def test_a_compact_line_is_materially_shorter_than_a_full_one():
|
||||
@@ -188,7 +186,8 @@ def test_a_compact_line_is_materially_shorter_than_a_full_one():
|
||||
"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)
|
||||
rule = fake_rule(id=4, title="dev is home", when_to_apply=long_trigger,
|
||||
statement=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