This commit is contained in:
Lars committed 2026-08-29 20:28:59 +02:00
1 parent be11f82f84
commit e42f751fdc
47 files changed
+3359 -301

No files matched your search

@@ -60,7 +60,6 @@ HARD_FACTS = (
"Plan und Vollzug",
"Verneinungen",
"Unsicherheiten",
"STYLE_EXAMPLES dienen ausschließlich als Stilreferenz",
"[[PERSON:01]]",
)
BANNED_CODE_PHRASES = (
@@ -101,6 +100,11 @@ REQUIRED_KEYS = {
("voice", "light"),
("voice", "noticeable"),
("voice", "clear"),
("voice", "with_examples"),
("voice", "legacy_neutral"),
("voice", "legacy_light"),
("voice", "legacy_noticeable"),
("voice", "legacy_clear"),
("narrative", "chronicle"),
("narrative", "structured"),
("narrative", "weighted"),
@@ -209,7 +213,9 @@ def test_runtime_has_no_numeric_policy() -> None:
continue
expect(not has_token(text, token), f"{path.name} has no {token}")
day = (FRONTEND / "src" / "pages" / "JournalDayPage.jsx").read_text(encoding="utf-8")
expect('type="range"' not in day, "journal page has no sliders")
expect("Stilquellen" in day, "voice select can show which style sources apply")
expect("type=\"range\"" not in day, "journal page has no extra sliders for style context")
expect(day.count("<select") == 1, "journal page maps four slots onto one select, not extra style-context fields")
expect("policy-slider" not in day, "journal page has no slider class")
expect("SLOT_SELECTS" in day, "journal page names the four selects")
expect(day.count("slot:") >= 4, "journal page has four independent slots")
@@ -224,7 +230,10 @@ def test_runtime_has_no_numeric_policy() -> None:
admin = (FRONTEND / "src" / "pages" / "AdminGenerationPage.jsx").read_text(encoding="utf-8")
expect("<textarea" not in admin.split("generation-admin-editor")[0], "admin overview has no textareas")
expect(admin.count("<textarea") == 1, "admin opens one instruction editor at a time")
expect("Öffnen" in admin, "admin overview has open action")
expect("Stilquellen für diese Ausprägung" in admin, "admin edits style context with the instruction")
expect("Vorgänger" in admin, "admin shows predecessor or clone origin")
expect("include_core" in admin, "admin names core inclusion")
expect("Writing-Profile-Core" in admin, "admin labels core in German product terms")
expect("backend/config/" not in admin, "admin copy does not advertise seed file paths")
expect("Quellenmodus" not in admin, "admin has no source-mode management")
expect("source_mode" not in admin, "admin source has no source_mode slot")
@@ -239,6 +248,8 @@ def test_runtime_has_no_numeric_policy() -> None:
expect("Chunks technisch verarbeitet" in trace_ui, "trace separates technical chunk coverage")
expect("Semantische Identitätserkennung" in trace_ui, "trace names semantic uncertainty")
expect("nicht garantiert" in trace_ui, "trace does not claim semantic completeness")
expect("Stilanwendung" in trace_ui, "trace shows requested versus effective style application")
expect("cloned_from" in trace_ui, "trace can show the predecessor id")
expect("Gespeicherter Entwurf" in trace_ui, "trace shows the stored draft")
expect("Technisch verarbeitete Chunks bedeuten keine vollständige" in trace_ui, "trace explains coverage is not identity certainty")
@@ -275,8 +286,22 @@ def test_seed_and_compiler() -> None:
"default narrative instruction matches the seed",
)
expect(defaults.seed_revision == SEED["seed_revision"], "compiled policy names the seed revision")
expect(defaults.style_context["include_core"] is True, "default voice includes core")
expect(defaults.style_context["include_facet"] is True, "default voice includes facet")
expect(defaults.style_context["include_traits"] is True, "default voice includes traits")
expect(defaults.style_context["include_style_examples"] is False, "default voice omits style examples")
expect("source_mode_instructions" not in defaults.instructions, "compiler has no source-mode instruction")
free = compile_selection({**default_selection_ids(), "voice_id": seed_id("voice", "neutral")})
expect(free.style_context == {
"include_core": False,
"include_facet": False,
"include_traits": False,
"include_style_examples": False,
}, "profile-free voice selects no style sources")
examples = compile_selection({**default_selection_ids(), "voice_id": seed_id("voice", "with_examples")})
expect(all(examples.style_context.values()), "with-examples voice selects all style sources")
low = compile_selection(low_ids())
high = compile_selection(high_ids())
expect(low.keys["transformation"] == "correction", "low transformation is named")
@@ -389,18 +414,19 @@ def test_prompt_contract() -> None:
expect("{{editorial_mode}}" not in text, "prompt has no editorial_mode placeholder")
expect("{{editorial_instructions}}" not in text, "prompt has no editorial_instructions placeholder")
expect(MIXED_SOURCES_INSTRUCTION in text, "prompt contains the mixed-source instruction")
expect("STYLE_EXAMPLES dienen ausschließlich" not in text, "standing prompt has no orphaned STYLE_EXAMPLES sentence")
for fact in HARD_FACTS:
expect(fact in text, f"hard fact rule remains: {fact}")
expect("ich gieng zum laden" not in text, "no synthetic prose example")
expect("nachbarhund im garten" not in text, "no synthetic notes example")
expect("EDITORIAL_MODE" not in text, "source mode is not a user-facing prompt heading")
expect(GENERATE_SEED_REVISION == "2026-08-27-journal-mixed-sources-v1", "seed revision constant tracks mixed sources")
expect(GENERATE_SEED_REVISION == "2026-08-29-voice-legacy-immutable-v1", "seed revision constant tracks immutable voice catalog")
with get_db() as conn:
row = conn.execute(
"SELECT seed_revision, template, default_template FROM ai_prompts WHERE slug = ?",
("mvp.journal_generate",),
).fetchone()
expect(row["seed_revision"] == "2026-08-27-journal-mixed-sources-v1", "untouched default is updated to mixed sources")
expect(row["seed_revision"] == "2026-08-29-voice-legacy-immutable-v1", "untouched default is updated to immutable voice catalog")
expect(row["template"] == row["default_template"], "untouched template matches the seed")
expect("source_mode" not in (SEED.get("slots") or {}), "source modes stay out of the seed")
@@ -1019,7 +1045,7 @@ def main() -> None:
).fetchone()
expect("{{transformation_instructions}}" in (row["default_template"] or ""), "default template still tracks mixed sources")
expect(MIXED_SOURCES_INSTRUCTION in (row["default_template"] or ""), "default template has mixed-source instruction")
expect(row["seed_revision"] == "2026-08-27-journal-mixed-sources-v1", "revision updates even when template is custom")
expect(row["seed_revision"] == "2026-08-29-voice-legacy-immutable-v1", "revision updates even when template is custom")
readable = snapshot_summary(
{