Merge remote-tracking branch 'origin/main' into item-316
CI / tests (pull_request) Successful in 3m32s

# Conflicts:
#	docs/reading-cost.md
This commit is contained in:
2026-11-18 19:52:58 +01:00
124 changed files with 5044 additions and 705 deletions
+40
View File
@@ -1497,6 +1497,46 @@ class CommittedFiles(unittest.TestCase):
self.assertEqual(self.commit().returncode, 0)
class TranscriptRead(unittest.TestCase):
HOME = "/home/h"
TRANSCRIPT = "/home/h/.claude/projects/-home-h-code-acme/abc-123.jsonl"
def breached(self, tool: str, given: dict[str, typing.Any], cwd: str = "/r") -> list[str]:
found = breaches_of(Call(tool, given, cwd), self.HOME, {})
return [rule for rule in rules(found[2]) if rule == "transcript-read"] if found else []
def test_a_read_of_a_session_s_transcript_or_a_subagent_s_is_refused(self):
self.assertEqual(self.breached("Read", {"file_path": self.TRANSCRIPT}), ["transcript-read"])
self.assertEqual(self.breached("Read", {"file_path": "/home/h/.claude/projects/-home-h-code-acme/abc-123/subagents/agent-a1.jsonl"}), ["transcript-read"])
def test_a_read_spelt_from_home_or_from_the_working_directory_is_refused(self):
self.assertEqual(self.breached("Read", {"file_path": "~/.claude/projects/-home-h-code-acme/abc-123.jsonl"}), ["transcript-read"])
self.assertEqual(self.breached("Read", {"file_path": "abc-123.jsonl"}, "/home/h/.claude/projects/-home-h-code-acme"), ["transcript-read"])
def test_the_refusal_names_the_file_and_what_to_use_instead(self):
found = breaches_of(Call("Read", {"file_path": self.TRANSCRIPT}, "/r"), self.HOME, {})
[detail] = [breach.detail for breach in found[2] if breach.rule == "transcript-read"]
self.assertIn(self.TRANSCRIPT, detail)
self.assertIn("grep or jq", detail)
def test_the_refusal_is_logged_in_the_checkout_of_the_working_directory(self):
found = breaches_of(Call("Read", {"file_path": self.TRANSCRIPT}, "/r"), self.HOME, {})
self.assertEqual([breach.directory for breach in found[2] if breach.rule == "transcript-read"], ["/r"])
def test_a_read_of_a_long_result_claude_code_saved_to_a_file_or_of_a_memory_file_passes(self):
for path in ("/home/h/.claude/projects/-home-h-code-acme/abc-123/tool-results/b3ij9u144.txt", "/home/h/.claude/projects/-home-h-code-acme/memory/MEMORY.md"):
with self.subTest(path):
self.assertEqual(self.breached("Read", {"file_path": path}), [])
def test_a_jsonl_file_outside_the_projects_folder_passes(self):
self.assertEqual(self.breached("Read", {"file_path": "/home/h/code/acme/cases.jsonl"}), [])
self.assertEqual(self.breached("Read", {"file_path": "/home/h/.claude/loop-claude-transcripts/x.jsonl"}), [])
def test_a_search_of_a_transcript_is_not_checked(self):
self.assertEqual(self.breached("Grep", {"pattern": "x", "path": self.TRANSCRIPT}), [])
self.assertEqual(self.breached("Bash", {"command": f"grep x {self.TRANSCRIPT}"}), [])
class RuleNames(unittest.TestCase):
def test_every_rule_name_has_a_rule_and_every_rule_a_name(self):
self.assertEqual(set(RULES), set(typing.get_args(RuleName)))