refactor: rename package fabledassistant -> scribe (code-only)
Renames src/fabledassistant -> src/scribe and all imports, plus the default DB name and DB user/password (fabled -> scribe) in config + compose. 952 refs / 154 files. Reverses the old 'internal name stays fabledassistant' convention. Code-only: live databases are still physically named 'fabledassistant'. Deployed environments must set POSTGRES_DB / POSTGRES_USER (or rename the DB) since the defaults now resolve to 'scribe'. Repo (FabledScribe), git host (fabledsword), MCP (fabled-git) and the image name (fabledscribe) are intentionally unchanged. ruff check src/ clean locally; CI (typecheck + pytest) is the gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,9 +26,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("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import delete
|
||||
from scribe.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
|
||||
@@ -40,9 +40,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("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import delete
|
||||
from scribe.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
|
||||
@@ -63,9 +63,9 @@ async def test_delete_project_cascades_to_notes_milestones_project_rules_and_sup
|
||||
MagicMock(), MagicMock(),
|
||||
MagicMock(),
|
||||
])
|
||||
with patch("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import delete
|
||||
from scribe.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 == 7
|
||||
@@ -80,9 +80,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("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import delete
|
||||
from scribe.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
|
||||
@@ -99,9 +99,9 @@ async def test_restore_clears_batch_across_all_models():
|
||||
session = _make_mock_session()
|
||||
# 7 models, each returns a rowcount
|
||||
session.execute = AsyncMock(side_effect=[_rowcount_result(i) for i in [2, 0, 1, 1, 0, 0, 0]])
|
||||
with patch("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import restore
|
||||
from scribe.services.trash import restore
|
||||
n = await restore(user_id=1, batch_id="abc")
|
||||
assert n == 4
|
||||
assert session.execute.await_count == 7
|
||||
@@ -112,9 +112,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("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import purge_expired
|
||||
from scribe.services.trash import purge_expired
|
||||
n = await purge_expired(1, 0)
|
||||
assert n == 0
|
||||
assert not session.execute.called # never opens a delete
|
||||
@@ -124,9 +124,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(7)])
|
||||
with patch("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import purge_expired
|
||||
from scribe.services.trash import purge_expired
|
||||
n = await purge_expired(1, 90)
|
||||
assert n == 7
|
||||
assert session.execute.await_count == 7
|
||||
@@ -135,9 +135,9 @@ async def test_purge_expired_deletes_across_models_when_positive():
|
||||
def test_owner_clause_scopes_every_model():
|
||||
"""Regression: every trash op must owner-scope, including topics/rules
|
||||
which previously had NO owner check (IDOR across tenants)."""
|
||||
from fabledassistant.services.trash import _owner_clause, _MODEL_FOR
|
||||
from fabledassistant.models.note import Note
|
||||
from fabledassistant.models.rulebook import Rulebook, RulebookTopic, Rule
|
||||
from scribe.services.trash import _owner_clause, _MODEL_FOR
|
||||
from scribe.models.note import Note
|
||||
from scribe.models.rulebook import Rulebook, RulebookTopic, Rule
|
||||
|
||||
# Models with a direct owner column.
|
||||
assert "user_id" in str(_owner_clause(Note, 7))
|
||||
@@ -172,9 +172,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("fabledassistant.services.trash.async_session") as cls:
|
||||
with patch("scribe.services.trash.async_session") as cls:
|
||||
cls.return_value = session
|
||||
from fabledassistant.services.trash import list_trash
|
||||
from scribe.services.trash import list_trash
|
||||
out = await list_trash(user_id=1)
|
||||
assert len(out) == 1
|
||||
assert out[0]["batch_id"] == "b1"
|
||||
|
||||
Reference in New Issue
Block a user