rename(547): the server is grimoire — package, image, DB defaults, backups
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
Step 2 of the Scribe -> Grimoire rename. - src/scribe -> src/grimoire, and every import, patch target, module path, hypercorn entry point and `python -m grimoire.restore` with it; pyproject, uv.lock and the frontend package are named grimoire. - Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service runs as grimoire / grimoire_test. - Compose files default the DB user, database and (prod) volume to grimoire, each overridable from .env, so an install created as Scribe keeps its data by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME. - Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar. Archives named scribe-* with the scribe-backup-tar manifest still restore and are still counted at the destination (folder and S3), with tests. - Exports, the MCP auth realm, the ASGI scope key and the persistent logger carry the new name. Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1", because every stored secret was derived under it. Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is step 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from scribe.mcp.tools.projects import (
|
||||
from grimoire.mcp.tools.projects import (
|
||||
list_projects, get_project, create_project,
|
||||
update_project, enter_project,
|
||||
)
|
||||
@@ -21,7 +21,7 @@ def _no_systems():
|
||||
the lookup is stubbed to the common case — a project with none. The
|
||||
populated shape is asserted in its own test below.
|
||||
"""
|
||||
with patch("scribe.mcp.tools.projects.systems_svc.list_systems",
|
||||
with patch("grimoire.mcp.tools.projects.systems_svc.list_systems",
|
||||
AsyncMock(return_value=[])):
|
||||
yield
|
||||
|
||||
@@ -33,7 +33,7 @@ def _no_platforms():
|
||||
case — a project with none yet. The populated shape is asserted in its
|
||||
own test.
|
||||
"""
|
||||
with patch("scribe.mcp.tools.projects.platforms_svc.project_platforms",
|
||||
with patch("grimoire.mcp.tools.projects.platforms_svc.project_platforms",
|
||||
AsyncMock(return_value=[])):
|
||||
yield
|
||||
|
||||
@@ -44,7 +44,7 @@ def _no_coverage():
|
||||
deal: no database here, stub the common case (nothing computed). The
|
||||
populated line is asserted in tests/test_pattern_coverage.py.
|
||||
"""
|
||||
with patch("scribe.mcp.tools.projects.coverage_svc.cached_coverage",
|
||||
with patch("grimoire.mcp.tools.projects.coverage_svc.cached_coverage",
|
||||
AsyncMock(return_value=None)):
|
||||
yield
|
||||
|
||||
@@ -54,7 +54,7 @@ def _no_family():
|
||||
"""enter_project reads the family-canon readout —
|
||||
no database here, so the common case is stubbed: nothing to answer. The
|
||||
populated key is asserted in its own test below."""
|
||||
with patch("scribe.mcp.tools.projects.family_adoption_svc.family_readout",
|
||||
with patch("grimoire.mcp.tools.projects.family_adoption_svc.family_readout",
|
||||
AsyncMock(return_value=None)) as mock:
|
||||
yield mock
|
||||
|
||||
@@ -64,7 +64,7 @@ def _no_background_seed():
|
||||
"""enter_project fire-and-forgets a coverage self-seed. These
|
||||
are no-database unit tests, so the spawn is stubbed out; the firing shape
|
||||
has its own test below."""
|
||||
with patch("scribe.mcp.tools.projects.spawn") as mock:
|
||||
with patch("grimoire.mcp.tools.projects.spawn") as mock:
|
||||
yield mock
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ def _no_bootstrap():
|
||||
records — a database read. Stub the common case (young project, no ask);
|
||||
the firing shape has its own test below.
|
||||
"""
|
||||
with patch("scribe.mcp.tools.projects.systems_tools.bootstrap_systems_ask",
|
||||
with patch("grimoire.mcp.tools.projects.systems_tools.bootstrap_systems_ask",
|
||||
AsyncMock(return_value=None)) as mock:
|
||||
yield mock
|
||||
|
||||
@@ -84,7 +84,7 @@ def _no_bootstrap():
|
||||
async def test_list_projects_wraps_in_dict():
|
||||
rows = [fake_project(id=1), fake_project(id=2)]
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.list_projects",
|
||||
"grimoire.mcp.tools.projects.projects_svc.list_projects",
|
||||
AsyncMock(return_value=rows),
|
||||
):
|
||||
out = await list_projects()
|
||||
@@ -99,13 +99,13 @@ async def test_get_project_enriches_with_milestone_summary():
|
||||
"rules": [], "truncated": False,
|
||||
}
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
"grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=milestone_summary),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
"grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value=applicable_payload),
|
||||
):
|
||||
out = await get_project(project_id=5)
|
||||
@@ -131,13 +131,13 @@ async def test_get_project_includes_applicable_rules_and_project_rules():
|
||||
"truncated": False,
|
||||
}
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
"grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=milestone_summary),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
"grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value=applicable_payload),
|
||||
):
|
||||
out = await get_project(project_id=3)
|
||||
@@ -151,7 +151,7 @@ async def test_get_project_includes_applicable_rules_and_project_rules():
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_project_raises_when_not_found():
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="project 999 not found"):
|
||||
@@ -162,7 +162,7 @@ async def test_get_project_raises_when_not_found():
|
||||
async def test_create_project_passes_color_empty_as_none():
|
||||
p = fake_project()
|
||||
mock = AsyncMock(return_value=p)
|
||||
with patch("scribe.mcp.tools.projects.projects_svc.create_project", mock):
|
||||
with patch("grimoire.mcp.tools.projects.projects_svc.create_project", mock):
|
||||
await create_project(title="P", color="")
|
||||
assert mock.call_args.kwargs["color"] is None
|
||||
|
||||
@@ -171,7 +171,7 @@ async def test_create_project_passes_color_empty_as_none():
|
||||
async def test_update_project_only_sends_non_default_fields():
|
||||
p = fake_project()
|
||||
mock = AsyncMock(return_value=p)
|
||||
with patch("scribe.mcp.tools.projects.projects_svc.update_project", mock):
|
||||
with patch("grimoire.mcp.tools.projects.projects_svc.update_project", mock):
|
||||
await update_project(project_id=1, status="archived")
|
||||
args, kwargs = mock.call_args
|
||||
assert args == (7, 1)
|
||||
@@ -181,7 +181,7 @@ async def test_update_project_only_sends_non_default_fields():
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_project_raises_when_not_found():
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.update_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.update_project",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="project 999 not found"):
|
||||
@@ -209,16 +209,16 @@ async def test_enter_project_composes_full_context():
|
||||
note1.updated_at = None # avoids datetime mocking
|
||||
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
"grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value=applicable_payload),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
"grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=milestone_summary),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.notes_svc.list_notes",
|
||||
"grimoire.mcp.tools.projects.notes_svc.list_notes",
|
||||
AsyncMock(side_effect=[([task1], 1), ([note1], 1)]),
|
||||
):
|
||||
out = await enter_project(project_id=5)
|
||||
@@ -260,19 +260,19 @@ async def test_enter_project_surfaces_the_systems_vocabulary():
|
||||
sys1.description = "Embeddings, ranking, auto-inject.\nLong detail below."
|
||||
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
"grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value={"rules": [], "truncated": False}),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
"grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.notes_svc.list_notes",
|
||||
"grimoire.mcp.tools.projects.notes_svc.list_notes",
|
||||
AsyncMock(side_effect=[([], 0), ([], 0)]),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.systems_svc.list_systems",
|
||||
"grimoire.mcp.tools.projects.systems_svc.list_systems",
|
||||
AsyncMock(return_value=[sys1]),
|
||||
):
|
||||
out = await enter_project(project_id=5)
|
||||
@@ -283,13 +283,13 @@ async def test_enter_project_surfaces_the_systems_vocabulary():
|
||||
def _enter_project_stubs(p):
|
||||
"""The four patches every enter_project test repeats, as one context list."""
|
||||
return [
|
||||
patch("scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
patch("grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p)),
|
||||
patch("scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
patch("grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value={"rules": [], "truncated": False})),
|
||||
patch("scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
patch("grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=[])),
|
||||
patch("scribe.mcp.tools.projects.notes_svc.list_notes",
|
||||
patch("grimoire.mcp.tools.projects.notes_svc.list_notes",
|
||||
AsyncMock(side_effect=[([], 0), ([], 0)])),
|
||||
]
|
||||
|
||||
@@ -306,7 +306,7 @@ async def test_enter_project_carries_the_bootstrap_ask_when_it_fires():
|
||||
for cm in _enter_project_stubs(fake_project(id=5)):
|
||||
stack.enter_context(cm)
|
||||
stack.enter_context(patch(
|
||||
"scribe.mcp.tools.projects.systems_tools.bootstrap_systems_ask",
|
||||
"grimoire.mcp.tools.projects.systems_tools.bootstrap_systems_ask",
|
||||
AsyncMock(return_value=ask),
|
||||
))
|
||||
out = await enter_project(project_id=5)
|
||||
@@ -327,7 +327,7 @@ async def test_enter_project_never_asks_bootstrap_once_a_vocabulary_exists(
|
||||
for cm in _enter_project_stubs(fake_project(id=5)):
|
||||
stack.enter_context(cm)
|
||||
stack.enter_context(patch(
|
||||
"scribe.mcp.tools.projects.systems_svc.list_systems",
|
||||
"grimoire.mcp.tools.projects.systems_svc.list_systems",
|
||||
AsyncMock(return_value=[sys1]),
|
||||
))
|
||||
out = await enter_project(project_id=5)
|
||||
@@ -351,7 +351,7 @@ async def test_enter_project_fires_the_coverage_seed_on_the_owner(
|
||||
for cm in _enter_project_stubs(project):
|
||||
stack.enter_context(cm)
|
||||
seed = stack.enter_context(patch(
|
||||
"scribe.mcp.tools.projects.coverage_svc.refresh_if_stale",
|
||||
"grimoire.mcp.tools.projects.coverage_svc.refresh_if_stale",
|
||||
MagicMock(return_value=object()),
|
||||
))
|
||||
await enter_project(project_id=5)
|
||||
@@ -372,19 +372,19 @@ async def test_enter_project_hands_back_the_design_system_when_the_project_has_o
|
||||
"inherits_from": ["House"], "description": ""}
|
||||
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=p),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
"grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules",
|
||||
AsyncMock(return_value={"rules": [], "truncated": False}),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
"grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
||||
AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.notes_svc.list_notes",
|
||||
"grimoire.mcp.tools.projects.notes_svc.list_notes",
|
||||
AsyncMock(side_effect=[([], 0), ([], 0)]),
|
||||
), patch(
|
||||
"scribe.mcp.tools.projects.design_systems_svc.design_context",
|
||||
"grimoire.mcp.tools.projects.design_systems_svc.design_context",
|
||||
AsyncMock(return_value=design),
|
||||
) as ctx:
|
||||
out = await enter_project(project_id=5)
|
||||
@@ -400,7 +400,7 @@ async def test_enter_project_hands_back_the_design_system_when_the_project_has_o
|
||||
@pytest.mark.asyncio
|
||||
async def test_enter_project_raises_when_project_not_found():
|
||||
with patch(
|
||||
"scribe.mcp.tools.projects.projects_svc.get_project",
|
||||
"grimoire.mcp.tools.projects.projects_svc.get_project",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
with pytest.raises(ValueError, match="project 999 not found"):
|
||||
@@ -409,7 +409,7 @@ async def test_enter_project_raises_when_project_not_found():
|
||||
|
||||
def test_enter_project_registered_in_register():
|
||||
"""register(mcp) registers enter_project alongside the existing tools."""
|
||||
from scribe.mcp.tools.projects import register
|
||||
from grimoire.mcp.tools.projects import register
|
||||
mcp = FakeMCP()
|
||||
|
||||
register(mcp)
|
||||
@@ -422,8 +422,8 @@ def test_enter_project_registered_in_register():
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_project_without_inception_args_stays_undecided():
|
||||
p = fake_project(id=5, title="P", inception=None)
|
||||
with patch("scribe.mcp.tools.projects.projects_svc.create_project", AsyncMock(return_value=p)), \
|
||||
patch("scribe.mcp.tools.projects.inception_svc.decide", AsyncMock()) as decide:
|
||||
with patch("grimoire.mcp.tools.projects.projects_svc.create_project", AsyncMock(return_value=p)), \
|
||||
patch("grimoire.mcp.tools.projects.inception_svc.decide", AsyncMock()) as decide:
|
||||
out = await create_project(title="P")
|
||||
decide.assert_not_awaited()
|
||||
assert "inception_hint" in out and "inception_effects" not in out
|
||||
@@ -433,8 +433,8 @@ async def test_create_project_without_inception_args_stays_undecided():
|
||||
async def test_create_project_with_inception_args_decides_via_mcp():
|
||||
p = fake_project(id=5, title="P", inception=None)
|
||||
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:
|
||||
with patch("grimoire.mcp.tools.projects.projects_svc.create_project", AsyncMock(return_value=p)), \
|
||||
patch("grimoire.mcp.tools.projects.inception_svc.decide", AsyncMock(return_value=decided)) as decide:
|
||||
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"
|
||||
@@ -444,9 +444,9 @@ async def test_create_project_with_inception_args_decides_via_mcp():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_decide_project_inception_tool_records_an_inherit_all_decision_when_given_nothing():
|
||||
from scribe.mcp.tools.projects import decide_project_inception
|
||||
from grimoire.mcp.tools.projects import decide_project_inception
|
||||
decided = {"inception": {"via": "mcp"}, "effects": {}}
|
||||
with patch("scribe.mcp.tools.projects.inception_svc.decide", AsyncMock(return_value=decided)) as decide:
|
||||
with patch("grimoire.mcp.tools.projects.inception_svc.decide", AsyncMock(return_value=decided)) as decide:
|
||||
out = await decide_project_inception(project_id=5)
|
||||
assert decide.await_args.kwargs["choices"] == {}
|
||||
assert out["project_id"] == 5 and out["inception"]["via"] == "mcp"
|
||||
@@ -458,13 +458,13 @@ async def test_enter_project_carries_the_inception_ask_only_for_an_undecided_own
|
||||
ask = {"defaults": {}, "ask": "decide", "call": "decide_project_inception(...)"}
|
||||
|
||||
async def run(project):
|
||||
with patch("scribe.mcp.tools.projects.projects_svc.get_project", AsyncMock(return_value=project)), \
|
||||
patch("scribe.mcp.tools.projects.rulebooks_svc.get_applicable_rules", AsyncMock(return_value=applicable)), \
|
||||
patch("scribe.mcp.tools.projects.milestones_svc.get_project_milestone_summary", AsyncMock(return_value=[])), \
|
||||
patch("scribe.mcp.tools.projects.notes_svc.list_notes", AsyncMock(side_effect=[([], 0), ([], 0)])), \
|
||||
patch("scribe.mcp.tools.projects.systems_svc.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("scribe.mcp.tools.projects.systems_tools.bootstrap_systems_ask", AsyncMock(return_value=None)), \
|
||||
patch("scribe.mcp.tools.projects.inception_svc.inception_ask", AsyncMock(return_value=ask)) as asked:
|
||||
with patch("grimoire.mcp.tools.projects.projects_svc.get_project", AsyncMock(return_value=project)), \
|
||||
patch("grimoire.mcp.tools.projects.rulebooks_svc.get_applicable_rules", AsyncMock(return_value=applicable)), \
|
||||
patch("grimoire.mcp.tools.projects.milestones_svc.get_project_milestone_summary", AsyncMock(return_value=[])), \
|
||||
patch("grimoire.mcp.tools.projects.notes_svc.list_notes", AsyncMock(side_effect=[([], 0), ([], 0)])), \
|
||||
patch("grimoire.mcp.tools.projects.systems_svc.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("grimoire.mcp.tools.projects.systems_tools.bootstrap_systems_ask", AsyncMock(return_value=None)), \
|
||||
patch("grimoire.mcp.tools.projects.inception_svc.inception_ask", AsyncMock(return_value=ask)) as asked:
|
||||
return await enter_project(project_id=5), asked
|
||||
|
||||
# Own + undecided → the ask rides along.
|
||||
@@ -479,8 +479,8 @@ async def test_enter_project_carries_the_inception_ask_only_for_an_undecided_own
|
||||
|
||||
|
||||
def test_inception_routes_and_tool_are_registered():
|
||||
from scribe.app import create_app
|
||||
from scribe.mcp.server import build_mcp_server
|
||||
from grimoire.app import create_app
|
||||
from grimoire.mcp.server import build_mcp_server
|
||||
rules = {r.rule for r in create_app().url_map.iter_rules()}
|
||||
assert "/api/projects/<int:project_id>/inception" in rules
|
||||
assert "/api/projects/<int:project_id>/inception/defaults" in rules
|
||||
|
||||
Reference in New Issue
Block a user