From 24549589ecb8bd304db691ff594af434837b5d74 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 16 Oct 2026 12:56:20 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20principles=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20cite=20item=20171=20in=20th?= =?UTF-8?q?e=20figures=20decision,=20check=20a=20handed=20route's=20levels?= =?UTF-8?q?=20as=20a=20value,=20carry=20the=20item=20and=20levels=20in=20A?= =?UTF-8?q?rchivedWorker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/loop_claude/loop/reload.py | 9 +++------ bin/loop_claude/test_loop_claude.py | 3 +++ bin/model_routing/route.py | 31 +++++++++++++++++++---------- bin/routing_figures/measure.py | 2 +- docs/decisions.md | 2 +- todo.md | 2 +- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2768417f..c26546dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - 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. -- `rule-hook` refuses an Agent call that launches a reviewer, a comprehension seat or the security pass on a rung below the one `loop-claude` names for it, and takes no override: pass the model and effort the refusal names. A seat or the security pass is held to the project's rung, and a reviewer to the reviewers' rung below. +- `rule-hook` refuses an Agent call that launches a reviewer, a comprehension seat or the security pass on a rung below the one `loop-claude` names for it, and takes no override: pass the model and effort the refusal names. A seat or the security pass is held to the project's rung, and a reviewer to the reviewers' rung above. ## 0.1.0 diff --git a/bin/loop_claude/loop/reload.py b/bin/loop_claude/loop/reload.py index d8105ffa..89be44c1 100644 --- a/bin/loop_claude/loop/reload.py +++ b/bin/loop_claude/loop/reload.py @@ -58,13 +58,10 @@ def decoded_as(value: object, kind: typing.Any) -> typing.Any: if not isinstance(value, dict) or not required <= value.keys() <= shape.keys(): return REJECTED fields = {name: decoded_as(field, shape[name]) for name, field in value.items()} - if any(field in (REJECTED, RETIRED) for field in fields.values()): - return REJECTED - try: - return kind(**fields) - except ValueError: - # A dataclass that checks its fields, as Route does, refuses a handed state that breaks them. + # A dataclass that checks its fields, as Route does, names the check fits. + if any(field in (REJECTED, RETIRED) for field in fields.values()) or not getattr(kind, "fits", lambda _: True)(fields): return REJECTED + return kind(**fields) return value if type(value) is kind else REJECTED diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 790ccff6..ee9dc3b6 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -908,6 +908,9 @@ class LoopRuns(unittest.TestCase): self.assertIsNone(reload.decode_handed(json.dumps(handed), main.LoopRun)) del handed["route"]["rung"] self.assertIsNone(reload.decode_handed(json.dumps(handed), main.LoopRun)) + off_scale = dataclasses.asdict(state) + off_scale["route"]["likelihood"] = 9 + self.assertIsNone(reload.decode_handed(json.dumps(off_scale), 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 f64cb98c..6de827be 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -14,9 +14,10 @@ LEVELS_ROUTED = re.compile(r"L of (?P[0-9]+) and E \+ I of (?P bool: @@ -24,9 +25,14 @@ def on_their_scales(likelihood: int, escape_and_impact: int) -> bool: return 1 <= likelihood <= LEVELS["L"] and 2 <= escape_and_impact <= LEVELS["E"] + LEVELS["I"] +def levels_fit(item: int, likelihood: int, escape_and_impact: int) -> bool: + """Whether a route may hold these: an item with levels on their scales, or no item and no levels.""" + return on_their_scales(likelihood, escape_and_impact) if item else not (likelihood or escape_and_impact) + + @dataclasses.dataclass(frozen=True) class Route: - """A chunk's worker rung, and the plan item that picked it, 0 for none, with its L, which picked the worker's rung, and its E + I, which picks its reviewers'. A route with an item holds levels on their scales, and one without holds none, so no rung is picked from a level off its scale. + """A chunk's worker rung, and the plan item that picked it, 0 for none, with its L, which picked the worker's rung, and its E + I, which picks its reviewers'. A route holds only levels that levels_fit, so no rung is picked from a level off its scale. unfinished counts the unfinished verdicts towards the next one-rung step; a reload hands it over with the rung. """ @@ -39,9 +45,15 @@ class Route: unfinished: int = 0 def __post_init__(self) -> None: - if (self.item and not on_their_scales(self.likelihood, self.escape_and_impact)) or (not self.item and (self.likelihood or self.escape_and_impact)): + # A guard against a programming error, which nothing catches: route_from and the reload decoder check fits before they build a route. + if not levels_fit(self.item, self.likelihood, self.escape_and_impact): raise ValueError(f"a route by item {self.item} cannot hold an L of {self.likelihood} and an E + I of {self.escape_and_impact}") + @staticmethod + def fits(fields: typing.Mapping[str, typing.Any]) -> bool: + """Whether a route may be built from these fields, as the reload decoder asks of a handed one.""" + return levels_fit(fields.get("item", 0), fields.get("likelihood", 0), fields.get("escape_and_impact", 0)) + def __str__(self) -> str: """What the archive records as each verdict's worker; ROUTED reads it back.""" return f"{self.rung}, routed by item {self.item}'s L of {self.likelihood} and E + I of {self.escape_and_impact}" if self.item else str(self.rung) @@ -51,16 +63,15 @@ def archived_worker(worker: str) -> ArchivedWorker | None: """What an archived worker line names; None for a model run off the ladder.""" found = ROUTED.fullmatch(worker) rung = Rung.parse(found["rung"]) if found else None - return ArchivedWorker(rung, bool(found["item"])) if found and rung else None + return ArchivedWorker(rung, int(found["item"] or 0), found["levels"] or "") if found and rung else None def route_from(worker: str) -> Route | None: """The route an archived worker line names; None for a model run off the ladder, or a route by anything but levels on their scales.""" archived = archived_worker(worker) - if archived is None or not archived.routed: + if archived is None or not archived.item: return Route(archived.rung) if archived else None - found = typing.cast(re.Match[str], ROUTED.fullmatch(worker)) - levels = LEVELS_ROUTED.fullmatch(found["levels"]) - if not levels or not on_their_scales(int(levels["likelihood"]), int(levels["escape_and_impact"])): + levels = LEVELS_ROUTED.fullmatch(archived.levels) + if not levels or not levels_fit(archived.item, int(levels["likelihood"]), int(levels["escape_and_impact"])): return None - return Route(archived.rung, int(found["item"]), int(levels["likelihood"]), int(levels["escape_and_impact"])) + return Route(archived.rung, archived.item, int(levels["likelihood"]), int(levels["escape_and_impact"])) diff --git a/bin/routing_figures/measure.py b/bin/routing_figures/measure.py index ee11c017..29199c6c 100644 --- a/bin/routing_figures/measure.py +++ b/bin/routing_figures/measure.py @@ -94,7 +94,7 @@ def measured(chunk: Chunk, home: str) -> ChunkFigures: start = archived_worker(cycles[0][1]) if cycles else None return ChunkFigures( tokens=tokens, - start=start.rung if start and start.routed else None, + start=start.rung if start and start.item else None, rounds_past_first=rounds_past_first(chunk.worker, home), unfinished=sum(len(UNFINISHED_AT.findall(kept)) for kept in chunk.outcomes), delegated=delegated, diff --git a/docs/decisions.md b/docs/decisions.md index f59da4e4..e19d3631 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -260,7 +260,7 @@ Valid while a model switch inside a session discards its prompt cache. The cost of a cheaper worker shows as extra review rounds and unfinished verdicts. Every 20 cycles across the archive, loop-claude measures them in code, with no model run (goal 1.4), and interrupts lilleman with the calls not raised before, when chunks routed onto a rung took more of either than chunks routed onto the next rung up, each rung with 5 chunks or more. Five keeps one odd chunk from calling for a change (goal 1.2). It also calls when the reports of 5 or more subagents of one type were longer than the tool results they read, so a delegated search cost the worker more context than it saved. `bin/routing_figures/` measures and words the calls. A loop on another project cannot commit here, so it writes the figures and the calls raised at the archive's root, and this repo's next chunk files the plan item, as `AGENTS.md` says. Off a terminal, a call is said on stderr and the loop goes on: it is about this setup, not the running project's chunk. A reset line in the calls file restarts the figures after a routing change, so they show whether the change worked. -Valid while loop-claude's archive holds every finished chunk's review rounds and unfinished verdicts. +Since 2026-10-16 the reviewers run on the rung their item's E + I picks, apart from the worker's, so a lower worker rung's chunks may take more rounds from stronger reviewers, and a call could blame the worker's rung for them; `todo.md` item 171 groups the rounds by the reviewers' rung too. Valid while loop-claude's archive holds every finished chunk's review rounds and unfinished verdicts. ## routing: a worker delegates a task only where it needs just the task's conclusion, and each subagent runs on the rung its task's L picks from the project's rung, never below the project's rung when it files or scores todo.md items diff --git a/todo.md b/todo.md index 9531bdb8..8eff0566 100644 --- a/todo.md +++ b/todo.md @@ -41,7 +41,7 @@ | 168 | 0.3.0 | | | **Name the project's rung `project` across `bin/loop_claude`, in place of `anchor`, as `bin/model_routing/ladder.py` names it.** | 2 | 1 | 3 | 4 | 3 | 1.1 by 3, 1.4 by 3 | 6.2 | | 82 | 0.3.0 | | principle | **Sort `AGENTS.md`'s decision titles and `docs/decisions.md`'s entries by title.** | 2 | 2 | 1 | 3 | 4 | 1.1 by 4, 1.4 by 4 | 5.5 | | 162 | 0.3.0 | | owner | **Script each step that 0.2.0's chunks repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4, 1.5 by 4 | 4.9 | -| 171 | 0.3.0 | | | **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 | +| 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 | | 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 |