feat(rules)!: retire rulebook subscriptions and per-project suppressions (#4052)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / integration (push) Successful in 49s
CI & Build / TypeScript typecheck (push) Successful in 57s
CI & Build / Python tests (push) Failing after 1m3s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / integration (push) Successful in 49s
CI & Build / TypeScript typecheck (push) Successful in 57s
CI & Build / Python tests (push) Failing after 1m3s
CI & Build / Build & push image (push) Skipped
A rule's home is its scope now: a rule in a rulebook topic is global, a rule on a project applies to that project, and retrieval reads that directly (#4074). A subscription had stopped changing anything a session received; a suppression muted rules from a subscription. Operator, 2026-09-15: "we have global and project scoped rules, we don't need the subscriptions now." What goes, whole (rule 22): - Migration 0101 drops project_rulebook_subscriptions, project_rule_suppressions and project_topic_suppressions, and strips subscribe_rulebooks (and 394's leftover exclude_always_on_rulebooks) from stored inception choices. - Service, MCP and REST: subscribe/unsubscribe and the four suppress/unsuppress operations. The Subscribers checklist, the subscribe chips, the skip buttons and the Suppressed section in the rules UI. - Inception asks two questions (design system, seed Systems). create_project and decide_project_inception lose subscribe_rulebooks. - Backup v15 stops exporting the three sections; older archives still restore, the keys simply unread. Trash no longer hard-deletes suppression rows. What changes meaning: - get_applicable_rules is a project's LISTING: its own rules, plus the global rules tagged to an area it works in. Untagged global rules apply everywhere and arrive by retrieval, so they are not listed. A co_surfaces partner on a different project is not dragged in. - list_rules(project_id) lists that project's own rules. - rules_payload drops subscribed_rulebooks and suppressed_*; the handshake's brief form is project_rules alone. - using-scribe's "Where a new rule goes" and inception sections, tool docstrings and docs say global vs project. Plugin 2026.09.15.1620. Milestone 414 step 2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy
This commit is contained in:
@@ -73,7 +73,7 @@ async def test_get_project_enriches_with_milestone_summary():
|
||||
p = fake_project(id=5, title="found")
|
||||
milestone_summary = [{"id": 10, "title": "MS", "status": "active", "total": 3}]
|
||||
applicable_payload = {
|
||||
"rules": [], "truncated": False, "subscribed_rulebooks": [],
|
||||
"rules": [], "truncated": False,
|
||||
}
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
@@ -91,9 +91,10 @@ async def test_get_project_enriches_with_milestone_summary():
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_project_includes_applicable_rules_and_subscribed_rulebooks():
|
||||
async def test_get_project_includes_applicable_rules_and_project_rules():
|
||||
"""The augmented get_project response includes applicable_rules and
|
||||
subscribed_rulebooks pulled from services/rulebooks.get_applicable_rules.
|
||||
project_rules pulled from services/rulebooks.get_applicable_rules, and
|
||||
nothing about subscriptions (milestone 414).
|
||||
"""
|
||||
p = fake_project(id=3, title="Fabled Assistant")
|
||||
milestone_summary = []
|
||||
@@ -105,7 +106,6 @@ async def test_get_project_includes_applicable_rules_and_subscribed_rulebooks():
|
||||
"rulebook_title": "FabledSword family"},
|
||||
],
|
||||
"truncated": False,
|
||||
"subscribed_rulebooks": [{"id": 1, "title": "FabledSword family"}],
|
||||
}
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
@@ -119,8 +119,10 @@ async def test_get_project_includes_applicable_rules_and_subscribed_rulebooks():
|
||||
):
|
||||
out = await get_project(project_id=3)
|
||||
assert out["applicable_rules"][0]["title"] == "dev is home"
|
||||
assert out["subscribed_rulebooks"] == [{"id": 1, "title": "FabledSword family"}]
|
||||
assert out["project_rules"] == []
|
||||
assert out["applicable_rules_truncated"] is False
|
||||
for gone in ("subscribed_rulebooks", "suppressed_rules", "suppressed_topics"):
|
||||
assert gone not in out, gone
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -173,7 +175,6 @@ async def test_enter_project_composes_full_context():
|
||||
"topic_title": "t", "rulebook_title": "rb"}],
|
||||
"project_rules": [{"id": 99, "title": "pr1", "statement": "ps"}],
|
||||
"truncated": False,
|
||||
"subscribed_rulebooks": [{"id": 2, "title": "rb"}],
|
||||
}
|
||||
milestone_summary = [{"id": 10, "title": "MS", "status": "active", "total": 3}]
|
||||
|
||||
@@ -202,10 +203,9 @@ async def test_enter_project_composes_full_context():
|
||||
assert out["project"] == {"id": 5, "title": "P", "status": "active", "goal": ""}
|
||||
assert out["milestone_summary"] == milestone_summary
|
||||
# Rules arrive in full by retrieval; the handshake lists the project's own
|
||||
# by id and title and drops the subscription bookkeeping (#4045).
|
||||
# by id and title (#4045), and nothing about subscriptions (milestone 414).
|
||||
assert out["project_rules"] == [{"id": 99, "title": "pr1"}]
|
||||
assert out["subscribed_rulebooks"] == [{"id": 2, "title": "rb"}]
|
||||
for gone in ("applicable_rules", "applicable_rules_truncated",
|
||||
for gone in ("applicable_rules", "applicable_rules_truncated", "subscribed_rulebooks",
|
||||
"suppressed_rules", "suppressed_topics", "recent_notes"):
|
||||
assert gone not in out, gone
|
||||
assert out["open_tasks"] == [{
|
||||
@@ -243,8 +243,7 @@ async def test_enter_project_surfaces_the_systems_vocabulary():
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value={"rules": [], "truncated": False,
|
||||
"subscribed_rulebooks": []}),
|
||||
AsyncMock(return_value={"rules": [], "truncated": False}),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=[]),
|
||||
@@ -266,8 +265,7 @@ def _enter_project_stubs(p):
|
||||
patch("scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p)),
|
||||
patch("scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value={"rules": [], "truncated": False,
|
||||
"subscribed_rulebooks": []})),
|
||||
AsyncMock(return_value={"rules": [], "truncated": False})),
|
||||
patch("scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=[])),
|
||||
patch("scribe.mcp.tools.projects.notes_svc.list_notes",
|
||||
@@ -357,8 +355,7 @@ async def test_enter_project_hands_back_the_design_system_when_the_project_has_o
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value={"rules": [], "truncated": False,
|
||||
"subscribed_rulebooks": []}),
|
||||
AsyncMock(return_value={"rules": [], "truncated": False}),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=[]),
|
||||
@@ -417,11 +414,10 @@ async def test_create_project_with_inception_args_decides_via_mcp():
|
||||
decided = {"inception": {"via": "mcp", "choices": {}}, "effects": {"systems_seeded": []}}
|
||||
with patch("scribe.mcp.tools.projects.projects_svc.create_project", AsyncMock(return_value=p)), \
|
||||
patch("scribe.mcp.tools.projects.inception_svc.decide", AsyncMock(return_value=decided)) as decide:
|
||||
out = await create_project(title="P", subscribe_rulebooks=[1], design_system_id=-1, seed_systems=True)
|
||||
out = await create_project(title="P", design_system_id=-1, seed_systems=True)
|
||||
kw = decide.await_args.kwargs
|
||||
assert decide.await_args.args[1] == 5 and kw["via"] == "mcp"
|
||||
assert kw["choices"] == {"subscribe_rulebooks": [1],
|
||||
"design_system_id": None, "seed_systems": True}
|
||||
assert kw["choices"] == {"design_system_id": None, "seed_systems": True}
|
||||
assert out["inception"]["via"] == "mcp" and "inception_effects" in out
|
||||
|
||||
|
||||
@@ -437,8 +433,7 @@ async def test_decide_project_inception_tool_records_an_inherit_all_decision_whe
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_enter_project_carries_the_inception_ask_only_for_an_undecided_own_project():
|
||||
applicable = {"rules": [], "project_rules": [], "truncated": False,
|
||||
"subscribed_rulebooks": []}
|
||||
applicable = {"rules": [], "project_rules": [], "truncated": False}
|
||||
ask = {"defaults": {}, "ask": "decide", "call": "decide_project_inception(...)"}
|
||||
|
||||
async def run(project):
|
||||
@@ -471,6 +466,8 @@ def test_inception_routes_and_tool_are_registered():
|
||||
mcp = build_mcp_server()
|
||||
assert mcp._tool_manager.get_tool("decide_project_inception") is not None
|
||||
tool = mcp._tool_manager.get_tool("create_project")
|
||||
for name in ("subscribe_rulebooks", "design_system_id", "seed_systems"):
|
||||
for name in ("design_system_id", "seed_systems"):
|
||||
assert name in tool.parameters.get("properties", {}), name
|
||||
# Rules left inception with subscriptions (milestone 414).
|
||||
assert "subscribe_rulebooks" not in tool.parameters.get("properties", {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user