Files
DECNET/tests/orchestrator/emailgen/test_threads.py
anti 3ee55ec341 feat(emailgen): Ollama-driven fake email worker for IMAP/POP3 deckies
Second orchestrator worker (decnet emailgen) that drips persona-driven,
threaded, multi-language fake emails into running mail deckies.  Personas
live on Topology.email_personas; topology-wide language_default falls
through to any persona that doesn't pin its own.  Em-dashes are
suppressed at the prompt layer by default and only lifted for personas
explicitly marked uses_llms_heavily — em-dashes are an LLM tell and a
flat corpus of em-dashed mail is a giveaway.

EML delivery writes into /var/spool/decnet-emails/<thread>/<msg>.eml on
the mail decky via docker exec; wiring the IMAP/POP3 templates to read
from that spool (replacing the hardcoded _BAIT_EMAILS) is the next step.
2026-04-26 22:16:19 -04:00

62 lines
1.5 KiB
Python

"""Thread-chain helpers."""
from __future__ import annotations
from decnet.orchestrator.emailgen.threads import (
ThreadChain,
new_message_id,
new_thread_id,
references_for_reply,
reply_subject,
)
def test_new_thread_id_is_uuid_string():
tid = new_thread_id()
assert len(tid) == 36
assert tid.count("-") == 4
def test_new_message_id_format_with_domain():
mid = new_message_id("example.com")
assert mid.startswith("<") and mid.endswith(">")
assert "@example.com" in mid
def test_new_message_id_handles_blank_domain():
mid = new_message_id(" ")
assert "@localhost" in mid
def test_reply_subject_prepends_re():
assert reply_subject("Q3 budget") == "Re: Q3 budget"
def test_reply_subject_collapses_existing_re():
assert reply_subject("Re: Re: Q3 budget") == "Re: Q3 budget"
assert reply_subject("RE: Q3 budget") == "Re: Q3 budget"
def test_references_for_reply_root_is_empty():
assert references_for_reply(None) == ""
def test_references_for_reply_appends_parent():
chain = ThreadChain(
thread_id="t1",
parent_message_id="<m2@x>",
references=("<m1@x>",),
parent_subject="Re: budget",
)
refs = references_for_reply(chain)
assert refs == "<m1@x> <m2@x>"
def test_references_empty_chain_starts_with_parent_only():
chain = ThreadChain(
thread_id="t1",
parent_message_id="<m1@x>",
references=(),
parent_subject="budget",
)
assert references_for_reply(chain) == "<m1@x>"