Milestone 639 steps 3–4: one assembler per hook under a budget; prior art and preferences behind a cue-swap gate #225

Merged
bvandeusen merged 4 commits from dev into main 2026-11-23 00:10:35 -05:00
Owner

Steps 3 and 4 of milestone 639.

Step 3 (#7729) — one assembler per hook: rule statements first, then the reply shape, then records, under a budget. Plugin 2026.11.23.0004.

Step 4 (#7730) — prior art and preference lines found by resemblance speak only when the cue's best match beats all but kb_cue_gate_rate% (default 10) of the user's recent cues on that surface and project; at most two lines; silence until 20 cues are seen. Harness-written turns are skipped server-side. Settings gains a rate field and a per-surface readout (GET /api/retrieval/gate). Migration 0131 adds gate_bar and gate_kept to retrieval_logs.

CI green on 6b4c24e (run 10772).

🤖 Generated with Claude Code

Steps 3 and 4 of milestone 639. **Step 3 (#7729)** — one assembler per hook: rule statements first, then the reply shape, then records, under a budget. Plugin 2026.11.23.0004. **Step 4 (#7730)** — prior art and preference lines found by resemblance speak only when the cue's best match beats all but `kb_cue_gate_rate`% (default 10) of the user's recent cues on that surface and project; at most two lines; silence until 20 cues are seen. Harness-written turns are skipped server-side. Settings gains a rate field and a per-surface readout (`GET /api/retrieval/gate`). Migration 0131 adds `gate_bar` and `gate_kept` to `retrieval_logs`. CI green on 6b4c24e (run 10772). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bvandeusen added 4 commits 2026-11-23 00:10:31 -05:00
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
a16dee4080
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>
fix(7729): a rule with no statement keeps its full line, and the delivery test flushes like a door
CI & Build / TypeScript typecheck (push) Successful in 38s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 1m56s
CI & Build / integration (push) Successful in 2m8s
CI & Build / Build & push image (push) Successful in 33s
05831149b8
A first mention whose rule had an empty statement fell through to the
reference form and lost its "may apply <where>" — for a trigger-fired rule,
the very clause that says which trigger fired. The full form now renders
with or without a statement. The integration helper flushes the request
buffer, as a door does once its payload is fitted. using-grimoire trimmed
back to its 350-line budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(7730): prior art and preferences speak only past a cue-swap gate, at most two lines
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Python tests (push) Failing after 1m35s
CI & Build / integration (push) Successful in 2m1s
CI & Build / Build & push image (push) Skipped
4a65f5ddfd
A record or preference found by resemblance alone is shown only when the
message's score beats all but a set share (default 10%) of the user's own
recent cues on that surface and project. The comparison set is the
best_available_score already logged per call, so the bar rises with the
store by construction and a fixed floor no longer decides. Too few cues to
judge by is silence; the searches still run and calibrate the gate.

- cue_gate: conformal bar, per (user, surface, project) with a user-wide
  fallback, cached five minutes; readout for Settings.
- Notes arms (auto_inject, write_path) abstain unless the top line passes,
  show at most two lines, and hold slots to the same bar and cap.
- Rule arms hold preference lines to the gate; rules are not gated.
- retrieval_logs gains gate_bar and gate_kept (migration 0131).
- Turns the harness wrote are refused server-side as well as in the plugin.
- Settings: the rate field and a per-surface readout of bar and how often
  each surface spoke; GET /api/retrieval/gate.
- Replay test: on unrelated cues a fixed bar tuned to 5% on a 32-record
  store fires ~97% on 2,048 records; the gate stays near 10% at both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test(7730): the retrieval route inventory includes the gate readout
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 37s
CI & Build / Python tests (push) Successful in 2m9s
CI & Build / integration (push) Successful in 2m21s
CI & Build / Build & push image (push) Successful in 42s
6b4c24e336
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bvandeusen merged commit 8798b5c59a into main 2026-11-23 00:10:35 -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#225