File a finding and record a decision in a do-epic epic, and give the judge the epic's records beside the repo's
CI / tests (pull_request) Failing after 4m22s

This commit is contained in:
2026-11-18 23:13:43 +01:00
parent 36dbddfa0b
commit d0ecdd6359
19 changed files with 334 additions and 47 deletions
+2 -2
View File
@@ -216,7 +216,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
- `branch_chunks/` cuts a default branch into chunks and finds, for each, the items it shipped and the later chunks that fixed its code, for `score_outcomes` and `routing_figures`. It imports `reading_cost`'s record path.
- `command_lines/` reads a shell command: its simple commands, and a docker call's subcommand and memory limits, for `command_patterns`, `reading_cost`, `routing_figures`, `rule_hook` and `run_heavy`.
- `deploy_release` imports `release_plan`'s `release_standing`.
- `do_epic/` holds `do-epic`, the tool that drives one Jira epic. `main.py` starts the epic's chunks and runs one chunk's cycles in its window, through `agent_cycle`. `scheduler.py` says which issues run now: as many as the epic's cap and each repo's `parallel-chunks` allow, and none in a repo where loop-claude runs chunks. Beside it, `chunk_prompt.py` words what a chunk's worker reads. `config.py` reads its machine-wide settings, importing `project_config`'s settings and `model_routing`'s ladder file, and `epic_record.py` reads and writes an epic's description by section, language line and cap line, through `record_store`'s `EpicDescription`. `repos.py` finds a repo's checkout and project config by its name, and clones a missing checkout from the host and owner of the epic's other repos, through `forge`'s `url_beside`. `repo_pick.py` asks claude, by `repo-rule.md`, where an epic item is worked, and records the answer as a label on the issue. `split.py` has claude predict from the code which repos an item changes, and files a sub-task per repo under it where there are several. `ranking.py` orders an epic's items by score over one chain of goals, the epic's, then code health, then the item's repo's, through `plan`'s ranking, and re-ranks the tracker's backlog to that order through `backend/`. `backend/` reads, files and ranks the epic's issues, adds the labels `repo_pick.py` and `split.py` record, and posts comments.
- `do_epic/` holds `do-epic`, the tool that drives one Jira epic. `main.py` starts the epic's chunks and runs one chunk's cycles in its window, through `agent_cycle`. `scheduler.py` says which issues run now: as many as the epic's cap and each repo's `parallel-chunks` allow, and none in a repo where loop-claude runs chunks. Beside it, `chunk_prompt.py` words what a chunk's worker reads. `findings.py` is what that worker writes into the epic: `do-epic <EPIC-KEY> --file` files a finding as an issue of the epic, and `--record-decision` appends a decision to its description. `config.py` reads its machine-wide settings, importing `project_config`'s settings and `model_routing`'s ladder file, and `epic_record.py` reads and writes an epic's description by section, language line and cap line, through `record_store`'s `EpicDescription`. `repos.py` finds a repo's checkout and project config by its name, and clones a missing checkout from the host and owner of the epic's other repos, through `forge`'s `url_beside`. `repo_pick.py` asks claude, by `repo-rule.md`, where an epic item is worked, and records the answer as a label on the issue. `split.py` has claude predict from the code which repos an item changes, and files a sub-task per repo under it where there are several. `ranking.py` orders an epic's items by score over one chain of goals, the epic's, then code health, then the item's repo's, through `plan`'s ranking, and re-ranks the tracker's backlog to that order through `backend/`. `backend/` reads, files and ranks the epic's issues, adds the labels `repo_pick.py` and `split.py` record, and posts comments.
- `forge/` tells a GitHub origin from a Gitea one, names a repo beside an origin's and runs that forge's CLI (`commands.py`), and finds a pull request and waits for its checks (`pulls.py`), for `chunk_preflight`, `chunk_pr`, `deploy_release`, `do_epic` and `larv_review`.
- `git_cli/` runs git for every tool (`git_repo.py`), and reads the git calls in a shell command (`git_command.py`).
- `judge_replay` imports `agent_cycle`'s judge and verdicts, and `loop_claude`'s premises, records and `ANSWER_DESTINATIONS`.
@@ -237,7 +237,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
- `routing_figures/` measures loop-claude's archive, and each of its projects' default branches, for loop-claude's routing calls.
- `rung_replay/` holds what `judge_replay` and `review_replay` share: the parallel replay runner, the argument reader, the candidate rungs and the exits, and `judge_replay`'s rung search. It reads `agent_cycle`'s retry count and `loop_claude`'s models file, and finds that file through `loop_state`'s paths. Its `archive.py` keeps each replay's runs and its report in a `replays/` folder of loop-claude's archive.
- `test_env.py` serves the tests.
- `text_files/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, stamps times in UTC, replaces a file in one step, private where it is new, and gzips a file beside its plain name, by which it reads it afterwards.
- `text_files/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, reads the text piped into a command, stamps times in UTC, replaces a file in one step, private where it is new, and gzips a file beside its plain name, by which it reads it afterwards.
- `transcript_archive/` stores loop-claude's transcripts. Its `project_key.py` names each project's archive folder, loop-claude session and models-file entry.
## Test
+3 -1
View File
@@ -141,6 +141,8 @@ class Brief(typing.NamedTuple):
task: str
premises: str
records: str
# What the records are, in their order, as WorkerPrompts.records_named has it.
records_named: str
# Where the worker may record an answer the human typed, as the entry point names it.
answer_destinations: str
entries: list[Entry]
@@ -290,7 +292,7 @@ def judge_prompt(brief: Brief) -> tuple[str, Grounds]:
"""The prompt, and what the judge's quotes are checked against."""
head = (
f"From the goals file, {brief.premises}\n\n"
f"The records: the project's working rules and decisions, then the human's rules for every project:\n{brief.records or 'none'}\n\n"
f"The records: {brief.records_named}:\n{brief.records or 'none'}\n\n"
f"{TASK_HEADING}{brief.task}\n\n"
f"{transcript_heading(brief.driver)}"
)
+1
View File
@@ -156,6 +156,7 @@ def rule(cycle: Cycle, transcript_path: str, quoted_answers: int) -> Ruled | Sto
task=cycle.task,
premises=cycle.premises,
records=cycle.records,
records_named=cycle.prompts.records_named,
answer_destinations=cycle.prompts.answer_destinations,
entries=entries,
escalated_at=cycle.route.escalated_at,
+2
View File
@@ -45,6 +45,8 @@ class WorkerPrompts:
quote_sources: str
# Where the worker may record an answer the human typed.
answer_destinations: str
# What the records the judge reads are, in the order it reads them.
records_named: str
def answered(self, question: str, answer: str, route: Route, project: ProjectRung | None, stepped: bool) -> str:
"""stepped is whether the answer's ruling stepped the worker up."""
+11 -2
View File
@@ -1,5 +1,8 @@
"""What a do-epic cycle's worker is told: its task, from the issue, and its first prompt. The resumed prompt and the rung sentences are the ones loop-claude's cycles use, naming do-epic."""
from do_epic.backend.protocol import EpicIssue
from do_epic import findings
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from text_files.markdown_text import listed
from model_routing.ladder import ProjectRung
from loop_claude.cycle import prompts
from model_routing.route import Route
@@ -11,7 +14,7 @@ DRIVER = "do-epic"
def task(issue: EpicIssue, epic: str, checkout: str | None) -> str:
"""The task of the chunk that works issue, of the epic with the key epic: in checkout, or without a repo where it is None."""
where = f"in the checkout {checkout}, on the branch {issue.key}" if checkout else "which changes no repo: work in the folder you start in"
return f"Work the Jira issue {issue.key} of the epic {epic} as one chunk, {where}. Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
return f"Work the Jira issue {issue.key} of the epic {epic} as one chunk, {where}. {findings.instructions(epic)} Its summary: {issue.summary}" + (f"\n\nIts description:\n\n{issue.detail}" if issue.detail else "")
CODE_HEALTH = '~/.claude/CLAUDE.md → "Shared goal"'
@@ -25,4 +28,10 @@ def fresh(task: str, premises: str, route: Route, project: ProjectRung | None, f
# The worker names no plan items: the chunk's one item is its issue.
WORKER = prompts.worker_prompts(DRIVER, fresh, "")
# The epic's records come first, as its goals do; a chunk without a repo has only those and the human's rules.
NAMES = prompts.RecordNames(
quote_sources=listed(("the epic's description", "the repo's goals file's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES), "or"),
answer_destinations="the epic's description under ## Decisions, the repo's goals file's Goals or Audience, " + ", ".join(RECORD_FILES) + ", the repo's plan or a comment",
records_named="the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project",
)
WORKER = prompts.worker_prompts(DRIVER, fresh, "", NAMES)
+13
View File
@@ -110,6 +110,19 @@ class EpicRecord:
"""Writes body as the ## name section. approved says the human approved the change in an interrupt, which Goals and Audience need."""
return self.written(lambda text: with_section(text, name, body), frozenset({name}) if approved else frozenset())
def append_decision(self, title: str, entry: str) -> Held | Failure:
"""Adds entry under a ### title heading at the end of ## Decisions, leaving the decisions before it as they are."""
if not title.strip() or "\n" in title:
return Failure("the title must be one line of text")
if not entry.strip():
return Failure("pipe the decision's text in")
def appended(text: str) -> str | Failure:
before = read_section(text, "Decisions")
return before if isinstance(before, Failure) else with_section(text, "Decisions", f"{before}\n\n### {title.strip()}\n\n{entry.strip()}".strip())
return self.written(appended, frozenset())
def write_language(self, language: str) -> Held | Failure:
return self.written(lambda text: with_language(text, language), frozenset())
+59
View File
@@ -0,0 +1,59 @@
"""What a chunk's worker writes into its epic: a finding, filed as an issue, and a decision, appended to the description.
A finding about one of the epic's goals is filed in the epic, and one about a repo's goals by that repo's rules (docs/decisions.md → `do-epic: drives one Jira epic …` → "Findings"). A decision that governs the epic goes under the description's ## Decisions, where the judge of each later chunk reads it."""
import typing
from do_epic.backend.protocol import EpicStore
from do_epic.epic_record import EpicRecord
from failure import Failure
from text_files.piped_text import piped
# Three readers, seated as the human and as a chunk's worker, ranked four spellings of each flag: `<EPIC-KEY> --file` came first, second and second, ahead of `--file <EPIC-KEY>`, `add` and `--finding`; `--record-decision` won 2-1 over `--decision`, since `--decide` reads as do-epic deciding.
FILE = "--file"
LABEL = "--label"
RECORD_DECISION = "--record-decision"
USAGE = f"""do-epic <EPIC-KEY> {FILE} <summary> [{LABEL} <label>] [<<'EOF' detail EOF]
do-epic <EPIC-KEY> {RECORD_DECISION} <title> <<'EOF' entry EOF"""
HELP = f"""{FILE} files a finding about one of the epic's goals as an open issue of the epic, with the markdown piped in as its description.
{LABEL} names its repo, or says the work changes no repo; without one the issue waits.
A finding about a repo's own goals goes into that repo's plan instead.
{RECORD_DECISION} appends a decision that governs the epic to its description's ## Decisions, under the title, with the markdown piped in as its text."""
def instructions(epic: str) -> str:
"""What a chunk's first prompt says about filing a finding and recording a decision in the epic with the key epic."""
return (
f"File a finding about one of the epic's goals in the epic, with `do-epic {epic} {FILE} \"<summary>\" [{LABEL} <label>]` and its detail on stdin. "
"File one about a repo's goals by that repo's rules. Where unsure which, ask the human. "
f"Record a decision that governs the epic, such as an answer the human typed, with `do-epic {epic} {RECORD_DECISION} \"<title>\"` and its text on stdin."
)
def parsed(words: list[str]) -> tuple[str, str, str | None] | None:
"""The flag, its one value and the label of the words after the epic's key; None where they aren't a filing or a decision spelt as USAGE has them. A word that opens with `--` is no summary, title or label."""
if not words or words[0] not in (FILE, RECORD_DECISION):
return None
label: str | None = None
rest = words[1:]
if words[0] == FILE and LABEL in rest:
at = rest.index(LABEL)
if at + 1 >= len(rest):
return None
label, rest = rest[at + 1], rest[:at] + rest[at + 2:]
if len(rest) != 1 or any(word.startswith("--") for word in (*rest, label or "")):
return None
return words[0], rest[0], label
def written(epic: str, flag: str, value: str, label: str | None, store: EpicStore, record: EpicRecord, stdin: typing.TextIO) -> str | Failure:
"""Files the finding or records the decision, as flag says, and answers the line to print."""
text = piped(stdin)
if flag == FILE:
key = store.file(epic, value, text, (label,) if label else ())
if isinstance(key, Failure):
return Failure(f"cannot file the finding in the epic {epic}: {key.reason}")
return f"Filed {key} in the epic {epic}." + ("" if label else " It waits until a label names its repo.")
recorded = record.append_decision(value, text)
if isinstance(recorded, Failure):
return Failure(f"cannot record the decision in the epic {epic}'s description: {recorded.reason}")
return f"Recorded the decision in the epic {epic}'s description."
+34 -8
View File
@@ -3,12 +3,14 @@
`do-epic <EPIC-KEY>` starts each of the epic's chunks that may start now, each in a window of the epic's tmux session, as `scheduler` picks them, and puts that session on the terminal. Each window runs `do-epic --chunk <ISSUE-KEY> <EPIC-KEY>`: the cycles of one issue's chunk, run by the code that runs loop-claude's (`agent_cycle`), until the judge rules it finished. Then it starts the chunks that may start now, and its window closes."""
import dataclasses
import pathlib
import sys
import typing
from loop_claude.loop.chunk_start import archived_route, routed
from do_epic import chunk_prompt, scheduler
from do_epic import chunk_prompt, findings, scheduler
from do_epic.repo_pick import ClaudeWork, HumanTask, recorded, Repo
from loop_claude.loop.close import closed_cycle
from loop_claude.project.records import CONSEQUENCE, read_records
from agent_cycle.run import Cycle, run_cycle
from do_epic.config import DoEpicConfig, load
from loop_effects.effects import Effects, say
@@ -29,7 +31,6 @@ from loop_state.paths import Paths
from transcript_archive.project_key import project_key
from model_routing.ladder_file import project_ladder_file, read_ladder, SHIPPED
from loop_claude.project.premises import read_premises
from loop_claude.project.records import read_records
from claude_code.session import session_named
from loop_claude.loop.main import setup_version
from agent_cycle.stop import Stop
@@ -37,12 +38,14 @@ from agent_cycle.direct_message import tell
from agent_cycle import tmux
HELP = f"""usage: do-epic <EPIC-KEY>
{findings.USAGE}
Runs the chunks of one Jira epic, such as ABC-12, each in its own window of the tmux session epic-<EPIC-KEY>.
An open issue of the epic runs as a chunk once it has a label and no issue blocks it.
The label names the issue's repo, or says the work changes no repo.
As many run at once as the epic's description allows with a line such as `**Max parallel chunks:** 2`, one where it has none.
A repo takes as many chunks as its `parallel-chunks`, and none while loop-claude runs chunks in it.
{findings.HELP}
The Jira site and its credentials are set in ~/.claude-projects/do-epic/config.toml."""
# Under the home folder, where a chunk's cycles are archived, a folder per epic. It is not loop-claude's archive, since that archive's readers, such as judge-replay and the routing figures, read loop-claude's prompts.
ARCHIVE = ".claude/do-epic-transcripts"
@@ -73,9 +76,9 @@ class EpicRun:
return tmux.session_name(tmux.EPIC, self.key)
def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, effects: Effects, backend: Backend = jira_backend) -> int:
def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, effects: Effects, backend: Backend = jira_backend, stdin: typing.TextIO = sys.stdin) -> int:
try:
stop = run(argv, env, paths, launcher, effects, backend)
stop = run(argv, env, paths, launcher, effects, backend, stdin)
except KeyboardInterrupt:
stop = Stop(130, "")
except Exception as crash:
@@ -89,10 +92,14 @@ def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
return stop.code
def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, effects: Effects, backend: Backend) -> Stop:
def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, effects: Effects, backend: Backend, stdin: typing.TextIO) -> Stop:
chunk, words = (argv[1], argv[2:]) if len(argv) >= 2 and argv[0] == scheduler.CHUNK_FLAG else (None, argv)
if len(words) != 1 or not ISSUE_KEY.fullmatch(words[0]) or (chunk is not None and not ISSUE_KEY.fullmatch(chunk)):
# What the words after the epic's key write into the epic, where they are a filing or a decision.
writes = findings.parsed(words[1:]) if chunk is None else None
if (len(words) != 1 and not writes) or not ISSUE_KEY.fullmatch(words[0]) or (chunk is not None and not ISSUE_KEY.fullmatch(chunk)):
return Stop(0 if words in (["-h"], ["--help"]) else 1, HELP)
if writes:
return epic_written(words[0], writes, paths, backend, stdin)
# Before anything starts: a clone, a claude session or a tmux window.
if reason := tmux.unusable(effects.tmux, chunk_prompt.DRIVER):
return Stop(1, reason)
@@ -104,6 +111,15 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
return windows_opened(epic) if chunk is None else chunk_run(chunk, epic)
def epic_written(key: str, writes: tuple[str, str, str | None], paths: Paths, backend: Backend, stdin: typing.TextIO) -> Stop:
"""Files a finding in the epic, or records a decision in its description. It needs no tmux, so a chunk's worker may run it anywhere."""
config = load(paths.home)
if isinstance(config, Failure):
return Stop(1, config.reason)
done = findings.written(key, *writes, *backend(config, key), stdin)
return Stop(1, done.reason) if isinstance(done, Failure) else Stop(0, done)
def windows_opened(epic: EpicRun) -> Stop:
"""What the do-epic the human runs does: starts each chunk that may start now, says why each other open issue waits, then puts the epic's session on the terminal until the human detaches."""
started = chunks_started(epic, None)
@@ -239,8 +255,7 @@ def next_cycle(loop_run: LoopRun, loop: Loop, in_repo: bool, epic: EpicRun) -> C
premises = premises_read(loop.root if in_repo else None, epic)
if isinstance(premises, Failure):
return Stop(1, premises.reason)
# The epic's records join the repo's with todo.md item 413; until then a chunk without a repo has none.
records = read_records(loop.root, epic.paths.home, epic.paths.claude_dir) if in_repo else ""
records = records_read(loop.root if in_repo else None, epic)
if isinstance(records, Failure):
return Stop(1, records.reason)
models = get_or_ask_models(project_key(loop.root, epic.paths.home), epic.paths, epic.env, chunk_prompt.DRIVER, epic.effects) if in_repo else repoless_models(epic)
@@ -264,6 +279,17 @@ def repoless_models(epic: EpicRun) -> Models:
return Models(epic.env.get("LOOP_CLAUDE_JUDGE_MODEL") or epic.config.repoless_model, epic.env.get("LOOP_CLAUDE_WORKER_MODEL") or epic.config.repoless_model)
def records_read(root: str | None, epic: EpicRun) -> str | Failure:
"""The epic's Scoring and Decisions, from its description, then the records of the repo checked out at root, where the chunk has one, then the human's rules."""
sections: list[tuple[str, str]] = []
for name in ("Scoring", "Decisions"):
body = epic.record.section(name)
if isinstance(body, Failure):
return Failure(f"the epic {epic.key}'s description: {body.reason} - {CONSEQUENCE}.")
sections.append((f"the epic {epic.key}'s description, ## {name}", body))
return read_records(root, epic.paths.home, epic.paths.claude_dir, tuple(sections))
def premises_read(root: str | None, epic: EpicRun) -> str | Failure:
"""The epic's Goals and Audience, from its description, then those of the repo checked out at root, where the chunk has one. A Failure where the epic lacks either: no chunk runs without premises."""
bodies: list[str] = []
+111
View File
@@ -0,0 +1,111 @@
import contextlib
import dataclasses
import io
import pathlib
import sys
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic import main
from do_epic.backend.fake import MemoryEpic
from do_epic.epic_record import EpicRecord
from do_epic.test_main import DESCRIPTION, DoEpicTest
from failure import Failure
from loop_claude.test_loop_claude import FakeEffects
from loop_state.paths import paths_from
from record_store.held import Held
@dataclasses.dataclass(frozen=True)
class WrittenDescription:
"""Stands in for an epic's description in Jira that takes writes: kept holds each text it held, the last one now."""
kept: list[str]
approved: frozenset[str] = frozenset()
@property
def text(self) -> str:
return self.kept[-1]
def read(self) -> str | Failure:
return self.text
def held(self) -> Held | Failure:
return Held(self.text)
def write(self, text: str, version: str | None) -> Held | Failure:
self.kept.append(text)
return Held(text)
class FindingsTest(DoEpicTest):
def setUp(self) -> None:
super().setUp()
self.store = MemoryEpic("ABC-12", list(self.issues))
self.written = WrittenDescription([DESCRIPTION])
def backend(self, config: object, key: str) -> tuple[MemoryEpic, EpicRecord]:
return self.store, EpicRecord(self.written) # type: ignore[arg-type]
def run_with(self, argv: list[str], stdin: str = "") -> tuple[int, str, str, FakeEffects]:
out, err, fake = io.StringIO(), io.StringIO(), FakeEffects()
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
code = main.main(argv, {}, paths_from(self.home), pathlib.Path("/b/do-epic"), fake.effects(), self.backend, io.StringIO(stdin))
# Without the time each line of do-epic opens with.
return code, out.getvalue().replace("<1790000000> ", ""), err.getvalue().replace("<1790000000> ", ""), fake
class FilingAFinding(FindingsTest):
def test_files_an_issue_under_the_epic_with_the_detail_piped_in_and_starts_nothing(self) -> None:
code, out, err, fake = self.run_with(["ABC-12", "--file", "Retry the import on a 503"], "The client times out.\n")
self.assertEqual((code, out, err), (0, "Filed ABC-102 in the epic ABC-12. It waits until a label names its repo.\n", ""))
filed = self.store.issues[-1]
self.assertEqual((filed.key, filed.summary, filed.detail, filed.labels, filed.parent, filed.by_loop), ("ABC-102", "Retry the import on a 503", "The client times out.", (), "ABC-12", True))
self.assertEqual(fake.calls, [], "filing needs no tmux, clone or claude")
def test_a_label_names_the_issues_repo(self) -> None:
for argv in (["ABC-12", "--file", "Retry", "--label", "api"], ["ABC-12", "--file", "--label", "api", "Retry"]):
with self.subTest(argv=argv):
code, out, _, _ = self.run_with(argv)
filed = self.store.issues[-1]
self.assertEqual((code, out, filed.labels, filed.detail), (0, f"Filed {filed.key} in the epic ABC-12.\n", ("api",), ""))
def test_says_why_an_issue_was_not_filed(self) -> None:
code, out, err, _ = self.run_with(["ABC-12", "--file", "Retry", "--label", "a b"])
self.assertEqual((code, out, len(self.store.issues)), (1, "", 2))
self.assertEqual(err, "cannot file the finding in the epic ABC-12: the label 'a b' is empty or holds white space\n")
self.store.fails = "Jira answered 401"
code, _, err, _ = self.run_with(["ABC-12", "--file", "Retry"])
self.assertEqual((code, err), (1, "cannot file the finding in the epic ABC-12: Jira answered 401\n"))
def test_prints_the_help_for_a_filing_spelt_wrong(self) -> None:
for argv in (["ABC-12", "--file"], ["ABC-12", "--file", "a", "b"], ["ABC-12", "--file", "a", "--label"], ["ABC-12", "--file", "a", "--labels", "x"], ["--file", "ABC-12", "a"], ["ABC-12", "--file", "--label", "x"]):
with self.subTest(argv=argv):
code, out, err, _ = self.run_with(argv)
self.assertEqual((code, out, err, len(self.store.issues)), (1, "", main.HELP + "\n", 2))
class RecordingADecision(FindingsTest):
def test_appends_the_entry_to_the_descriptions_decisions(self) -> None:
code, out, err, fake = self.run_with(["ABC-12", "--record-decision", "Imports retry three times"], "2026-11-18, the human's answer. Valid while the client's API rate-limits.\n")
self.assertEqual((code, out, err, fake.calls), (0, "Recorded the decision in the epic ABC-12's description.\n", "", []))
self.assertEqual(self.written.text, DESCRIPTION + "\n## Decisions\n\n### Imports retry three times\n\n2026-11-18, the human's answer. Valid while the client's API rate-limits.\n")
self.assertEqual(self.run_with(["ABC-12", "--record-decision", "Merges squash"], "Always.")[0], 0)
self.assertTrue(self.written.text.endswith("rate-limits.\n\n### Merges squash\n\nAlways.\n"), self.written.text)
self.assertIn("## Goals\nShip the import.\n\n## Audience\nThe client's team.\n", self.written.text)
def test_refuses_a_decision_without_a_title_or_a_body(self) -> None:
for argv, stdin, reason in ((["ABC-12", "--record-decision", "Merges squash"], " \n", "pipe the decision's text in"), (["ABC-12", "--record-decision", "two\nlines"], "Always.", "the title must be one line of text"), (["ABC-12", "--record-decision", "Merges squash"], "## Goals\nNone.", "the body of ## Decisions holds a level 1 or 2 heading, which would start another section")):
with self.subTest(argv=argv, stdin=stdin):
code, out, err, _ = self.run_with(argv, stdin)
self.assertEqual((code, out, err, self.written.text), (1, "", f"cannot record the decision in the epic ABC-12's description: {reason}\n", DESCRIPTION))
def test_prints_the_help_for_a_decision_spelt_wrong(self) -> None:
for argv in (["ABC-12", "--record-decision"], ["ABC-12", "--record-decision", "a", "b"], ["ABC-12", "--decide", "a"]):
with self.subTest(argv=argv):
code, out, err, _ = self.run_with(argv, "Always.")
self.assertEqual((code, out, err, self.written.text), (1, "", main.HELP + "\n", DESCRIPTION))
if __name__ == "__main__":
import unittest
unittest.main()
+12 -3
View File
@@ -142,11 +142,17 @@ class ACycleOfAChunkWithoutARepo(DoEpicTest):
cycle = self.cycle()
self.assertEqual((cycle.root, cycle.project_archive, cycle.records), (str(self.home / ".local/state/do-epic/ABC-12"), self.home / ".claude/do-epic-transcripts/ABC-12", ""))
def test_the_records_are_the_epics_scoring_and_decisions_then_the_humans_rules(self) -> None:
self.description = DESCRIPTION + "\n## Scoring\nE + I, bar 4.\n\n## Decisions\n### Merges squash\nAlways.\n"
(self.home / ".claude").mkdir()
(self.home / ".claude/CLAUDE.md").write_text("# Global\n", encoding="utf-8")
self.assertEqual(self.cycle().records, "From the epic ABC-12's description, ## Scoring:\nE + I, bar 4.\n\nFrom the epic ABC-12's description, ## Decisions:\n### Merges squash\nAlways.\n\nFrom ~/.claude/CLAUDE.md:\n# Global")
def test_the_premises_are_the_epics_goals_and_audience(self) -> None:
self.assertEqual(self.cycle().premises, "the epic ABC-12's description:\n## Goals\nShip the import.\n\n## Audience\nThe client's team.")
def test_the_task_is_the_issue(self) -> None:
self.assertEqual(self.cycle().task, "Work the Jira issue ABC-21 of the epic ABC-12 as one chunk, which changes no repo: work in the folder you start in. Its summary: Do ABC-21\n\nIts description:\n\nTidy the docs.")
self.assertEqual(self.cycle().task, "Work the Jira issue ABC-21 of the epic ABC-12 as one chunk, which changes no repo: work in the folder you start in. File a finding about one of the epic's goals in the epic, with `do-epic ABC-12 --file \"<summary>\" [--label <label>]` and its detail on stdin. File one about a repo's goals by that repo's rules. Where unsure which, ask the human. Record a decision that governs the epic, such as an answer the human typed, with `do-epic ABC-12 --record-decision \"<title>\"` and its text on stdin. Its summary: Do ABC-21\n\nIts description:\n\nTidy the docs.")
def test_an_issue_without_scores_runs_on_the_projects_rung(self) -> None:
self.issues[1] = dataclasses.replace(self.issues[1], scores={})
@@ -299,16 +305,19 @@ class AChunksRun(DoEpicTest):
(checkout / "README.md").write_text("## Goals\nServe the API.\n\n## Audience\nIts callers.\n", encoding="utf-8")
(checkout / "AGENTS.md").write_text("Squash every merge.\n", encoding="utf-8")
self.issues = [dataclasses.replace(issue("ABC-20", "repo:api"), scores={"L": 2, "E": 1, "I": 1})]
self.description = DESCRIPTION + "\n## Decisions\nKeep the v1 endpoints.\n"
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD)
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
prompt = " ".join([what for seam, what in fake.calls if seam == "stream_claude"][0])
self.assertIn(f"Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout {checkout}, on the branch ABC-20.", prompt)
self.assertIn(f"Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout {checkout}, on the branch ABC-20. File a finding", prompt)
self.assertIn("Ship the import.", prompt)
self.assertIn("The repo's goals, which rank after the epic's and after code health, are from", prompt)
self.assertIn("Serve the API.", prompt)
self.assertIn("the chunk finished; started no other\n", out)
self.assertIn("Squash every merge.", [what[1] for seam, what in fake.calls if seam == "claude"][0])
judge_prompt = [what[1] for seam, what in fake.calls if seam == "claude"][0]
self.assertIn("The records: the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project:\nFrom the epic ABC-12's description, ## Decisions:\nKeep the v1 endpoints.\n\nFrom AGENTS.md:\nSquash every merge.", judge_prompt)
self.assertIn("writing it into the epic's description under ## Decisions, the repo's goals file's Goals or Audience, AGENTS.md, docs/decisions.md, the repo's plan or a comment", judge_prompt)
def repo_chunk(self) -> pathlib.Path:
"""Makes ABC-20 the one issue, a chunk in the repo api whose checkout holds its premises; the folder of the repo's config."""
+1 -1
View File
@@ -197,7 +197,7 @@ class StartingAnEpicsChunks(unittest.TestCase):
class TheFirstPrompt(unittest.TestCase):
def test_the_task_names_the_checkout_and_branch_and_quotes_a_description_only_where_there_is_one(self) -> None:
self.assertEqual(chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api"), "Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout /code/api, on the branch ABC-20. Its summary: Do ABC-20")
self.assertEqual(chunk_prompt.task(issue("ABC-20"), "ABC-12", "/code/api"), "Work the Jira issue ABC-20 of the epic ABC-12 as one chunk, in the checkout /code/api, on the branch ABC-20. File a finding about one of the epic's goals in the epic, with `do-epic ABC-12 --file \"<summary>\" [--label <label>]` and its detail on stdin. File one about a repo's goals by that repo's rules. Where unsure which, ask the human. Record a decision that governs the epic, such as an answer the human typed, with `do-epic ABC-12 --record-decision \"<title>\"` and its text on stdin. Its summary: Do ABC-20")
def test_opens_with_the_task_then_the_rung_then_the_premises(self) -> None:
rest = f"The issue sets the chunk's scope. The goals below choose between ways to deliver that scope, and never widen it. The epic's goals rank first, then code health ({chunk_prompt.CODE_HEALTH}), then the repo's.\n\nFrom P"
+2 -2
View File
@@ -71,7 +71,7 @@ from model_routing.ladder import Ladder, ProjectRung, REVIEW_STEPS, Rung
from claude_code.reply import Limited
from model_routing.ladder_file import read_ladder, SHIPPED
from loop_claude.project.premises import read_premises
from loop_claude.project.records import read_records
from loop_claude.project.records import read_records, RECORDS_NAMED
from claude_code.transcript import read_transcript
from agent_cycle.verdicts import Verdict
@@ -172,5 +172,5 @@ def rule(case: Case, rung: Rung, home: pathlib.Path, effects: Effects) -> Kind |
if isinstance(records, Failure):
return verdict_kind(records)
# 0 for the route's mark, as before any step-up: the replay compares verdict kinds, and a mark changes only which escalation quotes count.
verdict = first_reply(lambda: judge_once(case.root, Brief(task=case.task, premises=premises, records=records, answer_destinations=ANSWER_DESTINATIONS, entries=entries, escalated_at=0, driver=DRIVER), rung, effects))
verdict = first_reply(lambda: judge_once(case.root, Brief(task=case.task, premises=premises, records=records, records_named=RECORDS_NAMED, answer_destinations=ANSWER_DESTINATIONS, entries=entries, escalated_at=0, driver=DRIVER), rung, effects))
return verdict if isinstance(verdict, Limited) else verdict_kind(verdict)
+11 -4
View File
@@ -8,7 +8,7 @@ from model_routing.review_choice import chosen, ReviewChoice
from loop_claude.cycle.chunk_items import CHUNK_ITEMS
from model_routing.route import ESCALATION_MARKER, Route
from agent_cycle.routing import escalation_rungs
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES, RECORDS_NAMED
from review_rules.review_passes import INSTRUCTION_FILES, INSTRUCTION_FOLDERS
from text_files.markdown_text import listed, quoted
from model_routing.ladder import ProjectRung, Rung
@@ -186,9 +186,16 @@ def rungs_held(driver: str, route: Route, project: ProjectRung | None) -> str:
return "".join(f" {sentence}" for sentence in rung_sentences(driver, route, project))
def worker_prompts(driver: str, fresh: typing.Callable[[str, str, Route, ProjectRung | None, str], str], naming: str) -> WorkerPrompts:
"""The prompts of an entry point's cycles: its own fresh prompt, and the resumed prompt and rung sentences every entry point shares, each naming driver. resumed says what naming is."""
return WorkerPrompts(driver, fresh, functools.partial(resumed, driver, naming), functools.partial(rungs_held, driver), QUOTE_SOURCES, ANSWER_DESTINATIONS)
class RecordNames(typing.NamedTuple):
"""How an entry point names its project's records in a prompt; WorkerPrompts says what each field is."""
quote_sources: str = QUOTE_SOURCES
answer_destinations: str = ANSWER_DESTINATIONS
records_named: str = RECORDS_NAMED
def worker_prompts(driver: str, fresh: typing.Callable[[str, str, Route, ProjectRung | None, str], str], naming: str, names: RecordNames = RecordNames()) -> WorkerPrompts:
"""The prompts of an entry point's cycles: its own fresh prompt, and the resumed prompt and rung sentences every entry point shares, each naming driver. resumed says what naming is. names is loop-claude's unless the entry point keeps records elsewhere, as do-epic does."""
return WorkerPrompts(driver, fresh, functools.partial(resumed, driver, naming), functools.partial(rungs_held, driver), *names)
WORKER = worker_prompts(DRIVER, functools.partial(fresh, DRIVER), NAME_THE_ITEMS)
+16 -9
View File
@@ -13,28 +13,35 @@ RECORD_FILES = (WORKING_RULES[0], DECISIONS[0])
# then each .md file in the review standards folder the project's config sets.
HUMAN_RULES_FILE = "CLAUDE.md"
HUMAN_RULE_DIR = "rules"
# How the judge's prompt names the records above, in the order it reads them.
RECORDS_NAMED = "the project's working rules and decisions, then the human's rules for every project"
HUMAN_RULE_NAMES = (f"~/.claude/{HUMAN_RULES_FILE}", f"~/.claude/{HUMAN_RULE_DIR}/", "the project's review standards")
CONSEQUENCE = "the judge cannot read the records"
def read_records(root: str, home: pathlib.Path, claude_dir: pathlib.Path) -> str | Failure:
def read_records(root: str | None, home: pathlib.Path, claude_dir: pathlib.Path, first: tuple[tuple[str, str], ...] = ()) -> str | Failure:
"""The project's `AGENTS.md` and decision log, then the human's rules, CLAUDE.md first, each headed by its name; one that does not exist, or is empty, is left out.
`AGENTS.md` is read where the config under home of root's project puts it, and the decision log from the store that config names. Each is headed by its name in RECORD_FILES wherever it is kept."""
config = located(root, home)
if isinstance(config, Failure):
return Failure(f"{config.reason} - {CONSEQUENCE}.")
rules = [claude_dir / HUMAN_RULES_FILE, *sorted((claude_dir / HUMAN_RULE_DIR).glob("*.md")), *sorted(config.paths["standards"].glob("*.md"))]
decisions = store(config, DECISIONS[1]).read()
texts = [(WORKING_RULES[0], file_text(config.paths[WORKING_RULES[1]])), (DECISIONS[0], Failure(f"{decisions.reason} - {CONSEQUENCE}.") if isinstance(decisions, Failure) else decisions)]
`AGENTS.md` is read where the config under home of root's project puts it, and the decision log from the store that config names. Each is headed by its name in RECORD_FILES wherever it is kept.
first holds records kept outside the project, such as the sections of a Jira epic's description, each as its heading and text: they come before the project's. A root of None is work without a checkout, which has no project records and no review standards."""
texts: list[tuple[str, str | Failure]] = list(first)
rules = [claude_dir / HUMAN_RULES_FILE, *sorted((claude_dir / HUMAN_RULE_DIR).glob("*.md"))]
if root is not None:
config = located(root, home)
if isinstance(config, Failure):
return Failure(f"{config.reason} - {CONSEQUENCE}.")
rules += sorted(config.paths["standards"].glob("*.md"))
decisions = store(config, DECISIONS[1]).read()
texts += [(WORKING_RULES[0], file_text(config.paths[WORKING_RULES[1]])), (DECISIONS[0], Failure(f"{decisions.reason} - {CONSEQUENCE}.") if isinstance(decisions, Failure) else decisions)]
texts += [(named(rule, home, claude_dir), file_text(rule)) for rule in rules]
records = []
for heading, text in texts:
if isinstance(text, Failure):
return text
if text:
if text.strip():
records.append(f"From {heading}:\n{text.strip()}")
return "\n\n".join(records)
+25 -10
View File
@@ -1907,6 +1907,21 @@ class Records(unittest.TestCase):
config.unlink()
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent), Failure(f"no config names the checkout {root}: write ~/.claude-projects/<key>/config.toml, as `project-config --help` shows - the judge cannot read the records."))
def test_puts_the_records_handed_in_first_and_reads_only_the_humans_rules_without_a_checkout(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
configured(self, pathlib.Path(root), home=claude_md.parents[1])
claude_md.parent.mkdir(parents=True)
claude_md.write_text("# Global\n")
pathlib.Path(claude_md.parent, "rules").mkdir()
pathlib.Path(claude_md.parent, "rules", "todo-items.md").write_text("# Todo\n")
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards").mkdir(parents=True)
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
pathlib.Path(root, "AGENTS.md").write_text("# Rules\n")
first = (("the epic ABC-1's description, ## Decisions", "Squash.\n"), ("the epic ABC-1's description, ## Scoring", " \n"))
self.assertEqual(records.read_records(root, claude_md.parents[1], claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom AGENTS.md:\n# Rules\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments")
self.assertEqual(records.read_records(None, claude_md.parents[1], claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo")
def test_stops_on_a_record_it_cannot_read(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
@@ -1931,7 +1946,7 @@ class Records(unittest.TestCase):
class JudgePrompt(unittest.TestCase):
def test_shows_the_transcripts_tail_and_returns_what_it_showed(self):
entries = [assistant({"type": "text", "text": "old " + "x" * judge.JUDGE_PROMPT_CHARS}), assistant({"type": "text", "text": "new"})]
prompt, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 0, prompts.DRIVER))
prompt, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 0, prompts.DRIVER))
self.assertTrue(grounds.shown.endswith("\n\nnew"))
self.assertNotIn("old", grounds.shown)
self.assertIn(grounds.shown, prompt)
@@ -1940,11 +1955,11 @@ class JudgePrompt(unittest.TestCase):
self.assertEqual(grounds.quotable, "## Goals\n\n")
def test_the_judge_prompt_and_schema_call_the_worker_the_worker(self):
prompt, _ = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(assistant({"type": "text", "text": "done"})), 1, prompts.DRIVER))
prompt, _ = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(assistant({"type": "text", "text": "done"})), 1, prompts.DRIVER))
self.assertNotRegex(prompt + json.dumps(judge.judge_schema(prompts.DRIVER)), r"\b[Aa]gent")
def test_the_judge_prompt_names_the_entry_points_answer_destinations_in_both_rules_on_a_recorded_answer(self):
prompt, _ = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", "the ledger", kinds(assistant({"type": "text", "text": "done"})), 0, prompts.DRIVER))
prompt, _ = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, "the ledger", kinds(assistant({"type": "text", "text": "done"})), 0, prompts.DRIVER))
self.assertIn("is recorded in the ledger at the one place it governs", prompt)
self.assertIn("the worker writing it into the ledger, but not into one of the human's rules", prompt)
@@ -1957,24 +1972,24 @@ class JudgePrompt(unittest.TestCase):
def test_shows_the_judge_where_the_worker_last_stepped_up_and_checks_an_escalation_only_after_it(self):
entries = [assistant({"type": "text", "text": "round 2: 🔴"}), assistant({"type": "text", "text": "round 3: 🔴"})]
prompt, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER))
prompt, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER))
self.assertRegex(prompt, "round 2: 🔴\n\n\\[step\\] [^\n]+\n\nround 3: 🔴\n\n")
self.assertEqual(grounds.after_mark, "round 3: 🔴")
prompt, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 0, prompts.DRIVER))
prompt, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 0, prompts.DRIVER))
self.assertNotIn("stepped the worker up", prompt)
self.assertEqual(grounds.shown, "round 2: 🔴\n\nround 3: 🔴")
self.assertEqual(grounds.after_mark, "round 2: 🔴\n\nround 3: 🔴")
def test_drops_an_escalation_quote_from_after_the_step_up_that_the_tail_it_shows_cuts_off(self):
entries = [assistant({"type": "text", "text": "round 2: 🔴"}), assistant({"type": "text", "text": "old " + "x" * judge.JUDGE_PROMPT_CHARS}), assistant({"type": "text", "text": "new"})]
_, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER))
_, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER))
self.assertEqual(judge.quotes_checked(Unfinished("e", "old x", entries_read=3), grounds), Unfinished("e", entries_read=3))
self.assertEqual(judge.quotes_checked(Unfinished("e", "new", entries_read=3), grounds), Unfinished("e", "new", entries_read=3))
def test_shows_a_typed_answer_before_the_step_up_as_the_humans(self):
typed = prompts.WORKER.typed("Which one?", "Use B.", Route(Rung("worker-model")), None, False)
entries = [{**human(typed), "promptSource": "sdk"}, assistant({"type": "text", "text": "round 3: 🔴"})]
_, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER))
_, grounds = judge.judge_prompt(judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER))
self.assertIn("\n\n[human] Use B.\n\n[step] ", grounds.shown)
@@ -2201,7 +2216,7 @@ class Verdict(unittest.TestCase):
def test_drops_an_escalation_quote_found_only_in_the_transcript_entries_before_the_workers_last_step_up(self):
entries = [assistant({"type": "text", "text": "round 2: 🔴"}), assistant({"type": "text", "text": "round 3: 🔴"}), assistant({"type": "text", "text": "working"})]
def judged_on(mark, escalation):
return judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), mark, prompts.DRIVER), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", escalation=escalation)]).effects())
return judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), mark, prompts.DRIVER), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", escalation=escalation)]).effects())
self.assertEqual(judged_on(0, "round 2: 🔴"), Unfinished("working", "round 2: 🔴", entries_read=3))
self.assertEqual(judged_on(1, "round 2: 🔴"), Unfinished("working", entries_read=3))
self.assertEqual(judged_on(1, "round 3: 🔴"), Unfinished("working", "round 3: 🔴", entries_read=3))
@@ -2210,12 +2225,12 @@ class Verdict(unittest.TestCase):
def test_drops_an_escalation_quote_that_only_loop_claudes_prompts_or_the_humans_lines_repeat_after_the_step_up(self):
entries = [assistant({"type": "text", "text": "round 2: 🔴"}), {**human("as the work remaining: round 2: 🔴"), "promptSource": "sdk"}, human("round 2: 🔴 again"), assistant({"type": "text", "text": "working"})]
verdict = judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", escalation="round 2: 🔴")]).effects())
verdict = judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", escalation="round 2: 🔴")]).effects())
self.assertEqual(verdict, Unfinished("working", entries_read=4))
def test_takes_evidence_from_before_the_workers_last_step_up(self):
entries = [assistant({"type": "text", "text": "round 2: 🔴"}), assistant({"type": "text", "text": "working"})]
verdict = judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", evidence="round 2: 🔴")]).effects())
verdict = judge.judge_once("/r", judge.Brief("Do it.", "## Goals", "", records.RECORDS_NAMED, prompts.ANSWER_DESTINATIONS, kinds(*entries), 1, prompts.DRIVER), Rung("judge-model"), FakeEffects(claude=[judged("unfinished", evidence="round 2: 🔴")]).effects())
self.assertEqual(verdict, Unfinished("round 2: 🔴", entries_read=2))
+6
View File
@@ -0,0 +1,6 @@
import typing
def piped(stdin: typing.TextIO) -> str:
"""The text piped in, empty from a terminal. Claude Code's Bash tool gives a command /dev/null as stdin (readlink /proc/self/fd/0 shows it), so without a heredoc read() returns "" at once."""
return "" if stdin.isatty() else stdin.read()
+2 -5
View File
@@ -85,6 +85,8 @@ import pathlib
import sys
import typing
from text_files.piped_text import piped
from plan.todo_table import BLOCKED_BY, MOVES
from failure import Failure
from project_config.main import located
@@ -184,11 +186,6 @@ def fields(args: argparse.Namespace) -> dict[str, str]:
return {field: value for field, value in given.items() if value is not None}
def piped(stdin: typing.TextIO) -> str:
"""The text piped in, empty from a terminal. Claude Code's Bash tool gives a command /dev/null as stdin (readlink /proc/self/fd/0 shows it), so without a heredoc read() returns "" at once."""
return "" if stdin.isatty() else stdin.read()
def reported(written: Written | Failure, refusal: str, done: typing.Callable[[Written], str]) -> str | Failure:
"""What a write prints: done's line, after the backend's notes on stderr; else the Failure, opened with refusal."""
if isinstance(written, Failure):
+22
View File
@@ -2888,3 +2888,25 @@ Read most (opens and searches):
- `README.md` 1
- `bin/rule_hook/endless_wait.py` 1
- `bin/rule_hook/env_file.py` 1
## Reading cost, chunk c7c9393c2307, finished 2026-11-18T21:50:41Z
50171 new input tokens before the first commit.
Read most (opens and searches):
- `bin/chunk_preflight/test_chunk_preflight.py` 3
- `bin/chunk_preflight/main.py` 2
## Reading cost, chunk b5056eb2a505, finished 2026-11-18T22:01:58Z
98259 new input tokens before the first commit.
Read most (opens and searches):
- `rules/todo-items.md` 3
- `bin/loop_claude/loop/chunk_windows.py` 2
- `bin/loop_claude/loop/main.py` 2
- `docs/decisions.md` 2
- `bin/agent_cycle/tmux.py` 1
- `bin/loop-claude` 1
+1
View File
@@ -121,6 +121,7 @@ A fix meets every row it fits, except that a fix for a 🟡 meets only the 🟡
**Findings.** A reviewer rates each finding 🔴 must fix, 🟡 should fix, 🟢 nit, ❓ question, or 🔀 escalation naming the reviewer whose concern it is.
- **Outside the chunk.** A finding outside the chunk's change, whatever its pass or severity, is scored and filed in `todo.md` per `~/.claude/rules/todo-items.md`. A 🔴 is marked `defect`. A 🟡 against a file in the config's principles folder is marked `principle`, its detail naming the principle, where no other reason fits. One under the bar and not exempt is named in the summary with its score. A verified security HIGH is handled per "Security". In the release review the whole project is the chunk's change, so nothing lies outside it; "Release review" → "Findings" says which of its findings are filed.
- **Under do-epic.** In a chunk do-epic runs, a finding about one of the epic's goals is filed in the epic, with the command the chunk's prompt gives, in place of `todo.md`. One about a repo's goals is filed by that repo's rules, as above. Where unsure which, ask the human.
- **Goal or decision.** A fix that would change a goal, or a `docs/decisions.md` entry the repo held before the chunk began, is asked; no user reachable → filed, marked `question`, the goal or decision left as is.
- **New decision.** Each decision a fix or an answer records in `docs/decisions.md` is checked against the project principles per `~/.claude/rules/decisions.md` → "Decisions: one home, each linked to a goal or a technical principle", "Check each new decision against the project's principles", before the commit that records it.
- **🔴.** A 🔴 is fixed, or shown factually wrong, and what disproved it recorded per the review standards' `comments.md` → "Where a choice goes": in a comment at the code the finding concerns, or in `docs/decisions.md` when it concerns more than one place. Never declined.