"""skill names follow the plugin's name Revision ID: 0124 Revises: 0123 Create Date: 2026-10-22 The plugin is named `grimoire`, so its skills reach a session as `grimoire:` and stored processes as `grimoire-proc-`. A rule mounted on one of those skills, a judgment about that mount, and an install's own action mapping all store the skill's name, and a stored name the harness no longer sends never matches again. This rewrites the plugin's earlier prefixes, `scribe:` and `scribe-proc-`, to the current ones. Cost: three small tables, each one row per mount, judgment or mapping. """ from alembic import op revision = "0124" down_revision = "0123" branch_labels = None depends_on = None _MOMENT_TABLES = ("rule_moments", "rule_moment_judgments", "moment_mappings") def _rename(old: str, new: str) -> None: for table in _MOMENT_TABLES: op.execute( f"UPDATE {table} SET moment = regexp_replace(moment, " f"'^skill\\.{old}(:|-proc-)', 'skill.{new}\\1') " f"WHERE moment ~ '^skill\\.{old}(:|-proc-)'" ) op.execute( f'UPDATE moment_mappings SET "match" = regexp_replace("match", ' f"'skill={old}(:|-proc-)', 'skill={new}\\1', 'g') " f"WHERE \"match\" ~ 'skill={old}(:|-proc-)'" ) def upgrade() -> None: _rename("scribe", "grimoire") def downgrade() -> None: _rename("grimoire", "scribe")