Give record, verdict and judge one meaning each

This commit is contained in:
2026-10-03 17:53:25 +02:00
parent 9f75fe8c51
commit 5f7d34b87d
12 changed files with 39 additions and 39 deletions
+8 -8
View File
@@ -23,11 +23,11 @@ def archive(project_key: str, path: str, task: str, outcome: str, paths: Paths)
if sibling != path and (unkept := mirror(pathlib.Path(sibling), folder / "session" / os.path.basename(sibling))):
return unkept
copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl"
verdict = copy.with_suffix(".verdict.md")
outcomes = copy.with_suffix(".outcomes.md")
if copy.exists():
return add_outcome(verdict, outcome)
# The copy lands last, so a copy on disk always has its verdict and its session's files beside it.
for dest, data in ((verdict, f"Task: {task}\n\n{outcome}\n".encode()), (copy, raw)):
return add_outcome(outcomes, outcome)
# 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{outcome}\n".encode()), (copy, raw)):
if unwritten := replace_file(dest, data):
return unarchived(dest, unwritten.reason)
print(f"transcript: {copy}", file=sys.stderr)
@@ -38,13 +38,13 @@ def unarchived(where: object, why: str | None) -> Failure:
return Failure(f"could not archive the transcript: {where}: {why}")
def add_outcome(verdict: pathlib.Path, outcome: str) -> Failure | None:
def add_outcome(outcomes: pathlib.Path, outcome: str) -> Failure | None:
try:
outcomes = verdict.read_bytes()
kept = outcomes.read_bytes()
except OSError as failure:
return unarchived(failure.filename, failure.strerror)
if unwritten := replace_file(verdict, outcomes + f"\n{outcome}\n".encode()):
return unarchived(verdict, unwritten.reason)
if unwritten := replace_file(outcomes, kept + f"\n{outcome}\n".encode()):
return unarchived(outcomes, unwritten.reason)
return None
+1 -1
View File
@@ -21,7 +21,7 @@ relative to ~/code, or to / outside it. The session is deleted when its chunk fi
interrupt, and as every cycle ends, Ctrl-C and a failure included, the session's transcript is
copied to $LOOP_CLAUDE_TRANSCRIPTS/<key>/<chunk>/<sha256>.jsonl (default
~/.claude/loop-claude-transcripts), named by its hash. <chunk> is the hash of the transcript's first
line with a timestamp, the same for every cycle of a chunk. Beside the copy, <sha256>.verdict.md
line with a timestamp, the same for every cycle of a chunk. Beside the copy, <sha256>.outcomes.md
holds the verdict, and why the loop stopped. Claude Code keeps a folder per session beside its
transcript, holding the subagents' transcripts among other files; that folder, and every other file
named after the session except the transcript, are copied into <chunk>/session/. A file there is
+1 -1
View File
@@ -27,7 +27,7 @@ PRIVATE = [
"tasks/a/b.json",
"workflow-bench/a-1-1.md",
"workflow-bench/a-1-1/README.md",
"workflow-bench/judge/a/A1/fixes.diff",
"workflow-bench/compare/a/A1/fixes.diff",
"workflow-bench/logs/a.jsonl",
]
+1 -1
View File
@@ -169,7 +169,7 @@ class Cycles(unittest.TestCase):
return run.Cycle(effects=fake.effects(), models=model_choice.Models("judge-model", "worker-model"), paths=self.paths, premises="## Goals", project_key="proj", records=records, root=str(self.home), session=self.session, task="Do it.")
def archived_verdicts(self):
return sorted(path.read_text() for path in (self.paths.transcript_archive / "proj").glob("*/*.verdict.md"))
return sorted(path.read_text() for path in (self.paths.transcript_archive / "proj").glob("*/*.outcomes.md"))
def test_a_finished_chunk_is_archived_and_its_session_deleted(self):
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")])
+6 -6
View File
@@ -250,17 +250,17 @@ class Checkout:
return pathlib.Path(self.env.get("LOOP_CLAUDE_TRANSCRIPTS", self.home / ".claude" / "loop-claude-transcripts"))
def archived(self):
"""Each archived transcript's verdict, after checking the copy is named by its content hash."""
verdicts = {}
"""Each archived transcript's outcomes, after checking the copy is named by its content hash."""
outcomes = {}
for folder in (self.archive(), self.archive() / "proj", *(self.archive() / "proj").iterdir()):
self.test.assertEqual(stat.S_IMODE(folder.stat().st_mode), 0o700, folder)
for copy in sorted((self.archive() / "proj").glob("*/*.jsonl")):
self.test.assertEqual(copy.stem, hashlib.sha256(copy.read_bytes()).hexdigest())
verdict = copy.with_suffix(".verdict.md")
for archived in (copy, verdict):
kept = copy.with_suffix(".outcomes.md")
for archived in (copy, kept):
self.test.assertEqual(stat.S_IMODE(archived.stat().st_mode), 0o600)
verdicts[copy.read_text()] = verdict.read_text()
return verdicts
outcomes[copy.read_text()] = kept.read_text()
return outcomes
def argument(call, flag):