This commit is contained in:
team3
2026-07-12 20:02:13 +02:00
parent 31a42bbf1d
commit cde1721d10
23 changed files with 731 additions and 219 deletions

View File

@@ -1,6 +1,7 @@
"""Struktur-Ebene: Topo-Sortierung, Zyklenbruch, Band-Schnitt — mit synthetischen Atomen."""
import db
import inventar
import llm
import struktur
from conftest import run_anlegen, topic_anlegen
@@ -224,6 +225,30 @@ def test_level_konflikt_absenkung():
assert not [b for b in struktur.messen(ctx) if b["art"] == "level_konflikt"]
async def test_braucht_fallback_kompositum():
# braucht-Titel "Approximationsalgorithmus" (Kompositum) trifft weder norm noch
# titel_kern das Atom "Approximativer Algorithmus" (Phrase). Der Fallback-Judge
# legt die Kante; _level_konflikte_loesen senkt die Voraussetzung von M auf E.
topic = topic_anlegen("brfall")
run = run_anlegen(topic)
ziel = db.insert("lernziele", topic=topic, text="Kann X", status="aktiv")
a = db.insert("atome", topic=topic, titel="Absolute Güte", typ="begriff",
definition="d", level="E", status="neu", ziel_id=ziel,
braucht=db.j(["Approximationsalgorithmus"]))
b = db.insert("atome", topic=topic, titel="Approximativer Algorithmus", typ="begriff",
definition="d", level="M", status="neu", ziel_id=ziel, braucht=db.j([]))
ctx = llm.Kontext(run, topic, "minimax")
ctx.ebene = "struktur"
inventar._kanten_aufloesen(topic) # deterministisch: verfehlt das Kompositum
assert db.query("SELECT * FROM kanten WHERE topic=? AND von_atom=?", (topic, a)) == []
await inventar._braucht_fallback(ctx)
kante = db.one("SELECT * FROM kanten WHERE topic=? AND von_atom=? AND zu_atom=?",
(topic, a, b))
assert kante and kante["art"] == "braucht"
struktur._level_konflikte_loesen(topic)
assert db.one("SELECT level FROM atome WHERE id=?", (b,))["level"] == "E"
async def test_level_split_ordnung_kapitel():
# Ein Ziel mit 4×E + 4×M → zwei Bausteine mit level, E-ord < M-ord,
# Kapitel je Durchgang, kein level_mix/kapitel_level