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
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:
@@ -23,6 +23,7 @@ FENCE = HOOKS / "grimoire_project_fence.sh"
|
||||
FENCE_RAN = HOOKS / "grimoire_fence_ran.sh"
|
||||
STOP = "/api/plugin/gate-stop"
|
||||
RAN = "/api/plugin/gate-ran"
|
||||
REPLY_CHECK = HOOKS / "grimoire_reply_check.sh"
|
||||
TOOLS = {"/api/plugin/moment-tools": b'{"tools":["bash"]}'}
|
||||
|
||||
|
||||
@@ -194,3 +195,41 @@ def test_the_after_call_hook_is_registered_only_after_calls_and_on_the_fenced_to
|
||||
for h in m["hooks"] if "grimoire_project_fence.sh" in h["command"]]
|
||||
assert matchers("PreToolUse") == []
|
||||
assert matchers("PostToolUse") == fence_pre
|
||||
|
||||
|
||||
# ── the reply hold ───────────────────────────────────────────────────────
|
||||
|
||||
def _transcript(tmp_path, reply):
|
||||
lines = [
|
||||
{"type": "user", "message": {"role": "user", "content": "is it finished?"}},
|
||||
{"type": "assistant", "message": {"content": [{"type": "text", "text": reply}]}},
|
||||
]
|
||||
path = tmp_path / "t.jsonl"
|
||||
path.write_text("\n".join(json.dumps(x, separators=(",", ":")) for x in lines) + "\n")
|
||||
return path
|
||||
|
||||
|
||||
def _stop(tmp_path, transcript):
|
||||
return {"session_id": "s-gate", "transcript_path": str(transcript), "cwd": str(tmp_path),
|
||||
"hook_event_name": "Stop", "stop_hook_active": False}
|
||||
|
||||
|
||||
def test_each_rule_that_holds_a_reply_is_reported_with_where_it_was_reached(tmp_path):
|
||||
held = json.dumps({"reason": "Held for one read.", "rule_ids": [11, 40],
|
||||
"rule_at": ["reply.report", "reply_rule"],
|
||||
"moments": ["reply.report"]}).encode()
|
||||
with http_sink(by_path={"/api/plugin/reply-rules": held}) as (port, seen):
|
||||
out = _run(REPLY_CHECK, tmp_path, port, _stop(tmp_path, _transcript(tmp_path, "All done.")))
|
||||
assert json.loads(out)["decision"] == "block"
|
||||
assert [(s["gate"], s["outcome"], s["tool"], s["rule_id"], s["at"]) for s in _stops(seen)] == [
|
||||
("reply", "stopped", "reply", 11, "reply.report"),
|
||||
("reply", "stopped", "reply", 40, "reply_rule"),
|
||||
]
|
||||
|
||||
|
||||
def test_a_section_hold_names_no_rule_and_reports_no_gate_stop(tmp_path):
|
||||
"""The completion-section check has its own record (`report_check`)."""
|
||||
sections = b'{"reason":"Add the sections.","rule_ids":[],"moments":[],"report_check":"blocked"}'
|
||||
with http_sink(by_path={"/api/plugin/reply-rules": sections}) as (port, seen):
|
||||
_run(REPLY_CHECK, tmp_path, port, _stop(tmp_path, _transcript(tmp_path, "All done.")))
|
||||
assert _stops(seen) == []
|
||||
|
||||
Reference in New Issue
Block a user