Reply shape survives a compaction (#7716); test review pass (#8249); detector fix (#8292) #239

Merged
bvandeusen merged 27 commits from dev into main 2026-12-02 13:09:44 -05:00
Owner

Merges dev into main so the instance picks up:

  • #7716 "Prompt-hook context over 10,000 chars is cut to a 2KB preview…": the prompt payload now carries the top two rule lines, then the reply shape, then the rest. After a compaction every rule returns as a first mention, and before this change they pushed the shape out of the budget. Proven by a deliberate break (run 11251 failed the new test with assert [] == ['core']), reverted in 9de0e80.
  • #8249 "Acceptance — Grimoire's own suite reviewed with the new verdicts": redundant tests folded into their covering tests, and 6 deliberate breaks caught 19 of 19 behaviours.
  • #8292: the detector fix (881e0fd).
  • The claims hook test now skips through the shared need_tools helper.

CI on the head SHA 9de0e80: run 11254, green.

🤖 Generated with Claude Code

Merges `dev` into `main` so the instance picks up: - **#7716 "Prompt-hook context over 10,000 chars is cut to a 2KB preview…"**: the prompt payload now carries the top two rule lines, then the reply shape, then the rest. After a compaction every rule returns as a first mention, and before this change they pushed the shape out of the budget. Proven by a deliberate break (run 11251 failed the new test with `assert [] == ['core']`), reverted in 9de0e80. - **#8249 "Acceptance — Grimoire's own suite reviewed with the new verdicts"**: redundant tests folded into their covering tests, and 6 deliberate breaks caught 19 of 19 behaviours. - **#8292**: the detector fix (881e0fd). - The claims hook test now skips through the shared `need_tools` helper. CI on the head SHA 9de0e80: run 11254, green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bvandeusen added 27 commits 2026-12-02 13:09:42 -05:00
Review of the signature-flagged tests:
- Four route files each listed service names by hand and checked each takes
  user_id. A new service without the caller passed them, and a renamed one
  failed them. They become one test over services/{design_systems,systems,
  rulebooks,snippets}.py: every public coroutine takes user_id, except eight
  named with the reason each needs none, and an exception for a function that
  is gone or now takes the caller fails too.
- test_routes_trash was four existence checks: blueprint name, registered,
  handlers callable, the service surface, delete's parameter names. It
  becomes one check that the three trash routes are on the app; what they do
  is proven by test_services_trash and test_mcp_tool_trash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): DELIBERATE BREAK, a service without the caller and the trash list route removed
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m46s
CI & Build / integration (push) Successful in 2m24s
CI & Build / Build & push image (push) Skipped
496d047d69
Reverted by the next commit. CI must go red on
test_service_user_id_contract[systems] and test_routes_trash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The caller-scoping property now covers services/family, family_adoption and
  platforms, with the seven reads that need no caller named and why. The
  hand-written platform list goes.
- The snippet location keys: one test checks every door (service, MCP tool,
  web route) takes them; the route-only copy goes.
- The write-path hook: the payload-shape and skip-list tests searched the
  shell script for strings. They now run the hook against a local listener and
  check what it sends: the code from each of the four payload field names, and
  nothing for a note, JSON or SVG while a YAML file and a .py are still asked about.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refusal test raises, then checks nothing was written with
