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
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:
@@ -133,6 +133,22 @@ def test_an_open_sends_the_window_and_prints_the_answer(sandbox):
|
||||
assert (tmp / "grimoire-priorart" / "s1.opened.ids").read_text().startswith("11\t")
|
||||
|
||||
|
||||
def test_every_request_names_the_plugin_version_that_sent_it(sandbox):
|
||||
# The server counts a delivery toward a rule's open rate only when its
|
||||
# plugin sent its version, since that is the plugin that reports opens.
|
||||
tmp, env = sandbox
|
||||
version = json.loads((ROOT / "plugin" / ".claude-plugin" / "plugin.json").read_text())["version"]
|
||||
_run("grimoire_moment.sh", {"session_id": "s1", "tool_name": "Bash",
|
||||
"tool_input": {"command": "ls"}}, env,
|
||||
FAKE_CURL_REPLY='{"tools":["bash"]}')
|
||||
_run("grimoire_record_opened.sh",
|
||||
{"session_id": "s1", "tool_name": "mcp__grimoire__get_rule",
|
||||
"tool_input": {"rule_id": 11}}, env)
|
||||
calls = (tmp / "curl.log").read_text().splitlines()
|
||||
assert len(calls) >= 2
|
||||
assert all(f"X-Grimoire-Plugin: {version}" in call for call in calls), calls
|
||||
|
||||
|
||||
def test_the_window_is_the_last_three_acts(sandbox):
|
||||
tmp, env = sandbox
|
||||
ledger = tmp / "grimoire-moment"
|
||||
|
||||
Reference in New Issue
Block a user