Archive the raw transcript by content hash with its verdict, and stop on a failed archive

This commit is contained in:
2026-09-28 16:57:24 +02:00
parent 5e3b66232b
commit 6e31e0a833
7 changed files with 75 additions and 41 deletions
+9 -6
View File
@@ -224,19 +224,22 @@ class JudgePrompt(unittest.TestCase):
class Archive(unittest.TestCase):
def test_keeps_the_copy_and_every_folder_it_creates_as_private_as_the_transcript(self):
def test_keeps_one_copy_per_content_and_every_folder_it_creates_as_private_as_the_transcript(self):
with tempfile.TemporaryDirectory() as root:
transcript = os.path.join(root, "session.jsonl")
pathlib.Path(transcript).write_text(json.dumps(assistant({"type": "text", "text": "said"})) + "\n")
paths = paths_from(pathlib.Path(root), {"LOOP_CLAUDE_TRANSCRIPTS": os.path.join(root, "deep", "archive")})
cycle.archive("/srv/a/b", transcript, "note", paths)
[copy] = [os.path.join(folder, name) for folder, _, names in os.walk(paths.archive) for name in names]
self.assertEqual(stat.S_IMODE(os.stat(copy).st_mode), 0o600)
folder = os.path.dirname(copy)
with unittest.mock.patch("sys.stderr"):
for _ in range(2):
self.assertIsNone(cycle.archive("/srv/a/b", transcript, "note", paths))
copies = [os.path.join(folder, name) for folder, _, names in os.walk(paths.archive) for name in names]
self.assertEqual(len(copies), 2)
for copy in copies:
self.assertEqual(stat.S_IMODE(os.stat(copy).st_mode), 0o600)
folder = os.path.dirname(copies[0])
while folder != root:
self.assertEqual(stat.S_IMODE(os.stat(folder).st_mode), 0o700, folder)
folder = os.path.dirname(folder)
self.assertIn("said", pathlib.Path(copy).read_text())
class Said(unittest.TestCase):