Kill the surviving mutants of the spend, the setup version and the reversal count, and keep a subagent's type on one line
This commit is contained in:
@@ -15,6 +15,7 @@ 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 transcript_archive.location import project_archive
|
||||
from score_outcomes.main import report_text
|
||||
from score_outcomes.reversals import reversal_lines
|
||||
|
||||
@@ -311,6 +312,20 @@ class ScoreOutcomesTool(unittest.TestCase):
|
||||
def run_tool(self, *args, cwd=None):
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd or self.checkout, env=self.env, text=True)
|
||||
|
||||
def test_counts_the_reversals_in_loop_claudes_archive_of_the_main_checkout_run_from_a_worktree(self):
|
||||
archive = pathlib.Path(self.env["HOME"], "archive")
|
||||
self.env["LOOP_CLAUDE_TRANSCRIPTS"] = str(archive)
|
||||
chunk_file(project_archive(str(self.checkout), pathlib.Path(self.env["HOME"]), self.env), "a", ("2026-11-02T10:00:00Z", outcomes.finished('{"model": "m", "item": 4}', "e", "j", record=outcomes.Record("c", reversed="No."))))
|
||||
worktree = pathlib.Path(self.env["HOME"], "proj-item-4")
|
||||
self.git("worktree", "add", "-q", str(worktree))
|
||||
ran = self.run_tool(cwd=worktree)
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
self.assertTrue(ran.stdout.endswith("newest first:\n\n- 2026-11-02T10:00:00Z, item 4: 1 reversed\n"), ran.stdout[-400:])
|
||||
(archive.rglob("a.outcomes.md").__next__()).write_bytes(b"\xff")
|
||||
ran = self.run_tool()
|
||||
self.assertEqual(ran.returncode, 1)
|
||||
self.assertIn("could not read the archive", ran.stderr)
|
||||
|
||||
def test_measures_each_merged_chunk_that_removed_an_item(self):
|
||||
self.git("switch", "-q", "-c", "chunk")
|
||||
self.commit("Do it", {"a.py": "1\n2\n3\n", "todo.md": todo(SECOND)})
|
||||
@@ -490,6 +505,27 @@ class Reversals(unittest.TestCase):
|
||||
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."])
|
||||
|
||||
def test_says_all_chunks_have_none_and_names_no_item_the_worker_line_lacks(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
archive = pathlib.Path(root)
|
||||
chunk_file(archive, "kept", ("2026-11-03T10:00:00Z", outcomes.finished('{"model": "m", "item": 7}', "e", "j", record=outcomes.Record("c"))))
|
||||
self.assertEqual(reversal_lines(archive), ["- All 1 finished chunk: none."])
|
||||
for worker in ('{"model": "m"}', '{"model": "m", "item": true}', '["m"]', "not json"):
|
||||
with self.subTest(worker=worker):
|
||||
chunk_file(archive, "reversed", ("2026-11-04T10:00:00Z", outcomes.finished(worker, "e", "j", record=outcomes.Record("c", reversed="No."))))
|
||||
self.assertEqual(reversal_lines(archive), ["- 2026-11-04T10:00:00Z: 1 reversed", "- The other 1 finished chunk: none."])
|
||||
(archive / "reversed" / "a.outcomes.md").unlink()
|
||||
(archive / "reversed").rmdir()
|
||||
|
||||
def test_says_which_archive_it_could_not_read(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
archive = pathlib.Path(root)
|
||||
chunk_file(archive, "kept", ("2026-11-03T10:00:00Z", outcomes.finished("w", "e", "j", record=outcomes.Record("c"))))
|
||||
(archive / "kept" / "b.outcomes.md").write_bytes(b"\xff")
|
||||
found = reversal_lines(archive)
|
||||
self.assertIsInstance(found, Failure)
|
||||
self.assertTrue(found.reason.startswith(f"could not read the archive {archive}: "), found.reason)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user