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:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "grimoire",
|
||||
"description": "Grimoire for Claude Code: connects the grimoire MCP server, adds the hooks that deliver live project state and relevant records at the right moment, ships the shared client-neutral Grimoire skills (using-grimoire, writing-plans, reporting-back, systematic-debugging, verification, brainstorming, reusing-code, shape-accounting, family-canon), and syncs your saved Grimoire Processes as skills (/grimoire:sync).",
|
||||
"version": "2026.11.23.1802",
|
||||
"version": "2026.11.23.2051",
|
||||
"author": {
|
||||
"name": "Bryan Van Deusen"
|
||||
},
|
||||
|
||||
@@ -191,6 +191,7 @@ while IFS= read -r rel_path; do
|
||||
reached=1
|
||||
body=$(curl -fsS --max-time 8 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/prior-art?path=${path_enc}&code=${code_enc}${repo_q}${exclude_q}${sync_exclude_q}${derive_exclude_q}${shapes_q}" 2>/dev/null) || { body=""; reached=0; }
|
||||
# A call that was owed and didn't come back is said, once per outage —
|
||||
# shared marker with the pre-write hook, so one outage is one
|
||||
|
||||
@@ -149,6 +149,7 @@ fi
|
||||
|
||||
body=$(curl -fsS --max-time 5 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/retrieve?q=${q_enc}${ctx_q}${repo_q}${exclude_q}${carry_q}" 2>/dev/null) || exit 0
|
||||
[ -n "$body" ] || exit 0
|
||||
[ -n "$carry_q" ] && rm -f "$carry_file" 2>/dev/null
|
||||
|
||||
@@ -41,6 +41,7 @@ task_id=$(printf '%s' "$task_id" | tr -cd '0-9')
|
||||
sid_enc=$(printf '%s' "$session_id" | grimoire_urlenc) || exit 0
|
||||
curl -fsS --max-time 4 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/claim-session?task_id=${task_id}&session_id=${sid_enc}" \
|
||||
>/dev/null 2>&1 || true
|
||||
exit 0
|
||||
|
||||
@@ -868,6 +868,12 @@ grimoire_config() {
|
||||
# garbage Bearer token and 401. Treat it as unset.
|
||||
case "$url" in *'${'*) url="" ;; esac
|
||||
case "$token" in *'${'*) token="" ;; esac
|
||||
# Sent as `X-Grimoire-Plugin` on every request. The server keeps it on each
|
||||
# rule line it delivers, and counts a line toward a rule's open rate only
|
||||
# when it is there: a plugin that sends it also reports every open, so a
|
||||
# line without it is one whose opens were never going to be heard.
|
||||
plugin_version=$(sed -n 's/^ *"version": *"\([^"]*\)".*/\1/p' \
|
||||
"$(dirname "${BASH_SOURCE[0]}")/../.claude-plugin/plugin.json" 2>/dev/null | head -n 1)
|
||||
[ -n "$url" ] && [ -n "$token" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ case "$stamp" in ''|*[!0-9]*) stamp=0 ;; esac
|
||||
if [ "$now" -eq 0 ] || [ $((now - stamp)) -gt 300 ]; then
|
||||
listed=$(curl -fsS --max-time 3 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/moment-tools" 2>/dev/null) || listed=""
|
||||
{
|
||||
printf '%s\n' "$now"
|
||||
@@ -141,6 +142,7 @@ query="${repo_q}${ledger_q}"
|
||||
query=${query#&}
|
||||
body=$(printf '%s' "$event" | curl -fsS --max-time 3 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @- \
|
||||
"${url%/}/api/plugin/moment${query:+?$query}" 2>/dev/null) || exit 0
|
||||
|
||||
@@ -251,6 +251,7 @@ fi
|
||||
reached=1
|
||||
body=$(curl -fsS --max-time 5 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/prior-art?path=${path_enc}&code=${code_enc}${repo_q}${exclude_q}${sync_exclude_q}${derive_exclude_q}${rule_exclude_q}${rulings_q}${shapes_q}" 2>/dev/null) || { body=""; reached=0; }
|
||||
unreached_context=""
|
||||
if [ "$reached" = 1 ]; then
|
||||
|
||||
@@ -228,7 +228,7 @@ while IFS= read -r check; do
|
||||
act=${check#*$'\t'}
|
||||
q="target_${scope}&act=$(printf '%s' "$act" | grimoire_urlenc)"
|
||||
fi
|
||||
resp=$(curl -fsS --max-time 4 -H "Authorization: Bearer ${token}" "${base}${q}" 2>/dev/null) || {
|
||||
resp=$(curl -fsS --max-time 4 -H "Authorization: Bearer ${token}" -H "X-Grimoire-Plugin: ${plugin_version:-}" "${base}${q}" 2>/dev/null) || {
|
||||
fence_unreached
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ scope=$(grimoire_scope_query "${event_cwd:-${CLAUDE_PROJECT_DIR:-$PWD}}")
|
||||
body=$(printf '{"rule_id":%s,"session_id":"%s","acts":[%s]}' "$rule_id" "$sid_esc" "$acts" \
|
||||
| curl -fsS --max-time 3 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @- \
|
||||
"${url%/}/api/plugin/rule-opened${scope:+?$scope}" 2>/dev/null) || exit 0
|
||||
|
||||
@@ -107,6 +107,7 @@ query=${query#&}
|
||||
|
||||
answer=$(printf '{"reply":"%s"%s}' "$reply_esc" "$closing" | curl -fsS --max-time 6 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @- \
|
||||
"${url%/}/api/plugin/reply-rules${query:+?$query}" 2>/dev/null) || exit 0
|
||||
|
||||
@@ -192,6 +192,7 @@ if [ -n "$url" ] && [ -n "$token" ] && command -v curl >/dev/null 2>&1; then
|
||||
local resp meta
|
||||
resp=$(curl -sS --max-time "$1" -w '\n%{http_code} %{time_total}' \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/context${q}" 2>/dev/null)
|
||||
ctx_rc=$?
|
||||
meta=${resp##*$'\n'}
|
||||
|
||||
@@ -49,6 +49,7 @@ grimoire_config || exit 0
|
||||
sid_enc=$(printf '%s' "$session_id" | grimoire_urlenc) || exit 0
|
||||
curl -fsS --max-time 4 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/release-session?session_id=${sid_enc}" \
|
||||
>/dev/null 2>&1 || true
|
||||
exit 0
|
||||
|
||||
@@ -95,6 +95,7 @@ if [ -s "$asked_file" ]; then
|
||||
asked_enc=$(printf '%s' "$asked" | grimoire_urlenc) || asked_enc=""
|
||||
if [ -n "$asked_enc" ] && curl -fsS --max-time 4 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/shape-check?phase=after&written=${asked_enc}${scope_q}" \
|
||||
>/dev/null 2>&1; then
|
||||
rm -f "$asked_file" 2>/dev/null || true
|
||||
@@ -106,6 +107,7 @@ written=$(_unique "$ledger")
|
||||
written_enc=$(printf '%s' "$written" | grimoire_urlenc) || exit 0
|
||||
answer=$(curl -fsS --max-time 4 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/shape-check?phase=check&written=${written_enc}${scope_q}" 2>/dev/null) \
|
||||
|| exit 0 # unreachable: keep the ledger
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ grimoire_config || exit 0
|
||||
|
||||
body=$(curl -fsS --max-time 8 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/processes" 2>/dev/null) || exit 0
|
||||
[ -n "$body" ] || exit 0
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ fi
|
||||
# than silence. See the header.
|
||||
body=$(curl -fsS --max-time 5 \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "X-Grimoire-Plugin: ${plugin_version:-}" \
|
||||
"${url%/}/api/plugin/tool-rules?tool=${tool_enc}&command=${cmd_enc}${repo_q}${where_q}${rule_exclude_q}${rulings_q}" 2>/dev/null) || exit 0
|
||||
|
||||
body_flat=$(printf '%s' "$body" | grimoire_json_flat)
|
||||
|
||||
Reference in New Issue
Block a user