From 4eebe271ed8872fb9cc9f290e3d7c9695ffc068d Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 11 Sep 2026 16:24:38 -0400 Subject: [PATCH] fix(rules): restore system_ids and clear the imports the deletions orphaned (#394) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three defects from the sweep, all caught by ruff. system_ids was REMOVED FROM create_rule AND create_project_rule — a real API regression, not a lint nit. The parameter shared a signature line with tier, so deleting the tier deleted it too, and the tools lost the ability to tag a new rule to an area. Areas are what let a rule reach a project after this milestone, so the one parameter that decides reach went missing from the two tools that create reachable rules. The other two are imports left holding nothing: services/rulebooks.py's module-level datetime and its IntegrityError were used only by functions this milestone deleted, and plugin_context lost four (select, async_session, RulebookTopic, rulebooks_svc) with the preload and _topic_titles. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_011cPyzNnegXHr5iRMzzy5KJ --- src/scribe/mcp/tools/rulebooks.py | 6 +++--- src/scribe/services/plugin_context.py | 4 ---- src/scribe/services/rulebooks.py | 4 ---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/scribe/mcp/tools/rulebooks.py b/src/scribe/mcp/tools/rulebooks.py index 45d0e55..db505fd 100644 --- a/src/scribe/mcp/tools/rulebooks.py +++ b/src/scribe/mcp/tools/rulebooks.py @@ -18,7 +18,7 @@ from scribe.mcp._context import current_user_id from scribe.services import dedup as dedup_svc from scribe.services import rulebooks as rulebooks_svc from scribe.services import trash as trash_svc -from scribe.services.rule_usage import record_rule_pulled, record_rule_surfaced +from scribe.services.rule_usage import record_rule_pulled # ── Rulebook CRUD ─────────────────────────────────────────────────────── @@ -249,7 +249,7 @@ async def create_rule( topic_id: int, title: str, statement: str, when_to_apply: str = "", why: str = "", how_to_apply: str = "", order_index: int = 0, arose_from_id: int = 0, verify_with: str = "", expires_when: str = "", - force: bool = False, + system_ids: list[int] | None = None, force: bool = False, ) -> dict: """Create a new rule in a rulebook (a SHARED rule — keep it general). @@ -415,7 +415,7 @@ async def create_project_rule( project_id: int, statement: str, title: str = "", when_to_apply: str = "", why: str = "", how_to_apply: str = "", order_index: int = 0, arose_from_id: int = 0, verify_with: str = "", expires_when: str = "", - force: bool = False, + system_ids: list[int] | None = None, force: bool = False, ) -> dict: """Create a rule scoped to a single project (no rulebook needed). diff --git a/src/scribe/services/plugin_context.py b/src/scribe/services/plugin_context.py index a01fed0..a6f1b5d 100644 --- a/src/scribe/services/plugin_context.py +++ b/src/scribe/services/plugin_context.py @@ -18,15 +18,11 @@ import logging import re import time -from sqlalchemy import select -from scribe.models import async_session -from scribe.models.rulebook import RulebookTopic from scribe.services import design_systems as design_systems_svc from scribe.services import knowledge as knowledge_svc from scribe.services import notes as notes_svc from scribe.services import projects as projects_svc -from scribe.services import rulebooks as rulebooks_svc from scribe.services import shape_ledger as shape_ledger_svc from scribe.services import snippets as snippets_svc from scribe.services.access import label_shared_items, owner_names_for diff --git a/src/scribe/services/rulebooks.py b/src/scribe/services/rulebooks.py index 5a8c208..e3c6214 100644 --- a/src/scribe/services/rulebooks.py +++ b/src/scribe/services/rulebooks.py @@ -9,7 +9,6 @@ from __future__ import annotations import logging from collections.abc import Iterable -from datetime import datetime from typing import Optional from sqlalchemy import and_, delete as sql_delete, false as sa_false, insert, or_, select @@ -933,9 +932,6 @@ async def delete_rule(rule_id: int, user_id: int) -> None: # ── Subscriptions + get_applicable_rules ─────────────────────────────── -from sqlalchemy.exc import IntegrityError - - async def subscribe_project( project_id: int, rulebook_id: int, user_id: int, ) -> None: