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:
@@ -7,9 +7,9 @@ from tests.helpers import make_mock_session
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_system_denied_without_project_write():
|
||||
with patch("scribe.services.systems.access") as acc:
|
||||
with patch("grimoire.services.systems.access") as acc:
|
||||
acc.can_write_project = AsyncMock(return_value=False)
|
||||
from scribe.services.systems import create_system
|
||||
from grimoire.services.systems import create_system
|
||||
result = await create_system(user_id=1, project_id=5, name="Reader")
|
||||
assert result is None
|
||||
|
||||
@@ -24,11 +24,11 @@ async def test_create_system_sets_fields_when_authorized():
|
||||
captured["project_id"] = getattr(obj, "project_id", "MISSING")
|
||||
|
||||
mock_session.add = MagicMock(side_effect=_capture_add)
|
||||
with patch("scribe.services.systems.async_session") as mock_cls, \
|
||||
patch("scribe.services.systems.access") as acc:
|
||||
with patch("grimoire.services.systems.async_session") as mock_cls, \
|
||||
patch("grimoire.services.systems.access") as acc:
|
||||
acc.can_write_project = AsyncMock(return_value=True)
|
||||
mock_cls.return_value = mock_session
|
||||
from scribe.services.systems import create_system
|
||||
from grimoire.services.systems import create_system
|
||||
await create_system(user_id=1, project_id=5, name=" Reader ")
|
||||
assert captured["name"] == "Reader" # stripped
|
||||
assert captured["project_id"] == 5
|
||||
@@ -36,27 +36,27 @@ async def test_create_system_sets_fields_when_authorized():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_record_systems_denied_without_note_write():
|
||||
with patch("scribe.services.systems.access") as acc:
|
||||
with patch("grimoire.services.systems.access") as acc:
|
||||
acc.can_write_note = AsyncMock(return_value=False)
|
||||
from scribe.services.systems import set_record_systems
|
||||
from grimoire.services.systems import set_record_systems
|
||||
result = await set_record_systems(user_id=1, note_id=9, system_ids=[1, 2])
|
||||
assert result is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_systems_denied_returns_empty():
|
||||
with patch("scribe.services.systems.access") as acc:
|
||||
with patch("grimoire.services.systems.access") as acc:
|
||||
acc.can_read_project = AsyncMock(return_value=False)
|
||||
from scribe.services.systems import list_systems
|
||||
from grimoire.services.systems import list_systems
|
||||
result = await list_systems(user_id=1, project_id=5)
|
||||
assert result == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_count_open_issues_denied_returns_zero():
|
||||
with patch("scribe.services.systems.access") as acc:
|
||||
with patch("grimoire.services.systems.access") as acc:
|
||||
acc.can_read_project = AsyncMock(return_value=False)
|
||||
from scribe.services.systems import count_open_issues
|
||||
from grimoire.services.systems import count_open_issues
|
||||
result = await count_open_issues(user_id=1, project_id=5)
|
||||
assert result == 0
|
||||
|
||||
@@ -71,8 +71,8 @@ async def test_assess_matches_an_existing_system_on_case_and_spacing():
|
||||
another project's System) with a different answer."""
|
||||
existing = MagicMock()
|
||||
existing.id, existing.name = 7, "Scrape Pipeline"
|
||||
with patch("scribe.services.systems.list_systems", AsyncMock(return_value=[existing])):
|
||||
from scribe.services.systems import assess_system_name
|
||||
with patch("grimoire.services.systems.list_systems", AsyncMock(return_value=[existing])):
|
||||
from grimoire.services.systems import assess_system_name
|
||||
out = await assess_system_name(1, 5, " scrape pipeline ")
|
||||
assert out["duplicate"] == {"id": 7, "name": "Scrape Pipeline"}
|
||||
# A duplicate short-circuits: there is nothing to file when nothing is created.
|
||||
@@ -81,11 +81,11 @@ async def test_assess_matches_an_existing_system_on_case_and_spacing():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assess_prefers_an_exact_area_over_a_merely_similar_one():
|
||||
from scribe.services.systems import assess_system_name
|
||||
from grimoire.services.systems import assess_system_name
|
||||
exact = MagicMock()
|
||||
exact.id, exact.name = 3, "CI & Release"
|
||||
with patch("scribe.services.systems.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("scribe.services.systems.canonical_systems_svc") as canon:
|
||||
with patch("grimoire.services.systems.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("grimoire.services.systems.canonical_systems_svc") as canon:
|
||||
canon.find_by_name = AsyncMock(return_value=exact)
|
||||
canon.best_overlap = AsyncMock()
|
||||
out = await assess_system_name(1, 5, "CI and Release")
|
||||
@@ -96,10 +96,10 @@ async def test_assess_prefers_an_exact_area_over_a_merely_similar_one():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assess_falls_back_to_overlap_and_never_invents_a_match():
|
||||
from scribe.services.systems import assess_system_name
|
||||
from grimoire.services.systems import assess_system_name
|
||||
near = {"id": 3, "name": "CI & Release", "basis": "overlap", "score": 0.33}
|
||||
with patch("scribe.services.systems.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("scribe.services.systems.canonical_systems_svc") as canon:
|
||||
with patch("grimoire.services.systems.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("grimoire.services.systems.canonical_systems_svc") as canon:
|
||||
canon.find_by_name = AsyncMock(return_value=None)
|
||||
canon.best_overlap = AsyncMock(return_value=near)
|
||||
assert (await assess_system_name(1, 5, "CI & runners"))["canonical"] == near
|
||||
@@ -113,25 +113,25 @@ async def test_assess_falls_back_to_overlap_and_never_invents_a_match():
|
||||
async def test_assess_fails_open_so_a_naming_aid_cannot_block_a_create():
|
||||
"""Both arms degrade to "no opinion" rather than raising. A create must
|
||||
never fail because the catalog was unreachable."""
|
||||
from scribe.services.systems import assess_system_name
|
||||
with patch("scribe.services.systems.list_systems", AsyncMock(side_effect=RuntimeError("db down"))):
|
||||
from grimoire.services.systems import assess_system_name
|
||||
with patch("grimoire.services.systems.list_systems", AsyncMock(side_effect=RuntimeError("db down"))):
|
||||
assert await assess_system_name(1, 5, "Reader") == {"duplicate": None, "canonical": None}
|
||||
with patch("scribe.services.systems.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("scribe.services.systems.canonical_systems_svc") as canon:
|
||||
with patch("grimoire.services.systems.list_systems", AsyncMock(return_value=[])), \
|
||||
patch("grimoire.services.systems.canonical_systems_svc") as canon:
|
||||
canon.find_by_name = AsyncMock(side_effect=RuntimeError("db down"))
|
||||
assert (await assess_system_name(1, 5, "Reader"))["canonical"] is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_assess_says_nothing_about_a_nameless_system():
|
||||
from scribe.services.systems import assess_system_name
|
||||
from grimoire.services.systems import assess_system_name
|
||||
assert await assess_system_name(1, 5, " ") == {"duplicate": None, "canonical": None}
|
||||
|
||||
|
||||
# ── path patterns — the files that ARE the area ──
|
||||
|
||||
def test_patterns_are_tidied_to_repo_relative_and_deduplicated():
|
||||
from scribe.services.systems import normalize_path_patterns
|
||||
from grimoire.services.systems import normalize_path_patterns
|
||||
out = normalize_path_patterns([
|
||||
" ./src/billing/ ", "/src/billing", "", "src\\api\\*.py", " ",
|
||||
"frontend/src/**/Billing*.vue",
|
||||
@@ -150,7 +150,7 @@ def test_patterns_are_tidied_to_repo_relative_and_deduplicated():
|
||||
[f"src/f{i}.py" for i in range(51)],
|
||||
])
|
||||
def test_patterns_that_cannot_mean_an_area_are_refused(bad):
|
||||
from scribe.services.systems import normalize_path_patterns
|
||||
from grimoire.services.systems import normalize_path_patterns
|
||||
with pytest.raises(ValueError):
|
||||
normalize_path_patterns(bad)
|
||||
|
||||
@@ -173,7 +173,7 @@ def test_patterns_that_cannot_mean_an_area_are_refused(bad):
|
||||
("src/billing", "", False),
|
||||
])
|
||||
def test_path_matches(pattern, path, expected):
|
||||
from scribe.services.systems import path_matches
|
||||
from grimoire.services.systems import path_matches
|
||||
assert path_matches(pattern, path) is expected
|
||||
|
||||
|
||||
@@ -181,34 +181,34 @@ def test_path_matches(pattern, path, expected):
|
||||
async def test_systems_for_paths_returns_every_area_a_path_belongs_to():
|
||||
"""Areas overlap, and each one a path belongs to answers for it — the
|
||||
lookup never picks a winner. A System that named no files claims none."""
|
||||
api = MagicMock(id=1, path_patterns=["src/scribe/routes", "src/scribe/mcp/tools"])
|
||||
data = MagicMock(id=2, path_patterns=["src/scribe/models", "src/scribe/**/systems.py"])
|
||||
api = MagicMock(id=1, path_patterns=["src/grimoire/routes", "src/grimoire/mcp/tools"])
|
||||
data = MagicMock(id=2, path_patterns=["src/grimoire/models", "src/grimoire/**/systems.py"])
|
||||
unnamed = MagicMock(id=3, path_patterns=[])
|
||||
with patch("scribe.services.systems.list_systems",
|
||||
with patch("grimoire.services.systems.list_systems",
|
||||
AsyncMock(return_value=[api, data, unnamed])):
|
||||
from scribe.services.systems import systems_for_paths
|
||||
from grimoire.services.systems import systems_for_paths
|
||||
out = await systems_for_paths(1, 5, [
|
||||
"src/scribe/routes/systems.py", "./README.md", "",
|
||||
"src/grimoire/routes/systems.py", "./README.md", "",
|
||||
])
|
||||
assert [(s.id, paths) for s, paths in out] == [
|
||||
(1, ["src/scribe/routes/systems.py"]),
|
||||
(2, ["src/scribe/routes/systems.py"]),
|
||||
(1, ["src/grimoire/routes/systems.py"]),
|
||||
(2, ["src/grimoire/routes/systems.py"]),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_systems_for_paths_with_no_paths_reads_nothing():
|
||||
lister = AsyncMock(return_value=[])
|
||||
with patch("scribe.services.systems.list_systems", lister):
|
||||
from scribe.services.systems import systems_for_paths
|
||||
with patch("grimoire.services.systems.list_systems", lister):
|
||||
from grimoire.services.systems import systems_for_paths
|
||||
assert await systems_for_paths(1, 5, ["", " "]) == []
|
||||
lister.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_refuses_a_bad_pattern_before_touching_the_row():
|
||||
with patch("scribe.services.systems.async_session") as mock_cls:
|
||||
from scribe.services.systems import update_system
|
||||
with patch("grimoire.services.systems.async_session") as mock_cls:
|
||||
from grimoire.services.systems import update_system
|
||||
with pytest.raises(ValueError):
|
||||
await update_system(1, 9, path_patterns=["../elsewhere"])
|
||||
mock_cls.assert_not_called()
|
||||
@@ -220,11 +220,11 @@ async def test_update_with_an_empty_list_clears_the_patterns():
|
||||
system = MagicMock(deleted_at=None, project_id=5, path_patterns=["src/old"])
|
||||
session = make_mock_session()
|
||||
session.get = AsyncMock(return_value=system)
|
||||
with patch("scribe.services.systems.async_session", return_value=session), \
|
||||
patch("scribe.services.systems.access") as acc, \
|
||||
patch("scribe.services.systems.embed_system"):
|
||||
with patch("grimoire.services.systems.async_session", return_value=session), \
|
||||
patch("grimoire.services.systems.access") as acc, \
|
||||
patch("grimoire.services.systems.embed_system"):
|
||||
acc.can_write_project = AsyncMock(return_value=True)
|
||||
from scribe.services.systems import update_system
|
||||
from grimoire.services.systems import update_system
|
||||
await update_system(1, 9, path_patterns=[])
|
||||
assert system.path_patterns == []
|
||||
|
||||
@@ -235,17 +235,17 @@ async def test_create_stores_tidied_patterns():
|
||||
captured = {}
|
||||
mock_session.add = MagicMock(side_effect=lambda obj: captured.update(
|
||||
patterns=getattr(obj, "path_patterns", "MISSING")))
|
||||
with patch("scribe.services.systems.async_session", return_value=mock_session), \
|
||||
patch("scribe.services.systems.access") as acc, \
|
||||
patch("scribe.services.systems.embed_system"):
|
||||
with patch("grimoire.services.systems.async_session", return_value=mock_session), \
|
||||
patch("grimoire.services.systems.access") as acc, \
|
||||
patch("grimoire.services.systems.embed_system"):
|
||||
acc.can_write_project = AsyncMock(return_value=True)
|
||||
from scribe.services.systems import create_system
|
||||
from grimoire.services.systems import create_system
|
||||
await create_system(1, 5, "Billing", path_patterns=["./src/billing/"])
|
||||
assert captured["patterns"] == ["src/billing"]
|
||||
|
||||
|
||||
def test_system_to_dict_carries_its_patterns():
|
||||
from scribe.models.system import System
|
||||
from grimoire.models.system import System
|
||||
system = System(id=1, user_id=1, project_id=5, name="Billing",
|
||||
path_patterns=["src/billing"])
|
||||
assert system.to_dict()["path_patterns"] == ["src/billing"]
|
||||
|
||||
Reference in New Issue
Block a user