Answer architecture round 2: 0 🔴, 2 🟡; archive each verdict's judge rung, list the archive through transcript_archive alone, and say how the replay's retry differs from the loop's
This commit is contained in:
@@ -3,7 +3,7 @@ import pathlib
|
||||
|
||||
from transcript_archive.location import chunk_folder
|
||||
from failure import Failure
|
||||
from transcript_archive.outcomes import FINISHED_AT, workers
|
||||
from transcript_archive.outcomes import FILE_SUFFIX, FINISHED_AT, workers
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -19,7 +19,7 @@ def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Fail
|
||||
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 folder.glob("*.outcomes.md") if (stamps := FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))))
|
||||
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"))))
|
||||
@@ -31,14 +31,19 @@ def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Fail
|
||||
def archived_outcomes(root: pathlib.Path) -> list[tuple[str, pathlib.Path]] | Failure:
|
||||
"""Each outcomes file in the archive at root, with the key of the project it belongs to, sorted."""
|
||||
try:
|
||||
return sorted((str(path.parent.parent.relative_to(root)), path) for path in root.rglob("*.outcomes.md"))
|
||||
return sorted((str(path.parent.parent.relative_to(root)), path) for path in root.rglob(f"*{FILE_SUFFIX}"))
|
||||
except OSError as failure:
|
||||
return Failure(f"could not read the archive {root}: {failure}")
|
||||
|
||||
|
||||
def chunk_outcomes(folder: pathlib.Path) -> list[pathlib.Path]:
|
||||
"""The outcomes file of each transcript copy in a chunk's folder, sorted."""
|
||||
return sorted(folder.glob(f"*{FILE_SUFFIX}"))
|
||||
|
||||
|
||||
def transcript_of(outcomes: pathlib.Path) -> pathlib.Path:
|
||||
"""The transcript copy an outcomes file sits beside."""
|
||||
return outcomes.with_name(outcomes.name.removesuffix(".outcomes.md") + ".jsonl")
|
||||
return outcomes.with_name(outcomes.name.removesuffix(FILE_SUFFIX) + ".jsonl")
|
||||
|
||||
|
||||
def read_threads(chunk: FinishedChunk) -> list[bytes] | Failure:
|
||||
@@ -59,7 +64,7 @@ def latest_worker(project_archive: pathlib.Path, transcript: str) -> str | Failu
|
||||
folder = chunk_folder(project_archive, handle.read())
|
||||
if not folder.is_dir():
|
||||
return None
|
||||
files = sorted((path for path in folder.iterdir() if path.name.endswith(".outcomes.md")), key=lambda path: path.stat().st_mtime_ns, reverse=True)
|
||||
files = sorted((path for path in folder.iterdir() if path.name.endswith(FILE_SUFFIX)), key=lambda path: path.stat().st_mtime_ns, reverse=True)
|
||||
for path in files:
|
||||
if found := workers(path.read_text(encoding="utf-8")):
|
||||
return found[-1][1]
|
||||
|
||||
Reference in New Issue
Block a user