Record with each archived verdict the setup that ran it, what each model spent by kind, and the human's reversals
CI / tests (pull_request) Failing after 2m12s

This commit is contained in:
2026-11-12 09:57:56 +01:00
parent 8dc82fcf95
commit 3c4cedd389
22 changed files with 587 additions and 114 deletions
+23 -4
View File
@@ -77,8 +77,13 @@ Then, newest first, each finished chunk's later fixes, naming the fixing chunks,
that has any, then how many have none: the defects that reappear in what already shipped, the
other half of that counter-signal.
Then, newest first, how many of the human's typed answers each finished chunk's judge quoted as
reversing a choice the worker took on its own, for every chunk loop-claude finished that has any,
then how many have none: goal 1.2's counter-signal. It reads loop-claude's archive, and counts only
chunks whose verdicts record a Config line, since earlier judges didn't look for reversals.
Exit 1, saying why, on bad arguments, when git cannot start, finds no checkout or reads a shallow
clone, or the default branch cannot be read; or, after the rest of the report, when the anchors are
clone, the default branch or loop-claude's archive cannot be read; or, after the rest of the report, when the anchors are
left out.
"""
import functools
@@ -95,6 +100,8 @@ from score_outcomes.results import file_lines, fixed_later, item_text, misreads,
from release_plan.todo_table import item_details, LEVELS, risk, TOP_SCORE
from records.markdown_text import listed
from release_plan.named_code import named_files
from transcript_archive.location import project_archive
from score_outcomes.reversals import reversal_lines
# The scores score-outcomes takes, in order.
GIVEN = ("L", "E", "I", "S")
@@ -127,12 +134,15 @@ def main(argv: list[str]) -> int:
if isinstance(results, Failure):
return failed(results)
anchored = read_anchors()
print(report_text(results, anchored, dict(zip(GIVEN, map(int, argv))) if argv else None))
reversal = read_reversals()
if isinstance(reversal, Failure):
return failed(reversal)
print(report_text(results, anchored, dict(zip(GIVEN, map(int, argv))) if argv else None, reversal))
return failed(anchored) if isinstance(anchored, Failure) else 0
def report_text(results: list[Result], anchored: Anchors | Failure, given: dict[str, int] | None) -> str:
"""The report: the finished items nearest the given scores, where any are given, then the anchors, then the medians, then each chunk's misread findings, then its later fixes."""
def report_text(results: list[Result], anchored: Anchors | Failure, given: dict[str, int] | None, reversal: list[str]) -> str:
"""The report: the finished items nearest the given scores, where any are given, then the anchors, then the medians, then each chunk's misread findings, then its later fixes, then its reversals, as reversal_lines gives them."""
sections = []
if given is not None:
r = risk(given["L"], given["E"], given["I"])
@@ -142,6 +152,7 @@ def report_text(results: list[Result], anchored: Anchors | Failure, given: dict[
sections.append(["Median outcome at each guessed score, among chunks that shipped one item, never-replayed ones left out:", "", *report(results)])
sections.append(["🔴 and 🟡 findings, with how many a reviewer marked `[misread]`, per finished chunk whose round titles count them, newest first:", "", *misreads(results)])
sections.append(["Later fixes: the chunks that fixed code each finished chunk shipped, newest first:", "", *fixed_later(results)])
sections.append(["Reversals: the human's typed answers that reversed a choice the worker took on its own, per chunk loop-claude finished, newest first:", "", *reversal])
if any(result.landing != "merge" for result in results):
sections.append(UNMERGED)
return "\n\n".join("\n".join(section) for section in sections)
@@ -165,6 +176,14 @@ def read_anchors() -> Anchors | Failure:
return Failure(f"cannot read {ANCHORS_PATH}: {failure}")
def read_reversals() -> list[str] | Failure:
"""The reversals in loop-claude's archive of this project, which the main checkout's path keys, whichever worktree this runs in."""
common = git("rev-parse", "--path-format=absolute", "--git-common-dir")
if isinstance(common, Failure):
return common
return reversal_lines(project_archive(str(pathlib.Path(common.strip()).parent), pathlib.Path.home(), os.environ))
def read_results(default: str) -> list[Result] | Failure:
"""What each chunk on the default branch's first-parent line measured."""
if partial := full_history():
+40
View File
@@ -0,0 +1,40 @@
"""The human's reversals of choices workers took on their own, per finished chunk in loop-claude's archive: the counter-signal docs/decisions.md → `loop-claude: a judge decides each interrupt and each quoted answer…`, its entry of 2026-11-08, is valid under."""
import json
import pathlib
from failure import Failure
from score_outcomes.results import plural
from transcript_archive.outcomes import CONFIG, reversals, workers
from transcript_archive.read import chunk_outcomes, finished_chunks
def reversal_lines(project_archive: pathlib.Path) -> list[str] | Failure:
"""Newest first, each finished chunk the judge looked for reversals in, with how many distinct answers it quoted as reversing, then how many had none. The judge looks for them from the release that records a Config line beside each verdict, so a chunk without one is left out."""
chunks = finished_chunks(project_archive)
if isinstance(chunks, Failure):
return chunks
counted = []
for chunk in reversed(chunks):
try:
texts = [path.read_text(encoding="utf-8") for path in chunk_outcomes(project_archive / chunk.folder)]
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read the archive {project_archive}: {failure}")
if any(f"\n{CONFIG}" in text for text in texts):
# The judge quotes the latest reversal at each ruling, so one answer may be quoted many times.
found = dict.fromkeys(quote for text in texts for quote in reversals(text))
counted.append((f"{chunk.finished}{item_of(texts)}", len(found)))
if not counted:
return ["- None: loop-claude's archive holds no finished chunk whose verdicts record a Config line."]
lines = [f"- {chunk}: {count} reversed" for chunk, count in counted if count]
others = len(counted) - len(lines)
return lines + ([f"- {'The other' if lines else 'All'} {plural(others, 'finished chunk')}: none."] if others else [])
def item_of(texts: list[str]) -> str:
"""`, item <ID>` for the item the chunk's latest worker line routes it by; empty where none does."""
named = sorted(stamped for text in texts for stamped in workers(text))
try:
item = json.loads(named[-1][1]).get("item") if named else None
except (ValueError, AttributeError):
item = None
return f", item {item}" if isinstance(item, int) and not isinstance(item, bool) and item else ""
+36 -12
View File
@@ -14,7 +14,9 @@ from score_outcomes.results import file_lines, NamedCode, nearest, rank_correlat
from review_rules.round_titles import Findings
from test_env import isolated_env
from release_plan.todo_table import Item
from transcript_archive import outcomes
from score_outcomes.main import report_text
from score_outcomes.reversals import reversal_lines
TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes"
HEADER = "| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n"
@@ -193,7 +195,7 @@ class ReportText(unittest.TestCase):
def test_lists_the_nearest_by_r_then_the_anchors_then_the_medians(self):
found = [result(1, 5, 3, None, merged="2026-10-13T10:00:00Z"), result(2, 1, 3, None, merged="2026-10-12T10:00:00Z")]
too_few = "such chunks record"
self.assertEqual(report_text(found, [("L 1", (2,))], {"L": 1, "E": 1, "I": 1, "S": 3}), f"""Finished items nearest L 1, E 1, I 1, so R 1, and S 3, closest first:
self.assertEqual(report_text(found, [("L 1", (2,))], {"L": 1, "E": 1, "I": 1, "S": 3}, ["- None: loop-claude's archive holds no finished chunk whose verdicts record a Config line."]), f"""Finished items nearest L 1, E 1, I 1, so R 1, and S 3, closest first:
- Item 2, R 1, S 3: 10 lines in 1 file, 1 round past each pass's first, 0 🔴, 0 🟡, 0 later fixes; merged 2026-10-12T10:00:00Z in aaaaaaa. **Item 2.**
- Item 1, R 5, S 3: 10 lines in 1 file, 1 round past each pass's first, 0 🔴, 0 🟡, 0 later fixes; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 1.**
@@ -217,40 +219,44 @@ Median outcome at each guessed score, among chunks that shipped one item, never-
Later fixes: the chunks that fixed code each finished chunk shipped, newest first:
- None: no later chunk fixed code a finished chunk shipped.""")
- None: no later chunk fixed code a finished chunk shipped.
Reversals: the human's typed answers that reversed a choice the worker took on its own, per chunk loop-claude finished, newest first:
- None: loop-claude's archive holds no finished chunk whose verdicts record a Config line.""")
def test_lists_each_chunks_findings_with_their_misread_count_newest_first_once_per_chunk(self):
found = [result(1, 5, 3, None, findings=(1, 2), misread=1, merge="bbbbbbb", merged="2026-10-12T10:00:00Z", shipped_with=(2,)), result(2, 5, 3, None, findings=(1, 2), misread=1, merge="bbbbbbb", merged="2026-10-12T10:00:00Z", shipped_with=(1,)), result(3, 5, 3, None, findings=(0, 4), misread=0, merge="ccccccc", merged="2026-10-14T10:00:00Z", landing="rebase"), result(4, 5, 3, None)]
self.assertIn("""🔴 and 🟡 findings, with how many a reviewer marked `[misread]`, per finished chunk whose round titles count them, newest first:
- 2026-10-14T10:00:00Z in ccccccc: at least 0 🔴, 4 🟡 (0 misread)
- 2026-10-12T10:00:00Z in bbbbbbb: 1 🔴, 2 🟡 (1 misread)""", report_text(found, [], None))
- 2026-10-12T10:00:00Z in bbbbbbb: 1 🔴, 2 🟡 (1 misread)""", report_text(found, [], None, []))
def test_lists_each_chunks_later_fixes_newest_first_once_per_chunk_then_counts_the_others(self):
found = [result(1, 5, 3, None, merge="bbbbbbb", merged="2026-10-12T10:00:00Z", shipped_with=(2,), fixed_by=("ddddddd",)), result(2, 5, 3, None, merge="bbbbbbb", merged="2026-10-12T10:00:00Z", shipped_with=(1,), fixed_by=("ddddddd",)), result(3, 5, 3, None, merge="ccccccc", merged="2026-10-14T10:00:00Z", fixed_by=("eeeeeee", "ddddddd")), result(4, 5, 3, None), result(5, 5, 3, None, merge="fffffff")]
self.assertTrue(report_text(found, [], None).endswith("""Later fixes: the chunks that fixed code each finished chunk shipped, newest first:
self.assertIn("""Later fixes: the chunks that fixed code each finished chunk shipped, newest first:
- 2026-10-14T10:00:00Z in ccccccc: 2 later fixes, by eeeeeee and ddddddd
- 2026-10-12T10:00:00Z in bbbbbbb: 1 later fix, by ddddddd
- The other 2 finished chunks: none."""))
- The other 2 finished chunks: none.""", report_text(found, [], None, []))
def test_ends_with_how_it_reads_chunks_merged_by_rebase_only_where_it_measured_one(self):
text = report_text([result(1, 5, 3, None, landing="rebase")], [], None)
text = report_text([result(1, 5, 3, None, landing="rebase")], [], None, [])
self.assertIn("\n\nChunks that left no merge commit:\n\n- Each is the run of commits", text.split("Median outcome")[1])
self.assertIn("a pull request that shipped nothing adds its lines, files and rounds", text)
self.assertIn("at least what history shows, and the medians count the rebased ones as shown.", text)
self.assertIn("Chunks that left no merge commit", report_text([result(1, 5, 3, None, landing="push")], [], None))
self.assertNotIn("Chunks that left no merge commit", report_text([result(1, 5, 3, None)], [], None))
self.assertIn("Chunks that left no merge commit", report_text([result(1, 5, 3, None, landing="push")], [], None, []))
self.assertNotIn("Chunks that left no merge commit", report_text([result(1, 5, 3, None)], [], None, []))
def test_leaves_a_never_replayed_chunk_out_of_the_s_medians_and_keeps_a_rebased_one(self):
found = [result(id_, 2, 2, None, lines=10 * id_, landing="rebase" if id_ == 1 else "merge") for id_ in range(1, 11)]
self.assertIn("- S, lines changed: 2 → 55 (10 chunks)", report_text(found + [result(11, 2, 2, None, lines=100000, landing="push")], [], None))
self.assertIn("- S, lines changed: 2 → 55 (10 chunks)", report_text(found + [result(11, 2, 2, None, lines=100000, landing="push")], [], None, []))
def test_leaves_a_never_replayed_chunk_out_of_the_r_medians_and_the_rank_correlations(self):
levels = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4]
found = [result(id_, 2, 2, None, rounds=level, findings=(5 - level, 0), levels={"L": level, "E": 2, "I": level}) for id_, level in enumerate(levels, 1)]
pushed = result(11, 2, 2, None, rounds=9, findings=(9, 0), levels={"L": 1, "E": 2, "I": 1}, landing="push")
text = report_text(found + [pushed], [], None)
text = report_text(found + [pushed], [], None, [])
self.assertIn("- R, 🔴 findings: 2 → 2.5 (10 chunks)", text)
self.assertIn("- L, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and -1.00 (10 chunks)", text)
self.assertIn("- I, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and -1.00 (10 chunks)", text)
@@ -258,7 +264,7 @@ Later fixes: the chunks that fixed code each finished chunk shipped, newest firs
def test_keeps_a_never_replayed_chunk_in_the_nearest_and_anchors_lists(self):
pushed = result(9, 2, 3, None, landing="push")
text = report_text([pushed], [("L 1", (9,))], {"L": 1, "E": 1, "I": 1, "S": 3})
text = report_text([pushed], [("L 1", (9,))], {"L": 1, "E": 1, "I": 1, "S": 3}, [])
nearest_section, anchors_section = text.split("Anchors in ")
self.assertIn("- Item 9, R 2, S 3:", nearest_section)
self.assertIn("never replayed", nearest_section)
@@ -266,7 +272,7 @@ Later fixes: the chunks that fixed code each finished chunk shipped, newest firs
self.assertIn("never replayed", anchors_section.split("Median outcome")[0])
def test_lists_no_nearest_items_where_no_scores_are_given(self):
self.assertTrue(report_text([], [], None).startswith("Anchors in docs/score-anchors.md"))
self.assertTrue(report_text([], [], None, []).startswith("Anchors in docs/score-anchors.md"))
class ScoreOutcomesTool(unittest.TestCase):
@@ -467,5 +473,23 @@ class ScoreOutcomesTool(unittest.TestCase):
self.assertIn("usage: score-outcomes [L E I S]", ran.stderr)
def chunk_file(archive, folder, *stamped):
(archive / folder).mkdir(parents=True)
(archive / folder / "a.outcomes.md").write_text("Task: Do it.\n\n" + "".join(f"{stamp} {outcome}\n\n" for stamp, outcome in stamped))
class Reversals(unittest.TestCase):
def test_counts_each_chunks_distinct_reversals_newest_first_only_where_its_verdicts_record_a_config(self):
worker = '{"model": "m", "item": 7}'
with tempfile.TemporaryDirectory() as root:
archive = pathlib.Path(root)
self.assertEqual(reversal_lines(archive), ["- None: loop-claude's archive holds no finished chunk whose verdicts record a Config line."])
chunk_file(archive, "old", ("2026-11-01T10:00:00Z", outcomes.finished(worker, "e", "j", record=outcomes.Record(reversed="No."))))
chunk_file(archive, "reversed", ("2026-11-02T10:00:00Z", outcomes.unfinished(worker, "e", "j", "", record=outcomes.Record("c", reversed="No."))), ("2026-11-02T11:00:00Z", outcomes.unfinished(worker, "e", "j", "", record=outcomes.Record("c", reversed="No."))), ("2026-11-02T12:00:00Z", outcomes.finished(worker, "e", "j", record=outcomes.Record("c", reversed="Use X."))))
chunk_file(archive, "kept", ("2026-11-03T10:00:00Z", outcomes.finished('{"model": "m"}', "e", "j", record=outcomes.Record("c"))))
self.assertEqual(reversal_lines(archive), ["- 2026-11-02T12:00:00Z, item 7: 2 reversed", "- The other 1 finished chunk: none."])
if __name__ == "__main__":
unittest.main()