fix(7733): a rule's open rate counts only deliveries whose plugin reports opens
CI & Build / TypeScript typecheck (push) Canceled after 0s
CI & Build / Plugin hooks (push) Canceled after 0s
CI & Build / Python lint (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 0s
CI & Build / integration (push) Canceled after 0s
CI & Build / Build & push image (push) Canceled after 0s

Each rule line a hook delivers now records the plugin version that asked for
it (the X-Grimoire-Plugin header every hook request sends). The open rate
used to order rules, and the delivery history the weighing pass reads,
count only deliveries that carry one.

A plugin before 2026.11.22.2312 never reported an open of a rule a hook had
just named, so every delivery made to such a session read as unopened. The
server shipped delivery recording from dev on 2026-11-22. The plugin ships
from main, and a running session keeps the plugin it started with, so those
sessions kept arriving. They are why opens read about 1 in 600. Existing
rows have no version and drop out of the rate; nothing is deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 15:52:42 -05:00
co-authored by Claude Opus 5.5
parent 3a11c11543
commit e0621713d4
24 changed files with 150 additions and 17 deletions
+2 -2
View File
@@ -85,13 +85,13 @@ def _bound_request_records_only_kept():
spawned = MagicMock()
with patch.object(rule_deliveries, "spawn", spawned), \
patch.object(rule_deliveries, "_insert", lambda rows: rows):
rule_deliveries.bind_session("s-1")
rule_deliveries.bind_session("s-1", "2026.11.23.2100")
rule_deliveries.record(1, None, "pre_tool_rule", [(11, "pre_tool_rule", "full"),
(34, "pre_tool_rule", "full")])
assert not spawned.called, "a bound request's rows wait for the payload"
rule_deliveries.flush({11})
rows = spawned.call_args.args[0]
assert [r["rule_id"] for r in rows] == [11]
assert [(r["rule_id"], r["plugin"]) for r in rows] == [(11, "2026.11.23.2100")]
spawned.reset_mock()
rule_deliveries.flush()
assert not spawned.called, "the buffer is spent once flushed"