assert_not_called. The mock-only signal counted only plain asserts as outcome
checks, so 28 of the 44 tests it flagged in Grimoire's own suite were refusals.
pytest.raises and assertRaises now count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): DELIBERATE BREAK, notes no longer skipped, new_str not read, a platform read without the caller
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m53s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / integration (push) Canceled after 2m23s
adc460b5ba
Reverted by the next commit. CI must go red on
test_hook_asks_about_code_and_never_about_prose_or_data[README.md],
test_hook_reads_every_write_and_edit_payload_shape[Edit-new_str] and
test_every_public_service_takes_the_caller[platforms].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): the payload-shape test expects the code as the shell sends it, without a trailing newline
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m13s
CI & Build / integration (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 24s
85b29d642f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_write_path_trigger:
  - the sync, reuse and rule dedup channels: two string searches become one
    run of the hook twice in a session, checking each class of id comes back
    on its own parameter;
  - "stays a GET": one request to the prior-art route, with no body;
  - the route/hook argument contract: the hook runs with every ledger it
    keeps already holding something, and every key it sends must be read by
    the route (read from the route's AST);
  - the "names the shapes" string search goes: two runtime tests already check
    the Write and the Edit cases.
- test_rule_moment_signal_hooks: the body the route must read is the body the
  hook actually sent.
- test_task_claims: session start is run and must send source and session_id;
  session end is run and releases on logout but not on /clear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): DELIBERATE BREAK, /clear releases claims, session start drops session_id, sync ids renamed
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m56s
CI & Build / integration (push) Successful in 2m31s
CI & Build / Build & push image (push) Skipped
0b12d812ea
Reverted by the next commit. CI must go red on
test_session_end_releases_claims_but_not_on_clear[clear-False],
test_the_session_start_hook_sends_the_source_and_the_session and
test_each_class_of_hint_is_sent_back_on_its_own_channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): the route/hook argument run fills the sync channel too, so a renamed sync key is caught there
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 2m14s
CI & Build / integration (push) Canceled after 2m6s
4321b05387
Deliberate break 3 renamed exclude_sync_ids in the hook; the channel test
caught it, the argument contract test did not, because its run had no sync
ids to send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_moment_delivery: the route/hook name check runs the hook with the
  rule, opened and shape ledgers filled and checks every key it sends is read
  by the route; "leaves Grimoire's own tools alone" runs it with a listed
  Grimoire tool and sees no ask.
- test_gate_stop_hooks: the action hook run twice on one checkpoint rule
  holds once, and books the rule on the session ledger after the stop. This
  replaces two line-window checks in test_pre_act_checkpoint.
- The write hook never stopping a write: the two string guards (one per test
  file) are one, which now also forbids the shared deny helper, the call the
  old permissionDecision check could not see.
- route_query_args (tests/helpers.py) reads the query keys a route takes from
  its AST, shared by both route/hook contract tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): DELIBERATE BREAK, Grimoire tools asked about, shapes_seen renamed, checkpoint uncapped
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 15s
CI & Build / Python tests (push) Failing after 2m0s
CI & Build / integration (push) Successful in 2m30s
CI & Build / Build & push image (push) Skipped
84847cea0e
Reverted by the next commit. CI must go red on
test_grimoires_own_tools_are_left_to_their_responses,
test_the_route_reads_every_name_the_hook_sends and
test_a_checkpoint_holds_a_rule_once_and_books_it_as_surfaced_either_way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Revert the deliberate break: Grimoire tools left alone, shapes_seen named, checkpoint capped
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m58s
CI & Build / integration (push) Successful in 2m36s
CI & Build / Build & push image (push) Skipped
af30f46bee
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hook leaves a Grimoire tool before it reads the cached tool list, so the
right check is that no /moment ask is made; the test expected the list fetch.
Caught by CI on the reviewed tree (run 11237).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): prompt filter, shared rule ledger and reply-shape guards run the hooks
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m19s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / integration (push) Successful in 2m33s
CI & Build / Build & push image (push) Successful in 18s
ea30e0bd75
- test_prompt_boundary_filter: the prompt hook runs on a client-written turn
  and sends nothing, and on a typed one and asks; was "the filter call sits
  above the curl line" in the source.
- test_rule_usage_wiring: the write arm runs and is told it named rule 33,
  then the tool arm in the same session must send 33 as already named; was
  three string searches of each script for the ledger's path.
- test_reply_shape_turn: the hook half of the shape-ledger contract is the
  runtime test already there; the remaining test checks the route half from
  the route's AST.
- test_contract_around_the_change: its write-gate guard was a copy of
  test_hook_never_returns_a_permission_decision, which now checks the same
  two things.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): DELIBERATE BREAK, client turns retrieved, tool arm keeps its own rule ledger, route reads shape_seen
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 2m4s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / integration (push) Canceled after 2m43s
1c6c874257
Reverted by the next commit. CI must go red on
test_the_hook_spends_no_request_on_a_client_written_turn[client-written],
test_the_two_pre_tool_arms_share_one_session_rule_ledger and
test_the_route_reads_the_shape_ledger_the_hook_sends_and_returns_its_keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Revert the deliberate break: client turns skipped, one shared rule ledger, route reads shapes_seen
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 18s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m20s
CI & Build / integration (push) Successful in 2m23s
CI & Build / Build & push image (push) Successful in 19s
1d3d72d2d4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): area groups, first pass: one file folded in, three readout checks merged, two copies removed
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 2m23s
CI & Build / integration (push) Successful in 2m25s
CI & Build / Build & push image (push) Successful in 19s
094089e374
- test_mcp_tool_tasks_kind.py is folded into test_mcp_tool_tasks.py, the
  tool's own file: the two "kind passes through" cases are one table, the two
  list-filter cases one table; the minted_kind refusals move to the service's
  kind tests (test_services_notes_task_kind.py).
