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:
@@ -1713,6 +1713,10 @@ class MomentIO:
|
||||
"""As on `RuleIO`."""
|
||||
retired: Callable[..., Any] | None = None
|
||||
"""As on `RuleIO`."""
|
||||
record_refusal: Callable[..., Any] | None = None
|
||||
"""`rule_adherence.note_refused(user_id, [(rule_id, at, where)])`: an
|
||||
`enforce` rule refused this act, so it was kept there. None where the door
|
||||
keeps no deliveries."""
|
||||
|
||||
|
||||
def _reached_by(hit: dict) -> str:
|
||||
@@ -1771,11 +1775,18 @@ async def run_moment_arm(
|
||||
# rule about pushing to `main` mounted on work.deliver would hold
|
||||
# every push to `dev`). Reached by the mount alone, it is a line.
|
||||
triggered = board.triggered if board is not None else set()
|
||||
decision = act_decision(
|
||||
[(rule, at, where) for rule, at, where, spec in cands
|
||||
if spec == rule_order.BY_TRIGGER or rule.id not in triggered],
|
||||
held=moment.held,
|
||||
)
|
||||
acting = [(rule, at, where) for rule, at, where, spec in cands
|
||||
if spec == rule_order.BY_TRIGGER or rule.id not in triggered]
|
||||
decision = act_decision(acting, held=moment.held)
|
||||
if decision.get("kind") == "enforce" and io.record_refusal is not None:
|
||||
# A refusal is the one adherence verdict known at the act itself.
|
||||
refused = set(decision["rule_ids"])
|
||||
try:
|
||||
io.record_refusal(moment.user_id, [
|
||||
(rule.id, at, where) for rule, at, where in acting if rule.id in refused
|
||||
])
|
||||
except Exception: # noqa: BLE001 - observation never breaks the observed
|
||||
_telemetry_failed(MOMENT_RULE_SOURCE)
|
||||
gone = await _retired(io, moment, [rule for rule, _a, _w, _s in cands])
|
||||
if gone:
|
||||
cands = [c for c in cands if c[0].id not in gone]
|
||||
|
||||
Reference in New Issue
Block a user