Answer product-owner round 1: 0 🔴, 2 🟡 (0 misread); print the report before exiting 1 on an unreadable archive, naming the file

This commit is contained in:
2026-11-12 10:25:30 +01:00
parent d449c552c6
commit 72d9a9f652
4 changed files with 48 additions and 33 deletions
+14 -6
View File
@@ -18,13 +18,21 @@ class FinishedChunk:
def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Failure:
found = []
try:
for folder in sorted(path for path in project_archive.glob("*") if path.is_dir()):
copies = sorted((stamps[-1], outcomes) for outcomes in chunk_outcomes(folder) if (stamps := FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))))
if copies:
finished, outcomes = copies[-1]
found.append(FinishedChunk(folder.name, finished, transcript_of(outcomes), sorted(folder.glob("session/*/subagents/*.jsonl"))))
except (OSError, UnicodeDecodeError) as failure:
folders = sorted(path for path in project_archive.glob("*") if path.is_dir())
except OSError as failure:
return Failure(f"could not read the archive {project_archive}: {failure}")
for folder in folders:
copies = []
for outcomes in chunk_outcomes(folder):
try:
stamps = FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read the archive file {outcomes}: {failure}")
if stamps:
copies.append((stamps[-1], outcomes))
if copies:
finished, outcomes = max(copies)
found.append(FinishedChunk(folder.name, finished, transcript_of(outcomes), sorted(folder.glob("session/*/subagents/*.jsonl"))))
return sorted(found, key=lambda chunk: (chunk.finished, chunk.folder))