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
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:
@@ -165,6 +165,32 @@ async def test_a_rule_with_triggers_stops_only_the_acts_they_match():
|
||||
assert result.decision["kind"] == "hold"
|
||||
|
||||
|
||||
async def test_a_refused_act_is_recorded_as_the_rule_kept_there():
|
||||
# An enforce rule that refuses the act kept the rule at that moment by
|
||||
# construction; a hold, which lets the act go on after a read, does not.
|
||||
refusals = MagicMock()
|
||||
guard = _r(2, enforcement="enforce")
|
||||
note = _r(3, enforcement="hold")
|
||||
deliver = [{"moment": "work.deliver", "tool": "Bash", "match": "git push", "via": "default"}]
|
||||
result = await rp.run_moment_arm(
|
||||
deliver, rp.RuleMoment(user_id=1, query="", project_id=2),
|
||||
io=rp.MomentIO(lookup=AsyncMock(return_value=[(guard, "work.deliver"), (note, "work.deliver")]),
|
||||
record_rule_surfaced=MagicMock(), record_refusal=refusals),
|
||||
board=rt.Board(),
|
||||
)
|
||||
assert result.decision["kind"] == "enforce"
|
||||
refusals.assert_called_once_with(1, [(2, "work.deliver", "at work.deliver, reached by `git push`")])
|
||||
|
||||
refusals.reset_mock()
|
||||
await rp.run_moment_arm(
|
||||
deliver, rp.RuleMoment(user_id=1, query="", project_id=2),
|
||||
io=rp.MomentIO(lookup=AsyncMock(return_value=[(note, "work.deliver")]),
|
||||
record_rule_surfaced=MagicMock(), record_refusal=refusals),
|
||||
board=rt.Board(),
|
||||
)
|
||||
refusals.assert_not_called()
|
||||
|
||||
|
||||
async def test_the_board_lists_every_rule_that_has_a_trigger(monkeypatch):
|
||||
monkeypatch.setattr(rt, "_in_scope", AsyncMock(return_value=[
|
||||
(_r(1), [T("path", "alembic/**", "work.change")]),
|
||||
|
||||
Reference in New Issue
Block a user