This commit is contained in:
team3
2026-07-10 17:36:28 +02:00
parent 917b3ac702
commit ab1a28f0e7
8 changed files with 98 additions and 6 deletions

View File

@@ -297,6 +297,38 @@ def _bausteine_ordnen(topic: str, kanten: list[tuple[int, int]], rang: dict) ->
db.update("bausteine", "id", b_id, ord=pos)
async def _level_kalibrieren(ctx: llm.Kontext) -> None:
"""Stufen als Komplexitätsschichten (4C/ID): Die Extraktion sieht nur ihren
Chunk und stuft absolut (aak: 13 % E → Einstiegs-Durchgang war ein
Lücken-Gerippe). Hier stuft ein Judge je Baustein RELATIV nach — er sieht
alle Atome nebeneinander. E-Atome müssen allein einen kohärenten
Kurzdurchgang tragen; rein vertiefende Bausteine bleiben ohne E."""
bausteine = db.query("SELECT * FROM bausteine WHERE topic=?", (ctx.topic,))
atome = _atome(ctx.topic)
async def einer(b: dict) -> None:
eigene = [a for a in atome if a["baustein_id"] == b["id"]]
if not eigene:
return
# bewusst OHNE bisheriges Level: der Extraktions-Prior ist verzerrt
# (Chunk-blind, M-Anchoring) und würde die Neubewertung ankern
liste = "\n".join(f"{a['id']}: {a['titel']}{a['definition']}" for a in eigene)
res = await llm.call(ctx, stage="level", template="Level-Kalibrierung",
werte={"titel": b["titel"], "atome": liste},
role="judge", n=len(eigene), item=f"lv{b['id']}",
erwartet=list)
gueltig = {a["id"]: a["level"] for a in eigene}
for e in res or []:
if not isinstance(e, dict):
continue
atom_id = e.get("atom")
level = str(e.get("level", "")).strip().upper()
if atom_id in gueltig and level in ("E", "M", "S") and level != gueltig[atom_id]:
db.update("atome", "id", atom_id, level=level)
await llm.alle(einer(b) for b in bausteine)
async def _kapitel_bilden(ctx: llm.Kontext) -> None:
"""Kapitel = kontiguierliche Segmente der geordneten Baustein-Folge. Das Soll
ist seit der Entkopplung reine Checkliste — Kapitel sind Struktur. Der Judge
@@ -360,6 +392,7 @@ async def bauen(ctx: llm.Kontext) -> None:
await _ziele_bilden(ctx)
await _zyklen_brechen(ctx)
_bausteine_schneiden(ctx)
await _level_kalibrieren(ctx)
await _kapitel_bilden(ctx)
@@ -420,5 +453,6 @@ async def reparieren(ctx: llm.Kontext, befunde: list[dict]) -> bool:
await _ziele_bilden(ctx) # fängt Partition-Lücken
await _zyklen_brechen(ctx) # fängt Zyklen
_bausteine_schneiden(ctx) # Neu-Schnitt fängt Band + Vorwärts-Kanten
await _level_kalibrieren(ctx)
await _kapitel_bilden(ctx) # fängt Kapitel-Befunde
return True