From 3a77ebdb0d7a0ca425b3c57ca69c3e98765a4494 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 02:46:41 +0100 Subject: [PATCH 01/20] Re-score item 319 to L 4, S 5 after counting its size --- docs/reading-cost.md | 17 +++++++++++++++++ todo.md | 30 +++++++++++++++--------------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index f240976b..4cbc768f 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -2396,3 +2396,20 @@ Read most (opens and searches): - `bin/transcript_archive/test_transcript_archive.py` 3 - `skills/larv-review/SKILL.md` 3 - `bin/loop_claude/loop/close.py` 2 + +## Reading cost, chunk f7dbc8c79fac, finished 2026-11-17T01:44:51Z + +100764 new input tokens before the first commit. + +Read most (opens and searches): + +- `docs/decisions.md` 12 +- `README.md` 6 +- `bin/judge_replay/main.py` 6 +- `bin/judge_replay/test_judge_replay.py` 6 +- `bin/review_replay/main.py` 5 +- `bin/review_replay/test_review_replay.py` 4 +- `bin/claude_code/test_claude_code.py` 3 +- `bin/loop_claude/cycle/judge.py` 3 +- `bin/rung_replay/test_rung_replay.py` 3 +- `bin/claude_code/entries.py` 2 diff --git a/todo.md b/todo.md index 1bc3a4c8..7a457d84 100644 --- a/todo.md +++ b/todo.md @@ -17,13 +17,13 @@ | 338 | 0.12.0 | | owner | **Script each step that 0.9.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.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 2.3 | | 288 | 0.12.0 | | | **Point the two reading-cost decisions at code health and goal 1.4's counter-signal, in place of the goal 1.1 they cite.** | 1 | 2 | 1 | 2 | 1 | code health by 1, 1.4 by 1 | 2.2 | | 391 | 0.12.0 | | | **Read and write a Jira epic issue's description and a Confluence record page through the lossless pair, so saving an unedited document leaves it unchanged.** | 3 | 2 | 3 | 6 | 5 | 1.6 by 6, 1.1 by 3 | 1.9 | -| 319 | 0.12.0 | | | **Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session.** | 3 | 2 | 3 | 6 | 4 | 1.1 by 2, 1.4 by 2 | 1.2 | | 309 | 0.12.0 | | | **Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.** | 2 | 2 | 2 | 4 | 2 | 1.4 by 3 | 1.2 | | 299 | 0.12.0 | | | **Replay the archived judge verdicts through code rules and a classifier trained locally on the archive, and file an item for each verdict kind one of them decides with no missed interrupt.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.0 | | 311 | 0.12.0 | | | **Hand each worker's claude a Bash output ceiling that saves longer output to a file, and refuse a Read of a session transcript under `~/.claude/projects`.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.0 | | 316 | 0.12.0 | | | **Launch comprehension seats as an agent type of their own under `agents/`, without `CLAUDE.md` and the skill and agent listings a general-purpose subagent carries.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.0 | | 339 | 0.12.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.0 | | 341 | 0.12.0 | | | **Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.0 | +| 319 | 0.12.0 | | | **Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 2, 1.4 by 2 | 0.9 | | 310 | 0.12.0 | | | **Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 0.9 | | 393 | 0.12.0 | | decision | **Step an L 3 worker one rung up and an L 4 worker two up from the project's rung, as lilleman ruled on 2026-11-14.** | 2 | 1 | 3 | 4 | 4 | 1.4 by 3 | 0.9 | | 298 | 0.12.0 | | | **Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.** | 3 | 3 | 3 | 7 | 4 | 1.4 by 2, 1.5 by 1 | 0.9 | @@ -142,20 +142,6 @@ Touches: - `bin/plan_store/test_jira_epic.py`: `Editing`, `Filing` - `bin/record_store/test_confluence_page.py`: `ConfluencePageTest` -### 319. Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session. - -On SWE-bench Verified with Haiku 4.5 and Opus 4.7, handing the strong model the weak model's transcript solved 69.2% at $1.61 a task; starting the strong model fresh solved 79.2% at $0.90 (arXiv 2608.24358, The Handoff Tax). A model switch also rereads the whole context uncached (Claude Code prompt caching docs). A worker that steps from Sonnet 5.5 to Opus 5.5 by `--resume` is the raw handoff; an effort-only step within one model keeps the cache and isn't. The escalated subagent, which starts fresh with the trigger's evidence, already follows the pattern that won. - -Bench it first on `workflow-bench`: resume against a fresh start with a brief. The brief is the chunk's item, its branch and diff, open findings and the trigger. lilleman approved on 2026-11-11. Revise the decision `routing: a worker whose run ends asking for a higher rung…`. - -Touches: -- `bin/loop_claude/cycle/run.py`: `Cycle`, `run_cycle`, `worker_start` -- `bin/loop_claude/cycle/prompts.py`: `resumed`, `stepped_to` -- `bin/loop_claude/cycle/worker.py`: `worker_args` -- `bin/loop_claude/cycle/states.py` -- `bin/loop_claude/test_loop_claude.py`: `Cycles`, `WorkerArgs` -- `workflow-bench/bench.py`: `run`, `main` - ### 309. Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun. Seats cost $1,143 of the $9,154 measured from 2026-09-30 to 2026-11-11 (12.5%), scoring runs $470 of that. A scoring run today is four seats, run twice on one head: eight seat runs. Two seats on the second pass make it six, and two on both passes four. @@ -242,6 +228,20 @@ Touches: - `bin/review_replay/test_review_replay.py` - `bin/loop_claude/test_loop_claude.py`: `Cycles` (small), `HelpLimits` (small) +### 319. Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session. + +On SWE-bench Verified with Haiku 4.5 and Opus 4.7, handing the strong model the weak model's transcript solved 69.2% at $1.61 a task; starting the strong model fresh solved 79.2% at $0.90 (arXiv 2608.24358, The Handoff Tax). A model switch also rereads the whole context uncached (Claude Code prompt caching docs). A worker that steps from Sonnet 5.5 to Opus 5.5 by `--resume` is the raw handoff; an effort-only step within one model keeps the cache and isn't. The escalated subagent, which starts fresh with the trigger's evidence, already follows the pattern that won. + +Bench it first on `workflow-bench`: resume against a fresh start with a brief. The brief is the chunk's item, its branch and diff, open findings and the trigger. lilleman approved on 2026-11-11. Revise the decision `routing: a worker whose run ends asking for a higher rung…`. + +Touches: +- `bin/loop_claude/cycle/run.py`: `Cycle`, `run_cycle`, `worker_start` +- `bin/loop_claude/cycle/prompts.py`: `resumed`, `stepped_to` +- `bin/loop_claude/cycle/worker.py`: `worker_args` +- `bin/loop_claude/cycle/states.py` +- `bin/loop_claude/test_loop_claude.py`: `Cycles`, `WorkerArgs` +- `workflow-bench/bench.py`: `run`, `main` + ### 310. Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then. 281 worker resumes after the 1-hour cache expired rewrote a whole context, $379 of the $9,154 measured from 2026-09-30 to 2026-11-11 (4.1%). A compaction while the cache is warm reads the context at a twentieth of the input price and leaves about 20k tokens to rewrite later. From 75ae8639ab71a62c28e54177b3c2a823b2022e9f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 02:53:28 +0100 Subject: [PATCH 02/20] Record the reading cost before item 391's first commit --- docs/reading-cost.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index f240976b..4cbc768f 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -2396,3 +2396,20 @@ Read most (opens and searches): - `bin/transcript_archive/test_transcript_archive.py` 3 - `skills/larv-review/SKILL.md` 3 - `bin/loop_claude/loop/close.py` 2 + +## Reading cost, chunk f7dbc8c79fac, finished 2026-11-17T01:44:51Z + +100764 new input tokens before the first commit. + +Read most (opens and searches): + +- `docs/decisions.md` 12 +- `README.md` 6 +- `bin/judge_replay/main.py` 6 +- `bin/judge_replay/test_judge_replay.py` 6 +- `bin/review_replay/main.py` 5 +- `bin/review_replay/test_review_replay.py` 4 +- `bin/claude_code/test_claude_code.py` 3 +- `bin/loop_claude/cycle/judge.py` 3 +- `bin/rung_replay/test_rung_replay.py` 3 +- `bin/claude_code/entries.py` 2 From b7ec782282fbb4ea19d663603eb5b4398e9b7b78 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 02:53:28 +0100 Subject: [PATCH 03/20] Leave a Jira description or a Confluence page as it is where a save hands back the text a read showed --- bin/plan_store/jira_epic.py | 11 +++++++++-- bin/plan_store/test_jira_epic.py | 16 +++++++++++++++- bin/record_store/confluence_page.py | 17 +++++++++++++---- bin/record_store/test_confluence_page.py | 20 ++++++++++++++++++-- docs/decisions.md | 5 +++++ todo.md | 7 ++++++- 6 files changed, 66 insertions(+), 10 deletions(-) diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index c60d6451..03b353b2 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -185,6 +185,13 @@ class JiraPlan: description = self.to_adf(detail) return Failure(f"cannot convert the item's detail to a Jira description: {description.reason}") if isinstance(description, Failure) else description + def shows(self, issue: Issue, detail: str) -> bool: + """Whether detail is the issue's description as a read shows it. An edit leaves such a description as Jira holds it: converting the markdown back would drop the localIds and spacing paragraphs that the markdown a read shows leaves out.""" + if issue.description is None: + return not detail.strip() + texts = self.to_markdown([issue.description]) + return isinstance(texts, list) and texts[0].strip() == detail.strip() + def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure: """Sets the fields and the detail in one request, so Jira takes all of the edit or none, and then posts comment on the issue. `revision_of` says what an edit may set. @@ -203,7 +210,7 @@ class JiraPlan: if isinstance(revision, Failure): return revision body = revision.body - if detail is not None: + if detail is not None and not self.shows(issue, detail): description = self.description_of(detail) if isinstance(description, Failure): return description @@ -217,7 +224,7 @@ class JiraPlan: return version body = body | {"fields": body.get("fields", {}) | {"fixVersions": [{"name": version}]}} url = f"{self.epic.site}/rest/api/3/issue/{key}" - edited = self.http("PUT", url, authorization, body) + edited = self.http("PUT", url, authorization, body) if body else None if isinstance(edited, Failure): return Failure(f"cannot edit {key}: {edited.reason}; {PERHAPS_EDITED.format(key=key)}") if said is None: diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index 66878e0f..f393feee 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -500,7 +500,7 @@ class Editing(unittest.TestCase): return adf(markdown) def edit(self, id_: int, fields: dict[str, str], detail: str | None = None, comment: str | None = None): - return jira_epic.JiraPlan(EPIC, self.env, self.http, text_of, self.to_adf, scoring=Stated()).edit(id_, fields, detail, comment) + return jira_epic.JiraPlan(EPIC, self.env, self.http, lambda documents: [text_of(document) for document in documents], self.to_adf, scoring=Stated()).edit(id_, fields, detail, comment) def writes(self) -> list[tuple[str, str, object]]: """Each request that changes Jira, in order.""" @@ -518,7 +518,21 @@ class Editing(unittest.TestCase): self.edit(34, {"E": "3"}) self.assertEqual([body for _, _, body in self.writes()], [{"fields": {"summary": "Count every run."}}, {"properties": [{"key": "plan-item", "value": PROPERTY | {"E": 3}}]}]) + def test_a_detail_as_the_description_reads_leaves_the_description_as_jira_holds_it(self): + # Jira's own spacing paragraph and localIds, which a description converted back from markdown would lose. + held = {"type": "doc", "version": 1, "content": [{"type": "paragraph", "attrs": {"localId": "p-1"}, "content": [{"type": "text", "text": "Why it counts."}]}, {"type": "paragraph", "attrs": {"localId": "p-2"}}]} + self.open = [issue("ABC-34", scores=PROPERTY, description=held)] + self.assertEqual(self.edit(34, {"L": "2"}, "Why it counts.\n"), Written(34)) + self.assertEqual(self.edit(34, {}, "Why it counts."), Written(34)) + self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {"properties": [{"key": "plan-item", "value": PROPERTY | {"L": 2}}]})]) + + def test_an_edited_detail_replaces_the_description(self): + self.open = [issue("ABC-34", scores=PROPERTY, description=adf("Why it counts."))] + self.edit(34, {}, "Why it counts twice.") + self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {"fields": {"description": adf("Why it counts twice.")}})]) + def test_an_empty_detail_removes_the_description(self): + self.open = [issue("ABC-34", scores=PROPERTY, description=adf("Why it counts."))] self.edit(34, {}, " \n") self.assertEqual(self.writes(), [("PUT", f"{ISSUES}/ABC-34", {"fields": {"description": None}})]) diff --git a/bin/record_store/confluence_page.py b/bin/record_store/confluence_page.py index fb171ea5..94d863b0 100644 --- a/bin/record_store/confluence_page.py +++ b/bin/record_store/confluence_page.py @@ -2,6 +2,7 @@ A write never overwrites a teammate's edit: it sends the version after the one held() read, and Confluence refuses it where someone saved the page since. The human then decides (lilleman, 2026-11-12).""" import dataclasses +import hashlib import json import pathlib import typing @@ -20,9 +21,10 @@ SHAPE = "not in the shape Confluence Cloud's REST API version 2 documents" @dataclasses.dataclass(frozen=True) class Seen: - """The page's version number and title as a read found them or a write left them. A write needs both, so a Held's version holds both, as JSON.""" + """The page's version number and title as a read found them or a write left them, and the digest of the markdown it found or sent. A write needs all three, so a Held's version holds them, as JSON.""" version: int title: str + digest: str | None = None @property def token(self) -> str: @@ -64,7 +66,7 @@ class ConfluencePage: if not isinstance(body, str): return Failure(f"{self.label} is {SHAPE}: it holds no body in atlas_doc_format") text = self.converted(body) - return text if isinstance(text, Failure) else Held(text, seen.token) + return text if isinstance(text, Failure) else Held(text, Seen(seen.version, seen.title, digest_of(text)).token) def converted(self, held: str) -> str | Failure: """The markdown of the body held, the JSON of an ADF document; empty where held is.""" @@ -86,6 +88,9 @@ class ConfluencePage: seen = self.seen_of(over) if isinstance(seen, Failure): return seen + # The markdown a read shows drops the localIds and spacing paragraphs Confluence holds, so writing the text a read found back would lose them: leave the page alone. + if over is not None and seen.digest == digest_of(text): + return Held(text, over) document = self.to_adf(text) if isinstance(document, Failure): return Failure(f"cannot convert the text for {self.label} to ADF: {document.reason}") @@ -98,7 +103,7 @@ class ConfluencePage: return Failure(f"someone saved {self.label} since the loop read version {seen.version} of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do ({answer.reason})") if isinstance(answer, Failure): return Failure(f"cannot write {self.label}: {answer.reason}") - return Held(text, Seen(seen.version + 1, seen.title).token) + return Held(text, Seen(seen.version + 1, seen.title, digest_of(text)).token) def fetched(self, query: str) -> tuple[Seen, object] | Failure: """The page's version and title, and the value of its body in atlas_doc_format where query asks for it; None where it doesn't.""" @@ -124,6 +129,10 @@ class ConfluencePage: return fetched if isinstance(fetched, Failure) else fetched[0] try: held: typing.Any = json.loads(over) - return Seen(int(held["version"]), str(held["title"])) + return Seen(int(held["version"]), str(held["title"]), held.get("digest")) except (ValueError, KeyError, TypeError) as failure: return Failure(f"cannot read the version of {self.label} to write over, {over!r}: {failure}") + + +def digest_of(text: str) -> str: + return hashlib.sha256(text.encode("utf-8")).hexdigest() diff --git a/bin/record_store/test_confluence_page.py b/bin/record_store/test_confluence_page.py index 06cafb0d..03fadfbe 100644 --- a/bin/record_store/test_confluence_page.py +++ b/bin/record_store/test_confluence_page.py @@ -7,7 +7,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from record_store.confluence_page import ConfluencePage +from record_store.confluence_page import ConfluencePage, digest_of, Seen from rest_client.json_request import ErrorAnswer from failure import Failure from record_store.held import Held @@ -80,9 +80,25 @@ class ConfluencePageTest(ConfluenceCase): store = self.new_store() held = store.held() assert isinstance(held, Held), held - self.assertEqual(store.write("- a decision\n", held.version), Held("- a decision\n", '{"version": 8, "title": "Decisions"}')) + self.assertEqual(store.write("- a decision\n", held.version), Held("- a decision\n", Seen(8, "Decisions", digest_of("- a decision\n")).token)) self.assertEqual(self.confluence.calls[-1], ("PUT", URL, AUTHORIZATION, {"id": PAGE.page_id, "status": "current", "title": "Decisions", "body": {"representation": "atlas_doc_format", "value": json.dumps(to_adf("- a decision\n"))}, "version": {"number": 8}})) + def test_saving_the_text_a_read_found_leaves_the_page_as_confluence_holds_it(self) -> None: + self.confluence.teammate_saves("- a decision\n") + value = self.confluence.value + held = self.new_store().held() + assert isinstance(held, Held), held + self.assertEqual(self.new_store().write(held.text, held.version), held) + self.assertEqual([call[0] for call in self.confluence.calls], ["GET"]) + self.assertEqual((self.confluence.version, self.confluence.value), (2, value)) + + def test_saving_an_edited_text_writes_the_page(self) -> None: + self.confluence.teammate_saves("- a decision\n") + held = self.new_store().held() + assert isinstance(held, Held), held + self.assertIsInstance(self.new_store().write("- another decision\n", held.version), Held) + self.assertEqual(self.new_store().read(), "- another decision\n") + def test_refuses_to_overwrite_a_teammates_save_since_the_version_it_is_handed_and_says_to_ask_the_human(self) -> None: held = self.new_store().held() assert isinstance(held, Held), held diff --git a/docs/decisions.md b/docs/decisions.md index 6aeef3cf..f6b693d2 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -24,6 +24,7 @@ Each project principle states one rule that the decisions below apply; their ent - principles: about seven things per level, four or five where they act on each other, more where a reader finds them by name; crossing a limit asks for a grouping or a recorded reason - project config: a record may name a Confluence Cloud page as `confluence:` and its address, the loop reads and writes it as markdown, and a write never overwrites a save made since the loop's read - project config: a tool that reads a file's commits says where it does not support that file, and the work goes on +- project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, and a save that hands back the text it showed leaves the document as Jira or Confluence holds it - project config: `language` names the prose's language by its English name, and `commit-title`, `pull-request-title` and `branch` are brace templates over `{id}` and `{summary}` - project config: `plan` may name a Jira Cloud epic as `jira:` and its address, the plan is its open child issues in backlog order, and an issue's number is the item's ID - project config: `tooling-on-host = true` lets a project with no container setup run its language runtime, package manager, tests and task runner on the host @@ -323,6 +324,10 @@ Valid while the later fixes per finished chunk, which `score-outcomes` and the r - **A store keeps no version: its caller hands each write the version it writes over.** lilleman chose this on 2026-11-16, when 0.11.0's release review found the version kept as the store's hidden state, which made a write rest on whichever read came before it. `project-record` keeps the version `open` read in a file beside its copy, `~/.local/state/project-record///.version`, since `save` runs in a later process, and each save keeps the version it left for the next. Every other tool writes over the version its own read gave, so a read by another tool, such as larv-review's, never moves the version an edit in `project-record` rests on. The folder `` is named for the worktree that ran `open`, and `open` removes the folders of worktrees git no longer lists, so a chunk's copy doesn't outlive its worktree. - **The page holds ADF, which adf-codec converts both ways**, so a teammate reads the record as Confluence renders it. Where adf-codec cannot convert the markdown, the write fails with adf-codec's error. A node markdown cannot hold reads as text: a mention as its name, a macro as `_( not included)_`. So the next write replaces it with that text, and a record page should hold only what markdown can. +## project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, and a save that hands back the text it showed leaves the document as Jira or Confluence holds it + +2026-11-17, claude, through item 391. Serves goal 1.6: a team's own spacing and block ids stay in its Jira and Confluence, and agents, the judge and people still read the text easily (goal 1.4's reading cost). adf-codec's lossless pair keeps each block's localId and Jira's spacing paragraphs, but wraps every block in `!adf:` marker lines, which triples a short detail's lines (larvit/adf-codec#185). So reads stay on the portable pair, and a save leaves the document alone where its text is the text a read showed: `JiraPlan.shows` compares a new detail with the description converted again, and `ConfluencePage` keeps the digest of the text it read in the version a write names. Valid while every edit replaces a whole document: an edit that changes one line still rewrites it by the portable pair, dropping the localIds and spacing paragraphs everywhere, until `todo.md` item 395 keeps each block the edit didn't change. + ## project config: a tool that reads a file's commits says where it does not support that file, and the work goes on 2026-11-13, larv-review. Serves goal 1.6: a client's plan and records live in the config's folder, and the loop still runs there. A file the config puts outside the checkout has no commit in the project's history, so a tool that needs the file's commits cannot do its job for it. No such tool blocks the loop or a merge, and each says what it leaves undone: diff --git a/todo.md b/todo.md index 1bc3a4c8..a2407ee6 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 395` +`Next ID = 396` ## Items @@ -68,6 +68,7 @@ | 193 | 0.14.0 | | | **Narrow `numbered`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.** | 1 | 1 | 3 | 3 | 1 | 1.1 by 2 | 0.9 | | 194 | 0.14.0 | | | **Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.9 | | 265 | 0.14.0 | | | **Archive each wait that costs a chunk wall time, for a usage limit, low memory, a failed worker start or a heavy slot, with its start and end stamps, so goal 1.5's hours split waiting from work.** | 3 | 2 | 2 | 5 | 4 | 1.5 by 3 | 0.8 | +| 395 | 0.14.0 | | decision | **Keep each block a save didn't change as Jira or Confluence holds it, with its localId and spacing paragraphs.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 4 | 0.8 | | 169 | 0.14.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 | 0.7 | | 197 | 0.14.0 | | | **Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.** | 2 | 2 | 3 | 5 | 2 | 1.5 by 1 | 0.4 | | 1 | 0.15.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | @@ -577,6 +578,10 @@ Found by review of PR #317. The black-box test, `bin/loop_claude/test_black_box. No record holds these waits today. An outcomes file holds verdicts, stops, step-ups and the judge's cost (`bin/transcript_archive/outcomes.py`), and `~/.local/state/run-heavy/` holds only the slots' lock files. loop-claude waits out a usage limit and low memory in `bin/loop_claude/cycle/retry.py`; run-heavy waits for a slot in `bin/run_heavy/`. A heavy slot's wait happens inside a worker's Bash call, so loop-claude doesn't see it; run-heavy would write it where the archive can find it. +### 395. Keep each block a save didn't change as Jira or Confluence holds it, with its localId and spacing paragraphs. + +Today a Jira detail edited in one line, or a Confluence record with one entry appended, is written back whole by adf-codec's portable pair, so every block loses its localId and Jira's spacing paragraphs go. A save whose text is unchanged already leaves the document alone (`docs/decisions.md` → `project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, …`). Match the saved markdown's top-level blocks against the held document's, as the portable pair reads each, and send the held block where they match. The decision's "Valid while" ends with this item. + ### 169. Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits. 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. From 51917dfd6c2d112c5569f2174da84f59ac6ad74c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 02:54:05 +0100 Subject: [PATCH 04/20] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From e42eb5b28825729cbc464ea5531a99d590f5ab7c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 02:57:22 +0100 Subject: [PATCH 05/20] Bench a model step's handoff: resume, compact or a fresh session with a brief --- .gitignore | 4 + workflow-bench/advisor_bench.py | 24 ++- workflow-bench/handoff-brief-prompt.md | 4 + workflow-bench/handoff-resume-prompt.md | 1 + workflow-bench/handoff_bench.py | 175 ++++++++++++++++++ workflow-bench/test_handoff_bench.py | 224 ++++++++++++++++++++++++ 6 files changed, 423 insertions(+), 9 deletions(-) create mode 100644 workflow-bench/handoff-brief-prompt.md create mode 100644 workflow-bench/handoff-resume-prompt.md create mode 100644 workflow-bench/handoff_bench.py create mode 100644 workflow-bench/test_handoff_bench.py diff --git a/.gitignore b/.gitignore index 94c1be88..19e7cb16 100644 --- a/.gitignore +++ b/.gitignore @@ -184,9 +184,13 @@ !workflow-bench/bench.py !workflow-bench/compare-prompt.md !workflow-bench/compare.py +!workflow-bench/handoff-brief-prompt.md +!workflow-bench/handoff-resume-prompt.md +!workflow-bench/handoff_bench.py !workflow-bench/review_git.py !workflow-bench/run-prompt.md !workflow-bench/setup.cfg !workflow-bench/test_advisor_bench.py !workflow-bench/test_bench.py +!workflow-bench/test_handoff_bench.py !workflow-bench/test_review_git.py diff --git a/workflow-bench/advisor_bench.py b/workflow-bench/advisor_bench.py index a4ec633f..9c40f1e3 100644 --- a/workflow-bench/advisor_bench.py +++ b/workflow-bench/advisor_bench.py @@ -146,19 +146,25 @@ def run(work, name): "--no-session-persistence", "--output-format", "stream-json", "--verbose"], cwd=clone, stdout=out, stderr=subprocess.STDOUT) read_result((work / f"{name}.jsonl").read_text().splitlines()) - git(clone, "add", "--all") - (work / f"{name}.diff").write_text(git(clone, "diff", "--cached", base)) - changed = [*git(clone, "diff", "--cached", "--name-only", base).split(), *git(REPO, "diff", "--name-only", base, CASES[case][1]).split()] - targets = [target for target in suite_targets(changed) if (clone / target).exists()] or ["bin"] - tests = subprocess.run([str(RUN_HEAVY), *SUITE, *targets], cwd=clone, capture_output=True, text=True) - (work / f"{name}.tests").write_text(f"exit {tests.returncode}\n{tests.stdout[-1500:]}") + save_change(work, name, clone, CASES[case]) return f"{name}: ran" -def grade(work, name): - """Have the judge rule on one run's diff, blind to its arm, and save the verdict beside it.""" +def save_change(work, name, clone, commits): + """Save the clone's change since the case's start commit as .diff, and the result of the tests of the packages that it or the merged change touches as .tests.""" + base, merged = commits + git(clone, "add", "--all") + (work / f"{name}.diff").write_text(git(clone, "diff", "--cached", base)) + changed = [*git(clone, "diff", "--cached", "--name-only", base).split(), *git(REPO, "diff", "--name-only", base, merged).split()] + targets = [target for target in suite_targets(changed) if (clone / target).exists()] or ["bin"] + tests = subprocess.run([str(RUN_HEAVY), *SUITE, *targets], cwd=clone, capture_output=True, text=True) + (work / f"{name}.tests").write_text(f"exit {tests.returncode}\n{tests.stdout[-1500:]}") + + +def grade(work, name, cases=None): + """Have the judge rule on one run's diff, blind to its arm, and save the verdict beside it. cases stands in for CASES where another bench grades its own.""" case = split_name(name)[0] - base, merged = CASES[case] + base, merged = (cases or CASES)[case] prompt = (BENCH / "advisor-judge-prompt.md").read_text().format( text=item_text(git(REPO, "show", f"{base}:todo.md"), case), reference=git(REPO, "diff", base, merged, "--", ".", ":!todo.md", ":!docs", ":!CHANGELOG.md"), diff=(work / f"{name}.diff").read_text(), tests=(work / f"{name}.tests").read_text()) diff --git a/workflow-bench/handoff-brief-prompt.md b/workflow-bench/handoff-brief-prompt.md new file mode 100644 index 00000000..067e9f89 --- /dev/null +++ b/workflow-bench/handoff-brief-prompt.md @@ -0,0 +1,4 @@ + +## Handoff + +A worker on a weaker model began this item and stopped before it was done, asking for a stronger model. You start fresh, without its transcript. Its unfinished change is in the clone, uncommitted: read `git status` and `git diff` first. Keep what holds, redo what doesn't, and finish the item. diff --git a/workflow-bench/handoff-resume-prompt.md b/workflow-bench/handoff-resume-prompt.md new file mode 100644 index 00000000..2d271159 --- /dev/null +++ b/workflow-bench/handoff-resume-prompt.md @@ -0,0 +1 @@ +Continue the task; the previous run ended before the item was done. Your request for a higher rung went through: you now run on {rung}. The bench rules still hold. diff --git a/workflow-bench/handoff_bench.py b/workflow-bench/handoff_bench.py new file mode 100644 index 00000000..09c8947a --- /dev/null +++ b/workflow-bench/handoff_bench.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python3 +"""Bench how a worker's step to a stronger model hands the chunk over: handoff_bench.py start - ..., then run|grade -- ..., then summary + +The question: when loop-claude steps a worker to a rung on another model, which handoff serves the stronger model +best? Each case is an archived chunk of this repo, as in advisor_bench.py, whose judge and files this bench shares. +- `start` runs WEAK on the item in the clone /- until it has spent START_BUDGET, which + stands in for a run that ends asking for a higher rung. A worker that finishes within the budget leaves no + handoff, so `start` fails on it. It saves the change so far (-start-.diff), and a copy of the clone + (.tree) and of the session's transcript (.session.jsonl), which every arm starts from. +- `run` puts the clone and the session back as `start` left them, then continues on STRONG, one arm of a case at a + time. The resume arm resumes WEAK's session with handoff-resume-prompt.md. The compact arm does the same once WEAK + has compacted the session with `/compact`, whose stream it saves as .compact.jsonl. The brief arm starts a + session that has the item and handoff-brief-prompt.md, and no transcript. +- `grade` is advisor_bench.py's, over these cases. `summary` counts an arm's cost and seconds from its own runs, + the compaction included, and leaves out the start, which the arms share. +Run each arm of each case once; the table shows a direction, not a significance. +""" +import concurrent.futures +import collections +import json +import pathlib +import shutil +import subprocess +import sys +import threading +import uuid + +import advisor_bench +from advisor_bench import Arm + +BENCH = pathlib.Path(__file__).resolve().parent +# The ladder's first step that changes the model: bin/model_routing/routing-ladder.json. +WEAK = Arm("claude-sonnet-5-5", "high") +STRONG = Arm("claude-opus-5-5", "medium") +ARMS = ("resume", "compact", "brief") +# Claude Code keeps a session's transcript at //.jsonl. +CLAUDE_PROJECTS = pathlib.Path.home() / ".claude/projects" +# One per case and run number: its arms share one clone, so they run one at a time. +CLONE_LOCKS: collections.defaultdict = collections.defaultdict(threading.Lock) +# L 3 chunks, by todo item. advisor_bench's L 1 and L 2 chunks are too small: Sonnet 5.5 finished five of the six for +# under $0.20, before any handoff. +CASES = { + "143": ("45cb331a4", "545f3c347"), + "163": ("d4cf6e7fe", "d1b0fe3a4"), + "198": ("4a0ba5921", "fd60b6da"), + "210": ("4764d3d52", "dcbdc970"), + "227": ("eb7b50698", "3bde9cd6d"), + "239": ("d583f8d48", "47a40757"), +} +# Dollars WEAK may spend before the handoff. In a trial, $0.36 stopped Sonnet 5.5 on items 163 and 227 after 11 to 14 +# turns, with about 250 lines of diff. +START_BUDGET = 0.36 +CLAUDE_FLAGS = ["--setting-sources", "project", "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"] + + +def stopped_at_budget(lines): + """Whether a claude stream's first result line, the worker's own, says the run stopped at --max-budget-usd.""" + for line in lines: + try: + entry = json.loads(line) + except ValueError: + continue + if entry.get("type") == "result": + return entry.get("subtype") == "error_max_budget_usd" + return False + + +def run_prompt(case): + """advisor_bench's prompt for the case's item, as the item's text stood at the start commit.""" + base = CASES[case][0] + text = advisor_bench.item_text(advisor_bench.git(advisor_bench.REPO, "show", f"{base}:todo.md"), case) + return (BENCH / "advisor-run-prompt.md").read_text().format(base=base, item=case, text=text) + + +def claude(prompt, flags, clone, stream): + with stream.open("w") as out: + subprocess.run(["claude", "-p", prompt, *flags, *CLAUDE_FLAGS], cwd=clone, stdin=subprocess.DEVNULL, stdout=out, stderr=subprocess.STDOUT) + + +def start(work, name): + """WEAK's capped run of -, and the tree and session it leaves the arms; the files are in the module docstring.""" + case, number = name.split("-") + base = CASES[case][0] + clone, saved = work / name, work / f"{case}-start-{number}" + if clone.exists(): + raise ValueError(f"{name} already started: remove {clone}") + advisor_bench.fresh_clone(base, clone) + session = str(uuid.uuid4()) + stream = saved.with_suffix(".jsonl") + claude(run_prompt(case), [*WEAK.flags(), "--session-id", session, "--max-budget-usd", str(START_BUDGET)], clone, stream) + if not stopped_at_budget(stream.read_text().splitlines()): + raise ValueError("the weak worker finished within its budget, or its run failed, so there is no handoff to bench") + transcripts = list(CLAUDE_PROJECTS.glob(f"*/{session}.jsonl")) + if len(transcripts) != 1: + raise ValueError(f"expected one transcript of session {session} under {CLAUDE_PROJECTS}, found {len(transcripts)}") + shutil.copy(transcripts[0], saved.with_suffix(".session.jsonl")) + saved.with_suffix(".session").write_text(str(transcripts[0])) + # The worker may have committed against the bench rules, so the arms get its whole change since base, uncommitted. + advisor_bench.git(clone, "add", "--all") + saved.with_suffix(".diff").write_text(advisor_bench.git(clone, "diff", "--cached", base)) + advisor_bench.git(clone, "reset", "-q", "--mixed", base) + shutil.copytree(clone, saved.with_suffix(".tree"), symlinks=True) + return f"{name}: started" + + +def run(work, name): + """STRONG's run of one arm, --, from the tree and session `start` left.""" + case, arm, number = advisor_bench.split_name(name) + if arm not in ARMS: + raise ValueError(f"the arm {arm!r} is none of {ARMS}") + clone, saved = work / f"{case}-{number}", work / f"{case}-start-{number}" + if not saved.with_suffix(".tree").exists(): + raise ValueError(f"start {case}-{number} first") + stream = work / f"{name}.jsonl" + if stream.exists(): + raise ValueError(f"{name} already ran: remove {stream}") + with CLONE_LOCKS[clone]: + shutil.rmtree(clone) + shutil.copytree(saved.with_suffix(".tree"), clone, symlinks=True) + transcript = pathlib.Path(saved.with_suffix(".session").read_text()) + shutil.copy(saved.with_suffix(".session.jsonl"), transcript) + resumed = ["--resume", transcript.stem] + if arm == "compact": + claude("/compact", [*WEAK.flags(), *resumed], clone, work / f"{name}.compact.jsonl") + if arm == "brief": + claude(run_prompt(case) + "\n" + (BENCH / "handoff-brief-prompt.md").read_text(), [*STRONG.flags(), "--no-session-persistence"], clone, stream) + else: + prompt = (BENCH / "handoff-resume-prompt.md").read_text().format(rung=f"{STRONG.model} at {STRONG.effort} effort") + claude(prompt, [*STRONG.flags(), *resumed], clone, stream) + outcome(work, name) + advisor_bench.save_change(work, name, clone, CASES[case]) + return f"{name}: ran" + + +def outcome(work, name): + """The cost and seconds of an arm's run: its STRONG stream's, plus its compaction's where it made one.""" + streams = [stream for stream in (work / f"{name}.compact.jsonl", work / f"{name}.jsonl") if stream.exists()] + results = [advisor_bench.read_result(stream.read_text().splitlines()) for stream in streams] + return {"cost": sum(result.cost for result in results), "seconds": sum(result.seconds for result in results)} + + +def rows_of(work): + """One row per graded run: its arm, verdict, cost and seconds.""" + rows = [] + for verdict_file in sorted(work.glob("*.verdict")): + name = verdict_file.stem + rows.append({"arm": advisor_bench.split_name(name)[1], "verdict": json.loads(verdict_file.read_text())["verdict"], **outcome(work, name)}) + return rows + + +def summary(rows): + """A markdown table with one row per arm, in ARMS' order: its runs, passes, partials, mean cost and mean seconds.""" + lines = ["| arm | runs | pass | partial | mean cost $ | mean seconds |", "|---|---|---|---|---|---|"] + for name in ARMS: + own = [row for row in rows if row["arm"] == name] + if own: + passes, partials = (sum(row["verdict"] == kind for row in own) for kind in ("pass", "partial")) + cost, seconds = (sum(row[key] for row in own) / len(own) for key in ("cost", "seconds")) + lines.append(f"| {name} | {len(own)} | {passes} | {partials} | {cost:.2f} | {seconds:.0f} |") + return "\n".join(lines) + + +def main(argv): + work, step, names = pathlib.Path(argv[0]), argv[1], argv[2:] + if step == "summary": + print(summary(rows_of(work))) + return + steps = {"start": start, "run": run, "grade": lambda work, name: advisor_bench.grade(work, name, CASES)} + with concurrent.futures.ThreadPoolExecutor(max_workers=3) as pool: + for result in pool.map(lambda name: advisor_bench.attempted(steps[step], work, name), names): + print(result, flush=True) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/workflow-bench/test_handoff_bench.py b/workflow-bench/test_handoff_bench.py new file mode 100644 index 00000000..8c9f5b45 --- /dev/null +++ b/workflow-bench/test_handoff_bench.py @@ -0,0 +1,224 @@ +import json +import pathlib +import subprocess +import tempfile +import unittest +import unittest.mock +import uuid + +import advisor_bench +import handoff_bench +from test_advisor_bench import commit, TODO + +SESSION = uuid.UUID("11111111-2222-4333-8444-555555555555") + + +def result_line(**fields): + return json.dumps({"type": "result", "subtype": "success", "total_cost_usd": 0.5, "duration_ms": 12000, **fields}) + + +class StoppedAtBudget(unittest.TestCase): + def test_holds_where_the_first_result_is_the_budget_stop(self): + self.assertTrue(handoff_bench.stopped_at_budget(["not json", result_line(subtype="error_max_budget_usd", is_error=True)])) + + def test_fails_where_the_worker_finished_within_the_budget(self): + self.assertFalse(handoff_bench.stopped_at_budget([result_line()])) + + def test_fails_where_the_stream_has_no_result(self): + self.assertFalse(handoff_bench.stopped_at_budget(['{"type": "assistant"}'])) + + +class Summary(unittest.TestCase): + def test_prints_one_row_per_arm_with_passes_and_means(self): + rows = [ + {"arm": "brief", "verdict": "pass", "cost": 0.5, "seconds": 100.0}, + {"arm": "brief", "verdict": "partial", "cost": 1.5, "seconds": 300.0}, + {"arm": "resume", "verdict": "fail", "cost": 2.0, "seconds": 50.0}, + {"arm": "compact", "verdict": "pass", "cost": 0.25, "seconds": 9.0}, + ] + self.assertEqual(handoff_bench.summary(rows), "\n".join([ + "| arm | runs | pass | partial | mean cost $ | mean seconds |", + "|---|---|---|---|---|---|", + "| resume | 1 | 0 | 0 | 2.00 | 50 |", + "| compact | 1 | 1 | 0 | 0.25 | 9 |", + "| brief | 2 | 1 | 1 | 1.00 | 200 |", + ])) + + +class Orchestration(unittest.TestCase): + """start, run and main on a throwaway repo, with claude and run-heavy faked. Case 7 starts at a commit holding bin/pkg/mod.py and merges a change to it. The fake claude writes a session's transcript as Claude Code does, and each resumed run adds a line to it.""" + + def setUp(self): + scratch = tempfile.TemporaryDirectory() + self.addCleanup(scratch.cleanup) + root = pathlib.Path(scratch.name) + self.repo, self.work, self.projects = root / "repo", root / "work", root / "projects" + self.work.mkdir() + subprocess.run(["git", "init", "-q", str(self.repo)], check=True) + self.base = self.commit({"todo.md": TODO, "bin/pkg/mod.py": "x = 1\n"}) + merged = self.commit({"bin/pkg/mod.py": "x = 2\n"}) + self.calls = [] + self.start_result = {"subtype": "error_max_budget_usd", "is_error": True} + real_run = subprocess.run + for patch in ( + unittest.mock.patch.object(advisor_bench, "REPO", self.repo), + unittest.mock.patch.object(handoff_bench, "CASES", {"7": (self.base, merged)}), + unittest.mock.patch.object(handoff_bench, "START_BUDGET", 0.25), + unittest.mock.patch.object(handoff_bench, "CLAUDE_PROJECTS", self.projects), + unittest.mock.patch.object(handoff_bench.uuid, "uuid4", return_value=SESSION), + unittest.mock.patch.object(advisor_bench.subprocess, "run", side_effect=lambda args, **kwargs: self.fake(real_run, args, **kwargs)), + ): + patch.start() + self.addCleanup(patch.stop) + self.transcript = self.projects / "slug" / f"{SESSION}.jsonl" + + def commit(self, files): + for path, text in files.items(): + (self.repo / path).parent.mkdir(parents=True, exist_ok=True) + (self.repo / path).write_text(text) + subprocess.run(["git", "-C", str(self.repo), "add", "."], check=True) + commit(self.repo, "a commit") + return advisor_bench.git(self.repo, "rev-parse", "HEAD").strip() + + def fake(self, real_run, args, **kwargs): + if args[0] == "claude": + cwd = pathlib.Path(kwargs["cwd"]) + # What the run found as it began: the session's transcript and the files under bin/pkg. + found = (self.transcript.read_text() if self.transcript.exists() else None, sorted(path.name for path in (cwd / "bin/pkg").iterdir())) + self.calls.append((args, kwargs, found)) + if "--max-budget-usd" in args: + (cwd / "bin/pkg/mod.py").write_text("x = 3\n") + (cwd / "bin/pkg/new.py").write_text("n = 1\n") + self.transcript.parent.mkdir(parents=True) + self.transcript.write_text("weak\n") + kwargs["stdout"].write(result_line(**self.start_result) + "\n") + elif args[2] == "/compact": + self.transcript.write_text(self.transcript.read_text() + "compacted\n") + kwargs["stdout"].write(result_line(total_cost_usd=0.25, duration_ms=3000) + "\n") + else: + if "--resume" in args: + self.transcript.write_text(self.transcript.read_text() + "strong\n") + (cwd / "bin/pkg" / f"done_{len(self.calls)}.py").write_text("d = 1\n") + kwargs["stdout"].write(result_line() + "\n") + return subprocess.CompletedProcess(args, 0) + if args[0] == str(advisor_bench.RUN_HEAVY): + return subprocess.CompletedProcess(args, 0, stdout="3 passed\n", stderr="") + return real_run(args, **kwargs) + + def started(self): + handoff_bench.start(self.work, "7-1") + self.calls.clear() + + def test_start_runs_the_weak_worker_to_its_budget_and_saves_the_tree_and_the_session(self): + self.assertEqual(handoff_bench.start(self.work, "7-1"), "7-1: started") + (claude, kwargs, _), = self.calls + self.assertEqual(kwargs["cwd"], self.work / "7-1") + self.assertEqual(kwargs["stdin"], subprocess.DEVNULL) + self.assertEqual(claude[:2] + claude[3:], [ + "claude", "-p", *handoff_bench.WEAK.flags(), "--session-id", str(SESSION), "--max-budget-usd", "0.25", "--setting-sources", "project", + "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) + self.assertIn("Do the seventh thing.", claude[2]) + self.assertEqual((self.work / "7-start-1.session").read_text(), str(self.transcript)) + self.assertEqual((self.work / "7-start-1.session.jsonl").read_text(), "weak\n") + self.assertIn("-x = 1\n+x = 3\n", (self.work / "7-start-1.diff").read_text()) + tree = self.work / "7-start-1.tree" + self.assertEqual(((tree / "bin/pkg/mod.py").read_text(), (tree / "bin/pkg/new.py").read_text()), ("x = 3\n", "n = 1\n")) + self.assertEqual(advisor_bench.git(tree, "status", "--porcelain"), " M bin/pkg/mod.py\n?? bin/pkg/new.py\n") + self.assertEqual(advisor_bench.git(tree, "rev-parse", "HEAD").strip(), self.base) + + def test_start_refuses_a_worker_that_finished_within_its_budget(self): + self.start_result = {} + with self.assertRaisesRegex(ValueError, "finished within its budget"): + handoff_bench.start(self.work, "7-1") + + def test_start_refuses_a_name_that_already_started(self): + (self.work / "7-1").mkdir() + with self.assertRaisesRegex(ValueError, "already started"): + handoff_bench.start(self.work, "7-1") + + def test_start_refuses_a_session_whose_transcript_it_cannot_find(self): + self.transcript = self.work / "elsewhere" / f"{SESSION}.jsonl" + with self.assertRaisesRegex(ValueError, "found 0"): + handoff_bench.start(self.work, "7-1") + + def test_the_resume_arm_resumes_the_weak_workers_session_on_the_strong_rung(self): + self.started() + self.assertEqual(handoff_bench.run(self.work, "7-resume-1"), "7-resume-1: ran") + (claude, kwargs, _), = self.calls + self.assertEqual(kwargs["cwd"], self.work / "7-1") + self.assertEqual(claude[:2] + claude[3:], [ + "claude", "-p", *handoff_bench.STRONG.flags(), "--resume", str(SESSION), "--setting-sources", "project", + "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) + self.assertEqual(claude[2], (handoff_bench.BENCH / "handoff-resume-prompt.md").read_text().format(rung="claude-opus-5-5 at medium effort")) + diff = (self.work / "7-resume-1.diff").read_text() + self.assertIn("+x = 3\n", diff) + self.assertIn("+++ b/bin/pkg/done_1.py", diff) + self.assertEqual((self.work / "7-resume-1.tests").read_text(), "exit 0\n3 passed\n") + + def test_the_compact_arm_has_the_weak_model_compact_the_session_before_the_strong_one_resumes_it(self): + self.started() + handoff_bench.run(self.work, "7-compact-1") + (compact, _, _), (claude, _, found) = self.calls + self.assertEqual(compact[:2] + compact[3:], [ + "claude", "-p", *handoff_bench.WEAK.flags(), "--resume", str(SESSION), "--setting-sources", "project", + "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) + self.assertEqual(compact[2], "/compact") + self.assertEqual(claude[3:7], [*handoff_bench.STRONG.flags()][:4]) + self.assertIn("--resume", claude) + self.assertEqual(found[0], "weak\ncompacted\n") + self.assertEqual(handoff_bench.outcome(self.work, "7-compact-1"), {"cost": 0.75, "seconds": 15.0}) + + def test_the_brief_arm_starts_a_fresh_session_with_the_item_and_the_brief(self): + self.started() + self.assertEqual(handoff_bench.run(self.work, "7-brief-1"), "7-brief-1: ran") + (claude, kwargs, _), = self.calls + self.assertEqual(kwargs["cwd"], self.work / "7-1") + self.assertEqual(claude[:2] + claude[3:], [ + "claude", "-p", *handoff_bench.STRONG.flags(), "--no-session-persistence", "--setting-sources", "project", + "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) + self.assertIn("Do the seventh thing.", claude[2]) + self.assertIn("## Handoff", claude[2]) + self.assertIn("+++ b/bin/pkg/done_1.py", (self.work / "7-brief-1.diff").read_text()) + + def test_each_arm_begins_on_the_tree_and_the_session_that_start_left(self): + self.started() + for arm in ("resume", "compact", "brief"): + handoff_bench.run(self.work, f"7-{arm}-1") + self.assertEqual([found for _, _, found in self.calls if found[0] != "weak\ncompacted\n"], [("weak\n", ["mod.py", "new.py"])] * 3) + self.assertNotIn("done_1.py", (self.work / "7-brief-1.diff").read_text()) + + def test_run_refuses_an_arm_that_already_ran_or_never_started(self): + with self.assertRaisesRegex(ValueError, "start 7-1 first"): + handoff_bench.run(self.work, "7-brief-1") + self.started() + handoff_bench.run(self.work, "7-brief-1") + with self.assertRaisesRegex(ValueError, "already ran"): + handoff_bench.run(self.work, "7-brief-1") + + def test_run_refuses_an_unknown_arm(self): + self.started() + with self.assertRaisesRegex(ValueError, "arm"): + handoff_bench.run(self.work, "7-sonnet-1") + + def test_run_refuses_an_arm_whose_run_ended_in_an_error_before_it_tests(self): + self.started() + with unittest.mock.patch.object(advisor_bench, "save_change") as save_change, unittest.mock.patch.object(advisor_bench, "read_result", side_effect=ValueError("the run ended in an error")): + with self.assertRaisesRegex(ValueError, "ended in an error"): + handoff_bench.run(self.work, "7-brief-1") + save_change.assert_not_called() + + def test_main_grades_with_the_handoff_cases_and_prints_the_summary(self): + self.started() + handoff_bench.run(self.work, "7-brief-1") + with unittest.mock.patch.object(advisor_bench, "grade", return_value="7-brief-1: pass") as grade, unittest.mock.patch("builtins.print") as printed: + handoff_bench.main([str(self.work), "grade", "7-brief-1"]) + grade.assert_called_once_with(self.work, "7-brief-1", handoff_bench.CASES) + printed.assert_called_once_with("7-brief-1: pass", flush=True) + (self.work / "7-brief-1.verdict").write_text(json.dumps({"verdict": "pass"})) + with unittest.mock.patch("builtins.print") as printed: + handoff_bench.main([str(self.work), "summary"]) + self.assertIn("| brief | 1 | 1 | 0 | 0.50 | 12 |", printed.call_args.args[0]) + + +if __name__ == "__main__": + unittest.main() From 432b62aa0813f464b2d88f64f663556df78c052e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:11:17 +0100 Subject: [PATCH 06/20] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20an=20unedit?= =?UTF-8?q?ed=20save=20over=20a=20version=20a=20teammate=20moved=20refuses?= =?UTF-8?q?,=20and=20a=20test=20asserts=20the=20PUT=20rather=20than=20the?= =?UTF-8?q?=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/record_store/confluence_page.py | 13 ++++++++++-- bin/record_store/test_confluence_page.py | 26 +++++++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bin/record_store/confluence_page.py b/bin/record_store/confluence_page.py index 94d863b0..23737661 100644 --- a/bin/record_store/confluence_page.py +++ b/bin/record_store/confluence_page.py @@ -88,8 +88,13 @@ class ConfluencePage: seen = self.seen_of(over) if isinstance(seen, Failure): return seen - # The markdown a read shows drops the localIds and spacing paragraphs Confluence holds, so writing the text a read found back would lose them: leave the page alone. + # The markdown a read shows drops the localIds and spacing paragraphs Confluence holds, so writing the text a read found back would lose them: leave the page alone. No write means no 409, so the version is read instead: a save over a teammate's edit refuses whether or not the text changed. if over is not None and seen.digest == digest_of(text): + current = self.fetched("") + if isinstance(current, Failure): + return current + if current[0].version != seen.version: + return self.saved_since(seen.version, f"Confluence holds version {current[0].version}") return Held(text, over) document = self.to_adf(text) if isinstance(document, Failure): @@ -100,11 +105,15 @@ class ConfluencePage: body = {"id": self.page.page_id, "status": "current", "title": seen.title, "body": {"representation": "atlas_doc_format", "value": json.dumps(document)}, "version": {"number": seen.version + 1}} answer = self.http("PUT", self.url, authorization, body) if isinstance(answer, ErrorAnswer) and answer.status == CONFLICT: - return Failure(f"someone saved {self.label} since the loop read version {seen.version} of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do ({answer.reason})") + return self.saved_since(seen.version, answer.reason) if isinstance(answer, Failure): return Failure(f"cannot write {self.label}: {answer.reason}") return Held(text, Seen(seen.version + 1, seen.title, digest_of(text)).token) + def saved_since(self, version: int, evidence: str) -> Failure: + """The refusal of a write over version, which a teammate's save replaced, as evidence shows.""" + return Failure(f"someone saved {self.label} since the loop read version {version} of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do ({evidence})") + def fetched(self, query: str) -> tuple[Seen, object] | Failure: """The page's version and title, and the value of its body in atlas_doc_format where query asks for it; None where it doesn't.""" authorization = basic_auth(self.env_file) diff --git a/bin/record_store/test_confluence_page.py b/bin/record_store/test_confluence_page.py index 03fadfbe..a65c7da4 100644 --- a/bin/record_store/test_confluence_page.py +++ b/bin/record_store/test_confluence_page.py @@ -7,7 +7,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from record_store.confluence_page import ConfluencePage, digest_of, Seen +from record_store.confluence_page import ConfluencePage from rest_client.json_request import ErrorAnswer from failure import Failure from record_store.held import Held @@ -80,7 +80,9 @@ class ConfluencePageTest(ConfluenceCase): store = self.new_store() held = store.held() assert isinstance(held, Held), held - self.assertEqual(store.write("- a decision\n", held.version), Held("- a decision\n", Seen(8, "Decisions", digest_of("- a decision\n")).token)) + written = store.write("- a decision\n", held.version) + assert isinstance(written, Held), written + self.assertEqual(written.text, "- a decision\n") self.assertEqual(self.confluence.calls[-1], ("PUT", URL, AUTHORIZATION, {"id": PAGE.page_id, "status": "current", "title": "Decisions", "body": {"representation": "atlas_doc_format", "value": json.dumps(to_adf("- a decision\n"))}, "version": {"number": 8}})) def test_saving_the_text_a_read_found_leaves_the_page_as_confluence_holds_it(self) -> None: @@ -89,9 +91,27 @@ class ConfluencePageTest(ConfluenceCase): held = self.new_store().held() assert isinstance(held, Held), held self.assertEqual(self.new_store().write(held.text, held.version), held) - self.assertEqual([call[0] for call in self.confluence.calls], ["GET"]) + self.assertNotIn("PUT", [call[0] for call in self.confluence.calls]) self.assertEqual((self.confluence.version, self.confluence.value), (2, value)) + def test_refuses_to_save_the_text_a_read_found_where_a_teammate_saved_since(self) -> None: + self.confluence.teammate_saves("- a decision\n") + held = self.new_store().held() + assert isinstance(held, Held), held + self.confluence.teammate_saves("- their decision\n") + written = self.new_store().write(held.text, held.version) + assert isinstance(written, Failure), written + self.assertIn("someone saved", written.reason) + self.assertIn("ask the human", written.reason) + self.assertNotIn("PUT", [call[0] for call in self.confluence.calls]) + self.assertEqual(self.new_store().read(), "- their decision\n") + + def test_an_unedited_save_fails_where_the_pages_version_cannot_be_read(self) -> None: + held = self.new_store().held() + assert isinstance(held, Held), held + store = ConfluencePage(PAGE, self.env, lambda *_: ErrorAnswer("GET /wiki/api/v2/pages/2293761 answered 404: Not Found", 404), to_markdown, to_adf) + self.assertEqual(store.write(held.text, held.version), Failure(f"cannot read {PAGE.spelling}: GET /wiki/api/v2/pages/2293761 answered 404: Not Found")) + def test_saving_an_edited_text_writes_the_page(self) -> None: self.confluence.teammate_saves("- a decision\n") held = self.new_store().held() From 7e3204a0897a6a80cee39a5d67222d7ae6aa7b21 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:12:16 +0100 Subject: [PATCH 07/20] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1=20(0=20misread);=20the=20codec?= =?UTF-8?q?'s=20docstring=20and=20the=20decision=20say=20which=20pair=20th?= =?UTF-8?q?e=20loop=20uses=20and=20why,=20the=20entry=20sits=20in=20order,?= =?UTF-8?q?=20and=20item=20395=20names=20its=20parts=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/adf_codec/convert.py | 4 ++-- bin/plan_store/jira_epic.py | 2 +- bin/plan_store/test_jira_epic.py | 2 +- bin/record_store/confluence_page.py | 4 ++-- docs/decisions.md | 10 +++++----- todo.md | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/adf_codec/convert.py b/bin/adf_codec/convert.py index 608c8d5e..4e9ed444 100644 --- a/bin/adf_codec/convert.py +++ b/bin/adf_codec/convert.py @@ -3,8 +3,8 @@ It runs @larvit/adf-codec, a Node package, in a throwaway container that holds node_shim/shim.mjs; the shim's header says what its exit status means. adf-codec has two pairs of calls, and each function here names the one it runs: -- The lossless pair, `*_lossless`, for a document that already exists in Jira or Confluence and is edited and saved back. It keeps each block's localId and the empty paragraphs Jira uses for spacing, so a document read and saved unedited comes back identical. -- The portable pair, with no suffix, for new text written from scratch, and for markdown shown to a person. It drops the localId and the empty paragraphs, so saving a document that exists changes it. +- The portable pair, with no suffix, which the loop's tools use. It drops each block's localId and the empty paragraphs Jira uses for spacing, so saving a document read by it changes the document; a tool that saves one unedited sends nothing instead (`docs/decisions.md` → `project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, …`). +- The lossless pair, `*_lossless`, which keeps both, so a document read and saved unedited comes back identical. Its markdown wraps every block in `!adf:` marker lines, so no tool reads by it yet. """ import contextlib import dataclasses diff --git a/bin/plan_store/jira_epic.py b/bin/plan_store/jira_epic.py index 03b353b2..baf8a571 100644 --- a/bin/plan_store/jira_epic.py +++ b/bin/plan_store/jira_epic.py @@ -186,7 +186,7 @@ class JiraPlan: return Failure(f"cannot convert the item's detail to a Jira description: {description.reason}") if isinstance(description, Failure) else description def shows(self, issue: Issue, detail: str) -> bool: - """Whether detail is the issue's description as a read shows it. An edit leaves such a description as Jira holds it: converting the markdown back would drop the localIds and spacing paragraphs that the markdown a read shows leaves out.""" + """Whether detail is the issue's description as a read shows it. An edit leaves such a description as Jira holds it, since converting the markdown back would drop each block's localId and Jira's spacing paragraphs.""" if issue.description is None: return not detail.strip() texts = self.to_markdown([issue.description]) diff --git a/bin/plan_store/test_jira_epic.py b/bin/plan_store/test_jira_epic.py index f393feee..cba369b9 100644 --- a/bin/plan_store/test_jira_epic.py +++ b/bin/plan_store/test_jira_epic.py @@ -518,7 +518,7 @@ class Editing(unittest.TestCase): self.edit(34, {"E": "3"}) self.assertEqual([body for _, _, body in self.writes()], [{"fields": {"summary": "Count every run."}}, {"properties": [{"key": "plan-item", "value": PROPERTY | {"E": 3}}]}]) - def test_a_detail_as_the_description_reads_leaves_the_description_as_jira_holds_it(self): + def test_a_detail_unchanged_since_the_read_leaves_the_description_as_jira_holds_it(self): # Jira's own spacing paragraph and localIds, which a description converted back from markdown would lose. held = {"type": "doc", "version": 1, "content": [{"type": "paragraph", "attrs": {"localId": "p-1"}, "content": [{"type": "text", "text": "Why it counts."}]}, {"type": "paragraph", "attrs": {"localId": "p-2"}}]} self.open = [issue("ABC-34", scores=PROPERTY, description=held)] diff --git a/bin/record_store/confluence_page.py b/bin/record_store/confluence_page.py index 23737661..4335546f 100644 --- a/bin/record_store/confluence_page.py +++ b/bin/record_store/confluence_page.py @@ -21,7 +21,7 @@ SHAPE = "not in the shape Confluence Cloud's REST API version 2 documents" @dataclasses.dataclass(frozen=True) class Seen: - """The page's version number and title as a read found them or a write left them, and the digest of the markdown it found or sent. A write needs all three, so a Held's version holds them, as JSON.""" + """The page's version number and title as a read found them or a write left them, and the digest of the markdown it found or sent. A write needs the version and title, and sends nothing where its text has that digest, so a Held's version holds all three, as JSON. The digest is None where the version came from a request that held no text.""" version: int title: str digest: str | None = None @@ -88,7 +88,7 @@ class ConfluencePage: seen = self.seen_of(over) if isinstance(seen, Failure): return seen - # The markdown a read shows drops the localIds and spacing paragraphs Confluence holds, so writing the text a read found back would lose them: leave the page alone. No write means no 409, so the version is read instead: a save over a teammate's edit refuses whether or not the text changed. + # A read's markdown leaves out the localIds and spacing paragraphs Confluence holds, so a write of the same text back would drop them: send nothing. Without a write Confluence answers no 409, so read the version to refuse where a teammate saved since. if over is not None and seen.digest == digest_of(text): current = self.fetched("") if isinstance(current, Failure): diff --git a/docs/decisions.md b/docs/decisions.md index f6b693d2..25d8bbbd 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -24,9 +24,9 @@ Each project principle states one rule that the decisions below apply; their ent - principles: about seven things per level, four or five where they act on each other, more where a reader finds them by name; crossing a limit asks for a grouping or a recorded reason - project config: a record may name a Confluence Cloud page as `confluence:` and its address, the loop reads and writes it as markdown, and a write never overwrites a save made since the loop's read - project config: a tool that reads a file's commits says where it does not support that file, and the work goes on -- project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, and a save that hands back the text it showed leaves the document as Jira or Confluence holds it - project config: `language` names the prose's language by its English name, and `commit-title`, `pull-request-title` and `branch` are brace templates over `{id}` and `{summary}` - project config: `plan` may name a Jira Cloud epic as `jira:` and its address, the plan is its open child issues in backlog order, and an issue's number is the item's ID +- project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, and a save whose text is the text a read showed leaves the document as Jira or Confluence holds it - project config: `tooling-on-host = true` lets a project with no container setup run its language runtime, package manager, tests and task runner on the host - review: a release review fixes its findings in the release it reviews, and files under that release only a finding that needs a human answer, adds a feature or outlasts its five rounds - review: a reviewer or comprehension seat that rules the work below standard may ask to rerun once, one rung up, in the same round; the ruling that stands is an escalation trigger for the worker unless the fix changes only prose, and never for the judge @@ -324,10 +324,6 @@ Valid while the later fixes per finished chunk, which `score-outcomes` and the r - **A store keeps no version: its caller hands each write the version it writes over.** lilleman chose this on 2026-11-16, when 0.11.0's release review found the version kept as the store's hidden state, which made a write rest on whichever read came before it. `project-record` keeps the version `open` read in a file beside its copy, `~/.local/state/project-record///.version`, since `save` runs in a later process, and each save keeps the version it left for the next. Every other tool writes over the version its own read gave, so a read by another tool, such as larv-review's, never moves the version an edit in `project-record` rests on. The folder `` is named for the worktree that ran `open`, and `open` removes the folders of worktrees git no longer lists, so a chunk's copy doesn't outlive its worktree. - **The page holds ADF, which adf-codec converts both ways**, so a teammate reads the record as Confluence renders it. Where adf-codec cannot convert the markdown, the write fails with adf-codec's error. A node markdown cannot hold reads as text: a mention as its name, a macro as `_( not included)_`. So the next write replaces it with that text, and a record page should hold only what markdown can. -## project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, and a save that hands back the text it showed leaves the document as Jira or Confluence holds it - -2026-11-17, claude, through item 391. Serves goal 1.6: a team's own spacing and block ids stay in its Jira and Confluence, and agents, the judge and people still read the text easily (goal 1.4's reading cost). adf-codec's lossless pair keeps each block's localId and Jira's spacing paragraphs, but wraps every block in `!adf:` marker lines, which triples a short detail's lines (larvit/adf-codec#185). So reads stay on the portable pair, and a save leaves the document alone where its text is the text a read showed: `JiraPlan.shows` compares a new detail with the description converted again, and `ConfluencePage` keeps the digest of the text it read in the version a write names. Valid while every edit replaces a whole document: an edit that changes one line still rewrites it by the portable pair, dropping the localIds and spacing paragraphs everywhere, until `todo.md` item 395 keeps each block the edit didn't change. - ## project config: a tool that reads a file's commits says where it does not support that file, and the work goes on 2026-11-13, larv-review. Serves goal 1.6: a client's plan and records live in the config's folder, and the loop still runs there. A file the config puts outside the checkout has no commit in the project's history, so a tool that needs the file's commits cannot do its job for it. No such tool blocks the loop or a merge, and each says what it leaves undone: @@ -369,6 +365,10 @@ Messages keep each file's usual name, such as `todo.md`, as its label, since the - **`todo-item edit --comment` carries the comment, and a plan in a file takes the flag and keeps no comment**, so one command works in every project, as goal 1.3 asks. A bench of readers picked the spelling: three fresh readers, seated as the consultant who runs the loop in a client's project, each picked `--comment` over `--reason`, `--why` and `--because`. Only it says the text is posted where the team reads it, and `--reason` read as `--exempt`'s reason. - **The store finishes an item with the transition that the config's `jira-finish-transition` names**, which must lead to the status `jira-finish-status` names, since each Jira workflow differs (lilleman's call, 2026-11-12); any open child of the epic may move. It refuses a status outside Jira's done status category: the read counts an issue as finished only in that category, so the item would stay in the plan. Where the issue's present status has no direct transition to the status `jira-finish-status` names, `todo-item finish` fails and a person moves the issue in Jira: the store never walks an issue through other statuses to reach it. lilleman answered on 2026-11-15: "If it is possible to move it to done without a transisiont, that should happen. If not, fail." The implementer read "without a transition" as "without a transition in between". `rank_todo.py` refuses to rank a plan in Jira, and its `--check` passes, since Jira's backlog ranks it; rule-hook's rank check skips it. Each read first asks Jira for the epic itself, since a search under an epic the account cannot see answers no issues, as a finished plan does. +## project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, and a save whose text is the text a read showed leaves the document as Jira or Confluence holds it + +2026-11-17, claude, through item 391. Serves goal 1.6: a team's Jira and Confluence keep each block's localId and the empty paragraphs Jira uses for spacing, and agents, the judge and people still read the text easily, which keeps goal 1.4's reading cost down. adf-codec converts markdown and ADF by two pairs of calls, as `bin/adf_codec/convert.py` says. The lossless pair keeps the localIds and spacing paragraphs, but wraps every block in two `!adf:` marker lines: a five-line detail became 17 lines in a trial (larvit/adf-codec#185). The portable pair drops both. So the loop reads by the portable pair, and leaves a document alone where a save's text is the text a read showed. `JiraPlan.shows` compares a new detail with the description converted again. `ConfluencePage` keeps the digest of the text it read in the version a write names, and checks that the page still holds that version. Valid while the lossless markdown wraps every block in marker lines. A save that changes one line still rewrites the whole document by the portable pair, and so drops every localId and spacing paragraph, until `todo.md` item 395 keeps each block the save didn't change. + ## project config: `tooling-on-host = true` lets a project with no container setup run its language runtime, package manager, tests and task runner on the host 2026-11-12, lilleman, through todo item 358. Serves goal 1.6: a legacy product may have no container setup, and the loop works in it without its owners adding one. `CLAUDE.md`'s container rule and the stability reviewer follow the setting. rule-hook checks only how a container starts, its memory limits and its image's pin, never where a runtime runs, so it needs no change. A decision may still put one tool on the host where the project has containers, as this repo's `bin/` decision does. Readers seated as the person who writes the config picked the key, 2 of 3. Valid while the loop runs on the machine that holds the checkout. diff --git a/todo.md b/todo.md index a2407ee6..1e443489 100644 --- a/todo.md +++ b/todo.md @@ -68,7 +68,7 @@ | 193 | 0.14.0 | | | **Narrow `numbered`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.** | 1 | 1 | 3 | 3 | 1 | 1.1 by 2 | 0.9 | | 194 | 0.14.0 | | | **Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.9 | | 265 | 0.14.0 | | | **Archive each wait that costs a chunk wall time, for a usage limit, low memory, a failed worker start or a heavy slot, with its start and end stamps, so goal 1.5's hours split waiting from work.** | 3 | 2 | 2 | 5 | 4 | 1.5 by 3 | 0.8 | -| 395 | 0.14.0 | | decision | **Keep each block a save didn't change as Jira or Confluence holds it, with its localId and spacing paragraphs.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 4 | 0.8 | +| 395 | 0.14.0 | | decision | **Keep each block a save didn't change, with its localId, and the spacing paragraphs beside it as Jira or Confluence holds them.** | 3 | 2 | 2 | 5 | 5 | 1.6 by 4 | 0.8 | | 169 | 0.14.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 | 0.7 | | 197 | 0.14.0 | | | **Let the human edit what they type at loop-claude's terminal questions with the arrow keys, so Left moves the cursor in place of printing `^[[D`.** | 2 | 2 | 3 | 5 | 2 | 1.5 by 1 | 0.4 | | 1 | 0.15.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | @@ -578,9 +578,9 @@ Found by review of PR #317. The black-box test, `bin/loop_claude/test_black_box. No record holds these waits today. An outcomes file holds verdicts, stops, step-ups and the judge's cost (`bin/transcript_archive/outcomes.py`), and `~/.local/state/run-heavy/` holds only the slots' lock files. loop-claude waits out a usage limit and low memory in `bin/loop_claude/cycle/retry.py`; run-heavy waits for a slot in `bin/run_heavy/`. A heavy slot's wait happens inside a worker's Bash call, so loop-claude doesn't see it; run-heavy would write it where the archive can find it. -### 395. Keep each block a save didn't change as Jira or Confluence holds it, with its localId and spacing paragraphs. +### 395. Keep each block a save didn't change, with its localId, and the spacing paragraphs beside it as Jira or Confluence holds them. -Today a Jira detail edited in one line, or a Confluence record with one entry appended, is written back whole by adf-codec's portable pair, so every block loses its localId and Jira's spacing paragraphs go. A save whose text is unchanged already leaves the document alone (`docs/decisions.md` → `project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, …`). Match the saved markdown's top-level blocks against the held document's, as the portable pair reads each, and send the held block where they match. The decision's "Valid while" ends with this item. +Today a Jira detail edited in one line, or a Confluence record with one entry appended, is written back whole by adf-codec's portable pair, which drops each block's localId and the empty paragraphs Jira uses for spacing. A save whose text is the text a read showed already sends nothing (`docs/decisions.md` → `project config: the loop shows a Jira description and a Confluence page as adf-codec's portable markdown, …`). Match the saved markdown's top-level blocks against the held document's, each as the portable pair reads it, and send the held block where they match. The decision's limit on partial saves ends with this item. ### 169. Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits. From 0090f87351f24e66a5935ad0115cb4d90ae722c8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:23:50 +0100 Subject: [PATCH 08/20] Assert the whole refusal of a save over a teammate's version, and the version read before an unedited save --- bin/record_store/test_confluence_page.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bin/record_store/test_confluence_page.py b/bin/record_store/test_confluence_page.py index a65c7da4..bc2f7d60 100644 --- a/bin/record_store/test_confluence_page.py +++ b/bin/record_store/test_confluence_page.py @@ -92,6 +92,7 @@ class ConfluencePageTest(ConfluenceCase): assert isinstance(held, Held), held self.assertEqual(self.new_store().write(held.text, held.version), held) self.assertNotIn("PUT", [call[0] for call in self.confluence.calls]) + self.assertEqual(self.confluence.calls[-1], ("GET", URL, AUTHORIZATION, None)) self.assertEqual((self.confluence.version, self.confluence.value), (2, value)) def test_refuses_to_save_the_text_a_read_found_where_a_teammate_saved_since(self) -> None: @@ -100,9 +101,7 @@ class ConfluencePageTest(ConfluenceCase): assert isinstance(held, Held), held self.confluence.teammate_saves("- their decision\n") written = self.new_store().write(held.text, held.version) - assert isinstance(written, Failure), written - self.assertIn("someone saved", written.reason) - self.assertIn("ask the human", written.reason) + self.assertEqual(written, Failure(f"someone saved {PAGE.spelling} since the loop read version 2 of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do (Confluence holds version 3)")) self.assertNotIn("PUT", [call[0] for call in self.confluence.calls]) self.assertEqual(self.new_store().read(), "- their decision\n") @@ -124,10 +123,7 @@ class ConfluencePageTest(ConfluenceCase): assert isinstance(held, Held), held self.confluence.teammate_saves("their edit\n") written = self.new_store().write("my edit\n", held.version) - assert isinstance(written, Failure), written - self.assertIn("someone saved", written.reason) - self.assertIn("ask the human", written.reason) - self.assertIn(PAGE.spelling, written.reason) + self.assertEqual(written, Failure(f"someone saved {PAGE.spelling} since the loop read version 1 of it, so the loop didn't write it: never overwrite their edit, but ask the human what to do (PUT /wiki/api/v2/pages/{PAGE.page_id} answered 409: Version must be incremented on update. Current version is: 2)")) self.assertEqual(self.new_store().read(), "their edit\n") def test_keeps_no_version_itself_so_a_read_never_moves_the_version_a_write_names(self) -> None: From 48c65b9ba4c2e53d758215338bf2643facf09f29 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:35:37 +0100 Subject: [PATCH 09/20] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20both=20answ?= =?UTF-8?q?ers=20hold?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 2a24488a375c2cb263d08f13dbce711f03755cc2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:35:37 +0100 Subject: [PATCH 10/20] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20the=20ch?= =?UTF-8?q?ange=20delivers=20item=20391,=20and=20item=20395's=20release=20?= =?UTF-8?q?is=20the=20human's=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 7e7bc4a20c4d7dfb5c3420b2037840efc8ac9162 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:37:14 +0100 Subject: [PATCH 11/20] Finish item 391 in the plan --- CHANGELOG.md | 1 + todo.md | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b77776..9095ed4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `todo-item edit --detail` and `project-record save` leave a Jira description or a Confluence page exactly as it is, with its block ids and spacing paragraphs, where the text saved is the text a read showed. An unedited save over a page a teammate saved since still refuses. - Add `compress-archives`, which gzips each transcript in loop-claude's archive and each file in the review folders 30 days after it last changed, keeping all of them. The tools that read those folders read a gzipped file by its plain name. A new crontab line in the README's Install section runs it daily. - review-replay and judge-replay keep each run, with its prompt, claude's exit code and stream, and the report they print, in a `replays/--/` folder of loop-claude's archive, so a replay that decided a rung can be checked and re-priced later; claude's json replies are now stream-json, whose last line is the reply. - loop-claude's archive keeps each judge run's prompt and json reply in a judge/ folder beside its chunk's transcripts, and names the run on a `Judge run:` line of the outcome it produced; judge-replay replays a verdict on its archived prompt where the archive holds one. diff --git a/todo.md b/todo.md index 5db3d3dc..7ad0c699 100644 --- a/todo.md +++ b/todo.md @@ -15,7 +15,6 @@ | 387 | 0.12.0 | | | **Bind a project's rung to its ladder in one value, so the routing functions and `Cycle` take one argument for both.** | 3 | 1 | 3 | 5 | 5 | code health by 3 | 2.9 | | 338 | 0.12.0 | | owner | **Script each step that 0.9.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.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 2.3 | | 288 | 0.12.0 | | | **Point the two reading-cost decisions at code health and goal 1.4's counter-signal, in place of the goal 1.1 they cite.** | 1 | 2 | 1 | 2 | 1 | code health by 1, 1.4 by 1 | 2.2 | -| 391 | 0.12.0 | | | **Read and write a Jira epic issue's description and a Confluence record page through the lossless pair, so saving an unedited document leaves it unchanged.** | 3 | 2 | 3 | 6 | 5 | 1.6 by 6, 1.1 by 3 | 1.9 | | 319 | 0.12.0 | | | **Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session.** | 3 | 2 | 3 | 6 | 4 | 1.1 by 2, 1.4 by 2 | 1.2 | | 309 | 0.12.0 | | | **Run a scoring run's second pass on one head with two seats in place of four, once `larv-review agreement` shows the seats agree with each other more than a run agrees with its rerun.** | 2 | 2 | 2 | 4 | 2 | 1.4 by 3 | 1.2 | | 299 | 0.12.0 | | | **Replay the archived judge verdicts through code rules and a classifier trained locally on the archive, and file an item for each verdict kind one of them decides with no missed interrupt.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.0 | @@ -107,18 +106,6 @@ The chunk that ships this item files a copy of this audit in release 0.15.0, the Both `docs/decisions.md` entries under `reading cost: a rise is …` and `reading cost: larv-review measures each finished chunk …` open "Serves goal 1.1: comprehension …". No goal says that any more: code health (`CLAUDE.md` → "Shared goal") holds comprehension, and since PR #455 a rising reading cost is goal 1.4's first counter-signal. Raised by the stability review of PR #455 as a 🟢 outside that change. -### 391. Read and write a Jira epic issue's description and a Confluence record page through the lossless pair, so saving an unedited document leaves it unchanged. - -`plan_store/jira_epic.py` reads an issue's description and writes it back on an edit, and `record_store/confluence_page.py` reads a page and saves it back; both use the portable pair, which drops each block's `localId` and the empty paragraphs Jira uses for spacing. `record_store/jira_description.py` only reads, to show a person: it stays on the portable pair. - -Open before building: the lossless markdown is less readable than the portable one (upstream larvit/adf-codec#185), and agents and the judge read the plan's details from it. Decide how a detail stays readable, for example by reading lossless and showing a person a portable view. Test that an unedited issue and page save back identical. The item ships alone because its R is above 5. - -Touches: -- `bin/plan_store/jira_epic.py`: `JiraPlan` (small), `description_of` (small) -- `bin/record_store/confluence_page.py`: `ConfluencePage` (small) -- `bin/plan_store/test_jira_epic.py`: `Editing`, `Filing` -- `bin/record_store/test_confluence_page.py`: `ConfluencePageTest` - ### 319. Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session. On SWE-bench Verified with Haiku 4.5 and Opus 4.7, handing the strong model the weak model's transcript solved 69.2% at $1.61 a task; starting the strong model fresh solved 79.2% at $0.90 (arXiv 2608.24358, The Handoff Tax). A model switch also rereads the whole context uncached (Claude Code prompt caching docs). A worker that steps from Sonnet 5.5 to Opus 5.5 by `--resume` is the raw handoff; an effort-only step within one model keeps the cache and isn't. The escalated subagent, which starts fresh with the trigger's evidence, already follows the pattern that won. From 1bc2ce89e7bb704ab57ee1c964054ffbd654e4a4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:44:53 +0100 Subject: [PATCH 12/20] Net a resumed arm's cost of the start it resumes --- workflow-bench/handoff_bench.py | 27 ++++++++++++++++++++++----- workflow-bench/test_handoff_bench.py | 23 +++++++++++++++++------ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/workflow-bench/handoff_bench.py b/workflow-bench/handoff_bench.py index 09c8947a..7bacf54a 100644 --- a/workflow-bench/handoff_bench.py +++ b/workflow-bench/handoff_bench.py @@ -12,7 +12,7 @@ best? Each case is an archived chunk of this repo, as in advisor_bench.py, whose has compacted the session with `/compact`, whose stream it saves as .compact.jsonl. The brief arm starts a session that has the item and handoff-brief-prompt.md, and no transcript. - `grade` is advisor_bench.py's, over these cases. `summary` counts an arm's cost and seconds from its own runs, - the compaction included, and leaves out the start, which the arms share. + the compaction included, and leaves out the start, which the arms share (`outcome`). Run each arm of each case once; the table shows a direction, not a significance. """ import concurrent.futures @@ -132,11 +132,28 @@ def run(work, name): return f"{name}: ran" +def results(stream): + """The result lines of a claude stream. A resumed run may open with one that holds no work, and a background task's notification adds one.""" + found = [] + for line in stream.read_text().splitlines(): + try: + entry = json.loads(line) + except ValueError: + continue + if isinstance(entry, dict) and entry.get("type") == "result": + found.append(entry) + return found + + def outcome(work, name): - """The cost and seconds of an arm's run: its STRONG stream's, plus its compaction's where it made one.""" - streams = [stream for stream in (work / f"{name}.compact.jsonl", work / f"{name}.jsonl") if stream.exists()] - results = [advisor_bench.read_result(stream.read_text().splitlines()) for stream in streams] - return {"cost": sum(result.cost for result in results), "seconds": sum(result.seconds for result in results)} + """The cost and seconds of an arm's run, its compaction included. A resumed session's cost counts from the session's start, so the start's cost comes off it.""" + case, arm, number = advisor_bench.split_name(name) + ran = results(work / f"{name}.jsonl") + if not ran or ran[-1].get("is_error"): + raise ValueError(f"the run ended in an error: {ran[-1].get('result')}" if ran else "the stream has no result line") + compacted = results(work / f"{name}.compact.jsonl") if arm == "compact" else [] + before = 0 if arm == "brief" else results(work / f"{case}-start-{number}.jsonl")[-1]["total_cost_usd"] + return {"cost": ran[-1]["total_cost_usd"] - before, "seconds": sum(entry["duration_ms"] for entry in [*compacted, *ran]) / 1000} def rows_of(work): diff --git a/workflow-bench/test_handoff_bench.py b/workflow-bench/test_handoff_bench.py index 8c9f5b45..98873089 100644 --- a/workflow-bench/test_handoff_bench.py +++ b/workflow-bench/test_handoff_bench.py @@ -58,7 +58,8 @@ class Orchestration(unittest.TestCase): self.base = self.commit({"todo.md": TODO, "bin/pkg/mod.py": "x = 1\n"}) merged = self.commit({"bin/pkg/mod.py": "x = 2\n"}) self.calls = [] - self.start_result = {"subtype": "error_max_budget_usd", "is_error": True} + self.start_result = {"subtype": "error_max_budget_usd", "is_error": True, "total_cost_usd": 1.0} + self.strong_result = {} real_run = subprocess.run for patch in ( unittest.mock.patch.object(advisor_bench, "REPO", self.repo), @@ -94,12 +95,14 @@ class Orchestration(unittest.TestCase): kwargs["stdout"].write(result_line(**self.start_result) + "\n") elif args[2] == "/compact": self.transcript.write_text(self.transcript.read_text() + "compacted\n") - kwargs["stdout"].write(result_line(total_cost_usd=0.25, duration_ms=3000) + "\n") + kwargs["stdout"].write(result_line(total_cost_usd=1.25, duration_ms=3000) + "\n") else: if "--resume" in args: self.transcript.write_text(self.transcript.read_text() + "strong\n") + # A resumed session counts its cost from the session's start, and may open with a result that holds no work. + kwargs["stdout"].write(result_line(total_cost_usd=1.0, duration_ms=0) + "\n") (cwd / "bin/pkg" / f"done_{len(self.calls)}.py").write_text("d = 1\n") - kwargs["stdout"].write(result_line() + "\n") + kwargs["stdout"].write(result_line(**self.strong_result, total_cost_usd=3.0 if "--resume" in args else 0.5) + "\n") return subprocess.CompletedProcess(args, 0) if args[0] == str(advisor_bench.RUN_HEAVY): return subprocess.CompletedProcess(args, 0, stdout="3 passed\n", stderr="") @@ -154,6 +157,7 @@ class Orchestration(unittest.TestCase): self.assertIn("+x = 3\n", diff) self.assertIn("+++ b/bin/pkg/done_1.py", diff) self.assertEqual((self.work / "7-resume-1.tests").read_text(), "exit 0\n3 passed\n") + self.assertEqual(handoff_bench.outcome(self.work, "7-resume-1"), {"cost": 2.0, "seconds": 12.0}) def test_the_compact_arm_has_the_weak_model_compact_the_session_before_the_strong_one_resumes_it(self): self.started() @@ -166,7 +170,7 @@ class Orchestration(unittest.TestCase): self.assertEqual(claude[3:7], [*handoff_bench.STRONG.flags()][:4]) self.assertIn("--resume", claude) self.assertEqual(found[0], "weak\ncompacted\n") - self.assertEqual(handoff_bench.outcome(self.work, "7-compact-1"), {"cost": 0.75, "seconds": 15.0}) + self.assertEqual(handoff_bench.outcome(self.work, "7-compact-1"), {"cost": 2.0, "seconds": 15.0}) def test_the_brief_arm_starts_a_fresh_session_with_the_item_and_the_brief(self): self.started() @@ -202,11 +206,18 @@ class Orchestration(unittest.TestCase): def test_run_refuses_an_arm_whose_run_ended_in_an_error_before_it_tests(self): self.started() - with unittest.mock.patch.object(advisor_bench, "save_change") as save_change, unittest.mock.patch.object(advisor_bench, "read_result", side_effect=ValueError("the run ended in an error")): - with self.assertRaisesRegex(ValueError, "ended in an error"): + self.strong_result = {"is_error": True, "result": "overloaded"} + with unittest.mock.patch.object(advisor_bench, "save_change") as save_change: + with self.assertRaisesRegex(ValueError, "ended in an error: overloaded"): handoff_bench.run(self.work, "7-brief-1") save_change.assert_not_called() + def test_outcome_refuses_a_stream_with_no_result_line(self): + self.started() + (self.work / "7-brief-1.jsonl").write_text("not json\n[]\n") + with self.assertRaisesRegex(ValueError, "no result line"): + handoff_bench.outcome(self.work, "7-brief-1") + def test_main_grades_with_the_handoff_cases_and_prints_the_summary(self): self.started() handoff_bench.run(self.work, "7-brief-1") From 20edbcdd21e849ed645723227acec9fbf9cf821a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:45:08 +0100 Subject: [PATCH 13/20] Record that a stepped worker keeps resuming its session, after the handoff bench --- docs/decisions.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/decisions.md b/docs/decisions.md index 6aeef3cf..e2709cb7 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -557,6 +557,16 @@ The step is one rung up from the rung the worker would otherwise hold: its own, The archive quotes the judge's passage under `Escalation:` in the unfinished verdict, the interrupt or the quoted answer. The step an unfinished verdict causes is archived after it. The step an interrupt or a quoted answer causes is archived with it, at once: the interrupt or answer names the rung the worker ran on until then, and a step-up archived beside it names the rung it runs on from then. So the routing figures charge each stretch to its own rung, and a loop that dies while the human answers resumes on the stepped rung. Each archived worker line names the mark once there is one, so a resumed loop keeps it. `bin/routing_figures/` counts none of these steps as an escalation by trigger, which it counts only from subagent prompts. +A stepped worker resumes its session, also when the step changes its model. Item 319 proposed a fresh session with a brief of the chunk in its place, after arXiv 2608.24358 measured a fresh strong model ahead of one handed the weak model's transcript. `workflow-bench/handoff_bench.py` benched it on 2026-11-17, on five L 3 items this repo shipped. Sonnet 5.5 at high effort started each one and stopped at $0.36, after 16 to 20 turns. Opus 5.5 at medium effort then finished it three ways: resuming the session, resuming it after `/compact`, and in a fresh session with a brief of the item, the branch and its diff. A judge that did not know the arm graded each change against the tests the item shipped with. + +| arm | runs | pass | partial | fail | mean cost $ | mean seconds | +|---|---|---|---|---|---|---| +| resume | 5 | 2 | 3 | 0 | 0.68 | 235 | +| compact | 5 | 1 | 3 | 1 | 0.56 | 198 | +| brief | 5 | 1 | 4 | 0 | 0.78 | 310 | + +Resume's verdict matched or beat the brief's on every item, and the brief cost less on two of the five. So the bench gives no reason to pay for the change, which is larger than the worker's start: the archive files a chunk under its session's first line, so a chunk that spans two sessions would need the archive, and each figure read from it, to join them. The bench is small: each arm ran once per item, the judge is the strong arm's model, and no start was longer than 20 turns. Run it again before changing this, with longer starts, since the paper's gap may open only on a long transcript. + Valid while the worker reports in its transcript the triggers that fired, and while a chunk's session transcript only grows. ## routing: loop-claude measures review rounds and unfinished verdicts per rung every 20 cycles, and calls for a routing change when, of two rungs with 5 or more chunks each, the lower took more of either than the one above, or when 5 or more subagents of one type had reports longer than the tool results they read From a924cd264704d633cb2f8e6d030bcc1b7640b6a3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:46:06 +0100 Subject: [PATCH 14/20] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20no=20findin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 7da82b474865c06df9bb9172b464917c6726c0c6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:48:46 +0100 Subject: [PATCH 15/20] Hold the handoff bench's prompts, saved change and steps to their tests --- workflow-bench/handoff_bench.py | 2 +- workflow-bench/test_handoff_bench.py | 32 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/workflow-bench/handoff_bench.py b/workflow-bench/handoff_bench.py index 7bacf54a..9fec2a7b 100644 --- a/workflow-bench/handoff_bench.py +++ b/workflow-bench/handoff_bench.py @@ -15,8 +15,8 @@ best? Each case is an archived chunk of this repo, as in advisor_bench.py, whose the compaction included, and leaves out the start, which the arms share (`outcome`). Run each arm of each case once; the table shows a direction, not a significance. """ -import concurrent.futures import collections +import concurrent.futures import json import pathlib import shutil diff --git a/workflow-bench/test_handoff_bench.py b/workflow-bench/test_handoff_bench.py index 98873089..9698d3d9 100644 --- a/workflow-bench/test_handoff_bench.py +++ b/workflow-bench/test_handoff_bench.py @@ -7,8 +7,8 @@ import unittest.mock import uuid import advisor_bench -import handoff_bench from test_advisor_bench import commit, TODO +import handoff_bench SESSION = uuid.UUID("11111111-2222-4333-8444-555555555555") @@ -55,9 +55,11 @@ class Orchestration(unittest.TestCase): self.repo, self.work, self.projects = root / "repo", root / "work", root / "projects" self.work.mkdir() subprocess.run(["git", "init", "-q", str(self.repo)], check=True) - self.base = self.commit({"todo.md": TODO, "bin/pkg/mod.py": "x = 1\n"}) + (self.repo / "link").symlink_to("todo.md") + self.base = self.commit({"todo.md": TODO, "bin/pkg/mod.py": "x = 1\n", "bin/other/o.py": "o = 1\n"}) merged = self.commit({"bin/pkg/mod.py": "x = 2\n"}) - self.calls = [] + self.commit({"bin/other/o.py": "o = 2\n"}) + self.calls, self.heavy = [], [] self.start_result = {"subtype": "error_max_budget_usd", "is_error": True, "total_cost_usd": 1.0} self.strong_result = {} real_run = subprocess.run @@ -89,6 +91,9 @@ class Orchestration(unittest.TestCase): self.calls.append((args, kwargs, found)) if "--max-budget-usd" in args: (cwd / "bin/pkg/mod.py").write_text("x = 3\n") + # Against the bench rules, the worker commits a part of its change. + real_run(["git", "-C", str(cwd), "add", "bin/pkg/mod.py"], check=True) + commit(cwd, "against the rules") (cwd / "bin/pkg/new.py").write_text("n = 1\n") self.transcript.parent.mkdir(parents=True) self.transcript.write_text("weak\n") @@ -102,9 +107,11 @@ class Orchestration(unittest.TestCase): # A resumed session counts its cost from the session's start, and may open with a result that holds no work. kwargs["stdout"].write(result_line(total_cost_usd=1.0, duration_ms=0) + "\n") (cwd / "bin/pkg" / f"done_{len(self.calls)}.py").write_text("d = 1\n") + kwargs["stdout"].write("a line that is not JSON\n") kwargs["stdout"].write(result_line(**self.strong_result, total_cost_usd=3.0 if "--resume" in args else 0.5) + "\n") return subprocess.CompletedProcess(args, 0) if args[0] == str(advisor_bench.RUN_HEAVY): + self.heavy.append(args) return subprocess.CompletedProcess(args, 0, stdout="3 passed\n", stderr="") return real_run(args, **kwargs) @@ -116,11 +123,12 @@ class Orchestration(unittest.TestCase): self.assertEqual(handoff_bench.start(self.work, "7-1"), "7-1: started") (claude, kwargs, _), = self.calls self.assertEqual(kwargs["cwd"], self.work / "7-1") - self.assertEqual(kwargs["stdin"], subprocess.DEVNULL) + self.assertEqual((kwargs["stdin"], kwargs["stderr"]), (subprocess.DEVNULL, subprocess.STDOUT)) self.assertEqual(claude[:2] + claude[3:], [ "claude", "-p", *handoff_bench.WEAK.flags(), "--session-id", str(SESSION), "--max-budget-usd", "0.25", "--setting-sources", "project", "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) self.assertIn("Do the seventh thing.", claude[2]) + self.assertIn(f"a throwaway clone at `{self.base}`. Implement todo item 7 below", claude[2]) self.assertEqual((self.work / "7-start-1.session").read_text(), str(self.transcript)) self.assertEqual((self.work / "7-start-1.session.jsonl").read_text(), "weak\n") self.assertIn("-x = 1\n+x = 3\n", (self.work / "7-start-1.diff").read_text()) @@ -128,10 +136,11 @@ class Orchestration(unittest.TestCase): self.assertEqual(((tree / "bin/pkg/mod.py").read_text(), (tree / "bin/pkg/new.py").read_text()), ("x = 3\n", "n = 1\n")) self.assertEqual(advisor_bench.git(tree, "status", "--porcelain"), " M bin/pkg/mod.py\n?? bin/pkg/new.py\n") self.assertEqual(advisor_bench.git(tree, "rev-parse", "HEAD").strip(), self.base) + self.assertTrue((tree / "link").is_symlink()) def test_start_refuses_a_worker_that_finished_within_its_budget(self): self.start_result = {} - with self.assertRaisesRegex(ValueError, "finished within its budget"): + with self.assertRaisesRegex(ValueError, "^the weak worker finished within its budget, or its run failed, so there is no handoff to bench$"): handoff_bench.start(self.work, "7-1") def test_start_refuses_a_name_that_already_started(self): @@ -157,6 +166,9 @@ class Orchestration(unittest.TestCase): self.assertIn("+x = 3\n", diff) self.assertIn("+++ b/bin/pkg/done_1.py", diff) self.assertEqual((self.work / "7-resume-1.tests").read_text(), "exit 0\n3 passed\n") + self.assertEqual(self.heavy[-1][-1], "bin/pkg") + self.assertNotIn("bin/other", self.heavy[-1]) + self.assertTrue((self.work / "7-1" / "link").is_symlink()) self.assertEqual(handoff_bench.outcome(self.work, "7-resume-1"), {"cost": 2.0, "seconds": 12.0}) def test_the_compact_arm_has_the_weak_model_compact_the_session_before_the_strong_one_resumes_it(self): @@ -180,7 +192,7 @@ class Orchestration(unittest.TestCase): self.assertEqual(claude[:2] + claude[3:], [ "claude", "-p", *handoff_bench.STRONG.flags(), "--no-session-persistence", "--setting-sources", "project", "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) - self.assertIn("Do the seventh thing.", claude[2]) + self.assertEqual(claude[2], handoff_bench.run_prompt("7") + "\n" + (handoff_bench.BENCH / "handoff-brief-prompt.md").read_text()) self.assertIn("## Handoff", claude[2]) self.assertIn("+++ b/bin/pkg/done_1.py", (self.work / "7-brief-1.diff").read_text()) @@ -215,12 +227,14 @@ class Orchestration(unittest.TestCase): def test_outcome_refuses_a_stream_with_no_result_line(self): self.started() (self.work / "7-brief-1.jsonl").write_text("not json\n[]\n") - with self.assertRaisesRegex(ValueError, "no result line"): + with self.assertRaisesRegex(ValueError, "^the stream has no result line$"): handoff_bench.outcome(self.work, "7-brief-1") def test_main_grades_with_the_handoff_cases_and_prints_the_summary(self): - self.started() - handoff_bench.run(self.work, "7-brief-1") + with unittest.mock.patch("builtins.print") as printed: + handoff_bench.main([str(self.work), "start", "7-1"]) + handoff_bench.main([str(self.work), "run", "7-brief-1"]) + self.assertEqual([call.args[0] for call in printed.call_args_list], ["7-1: started", "7-brief-1: ran"]) with unittest.mock.patch.object(advisor_bench, "grade", return_value="7-brief-1: pass") as grade, unittest.mock.patch("builtins.print") as printed: handoff_bench.main([str(self.work), "grade", "7-brief-1"]) grade.assert_called_once_with(self.work, "7-brief-1", handoff_bench.CASES) From 24800c156b1e77804ae163f928f677eb769b305f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:51:01 +0100 Subject: [PATCH 16/20] Assert that the start's saved diff holds an untracked file --- workflow-bench/test_handoff_bench.py | 1 + 1 file changed, 1 insertion(+) diff --git a/workflow-bench/test_handoff_bench.py b/workflow-bench/test_handoff_bench.py index 9698d3d9..8d2cdf81 100644 --- a/workflow-bench/test_handoff_bench.py +++ b/workflow-bench/test_handoff_bench.py @@ -132,6 +132,7 @@ class Orchestration(unittest.TestCase): self.assertEqual((self.work / "7-start-1.session").read_text(), str(self.transcript)) self.assertEqual((self.work / "7-start-1.session.jsonl").read_text(), "weak\n") self.assertIn("-x = 1\n+x = 3\n", (self.work / "7-start-1.diff").read_text()) + self.assertIn("+n = 1\n", (self.work / "7-start-1.diff").read_text()) tree = self.work / "7-start-1.tree" self.assertEqual(((tree / "bin/pkg/mod.py").read_text(), (tree / "bin/pkg/new.py").read_text()), ("x = 3\n", "n = 1\n")) self.assertEqual(advisor_bench.git(tree, "status", "--porcelain"), " M bin/pkg/mod.py\n?? bin/pkg/new.py\n") From b4490b4a8c6be75309aa55b55b2a19beb1f4d2b7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:56:25 +0100 Subject: [PATCH 17/20] Refuse a compact arm whose compaction failed, and state the bench as it ran --- docs/decisions.md | 4 ++-- workflow-bench/advisor_bench.py | 2 +- workflow-bench/handoff_bench.py | 20 ++++++++++++++------ workflow-bench/test_handoff_bench.py | 18 +++++++++++++----- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/docs/decisions.md b/docs/decisions.md index e2709cb7..de344592 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -557,7 +557,7 @@ The step is one rung up from the rung the worker would otherwise hold: its own, The archive quotes the judge's passage under `Escalation:` in the unfinished verdict, the interrupt or the quoted answer. The step an unfinished verdict causes is archived after it. The step an interrupt or a quoted answer causes is archived with it, at once: the interrupt or answer names the rung the worker ran on until then, and a step-up archived beside it names the rung it runs on from then. So the routing figures charge each stretch to its own rung, and a loop that dies while the human answers resumes on the stepped rung. Each archived worker line names the mark once there is one, so a resumed loop keeps it. `bin/routing_figures/` counts none of these steps as an escalation by trigger, which it counts only from subagent prompts. -A stepped worker resumes its session, also when the step changes its model. Item 319 proposed a fresh session with a brief of the chunk in its place, after arXiv 2608.24358 measured a fresh strong model ahead of one handed the weak model's transcript. `workflow-bench/handoff_bench.py` benched it on 2026-11-17, on five L 3 items this repo shipped. Sonnet 5.5 at high effort started each one and stopped at $0.36, after 16 to 20 turns. Opus 5.5 at medium effort then finished it three ways: resuming the session, resuming it after `/compact`, and in a fresh session with a brief of the item, the branch and its diff. A judge that did not know the arm graded each change against the tests the item shipped with. +A stepped worker resumes its session, also when the step changes its model. Item 319 proposed a fresh session with a brief of the chunk in its place, after arXiv 2608.24358 measured a fresh strong model ahead of one handed the weak model's transcript. `workflow-bench/handoff_bench.py` benched it on 2026-11-17, on L 3 items this repo shipped. Sonnet 5.5 at high effort started each of six and was stopped at $0.36. It stopped itself on item 163 as it reached the budget, which the bench reads as a finished run, so five items went on, each stopped after 9 to 13 turns. Opus 5.5 at medium effort then finished it three ways: resuming the session, resuming it after `/compact`, and in a fresh session with the item's text and a brief, which says that the unfinished change lies uncommitted in the clone. A judge that did not know the arm graded each change. It saw the item, the change that shipped for it, and the result of the tests run on the worker's tree. | arm | runs | pass | partial | fail | mean cost $ | mean seconds | |---|---|---|---|---|---|---| @@ -565,7 +565,7 @@ A stepped worker resumes its session, also when the step changes its model. Item | compact | 5 | 1 | 3 | 1 | 0.56 | 198 | | brief | 5 | 1 | 4 | 0 | 0.78 | 310 | -Resume's verdict matched or beat the brief's on every item, and the brief cost less on two of the five. So the bench gives no reason to pay for the change, which is larger than the worker's start: the archive files a chunk under its session's first line, so a chunk that spans two sessions would need the archive, and each figure read from it, to join them. The bench is small: each arm ran once per item, the judge is the strong arm's model, and no start was longer than 20 turns. Run it again before changing this, with longer starts, since the paper's gap may open only on a long transcript. +Resume's verdict matched or beat the brief's on every item, and the brief cost less on two of the five. So the bench gives no reason to pay for a fresh session. Its price is more than a change to how the worker starts. The archive files a chunk under its session's first line. For a chunk that spans two sessions, the archive, and each figure read from it, would have to join them. The bench is small: each arm ran once per item, the judge is Opus 5.5 too, and no first run was longer than 13 turns. Run it again before changing this, with longer first runs, since the paper's gap may open only on a long transcript. Valid while the worker reports in its transcript the triggers that fired, and while a chunk's session transcript only grows. diff --git a/workflow-bench/advisor_bench.py b/workflow-bench/advisor_bench.py index 9c40f1e3..5d83a3f6 100644 --- a/workflow-bench/advisor_bench.py +++ b/workflow-bench/advisor_bench.py @@ -151,7 +151,7 @@ def run(work, name): def save_change(work, name, clone, commits): - """Save the clone's change since the case's start commit as .diff, and the result of the tests of the packages that it or the merged change touches as .tests.""" + """Save the clone's change since the case's start commit as .diff, and as .tests the result of the tests of the packages that the clone's change or the merged change touches.""" base, merged = commits git(clone, "add", "--all") (work / f"{name}.diff").write_text(git(clone, "diff", "--cached", base)) diff --git a/workflow-bench/handoff_bench.py b/workflow-bench/handoff_bench.py index 9fec2a7b..0fa7d299 100644 --- a/workflow-bench/handoff_bench.py +++ b/workflow-bench/handoff_bench.py @@ -6,7 +6,8 @@ best? Each case is an archived chunk of this repo, as in advisor_bench.py, whose - `start` runs WEAK on the item in the clone /- until it has spent START_BUDGET, which stands in for a run that ends asking for a higher rung. A worker that finishes within the budget leaves no handoff, so `start` fails on it. It saves the change so far (-start-.diff), and a copy of the clone - (.tree) and of the session's transcript (.session.jsonl), which every arm starts from. + (.tree), which every arm starts from, and a copy of the session's transcript (.session.jsonl), which the resume + and compact arms continue. - `run` puts the clone and the session back as `start` left them, then continues on STRONG, one arm of a case at a time. The resume arm resumes WEAK's session with handoff-resume-prompt.md. The compact arm does the same once WEAK has compacted the session with `/compact`, whose stream it saves as .compact.jsonl. The brief arm starts a @@ -48,7 +49,7 @@ CASES = { "239": ("d583f8d48", "47a40757"), } # Dollars WEAK may spend before the handoff. In a trial, $0.36 stopped Sonnet 5.5 on items 163 and 227 after 11 to 14 -# turns, with about 250 lines of diff. +# turns, as the result line's `num_turns` counts them, with about 250 lines of diff. START_BUDGET = 0.36 CLAUDE_FLAGS = ["--setting-sources", "project", "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"] @@ -60,7 +61,7 @@ def stopped_at_budget(lines): entry = json.loads(line) except ValueError: continue - if entry.get("type") == "result": + if isinstance(entry, dict) and entry.get("type") == "result": return entry.get("subtype") == "error_max_budget_usd" return False @@ -122,6 +123,7 @@ def run(work, name): resumed = ["--resume", transcript.stem] if arm == "compact": claude("/compact", [*WEAK.flags(), *resumed], clone, work / f"{name}.compact.jsonl") + finished(work / f"{name}.compact.jsonl") if arm == "brief": claude(run_prompt(case) + "\n" + (BENCH / "handoff-brief-prompt.md").read_text(), [*STRONG.flags(), "--no-session-persistence"], clone, stream) else: @@ -145,12 +147,18 @@ def results(stream): return found +def finished(stream): + """The result lines of a run that ended well; a run without one, or whose last one is an error, raises.""" + ran = results(stream) + if not ran or ran[-1].get("is_error"): + raise ValueError(f"the run ended in an error: {ran[-1].get('result')}" if ran else "the stream has no result line") + return ran + + def outcome(work, name): """The cost and seconds of an arm's run, its compaction included. A resumed session's cost counts from the session's start, so the start's cost comes off it.""" case, arm, number = advisor_bench.split_name(name) - ran = results(work / f"{name}.jsonl") - if not ran or ran[-1].get("is_error"): - raise ValueError(f"the run ended in an error: {ran[-1].get('result')}" if ran else "the stream has no result line") + ran = finished(work / f"{name}.jsonl") compacted = results(work / f"{name}.compact.jsonl") if arm == "compact" else [] before = 0 if arm == "brief" else results(work / f"{case}-start-{number}.jsonl")[-1]["total_cost_usd"] return {"cost": ran[-1]["total_cost_usd"] - before, "seconds": sum(entry["duration_ms"] for entry in [*compacted, *ran]) / 1000} diff --git a/workflow-bench/test_handoff_bench.py b/workflow-bench/test_handoff_bench.py index 8d2cdf81..b363af7b 100644 --- a/workflow-bench/test_handoff_bench.py +++ b/workflow-bench/test_handoff_bench.py @@ -25,7 +25,7 @@ class StoppedAtBudget(unittest.TestCase): self.assertFalse(handoff_bench.stopped_at_budget([result_line()])) def test_fails_where_the_stream_has_no_result(self): - self.assertFalse(handoff_bench.stopped_at_budget(['{"type": "assistant"}'])) + self.assertFalse(handoff_bench.stopped_at_budget(['{"type": "assistant"}', "[]"])) class Summary(unittest.TestCase): @@ -61,7 +61,7 @@ class Orchestration(unittest.TestCase): self.commit({"bin/other/o.py": "o = 2\n"}) self.calls, self.heavy = [], [] self.start_result = {"subtype": "error_max_budget_usd", "is_error": True, "total_cost_usd": 1.0} - self.strong_result = {} + self.compact_result, self.strong_result = {}, {} real_run = subprocess.run for patch in ( unittest.mock.patch.object(advisor_bench, "REPO", self.repo), @@ -100,7 +100,7 @@ class Orchestration(unittest.TestCase): kwargs["stdout"].write(result_line(**self.start_result) + "\n") elif args[2] == "/compact": self.transcript.write_text(self.transcript.read_text() + "compacted\n") - kwargs["stdout"].write(result_line(total_cost_usd=1.25, duration_ms=3000) + "\n") + kwargs["stdout"].write(result_line(**self.compact_result, total_cost_usd=1.25, duration_ms=3000) + "\n") else: if "--resume" in args: self.transcript.write_text(self.transcript.read_text() + "strong\n") @@ -193,8 +193,8 @@ class Orchestration(unittest.TestCase): self.assertEqual(claude[:2] + claude[3:], [ "claude", "-p", *handoff_bench.STRONG.flags(), "--no-session-persistence", "--setting-sources", "project", "--permission-mode", "bypassPermissions", "--output-format", "stream-json", "--verbose"]) - self.assertEqual(claude[2], handoff_bench.run_prompt("7") + "\n" + (handoff_bench.BENCH / "handoff-brief-prompt.md").read_text()) - self.assertIn("## Handoff", claude[2]) + self.assertIn("### 7. Do the seventh thing.", claude[2]) + self.assertTrue(claude[2].endswith("- End with a two-line summary of what you changed.\n\n\n## Handoff\n\n" + (handoff_bench.BENCH / "handoff-brief-prompt.md").read_text().split("## Handoff\n\n")[1]), claude[2][-400:]) self.assertIn("+++ b/bin/pkg/done_1.py", (self.work / "7-brief-1.diff").read_text()) def test_each_arm_begins_on_the_tree_and_the_session_that_start_left(self): @@ -225,6 +225,14 @@ class Orchestration(unittest.TestCase): handoff_bench.run(self.work, "7-brief-1") save_change.assert_not_called() + def test_run_refuses_a_compact_arm_whose_compaction_failed_before_the_strong_model_runs(self): + self.started() + self.compact_result = {"is_error": True, "result": "no conversation to compact"} + with self.assertRaisesRegex(ValueError, "^the run ended in an error: no conversation to compact$"): + handoff_bench.run(self.work, "7-compact-1") + self.assertEqual([args[2] for args, _, _ in self.calls], ["/compact"]) + self.assertFalse((self.work / "7-compact-1.jsonl").exists()) + def test_outcome_refuses_a_stream_with_no_result_line(self): self.started() (self.work / "7-brief-1.jsonl").write_text("not json\n[]\n") From 4875e07f988f7ed3ac6152f101941a42cbcc5fc0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:58:52 +0100 Subject: [PATCH 18/20] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20refuse=20a?= =?UTF-8?q?=20failed=20compaction=20and=20count=20the=20starts'=20turns=20?= =?UTF-8?q?as=20claude=20does?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workflow-bench/test_handoff_bench.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow-bench/test_handoff_bench.py b/workflow-bench/test_handoff_bench.py index b363af7b..49b275f3 100644 --- a/workflow-bench/test_handoff_bench.py +++ b/workflow-bench/test_handoff_bench.py @@ -19,7 +19,7 @@ def result_line(**fields): class StoppedAtBudget(unittest.TestCase): def test_holds_where_the_first_result_is_the_budget_stop(self): - self.assertTrue(handoff_bench.stopped_at_budget(["not json", result_line(subtype="error_max_budget_usd", is_error=True)])) + self.assertTrue(handoff_bench.stopped_at_budget(["not json", '{"type": "assistant"}', result_line(subtype="error_max_budget_usd", is_error=True)])) def test_fails_where_the_worker_finished_within_the_budget(self): self.assertFalse(handoff_bench.stopped_at_budget([result_line()])) From 07674b2c20712785ad33ec6c082b3ef926c85f2b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 03:58:52 +0100 Subject: [PATCH 19/20] =?UTF-8?q?Answer=20prose=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20the=20decis?= =?UTF-8?q?ion=20states=20what=20the=20judge=20saw,=20what=20the=20brief?= =?UTF-8?q?=20held=20and=20why=20five=20items=20ran?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 376a5a83235bfcc96ed2dfac0caf50be3c1eb105 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 04:01:29 +0100 Subject: [PATCH 20/20] Ask whether item 319 is dropped after its bench --- todo.md | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/todo.md b/todo.md index 7a457d84..8a12ebb5 100644 --- a/todo.md +++ b/todo.md @@ -12,6 +12,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| +| 319 | 0.12.0 | | question | **Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 2, 1.4 by 2 | 0.9 | | 306 | 0.12.0 | | | **Set a strategy that keeps loop-claude's archive and larv-review's review folders backed up and small over the years, compressing older entries without losing any.** | 3 | 2 | 4 | 7 | 5 | 3 by 5 | 3.9 | | 387 | 0.12.0 | | | **Bind a project's rung to its ladder in one value, so the routing functions and `Cycle` take one argument for both.** | 3 | 1 | 3 | 5 | 5 | code health by 3 | 2.9 | | 338 | 0.12.0 | | owner | **Script each step that 0.9.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.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 2.3 | @@ -23,7 +24,6 @@ | 316 | 0.12.0 | | | **Launch comprehension seats as an agent type of their own under `agents/`, without `CLAUDE.md` and the skill and agent listings a general-purpose subagent carries.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.0 | | 339 | 0.12.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.0 | | 341 | 0.12.0 | | | **Hand each worker's claude a lower Read limit through `CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS`, kept only where replays of the archived review rounds find what two unchanged replays find.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.0 | -| 319 | 0.12.0 | | | **Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 2, 1.4 by 2 | 0.9 | | 310 | 0.12.0 | | | **Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 0.9 | | 393 | 0.12.0 | | decision | **Step an L 3 worker one rung up and an L 4 worker two up from the project's rung, as lilleman ruled on 2026-11-14.** | 2 | 1 | 3 | 4 | 4 | 1.4 by 3 | 0.9 | | 298 | 0.12.0 | | | **Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.** | 3 | 3 | 3 | 7 | 4 | 1.4 by 2, 1.5 by 1 | 0.9 | @@ -74,6 +74,22 @@ ## Details +### 319. Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session. + +On SWE-bench Verified with Haiku 4.5 and Opus 4.7, handing the strong model the weak model's transcript solved 69.2% at $1.61 a task; starting the strong model fresh solved 79.2% at $0.90 (arXiv 2608.24358, The Handoff Tax). A model switch also rereads the whole context uncached (Claude Code prompt caching docs). A worker that steps from Sonnet 5.5 to Opus 5.5 by `--resume` is the raw handoff; an effort-only step within one model keeps the cache and isn't. The escalated subagent, which starts fresh with the trigger's evidence, already follows the pattern that won. + +Bench it first on `workflow-bench`: resume against a fresh start with a brief. The brief is the chunk's item, its branch and diff, open findings and the trigger. lilleman approved on 2026-11-11. Revise the decision `routing: a worker whose run ends asking for a higher rung…`. + +Touches: +- `bin/loop_claude/cycle/run.py`: `Cycle`, `run_cycle`, `worker_start` +- `bin/loop_claude/cycle/prompts.py`: `resumed`, `stepped_to` +- `bin/loop_claude/cycle/worker.py`: `worker_args` +- `bin/loop_claude/cycle/states.py` +- `bin/loop_claude/test_loop_claude.py`: `Cycles`, `WorkerArgs` +- `workflow-bench/bench.py`: `run`, `main` + +**Question for lilleman, 2026-11-17: drop this item, or build it despite the bench?** `workflow-bench/handoff_bench.py` benched it on five L 3 items. Resume passed 2 and was partial on 3, at a mean $0.68. The fresh session with a brief passed 1 and was partial on 4, at $0.78. Resume's verdict matched or beat the brief's on every item. The decision `routing: a worker whose run ends asking for a higher rung…` holds the table and the bench's limits. Building it also costs more than the files listed above: the archive files a chunk under its session's first line, so `bin/transcript_archive` and each figure read from it would have to join a chunk's two sessions. Recommendation: drop it with `Drop item 319`, and bench again with longer first runs before filing it anew. Whoever closes the item adds the bench to `CHANGELOG.md`. + ### 306. Set a strategy that keeps loop-claude's archive and larv-review's review folders backed up and small over the years, compressing older entries without losing any. Measured on 2026-11-11: loop-claude's archive is 6.3 GB (12,721 files from October alone, 0.84 GB older than 30 days), and `~/.local/state/larv-review/` is 997 MB, 984 MB of it under `code/`, with no pruning: `skills/larv-review/SKILL.md` → "Reports" keeps every folder after the merge, because `review-replay` replays rounds from them. The largest archived worker transcript, 23.4 MB, gzips to 9.1 MB at level 6. The disk holds 65 GB free today. @@ -228,20 +244,6 @@ Touches: - `bin/review_replay/test_review_replay.py` - `bin/loop_claude/test_loop_claude.py`: `Cycles` (small), `HelpLimits` (small) -### 319. Start a fresh session with a brief of the chunk when a rung step changes the worker's model, in place of resuming the old session. - -On SWE-bench Verified with Haiku 4.5 and Opus 4.7, handing the strong model the weak model's transcript solved 69.2% at $1.61 a task; starting the strong model fresh solved 79.2% at $0.90 (arXiv 2608.24358, The Handoff Tax). A model switch also rereads the whole context uncached (Claude Code prompt caching docs). A worker that steps from Sonnet 5.5 to Opus 5.5 by `--resume` is the raw handoff; an effort-only step within one model keeps the cache and isn't. The escalated subagent, which starts fresh with the trigger's evidence, already follows the pattern that won. - -Bench it first on `workflow-bench`: resume against a fresh start with a brief. The brief is the chunk's item, its branch and diff, open findings and the trigger. lilleman approved on 2026-11-11. Revise the decision `routing: a worker whose run ends asking for a higher rung…`. - -Touches: -- `bin/loop_claude/cycle/run.py`: `Cycle`, `run_cycle`, `worker_start` -- `bin/loop_claude/cycle/prompts.py`: `resumed`, `stepped_to` -- `bin/loop_claude/cycle/worker.py`: `worker_args` -- `bin/loop_claude/cycle/states.py` -- `bin/loop_claude/test_loop_claude.py`: `Cycles`, `WorkerArgs` -- `workflow-bench/bench.py`: `run`, `main` - ### 310. Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then. 281 worker resumes after the 1-hour cache expired rewrote a whole context, $379 of the $9,154 measured from 2026-09-30 to 2026-11-11 (4.1%). A compaction while the cache is warm reads the context at a twentieth of the input price and leaves about 20k tokens to rewrite later.