Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -9,11 +9,11 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from rung_replay.archive import archiving, print_report, replay_folder
|
||||
from rung_replay.command import down_from
|
||||
from rung_replay.archive import archiving, replay_folder
|
||||
from rung_replay.search import AT_ONCE, first_reply, Miss, Replay, replayed, Tried
|
||||
from rung_replay.command import down_from, print_report
|
||||
from loop_effects.effects import Effects
|
||||
from failure import Failure
|
||||
from rung_replay.search import first_reply, Miss, Replay, replayed, Tried
|
||||
from claude_code.reply import Limited
|
||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||
from model_routing.ladder import Rung
|
||||
@@ -34,8 +34,7 @@ def search(cases, candidates, replies, climbs=()):
|
||||
reply = replies[rung]
|
||||
return reply if isinstance(reply, Limited) else reply[case]
|
||||
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
return replayed(cases, REFERENCE, candidates, replay_one, lambda _, reply: sorted(reply), "cases", climbs), asked
|
||||
return replayed(cases, REFERENCE, candidates, replay_one, lambda _, reply: sorted(reply), "cases", lambda text: None, AT_ONCE, climbs), asked
|
||||
|
||||
|
||||
class Replayed(unittest.TestCase):
|
||||
@@ -96,8 +95,8 @@ class ArchivedRuns(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.folder = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) / "replays" / "tool-1"
|
||||
|
||||
def run_archived(self, replies):
|
||||
return archiving(effects(lambda args, cwd, prompt: replies.pop(0)), self.folder).claude
|
||||
def run_archived(self, replies, say=lambda text: None):
|
||||
return archiving(effects(lambda args, cwd, prompt: replies.pop(0)), self.folder, say).claude
|
||||
|
||||
def kept(self):
|
||||
return sorted(self.folder.glob("*.jsonl"))
|
||||
@@ -134,16 +133,15 @@ class ArchivedRuns(unittest.TestCase):
|
||||
raise FileNotFoundError(2, "No such file or directory")
|
||||
|
||||
with self.assertRaises(FileNotFoundError):
|
||||
archiving(effects(missing), self.folder).claude([], "/r", "p")
|
||||
archiving(effects(missing), self.folder, self.fail).claude([], "/r", "p")
|
||||
self.assertFalse(self.folder.exists())
|
||||
# A file where the folder's parent should be.
|
||||
self.folder.parent.parent.mkdir(exist_ok=True)
|
||||
self.folder.parent.write_text("")
|
||||
proc = subprocess.CompletedProcess(["claude"], 0, "{}", "")
|
||||
err = io.StringIO()
|
||||
with contextlib.redirect_stderr(err):
|
||||
self.assertIs(self.run_archived([proc])([], "/r", "p"), proc)
|
||||
self.assertIn(f"could not keep the run in {self.folder}: ", err.getvalue())
|
||||
said = []
|
||||
self.assertIs(self.run_archived([proc], said.append)([], "/r", "p"), proc)
|
||||
self.assertEqual([text.startswith(f"could not keep the run in {self.folder}: ") for text in said], [True])
|
||||
|
||||
def test_prints_the_report_and_keeps_it_beside_the_runs(self):
|
||||
out = io.StringIO()
|
||||
|
||||
Reference in New Issue
Block a user