MVP 0.95
This commit is contained in:
1 parent
4f37991ad1
commit
be11f82f84
39 files changed
+2490
-239
No files matched your search
@@ -42,6 +42,7 @@ from journal_generation_policy import (
|
||||
publish_guideline,
|
||||
save_selection,
|
||||
seed_generation_instructions,
|
||||
set_default_guideline,
|
||||
snapshot_summary,
|
||||
update_guideline,
|
||||
validate_selection,
|
||||
@@ -214,6 +215,9 @@ def test_runtime_has_no_numeric_policy() -> None:
|
||||
expect(day.count("slot:") >= 4, "journal page has four independent slots")
|
||||
expect("<select" in day, "journal page uses select fields")
|
||||
expect("Diese Auswahl als Standard merken" in day, "journal page can remember explicitly")
|
||||
expect("if (filled) return current" in day, "settings load does not overwrite a filled selection")
|
||||
expect("Auswahl nicht mehr aktiv" in day, "stale guideline ids stay visible as invalid")
|
||||
expect("Rev. ${option.revision}" in day, "options show the guideline revision")
|
||||
expect("Faktenregeln und Datenschutz bleiben unabhängig" in day, "facts/privacy note remains")
|
||||
editor = (FRONTEND / "src" / "pages" / "JournalEditorPage.jsx").read_text(encoding="utf-8")
|
||||
expect("generation_summary" in editor, "editor can show the generation snapshot")
|
||||
@@ -232,6 +236,11 @@ def test_runtime_has_no_numeric_policy() -> None:
|
||||
trace_ui = (FRONTEND / "src" / "components" / "CallTrace.jsx").read_text(encoding="utf-8")
|
||||
expect("Editorial Mode" not in trace_ui, "trace UI does not present source mode as a run decision")
|
||||
expect("source_mode" not in trace_ui, "trace UI has no source_mode label")
|
||||
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("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")
|
||||
|
||||
|
||||
def test_seed_and_compiler() -> None:
|
||||
@@ -493,6 +502,27 @@ def main() -> None:
|
||||
expect((rejected.json().get("detail") or {}).get("code") == "invalid_generation_selection", "rejection uses the selection code")
|
||||
after_reject = client.get("/api/journal/generation-settings", headers=headers).json()
|
||||
expect(after_reject["selection"] == default_ids(), "rejected values are not stored")
|
||||
save_selection(profile_id, low_ids())
|
||||
set_default_guideline(seed_id("transformation", "substantial"))
|
||||
expect(load_selection(profile_id)["transformation_id"] == seed_id("transformation", "correction"), "setting a catalog default does not rewrite a stored selection")
|
||||
save_selection(profile_id, default_ids())
|
||||
blocked_calls = {"n": 0}
|
||||
|
||||
def no_provider(*_a, **_k):
|
||||
blocked_calls["n"] += 1
|
||||
raise AssertionError("invalid selection must not call a provider")
|
||||
|
||||
with patch("privacy_gateway.complete_model", no_provider), patch("entity_detect.complete_chat", no_provider):
|
||||
before_provider = client.post(
|
||||
f"/api/journal/days/{day.json()['day']['id']}/generate",
|
||||
headers=headers,
|
||||
json={
|
||||
"conversation_ids": [conv.json()["id"]],
|
||||
"generation_selection": {**default_ids(), "transformation_id": "missing"},
|
||||
},
|
||||
)
|
||||
expect(before_provider.status_code == 400, "invalid selection still fails closed")
|
||||
expect(blocked_calls["n"] == 0, "invalid selection aborts before detect and generate")
|
||||
|
||||
draft = client.post(
|
||||
"/api/admin/generation-instructions/journal_generate",
|
||||
@@ -575,6 +605,53 @@ def main() -> None:
|
||||
for fact in HARD_FACTS:
|
||||
expect(fact in intern, f"hard fact remains at low policy: {fact}")
|
||||
|
||||
copyedit_ids = selection_of(
|
||||
transformation="copyedit",
|
||||
detail="complete",
|
||||
voice="clear",
|
||||
narrative="weighted",
|
||||
)
|
||||
reset_debug()
|
||||
copyedit_recorder = install_test_recorder()
|
||||
copyedit_run = client.post(
|
||||
f"/api/journal/days/{day.json()['day']['id']}/generate",
|
||||
headers=headers,
|
||||
json={
|
||||
"conversation_ids": [conv.json()["id"]],
|
||||
"generation_selection": copyedit_ids,
|
||||
"remember_generation_selection": False,
|
||||
},
|
||||
)
|
||||
expect(copyedit_run.status_code == 200, f"copyedit generate {copyedit_run.text}")
|
||||
copyedit_meta = selection_meta(copyedit_run.json())
|
||||
copyedit_intern = intern_of(copyedit_run.json())
|
||||
copyedit_snap = copyedit_run.json().get("generation_snapshot") or {}
|
||||
expect(copyedit_meta.get("ids") == {
|
||||
"transformation": seed_id("transformation", "copyedit"),
|
||||
"detail": seed_id("detail", "complete"),
|
||||
"voice": seed_id("voice", "clear"),
|
||||
"narrative": seed_id("narrative", "weighted"),
|
||||
}, "copyedit request ids reach the trace")
|
||||
expect(copyedit_meta.get("keys", {}).get("transformation") == "copyedit", "copyedit key reaches the trace")
|
||||
expect(copyedit_meta.get("revisions", {}).get("transformation") == 1, "copyedit revision reaches the trace")
|
||||
expect(copyedit_meta.get("revisions", {}).get("narrative") == 1, "weighted revision of the selected id reaches the trace")
|
||||
expect(copyedit_snap.get("transformation", {}).get("id") == seed_id("transformation", "copyedit"), "snapshot stores the selected copyedit id")
|
||||
expect(copyedit_snap.get("transformation", {}).get("revision") == 1, "snapshot stores the selected copyedit revision")
|
||||
expect(copyedit_snap.get("narrative", {}).get("id") == seed_id("narrative", "weighted"), "snapshot stores the selected weighted id")
|
||||
expect(seed_instruction("transformation", "copyedit") in copyedit_intern, "selected copyedit instruction reaches the prompt")
|
||||
expect(seed_instruction("narrative", "weighted") in copyedit_intern, "selected weighted instruction reaches the prompt")
|
||||
expect(seed_instruction("transformation", "substantial") not in copyedit_intern, "unselected substantial instruction is absent")
|
||||
expect([item.get("purpose") for item in copyedit_recorder] == ["journal_generate"], "copyedit still uses one generate call")
|
||||
preview = client.post(
|
||||
"/api/admin/generation-instructions/journal_generate/preview",
|
||||
headers=headers,
|
||||
json={"generation_selection": copyedit_ids},
|
||||
)
|
||||
expect(preview.status_code == 200, f"copyedit preview {preview.text}")
|
||||
expect(preview.json()["transformation_instructions"] == seed_instruction("transformation", "copyedit"), "preview compiles the same copyedit instruction")
|
||||
expect(preview.json().get("selection", {}).get("ids", {}).get("transformation") == seed_id("transformation", "copyedit"), "preview reports the same copyedit id")
|
||||
expect(preview.json().get("selection", {}).get("revisions", {}).get("narrative") == 1, "preview reports the same weighted revision")
|
||||
|
||||
notes_day = client.post(
|
||||
f"/api/journal/spaces/{space.json()['id']}/days",
|
||||
headers=headers,
|
||||
@@ -789,6 +866,7 @@ def main() -> None:
|
||||
headers=headers,
|
||||
)
|
||||
expect(published.status_code == 200, f"publish {published.text}")
|
||||
expect(load_selection(profile_id)["transformation_id"] == seed_id("transformation", "substantial"), "publishing a clone does not rewrite the stored selection")
|
||||
immutable = client.put(
|
||||
f"/api/admin/generation-instructions/journal_generate/{seed_id('transformation', 'substantial')}",
|
||||
headers=headers,
|
||||
|
||||
Reference in new issue
Block a user