Answer architecture round 6: split rules into ruling, rounds, base and scoring modules, read the fall sequence as one Fall state, and give the plan's reasons and the fall's their own functions

This commit is contained in:
2026-10-09 11:53:08 +02:00
parent 9ca791435f
commit 4cda8551b4
7 changed files with 260 additions and 243 deletions
+29
View File
@@ -0,0 +1,29 @@
from larv_review.history import entries, Entry, HistoryChange
def measured_commit(changes: list[HistoryChange]) -> str | None:
"""The newest change, of changes given newest first, whose last added paired ruling is better, or that adds a scoring run and whose last added paired ruling names no fall."""
for change in changes:
held = {entry.heading for entry in entries(change.before)}
added = [entry for entry in entries(change.after) if entry.heading not in held]
rulings = sorted((entry for entry in added if entry.paired), key=lambda entry: entry.time)
last = rulings[-1] if rulings else None
ruled_better = last is not None and last.ruling == "better"
scored_without_fall = any(not entry.paired for entry in added) and not (last and last.fell)
if ruled_better or scored_without_fall:
return change.commit
return None
def first_ruling(history: str) -> Entry | None:
rulings = sorted((entry for entry in entries(history) if entry.paired), key=lambda entry: entry.time)
return rulings[0] if rulings else None
def base(changes: list[HistoryChange], history: str) -> tuple[str, str] | None:
"""The commit a paired ruling reads against, and which fallback found it; None leaves the merge base of HEAD and the default branch. history is the default branch's."""
if found := measured_commit(changes):
return found, "the last measured commit"
if (first := first_ruling(history)) and first.against:
return first.against, "the base the history's first paired ruling names"
return None