From 387a5ce50653da2115cee41441524fbb276dd87e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 23 Oct 2026 10:54:24 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20architecture=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1;=20finish=20"record",=20record?= =?UTF-8?q?=20the=20three=20meanings=20as=20a=20decision,=20name=20rule-ho?= =?UTF-8?q?ok's=20check=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 1 + bin/claude_code/trust.py | 2 +- bin/judge_replay/replay.py | 16 ++++----- bin/judge_replay/test_judge_replay.py | 12 +++---- bin/larv_review/history_commands.py | 2 +- bin/larv_review/main.py | 2 +- bin/loop_claude/cycle/run.py | 10 +++--- bin/loop_claude/escalation_mark.py | 2 +- bin/loop_claude/loop/main.py | 8 ++--- bin/loop_claude/test_loop_claude.py | 36 +++++++++---------- bin/model_routing/ladder.py | 2 +- bin/model_routing/route.py | 40 ++++++++++----------- bin/review_replay/main.py | 6 ++-- bin/routing_figures/test_routing_figures.py | 10 +++--- bin/rule_hook/main.py | 12 +++---- bin/rule_hook/rules.py | 2 +- bin/rule_hook/test_rule_hook.py | 12 +++---- bin/rung_replay/search.py | 2 +- bin/score_outcomes/main.py | 8 ++--- bin/score_outcomes/results.py | 2 +- bin/transcript_archive/outcomes.py | 16 ++++----- docs/decisions.md | 10 ++++++ todo.md | 2 +- 23 files changed, 113 insertions(+), 102 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 28ab0c76..ae169ef8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,6 +2,7 @@ Decisions live in `docs/decisions.md`: +- bin/: an outcome is an entry of a `.outcomes.md` file in loop-claude's archive, a record is a document tools or people keep entries in, and a place is what a comprehension seat names - bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor - bin/: the tools and their tests run on the host's Python, with no container - chunks: a chunk takes every unblocked item of its release that fires the same review passes, whatever its purpose, and an item above R 5 ships alone diff --git a/bin/claude_code/trust.py b/bin/claude_code/trust.py index de8e0b32..ae382904 100644 --- a/bin/claude_code/trust.py +++ b/bin/claude_code/trust.py @@ -31,7 +31,7 @@ def trust(config: pathlib.Path, roots: list[str]) -> None: def mark_trusted(config: object, roots: list[str]) -> tuple[dict, list[str]] | Failure: if not isinstance(config, dict) or not isinstance(projects := config.get("projects", {}), dict): return Failure('not an object whose "projects" is an object') - if (wrong := next((path for path, record in projects.items() if not isinstance(record, dict)), None)) is not None: + if (wrong := next((path for path, settings in projects.items() if not isinstance(settings, dict)), None)) is not None: return Failure(f"projects[{json.dumps(wrong)}] is not an object") untrusted = [path for path in roots if not projects.get(path, {}).get("hasTrustDialogAccepted")] marked = {path: {**projects.get(path, {}), "hasTrustDialogAccepted": True} for path in untrusted} diff --git a/bin/judge_replay/replay.py b/bin/judge_replay/replay.py index 587db8c1..0422ec83 100644 --- a/bin/judge_replay/replay.py +++ b/bin/judge_replay/replay.py @@ -16,12 +16,12 @@ Kind = str @dataclasses.dataclass(frozen=True) class Case: - """One archived verdict: on_record, judged at its UTC stamp.""" + """One archived verdict: the kind the archive gives it, judged at its UTC stamp.""" root: str task: str transcript: pathlib.Path at: str - on_record: Kind + archived: Kind def case_from(root: str, outcomes: str, transcript: pathlib.Path) -> Case | None: @@ -40,8 +40,8 @@ def sample(cases: list[Case], per_kind: int) -> list[Case]: seen: collections.Counter[Kind] = collections.Counter() kept = [] for found in sorted(cases, key=lambda found: (found.at, found.root, str(found.transcript)), reverse=True): - seen[found.on_record] += 1 - if seen[found.on_record] <= per_kind: + seen[found.archived] += 1 + if seen[found.archived] <= per_kind: kept.append(found) return kept[::-1] @@ -63,12 +63,12 @@ def verdict_kind(verdict: Verdict | Failure) -> Kind: def reproduced(case: Case, kind: Kind) -> list[Kind]: - """The kind on record, where the reply returns it: a rung is held only to a verdict the reference judge reproduces.""" - return [kind] if kind == case.on_record else [] + """The archived kind, where the reply returns it: a rung is held only to a verdict the reference judge reproduces.""" + return [kind] if kind == case.archived else [] def report(model: str, reference: Rung, cases: list[Case], replay: Replay[Case, Kind, Kind]) -> str: - kinds = collections.Counter(found.on_record for found in cases) + kinds = collections.Counter(found.archived for found in cases) unreproduced = [(found, kind) for found, kind in zip(cases, replay.on_reference) if not reproduced(found, kind)] lines = [ f"Replayed {len(cases)} verdicts of {model} projects: {', '.join(f'{count} {kind}' for kind, count in sorted(kinds.items()))}.", @@ -86,4 +86,4 @@ def report(model: str, reference: Rung, cases: list[Case], replay: Replay[Case, def missed_lines(missed: list[tuple[Case, Kind]]) -> list[str]: - return [f" {found.root} {found.at}: on record {found.on_record}, replayed {kind}" for found, kind in missed] + return [f" {found.root} {found.at}: archived {found.archived}, replayed {kind}" for found, kind in missed] diff --git a/bin/judge_replay/test_judge_replay.py b/bin/judge_replay/test_judge_replay.py index 8360f61d..8ef54a42 100644 --- a/bin/judge_replay/test_judge_replay.py +++ b/bin/judge_replay/test_judge_replay.py @@ -25,8 +25,8 @@ MIDDLE = Rung("claude-sonnet-5-5", "high") REFERENCE = Rung("claude-opus-5-5", "xhigh") -def case(at, on_record): - return Case("/code/p", "Do the next chunk.", TRANSCRIPT, at, on_record) +def case(at, archived): + return Case("/code/p", "Do the next chunk.", TRANSCRIPT, at, archived) class CaseFrom(unittest.TestCase): @@ -37,7 +37,7 @@ class CaseFrom(unittest.TestCase): def test_reads_each_kind_of_verdict(self): for verdict in (FINISHED, UNFINISHED, INTERRUPTED, ANSWERED): found = case_from("/code/p", f"Task: t\n\n2026-10-14T10:00:00Z {verdict}\n\nmore\n", TRANSCRIPT) - self.assertEqual(found.on_record, verdict) + self.assertEqual(found.archived, verdict) def test_skips_a_copy_with_no_verdict(self): self.assertIsNone(case_from("/code/p", "Task: t\n\n2026-10-14T10:00:00Z Stepped up\n\nWorker: y\n", TRANSCRIPT)) @@ -60,7 +60,7 @@ class VerdictKind(unittest.TestCase): class Reproduced(unittest.TestCase): - def test_holds_a_rung_to_a_verdict_only_where_the_reference_returned_the_kind_on_record(self): + def test_holds_a_rung_to_a_verdict_only_where_the_reference_returned_the_archived_kind(self): self.assertEqual(reproduced(case("2026-10-14T10:00:00Z", FINISHED), FINISHED), [FINISHED]) self.assertEqual(reproduced(case("2026-10-14T10:00:00Z", FINISHED), INTERRUPTED), []) @@ -72,10 +72,10 @@ class Report(unittest.TestCase): self.assertEqual(report("claude-opus-5-5", REFERENCE, cases, replay).splitlines(), [ "Replayed 2 verdicts of claude-opus-5-5 projects: 1 Verdict: finished, 1 Verdict: interrupt.", "The reference judge, claude-opus-5-5 at xhigh effort, reproduced 1. It returned another kind on:", - " /code/p 2026-10-14T10:00:00Z: on record Verdict: finished, replayed Verdict: unfinished", + " /code/p 2026-10-14T10:00:00Z: archived Verdict: finished, replayed Verdict: unfinished", "claude-sonnet-5-5 at high effort missed 0.", "claude-haiku-5-5 at xhigh effort missed 1:", - " /code/p 2026-10-14T10:00:01Z: on record Verdict: interrupt, replayed Verdict: finished", + " /code/p 2026-10-14T10:00:01Z: archived Verdict: interrupt, replayed Verdict: finished", "Lowest rung that, like each rung above it, returns every verdict the reference judge reproduces: claude-sonnet-5-5 at high effort", ]) missed_all = report("claude-opus-5-5", REFERENCE, cases, Replay([FINISHED, INTERRUPTED], [Tried(MIDDLE, [Miss(cases[1], INTERRUPTED, FINISHED)])], None)).splitlines() diff --git a/bin/larv_review/history_commands.py b/bin/larv_review/history_commands.py index 5dcf9314..057a0ce3 100644 --- a/bin/larv_review/history_commands.py +++ b/bin/larv_review/history_commands.py @@ -77,7 +77,7 @@ def scored_seats(given: SeatsFile) -> ScoringRun | Failure: def read_seats(path: pathlib.Path, paired: bool) -> tuple[Heading, SeatsFile] | Failure: - """The seats file and the heading its record goes under. Fails when the file names a commit the checkout lacks, or when the history already holds an entry on what it reads; it runs before anything is printed.""" + """The seats file and the heading its entry goes under. Fails when the file names a commit the checkout lacks, or when the history already holds an entry on what it reads; it runs before anything is printed.""" try: given = seats_file(path.read_text(encoding="utf-8")) except (OSError, UnicodeDecodeError) as failure: diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index 7e7d981c..6c8c0ce3 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -86,7 +86,7 @@ and the inherited architect vote alike overall in a paired ruling more often tha same way in a pair. It prints both counts. It opens `Unchecked:` until the history holds {pairs} such pairs and one paired ruling, then `Assumption holds:` or `Assumption fails:`, and exits 0 each time. -Each record is appended to the history, created when missing, under a heading of the current UTC +Each entry is appended to the history, created when missing, under a heading of the current UTC time and the seats file's first line. Each commit that line names must be in the checkout. It exits 1 when the history already holds an entry on what that line reads. diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index cad4a712..cf65353b 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -77,7 +77,7 @@ def ruling_step_up(cycle: Cycle, verdict: Verdict) -> StepUp | None: def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop: path = transcript_file(cycle.session) - failure = archive(cycle.project_archive, path, cycle.task, outcomes.stopped(cycle.route.record(), why), cycle.effects.now()) if path else None + failure = archive(cycle.project_archive, path, cycle.task, outcomes.stopped(cycle.route.worker_line(), why), cycle.effects.now()) if path else None # A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once. return Stop(1, f"{failure.reason}\n{stop.reason}".rstrip()) if failure and failure.reason != stop.reason else stop @@ -135,7 +135,7 @@ def keep_answer(cycle: Cycle, answered: QuotedAnswer, step_up: StepUp | None) -> if not path: return None # As in ask: the answer names the rung the worker ran on until then, and a step-up archived after it names the rung it runs on from then. - quoted = outcomes.answered(answered.question, prompts.QUOTE_SOURCES, answered.answer, answered.evidence, answered.escalation, str(judge_of(cycle)), ran_on(cycle, step_up).record()) + quoted = outcomes.answered(answered.question, prompts.QUOTE_SOURCES, answered.answer, answered.evidence, answered.escalation, str(judge_of(cycle)), ran_on(cycle, step_up).worker_line()) if failure := archive_stepped(cycle, path, quoted, step_up): return Stop(1, failure.reason) return None @@ -160,7 +160,7 @@ def ask(cycle: Cycle, transcript_path: str, ruling: Interrupt | QuotedAnswer, st question = question_for(ruling) # Archived now, so the transcript the question was asked on is kept with it; the human's answer then grows the transcript. # The interrupt names the rung the worker ran on before it; a step-up archived after it names the stepped rung, so the figures charge each stretch to its own rung. - interrupted = outcomes.interrupted(question, ruling.evidence, str(judge_of(cycle)), ruling.escalation, ran_on(cycle, step_up).record()) + interrupted = outcomes.interrupted(question, ruling.evidence, str(judge_of(cycle)), ruling.escalation, ran_on(cycle, step_up).worker_line()) if failure := archive_stepped(cycle, transcript_path, interrupted, step_up): return Stop(1, failure.reason) # Only the human may cut a release, so a release ready to cut opens claude's session at once. @@ -178,7 +178,7 @@ def ran_on(cycle: Cycle, step_up: StepUp | None) -> Route: def archive_stepped(cycle: Cycle, transcript_path: str, outcome: str, step_up: StepUp | None) -> Failure | None: """Archives the outcome of a ruling, then the step-up it made, if it made one. The first failure is returned.""" - for kept in (outcome, outcomes.stepped_up(step_up.after.record())) if step_up else (outcome,): + for kept in (outcome, outcomes.stepped_up(step_up.after.worker_line())) if step_up else (outcome,): if failure := archive(cycle.project_archive, transcript_path, cycle.task, kept, cycle.effects.now()): return failure return None @@ -191,7 +191,7 @@ def question_for(ruling: Interrupt | QuotedAnswer) -> str: def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop: - outcome = outcomes.finished(cycle.route.record(), verdict.evidence, str(judge_of(cycle))) if isinstance(verdict, Finished) else outcomes.unfinished(cycle.route.record(), verdict.evidence, str(judge_of(cycle)), verdict.escalation) + outcome = outcomes.finished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle))) if isinstance(verdict, Finished) else outcomes.unfinished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle)), verdict.escalation) if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcome, cycle.effects.now()): return Stop(1, failure.reason) if isinstance(verdict, Finished) and (failure := delete_session(cycle.session)): diff --git a/bin/loop_claude/escalation_mark.py b/bin/loop_claude/escalation_mark.py index 2ad8f198..bde24bba 100644 --- a/bin/loop_claude/escalation_mark.py +++ b/bin/loop_claude/escalation_mark.py @@ -1,6 +1,6 @@ """The escalation mark makes one escalation trigger step the worker up one rung, never two (docs/decisions.md → `routing: a worker whose run ends asking for a higher rung`). -A worker whose run ends asking loop-claude for a higher rung cites the trigger that fired, and the judge quotes the passage where it fired as the verdict's escalation. The mark, Route.escalated_at, is how many transcript entries the session held when an escalation last stepped the worker up, 0 before any. The session's transcript only grows, so the mark holds across cycles, and the archive's Worker: records keep it for a rerun. +A worker whose run ends asking loop-claude for a higher rung cites the trigger that fired, and the judge quotes the passage where it fired as the verdict's escalation. The mark, Route.escalated_at, is how many transcript entries the session held when an escalation last stepped the worker up, 0 before any. The session's transcript only grows, so the mark holds across cycles, and the archive's Worker: lines keep it for a rerun. - Stamp. stamped() writes on the judge's verdict how many entries the judge read. - Step. routing.after_unfinished() and routing.after_ruling() step the worker up on an escalation and move the mark to moved_to(verdict). A ruling's StepUp travels through the cycle's states, so the archive and the worker's next prompt name it. diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 154b39be..2199f00f 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -59,7 +59,7 @@ the judge finds in the transcript an escalation trigger that fired and the worke rung. The rules are in bin/loop_claude/routing.py and bin/model_routing/ladder.py, the choice of each review's rung in bin/model_routing/review_choice.py, and the prompts' wording in bin/loop_claude/cycle/prompts.py. Each verdict, interrupt, quoted answer, stop and -step-up in the archive ends with a Worker: line, the route's JSON record (Route.record in +step-up in the archive ends with a Worker: line, the route as JSON (Route.worker_line in bin/model_routing/route.py); a rerun resumes an open chunk on the latest route named there. A todo.md or an archive that cannot be read or parsed is said on stderr, and the chunk is routed without it. @@ -214,11 +214,11 @@ def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> def archive_step(archive_folder: pathlib.Path, session: Session, task: str, before: Route, after: Route | None, effects: Effects) -> Stop | None: - """Archives the route after an unfinished verdict as a step-up, where its record differs from the route before it: a higher rung, or a higher E + I taken in. The verdict itself names the route before, which its cycle ran on.""" - if after is None or after.record() == before.record(): + """Archives the route after an unfinished verdict as a step-up, where its worker line differs from the one before it: a higher rung, or a higher E + I taken in. The verdict itself names the route before, which its cycle ran on.""" + if after is None or after.worker_line() == before.worker_line(): return None path = transcript_file(session) - failure = archive(archive_folder, path, task, outcomes.stepped_up(after.record()), effects.now()) if path else None + failure = archive(archive_folder, path, task, outcomes.stepped_up(after.worker_line()), effects.now()) if path else None return Stop(1, failure.reason) if failure else None diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 89fc845e..5715ff43 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -32,7 +32,7 @@ from claude_code.reply import Limited from loop_claude.loop import main, reload, routing_check from transcript_archive import outcomes, write from transcript_archive.location import project_archive -from model_routing.route import Record, Route, route_from +from model_routing.route import Route, route_from, WorkerLine from loop_claude.stop import Stop from utc_stamp import utc from loop_claude.cycle.judge import verdict_from @@ -895,24 +895,24 @@ class Routing(unittest.TestCase): without_i = TODO.replace("| E | I | R |", "| E | R |").replace("|---|---|---|---|---|---|---|---|---|---|---|", "|---|---|---|---|---|---|---|---|---|---|").replace("| 4 | 3 | 5 | 10 |", "| 4 | 3 | 10 |").replace("| 4 | 2 | 3 | 7 |", "| 4 | 2 | 7 |").replace("| 1 | 1 | 1 | 1 |", "| 1 | 1 | 1 |") self.assertIsNone(routing.routed_item(without_i, NO_CUT)) - def test_archives_the_route_as_a_json_record_it_reads_back_field_by_field(self): + def test_archives_the_route_as_a_json_worker_line_it_reads_back_field_by_field(self): route = Route(self.HIGH, 3, 4, 5) - self.assertEqual(route.record(), '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 4, "escape_and_impact": 5}') - self.assertEqual(route_from(route.record()), route) - self.assertEqual(Route(Rung("worker-model")).record(), '{"model": "worker-model"}') + self.assertEqual(route.worker_line(), '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 4, "escape_and_impact": 5}') + self.assertEqual(route_from(route.worker_line()), route) + self.assertEqual(Route(Rung("worker-model")).worker_line(), '{"model": "worker-model"}') self.assertEqual(route_from('{"model": "worker-model"}'), Route(Rung("worker-model"))) marked = Route(self.HIGH, 3, 4, 5, escape_and_impact_taken_in=7, escalated_at=12) - self.assertEqual(marked.record(), '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 4, "escape_and_impact": 5, "escape_and_impact_taken_in": 7, "escalated_at": 12}') - self.assertEqual(route_from(marked.record()), marked) - self.assertEqual(route_from(Route(self.HIGH, escalated_at=3).record()), Route(self.HIGH, escalated_at=3)) + self.assertEqual(marked.worker_line(), '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 4, "escape_and_impact": 5, "escape_and_impact_taken_in": 7, "escalated_at": 12}') + self.assertEqual(route_from(marked.worker_line()), marked) + self.assertEqual(route_from(Route(self.HIGH, escalated_at=3).worker_line()), Route(self.HIGH, escalated_at=3)) - def test_leaves_the_count_of_unfinished_verdicts_out_of_the_record_so_a_rerun_restarts_it(self): - self.assertEqual(route_from(Route(self.HIGH, 3, 4, 5, unfinished=1).record()), Route(self.HIGH, 3, 4, 5)) + def test_leaves_the_count_of_unfinished_verdicts_out_of_the_worker_line_so_a_rerun_restarts_it(self): + self.assertEqual(route_from(Route(self.HIGH, 3, 4, 5, unfinished=1).worker_line()), Route(self.HIGH, 3, 4, 5)) - def test_reads_no_route_from_a_record_of_unknown_or_mistyped_fields_or_levels_off_their_scales(self): - for record in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": '): - with self.subTest(record=record): - self.assertIsNone(route_from(record)) + def test_reads_no_route_from_a_worker_line_of_unknown_or_mistyped_fields_or_levels_off_their_scales(self): + for line in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": '): + with self.subTest(line=line): + self.assertIsNone(route_from(line)) def test_reads_the_route_from_a_line_loop_claude_wrote_before_it_archived_json(self): self.assertEqual(route_from("claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5"), Route(self.HIGH, 3, 4, 5)) @@ -962,12 +962,12 @@ class RouteSources(unittest.TestCase): transcript.write_text(json.dumps({"type": "queue-operation", "timestamp": "1"}) + "\n") self.assertIsNone(main.archived_route(archive, opened)) with contextlib.redirect_stderr(io.StringIO()): - self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(route.record(), "working", "j", ""), NOW)) + self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(route.worker_line(), "working", "j", ""), NOW)) with contextlib.redirect_stderr(stderr): self.assertEqual(main.archived_route(archive, opened), route) self.assertEqual(stderr.getvalue(), "") with contextlib.redirect_stderr(io.StringIO()): - self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.stepped_up(Record('{"model": "claude-opus-5-5", "rung": 3}')), NOW + 1)) + self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.stepped_up(WorkerLine('{"model": "claude-opus-5-5", "rung": 3}')), NOW + 1)) with contextlib.redirect_stderr(io.StringIO()) as stderr: self.assertIsNone(main.archived_route(archive, opened)) self.assertEqual(stderr.getvalue(), 'routing the chunk afresh: the archive\'s latest Worker: line names no route loop-claude can read: {"model": "claude-opus-5-5", "rung": 3}\n') @@ -1013,7 +1013,7 @@ class Steps(unittest.TestCase): transcript.write_text(json.dumps({"type": "queue-operation", "timestamp": "1"}) + "\n") before = Route(self.OPUS, 3, 3, 4) with contextlib.redirect_stderr(io.StringIO()): - self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(before.record(), "working", "j", ""), NOW)) + self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(before.worker_line(), "working", "j", ""), NOW)) after = main.after_verdict(main.LoopRun(cycle_number=1, root="/r", task="Do it.", unfinished_evidence=""), self.OPUS, run.Concluded(Unfinished("working", 4), before)) self.assertIsNone(main.archive_step(archive, opened, "Do it.", before, after.route, FakeEffects().effects())) self.assertEqual(main.archived_route(archive, opened), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4)) @@ -1035,7 +1035,7 @@ class Steps(unittest.TestCase): transcript.write_text(json.dumps({"type": "queue-operation", "timestamp": "1"}) + "\n") before = Route(self.OPUS, 3, 3, 4) with contextlib.redirect_stderr(io.StringIO()): - self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(before.record(), "working", "j", ""), NOW)) + self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(before.worker_line(), "working", "j", ""), NOW)) after = main.after_verdict(main.LoopRun(cycle_number=1, root="/r", task="Do it.", unfinished_evidence=""), self.OPUS, run.Concluded(Unfinished("working", highest_escape_and_impact_taken_in=6), before)) self.assertIsNone(main.archive_step(archive, opened, "Do it.", before, after.route, FakeEffects().effects())) self.assertEqual(main.archived_route(archive, opened), Route(self.OPUS, 3, 3, 4, escape_and_impact_taken_in=6)) diff --git a/bin/model_routing/ladder.py b/bin/model_routing/ladder.py index 9e8e0f14..1a95becd 100644 --- a/bin/model_routing/ladder.py +++ b/bin/model_routing/ladder.py @@ -36,7 +36,7 @@ class Rung: return Rung(model, effort) return Rung(family.model, effort) if effort else family - # The one spelling of a rung. loop-claude hands it to rule-hook in environment variables, and archive lines written before route.Route.record hold it, so parse must keep reading it. + # The one spelling of a rung. loop-claude hands it to rule-hook in environment variables, and archive lines written before route.Route.worker_line hold it, so parse must keep reading it. def __str__(self) -> str: return f"{self.model} at {self.effort} effort" if self.effort else self.model diff --git a/bin/model_routing/route.py b/bin/model_routing/route.py index 3b1300e2..f7b4ac4d 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -1,4 +1,4 @@ -"""A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as a record beside each verdict.""" +"""A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as JSON on the Worker: line beside each verdict.""" import dataclasses import json import re @@ -9,9 +9,9 @@ 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" -# What Route.record writes. The outcome writers take only this as the worker, so mypy refuses a str(route) there. -Record = typing.NewType("Record", str) -# A worker line loop-claude wrote before it archived the route as a record. Nothing writes this format any more, so its wording never changes. route_from reads it for the chunks the routing figures still count, and for a chunk a rerun resumes across the change. +# What Route.worker_line writes. The outcome writers take only this as the worker, so mypy refuses a str(route) there. +WorkerLine = typing.NewType("WorkerLine", str) +# A worker line loop-claude wrote before it archived the route as JSON. Nothing writes this format any more, so its wording never changes. route_from reads it for the chunks the routing figures still count, and for a chunk a rerun resumes across the change. LEGACY_WORKER = re.compile(r"(?P.+?)(?:, routed by item (?P[0-9]+)'s L of (?P[0-9]+) and E \+ I of (?P[0-9]+))?(?:, taking in an E \+ I of (?P[0-9]+))?(?:, escalated at transcript entry (?P[0-9]+))?") @@ -40,7 +40,7 @@ class Route: unfinished counts the unfinished verdicts towards the next one-rung step; a reload hands it over with the rung. """ - # Each field below but rung and unfinished is a key of the archive's records, so renaming one makes the records already archived unreadable, and their chunks route afresh. + # Each field below but rung and unfinished is a key of the archive's worker lines, so renaming one makes the lines already archived unreadable, and their chunks route afresh. # The fields a loop-claude from before L and E + I replaced R + C hands on reload; the reloaded script drops such a route, and the chunk routes afresh. RETIRED: typing.ClassVar[frozenset[str]] = frozenset({"risk_and_complexity"}) rung: Rung @@ -71,38 +71,38 @@ class Route: """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.""" return max(self.escape_and_impact, self.escape_and_impact_taken_in) - def record(self) -> Record: - """What the archive records as each verdict's worker: a JSON object of the rung's model and effort and the RECORD_FIELDS, leaving out each that is 0 or empty; route_from reads it back.""" - fields = {"model": self.rung.model, "effort": self.rung.effort, **{name: getattr(self, name) for name in RECORD_FIELDS}} - return Record(json.dumps({name: value for name, value in fields.items() if value})) + def worker_line(self) -> WorkerLine: + """What the archive records as each verdict's worker: a JSON object of the rung's model and effort and the WORKER_LINE_FIELDS, leaving out each that is 0 or empty; route_from reads it back.""" + fields = {"model": self.rung.model, "effort": self.rung.effort, **{name: getattr(self, name) for name in WORKER_LINE_FIELDS}} + return WorkerLine(json.dumps({name: value for name, value in fields.items() if value})) -# The Route fields a record holds beside the rung's model and effort. A human reads the record in the archive, so it is flatter than the JSON a reload hands over (loop_claude/loop/reload.py) and leaves out zeros. It leaves out unfinished, so a rerun restarts that count. -RECORD_FIELDS = tuple(field.name for field in dataclasses.fields(Route) if field.name not in ("rung", "unfinished")) +# The Route fields a worker line holds beside the rung's model and effort. A human reads the line in the archive, so it is flatter than the JSON a reload hands over (loop_claude/loop/reload.py) and leaves out zeros. It leaves out unfinished, so a rerun restarts that count. +WORKER_LINE_FIELDS = tuple(field.name for field in dataclasses.fields(Route) if field.name not in ("rung", "unfinished")) def route_from(worker: str) -> Route | None: - """The route an archived worker line names, whether a record or a line written before records. None where it names no model, holds fields Route.record never writes, or holds levels off their scales; and for an older line, where it names a model without an effort.""" - fields = record_fields(worker) if worker.startswith("{") else legacy_fields(worker) + """The route an archived worker line names, whether JSON or a line written before JSON. None where it names no model, holds fields Route.worker_line never writes, or holds levels off their scales; and for an older line, where it names a model without an effort.""" + fields = json_fields(worker) if worker.startswith("{") else legacy_fields(worker) if fields is None or not Route.fits(fields): return None - return Route(Rung(fields["model"], fields.get("effort", "")), **{name: fields.get(name, 0) for name in RECORD_FIELDS}) + return Route(Rung(fields["model"], fields.get("effort", "")), **{name: fields.get(name, 0) for name in WORKER_LINE_FIELDS}) -def record_fields(record: str) -> dict[str, typing.Any] | None: - """The fields of a record Route.record wrote; None for any other text.""" +def json_fields(line: str) -> dict[str, typing.Any] | None: + """The fields of a line Route.worker_line wrote; None for any other text.""" try: - fields = json.loads(record) + fields = json.loads(line) except ValueError: return None - if not (isinstance(fields, dict) and isinstance(fields.get("model"), str) and isinstance(fields.get("effort", ""), str) and fields.keys() <= {"model", "effort", *RECORD_FIELDS}): + if not (isinstance(fields, dict) and isinstance(fields.get("model"), str) and isinstance(fields.get("effort", ""), str) and fields.keys() <= {"model", "effort", *WORKER_LINE_FIELDS}): return None # type(), not isinstance(): JSON true is no integer. - return fields if all(type(fields.get(name, 0)) is int and fields.get(name, 0) >= 0 for name in RECORD_FIELDS) else None + return fields if all(type(fields.get(name, 0)) is int and fields.get(name, 0) >= 0 for name in WORKER_LINE_FIELDS) else None def legacy_fields(line: str) -> dict[str, typing.Any] | None: - """The fields of a LEGACY_WORKER line, as record_fields gives them; None for any other text.""" + """The fields of a LEGACY_WORKER line, as json_fields gives them; None for any other text.""" found = LEGACY_WORKER.fullmatch(line) rung = Rung.parse(found["rung"]) if found else None if not (found and rung): diff --git a/bin/review_replay/main.py b/bin/review_replay/main.py index eb6ccd22..c3266aea 100644 --- a/bin/review_replay/main.py +++ b/bin/review_replay/main.py @@ -16,11 +16,11 @@ folder, holding only the reports written after the chunk began and before the ro finds nothing where its prompt still names the review folder, or names a file there, other than a round's report, that the folder did not hold from the chunk's start until the round's. -It first replays every round on the project's rung, the reference reviewer. Findings on record +It first replays every round on the project's rung, the reference reviewer. Archived findings that the reference reviewer does not raise again may rest on code or rules that have changed since; no rung is held to them. It then replays the rounds where the reference raised any, on each rung below, highest first, down to the ladder's lowest, and stops at the first rung that misses -one. For each replay, claude on the project's rung matches the report to the findings on record, +one. For each replay, claude on the project's rung matches the report to the archived findings, and counts a finding only where the report raises it as 🔴 or 🟡. The tool prints each finding a rung missed and the lowest rung that, like each rung above it, missed none. That rung is the evidence for running the pass's reviewer on it; the decision above records each run. @@ -150,7 +150,7 @@ def chunk_rounds(reviewer: str, checkout: str, chunk: pathlib.Path) -> list[Roun def code_of(found: Round, effects: Effects) -> Code | Failure: """Where, and at which commits, found's reviewer read the code, as the archive lets it be found again: the folder rounds.reviewed_path guesses from the prompt, and the commits authored by then. - Recording the reviewed commit at review time would need no such reading, but then no round archived before that change could be replayed. A wrong guess costs no rung: the reference reviewer, replayed on that code, finds fewer findings on record, and no rung is held to those. + Recording the reviewed commit at review time would need no such reading, but then no round archived before that change could be replayed. A wrong guess costs no rung: the reference reviewer, replayed on that code, finds fewer of the archived findings, and no rung is held to those. """ if not os.path.isdir(found.root): return Failure("the project has no checkout") diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 9b9e25c6..afade8d4 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -19,7 +19,7 @@ from model_routing.route import Route LOW = Rung("claude-opus-5-5", "medium") HIGH = Rung("claude-opus-5-5", "high") -LOW_ROUTE = Route(LOW, 7, 3, 4).record() +LOW_ROUTE = Route(LOW, 7, 3, 4).worker_line() def message(id_, at, *parts, model="claude-opus-5-5", tokens=(1, 10, 100)): @@ -50,7 +50,7 @@ class Measured(unittest.TestCase): message("m2", "2026-10-14T10:05:00.000Z", {"type": "text", "text": "done"}), message("m3", "2026-10-14T11:00:00.000Z", {"type": "text", "text": "on"}), ] - kept = stamped("2026-10-14T10:30:00Z", outcomes.unfinished(LOW_ROUTE, "e", "j", "")) + stamped("2026-10-14T10:30:00Z", outcomes.stepped_up(Route(HIGH).record())) + stamped("2026-10-14T12:00:00Z", outcomes.finished(Route(HIGH).record(), "merged", "j")) + kept = stamped("2026-10-14T10:30:00Z", outcomes.unfinished(LOW_ROUTE, "e", "j", "")) + stamped("2026-10-14T10:30:00Z", outcomes.stepped_up(Route(HIGH).worker_line())) + stamped("2026-10-14T12:00:00Z", outcomes.finished(Route(HIGH).worker_line(), "merged", "j")) found = measured(Chunk("log", [kept], worker, []), "/h") self.assertEqual(found.tokens["project"], {"log": 333}) self.assertEqual(found.tokens["subagent type"], {"worker": 333}) @@ -93,14 +93,14 @@ class Measured(unittest.TestCase): self.assertEqual(found.tokens["rung"], {str(LOW): 111}) def test_starts_no_route_for_a_chunk_no_item_routed(self): - kept = stamped("2026-10-14T10:00:00Z", outcomes.finished(Route(LOW).record(), "m", "j")) + kept = stamped("2026-10-14T10:00:00Z", outcomes.finished(Route(LOW).worker_line(), "m", "j")) found = measured(Chunk("log", [kept], [message("m1", "2026-10-14T09:00:00Z")], []), "/h") self.assertIsNone(found.start) self.assertEqual(found.tokens["rung"], {str(LOW): 111}) def test_puts_a_subagent_on_the_model_it_ran_at_the_effort_of_the_cycle_that_launched_it(self): - kept = stamped("2026-10-14T10:00:00Z", outcomes.unfinished(LOW_ROUTE, "e", "j", "")) + stamped("2026-10-14T11:00:00Z", outcomes.finished(Route(HIGH).record(), "m", "j")) + kept = stamped("2026-10-14T10:00:00Z", outcomes.unfinished(LOW_ROUTE, "e", "j", "")) + stamped("2026-10-14T11:00:00Z", outcomes.finished(Route(HIGH).worker_line(), "m", "j")) worker = [ message("m1", "2026-10-14T10:00:00.900Z"), message("m2", "2026-10-14T10:30:00Z", call("Agent", "a1", subagent_type="Explore", model="sonnet")), @@ -212,7 +212,7 @@ class Archive(unittest.TestCase): with contextlib.redirect_stderr(io.StringIO()): self.assertIsNone(write.archive(kept / "log", str(transcript), "t", outcomes.unfinished(LOW_ROUTE, "e", "j", ""), 1790000000)) transcript.write_text(json.dumps(first) + "\n" + json.dumps(message("m2", "2099-01-01T00:00:00Z")) + "\n") - self.assertIsNone(write.archive(kept / "log", str(transcript), "t", outcomes.finished(Route(HIGH).record(), "m", "j"), 4070908800)) + self.assertIsNone(write.archive(kept / "log", str(transcript), "t", outcomes.finished(Route(HIGH).worker_line(), "m", "j"), 4070908800)) (found,) = archive.measure_archive(kept, "/h", "").chunks self.assertEqual((found.start, found.unfinished), (LOW, 1)) self.assertEqual(found.tokens["rung"], {str(LOW): 111, str(HIGH): 111}) diff --git a/bin/rule_hook/main.py b/bin/rule_hook/main.py index 528083c3..c0351654 100644 --- a/bin/rule_hook/main.py +++ b/bin/rule_hook/main.py @@ -37,7 +37,7 @@ import time import typing from rule_hook.call import applied, Call, FILE_TOOLS, parsed_call, text -from rule_hook.rules import Breach, Checked, command_breaches, file_breaches, rules_help, verdict +from rule_hook.rules import Breach, check, Checked, command_breaches, file_breaches, rules_help from git_command import commits from failure import Failure from rule_hook.override_log import Log, log_path, logged, print_overrides, write_override @@ -67,7 +67,7 @@ def main(argv: list[str], stdin: str) -> int: if found is None: return 0 written, what, breaches = found - return answer(verdict(breaches, written, text(call.given, "file_path").endswith(".md"), call.tool == "Bash"), what, time.time()) + return answer(check(breaches, written, text(call.given, "file_path").endswith(".md"), call.tool == "Bash"), what, time.time()) def breaches_of(call: Call, home: str, environ: typing.Mapping[str, str]) -> tuple[str, str, list[Breach]] | None: @@ -85,12 +85,12 @@ def breaches_of(call: Call, home: str, environ: typing.Mapping[str, str]) -> tup return added, path, report_breaches(call, path, home) + file_breaches(path, before, added, after) -def answer(judged: Checked, what: str, now: float) -> int: - for message in judged.messages: +def answer(checked: Checked, what: str, now: float) -> int: + for message in checked.messages: print(message, file=sys.stderr) - if judged.blocked: + if checked.blocked: return 2 - logs = [(breach, reason, log_path(breach.directory)) for breach, reason in judged.overridden] + logs = [(breach, reason, log_path(breach.directory)) for breach, reason in checked.overridden] # Resolve every log before writing any, so a call that ends blocked has logged nothing. unloggable = [f"{breach.rule}: {log.reason}" for breach, _, log in logs if isinstance(log, Failure)] if not unloggable: diff --git a/bin/rule_hook/rules.py b/bin/rule_hook/rules.py index c928bdda..42a58c10 100644 --- a/bin/rule_hook/rules.py +++ b/bin/rule_hook/rules.py @@ -103,7 +103,7 @@ def overrides(written: str) -> tuple[dict[str, str], list[str]]: return granted, [f"rule-override {rule}: {reason}" for rule, reason in given if rule not in RULES or not reason] -def verdict(breaches: list[Breach], written: str, markdown: bool, bash: bool) -> Checked: +def check(breaches: list[Breach], written: str, markdown: bool, bash: bool) -> Checked: granted, malformed = overrides(written) blocking = [breach for breach in breaches if breach.rule not in granted] messages = [f"`{marker}` names no rule below, or gives no reason." for marker in malformed] if blocking else [] diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 47ce8e23..2636f00a 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -9,7 +9,7 @@ import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from rule_hook.rules import blocks, Breach, command_breaches, file_breaches, overrides, verdict +from rule_hook.rules import blocks, Breach, check, command_breaches, file_breaches, overrides from rule_hook.main import breaches_of from rule_hook.call import Call from git_command import Commit, commit_message, commits @@ -115,7 +115,7 @@ class CommandBreaches(unittest.TestCase): def test_an_override_quoting_the_human_s_yes_lets_a_round_past_the_cap_through(self): command = "git commit -m 'Answer stability round 4: 0 🔴, 1 🟡; fix' # rule-override round-cap: the human answered 'yes, one more'" - self.assertFalse(verdict(command_breaches(command, simple_commands(command, "/r", "/h"), "/h"), command, False, True).blocked) + self.assertFalse(check(command_breaches(command, simple_commands(command, "/r", "/h"), "/h"), command, False, True).blocked) def test_an_attribution_breaks_only_in_a_git_gh_or_tea_command(self): self.assertEqual(checked(f"tea pr create --description '{TRAILER}'"), ["no-ai-attribution"]) @@ -172,13 +172,13 @@ class Overrides(unittest.TestCase): def test_a_blocked_call_overrides_nothing_yet(self): breaches = [Breach("image-pin", "x", "/r"), Breach("action-pin", "y", "/r")] - judged = verdict(breaches, "# rule-override image-pin: a", False, False) - self.assertTrue(judged.blocked) - passed = verdict(breaches[:1], "# rule-override image-pin: a", False, False) + checked = check(breaches, "# rule-override image-pin: a", False, False) + self.assertTrue(checked.blocked) + passed = check(breaches[:1], "# rule-override image-pin: a", False, False) self.assertEqual((passed.blocked, passed.overridden), (False, [(breaches[0], "a")])) def test_a_markdown_file_is_told_the_html_comment(self): - self.assertIn("``", verdict([Breach("no-ai-attribution", "x", "/r")], "", True, False).messages[0]) + self.assertIn("``", check([Breach("no-ai-attribution", "x", "/r")], "", True, False).messages[0]) class OverrideLog(unittest.TestCase): diff --git a/bin/rung_replay/search.py b/bin/rung_replay/search.py index d8766939..1d1f521c 100644 --- a/bin/rung_replay/search.py +++ b/bin/rung_replay/search.py @@ -13,7 +13,7 @@ from model_routing.ladder import Rung AT_ONCE = 4 Case = typing.TypeVar("Case") -# What of a case's record a reply reproduces, such as a verdict's kind or a finding's index. +# What of an archived case a reply reproduces, such as a verdict's kind or a finding's index. Item = typing.TypeVar("Item") Reply = typing.TypeVar("Reply") T = typing.TypeVar("T") diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index a799b803..7a1ac8c2 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -138,11 +138,11 @@ def read_results(default: str) -> list[Result] | Failure: log = git("log", "--first-parent", "--format=%x1e%h %ct %at %p", "--name-only", default) if isinstance(log, Failure): return log - # Each record is a commit's line, then the files it changed against its first parent. - records = [record.splitlines() for record in log.split("\x1e")[1:]] - headers = [record[0] for record in records] + # Each commit's part of the log is its line, then the files it changed against its first parent. + commits = [part.splitlines() for part in log.split("\x1e")[1:]] + headers = [commit[0] for commit in commits] hashes = [header.split()[0] for header in headers] - plan = {short for short, record in zip(hashes, records) if "todo.md" in record} + plan = {short for short, commit in zip(hashes, commits) if "todo.md" in commit} results: list[Result] = [] for first, last, committed, landed in chunk_log(headers): # Only a chunk that changed todo.md can ship an item, so the others skip measure's git calls. diff --git a/bin/score_outcomes/results.py b/bin/score_outcomes/results.py index fa98f4fa..f9a91bf5 100644 --- a/bin/score_outcomes/results.py +++ b/bin/score_outcomes/results.py @@ -19,7 +19,7 @@ Landing = typing.Literal["merge", "rebase", "push"] Chunk = tuple[str, str, int, Landing] -# The tool's name and report call a Result an outcome; the code doesn't, since an outcome is an entry of loop-claude's archive (transcript_archive/outcomes.py). +# The tool's name and report call a Result an outcome; the code doesn't: docs/decisions.md → `bin/: an outcome is an entry of a .outcomes.md file`. @dataclasses.dataclass(frozen=True) class Result: """What the chunk that shipped an item measured. findings holds the 🔴 and 🟡 counts, None where a round title lacks them or the branch has no round. landed says how the chunk reached the default branch: by a merge commit, by a rebase that replayed its commits, or by commits never replayed.""" diff --git a/bin/transcript_archive/outcomes.py b/bin/transcript_archive/outcomes.py index b3c29d22..50d47e78 100644 --- a/bin/transcript_archive/outcomes.py +++ b/bin/transcript_archive/outcomes.py @@ -1,8 +1,8 @@ import re from markdown_text import quoted -from model_routing.route import Record from utc_stamp import STAMPED +from model_routing.route import WorkerLine TASK = "Task: " FINISHED = "Verdict: finished" @@ -29,23 +29,23 @@ def escalation_block(escalation: str) -> str: return f"Escalation:\n{quoted(escalation)}\n\n" if escalation else "" -def finished(worker: Record, evidence: str, judge: str) -> str: +def finished(worker: WorkerLine, evidence: str, judge: str) -> str: return f"{FINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{JUDGE}{judge}\n{WORKER}{worker}" -def unfinished(worker: Record, evidence: str, judge: str, escalation: str) -> str: +def unfinished(worker: WorkerLine, evidence: str, judge: str, escalation: str) -> str: """escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none.""" escalated = escalation_block(escalation) return f"{UNFINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" -def interrupted(question: str, evidence: str, judge: str, escalation: str, worker: Record) -> str: - """escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none. worker is the record of the route the worker ran on until the interrupt.""" +def interrupted(question: str, evidence: str, judge: str, escalation: str, worker: WorkerLine) -> str: + """escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none. worker is the line naming the route the worker ran on until the interrupt.""" escalated = escalation_block(escalation) return f"{INTERRUPTED}\n\n{question}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" -def answered(question: str, sources: str, answer: str, evidence: str, escalation: str, judge: str, worker: Record) -> str: +def answered(question: str, sources: str, answer: str, evidence: str, escalation: str, judge: str, worker: WorkerLine) -> str: """escalation and worker are as on interrupted.""" escalated = escalation_block(escalation) return f"{ANSWERED}\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{JUDGE}{judge}\n{WORKER}{worker}" @@ -56,12 +56,12 @@ def rejected(why: str, reply: str, judge: str) -> str: return f"{REJECTED}: {why}\n\nReply:\n{quoted(reply)}\n\n{JUDGE}{judge}" -def stepped_up(worker: Record) -> str: +def stepped_up(worker: WorkerLine) -> str: """The rung the next cycle steps up to, archived as it steps, so a rerun after any exit resumes on it.""" return f"Stepped up\n\n{WORKER}{worker}" -def stopped(worker: Record, why: str) -> str: +def stopped(worker: WorkerLine, why: str) -> str: return f"Stopped: {why}\n\n{WORKER}{worker}" diff --git a/docs/decisions.md b/docs/decisions.md index 71a96571..01b275ff 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -1,5 +1,15 @@ # Decisions +## bin/: an outcome is an entry of a `.outcomes.md` file in loop-claude's archive, a record is a document tools or people keep entries in, and a place is what a comprehension seat names + +2026-10-23, larv-review, through PR #367. Serves code health: a reader can trust that one word names one thing in every tool. Before, three tools used each of these words for different things. Each word kept the meaning it already had where renaming costs most: + +- An outcome: the archive's file names end in `.outcomes.md`, and the tools that read them find them by that suffix. score-outcomes' `Outcome` became `Result`, and rule-hook's became `Checked`. score-outcomes' CLI name and printed report keep "outcome", since they are public text. +- A record: "judge's records" is a term in `~/.claude/CLAUDE.md` → "Vocabulary", and reading-cost's help calls its file a record. A single item in such a document is an entry; the route the archive keeps is a worker line (`Route.worker_line`). The verb "to record" keeps its plain meaning. +- A place: the comprehension panel's term, also in the Vocabulary. A count of files is called `files`. + +Valid while the archive's file names, the Vocabulary and the panel keep these words. + ## bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor 2026-09-26, larv-review. Serves goal 2. The suite reruns itself on a `uv`-fetched interpreter of the version Install names: `ast.parse(feature_version=)` on the host's Python accepts the nested f-string 186181a fixed, a compile check passes a call newer than the floor, like 3.12's `itertools.batched`, and a `python3.N` on `PATH` is installed by hand on every machine and again at each bump. Valid while `uv` can fetch the floor interpreter and no machine taking the checkout ships an older Python. diff --git a/todo.md b/todo.md index 724dc777..8eab5112 100644 --- a/todo.md +++ b/todo.md @@ -173,7 +173,7 @@ Raised by the overrides pass of PR #296. The hook imports the main checkout's `r ### 101. Have `larv_review/history_commands.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects. -Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/history_commands.py:79` reads `time.time()`, then checks git (`:70`, `commit_exists`) and the history file (`:75`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout. +Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/history_commands.py:87` reads `time.time()`, then checks git (`:90`, `commit_exists`) and the history file (`:92`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout. ### 110. Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.