feat(7728): a rule declares its enforcement and salience
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Failing after 21s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / integration (push) Successful in 2m2s
CI & Build / Build & push image (push) Skipped

A rule now carries what it does when it arrives, declared by its author
rather than guessed from a score: enforce (the act is checked), hold (the
reply or act waits for one read) or inform (a line beside the work, the
default). And a salience, high, normal or low, for ranking among rules of
the same enforcement at a crowded moment. A preference is always inform.

Migration 0128 adds both with CHECKs. Every door carries them: the
service, the MCP create and update tools, REST, backup and restore, and
the rule editor, which also marks holding and enforced rules in the list.
Unknown values are refused rather than mapped. Nothing reads them yet
beyond the record; the ordering function and the lifecycle come next in
this step, and step 5 decides who holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 18:05:45 -05:00
co-authored by Claude Opus 5.5
parent da7c43aa8a
commit 61077752b9
12 changed files with 402 additions and 10 deletions
+10
View File
@@ -959,6 +959,7 @@ def _rule_rows(rows) -> list[dict]:
"title": r.title, "statement": r.statement, "why": r.why,
"how_to_apply": r.how_to_apply, "order_index": r.order_index,
"when_to_apply": r.when_to_apply, "kind": r.kind,
"enforcement": r.enforcement, "salience": r.salience,
"verify_with": r.verify_with, "expires_when": r.expires_when,
"verified_at": r.verified_at.isoformat() if r.verified_at else None,
"arose_from_id": r.arose_from_id,
@@ -1717,6 +1718,15 @@ def _build_rule(row: dict, maps: _Maps) -> Rule | None:
# way would restore an old backup with things that had always bound
# quietly not binding.
kind=row.get("kind") or "rule",
# An archive from before these columns restores every rule as it
# behaved then: a line beside the work, at normal rank. A preference
# is always `inform`, whatever the archive says, since the CHECK would
# refuse anything else and take the whole restore down with it.
enforcement=(
"inform" if (row.get("kind") or "rule") == "preference"
else (row.get("enforcement") if row.get("enforcement") in ("enforce", "hold", "inform") else "inform")
),
salience=row.get("salience") if row.get("salience") in ("high", "normal", "low") else "normal",
verify_with=row.get("verify_with") or None,
expires_when=row.get("expires_when") or None,
# Restored as-is, NOT reset to null. `verified_at` records when someone