feat(7733): adherence is measured per rule and per moment, and shown
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / TypeScript typecheck (push) Successful in 36s
CI & Build / Python tests (push) Failing after 1m48s
CI & Build / integration (push) Successful in 2m26s
CI & Build / Build & push image (push) Skipped

A rule is in force at a moment of a session when it was delivered there.
Each (session, rule, place) now carries at most one verdict (rule_adherence,
migration 0134): followed, departed, broken or not applicable, with where it
came from:

- an enforce rule refusing the act: followed, recorded by the moment arm, and
  never replaced;
- the session's own rule_outcome (applied, departed) and rule_misfired calls,
  which the plugin's outcome hook now also posts with the session id
  (/api/plugin/rule-verdict) onto the delivery being answered;
- a transcript review: adherence_to_judge lists what has no verdict yet, by
  session, and judge_adherence records verdicts with their evidence.

rule_adherence (MCP) and /api/retrieval/adherence give the readout: sessions
in force, opened and each verdict per rule and per place. Settings > Moments
shows it in a "Were they followed" panel, beside each moment's delivered and
opened counts, and per rule inside each moment.

Verdicts are pruned with their deliveries and left out of backups like them.
Plugin 2026.11.23.2227.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 17:28:23 -05:00
co-authored by Claude Opus 5.5
parent e70b2c2c00
commit b4bdd7798c
25 changed files with 1114 additions and 25 deletions
+27
View File
@@ -227,3 +227,30 @@ def test_the_hook_and_the_route_agree_on_the_body():
assert f'"{field}"' in src and f'"{field}"' in route
assert "'.context'" in src
assert '"context"' in inspect.getsource(judgments_svc.opened_after)
def test_an_outcome_is_sent_as_a_verdict_with_the_session(sandbox):
tmp, env = sandbox
_run("grimoire_record_outcome.sh",
{"session_id": "s1", "tool_name": "mcp__grimoire__rule_outcome",
"tool_input": {"rule_id": 11, "outcome": "departed", "why": 'the operator said "ship"'}},
env)
assert json.loads((tmp / "curl.body").read_text()) == {
"rule_id": 11, "session_id": "s1", "outcome": "departed", "moment": "",
"why": 'the operator said "ship"',
}
assert "/api/plugin/rule-verdict" in (tmp / "curl.log").read_text()
assert (tmp / "grimoire-priorart" / "s1.acted.ids").exists()
def test_a_misfire_is_sent_as_a_verdict_at_the_moment_it_names(sandbox):
tmp, env = sandbox
_run("grimoire_record_outcome.sh",
{"session_id": "s1", "tool_name": "mcp__grimoire__rule_misfired",
"tool_input": {"rule_id": 4, "moment": "work.deliver", "why": "a redeploy, not a release"}},
env)
assert json.loads((tmp / "curl.body").read_text()) == {
"rule_id": 4, "session_id": "s1", "outcome": "", "moment": "work.deliver",
"why": "a redeploy, not a release",
}