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:
@@ -36,9 +36,9 @@ def _fake_rulebook(id=1, owner_user_id=7, title="FabledSword family", descriptio
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_rulebook_stores_to_db():
|
||||
mock_session = _make_mock_session()
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import create_rulebook
|
||||
from scribe.services.rulebooks import create_rulebook
|
||||
await create_rulebook(
|
||||
user_id=7, title="FabledSword family", description="rules for the family",
|
||||
)
|
||||
@@ -53,9 +53,9 @@ async def test_list_rulebooks_returns_owned_only():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalars.return_value.all.return_value = [rb]
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import list_rulebooks
|
||||
from scribe.services.rulebooks import list_rulebooks
|
||||
results = await list_rulebooks(user_id=7)
|
||||
assert len(results) == 1
|
||||
|
||||
@@ -67,9 +67,9 @@ async def test_get_rulebook_returns_none_when_not_owner():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalar_one_or_none.return_value = None
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import get_rulebook
|
||||
from scribe.services.rulebooks import get_rulebook
|
||||
result = await get_rulebook(rulebook_id=1, user_id=99)
|
||||
assert result is None
|
||||
|
||||
@@ -81,9 +81,9 @@ async def test_update_rulebook_only_sets_provided_fields():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalar_one_or_none.return_value = rb
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import update_rulebook
|
||||
from scribe.services.rulebooks import update_rulebook
|
||||
await update_rulebook(rulebook_id=1, user_id=7, title="new")
|
||||
assert rb.title == "new"
|
||||
|
||||
@@ -96,9 +96,9 @@ async def test_delete_rulebook_calls_delete():
|
||||
mock_result.scalar_one_or_none.return_value = rb
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
mock_session.delete = AsyncMock()
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import delete_rulebook
|
||||
from scribe.services.rulebooks import delete_rulebook
|
||||
await delete_rulebook(rulebook_id=1, user_id=7)
|
||||
assert mock_session.delete.called
|
||||
|
||||
@@ -128,9 +128,9 @@ async def test_create_topic_requires_owned_rulebook():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalar_one_or_none.return_value = None
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import create_topic
|
||||
from scribe.services.rulebooks import create_topic
|
||||
with pytest.raises(ValueError, match="not found"):
|
||||
await create_topic(
|
||||
rulebook_id=999, user_id=7, title="git-workflow",
|
||||
@@ -150,9 +150,9 @@ async def test_list_topics_returns_topics_for_owned_rulebook():
|
||||
topic_result.scalars.return_value.all.return_value = [topic]
|
||||
mock_session.execute = AsyncMock(side_effect=[rb_result, topic_result])
|
||||
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import list_topics
|
||||
from scribe.services.rulebooks import list_topics
|
||||
results = await list_topics(rulebook_id=1, user_id=7)
|
||||
assert len(results) == 1
|
||||
assert results[0].title == "git-workflow"
|
||||
@@ -186,9 +186,9 @@ async def test_create_rule_requires_owned_topic():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalar_one_or_none.return_value = None # topic not found
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import create_rule
|
||||
from scribe.services.rulebooks import create_rule
|
||||
with pytest.raises(ValueError, match="topic .* not found"):
|
||||
await create_rule(
|
||||
topic_id=999, user_id=7, title="x", statement="y",
|
||||
@@ -203,9 +203,9 @@ async def test_list_rules_filters_by_topic_id():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalars.return_value.all.return_value = [rule]
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import list_rules
|
||||
from scribe.services.rulebooks import list_rules
|
||||
results = await list_rules(user_id=7, topic_id=10)
|
||||
assert len(results) == 1
|
||||
|
||||
@@ -216,9 +216,9 @@ async def test_get_rule_returns_none_when_not_owner():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalar_one_or_none.return_value = None
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import get_rule
|
||||
from scribe.services.rulebooks import get_rule
|
||||
result = await get_rule(rule_id=1, user_id=99)
|
||||
assert result is None
|
||||
|
||||
@@ -232,9 +232,9 @@ async def test_subscribe_project_requires_owned_rulebook():
|
||||
mock_result = MagicMock()
|
||||
mock_result.scalar_one_or_none.return_value = None
|
||||
mock_session.execute = AsyncMock(return_value=mock_result)
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import subscribe_project
|
||||
from scribe.services.rulebooks import subscribe_project
|
||||
with pytest.raises(ValueError, match="not found"):
|
||||
await subscribe_project(
|
||||
project_id=1, rulebook_id=999, user_id=7,
|
||||
@@ -267,9 +267,9 @@ async def test_get_applicable_rules_returns_shape():
|
||||
sub_result, _empty(), _empty(), rules_result, _empty(),
|
||||
])
|
||||
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import get_applicable_rules
|
||||
from scribe.services.rulebooks import get_applicable_rules
|
||||
result = await get_applicable_rules(project_id=3, user_id=7, limit=50)
|
||||
|
||||
assert "rules" in result
|
||||
@@ -302,9 +302,9 @@ async def test_get_applicable_rules_truncates_when_over_limit():
|
||||
sub_result, _empty(), _empty(), rules_result, _empty(),
|
||||
])
|
||||
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import get_applicable_rules
|
||||
from scribe.services.rulebooks import get_applicable_rules
|
||||
result = await get_applicable_rules(project_id=3, user_id=7, limit=50)
|
||||
|
||||
assert result["truncated"] is True
|
||||
@@ -324,9 +324,9 @@ async def test_get_applicable_rules_includes_project_scoped_rules():
|
||||
_empty(), _empty(), _empty(), _empty(), proj_rules_result,
|
||||
])
|
||||
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import get_applicable_rules
|
||||
from scribe.services.rulebooks import get_applicable_rules
|
||||
result = await get_applicable_rules(project_id=3, user_id=7)
|
||||
|
||||
assert len(result["project_rules"]) == 2
|
||||
@@ -353,9 +353,9 @@ async def test_get_applicable_rules_surfaces_suppressed_with_context():
|
||||
_empty(), suppressed_rules_result, suppressed_topics_result, _empty(), _empty(),
|
||||
])
|
||||
|
||||
with patch("fabledassistant.services.rulebooks.async_session") as mock_cls:
|
||||
with patch("scribe.services.rulebooks.async_session") as mock_cls:
|
||||
mock_cls.return_value = mock_session
|
||||
from fabledassistant.services.rulebooks import get_applicable_rules
|
||||
from scribe.services.rulebooks import get_applicable_rules
|
||||
result = await get_applicable_rules(project_id=3, user_id=7)
|
||||
|
||||
assert len(result["suppressed_rules"]) == 1
|
||||
|
||||
Reference in New Issue
Block a user