feat(8141): a rule holding the finished reply is recorded as a gate stop too
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Failing after 1m49s
CI & Build / integration (push) Successful in 2m4s
CI & Build / Build & push image (push) Skipped

The end-of-turn reply hold was the one gate the gate_stops table left out.
The server applies the per-session cap before anything holds and the Stop
hook blocks on every reason it is given, so the hook reports each held rule
after blocking, as the tool-call gates do: gate `reply`, tool `reply`, and
where the rule was reached (`rule_at`, new beside `rule_ids` in the
/reply-rules answer: the moment it is mounted on, or `reply_rule` for the
backstop). A section hold names no rule and stays counted by report_check.
Opening the rule clears the stop, and rule_misfired marks it, unchanged.

The readout, the telemetry docstring and the Settings panel name the new gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 14:32:46 -05:00
co-authored by Claude Opus 5.5
parent 9b781d57de
commit 82ffd9a235
11 changed files with 85 additions and 18 deletions
+3 -2
View File
@@ -540,8 +540,9 @@ async def retrieval_telemetry(
`gates` — every time a Grimoire gate stood in front of a tool call, from
`gate_stops`, as the plugin hook that made the stop reported it. In
`by_gate`, for each of `enforce` and `hold` (a moment rule's
enforcement), `checkpoint` (the act checkpoint on a command) and
`fence` (the project fence asking the operator), it gives:
enforcement), `checkpoint` (the act checkpoint on a command), `fence`
(the project fence asking the operator) and `reply` (a rule holding the
finished reply for one read), it gives:
- `stops`: calls denied or put to the operator;
- `cleared`: stops the session cleared by opening the rule, which is how
a hold is meant to clear;
+5 -3
View File
@@ -11,7 +11,8 @@ ENFORCE = "enforce" # a moment rule set to enforce: refused every time
HOLD = "hold" # a moment rule set to hold: one read before the act
CHECKPOINT = "checkpoint" # the act checkpoint on a command (tool-rules)
FENCE = "fence" # the project fence: the operator is asked
GATES = (ENFORCE, HOLD, CHECKPOINT, FENCE)
REPLY = "reply" # a rule holding the finished reply for one read
GATES = (ENFORCE, HOLD, CHECKPOINT, FENCE, REPLY)
# What the hook did with it.
STOPPED = "stopped" # the call was denied, the reason shown instead
@@ -23,8 +24,9 @@ OUTCOMES = (STOPPED, LET_THROUGH, ASKED)
class GateStop(Base):
"""One time a Grimoire gate stood in front of a tool call.
WHY IT EXISTS. A rule set to enforce or hold, the act checkpoint and the
project fence are the only places Grimoire stops work rather than
WHY IT EXISTS. A rule set to enforce or hold, the act checkpoint, the
project fence and the hold on a finished reply (the Stop hook, `tool` =
"reply") are the only places Grimoire stops work rather than
commenting on it, and a stop that fires at the wrong moment costs a
round trip every time. Whether the plugin actually stops a call is
decided client-side (the per-rule and per-session caps in
+4 -1
View File
@@ -624,7 +624,9 @@ async def reply_rules():
holds once, and the per-session cap counts these).
Returns `reason` — the words the hook blocks with, empty when nothing
holds — plus `rule_ids` for the hook's ledger, `moments` reached and
holds — plus `rule_ids` for the hook's ledger, `rule_at` beside them
(where each was reached, which the hook reports with the hold),
`moments` reached and
`report_check` (the recorded outcome, or "" when nothing was checked).
"""
data = await request.get_json(silent=True) or {}
@@ -656,6 +658,7 @@ async def reply_rules():
return jsonify({
"reason": "\n\n".join(reasons),
"rule_ids": held.get("rule_ids", []),
"rule_at": held.get("rule_at", []),
"moments": held.get("moments", []),
"report_check": checked.get("outcome", ""),
})
+5 -1
View File
@@ -406,7 +406,7 @@ async def reply_hold(
holds a session once. Past the act checkpoint's per-session cap nothing
holds — a mis-set bar degrades to a quiet session, never a stuck one.
Returns {} or {"reason", "rule_ids", "moments"}. Fails open to {}.
Returns {} or {"reason", "rule_ids", "rule_at", "moments"}. Fails open to {}.
"""
from grimoire.services import plugin_context as pc
from grimoire.services import rule_usage, rulebooks
@@ -470,6 +470,10 @@ async def reply_hold(
return {
"reason": reply_hold_reason(out),
"rule_ids": [item["rule_id"] for item in out],
# Where each held rule was reached, beside `rule_ids`: the moment
# it is mounted on, or the reply arm that matched it. The hook
# reports each hold with it (`gate_stops`).
"rule_at": [item.get("moment") or rp.REPLY_RULE.source for item in out],
"moments": names,
}
except Exception: # noqa: BLE001 - a recall aid never stops a session by failing