Archive each verdict's evidence, and stamp each outcome with its UTC time

This commit is contained in:
2026-10-03 20:44:36 +02:00
parent 8e1cd07402
commit 69ffd6c1a1
7 changed files with 28 additions and 33 deletions
+5 -3
View File
@@ -2,6 +2,7 @@ import hashlib
import os
import pathlib
import sys
import time
from failure import Failure
from loop_claude.claude_code.transcript import first_timestamped_line
@@ -10,7 +11,7 @@ from loop_claude.paths import Paths
from loop_claude.claude_code.session import session_files
def archive(project_key: str, path: str, task: str, outcome: str, paths: Paths) -> Failure | None:
def archive(project_key: str, path: str, task: str, outcome: str, at: float, paths: Paths) -> Failure | None:
try:
with open(path, "rb") as handle:
raw = handle.read()
@@ -24,10 +25,11 @@ def archive(project_key: str, path: str, task: str, outcome: str, paths: Paths)
return unkept
copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl"
outcomes = copy.with_suffix(".outcomes.md")
stamped = f"{time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(at))} {outcome}"
if copy.exists() and outcomes.exists():
return add_outcome(outcomes, outcome)
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{outcome}\n".encode()), (copy, raw)):
for dest, data in ((outcomes, f"Task: {task}\n\n{stamped}\n".encode()), (copy, raw)):
if unwritten := replace_file(dest, data):
return unarchived(dest, unwritten.reason)
print(f"transcript: {copy}", file=sys.stderr)