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
+19 -19
View File
@@ -19,9 +19,9 @@ async def test_delete_note_returns_batch_and_commits():
no_children = MagicMock()
no_children.scalars.return_value.all.return_value = []
session.execute = AsyncMock(side_effect=[_exists_result(True), no_children, MagicMock()])
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import delete
from grimoire.services.trash import delete
batch = await delete(user_id=1, entity_type="note", entity_id=5)
assert isinstance(batch, str) and len(batch) > 0
assert session.commit.called
@@ -33,9 +33,9 @@ async def test_delete_note_returns_batch_and_commits():
async def test_delete_returns_none_when_not_found():
session = make_mock_session()
session.execute = AsyncMock(return_value=_exists_result(False))
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import delete
from grimoire.services.trash import delete
batch = await delete(user_id=1, entity_type="task", entity_id=999)
assert batch is None
assert not session.commit.called
@@ -54,9 +54,9 @@ async def test_delete_project_cascades_to_notes_milestones_and_project_rules():
MagicMock(), MagicMock(), MagicMock(),
MagicMock(),
])
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import delete
from grimoire.services.trash import delete
batch = await delete(user_id=1, entity_type="project", entity_id=3)
assert isinstance(batch, str)
assert session.execute.await_count == 5
@@ -71,9 +71,9 @@ async def test_delete_rulebook_cascades_topics_and_rules():
session.execute = AsyncMock(side_effect=[
_exists_result(True), topic_ids_result, MagicMock(), MagicMock(), MagicMock(),
])
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import delete
from grimoire.services.trash import delete
batch = await delete(user_id=7, entity_type="rulebook", entity_id=2)
assert isinstance(batch, str)
assert session.execute.await_count == 5
@@ -90,9 +90,9 @@ async def test_restore_clears_batch_across_all_models():
session = make_mock_session()
# 6 soft-deletable models, each returns a rowcount
session.execute = AsyncMock(side_effect=[_rowcount_result(i) for i in [2, 0, 1, 1, 0, 0]])
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import restore
from grimoire.services.trash import restore
n = await restore(user_id=1, batch_id="abc")
assert n == 4
assert session.execute.await_count == 6
@@ -103,9 +103,9 @@ async def test_restore_clears_batch_across_all_models():
async def test_purge_expired_skips_when_retention_zero():
session = make_mock_session()
session.execute = AsyncMock()
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import purge_expired
from grimoire.services.trash import purge_expired
n = await purge_expired(1, 0)
assert n == 0
assert not session.execute.called # never opens a delete
@@ -115,9 +115,9 @@ async def test_purge_expired_skips_when_retention_zero():
async def test_purge_expired_deletes_across_models_when_positive():
session = make_mock_session()
session.execute = AsyncMock(side_effect=[_rowcount_result(1) for _ in range(6)])
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import purge_expired
from grimoire.services.trash import purge_expired
n = await purge_expired(1, 90)
assert n == 6
assert session.execute.await_count == 6
@@ -126,9 +126,9 @@ async def test_purge_expired_deletes_across_models_when_positive():
def test_owner_clause_scopes_every_model():
"""Every trash op must owner-scope, topics and rules included — a model
with no owner check is an IDOR across tenants."""
from scribe.services.trash import _owner_clause, _MODEL_FOR
from scribe.models.note import Note
from scribe.models.rulebook import Rulebook, RulebookTopic, Rule
from grimoire.services.trash import _owner_clause, _MODEL_FOR
from grimoire.models.note import Note
from grimoire.models.rulebook import Rulebook, RulebookTopic, Rule
# Models with a direct owner column.
assert "user_id" in str(_owner_clause(Note, 7))
@@ -163,9 +163,9 @@ async def test_list_trash_groups_by_batch():
empty = MagicMock()
empty.scalars.return_value.all.return_value = []
session.execute = AsyncMock(side_effect=[note_rows] + [empty] * 6)
with patch("scribe.services.trash.async_session") as cls:
with patch("grimoire.services.trash.async_session") as cls:
cls.return_value = session
from scribe.services.trash import list_trash
from grimoire.services.trash import list_trash
out = await list_trash(user_id=1)
assert len(out) == 1
assert out[0]["batch_id"] == "b1"