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

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:
2026-10-22 10:50:45 -04:00
co-authored by Claude Opus 5.5
parent e99f1169f7
commit 0f5ef0be63
447 changed files with 3611 additions and 3558 deletions
+43 -43
View File
@@ -1,10 +1,10 @@
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from scribe.services import plugin_context as pc_module
from scribe.services import retrieval_surfaces as rs
from scribe.services.retrieval_pipeline import REUSE_SLOT
from scribe.services.lessons import LESSON_NOTE_TYPE
from grimoire.services import plugin_context as pc_module
from grimoire.services import retrieval_surfaces as rs
from grimoire.services.retrieval_pipeline import REUSE_SLOT
from grimoire.services.lessons import LESSON_NOTE_TYPE
from tests.helpers import fake_note, writepath_cfg
@@ -18,7 +18,7 @@ pytestmark = pytest.mark.usefixtures("_no_supersession")
@pytest.mark.asyncio
async def test_get_autoinject_config_defaults_and_clamps():
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
# No settings stored → defaults.
with patch.object(pc, "get_setting", AsyncMock(side_effect=lambda uid, k, d: d)), \
@@ -50,7 +50,7 @@ async def test_get_autoinject_config_defaults_and_clamps():
@pytest.mark.asyncio
async def test_build_autoinject_hint_disabled_returns_empty_and_skips_search():
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
search = AsyncMock()
with patch.object(pc, "get_autoinject_config",
AsyncMock(return_value={"enabled": False, "threshold": 0.55, "top_k": 3})), \
@@ -63,7 +63,7 @@ async def test_build_autoinject_hint_disabled_returns_empty_and_skips_search():
@pytest.mark.asyncio
async def test_build_autoinject_hint_titles_only_with_margin_gate():
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
# top=0.80; 0.74 within band (0.10), 0.61 outside → dropped.
hits = [(0.80, fake_note(id=11, title="Pool sizing decision", user_id=1)),
(0.74, fake_note(id=22, title="run_maintenance thresholds", user_id=1)),
@@ -94,7 +94,7 @@ async def test_build_autoinject_hint_titles_only_with_margin_gate():
@pytest.mark.asyncio
async def test_build_autoinject_hint_blank_query_returns_empty():
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
search = AsyncMock()
with patch.object(pc, "get_autoinject_config",
AsyncMock(return_value={"enabled": True, "threshold": 0.55, "top_k": 3})), \
@@ -113,11 +113,11 @@ async def test_build_session_context_includes_project_when_scoped():
# opposite of what this test is about.
project = MagicMock(id=2, title="FabledScribe", goal="ship it",
design_system_id=None)
with patch("scribe.services.plugin_context.projects_svc.get_project",
with patch("grimoire.services.plugin_context.projects_svc.get_project",
AsyncMock(return_value=project)), \
patch("scribe.services.plugin_context.notes_svc.list_notes",
patch("grimoire.services.plugin_context.notes_svc.list_notes",
AsyncMock(return_value=([], 4))):
from scribe.services.plugin_context import build_session_context
from grimoire.services.plugin_context import build_session_context
out = await build_session_context(user_id=7, project_id=2)
assert out["project"] == {"id": 2, "title": "FabledScribe"}
@@ -133,7 +133,7 @@ async def test_build_session_context_includes_project_when_scoped():
def test_a_short_goal_is_shown_whole():
from scribe.services.plugin_context import _goal_line
from grimoire.services.plugin_context import _goal_line
assert _goal_line("ship it", 2) == "Goal: ship it"
assert _goal_line("", 2) == ""
@@ -141,7 +141,7 @@ def test_a_short_goal_is_shown_whole():
def test_a_long_goal_is_cut_at_a_word_and_says_where_the_rest_is():
"""A raw slice ends mid-word with nothing marking the cut, and a reader
takes half a sentence for the whole goal."""
from scribe.services.plugin_context import _GOAL_CHARS, _goal_line
from grimoire.services.plugin_context import _GOAL_CHARS, _goal_line
goal = "make the record reach the next session\nso a solution is recalled " * 10
line = _goal_line(goal, 2)
shown = line.removeprefix("Goal: ").split(" (full goal:")[0]
@@ -153,7 +153,7 @@ def test_a_long_goal_is_cut_at_a_word_and_says_where_the_rest_is():
def test_an_unbroken_goal_still_shows_its_start():
from scribe.services.plugin_context import _GOAL_CHARS, _goal_line
from grimoire.services.plugin_context import _GOAL_CHARS, _goal_line
shown = _goal_line("x" * 500, 2).removeprefix("Goal: ").split(" (full goal:")[0]
assert shown == "x" * (_GOAL_CHARS - 1) + "…"
@@ -170,13 +170,13 @@ async def test_build_session_context_pushes_the_projects_design_system():
"guidance": [], "token_count": 95,
"token_groups": ["accent", "surface", "type"],
}
with patch("scribe.services.plugin_context.projects_svc.get_project",
with patch("grimoire.services.plugin_context.projects_svc.get_project",
AsyncMock(return_value=project)), \
patch("scribe.services.plugin_context.notes_svc.list_notes",
patch("grimoire.services.plugin_context.notes_svc.list_notes",
AsyncMock(return_value=([], 0))), \
patch("scribe.services.plugin_context.design_systems_svc.design_context",
patch("grimoire.services.plugin_context.design_systems_svc.design_context",
AsyncMock(return_value=design)):
from scribe.services.plugin_context import build_session_context
from grimoire.services.plugin_context import build_session_context
out = await build_session_context(user_id=7, project_id=2)
ctx = out["context"]
@@ -199,13 +199,13 @@ async def test_build_session_context_survives_an_unreadable_design_system():
That must degrade to "no design block", not to a crash that costs the
session its rules too."""
project = MagicMock(id=2, title="App", goal="", design_system_id=9)
with patch("scribe.services.plugin_context.projects_svc.get_project",
with patch("grimoire.services.plugin_context.projects_svc.get_project",
AsyncMock(return_value=project)), \
patch("scribe.services.plugin_context.notes_svc.list_notes",
patch("grimoire.services.plugin_context.notes_svc.list_notes",
AsyncMock(return_value=([], 0))), \
patch("scribe.services.plugin_context.design_systems_svc.design_context",
patch("grimoire.services.plugin_context.design_systems_svc.design_context",
AsyncMock(return_value=None)):
from scribe.services.plugin_context import build_session_context
from grimoire.services.plugin_context import build_session_context
out = await build_session_context(user_id=7, project_id=2)
assert "## Design system" not in out["context"]
@@ -214,7 +214,7 @@ async def test_build_session_context_survives_an_unreadable_design_system():
@pytest.mark.asyncio
async def test_build_session_context_unbound_repo_emits_bind_hint():
from scribe.services.plugin_context import build_session_context
from grimoire.services.plugin_context import build_session_context
out = await build_session_context(
user_id=7, project_id=0, unbound_repo="host/owner/repo",
)
@@ -238,8 +238,8 @@ async def test_a_project_id_that_does_not_resolve_is_reported_not_dropped():
sent and failed takes the outer arm, finds no project, and falls out of the
block having said nothing at all.
"""
from scribe.services.plugin_context import build_session_context
with patch("scribe.services.plugin_context.projects_svc.get_project",
from grimoire.services.plugin_context import build_session_context
with patch("grimoire.services.plugin_context.projects_svc.get_project",
AsyncMock(return_value=None)):
out = await build_session_context(user_id=7, project_id=41)
@@ -258,9 +258,9 @@ async def test_build_process_manifest_renders_stub_specs():
{"id": 5, "title": "Drift Audit", "tags": [], "snippet": "Find drifted docs."},
{"id": 9, "title": "DRY Pass", "tags": [], "snippet": ""},
]
with patch("scribe.services.plugin_context.knowledge_svc.query_knowledge",
with patch("grimoire.services.plugin_context.knowledge_svc.query_knowledge",
AsyncMock(return_value=(items, 2))):
from scribe.services.plugin_context import build_process_manifest
from grimoire.services.plugin_context import build_process_manifest
out = await build_process_manifest(user_id=7)
assert out["total"] == 2
@@ -281,9 +281,9 @@ async def test_build_process_manifest_dedupes_slugs_and_skips_blank_titles():
{"id": 2, "title": "my process", "tags": [], "snippet": "b"}, # same slug
{"id": 3, "title": " ", "tags": [], "snippet": "skip me"}, # blank title
]
with patch("scribe.services.plugin_context.knowledge_svc.query_knowledge",
with patch("grimoire.services.plugin_context.knowledge_svc.query_knowledge",
AsyncMock(return_value=(items, 3))):
from scribe.services.plugin_context import build_process_manifest
from grimoire.services.plugin_context import build_process_manifest
out = await build_process_manifest(user_id=7)
slugs = [p["slug"] for p in out["processes"]]
@@ -294,9 +294,9 @@ async def test_build_process_manifest_dedupes_slugs_and_skips_blank_titles():
@pytest.mark.asyncio
async def test_build_process_manifest_truncates_long_preview():
items = [{"id": 1, "title": "Big", "tags": [], "snippet": "x" * 500}]
with patch("scribe.services.plugin_context.knowledge_svc.query_knowledge",
with patch("grimoire.services.plugin_context.knowledge_svc.query_knowledge",
AsyncMock(return_value=(items, 1))):
from scribe.services.plugin_context import build_process_manifest
from grimoire.services.plugin_context import build_process_manifest
out = await build_process_manifest(user_id=7)
assert "…" in out["processes"][0]["description"]
@@ -318,7 +318,7 @@ async def test_build_session_context_caps_length():
is the part a reader depends on. The unbound-repo hint supplies the text:
the block carries live state only, and a bare session is a one-liner.
"""
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
with patch.object(pc, "_MAX_CHARS", 60):
out = await pc.build_session_context(user_id=7, unbound_repo="host/owner/repo")
@@ -364,15 +364,15 @@ async def _autoinject(main_hits, reuse_hits, cfg=None, lesson_hits=None):
return reuse_hits
return main_hits
with patch("scribe.services.plugin_context.get_autoinject_config",
with patch("grimoire.services.plugin_context.get_autoinject_config",
AsyncMock(return_value=dict(cfg or _CFG))), \
patch("scribe.services.plugin_context.semantic_search_notes",
patch("grimoire.services.plugin_context.semantic_search_notes",
AsyncMock(side_effect=fake_search)), \
patch("scribe.services.plugin_context.record_retrieval", MagicMock()), \
patch("scribe.services.plugin_context.record_surfaced", MagicMock()), \
patch("scribe.services.plugin_context.owner_names_for",
patch("grimoire.services.plugin_context.record_retrieval", MagicMock()), \
patch("grimoire.services.plugin_context.record_surfaced", MagicMock()), \
patch("grimoire.services.plugin_context.owner_names_for",
AsyncMock(return_value={})):
from scribe.services.plugin_context import build_autoinject_hint
from grimoire.services.plugin_context import build_autoinject_hint
out = await build_autoinject_hint(1, "write a debounce helper")
return out, calls
@@ -463,7 +463,7 @@ async def test_write_path_semantic_arm_asks_for_experience_not_just_snippets():
issue saying "we tried this and it deadlocked" could never reach the moment
that code was about to be written — arguably the better prior art, because
it says what NOT to do."""
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
hits = [(0.72, fake_note(id=9, title="debounce helper", user_id=1, note_type="snippet")),
(0.70, fake_note(id=7, title="Debounce dropped the trailing call", user_id=1, is_task=True, task_kind="issue"))]
@@ -496,7 +496,7 @@ async def test_write_path_labels_a_non_snippet_hit_with_its_kind():
"""An unlabelled issue on this menu reads as "here is code to reuse", which
is the opposite of what it says. A snippet stays unlabelled — it is the
menu's default and the header's default reading."""
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
hits = [(0.72, fake_note(id=9, title="debounce helper", user_id=1, note_type="snippet")),
(0.71, fake_note(id=7, title="Debounce dropped the trailing call", user_id=1, is_task=True, task_kind="issue"))]
@@ -540,7 +540,7 @@ async def test_the_config_stand_in_carries_every_key_the_real_one_does():
"""
from unittest.mock import AsyncMock, patch
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
from tests.helpers import writepath_cfg
with patch.object(pc, "get_setting", AsyncMock(return_value="0.6")), \
@@ -564,7 +564,7 @@ async def test_the_menu_shows_the_passage_that_matched():
and answers "does this apply to me"; for an issue or a dev-log the reason
this record matched is a sentence somewhere inside it, and the reader was
being handed the one part guaranteed not to say so."""
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
hits = [(0.80, fake_note(id=11, title="Pool sizing decision", user_id=1))]
@@ -604,7 +604,7 @@ async def test_a_record_with_no_stored_chunk_gets_no_invented_passage():
opening would put a line of preamble under them dressed as the reason they
matched — and once indented identically, a reader cannot tell the two
apart."""
from scribe.services import plugin_context as pc
from grimoire.services import plugin_context as pc
hits = [(0.80, fake_note(id=11, title="Has a chunk", user_id=1)),
(0.78, fake_note(id=22, title="Has none", user_id=1,