Answer architecture round 2: 2 🔴, 3 🟡; route from the ladder by rung, keep a stepped-up rung across reruns and reloads, test the judge's bundled range, and file item 136 for routing on the item taken
This commit is contained in:
@@ -5,14 +5,18 @@ from utc_stamp import STAMPED
|
||||
|
||||
FINISHED = "Verdict: finished"
|
||||
FINISHED_AT = re.compile(rf"^({STAMPED}) {re.escape(FINISHED)}$", re.MULTILINE)
|
||||
# An outcome opens with its UTC stamp; a verdict that closes a cycle, or a stop, ends with the worker line.
|
||||
OUTCOME_AT = re.compile(rf"^({STAMPED}) ", re.MULTILINE)
|
||||
CLOSES_A_CYCLE = ("Verdict: finished\n", "Verdict: unfinished\n", "Stopped: ")
|
||||
WORKER = "Worker: "
|
||||
|
||||
|
||||
def finished(worker: str, evidence: str) -> str:
|
||||
return f"{FINISHED}\n\nWorker: {worker}\n\nEvidence:\n{quoted(evidence)}"
|
||||
return f"{FINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{WORKER}{worker}"
|
||||
|
||||
|
||||
def unfinished(worker: str, evidence: str) -> str:
|
||||
return f"Verdict: unfinished\n\nWorker: {worker}\n\nEvidence:\n{quoted(evidence)}"
|
||||
return f"Verdict: unfinished\n\nEvidence:\n{quoted(evidence)}\n\n{WORKER}{worker}"
|
||||
|
||||
|
||||
def interrupted(question: str, evidence: str) -> str:
|
||||
@@ -23,5 +27,17 @@ def answered(question: str, sources: str, answer: str, evidence: str) -> str:
|
||||
return f"Verdict: quoted answer\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}"
|
||||
|
||||
|
||||
def stopped(why: str) -> str:
|
||||
return f"Stopped: {why}"
|
||||
def stopped(worker: str, why: str) -> str:
|
||||
return f"Stopped: {why}\n\n{WORKER}{worker}"
|
||||
|
||||
|
||||
def workers(outcomes: str) -> list[tuple[str, str]]:
|
||||
"""The UTC stamp and the worker of each outcome that closes a cycle, in the order they were written."""
|
||||
starts = list(OUTCOME_AT.finditer(outcomes))
|
||||
found = []
|
||||
for start, after in zip(starts, [*starts[1:], None]):
|
||||
outcome = outcomes[start.end():after.start() if after else len(outcomes)].rstrip("\n")
|
||||
last = outcome.rsplit("\n", 1)[-1]
|
||||
if outcome.startswith(CLOSES_A_CYCLE) and last.startswith(WORKER):
|
||||
found.append((start[1], last.removeprefix(WORKER)))
|
||||
return found
|
||||
|
||||
Reference in New Issue
Block a user