Archive transcripts as private as their session files
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import stat
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
LOADER = importlib.machinery.SourceFileLoader("loop_claude", str(pathlib.Path(__file__).with_name("loop-claude")))
|
||||
@@ -65,6 +69,19 @@ class JudgePrompt(unittest.TestCase):
|
||||
self.assertTrue(prompt.endswith(loop.JUDGE_RULES))
|
||||
|
||||
|
||||
class Archive(unittest.TestCase):
|
||||
def test_keeps_the_copy_as_private_as_the_transcript(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
transcript = os.path.join(root, "session.jsonl")
|
||||
open(transcript, "w").write(json.dumps(assistant({"type": "text", "text": "said"})) + "\n")
|
||||
loop.ARCHIVE = os.path.join(root, "archive")
|
||||
loop.archive(transcript, "note")
|
||||
[copy] = [os.path.join(folder, name) for folder, _, names in os.walk(loop.ARCHIVE) for name in names]
|
||||
self.assertEqual(stat.S_IMODE(os.stat(copy).st_mode), 0o600)
|
||||
self.assertEqual(stat.S_IMODE(os.stat(os.path.dirname(copy)).st_mode), 0o700)
|
||||
self.assertIn("said", open(copy).read())
|
||||
|
||||
|
||||
class Grounded(unittest.TestCase):
|
||||
def test_an_interrupt_must_quote_the_transcript(self):
|
||||
self.assertTrue(loop.grounded({"ask": False, "evidence": ""}, "anything"))
|
||||
|
||||
Reference in New Issue
Block a user