MVP 0.94
This commit is contained in:
1 parent
f17b3083e8
commit
4f37991ad1
48 files changed
+4919
-540
No files matched your search
@@ -49,21 +49,25 @@ def test_active_prompt_contract() -> None:
|
||||
init_db()
|
||||
prompt = load_active_prompt("mvp.journal_generate")
|
||||
text = prompt.get("template") or ""
|
||||
expect("Faktentreue ist nicht Wortlauttreue" in text, "active prompt separates fact fidelity from wording")
|
||||
expect("INHALTSTREUE" in text, "active prompt keeps hard content rules")
|
||||
expect("CURRENT_DAY_SOURCES" in text, "active prompt labels current-day facts")
|
||||
expect("STYLE_EXAMPLES" in text, "active prompt labels style examples")
|
||||
expect("Rechtschreibung" in text or "korrigieren" in text, "active prompt allows spelling and grammar fixes")
|
||||
expect("Unsicherheit bleibt Unsicherheit" in text, "active prompt keeps semantic uncertainty")
|
||||
expect("keine neuen Informationen" in text.lower() or "Keine neuen Informationen" in text, "active prompt still forbids new facts")
|
||||
expect("Verneinungen" in text and "Unsicherheiten" in text, "active prompt keeps semantic uncertainty")
|
||||
expect("keine neuen tatsachen" in text.lower(), "active prompt still forbids new facts")
|
||||
expect("Plan und Vollzug" in text, "active prompt keeps plan versus completion")
|
||||
expect("[[…" not in text and "[[..." not in text, "active prompt must not teach ellipsis placeholders")
|
||||
expect("Nur den verifizierten Nutzerwortlaut" not in text, "old wording-as-output rule is gone")
|
||||
expect("Unsicherheiten im Wortlaut" not in text, "old keep-uncertainty-in-wording rule is gone")
|
||||
expect("{{transformation_instructions}}" in text, "active prompt uses compiled transformation instructions")
|
||||
expect("{{source_mode_instructions}}" not in text, "active prompt has no source-mode placeholder")
|
||||
expect("Zwinge nicht den gesamten Tag in einen einzigen Quellenmodus." in text, "active prompt has mixed-source instruction")
|
||||
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-placeholders-v1", "system prompt revision is stored")
|
||||
expect(row["seed_revision"] == "2026-08-27-journal-mixed-sources-v1", "system prompt revision is stored")
|
||||
expect(row["template"] == row["default_template"], "untouched install uses the seeded template")
|
||||
|
||||
|
||||
@@ -118,6 +122,24 @@ def test_unattested_identity_is_journal_not_privacy() -> None:
|
||||
is None,
|
||||
"food homonym of an unused mapping is not unattested identity",
|
||||
)
|
||||
expect(
|
||||
unattested_journal_content(
|
||||
"Clarissa kam ins Wohnzimmer.",
|
||||
["Heute war Sushi im Wohnzimmer."],
|
||||
[
|
||||
{
|
||||
"local_label": "Clarissa",
|
||||
"canonical_label": "Clarissa",
|
||||
"token": "PERSON:01",
|
||||
"aliases": ["Sushi"],
|
||||
"demask_label": "Clarissa",
|
||||
}
|
||||
],
|
||||
["PERSON:01"],
|
||||
)
|
||||
is None,
|
||||
"confirmed alias in the source attests the canonical demasked spelling",
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -165,11 +187,11 @@ def main() -> None:
|
||||
for stage in (gen.json().get("trace") or {}).get("stages") or []:
|
||||
if stage.get("purpose") == "journal_generate":
|
||||
intern = stage.get("intern") or ""
|
||||
style = intern.split("CURRENT_DAY_SOURCES")[0]
|
||||
style = intern.split("\nCURRENT_DAY_SOURCES\n")[0]
|
||||
expect("Neutraler Journalstil" in style, "neutral style reaches the generate prompt")
|
||||
expect("Erzählmerkmale" not in style, "current day dialogue is not a style brief")
|
||||
expect("zimlich" not in style, "today's typo is not a style exemplar")
|
||||
expect("Faktentreue ist nicht Wortlauttreue" in intern, "runtime intern uses the new narration contract")
|
||||
expect("INHALTSTREUE" in intern, "runtime intern uses the new narration contract")
|
||||
expect("CURRENT_DAY_SOURCES" in intern, "runtime intern labels current-day facts")
|
||||
expect("Nur den verifizierten Nutzerwortlaut" not in intern, "old output-wording rule is not in the runtime prompt")
|
||||
expect("Unsicherheiten im Wortlaut" not in intern, "old uncertainty-in-wording rule is not in the runtime prompt")
|
||||
@@ -252,7 +274,7 @@ def main() -> None:
|
||||
for stage in (second.json().get("trace") or {}).get("stages") or []:
|
||||
if stage.get("purpose") == "journal_generate":
|
||||
intern2 = stage.get("intern") or ""
|
||||
expect("trockener Schnitt" in intern2.split("CURRENT_DAY_SOURCES")[0], "confirmed writing profile reaches generate")
|
||||
expect("trockener Schnitt" in intern2.split("\nCURRENT_DAY_SOURCES\n")[0], "confirmed writing profile reaches generate")
|
||||
|
||||
def invent(_messages, _policy):
|
||||
return ChatResult(
|
||||
@@ -268,13 +290,14 @@ def main() -> None:
|
||||
headers=headers,
|
||||
json={"conversation_ids": [conv.json()["id"]]},
|
||||
)
|
||||
expect(blocked.status_code == 200, f"unattested generate {blocked.text}")
|
||||
log = blocked.json().get("run_log") or []
|
||||
expect(any(item.get("reason") == "unattested_identity" for item in log), "unattested person uses local fallback")
|
||||
expect(any(item.get("status") == "local_fallback" for item in log), "fallback path is distinct from the model path")
|
||||
expect("Clarissa" not in (blocked.json().get("body") or ""), "unattested person is not in the accepted draft")
|
||||
expect("markt" in (blocked.json().get("body") or "").lower(), "fallback still has the user sources")
|
||||
expect("rote tasche" in (blocked.json().get("body") or "").lower(), "fallback keeps the unique source detail")
|
||||
expect(blocked.status_code == 409, f"unattested generate {blocked.text}")
|
||||
detail = blocked.json().get("detail") or {}
|
||||
expect(detail.get("code") == "journal_generation_not_accepted", "unattested person is not stored as a draft")
|
||||
expect(detail.get("message") == "Generierung nicht übernommen.", "API names the rejection")
|
||||
log = (detail.get("diagnostics") or {}).get("log") or []
|
||||
expect(any(item.get("reason") == "unattested_identity" for item in log), "unattested person is a provenance reject")
|
||||
expect(any(item.get("status") == "not_accepted" for item in log), "reject path is distinct from the model path")
|
||||
expect("Clarissa" not in json.dumps((detail.get("diagnostics") or {}).get("log") or []), "clear labels stay out of compact logs")
|
||||
|
||||
with get_db() as conn:
|
||||
conn.execute(
|
||||
@@ -289,8 +312,8 @@ def main() -> None:
|
||||
"SELECT default_template, seed_revision FROM ai_prompts WHERE slug = ?",
|
||||
("mvp.journal_generate",),
|
||||
).fetchone()
|
||||
expect("Faktentreue ist nicht Wortlauttreue" in (row["default_template"] or ""), "default template still tracks the seed")
|
||||
expect(row["seed_revision"] == "2026-08-27-journal-placeholders-v1", "revision updates even when template is custom")
|
||||
expect("INHALTSTREUE" in (row["default_template"] or ""), "default template still tracks the seed")
|
||||
expect(row["seed_revision"] == "2026-08-27-journal-mixed-sources-v1", "revision updates even when template is custom")
|
||||
|
||||
print("journal narration tests passed.")
|
||||
|
||||
|
||||
Reference in new issue
Block a user