Gzip loop-claude's archive and the review folders 30 days after each file was last written, and read gzipped files by their plain name
CI / tests (pull_request) Failing after 2m59s

This commit is contained in:
2026-11-17 02:00:32 +01:00
parent 7b0e4d013e
commit b9876c17fe
23 changed files with 467 additions and 18 deletions
@@ -10,6 +10,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from transcript_archive.project_key import checkout_of, project_key
from text_files import compressed
from failure import Failure
from transcript_archive.judge_run import JudgeRun
from transcript_archive import outcomes, read, write
@@ -119,6 +120,47 @@ class CopyFor(unittest.TestCase):
self.assertIsNone(write.copy_for(copy, b"second"))
self.assertEqual(write.copy_for(copy, b"first, grown"), copy)
def test_reads_a_compressed_copy_as_the_kept_version(self):
with tempfile.TemporaryDirectory() as temp:
copy = pathlib.Path(temp, "agent-a.jsonl")
copy.write_bytes(b"first\n")
self.assertIsNone(compressed.compress(copy))
self.assertIsNone(write.copy_for(copy, b"first\n"))
self.assertEqual(write.copy_for(copy, b"first\nsecond\n"), copy)
self.assertEqual(write.copy_for(copy, b"other\n"), copy.with_name(f"agent-a.jsonl.{hashlib.sha256(b'other' + bytes([10])).hexdigest()}"))
class Compressed(unittest.TestCase):
"""The archive, its transcript copies and subagents' transcripts gzipped as compress-archives leaves them."""
def archived(self, root: str) -> pathlib.Path:
kept = pathlib.Path(root, "archive")
transcript = pathlib.Path(root, "t.jsonl")
transcript.write_text('{"timestamp": "2026-10-03T00:00:00Z"}\n')
subagent = pathlib.Path(root, "t", "subagents", "agent-a.jsonl")
subagent.parent.mkdir(parents=True)
subagent.write_text('{"sub": 1}\n')
with contextlib.redirect_stderr(io.StringIO()):
self.assertIsNone(write.archive(kept, str(transcript), "Do it.", outcomes.finished("w", "merged", "j"), NOW))
for copy in kept.rglob("*.jsonl"):
self.assertIsNone(compressed.compress(copy))
return transcript
def test_a_compressed_copy_takes_the_next_outcome_and_is_not_copied_again(self):
with tempfile.TemporaryDirectory() as root:
transcript = self.archived(root)
kept = pathlib.Path(root, "archive")
with contextlib.redirect_stderr(io.StringIO()):
self.assertIsNone(write.archive(kept, str(transcript), "Do it.", outcomes.stopped("w", "Ctrl-C"), NOW + 1))
self.assertEqual([path.name.endswith(".gz") for path in kept.rglob("*.jsonl*")], [True, True])
self.assertIn("Stopped: Ctrl-C", next(kept.glob("*/*.outcomes.md")).read_text())
def test_reads_a_finished_chunk_whose_copies_are_compressed(self):
with tempfile.TemporaryDirectory() as root:
self.archived(root)
(chunk,) = read.finished_chunks(pathlib.Path(root, "archive"))
self.assertEqual(read.read_threads(chunk), [b'{"timestamp": "2026-10-03T00:00:00Z"}\n', b'{"sub": 1}\n'])
class Outcomes(unittest.TestCase):
def test_the_archive_stamps_what_it_reads_back(self):