Answer stability round 1: 0 🔴, 6 🟡 (1 misread); name a checkout by its real path, pick a chunk's repo once, test the step line, the repo's model and ladder, and a clone
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import contextlib
|
||||
import dataclasses
|
||||
import io
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -118,11 +120,12 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
|
||||
assert not isinstance(config, Failure)
|
||||
store, record = self.backend(config, "ABC-12")
|
||||
epic = main.EpicRun("ABC-12", config, store, record, paths, env or {}, pathlib.Path("/b/do-epic"), fake.effects())
|
||||
root = main.chunk_root(self.issues[1], epic)
|
||||
assert isinstance(root, str)
|
||||
place = main.chunk_root(self.issues[1], epic)
|
||||
assert isinstance(place, tuple)
|
||||
root, in_repo = place
|
||||
loop = Loop(root=root, session=main.session_named("A ABC-12 do-epic ABC-21", paths.claude_code_transcripts), window=tmux.Window("epic-ABC-12", "ABC-21", "%1"), paths=paths, env=env or {}, launcher=pathlib.Path("/b/do-epic"), effects=fake.effects())
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
found = main.next_cycle(LoopRun(1, root, "", "", chunk="ABC-21"), loop, epic)
|
||||
found = main.next_cycle(LoopRun(1, root, "", "", chunk="ABC-21"), loop, in_repo, epic)
|
||||
assert isinstance(found, main.Cycle), found
|
||||
return found
|
||||
|
||||
@@ -175,7 +178,7 @@ class TheHumansRun(DoEpicTest):
|
||||
fake = FakeEffects()
|
||||
code, out, _ = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn("started no chunk in the tmux session epic-ABC-12\n", out)
|
||||
self.assertIn("started no chunk\n", out)
|
||||
self.assertNotIn("attach-session", [args[0] for args in fake.tmux_calls])
|
||||
|
||||
def test_stops_without_its_settings_or_on_a_cap_it_cannot_read(self) -> None:
|
||||
@@ -207,6 +210,31 @@ class TheHumansRun(DoEpicTest):
|
||||
self.assertIn("started ABC-20, ABC-22 in the tmux session epic-ABC-12\n", out)
|
||||
self.assertEqual([args[args.index("-c") + 1] for args in fake.tmux_calls if args[0] in ("new-session", "new-window")], [str(self.home / "code/api"), str(self.home / "code/web")])
|
||||
|
||||
def test_clones_a_missing_repo_from_the_host_of_the_repos_located_before_it(self) -> None:
|
||||
for name in ("api", "web"):
|
||||
configured(self, self.home / "code" / name, home=self.home)
|
||||
shutil.rmtree(self.home / "code/web")
|
||||
self.issues = [issue("ABC-20", "repo:api"), issue("ABC-22", "repo:web")]
|
||||
fake = FakeEffects(on_terminal=False, git=["git@host.example:team/api.git", ""])
|
||||
code, out, err = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("started ABC-20, ABC-22 in the tmux session epic-ABC-12\n", out)
|
||||
clones = [what for seam, what in fake.calls if seam == "git" and "clone" in what]
|
||||
self.assertEqual([what[what.index("--") + 1:] for what in clones], [["git@host.example:team/web", str(self.home / "code/web")]])
|
||||
|
||||
def test_names_a_checkout_as_loop_claude_does_whatever_way_its_config_spells_it(self) -> None:
|
||||
real = self.home / "code" / "api"
|
||||
real.mkdir(parents=True)
|
||||
(self.home / "work").mkdir()
|
||||
(self.home / "work/api").symlink_to(real)
|
||||
configured(self, self.home / "work/api", home=self.home)
|
||||
self.issues = [issue("ABC-20", "repo:api")]
|
||||
fake = FakeEffects(on_terminal=False)
|
||||
code, _, err = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertEqual([args[args.index("-c") + 1] for args in fake.tmux_calls if args[0] == "new-session"], [str(real)])
|
||||
self.assertEqual([args[-2:] for args in fake.tmux_calls if "@chunk-root" in args], [["@chunk-root", str(real)]])
|
||||
|
||||
|
||||
class AChunksRun(DoEpicTest):
|
||||
def worker(self) -> Worker:
|
||||
@@ -231,7 +259,7 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertNotIn("Work the Jira issue", " ".join(streamed[1]))
|
||||
|
||||
def test_every_text_of_a_run_names_do_epic_as_what_drives_it(self) -> None:
|
||||
fake = FakeEffects(streams=[self.worker()] * 3, claude=[judged("unfinished"), judged("interrupt"), judged("finished")], inputs=["Use B."], git=UNREAD)
|
||||
fake = FakeEffects(streams=[self.worker()] * 3, claude=[judged("unfinished", escalation="working"), judged("interrupt"), judged("finished")], inputs=["Use B."], git=UNREAD)
|
||||
code, _, err = self.run_main(["--chunk", "ABC-21", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
prompts = [" ".join(what) for seam, what in fake.calls if seam == "stream_claude"]
|
||||
@@ -244,8 +272,10 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("The human answered your question at do-epic's terminal:\nUse B.", prompts[2])
|
||||
for text in judged_with:
|
||||
self.assertIn("what do-epic told it on [loop] lines, latest last:\n", text)
|
||||
self.assertIn(escalation_mark.asks_higher_rung(chunk_prompt.DRIVER), text)
|
||||
self.assertIn("asking do-epic for a higher rung", text)
|
||||
self.assertIn("do-epic in ", fake.dms[0])
|
||||
self.assertNotIn("\n\n[step] ", judged_with[0])
|
||||
self.assertIn("\n\n[step] do-epic stepped the worker up a rung here", judged_with[1])
|
||||
|
||||
def test_stops_for_the_human_after_six_unfinished_cycles_naming_do_epic(self) -> None:
|
||||
fake = FakeEffects(streams=[self.worker()] * 6, claude=[judged("unfinished")] * 6, git=UNREAD)
|
||||
@@ -280,6 +310,64 @@ class AChunksRun(DoEpicTest):
|
||||
self.assertIn("the chunk finished; started no other\n", out)
|
||||
self.assertIn("Squash every merge.", [what[1] for seam, what in fake.calls if seam == "claude"][0])
|
||||
|
||||
def repo_chunk(self) -> pathlib.Path:
|
||||
"""Makes ABC-20 the one issue, a chunk in the repo api whose checkout holds its premises; the folder of the repo's config."""
|
||||
checkout = self.home / "code" / "api"
|
||||
folder = configured(self, checkout, home=self.home)
|
||||
(checkout / "README.md").write_text("## Goals\nServe the API.\n\n## Audience\nIts callers.\n", encoding="utf-8")
|
||||
self.issues = [issue("ABC-20", "repo:api")]
|
||||
return folder
|
||||
|
||||
def test_a_chunk_in_a_repo_routes_on_the_repos_model(self) -> None:
|
||||
folder = self.repo_chunk()
|
||||
models = self.home / ".claude/loop-claude-models.json"
|
||||
models.parent.mkdir(parents=True, exist_ok=True)
|
||||
models.write_text(json.dumps({folder.name: "claude-fable-5-2", "other": "claude-opus-5-5"}), encoding="utf-8")
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD)
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, {"TMUX_PANE": "%1"})
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("=== cycle 1, worker on claude-fable-5-2 at low effort ===\n", out)
|
||||
|
||||
def test_a_chunk_in_a_repo_stops_where_the_repos_ladder_or_records_cannot_be_read(self) -> None:
|
||||
folder = self.repo_chunk()
|
||||
(folder / "routing-ladder.json").write_text("[", encoding="utf-8")
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], FakeEffects(git=UNREAD), MODELS)
|
||||
self.assertEqual((code, out), (1, ""))
|
||||
self.assertIn(f"{folder / 'routing-ladder.json'}", err.strip().splitlines()[-1])
|
||||
(folder / "routing-ladder.json").unlink()
|
||||
(self.home / "code/api/docs/decisions.md").mkdir(parents=True)
|
||||
fake = FakeEffects(git=UNREAD)
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual((code, out), (1, ""))
|
||||
self.assertIn("decisions.md", err.strip().splitlines()[-1])
|
||||
self.assertIn("decisions.md", fake.dms[0])
|
||||
|
||||
def test_an_issue_that_is_a_humans_or_names_no_repo_is_no_chunk(self) -> None:
|
||||
for labels, why in ((("do-epic-human",), "it is a human's task"), ((), "no label names its repo")):
|
||||
with self.subTest(labels):
|
||||
self.issues = [issue("ABC-20", *labels)]
|
||||
fake = FakeEffects(git=UNREAD)
|
||||
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn(f"ABC-20 is no chunk: {why}\n", err)
|
||||
self.assertEqual([seam for seam, _ in fake.calls if seam == "stream_claude"], [])
|
||||
|
||||
def test_a_chunk_stays_in_its_repo_when_its_labels_change_under_it(self) -> None:
|
||||
self.repo_chunk()
|
||||
store = MemoryEpic("ABC-12", list(self.issues))
|
||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
|
||||
class Relabelling(Worker):
|
||||
def __call__(inner, *args: object, **kwargs: object) -> object:
|
||||
store.issues[:] = [issue("ABC-20", "do-epic-claude")]
|
||||
return super().__call__(*args, **kwargs)
|
||||
|
||||
worker = Relabelling(paths_from(self.home).claude_code_transcripts.parent)
|
||||
fake = FakeEffects(streams=[worker, self.worker()], claude=[judged("unfinished"), judged("finished")], git=UNREAD)
|
||||
code, _, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertIn("Serve the API.", [what[1] for seam, what in fake.calls if seam == "claude"][1])
|
||||
|
||||
def test_a_chunk_in_a_repo_without_premises_stops(self) -> None:
|
||||
configured(self, self.home / "code" / "api", home=self.home)
|
||||
self.issues = [issue("ABC-20", "repo:api")]
|
||||
@@ -329,7 +417,7 @@ class WhatAWorkerJudgeAndHumanRead(DoEpicTest):
|
||||
self.assertNotIn("Chunk items:", texts[1])
|
||||
# The worker's prompt and the judge's rules word the request for a higher rung alike, from one place.
|
||||
for text in (texts[0], texts[3]):
|
||||
self.assertIn(escalation_mark.asks_higher_rung(chunk_prompt.DRIVER), text)
|
||||
self.assertIn("asking do-epic for a higher rung", text)
|
||||
self.assertEqual(escalation_mark.asks_higher_rung(chunk_prompt.DRIVER), "asking do-epic for a higher rung")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user