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:
@@ -781,6 +781,33 @@ def check_version_is_minted(base: str = "origin/main") -> None:
|
||||
ok(f"nothing version-relevant changed against {base} — no mint required")
|
||||
|
||||
|
||||
# The lower of the two caps recorded for a hook's additional context: the docs
|
||||
# give 10,000 characters, and an installed build has been read capping it at
|
||||
# 8,000. Past the cap the model gets only a short preview.
|
||||
HOOK_CONTEXT_CAP = 8_000
|
||||
PAYLOAD_MODULE = ROOT / "src" / "grimoire" / "services" / "hook_payload.py"
|
||||
|
||||
|
||||
def check_payload_bound() -> None:
|
||||
"""The server fits every hook payload under `hook_payload.HARD_MAX`, and
|
||||
that ceiling must sit under Claude Code's cap whatever a user sets."""
|
||||
try:
|
||||
text = PAYLOAD_MODULE.read_text()
|
||||
except OSError:
|
||||
fail(f"no payload assembler at {PAYLOAD_MODULE.relative_to(ROOT)}")
|
||||
return
|
||||
found = re.search(r"^HARD_MAX\s*=\s*([0-9_]+)\s*$", text, re.M)
|
||||
if not found:
|
||||
fail("hook_payload.HARD_MAX is not a literal this check can read")
|
||||
return
|
||||
hard_max = int(found.group(1).replace("_", ""))
|
||||
if hard_max >= HOOK_CONTEXT_CAP:
|
||||
fail(f"hook_payload.HARD_MAX is {hard_max}, at or past Claude Code's "
|
||||
f"{HOOK_CONTEXT_CAP}-character hook context cap")
|
||||
else:
|
||||
ok(f"hook payloads are bounded at {hard_max} characters, under {HOOK_CONTEXT_CAP}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--no-version", action="store_true",
|
||||
@@ -800,6 +827,7 @@ def main() -> int:
|
||||
check_fail_open()
|
||||
check_local_prior_art_needs_no_instance()
|
||||
check_session_context_reports_its_version()
|
||||
check_payload_bound()
|
||||
if not args.no_version:
|
||||
check_version_is_minted(args.base)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user