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