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
+7 -5
View File
@@ -7,6 +7,7 @@ from transcript_archive.location import chunk_folder, outcomes_of
from failure import Failure
from transcript_archive.judge_run import JudgeRun
from text_files.file_writes import make_private, replace_file
from text_files.compressed import read_stored, stored
from claude_code.session import session_files
from transcript_archive.outcomes import TASK
from text_files.utc_stamp import utc
@@ -29,7 +30,7 @@ def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, a
copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl"
outcomes = outcomes_of(copy)
stamped = f"{utc(at)} {outcome}"
if copy.exists() and outcomes.exists():
if stored(copy) and outcomes.exists():
return add_outcome(outcomes, stamped)
# The copy lands last, so a copy on disk always has its outcomes and its session's files beside it.
for dest, data in ((outcomes, f"{TASK}{task}\n\n{stamped}\n".encode()), (copy, raw)):
@@ -41,7 +42,7 @@ def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, a
def keep_judge_run(folder: pathlib.Path, run: JudgeRun) -> Failure | None:
kept = folder / run.file
if kept.exists():
if stored(kept):
return None
try:
make_private(kept.parent)
@@ -93,11 +94,12 @@ def files_under(folder: pathlib.Path) -> list[pathlib.Path]:
# Claude Code rewrites some files whole, such as custom-title.json, so a copy is replaced only by a file that grew from it.
# A grown copy lands plain beside its gzip, which compress-archives then replaces losing nothing, since the gzip holds a prefix of it.
def copy_for(copy: pathlib.Path, data: bytes) -> pathlib.Path | None:
if not copy.is_file():
if not stored(copy):
return copy
kept = copy.read_bytes()
kept = read_stored(copy)
if data.startswith(kept):
return copy if data != kept else None
beside = copy.with_name(f"{copy.name}.{hashlib.sha256(data).hexdigest()}")
return None if beside.exists() else beside
return None if stored(beside) else beside