refactor(realism): move emailgen LLM/personas/prompt into shared library
Lift the format-agnostic pieces from decnet/orchestrator/emailgen/
into the new decnet/realism/ library so file-class content generation
(stage 3 of the realism migration) can reuse them. Email-specific
delivery (RFC 2822 EML, IMAP/POP3 spool, thread chains) stays in
orchestrator/.
Renames (history-preserving git mv):
emailgen/personas.py -> realism/personas.py
emailgen/prompt.py -> realism/prompts/email.py
emailgen/global_pool.py -> realism/personas_pool.py
emailgen/llm/ -> realism/llm/
Env-var clean break (pre-v1, no aliases):
DECNET_EMAILGEN_LLM -> DECNET_REALISM_LLM
DECNET_EMAILGEN_MODEL -> DECNET_REALISM_MODEL
DECNET_EMAILGEN_TIMEOUT -> DECNET_REALISM_TIMEOUT
DECNET_EMAILGEN_PERSONAS -> DECNET_REALISM_PERSONAS
DECNET_EMAILGEN_FAKE_OUTPUT -> DECNET_REALISM_FAKE_OUTPUT
Importers rewritten in: orchestrator/emailgen/scheduler.py,
orchestrator/drivers/email.py, web/router/{emailgen,topology}/
api_personas.py, cli/emailgen.py. Tests for moved modules relocated
to tests/realism/; tests for stay-put modules updated in place.
API URL `/api/v1/emailgen/personas` and CLI `decnet emailgen
import-personas` keep their public names until the service-collapse
commit (stage 5).
This commit is contained in:
@@ -7,7 +7,8 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from decnet.orchestrator.emailgen import global_pool, scheduler
|
||||
from decnet.orchestrator.emailgen import scheduler
|
||||
from decnet.realism import personas_pool as global_pool
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -147,7 +148,7 @@ async def test_pick_for_fleet_source_uses_global_pool(tmp_path, monkeypatch):
|
||||
personas come from the host-wide JSON file."""
|
||||
pool_file = tmp_path / "personas.json"
|
||||
pool_file.write_text(json.dumps(_PERSONAS_TWO))
|
||||
monkeypatch.setenv("DECNET_EMAILGEN_PERSONAS", str(pool_file))
|
||||
monkeypatch.setenv("DECNET_REALISM_PERSONAS", str(pool_file))
|
||||
|
||||
repo = _FakeRepo(
|
||||
deckies=[_decky(source="fleet", topology_id=None)],
|
||||
@@ -163,7 +164,7 @@ async def test_pick_for_shard_source_uses_global_pool(tmp_path, monkeypatch):
|
||||
"""SWARM shards are non-topology too — same path as fleet."""
|
||||
pool_file = tmp_path / "personas.json"
|
||||
pool_file.write_text(json.dumps(_PERSONAS_TWO))
|
||||
monkeypatch.setenv("DECNET_EMAILGEN_PERSONAS", str(pool_file))
|
||||
monkeypatch.setenv("DECNET_REALISM_PERSONAS", str(pool_file))
|
||||
|
||||
repo = _FakeRepo(
|
||||
deckies=[_decky(source="shard", topology_id=None)],
|
||||
@@ -174,7 +175,7 @@ async def test_pick_for_shard_source_uses_global_pool(tmp_path, monkeypatch):
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pick_fleet_with_empty_global_pool_returns_none(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("DECNET_EMAILGEN_PERSONAS", str(tmp_path / "missing.json"))
|
||||
monkeypatch.setenv("DECNET_REALISM_PERSONAS", str(tmp_path / "missing.json"))
|
||||
repo = _FakeRepo(deckies=[_decky(source="fleet", topology_id=None)])
|
||||
assert await scheduler.pick(repo, now=datetime(2026, 4, 26, 12, 0, 0)) is None
|
||||
|
||||
@@ -191,7 +192,7 @@ async def test_topology_personas_isolated_from_global_pool(tmp_path, monkeypatch
|
||||
"tone": "casual",
|
||||
"mannerisms": [],
|
||||
}]))
|
||||
monkeypatch.setenv("DECNET_EMAILGEN_PERSONAS", str(pool_file))
|
||||
monkeypatch.setenv("DECNET_REALISM_PERSONAS", str(pool_file))
|
||||
|
||||
repo = _FakeRepo(
|
||||
deckies=[_decky()],
|
||||
|
||||
Reference in New Issue
Block a user