Rename loop-claude to build-release, with no alias
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""What the entry points that drive chunks share: loop-claude and do-epic.
|
||||
"""What the entry points that drive chunks share: build-release and do-epic.
|
||||
|
||||
Each runs a chunk as cycles of bin/agent_cycle/. cycle_start.py starts a cycle and chunk_run.py closes it, on the Loop this_loop.py holds, once claims.py has claimed the checkout. prompts.py words what every worker is told, project/ reads a checkout's premises, records and saved models, and drivers.py names the entry points. No module here imports an entry point's package, and bin/repo_checks/test_package_cycles.py fails on such an import.
|
||||
"""
|
||||
|
||||
@@ -17,7 +17,7 @@ UNFINISHED_LIMIT = 6
|
||||
|
||||
|
||||
class Run(typing.Protocol):
|
||||
"""What closing a cycle reads and replaces in an entry point's run of one chunk. ChunkRun below is one; loop-claude's LoopRun is another, since it hands the same fields on at a reload."""
|
||||
"""What closing a cycle reads and replaces in an entry point's run of one chunk. ChunkRun below is one; build-release's LoopRun is another, since it hands the same fields on at a reload."""
|
||||
# Every run is a dataclass, which is what lets closing a cycle replace its fields.
|
||||
__dataclass_fields__: typing.ClassVar[dict[str, typing.Any]]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""How entry points claim a checkout before they start a chunk in it, so that two never start the same chunk and do-epic never starts one where loop-claude runs.
|
||||
"""How entry points claim a checkout before they start a chunk in it, so that two never start the same chunk and do-epic never starts one where build-release runs.
|
||||
|
||||
An entry point holds `starting` on `project_lock` while it lists the windows of the checkout's chunks and starts new ones. Where the lock cannot be taken, `starting` yields a Failure, and the entry point doesn't start any chunk. It starts each chunk in a tmux window with CHUNK_FLAG, and hands that window the variables named with HANDED.
|
||||
"""
|
||||
@@ -13,13 +13,13 @@ from loop_state.paths import STATE_FOLDER
|
||||
from agent_cycle import tmux
|
||||
|
||||
# Under the home folder, a folder per project key holds LOCK.
|
||||
CLAIMS = f"{STATE_FOLDER}/loop-claude"
|
||||
# The file an entry point keeps locked with flock while it lists the windows of a project's chunks and starts new ones. Two loops whose chunks finish together then don't start a chunk twice, and do-epic, which holds the same lock, never starts a chunk in a checkout while loop-claude does.
|
||||
CLAIMS = f"{STATE_FOLDER}/build-release"
|
||||
# The file an entry point keeps locked with flock while it lists the windows of a project's chunks and starts new ones. Two loops whose chunks finish together then don't start a chunk twice, and do-epic, which holds the same lock, never starts a chunk in a checkout while build-release does.
|
||||
LOCK = "starting"
|
||||
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for loop-claude and `--chunk ABC-34 ABC-12` for do-epic. Nobody types it, so no panel picked it.
|
||||
# The flag that tells the entry point in a window its chunk, as `--chunk item-372` for build-release and `--chunk ABC-34 ABC-12` for do-epic. Nobody types it, so no panel picked it.
|
||||
CHUNK_FLAG = "--chunk"
|
||||
# The prefix of the variables both entry points read. A window gets the tmux server's environment, not the starting terminal's, so they are handed to each window by name.
|
||||
HANDED = "LOOP_CLAUDE_"
|
||||
HANDED = "BUILD_RELEASE_"
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
@@ -53,12 +53,12 @@ def project_lock(root: str, home: pathlib.Path) -> pathlib.Path:
|
||||
|
||||
|
||||
def loop_session(root: str, home: pathlib.Path) -> str:
|
||||
"""The tmux session that holds the windows of loop-claude's chunks of the checkout root."""
|
||||
"""The tmux session that holds the windows of build-release's chunks of the checkout root."""
|
||||
return tmux.session_name(tmux.LOOP, project_key(root, home))
|
||||
|
||||
|
||||
def loop_chunks(root: str, home: pathlib.Path, run: tmux.Tmux) -> list[tmux.Listed]:
|
||||
"""The windows of loop-claude's chunks that run in the checkout root. A session that runs another checkout's chunks under the same name doesn't hold any."""
|
||||
"""The windows of build-release's chunks that run in the checkout root. A session that runs another checkout's chunks under the same name doesn't hold any."""
|
||||
session = loop_session(root, home)
|
||||
running = [window for window in tmux.listed(session, run) if not window.dead]
|
||||
return running if running and tmux.owner(session, run) == root else []
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"""The entry points that drive chunks, each by its name as its workers, its judge and the human read it. A prompt function that takes a driver takes one of these."""
|
||||
LOOP_CLAUDE = "loop-claude"
|
||||
BUILD_RELEASE = "build-release"
|
||||
DO_EPIC = "do-epic"
|
||||
|
||||
@@ -19,8 +19,8 @@ class Models:
|
||||
|
||||
|
||||
# The environment variables that name the judge's and the worker's model for one run, over the model saved or configured.
|
||||
JUDGE_MODEL = "LOOP_CLAUDE_JUDGE_MODEL"
|
||||
WORKER_MODEL = "LOOP_CLAUDE_WORKER_MODEL"
|
||||
JUDGE_MODEL = "BUILD_RELEASE_JUDGE_MODEL"
|
||||
WORKER_MODEL = "BUILD_RELEASE_WORKER_MODEL"
|
||||
# The file, in CLAIMS under the home folder, that save_model keeps locked with flock while it rereads and replaces the models file. The models file's own folder is a checkout of this setup, which takes no lock file.
|
||||
MODELS_LOCK = "models.lock"
|
||||
|
||||
@@ -72,7 +72,7 @@ def save_model(project_key: str, chosen: str, paths: Paths, replace: typing.Call
|
||||
|
||||
|
||||
def read_models_file(saved: pathlib.Path) -> dict[str, str] | Failure:
|
||||
"""Each project's model, as the models file at saved maps them; none where there is no such file. The entry points, loop-claude and do-epic, and the replay tools read it."""
|
||||
"""Each project's model, as the models file at saved maps them; none where there is no such file. The entry points, build-release and do-epic, and the replay tools read it."""
|
||||
try:
|
||||
with open(saved, encoding="utf-8") as handle:
|
||||
models = json.load(handle)
|
||||
|
||||
@@ -12,7 +12,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
|
||||
|
||||
from failure import Failure
|
||||
from loop_effects.doubles import FakeEffects
|
||||
from chunk_driver.drivers import LOOP_CLAUDE
|
||||
from chunk_driver.drivers import BUILD_RELEASE
|
||||
from chunk_driver.project import model_choice
|
||||
from loop_state.paths import paths_from
|
||||
from text_files.file_writes import replace_file
|
||||
@@ -22,8 +22,8 @@ from agent_cycle.stop import Stop
|
||||
class Overridden(unittest.TestCase):
|
||||
def test_the_environment_names_the_judges_or_the_workers_model_over_the_default(self):
|
||||
self.assertEqual(model_choice.overridden({}, "saved"), model_choice.Models("saved", "saved"))
|
||||
self.assertEqual(model_choice.overridden({"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": ""}, "saved"), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.overridden({"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": "w"}, "saved"), model_choice.Models("j", "w"))
|
||||
self.assertEqual(model_choice.overridden({"BUILD_RELEASE_JUDGE_MODEL": "j", "BUILD_RELEASE_WORKER_MODEL": ""}, "saved"), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.overridden({"BUILD_RELEASE_JUDGE_MODEL": "j", "BUILD_RELEASE_WORKER_MODEL": "w"}, "saved"), model_choice.Models("j", "w"))
|
||||
|
||||
|
||||
class ModelsOfARun(unittest.TestCase):
|
||||
@@ -36,39 +36,39 @@ class ModelsOfARun(unittest.TestCase):
|
||||
def test_a_run_that_names_both_models_reads_no_models_file_and_asks_nothing(self):
|
||||
self.paths.models_file.write_text("not json")
|
||||
fake = FakeEffects()
|
||||
env = {"LOOP_CLAUDE_JUDGE_MODEL": "j", "LOOP_CLAUDE_WORKER_MODEL": "w"}
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, env, LOOP_CLAUDE, fake.effects()), model_choice.Models("j", "w"))
|
||||
env = {"BUILD_RELEASE_JUDGE_MODEL": "j", "BUILD_RELEASE_WORKER_MODEL": "w"}
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, env, BUILD_RELEASE, fake.effects()), model_choice.Models("j", "w"))
|
||||
self.assertEqual(fake.calls, [])
|
||||
|
||||
def test_a_run_that_names_one_model_takes_the_other_from_the_models_file(self):
|
||||
self.paths.models_file.write_text(json.dumps({"proj": "saved"}))
|
||||
fake = FakeEffects()
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"LOOP_CLAUDE_JUDGE_MODEL": "j"}, LOOP_CLAUDE, fake.effects()), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"LOOP_CLAUDE_WORKER_MODEL": "w"}, LOOP_CLAUDE, fake.effects()), model_choice.Models("saved", "w"))
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"BUILD_RELEASE_JUDGE_MODEL": "j"}, BUILD_RELEASE, fake.effects()), model_choice.Models("j", "saved"))
|
||||
self.assertEqual(model_choice.get_or_ask_models("proj", self.paths, {"BUILD_RELEASE_WORKER_MODEL": "w"}, BUILD_RELEASE, fake.effects()), model_choice.Models("saved", "w"))
|
||||
self.assertEqual(fake.calls, [])
|
||||
|
||||
def test_a_run_that_names_one_model_asks_for_the_projects_where_none_is_saved_and_saves_the_pick(self):
|
||||
fake, said = FakeEffects(inputs=["my-model"]), io.StringIO()
|
||||
with contextlib.redirect_stderr(said):
|
||||
models = model_choice.get_or_ask_models("proj", self.paths, {"LOOP_CLAUDE_JUDGE_MODEL": "j"}, LOOP_CLAUDE, fake.effects())
|
||||
models = model_choice.get_or_ask_models("proj", self.paths, {"BUILD_RELEASE_JUDGE_MODEL": "j"}, BUILD_RELEASE, fake.effects())
|
||||
self.assertEqual(models, model_choice.Models("j", "my-model"))
|
||||
self.assertEqual(json.loads(self.paths.models_file.read_text()), {"proj": "my-model"})
|
||||
self.assertIn(" proj runs on my-model\n", said.getvalue())
|
||||
|
||||
def test_off_a_terminal_it_stops_naming_the_driver_to_rerun_and_the_file_to_merge_the_model_into(self):
|
||||
fake = FakeEffects(on_terminal=False)
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, LOOP_CLAUDE, fake.effects())
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, BUILD_RELEASE, fake.effects())
|
||||
assert isinstance(stop, Stop)
|
||||
self.assertEqual(stop.code, 2)
|
||||
self.assertIn(f"pick proj's model, or merge {{\"proj\": \"<model>\"}} into {self.paths.models_file}", stop.reason)
|
||||
self.assertIn(LOOP_CLAUDE, stop.reason)
|
||||
self.assertIn(BUILD_RELEASE, stop.reason)
|
||||
self.assertFalse(self.paths.models_file.exists())
|
||||
|
||||
def test_stops_with_exit_1_where_the_models_file_maps_no_projects_to_model_names(self):
|
||||
for held in ("[]", '{"proj": 5}', '{"proj": ""}'):
|
||||
with self.subTest(held=held):
|
||||
self.paths.models_file.write_text(held)
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, LOOP_CLAUDE, FakeEffects().effects())
|
||||
stop = model_choice.get_or_ask_models("proj", self.paths, {}, BUILD_RELEASE, FakeEffects().effects())
|
||||
self.assertEqual(stop, Stop(1, f"could not read {self.paths.models_file}: not an object mapping projects to model names"))
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class SavingAModel(unittest.TestCase):
|
||||
return Failure("could not save")
|
||||
|
||||
fake.replace_file = replace
|
||||
self.assertEqual(model_choice.get_or_ask_model("proj", self.paths, LOOP_CLAUDE, fake.effects()), Stop(1, f"could not save the model in {self.paths.models_file}: could not save"))
|
||||
self.assertEqual(model_choice.get_or_ask_model("proj", self.paths, BUILD_RELEASE, fake.effects()), Stop(1, f"could not save the model in {self.paths.models_file}: could not save"))
|
||||
self.assertEqual(held, [True])
|
||||
|
||||
|
||||
@@ -155,10 +155,10 @@ class ModelPrompt(unittest.TestCase):
|
||||
def test_asks_again_until_an_answer_picks_a_model(self):
|
||||
with tempfile.TemporaryDirectory() as empty:
|
||||
fake = FakeEffects(inputs=["", "my-model"])
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), LOOP_CLAUDE, fake.effects()), "my-model")
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), BUILD_RELEASE, fake.effects()), "my-model")
|
||||
self.assertEqual(len(fake.made("input")), 2)
|
||||
fake = FakeEffects(inputs=[EOFError()])
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), LOOP_CLAUDE, fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended"))
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), BUILD_RELEASE, fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""What every entry point says to the worker each cycle. model_routing.review_choice chooses where the reviews run. review_launches and reruns put that choice into sentences, and escalation says where escalated subagents run; rung_sentences returns the sentences of all three. An entry point places them in a chunk's first prompt, as loop-claude does in bin/loop_claude/chunk/fresh_prompt.py. rungs_held repeats them at the end of a prompt after a step-up or an unfinished verdict."""
|
||||
"""What every entry point says to the worker each cycle. model_routing.review_choice chooses where the reviews run. review_launches and reruns put that choice into sentences, and escalation says where escalated subagents run; rung_sentences returns the sentences of all three. An entry point places them in a chunk's first prompt, as build-release does in bin/build_release/chunk/fresh_prompt.py. rungs_held repeats them at the end of a prompt after a step-up or an unfinished verdict."""
|
||||
import functools
|
||||
import typing
|
||||
|
||||
@@ -70,7 +70,7 @@ def shared_launches(choice: ReviewChoice, route: Route, project: ProjectRung) ->
|
||||
|
||||
|
||||
def taken_in_launches(choice: ReviewChoice) -> list[str]:
|
||||
"""The sentence naming the reviewers' rung each higher E + I picks, so the worker reviews an item it takes in on that rung in the same run, since loop-claude reads a taken-in item's E + I only as the cycle ends, and routes on it from the next cycle. None where no higher E + I picks a higher rung.
|
||||
"""The sentence naming the reviewers' rung each higher E + I picks, so the worker reviews an item it takes in on that rung in the same run, since build-release reads a taken-in item's E + I only as the cycle ends, and routes on it from the next cycle. None where no higher E + I picks a higher rung.
|
||||
|
||||
For a worker on the project's rung, routed by an item of E + I 6, it reads: `Where an item you take into the chunk has an E + I of 7 or more, launch each reviewer with the Agent tool set to `<rung>` from 7 and `<rung>` from 8.`
|
||||
"""
|
||||
@@ -93,7 +93,7 @@ def escalation(driver: str, route: Route, project: ProjectRung | None) -> list[s
|
||||
"""The prompt's escalation sentences, the marker's among them. None off the ladder or on its top rung. Where escalation_rungs opens none, the worker escalates only with the human's yes.
|
||||
Else they name the rungs escalation_rungs opens to a subagent, and offer to resume the worker one rung up for the rest of the chunk, up to the highest of those rungs.
|
||||
|
||||
For a worker one rung above the project's, routed by item 3 of L 3, they read: `When an escalation trigger in the setup's `CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `<rung>`, one rung above yours, and on each further trigger one rung higher, up to `<rung>`; above that, ask the human first.`, `Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number.` and `Where the hard part is the rest of the chunk, end your run instead, asking loop-claude for a higher rung and naming a trigger that fired since your last step-up, if any: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to `<rung>`.`
|
||||
For a worker one rung above the project's, routed by item 3 of L 3, they read: `When an escalation trigger in the setup's `CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `<rung>`, one rung above yours, and on each further trigger one rung higher, up to `<rung>`; above that, ask the human first.`, `Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number.` and `Where the hard part is the rest of the chunk, end your run instead, asking build-release for a higher rung and naming a trigger that fired since your last step-up, if any: once the judge finds it in your transcript, the next cycle resumes you one rung up, up to `<rung>`.`
|
||||
"""
|
||||
if project is None or route.rung not in project.ladder.rungs[:-1]:
|
||||
return []
|
||||
@@ -154,5 +154,5 @@ class RecordNames(typing.NamedTuple):
|
||||
|
||||
|
||||
def worker_prompts(driver: str, fresh: typing.Callable[[str, str, Route, ProjectRung | None, str], str], naming: str, names: RecordNames = RecordNames()) -> WorkerPrompts:
|
||||
"""The prompts of an entry point's cycles: its own fresh prompt, and the resumed prompt and rung sentences every entry point shares, each naming driver. resumed says what naming is. names is loop-claude's unless the entry point keeps records elsewhere, as do-epic does."""
|
||||
"""The prompts of an entry point's cycles: its own fresh prompt, and the resumed prompt and rung sentences every entry point shares, each naming driver. resumed says what naming is. names is build-release's unless the entry point keeps records elsewhere, as do-epic does."""
|
||||
return WorkerPrompts(driver, fresh, functools.partial(resumed, driver, naming), functools.partial(rungs_held, driver), *names)
|
||||
|
||||
@@ -75,7 +75,7 @@ class ProjectRouting(unittest.TestCase):
|
||||
self.paths.models_file.write_text(json.dumps({"acme": "claude-opus-5-5"}))
|
||||
shipped = read_ladder(SHIPPED)
|
||||
self.assertEqual(self.routing(), cycle_start.Routing(Models("claude-opus-5-5", "claude-opus-5-5"), shipped, SHIPPED))
|
||||
self.assertEqual(self.routing(env={"LOOP_CLAUDE_JUDGE_MODEL": "j"}), cycle_start.Routing(Models("j", "claude-opus-5-5"), shipped, SHIPPED))
|
||||
self.assertEqual(self.routing(env={"BUILD_RELEASE_JUDGE_MODEL": "j"}), cycle_start.Routing(Models("j", "claude-opus-5-5"), shipped, SHIPPED))
|
||||
own = self.config / "routing-ladder.json"
|
||||
own.write_text('[{"model": "claude-fable-5-2", "effort": "low"}]', encoding="utf-8")
|
||||
routing = self.routing()
|
||||
|
||||
@@ -10,8 +10,8 @@ from agent_cycle.tmux import Window
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Loop:
|
||||
"""What stays the same while an entry point drives one chunk in one process. loop-claude builds it once per process, so a reload builds it afresh; do-epic builds one per chunk."""
|
||||
# The checkout the loop runs in. loop-claude's LoopRun.root names it too, since a reload hands it on there.
|
||||
"""What stays the same while an entry point drives one chunk in one process. build-release builds it once per process, so a reload builds it afresh; do-epic builds one per chunk."""
|
||||
# The checkout the loop runs in. build-release's LoopRun.root names it too, since a reload hands it on there.
|
||||
root: str
|
||||
# The worker's session.
|
||||
session: Session
|
||||
@@ -19,6 +19,6 @@ class Loop:
|
||||
window: Window
|
||||
paths: Paths
|
||||
env: typing.Mapping[str, str]
|
||||
# The entry point's script, beside which chunk-preflight lies; an edit of loop-claude's reloads its loop.
|
||||
# The entry point's script, beside which chunk-preflight lies; an edit of build-release's reloads its loop.
|
||||
launcher: pathlib.Path
|
||||
effects: Effects
|
||||
|
||||
Reference in New Issue
Block a user