diff --git a/CHANGELOG.md b/CHANGELOG.md index daccb60e..5292f3f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Reshape every project's `todo.md` to the new shape below: until it is reshaped, that is the project's only work, as it is while README.md lacks Goals and Audience, and `rank_todo.py` says so. First move every machine to this release: an older release rejects the new formula, so it fails on every reshaped `todo.md`. Then mark the README's goals `**Maintain:**` or `**Achieve:**`, score each item's L, E and I, and set a bar on the new scale below the score of every item to keep, since the old bar would drop most items. Until then, an old-shape `todo.md` still ranks by its own formula and weights. - `todo.md` ranks items by value per cost: this setup's own plan uses `Score = 100 * V / (2**S + 8)`, where 8 is a chunk's fixed cost, about one size-3 change, and `rank_todo.py --help` shows it. A Moves column replaces A, G and Goals, naming each achieve goal an item moves and how far, such as `1.1 by 8, 1.2 by 5`. V sums each named goal's weight times its move. `rank_todo.py` weighs each achieve goal by its position in README.md, the first heaviest, so the goal weights table goes. An item names the most specific goal it moves, never a goal beside its own sub-goal. `rules/todo-items.md` and `rank_todo.py --help` show the new shape. - L, E and I replace C, and set R. L is the chance the change holds a defect, from 1 to 4; E the chance a defect escapes tests and review, from 1 to 3; I the damage it would do, from 1 to 5, counting every project and session that runs the change. `rules/todo-items.md` defines each level in words, and `rank_todo.py` writes R as L + E + I − 2, at least 7 when I is 5 and at least 5 when I is 4. The table's score columns are `| L | E | I | R | S |`. `score-outcomes` takes `L E I S`, and reports how well L, E and I each order finished chunks by review rounds and 🔴 findings. -- `loop-claude` routes a chunk's worker on its item's L, from two rungs below the project's rung at L 1 to one above it at L 4. It routes the reviewers on the highest E + I among the chunk's items, the routed one and each the worker takes in, one rung above the project's for each point past 4, never below the worker's rung. It runs the judge of an Opus 5.5 project on the rung that E + I picks, never below the project's, and keeps it there when the worker steps up. The comprehension seats and the security pass stay on the project's rung. rule-hook holds each reviewer launch to the reviewers' rung, which `loop-claude` hands the worker in `LOOP_CLAUDE_REVIEWER_RUNG`. A delegated task's subagent takes the rung its L picks: `subagent-rung` takes L in place of R + C. Until a project reshapes its `todo.md`, every chunk there runs on the project's rung. Expect reviews of items whose defects would escape far or break much to cost more, and escalation from an item of L 4 to reach Fable 5.1 only with your yes. +- `loop-claude` routes a chunk's worker on its item's L, from two rungs below the project's rung at L 1 to one above it at L 4. It routes the reviewers on the highest E + I among the chunk's items, the routed one and each the worker takes in, one rung above the project's for each point past 4, never below the worker's rung. The worker's prompt names the rung each higher E + I picks, so a taken-in item is reviewed on it in the same run; from the next cycle, loop-claude routes on it. It runs the judge of an Opus 5.5 project on the rung that E + I picks, never below the project's, and keeps it there when the worker steps up. The comprehension seats and the security pass stay on the project's rung. rule-hook holds each reviewer launch to the reviewers' rung, which `loop-claude` hands the worker in `LOOP_CLAUDE_REVIEWER_RUNG`. A delegated task's subagent takes the rung its L picks: `subagent-rung` takes L in place of R + C. Until a project reshapes its `todo.md`, every chunk there runs on the project's rung. Expect reviews of items whose defects would escape far or break much to cost more, and escalation from an item of L 4 to reach Fable 5.1 only with your yes. - An item that restores a maintain goal the project breaks today is exempt as `defect`, and its Moves may name that maintain goal, weighed as the heaviest achieve goal. A defect ranks by its score like any item. Only two kinds rank ahead of the rest of their release: questions first, since an answer may change other items, then security items. - The stability reviewer applies `principles/technical-principles.md` as written, in place of its own copies of it. Its test-data check now asks for UUID v7, where it asked for randomised UUIDs. - larv-review's principles audit is a pass of its own, and runs on every chunk that changes code, config or tests, not only on one with an architectural decision. A chunk of prose or planning alone skips it. diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index a780e608..d94c9864 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,5 +1,5 @@ from model_routing.ladder import climbed, LADDER, position, review_rungs, ReviewKind, Rung -from model_routing.route import ESCALATION_MARKER, Route +from model_routing.route import ESCALATION_MARKER, HIGHEST_ESCAPE_AND_IMPACT, Route from loop_claude.routing import escalation_rungs from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES from markdown_text import listed, quoted @@ -38,7 +38,24 @@ def review_launches(route: Route, anchor: Rung | None) -> str: launches = "".join(f" Launch {listed(reviews, 'and')} with the Agent tool set to {rung.agent_args()}, {rung_named(rung, route, anchor)}." for rung, reviews in launched.items()) scan = " Run a full scan only from such a subagent, since the scan's agents run on the model that starts them." if rungs["security"] != route.rung else "" planning = f" Your rung is below the project's: launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan {anchor.model} ` prints." if position(route.rung) < position(anchor) else "" - return f"{launches}{scan}{planning}" + return f"{launches}{scan}{planning}{taken_in_launches(route, anchor)}" + + +def taken_in_launches(route: Route, anchor: Rung) -> str: + """The rung each higher E + I picks for the reviewers, so the worker reviews an item it takes in on that rung in the same run; the judge reports the item, and loop-claude routes on it, only from the next cycle. Empty where no higher E + I picks a higher rung. + + For a worker on Opus 5.5 at medium, routed by an item of E + I 6, it reads: ` Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort max` from an E + I of 7 and `model fable, effort max` from 8.` + """ + reviewers = review_rungs(anchor, route.rung, route.reviewed_on())["reviewer"] + higher: dict[Rung, int] = {} + for escape_and_impact in range(route.reviewed_on() + 1, HIGHEST_ESCAPE_AND_IMPACT + 1): + rung = review_rungs(anchor, route.rung, escape_and_impact)["reviewer"] + if position(rung) > position(reviewers): + higher.setdefault(rung, escape_and_impact) + if not higher: + return "" + picks = [f"`{rung.agent_args()}` from {'an E + I of ' if not index else ''}{escape_and_impact}" for index, (rung, escape_and_impact) in enumerate(higher.items())] + return f" Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: {listed(picks, 'and')}." def rung_named(rung: Rung, route: Route, anchor: Rung) -> str: diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index f2d13652..8a09cae4 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -54,7 +54,9 @@ item's E + I picks the reviewers' rung, stepping up from the cheapest rung by RE never below the worker's rung. The worker's first prompt names the rung and the item, and asks the worker to name each item the chunk takes, with its L and E + I. The prompt names the rung of each review that runs on a rung other than the worker's: the reviewers' rung for the reviewers, and the cheapest rung -for each comprehension seat and the security pass. When the worker runs below the cheapest rung, +for each comprehension seat and the security pass. It also names the reviewers' rung each higher +E + I picks, so the worker reviews an item it takes in on that rung in the same run. When the +worker runs below the cheapest rung, the prompt has it launch each subagent that files or scores todo.md items on the rung subagent-rung --plan prints. The prompt after each unfinished verdict says this again, since a step-up may have moved the worker. A reviewer or @@ -72,7 +74,7 @@ trigger it named fired (~/.claude/CLAUDE.md → "Working with the codebase" list stops two rungs above the rung the chunk's item picks, and the worker's prompts offer it only while the worker is below that limit. Each finished or unfinished verdict, stop and step-up in the archive names the worker's rung, with the item, L and E + I that routed the chunk and the highest -E + I taken in; a taken-in E + I that lifts the reviewers is archived as a step-up too. A rerun +E + I taken in; a taken-in E + I that picks a higher review rung is archived as a step-up too. A rerun resumes an open chunk on the latest route named there, and counts its unfinished verdicts afresh. A rung no longer on the ladder, or below the one its item's L picks, is dropped, and the chunk is routed afresh from todo.md. So is a chunk whose archived line names an R + C, as loop-claude wrote before diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 6466baf8..b69b4dee 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -624,13 +624,16 @@ class Routing(unittest.TestCase): self.assertEqual(routing.stepped(self.OPUS, Route(self.XHIGH), 0, True), Route(self.XHIGH, unfinished=1)) self.assertEqual(routing.stepped(self.OPUS, Route(self.SONNET, 3, 2, 4), 4, True), Route(self.HIGH, 3, 2, 4, unfinished=1)) - def test_keeps_an_e_plus_i_taken_in_only_where_it_lifts_the_reviewers(self): + def test_keeps_an_e_plus_i_taken_in_only_where_it_picks_a_higher_review_rung(self): taken = Route(self.OPUS, 3, 3, 4).taking_in(6) self.assertEqual(taken, Route(self.OPUS, 3, 3, 4, escape_and_impact_taken_in=6)) + self.assertEqual(taken.taking_in(7), Route(self.OPUS, 3, 3, 4, escape_and_impact_taken_in=7)) self.assertEqual(taken.taking_in(5), taken) + self.assertEqual(taken.taking_in(6), taken) self.assertEqual(Route(self.OPUS, 3, 3, 4).taking_in(4), Route(self.OPUS, 3, 3, 4)) - self.assertEqual(Route(self.OPUS, 3, 3, 4).taking_in(3), Route(self.OPUS, 3, 3, 4)) + self.assertEqual(Route(self.OPUS, 3, 2, 2).taking_in(4), Route(self.OPUS, 3, 2, 2)) self.assertEqual(Route(self.OPUS).taking_in(5), Route(self.OPUS, escape_and_impact_taken_in=5)) + self.assertEqual(Route(self.OPUS).taking_in(3), Route(self.OPUS)) self.assertEqual(Route(self.OPUS).taking_in(0), Route(self.OPUS)) def test_a_rung_an_edit_took_off_the_ladder_counts_as_the_projects(self): @@ -767,6 +770,9 @@ class Steps(unittest.TestCase): self.assertEqual(main.archived_route(archive, opened), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4)) self.assertIsNone(main.archive_step(archive, opened, after, after.route, FakeEffects().effects())) self.assertIsNone(main.archive_step(archive, opened, after, None, FakeEffects().effects())) + finished = main.after_verdict(after, self.OPUS, Finished("done")) + self.assertIsNone(main.archive_step(archive, opened, finished, after.route, FakeEffects().effects())) + self.assertEqual(main.archived_route(archive, opened), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4)) blocked = pathlib.Path(home, "blocked") blocked.write_text("") stop = main.archive_step(blocked, opened, after, before, FakeEffects().effects()) @@ -785,8 +791,6 @@ class Steps(unittest.TestCase): after = main.after_verdict(main.LoopRun(cycle_number=1, root="/r", task="Do it.", unfinished_evidence="", route=before), self.OPUS, Unfinished("working", 0, bundled_escape_and_impact=6)) self.assertIsNone(main.archive_step(archive, opened, after, before, FakeEffects().effects())) self.assertEqual(main.archived_route(archive, opened), Route(self.OPUS, 3, 3, 4, escape_and_impact_taken_in=6)) - lower = main.after_verdict(main.LoopRun(cycle_number=1, root="/r", task="Do it.", unfinished_evidence="", route=before), self.OPUS, Unfinished("working", 0, bundled_escape_and_impact=3)) - self.assertEqual(lower.route, Route(self.OPUS, 3, 3, 4, unfinished=1)) class WorkerArgs(unittest.TestCase): @@ -803,35 +807,44 @@ class WorkerArgs(unittest.TestCase): def test_keeps_every_review_on_the_projects_rung_while_the_worker_runs_below_it(self): opus = Rung("claude-opus-5-5", "medium") below = prompts.fresh("Do it.", "## Goals", Route(Rung("claude-sonnet-5-5", "high"), 3, 2, 4), opus) - self.assertIn(f"whether or not it is item 3. Launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung.{self.SCAN} Your rung is below the project's: launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 ` prints. When an escalation trigger", below) + self.assertIn(f"whether or not it is item 3. Launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung.{self.SCAN} Your rung is below the project's: launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan claude-opus-5-5 ` prints. Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort high` from an E + I of 5, `model opus, effort xhigh` from 6, `model opus, effort max` from 7 and `model fable, effort max` from 8. When an escalation trigger", below) self.assertNotIn("Launch each", prompts.fresh("Do it.", "## Goals", Route(opus, 3, 3, 4), opus)) def test_launches_reviewers_on_the_rung_the_items_e_plus_i_picks_above_the_workers(self): opus = Rung("claude-opus-5-5", "medium") level = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 3, 6), opus) - self.assertIn("whether or not it is item 3. Launch each reviewer with the Agent tool set to model opus, effort xhigh, the rung item 3's E + I of 6 picks. When an escalation trigger", level) + self.assertIn("whether or not it is item 3. Launch each reviewer with the Agent tool set to model opus, effort xhigh, the rung item 3's E + I of 6 picks. Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort max` from an E + I of 7 and `model fable, effort max` from 8. When an escalation trigger", level) below = prompts.fresh("Do it.", "## Goals", Route(Rung("claude-sonnet-5-5", "high"), 3, 2, 5), opus) self.assertIn(f"whether or not it is item 3. Launch each reviewer with the Agent tool set to model opus, effort high, the rung item 3's E + I of 5 picks.{self.SEATS}{self.SCAN} Your rung is below the project's:", below) self.assertNotIn("Launch each reviewer", prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 4, 6), opus)) + def test_names_the_reviewers_rung_each_higher_e_plus_i_an_item_taken_in_picks(self): + opus = Rung("claude-opus-5-5", "medium") + taking_in = " Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort high` from an E + I of 5, `model opus, effort xhigh` from 6, `model opus, effort max` from 7 and `model fable, effort max` from 8." + self.assertIn(f"whether or not it is item 3.{taking_in} When an escalation trigger", prompts.fresh("Do it.", "## Goals", Route(opus, 3, 3, 4), opus)) + self.assertIn(" Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort max` from an E + I of 7 and `model fable, effort max` from 8.", prompts.resumed("", Route(opus, 3, 3, 6), opus)) + self.assertIn(" Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort max` from an E + I of 7 and `model fable, effort max` from 8.", prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 4, 4), opus)) + self.assertNotIn("Where an item you take into", prompts.resumed("", Route(opus, 3, 3, 8), opus)) + self.assertNotIn("Where an item you take into", prompts.resumed("", Route(Rung("m")), None)) + def test_launches_reviewers_on_the_rung_the_highest_e_plus_i_taken_in_picks(self): opus = Rung("claude-opus-5-5", "medium") - self.assertIn(f"loop-claude runs you on claude-opus-5-5 at medium effort. Launch each reviewer with the Agent tool set to model opus, effort max, the rung an E + I of 7 taken into the chunk picks. When an escalation trigger", prompts.resumed("", Route(opus, 3, 3, 5, escape_and_impact_taken_in=7), opus)) + self.assertIn(f"loop-claude runs you on claude-opus-5-5 at medium effort. Launch each reviewer with the Agent tool set to model opus, effort max, the rung an E + I of 7 taken into the chunk picks. Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model fable, effort max` from an E + I of 8. When an escalation trigger", prompts.resumed("", Route(opus, 3, 3, 5, escape_and_impact_taken_in=7), opus)) self.assertIn(" Launch each reviewer with the Agent tool set to model opus, effort high, the rung an E + I of 5 taken into the chunk picks.", prompts.resumed("", Route(opus, escape_and_impact_taken_in=5), opus)) def test_keeps_seats_and_the_security_pass_on_the_projects_rung_while_the_worker_runs_above_it(self): opus = Rung("claude-opus-5-5", "medium") above = prompts.fresh("Do it.", "## Goals", Route(Rung("claude-opus-5-5", "high"), 3, 4, 4), opus) stepped_up = prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 3, 4), opus) - self.assertIn(f"{prompts.ANSWERS_RECORDED}. loop-claude runs you on claude-opus-5-5 at high effort.{self.SEATS}{self.SCAN} When an escalation trigger", stepped_up) + self.assertIn(f"{prompts.ANSWERS_RECORDED}. loop-claude runs you on claude-opus-5-5 at high effort.{self.SEATS}{self.SCAN} Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort xhigh` from an E + I of 6, `model opus, effort max` from 7 and `model fable, effort max` from 8. When an escalation trigger", stepped_up) self.assertNotIn("the project's", prompts.resumed("", Route(opus, 3, 3, 4), opus)) self.assertNotIn("runs you on", prompts.resumed("", Route(Rung("m")), None)) - self.assertIn(f"whether or not it is item 3.{self.SEATS}{self.SCAN} When an escalation trigger", above) + self.assertIn(f"whether or not it is item 3.{self.SEATS}{self.SCAN} Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort xhigh` from an E + I of 6, `model opus, effort max` from 7 and `model fable, effort max` from 8. When an escalation trigger", above) def test_names_the_rungs_an_escalation_trigger_lets_the_worker_hand_a_task_to_at_most_two_above_its_items(self): opus = Rung("claude-opus-5-5", "medium") fresh = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 3, 4), opus) - self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.", fresh) + self.assertIn("whether or not it is item 3. Where an item you take into the chunk has a higher E + I, launch each reviewer on the rung it picks: `model opus, effort high` from an E + I of 5, `model opus, effort xhigh` from 6, `model opus, effort max` from 7 and `model fable, effort max` from 8. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.", fresh) self.assertIn(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.", prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 3, 4), opus)) self.assertIn(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand the hard part of a task to a subagent with the Agent tool set to `model opus, effort max`, one rung above yours, only once the human agrees; loop-claude will not resume you higher for a trigger either, so ask the human for that yes. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.", prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 3, 4), opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-1", "max"), 3, 4, 8), opus)) @@ -1010,6 +1023,16 @@ class LoopRuns(unittest.TestCase): off_scale = dataclasses.asdict(state) off_scale["route"]["likelihood"] = 9 self.assertIsNone(reload.decode_handed(json.dumps(off_scale), main.LoopRun)) + older = dataclasses.asdict(state) + del older["route"]["escape_and_impact_taken_in"] + self.assertEqual(reload.decode_handed(json.dumps(older), main.LoopRun), state) + taken = dataclasses.replace(state, route=dataclasses.replace(state.route, escape_and_impact_taken_in=7)) + self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(taken)), main.LoopRun), taken) + for taken_in in (9, 5): + with self.subTest(taken_in=taken_in): + handed = dataclasses.asdict(state) + handed["route"]["escape_and_impact_taken_in"] = taken_in + self.assertIsNone(reload.decode_handed(json.dumps(handed), main.LoopRun)) def test_drops_a_route_an_older_loop_claude_handed_under_r_plus_c_so_the_chunk_routes_afresh(self): older = {"cycle_number": 3, "root": "/r", "task": "do it", "unfinished_evidence": "", "route": {"rung": {"model": "claude-opus-5-5", "effort": "high"}, "item": 3, "risk_and_complexity": 11, "unfinished": 1}} diff --git a/bin/model_routing/route.py b/bin/model_routing/route.py index d00be5f6..15e7b22d 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -4,7 +4,7 @@ import re import typing from todo_table import LEVELS -from model_routing.ladder import Rung +from model_routing.ladder import REVIEW_STEPS, Rung # How a worker opens the prompt of a subagent it escalates a task to, `Escalation trigger 2: …`: docs/decisions.md → `routing: a worker hands a task one rung up`. ESCALATION_MARKER = "Escalation trigger" @@ -21,9 +21,12 @@ class ArchivedWorker(typing.NamedTuple): escape_and_impact_taken_in: int +HIGHEST_ESCAPE_AND_IMPACT = LEVELS["E"] + LEVELS["I"] + + def on_its_scale(escape_and_impact: int) -> bool: """Whether E + I is a level on the scales todo_table.LEVELS gives; E and I each start at 1.""" - return 2 <= escape_and_impact <= LEVELS["E"] + LEVELS["I"] + return 2 <= escape_and_impact <= HIGHEST_ESCAPE_AND_IMPACT def on_their_scales(likelihood: int, escape_and_impact: int) -> bool: @@ -31,7 +34,7 @@ def on_their_scales(likelihood: int, escape_and_impact: int) -> bool: return 1 <= likelihood <= LEVELS["L"] and on_its_scale(escape_and_impact) -def levels_fit(item: int, likelihood: int, escape_and_impact: int, escape_and_impact_taken_in: int = 0) -> bool: +def levels_fit(item: int, likelihood: int, escape_and_impact: int, escape_and_impact_taken_in: int) -> bool: """Whether a route may hold these: an item with levels on their scales, or no item and no levels; and no E + I taken in, or one on its scale above the item's, as Route.taking_in keeps.""" routed = on_their_scales(likelihood, escape_and_impact) if item else not (likelihood or escape_and_impact) return routed and (escape_and_impact_taken_in == 0 or (on_its_scale(escape_and_impact_taken_in) and escape_and_impact_taken_in > escape_and_impact)) @@ -64,8 +67,8 @@ class Route: return levels_fit(fields.get("item", 0), fields.get("likelihood", 0), fields.get("escape_and_impact", 0), fields.get("escape_and_impact_taken_in", 0)) def taking_in(self, escape_and_impact: int) -> "Route": - """The route after the judge saw the worker take in an item of this E + I, 0 for none: it keeps the E + I only where it lifts reviewed_on, so the archive records no step-up that lifts nothing.""" - return dataclasses.replace(self, escape_and_impact_taken_in=escape_and_impact) if escape_and_impact > self.reviewed_on() else self + """The route after the judge saw the worker take in an item of this E + I, 0 for none: it keeps the E + I only where REVIEW_STEPS steps it further than reviewed_on, so the archive records no step-up that picks no higher review rung.""" + return dataclasses.replace(self, escape_and_impact_taken_in=escape_and_impact) if REVIEW_STEPS.get(escape_and_impact, 0) > REVIEW_STEPS.get(self.reviewed_on(), 0) else self def reviewed_on(self) -> int: """The E + I that picks the reviewers' and the judge's rung: the routed item's or the highest taken in, whichever is higher; 0 for neither.""" diff --git a/docs/decisions.md b/docs/decisions.md index 756eee71..4f9cb743 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -244,7 +244,7 @@ Only chunks run below the project's rung can prove that a cheaper worker holds q While the worker runs above the project's rung, loop-claude's prompt has it launch the comprehension seats and the security pass's subagent on the project's rung too. So the seats score every chunk on one rung, and the security pass spends no more than the project chose. The prompt after each unfinished verdict repeats this, since a step-up may have taken the worker above the project's rung. The other reviewers never run below the worker's rung: a worker climbs because its chunk proved harder than its score said, which is when a cheaper reviewer is the bigger risk. A reviewer or seat that rules the work below standard may rerun one rung up: `review: a reviewer or comprehension seat that rules the work below standard`. -On 2026-10-16 lilleman routed the reviewers on their item's E + I as well, on either side of the project's rung, which may lift them above both the worker's rung and the project's: how far a defect would escape, and what it would break, set how hard review must look (goal 1.1). loop-claude names that rung in the worker's prompt, and hands it to the worker's claude beside the project's and the worker's, so rule-hook holds each reviewer launch to it. A low E + I never steps a reviewer below the project's rung: lilleman chose to lower a pass only where a replay shows a lower rung finding every 🔴 and 🟡 the project's rung finds, which `todo.md` item 159 measures for each pass. An item the worker takes in beyond the routed one counts too: the judge reports the highest E + I the worker states for one, and loop-claude archives it with the route, so a rerun keeps it. A defect in a taken-in item escapes and breaks as far as one in the routed item. +On 2026-10-16 lilleman routed the reviewers on their item's E + I as well, on either side of the project's rung, which may lift them above both the worker's rung and the project's: how far a defect would escape, and what it would break, set how hard review must look (goal 1.1). loop-claude names that rung in the worker's prompt, and hands it to the worker's claude beside the project's and the worker's, so rule-hook holds each reviewer launch to it. A low E + I never steps a reviewer below the project's rung: lilleman chose to lower a pass only where a replay shows a lower rung finding every 🔴 and 🟡 the project's rung finds, which `todo.md` item 159 measures for each pass. An item the worker takes in beyond the routed one counts too, since a defect in it escapes and breaks as far as one in the routed item. The worker's prompt names the reviewers' rung each higher E + I picks, so the worker reviews a taken-in item on it in the same run. The judge reports the highest E + I the worker states for one, and from the next cycle loop-claude routes on it and archives it with the route, so a rerun keeps it. Valid until the trial on real chunks shows whether a worker below the project's rung holds quality. diff --git a/todo.md b/todo.md index da7b98f7..a4ca7414 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 174` +`Next ID = 175` ## Items @@ -42,6 +42,7 @@ | 171 | 0.3.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 3.2 | | 165 | 0.3.0 | | | **Make this repo's tests assert the facts a prompt or help text carries in place of its sentences, and drop the tests that scan source or assert a constant.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4, 1.4 by 3 | 3.0 | | 169 | 0.3.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 2.7 | +| 174 | 0.3.0 | | | **Ask the worker of a chunk no item routed to name each todo.md item it takes, with its L and E + I, so the judge can route on an item it takes in.** | 1 | 2 | 3 | 4 | 2 | 1.1 by 1 | 1.8 | | 122 | 0.4.0 | | | **Assemble the judge's prompt in `bin/loop_claude/cycle/judge.py`, importing only wording the worker also sees, and call the worker "the worker" in it.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5, 1.4 by 5 | 10.3 | | 158 | 0.4.0 | | decision | **Measure the fixed cost of a chunk from loop-claude's archive, in tokens and hours against its items' S, and set F in `Score = 100 * V / (2**S + F)` to it.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 5, 1.4 by 5 | 10.3 | | 170 | 0.4.0 | | decision | **Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 10 chunks have shipped under them, from how well L, E and I order their review rounds and 🔴 findings.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 3, 1.4 by 5 | 10.0 | @@ -230,6 +231,10 @@ A test audit across lilleman's projects on 2026-10-16 found 10 of 33 sampled tes The hook judges a call before it runs, and `changed` in `bin/rule_hook/todo_check.py` compares `todo.md` with the index and HEAD as they stand then. A call that edits `todo.md` and commits it, such as a heredoc script followed by `git commit`, passes unchecked: PR #296's commit 149108e did, and the override marker it carried was never logged. larv-review's gate still runs `rank_todo.py --check`, so an unranked plan stops at merge rather than at commit. A git pre-commit hook would see the staged file. +### 174. Ask the worker of a chunk no item routed to name each todo.md item it takes, with its L and E + I, so the judge can route on an item it takes in. + +The principles pass of PR #301 found that only `routed_by` in `bin/loop_claude/cycle/prompts.py` asks the worker to name each item it takes with its L and E + I, and `fresh` uses it only where an item routed the chunk. In an unrouted chunk the judge has no levels to report, so neither the taken-in L nor the taken-in E + I lifts the worker, the reviewers or the judge, and the prompt names no reviewers' rung for a higher E + I. + ### 122. Assemble the judge's prompt in `bin/loop_claude/cycle/judge.py`, importing only wording the worker also sees, and call the worker "the worker" in it. All four seats of PR #257's scoring run named `bin/loop_claude/cycle/judge.py:16` `JUDGE_RULES`. The prompt is spliced from constants in `cycle/prompts.py` (`ANSWER_DESTINATIONS`, `ANSWERS_RECORDED`, `either`) and `project/records.py` (`HUMAN_RULE_NAMES`), so a reader rebuilds it from three files. It says "the agent" where the code and `CLAUDE.md` → "Vocabulary" say "worker". Wording the worker also sees, such as `ANSWER_DESTINATIONS` in `prompts.resumed`, may stay in `cycle/prompts.py`. Make `JUDGE_RULES` easier to read.