feat(rules): project rule + topic suppressions
Lets a project mute individual rules or whole topics from rulebooks it subscribes to, without unsubscribing the rulebook. Two new association tables (migration 0060), 4 MCP tools (suppress/unsuppress × rule/topic), 4 REST endpoints, and an inline "× skip" affordance plus collapsed "Suppressed (N)" section in the project's Rules tab. get_applicable_rules now emits suppressed_rules and suppressed_topics (detail objects with rulebook/topic context, not just IDs) so the UI can render the suppressed list without a follow-up lookup. The main rules projection grew topic_id and rulebook_id columns for the per-row suppress affordance. Project deletion cascades the suppression rows via hard DELETE — they are pure associations with no soft-delete column, and restoring a deleted project should start fresh, not inherit stale mutes. Project-scoped rules (Rule.project_id) are deliberately not suppressible — delete them with delete_rule instead. Implements plan-task #187. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,8 @@ def test_service_signatures_require_user_id():
|
||||
"list_rules", "list_always_on_rules",
|
||||
"get_rule", "update_rule", "delete_rule",
|
||||
"subscribe_project", "unsubscribe_project", "get_applicable_rules",
|
||||
"suppress_rule_for_project", "unsuppress_rule_for_project",
|
||||
"suppress_topic_for_project", "unsuppress_topic_for_project",
|
||||
):
|
||||
sig = inspect.signature(getattr(svc, fn_name))
|
||||
assert "user_id" in sig.parameters, f"{fn_name} missing user_id param"
|
||||
@@ -67,6 +69,29 @@ def test_create_project_rule_route_exists():
|
||||
assert callable(getattr(rb_routes, "create_project_rule"))
|
||||
|
||||
|
||||
def test_suppression_route_handlers_exist():
|
||||
"""The 4 suppression endpoint handlers are registered as Python callables."""
|
||||
from fabledassistant.routes import rulebooks as rb_routes
|
||||
for name in (
|
||||
"suppress_project_rule", "unsuppress_project_rule",
|
||||
"suppress_project_topic", "unsuppress_project_topic",
|
||||
):
|
||||
assert callable(getattr(rb_routes, name)), f"missing route handler: {name}"
|
||||
|
||||
|
||||
def test_suppression_association_tables_declared():
|
||||
"""Migration 0060 created two new association tables; the models module
|
||||
must declare matching Table() objects so the rest of the service layer
|
||||
can reference them via .c.<column>."""
|
||||
from fabledassistant.models import rulebook as rb_models
|
||||
for tbl_name in ("project_rule_suppressions", "project_topic_suppressions"):
|
||||
tbl = getattr(rb_models, tbl_name, None)
|
||||
assert tbl is not None, f"models.rulebook missing {tbl_name}"
|
||||
cols = {c.name for c in tbl.columns}
|
||||
assert "project_id" in cols
|
||||
assert "rule_id" in cols or "topic_id" in cols
|
||||
|
||||
|
||||
def test_rulebook_model_carries_always_on():
|
||||
"""Migration 0058 added rulebooks.always_on — verify the model declares it."""
|
||||
from fabledassistant.models.rulebook import Rulebook
|
||||
|
||||
Reference in New Issue
Block a user