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:
+30
-27
@@ -87,9 +87,12 @@ import sys
|
||||
import time
|
||||
import typing
|
||||
|
||||
from larv_review.history import appended, Entry, heading, ruling_entry, scoring_entry, vote_text
|
||||
from larv_review.rules import base, CAP, chunk_entries, counted, fall_outcome, fallen, FLOOR, floor_verdict, means, PASSES, pending_fall, plan_items, round_counts, ruling, scoring_run_due, standing_ratchet, uncalled, under_floor, votes
|
||||
from larv_review.history import appended, heading, ruling_entry, scoring_entry, vote_text
|
||||
from larv_review.base import base
|
||||
from larv_review.rounds import CAP, PASSES, round_counts
|
||||
from larv_review.scoring import chunk_entries, fall, Fall, fall_outcome, fall_reasons, FLOOR, floor_verdict, means, plan_items, scoring_run_due, uncalled, under_floor
|
||||
from larv_review.git import commit_exists, default_branch, file_at, git, HISTORY, history_changes, landed_since_release, top
|
||||
from larv_review.ruling import counted, fallen, ruling, votes
|
||||
from larv_review.seats import DIMENSIONS, MEAN, Report, report, score_line, scores
|
||||
from failure import Failure
|
||||
from rank_todo import ITEMS_HEADER
|
||||
@@ -166,20 +169,21 @@ def round_count(default: str) -> Failure | None:
|
||||
|
||||
|
||||
def needs_scoring_run(default: str, ids: list[int]) -> Failure | None:
|
||||
recorded = chunk_history(default)
|
||||
if isinstance(recorded, Failure):
|
||||
return recorded
|
||||
reasons = due_reasons(default, ids, pending_fall(recorded))
|
||||
if isinstance(reasons, Failure):
|
||||
return reasons
|
||||
state = chunk_fall(default)
|
||||
if isinstance(state, Failure):
|
||||
return state
|
||||
planned = plan_reasons(default, ids)
|
||||
if isinstance(planned, Failure):
|
||||
return planned
|
||||
reasons = planned + fall_reasons(state)
|
||||
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")
|
||||
if ratchet := standing_ratchet(recorded):
|
||||
print(f"Still standing: {ratchet} Fix it and rule again.")
|
||||
if state.ratchet:
|
||||
print(f"Still standing: {state.ratchet} Fix it and rule again.")
|
||||
return None
|
||||
|
||||
|
||||
def due_reasons(default: str, ids: list[int], fell: list[str]) -> list[str] | Failure:
|
||||
"""Why the chunk is due a scoring run, from the default branch's plan and the checkout's."""
|
||||
def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure:
|
||||
"""Why the plan calls a scoring run, from the default branch's todo.md and the checkout's."""
|
||||
checkout = top()
|
||||
if isinstance(checkout, Failure):
|
||||
return checkout
|
||||
@@ -200,18 +204,18 @@ def due_reasons(default: str, ids: list[int], fell: list[str]) -> list[str] | Fa
|
||||
landed = landed_since_release(default)
|
||||
if isinstance(landed, Failure):
|
||||
return landed
|
||||
return scoring_run_due(planned, chunk, ids, landed, fell)
|
||||
return scoring_run_due(planned, chunk, ids, landed)
|
||||
|
||||
|
||||
def chunk_history(default: str) -> list[Entry] | Failure:
|
||||
"""The entries the checkout's history holds and the default branch's lacks."""
|
||||
def chunk_fall(default: str) -> Fall | Failure:
|
||||
"""Where the chunk stands in the fall sequence, from the entries the checkout's history holds and the default branch's lacks."""
|
||||
held = file_at(default, HISTORY)
|
||||
if isinstance(held, Failure):
|
||||
return held
|
||||
read = history_text()
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
return chunk_entries(held, read[1])
|
||||
return fall(chunk_entries(held, read[1]))
|
||||
|
||||
|
||||
def record_ruling(seats_file: pathlib.Path) -> Failure | None:
|
||||
@@ -246,19 +250,18 @@ def record_scoring(default: str, seats_file: pathlib.Path, ids: list[int]) -> Fa
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
mean = means(list(found.values()))
|
||||
recorded = chunk_history(default)
|
||||
if isinstance(recorded, Failure):
|
||||
return recorded
|
||||
blocking = due_reasons(default, ids, [])
|
||||
if isinstance(blocking, Failure):
|
||||
return blocking
|
||||
fell = pending_fall(recorded)
|
||||
if not (blocking or fell):
|
||||
return Failure(uncalled(recorded))
|
||||
state = chunk_fall(default)
|
||||
if isinstance(state, Failure):
|
||||
return state
|
||||
planned = plan_reasons(default, ids)
|
||||
if isinstance(planned, Failure):
|
||||
return planned
|
||||
if not (planned or state.pending):
|
||||
return Failure(uncalled(state))
|
||||
print(f"Means: {means_text(mean)}.")
|
||||
print(f"Item IDs read: {', '.join(map(str, ids)) or 'none'}.")
|
||||
print(floor_verdict(under_floor(mean), blocking))
|
||||
outcome = fall_outcome(fell, mean)
|
||||
print(floor_verdict(under_floor(mean), planned))
|
||||
outcome = fall_outcome(state.pending, mean)
|
||||
if outcome:
|
||||
print(outcome[0])
|
||||
return append(scoring_entry(title, given.seats, found, [str(value) for value in mean], outcome[1] if outcome else []))
|
||||
|
||||
Reference in New Issue
Block a user