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

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>
This commit is contained in:
2026-11-22 21:05:02 -05:00
co-authored by Claude Opus 5.5
parent 05831149b8
commit 4a65f5ddfd
13 changed files with 771 additions and 19 deletions
+18
View File
@@ -365,3 +365,21 @@ def _default_payload_budget(request):
with patch.object(hook_payload, "payload_budget",
AsyncMock(return_value=hook_payload.DEFAULT_BUDGET)):
yield
@pytest.fixture(autouse=True)
def _ungated_doors(request):
"""Leave the plugin doors' cue-swap gate off unless a test asks for it.
The gate reads the user's earlier cues from `retrieval_logs`, which a
test that is about something else has not written, so with it on every
door would abstain. A test of the gate marks itself `cue_gate`, or calls
`cue_gate` directly.
"""
if request.node.get_closest_marker("cue_gate"):
yield
return
from grimoire.services import plugin_context
with patch.object(plugin_context, "_gate_for", AsyncMock(return_value=None)):
yield