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>
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""rule enforcement and salience — what a rule does when it arrives, and how much it outranks
|
|
|
|
Revision ID: 0128
|
|
Revises: 0127
|
|
Create Date: 2026-11-22
|
|
|
|
Two declared columns on a rule, read by the one function that orders what
|
|
reaches a moment:
|
|
|
|
- `enforcement`: `enforce` (the act itself is checked), `hold` (the reply or act
|
|
waits for one read), `inform` (a line beside the work). Every existing rule
|
|
starts as `inform`; declaring which ones hold is the author's call.
|
|
- `salience`: `high`, `normal`, `low` — the author's ranking among rules of
|
|
the same enforcement.
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "0128"
|
|
down_revision = "0127"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
_ENFORCEMENTS = ("enforce", "hold", "inform")
|
|
_SALIENCES = ("high", "normal", "low")
|
|
|
|
|
|
def _in_list(column: str, values: tuple[str, ...]) -> str:
|
|
return f"{column} IN ({', '.join(repr(v) for v in values)})"
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("rules", sa.Column("enforcement", sa.Text(), nullable=False, server_default="inform"))
|
|
op.add_column("rules", sa.Column("salience", sa.Text(), nullable=False, server_default="normal"))
|
|
op.create_check_constraint("ck_rules_enforcement", "rules", _in_list("enforcement", _ENFORCEMENTS))
|
|
op.create_check_constraint("ck_rules_salience", "rules", _in_list("salience", _SALIENCES))
|
|
# A preference claims no force: it is how work is liked done, not a bar.
|
|
op.create_check_constraint(
|
|
"ck_rules_preference_informs", "rules", "kind <> 'preference' OR enforcement = 'inform'",
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_constraint("ck_rules_preference_informs", "rules", type_="check")
|
|
op.drop_constraint("ck_rules_salience", "rules", type_="check")
|
|
op.drop_constraint("ck_rules_enforcement", "rules", type_="check")
|
|
op.drop_column("rules", "salience")
|
|
op.drop_column("rules", "enforcement")
|