Answer architecture round 1: 2 🔴, 2 🟡 (0 misread); move transcript parsing into claude_code and keep repeat_read pure
This commit is contained in:
@@ -10,14 +10,13 @@ import unittest.mock
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from rule_hook.rules import blocks, Breach, check, command_breaches, file_breaches, overrides
|
||||
from rule_hook.main import breaches_of
|
||||
from rule_hook.main import breaches_of, read_breaches
|
||||
from rule_hook.call import Call, parsed_call
|
||||
from git_command import Commit, commit_message, commits
|
||||
from test_rank_todo import DECISIONS, README, TODO
|
||||
from test_env import isolated_env
|
||||
from model_routing import ladder
|
||||
from rule_hook.override_log import LogLine, parsed_entry, this_chunks
|
||||
from rule_hook.repeat_read import repeat_breaches
|
||||
from rule_hook.reviewer_rung import reviewer_breaches
|
||||
from rule_hook.git import git as rule_hook_git
|
||||
from model_routing.ladder import Rung
|
||||
@@ -359,7 +358,7 @@ class RepeatRead(unittest.TestCase):
|
||||
return "\n".join(self.LINES[start - 1:end])
|
||||
|
||||
def found(self, tool: str, given: dict, agent: str = "") -> list[Breach]:
|
||||
return repeat_breaches(Call(tool, given, self.folder, agent, self.transcript), "/h")
|
||||
return read_breaches(Call(tool, given, self.folder, agent, self.transcript), "/h")
|
||||
|
||||
def test_a_read_of_lines_already_read_is_blocked_with_a_note(self):
|
||||
self.read(1, 10)
|
||||
@@ -425,11 +424,11 @@ class RepeatRead(unittest.TestCase):
|
||||
given = {"cwd": self.folder, "tool_name": "Read", "tool_input": {"file_path": self.file, "offset": 1, "limit": 10}, "transcript_path": self.transcript}
|
||||
subagent = parsed_call(given | {"agent_id": "a1", "agent_type": "Explore"})
|
||||
self.assertEqual(subagent.transcript, f"{self.folder}/s/subagents/agent-a1.jsonl")
|
||||
self.assertEqual(repeat_breaches(subagent, "/h"), [], "the parent's reads are not in the subagent's context")
|
||||
self.assertEqual(rules(repeat_breaches(parsed_call(given), "/h")), ["repeat-read"])
|
||||
self.assertEqual(read_breaches(subagent, "/h"), [], "the parent's reads are not in the subagent's context")
|
||||
self.assertEqual(rules(read_breaches(parsed_call(given), "/h")), ["repeat-read"])
|
||||
|
||||
def test_a_missing_transcript_blocks_nothing(self):
|
||||
self.assertEqual(repeat_breaches(Call("Read", {"file_path": self.file}, self.folder, "", f"{self.folder}/none.jsonl"), "/h"), [])
|
||||
self.assertEqual(read_breaches(Call("Read", {"file_path": self.file}, self.folder, "", f"{self.folder}/none.jsonl"), "/h"), [])
|
||||
|
||||
|
||||
class Hook(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user