- A fresh install reads as empty, not failed: three database tests each ran
  retrieval_summary on an empty install and checked one block
  (usage, judged, system_usage). One test now checks all three.
- test_reply_shapes::test_the_tool_is_registered_as_a_read: everything it
  checked, test_moments::test_the_tools_are_registered_and_classified checks.
- test_shape_ledger::test_classify_and_list_are_mounted_as_mcp_tools: every
  classified tool name must be a registered tool
  (test_mcp_auth::test_every_registered_tool_is_classified_exactly_once).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): the write-path sync-once check kept once, in the hook's own file
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m22s
CI & Build / integration (push) Successful in 2m50s
CI & Build / Build & push image (push) Successful in 17s
4caa7bae4b
test_ledger_references_not_silence::test_the_sync_class_still_shows_only_once
checked a subset of test_write_path_trigger::test_sync_dedup_silences_a_sync_nudge_already_shown
(sync_note_ids empty, the id absent from the context); the covering test also
checks the semantic arm excludes it. Its reasoning (why the sync nudge is the
one class shown only once) moves into the covering test's docstring. The
helper's now-unused sync_exclude parameter goes with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(8249): DELIBERATE BREAK, plan minted, kind filter sent as "", empty judged block, sync ledger ignored
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Failing after 2m4s
CI & Build / integration (push) Failing after 2m44s
CI & Build / Build & push image (push) Skipped
5e4fc3dccf
Revert the deliberate break: plan refused, kind filter None, empty judged block, sync ledger read
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Build & push image (push) Successful in 18s
CI & Build / Python tests (push) Successful in 2m20s
CI & Build / integration (push) Successful in 2m24s
fd1974bc91
test: the claims hook runner skips through need_tools rather than its own which-loop
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m19s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / integration (push) Canceled after 2m21s
3ad7d93386
_run_hook in test_task_claims.py repeated the shutil.which -> pytest.skip
guard that tests.helpers.need_tools exists to hold once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(7716): the reply shape rides after the top two rule lines, so a compaction cannot push it out
CI & Build / Python lint (push) Successful in 1s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m28s
CI & Build / integration (push) Successful in 2m23s
CI & Build / Build & push image (push) Successful in 25s
a3c4cc5921
A compaction sweeps the rule ledger as well as the shape ledger. On the
next prompt every rule the prompt arm reaches and every rule mounted on
reply.report comes back as a first mention with its statement (about 750
characters each), and the route placed all of them ahead of the shape. Six
fill the 4,500-character default budget, so the 2,343-character core was
left out on exactly the turn it is meant to return in full. Seen in a real
session: after 9 of 10 compactions the first prompt payload carried no
reply shape at all.

The prompt payload is now ordered as milestone 639 designed it: the first
two rule lines, the reply shape, the remaining rule lines, the reply's
lessons, the carried note, the records menu. Rules that do not fit stay off
the ledger and arrive on a later call.

The lesson-placement test now pins the lesson after the shape (a lesson
binds nothing; the shape is what the reply is written to). New test: six
full-length rule lines and the real core at the default budget; the shape
is kept and the later rules wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(7716): DELIBERATE BREAK, every rule line ahead of the reply shape again
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Failing after 2m15s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / integration (push) Canceled after 1m53s
c921f284d8
Revert the deliberate break: the reply shape after the top two rule lines
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / integration (push) Successful in 2m21s
CI & Build / Python tests (push) Successful in 2m34s
CI & Build / Build & push image (push) Successful in 21s
9de0e80531
bvandeusen merged commit fca43e71ea into main 2026-12-02 13:09:44 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bvandeusen/FabledGrimoire#239