Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2d72c97c6 | |||
| f1d749e0f5 | |||
| b1f89a9952 | |||
| 382ebde51e | |||
| 29e055584c | |||
| 9fc1392bc8 | |||
| c583900199 | |||
| 6e171fe2c0 | |||
| 4d40cc81bc | |||
| 08855e8055 | |||
| 43e7e96b41 | |||
| 9014fd0a2c | |||
| 3927dc280c | |||
| 3ef47907d0 | |||
| d3fd16d4ed | |||
| f7b448ccbf | |||
| cd7926b5ad | |||
| 18d0bb6b6d | |||
| 365b0f82a6 | |||
| 720ffd58b6 | |||
| 9240cd68ea | |||
| 4f831316d2 | |||
| 865f5b0306 | |||
| fe975488ec | |||
| 0254e427f2 | |||
| 47a40757c3 |
@@ -23,8 +23,8 @@ Decisions live in `docs/decisions.md`:
|
||||
- reading cost: a rise is the last 5 chunks' median above the 5 before them, and files or refreshes one plan item
|
||||
- reading cost: larv-review measures each finished chunk from loop-claude's archive and appends the figure to `docs/reading-cost.md` in the next chunk's PR
|
||||
- review: `/security-review` is the security pass of record, except where the full scan runs on the same change and replaces it
|
||||
- review: a fix for a 🔴 or 🟡 reruns the pass that found it and each pass whose row in `larv-review` §3's re-entry table the fix meets; from round 2 a pass reviews only the answers to its last round's findings and any other pass's fix that re-entered it; a fix for a 🟢, a ❓ or a prose finding reruns none
|
||||
- review: a pass gets at most three rounds per chunk; instead of a fourth, the run asks the human
|
||||
- review: a fix for a 🔴 or 🟡 reruns the pass that found it, unless that pass is at its cap, and each pass whose row in `larv-review` §3's re-entry table the fix meets; from round 2 a pass reviews only the answers to its last round's findings and any other pass's fix that re-entered it; a fix for a 🟢, a ❓ or a prose finding reruns none
|
||||
- review: a pass gets at most two rounds per chunk, with no third and no ask for one; the fixes answering round 2 merge once the gate passes
|
||||
- review: a pass skips only on a precedent: a decision, or a plan item crediting the pass, that the repo held before the chunk began
|
||||
- review: a project decision may opt every chunk out of the architect, the product-owner pass or the comprehension check, and a project opting out of the comprehension check voids code health
|
||||
- review: a project decision may suspend the comprehension check for the plan items it names
|
||||
@@ -70,4 +70,4 @@ The project values for `skills/comprehension-panel/seat-prompts.md`:
|
||||
- `{kind}`: a Claude Code configuration with an agent loop and review skills
|
||||
- `{domain}`: driving headless Claude Code sessions, agent review workflows
|
||||
- `{domain docs}`: the Claude Code documentation
|
||||
- `{3am question}`: a loop-claude run exits 1 overnight after the judge returned a verdict the loop rejected, or a larv-review run looped a reviewer a fourth time
|
||||
- `{3am question}`: a loop-claude run exits 1 overnight after the judge returned a verdict the loop rejected, or a larv-review run looped a reviewer a third time
|
||||
|
||||
+2
-1
@@ -2,6 +2,8 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- `loop-claude` now opens every message it prints with the machine's local time, as in `2026-10-28 11:46:01`, so you can see when each happened, such as how long a question has waited. A message of several lines, such as a question, carries the time on its first line only. The `retrying at …` time of a usage-limit wait now also shows seconds, and no longer names the zone.
|
||||
- larv-review now gives each review pass at most two rounds per chunk, where it gave three and then asked for more, and no longer asks: the fixes answering a pass's second round merge once the gate passes. rule-hook's new `round-cap` rule refuses a round commit that would take a pass past round 2, such as `Answer stability round 3: …`, and takes no override. It counts the pass's earlier round commits on the branch, so a third commit titled round 2 is refused too. `larv-review round-count` marks a pass at two rounds as at the cap.
|
||||
- rule-hook has a new rule, `repeat-read`, and now runs before each Read call too. It blocks a Read, or a Bash `cat`, `head` or `sed -n '<A>,<B>p'` of one file, when every line it asks for is already in the agent's context, and the block names those lines. The rule takes no override.
|
||||
- A line is in context when an earlier read's result in the agent's own transcript showed it since the last compaction, as the file holds it now. A subagent is judged on its own transcript, not its session's.
|
||||
- A read goes through when it asks for a line no earlier read showed, or one that changed since. A Bash output that Claude Code cut short shows no lines.
|
||||
@@ -19,7 +21,6 @@
|
||||
- Reviewers now mark a 🔴 or 🟡 `[misread]` where it arose because the implementer misread code that had already shipped. A round's commit title now counts the marked findings, as in `Answer stability round 1: 1 🔴, 2 🟡 (1 misread); …`, and rule-hook's `round-title-counts` blocks a round title without that count. `score-outcomes` shows the count on each finished item, and lists it after the medians for each chunk whose round titles carry it, newest first. A chunk whose round titles predate this change reads as unknown.
|
||||
- Sessions running at once no longer starve the machine. A new tool, `run-heavy <command>`, runs a heavy command, such as a full gate, mutation tests, an e2e run or a `docker build`, once it holds one of the machine's heavy slots: one per 4 CPUs, shared by every session. `CLAUDE.md` has every session run its heavy commands under it, and rule-hook blocks a `docker build` or a mutation run outside it. loop-claude now waits to start a worker while less than a quarter of the machine's memory is available.
|
||||
- larv-review's skill now says a commit answering the external auto-reviewer takes no `Answer <pass> round` title, and that `larv-review round-count` doesn't list the auto-reviewer. A worker who followed the skill used to get a "not a pass" warning.
|
||||
- rule-hook now blocks a larv-review round commit titled past round 3, such as `Answer stability round 4: …`, unless a `round-cap` override quotes the human's yes.
|
||||
- loop-claude's first prompt for a chunk that no plan item routed now also names the rung on which the worker launches its reviews for an item it takes in, as the prompt after a step-up or an unfinished verdict already did.
|
||||
- `loop-claude --help` now describes routing in two short paragraphs for the person running the loop. The rules it used to repeat are now stated once, in the code that enforces them.
|
||||
- loop-claude now archives the route on each `Worker:` line as a JSON record, such as `{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 4, "escape_and_impact": 5, "escalated_at": 12}`, and reads it back field by field. The line used to be a sentence, such as `claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5`, which loop-claude parsed back word for word: rewording the sentence in the code would have made every archived line unreadable, and a rerun would have routed the open chunk afresh. A rerun and the routing figures still read the sentences archived since loop-claude routed on L. A rerun that finds a `Worker:` line it can't read now says so on stderr. The judge's reply now names the levels the worker took in `highest_likelihood_taken_in` and `highest_escape_and_impact_taken_in`, in place of `bundled` and `bundled_escape_and_impact`.
|
||||
|
||||
@@ -75,7 +75,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i
|
||||
- Escalate a task that proves too hard for your rung. Four escalation triggers say so:
|
||||
1. A re-score of the item's L, made on the project's rung or above, picks a rung above yours.
|
||||
2. The same failing test or finding survives two fix attempts.
|
||||
3. A pass reports a 🔴 in round 2 or later.
|
||||
3. A pass reports a 🔴 in round 2.
|
||||
4. A review rules the work below standard: systems-architect's BLOCK, a finding against larv-review's `standards/quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` §3 → "Rung up").
|
||||
|
||||
When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread.
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from failure import Failure
|
||||
from file_writes import replace_json
|
||||
|
||||
|
||||
# A failure only warns: claude still opens, and the human answers Claude Code's trust dialog.
|
||||
def trust(config: pathlib.Path, roots: list[str]) -> None:
|
||||
def trust(config: pathlib.Path, roots: list[str], note: typing.Callable[[str], None]) -> None:
|
||||
try:
|
||||
with open(config, encoding="utf-8") as handle:
|
||||
data = json.load(handle)
|
||||
except (OSError, ValueError) as failure:
|
||||
print(f"could not read {config}: {getattr(failure, 'strerror', failure)}", file=sys.stderr)
|
||||
note(f"could not read {config}: {getattr(failure, 'strerror', failure)}")
|
||||
return
|
||||
marked = mark_trusted(data, roots)
|
||||
if isinstance(marked, Failure):
|
||||
print(f"could not read {config}: {marked.reason}", file=sys.stderr)
|
||||
note(f"could not read {config}: {marked.reason}")
|
||||
return
|
||||
updated, untrusted = marked
|
||||
if not untrusted:
|
||||
return
|
||||
if unwritten := replace_json(config, updated, indent=2):
|
||||
print(f"could not write {config}: {unwritten.reason}", file=sys.stderr)
|
||||
note(f"could not write {config}: {unwritten.reason}")
|
||||
return
|
||||
print("trusted for the interrupt: " + ", ".join(untrusted), file=sys.stderr)
|
||||
note("trusted for the interrupt: " + ", ".join(untrusted))
|
||||
|
||||
|
||||
# Claude Code's config: {"projects": {"/home/me/code/log": {"hasTrustDialogAccepted": true, ...}}, ...}
|
||||
|
||||
+6
-3
@@ -11,6 +11,7 @@ class Commit:
|
||||
directory: str
|
||||
messages: list[str]
|
||||
from_file: bool
|
||||
amends: bool
|
||||
|
||||
|
||||
def commits(simples: list[Simple], home: str) -> list[Commit]:
|
||||
@@ -36,14 +37,16 @@ def git_subcommand(words: list[str], directory: str, home: str) -> tuple[str, li
|
||||
return None
|
||||
|
||||
|
||||
def commit_message(args: list[str]) -> tuple[list[str], bool]:
|
||||
"""git commit's messages, and whether it reads one from a file."""
|
||||
def commit_message(args: list[str]) -> tuple[list[str], bool, bool]:
|
||||
"""git commit's messages, whether it reads one from a file, and whether it amends."""
|
||||
messages = []
|
||||
from_file = False
|
||||
amends = False
|
||||
words = iter(args)
|
||||
for word in words:
|
||||
if word == "--":
|
||||
break
|
||||
amends = amends or word == "--amend"
|
||||
name, equals, value = word.partition("=")
|
||||
if name in ("--message", "--file"):
|
||||
given = value if equals else next(words, "")
|
||||
@@ -55,4 +58,4 @@ def commit_message(args: list[str]) -> tuple[list[str], bool]:
|
||||
continue
|
||||
messages += [given] if name == "--message" else []
|
||||
from_file = from_file or name == "--file"
|
||||
return messages, from_file
|
||||
return messages, from_file, amends
|
||||
|
||||
+18
-6
@@ -60,20 +60,32 @@ def default_branch(stale_ok: bool, timeout: float | None = None) -> tuple[str, s
|
||||
return ref if isinstance(ref, Failure) else (ref, note)
|
||||
|
||||
|
||||
def default_ref(cwd: str | None = None, timeout: float | None = None) -> str | Failure:
|
||||
"""The default branch's ref as last fetched, read in cwd, else in the current directory: `origin/<branch>` with that remote, else the local main or master. Asking origin, where the checkout records no default branch for it, fails after timeout seconds."""
|
||||
remotes = git("remote", cwd=cwd)
|
||||
def default_ref(cwd: str | None = None, timeout: float | None = None, guarded: bool = False) -> str | Failure:
|
||||
"""The default branch's ref as last fetched, read in cwd, else in the current directory: `origin/<branch>` with that remote, else the local main or master.
|
||||
|
||||
Where the checkout records no default branch for origin, it asks origin, which fails after timeout seconds. Guarded, it runs git as `git` does with guarded, and fails there instead of asking origin."""
|
||||
remotes = git("remote", cwd=cwd, guarded=guarded)
|
||||
if isinstance(remotes, Failure):
|
||||
return remotes
|
||||
if "origin" in remotes.split():
|
||||
recorded = git("symbolic-ref", "--short", "refs/remotes/origin/HEAD", cwd=cwd)
|
||||
return recorded.strip() if not isinstance(recorded, Failure) else origin_head(cwd, timeout)
|
||||
recorded = git("symbolic-ref", "--short", "refs/remotes/origin/HEAD", cwd=cwd, guarded=guarded)
|
||||
if not isinstance(recorded, Failure):
|
||||
return recorded.strip()
|
||||
return Failure("origin records no default branch") if guarded else origin_head(cwd, timeout)
|
||||
for branch in ("main", "master"):
|
||||
if not isinstance(git("rev-parse", "--quiet", "--verify", f"refs/heads/{branch}", cwd=cwd), Failure):
|
||||
if not isinstance(git("rev-parse", "--quiet", "--verify", f"refs/heads/{branch}", cwd=cwd, guarded=guarded), Failure):
|
||||
return branch
|
||||
return Failure("no origin remote, and no main or master branch to take as the default branch")
|
||||
|
||||
|
||||
def branch_titles(default: str, cwd: str | None = None, timeout: float | None = None, guarded: bool = False) -> list[str] | Failure:
|
||||
"""The titles of the branch's own commits since default, newest first, read in cwd, else in the current directory.
|
||||
|
||||
--first-parent leaves out the commits a merge brought in, such as those of a default branch newer than the one the checkout last fetched."""
|
||||
titles = git("log", "--first-parent", "--format=%s", f"{default}..HEAD", cwd=cwd, timeout=timeout, guarded=guarded)
|
||||
return titles if isinstance(titles, Failure) else titles.splitlines()
|
||||
|
||||
|
||||
def origin_head(cwd: str | None, timeout: float | None) -> str | Failure:
|
||||
"""The default branch origin names, for a clone made by `git init` and `git remote add`, which records none."""
|
||||
listed = git("ls-remote", "--symref", "origin", "HEAD", cwd=cwd, timeout=timeout)
|
||||
|
||||
@@ -22,10 +22,11 @@ measured commit is the default branch's newest merged change that adds a paired
|
||||
run to the history; a merge commit counts as one change against its first parent. With none, it is
|
||||
the merge base of HEAD and the default branch.
|
||||
|
||||
round-count prints each pass's round count among the commits not yet on the default branch whose
|
||||
titles open `Answer <pass> round <n>:`, ignoring case. The count is the highest <n>, or the number of
|
||||
such commits when that is more. At or past the cap of {cap} rounds, it says to ask the human before
|
||||
another round. It also lists each name in such a title that is not a pass.
|
||||
round-count prints each pass's round count among the branch's commits since the default branch
|
||||
whose titles open `Answer <pass> round <n>:`, ignoring case. It follows first parents, as
|
||||
rule-hook's round-cap does. The count is the highest <n>, or the number of such commits when that
|
||||
is more. At or past the cap of {cap} rounds, it says the pass takes no more rounds. It also lists
|
||||
each name in such a title that is not a pass.
|
||||
|
||||
needs-scoring-run takes the IDs of the todo.md items the chunk ships, none when it ships none, and
|
||||
prints why the chunk is due a scoring run, or `No scoring run due.` It is due when the chunk ships
|
||||
@@ -101,8 +102,8 @@ import re
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from git_repo import branch_titles, default_branch, git, top
|
||||
from round_titles import CAP, round_counts
|
||||
from git_repo import default_branch, git, top
|
||||
from failure import Failure
|
||||
from comprehension_history import FLOOR
|
||||
from larv_review.history_changes import history_changes
|
||||
@@ -194,10 +195,10 @@ def show_ruling_base(default: str) -> Failure | None:
|
||||
|
||||
|
||||
def round_count(default: str) -> Failure | None:
|
||||
titles = git("log", "--format=%s", f"{default}..HEAD")
|
||||
titles = branch_titles(default)
|
||||
if isinstance(titles, Failure):
|
||||
return titles
|
||||
for name, count in round_counts(titles.splitlines()).items():
|
||||
for name, count in round_counts(titles).items():
|
||||
print(f"{name}: {count}{cap_note(count) if name in PASSES else ', not a pass: check the commit title'}")
|
||||
return None
|
||||
|
||||
@@ -205,7 +206,7 @@ def round_count(default: str) -> Failure | None:
|
||||
def cap_note(count: int) -> str:
|
||||
if count < CAP:
|
||||
return ""
|
||||
return f", {'at' if count == CAP else 'past'} the cap: ask the human before another round"
|
||||
return f", {'at' if count == CAP else 'past'} the cap: no more rounds"
|
||||
|
||||
|
||||
def needs_scoring_run(default: str, ids: list[int]) -> Failure | None:
|
||||
|
||||
@@ -388,14 +388,21 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.commit("Answer stability round 1: a")
|
||||
self.commit("Answer stability round 2: b")
|
||||
self.commit("Answer prose round 1: c")
|
||||
self.commit("Answer stability round 3: d")
|
||||
ran = self.run_tool("round-count")
|
||||
self.assertIn("stability: 3, at the cap: ask the human before another round\n", ran.stdout)
|
||||
self.commit("Answer stability round 4: e")
|
||||
self.assertIn("stability: 4, past the cap: ask the human before another round\n", self.run_tool("round-count").stdout)
|
||||
self.assertIn("stability: 2, at the cap: no more rounds\n", ran.stdout)
|
||||
self.commit("Answer stability round 3: d")
|
||||
self.assertIn("stability: 3, past the cap: no more rounds\n", self.run_tool("round-count").stdout)
|
||||
self.assertIn("prose: 1\n", ran.stdout)
|
||||
self.assertIn("architecture: 0\n", ran.stdout)
|
||||
|
||||
def test_leaves_out_the_round_commits_of_a_branch_merged_in_as_the_hook_does(self):
|
||||
self.git("switch", "-q", "-c", "sibling")
|
||||
self.commit("Answer stability round 1: a")
|
||||
self.commit("Answer stability round 2: b")
|
||||
self.git("switch", "-q", "chunk")
|
||||
self.git("merge", "-q", "--no-ff", "-m", "Merge sibling", "sibling")
|
||||
self.assertIn("stability: 0\n", self.run_tool("round-count").stdout)
|
||||
|
||||
def test_says_whether_a_scoring_run_is_due_and_refuses_an_unknown_item(self):
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "1").stdout, "Scoring run due: the chunk leaves release 0.1.0 with no plan item.\n")
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
||||
@@ -583,7 +590,7 @@ class LarvReviewTool(unittest.TestCase):
|
||||
def test_states_its_rules_and_finds_origins_default_branch_where_the_clone_recorded_none(self):
|
||||
helped = self.run_tool("--help")
|
||||
self.assertEqual(helped.returncode, 0, helped.stderr)
|
||||
self.assertIn("cap of 3 rounds", helped.stdout)
|
||||
self.assertIn("cap of 2 rounds", helped.stdout)
|
||||
self.git("remote", "set-head", "origin", "--delete")
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import dataclasses
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from claude_code.transcript import human_turns, read_transcript
|
||||
from loop_claude.stop import needs_human, needs_terminal, Stop
|
||||
@@ -24,7 +24,7 @@ class Talk:
|
||||
|
||||
def put_question(question: str, answer_here: bool, effects: Effects) -> str | Talk | Stop:
|
||||
"""Prints question for the human. Where answer_here, returns the line they type at loop-claude's terminal, stripped, or Talk where they type TALK; else Talk at once. A Stop where loop-claude is off a terminal, or they type nothing, or the input ends."""
|
||||
print(f"\n{question}", file=sys.stderr)
|
||||
say(f"\n{question}", effects)
|
||||
if stop := needs_terminal(ANSWER_QUESTION, effects.on_terminal()):
|
||||
return stop
|
||||
# Keys typed while the worker ran wait on the terminal, and would answer a question no one has read, here or in claude's session, which reads them too. Of a pasted answer, input takes the first line; the rest wait, and the next question drops them. A longer answer goes through TALK.
|
||||
@@ -34,7 +34,7 @@ def put_question(question: str, answer_here: bool, effects: Effects) -> str | Ta
|
||||
try:
|
||||
answer = effects.input(ASK_ANSWER).strip()
|
||||
except EOFError:
|
||||
print(file=sys.stderr)
|
||||
print(file=sys.stderr) # Ends the prompt's line. It isn't a message, so it gets no time.
|
||||
return needs_human(ANSWER_QUESTION, "the input ended")
|
||||
if not answer:
|
||||
return needs_human(ANSWER_QUESTION, "nothing was typed")
|
||||
@@ -57,7 +57,7 @@ def talk(root: str, session_id: uuid.UUID, worker: Rung, path: str, paths: Paths
|
||||
|
||||
def hand_over(rung: Rung, args: list[str], root: str, paths: Paths, env: dict[str, str], effects: Effects) -> Failure | None:
|
||||
"""Marks the checkout and each of its worktrees trusted, then runs claude on the terminal in root, on rung, with env added to its environment; the failure is why claude could not start."""
|
||||
trust(paths.claude_json, worktrees(root, effects))
|
||||
trust(paths.claude_json, worktrees(root, effects), lambda text: say(text, effects))
|
||||
try:
|
||||
effects.claude_on_terminal([*rung.flags(), "--permission-mode", "bypassPermissions", *args], root, env)
|
||||
except OSError as failure:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from claude_code.reply import Limited
|
||||
from loop_claude.stop import Stop
|
||||
@@ -24,7 +23,7 @@ def retried(who: str, attempt: typing.Callable[[], T | Failure | Limited], effec
|
||||
failures = 0
|
||||
now = effects.now()
|
||||
wait = limit_wait(result, now)
|
||||
print(f"the {who} hit a usage limit ({result.said}); retrying at {effects.local_time(now + wait)}", file=sys.stderr, flush=True)
|
||||
say(f"the {who} hit a usage limit ({result.said}); retrying at {effects.local_time(now + wait)}", effects)
|
||||
effects.sleep(wait)
|
||||
continue
|
||||
if not isinstance(result, Failure):
|
||||
@@ -34,7 +33,7 @@ def retried(who: str, attempt: typing.Callable[[], T | Failure | Limited], effec
|
||||
failures += 1
|
||||
if failures == FAILURES_RUNNING:
|
||||
return Stop(1, f"the {who} failed three times running: {result.reason}")
|
||||
print(f"retrying the {who} in a minute: {result.reason}", file=sys.stderr)
|
||||
say(f"retrying the {who} in a minute: {result.reason}", effects)
|
||||
effects.sleep(RETRY_DELAY)
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from loop_claude.routing import after_ruling, judge_rung
|
||||
from transcript_archive.write import archive
|
||||
from loop_claude.cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_WINDOW, run_worker, worker_args
|
||||
from claude_code.session import delete_session, Session, session_open, transcript_file
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from loop_claude.cycle.judge import judge, Rejected
|
||||
@@ -82,7 +82,7 @@ def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop:
|
||||
def archived_stop(project_archive: pathlib.Path, session: Session, task: str, route: Route, stop: Stop, why: str, effects: Effects) -> Stop:
|
||||
"""stop, once archived with the route the worker holds. A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once."""
|
||||
path = transcript_file(session)
|
||||
failure = archive(project_archive, path, task, outcomes.stopped(route.worker_line(), why), effects.now()) if path else None
|
||||
failure = archive(project_archive, path, task, outcomes.stopped(route.worker_line(), why), effects.now(), lambda text: say(text, effects)) if path else None
|
||||
return Stop(1, f"{failure.reason}\n{stop.reason}".rstrip()) if failure and failure.reason != stop.reason else stop
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ def step(cycle: Cycle, state: Active) -> Event | Stop:
|
||||
|
||||
def work(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, step_up: StepUp | None) -> WorkerRan | Stop:
|
||||
if isinstance(answered, QuotedAnswer):
|
||||
print(f"\n=== {prompts.QUOTE_SOURCES} answered: {answered.question} ===\n{answered.answer}", flush=True)
|
||||
say(f"\n=== {prompts.QUOTE_SOURCES} answered: {answered.question} ===\n{answered.answer}", cycle.effects, stdout=True)
|
||||
if stop := keep_answer(cycle, answered, step_up):
|
||||
return stop
|
||||
# worker_start runs inside the lambda: a failed attempt may have opened the session.
|
||||
@@ -155,7 +155,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
|
||||
|
||||
def keep_rejection(cycle: Cycle, transcript_path: str, rejected: Rejected) -> Stop | None:
|
||||
"""Archives a judge reply loop-claude rejected, so the archive shows what the judge returned before a retry or an exit 1."""
|
||||
if unkept := archive(cycle.project_archive, transcript_path, cycle.task, outcomes.rejected(rejected.reason, rejected.reply, str(judge_of(cycle))), cycle.effects.now()):
|
||||
if unkept := archive(cycle.project_archive, transcript_path, cycle.task, outcomes.rejected(rejected.reason, rejected.reply, str(judge_of(cycle))), cycle.effects.now(), lambda text: say(text, cycle.effects)):
|
||||
return Stop(1, unkept.reason)
|
||||
return None
|
||||
|
||||
@@ -183,7 +183,7 @@ def ran_on(cycle: Cycle, step_up: StepUp | None) -> Route:
|
||||
def archive_stepped(cycle: Cycle, transcript_path: str, outcome: str, step_up: StepUp | None) -> Failure | None:
|
||||
"""Archives the outcome of a ruling, then the step-up it made, if it made one. The first failure is returned."""
|
||||
for kept in (outcome, outcomes.stepped_up(step_up.after.worker_line())) if step_up else (outcome,):
|
||||
if failure := archive(cycle.project_archive, transcript_path, cycle.task, kept, cycle.effects.now()):
|
||||
if failure := archive(cycle.project_archive, transcript_path, cycle.task, kept, cycle.effects.now(), lambda text: say(text, cycle.effects)):
|
||||
return failure
|
||||
return None
|
||||
|
||||
@@ -196,7 +196,7 @@ def question_for(ruling: Interrupt | QuotedAnswer) -> str:
|
||||
|
||||
def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop:
|
||||
outcome = outcomes.finished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle))) if isinstance(verdict, Finished) else outcomes.unfinished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle)), verdict.escalation)
|
||||
if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcome, cycle.effects.now()):
|
||||
if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcome, cycle.effects.now(), lambda text: say(text, cycle.effects)):
|
||||
return Stop(1, failure.reason)
|
||||
if isinstance(verdict, Finished) and (failure := delete_session(cycle.session)):
|
||||
return Stop(1, failure.reason)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import sys
|
||||
|
||||
from claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from claude_code.reply import Limited
|
||||
from claude_code.transcript import part_line
|
||||
@@ -33,7 +31,7 @@ def run_worker(root: str, args: list[str], env: dict[str, str], effects: Effects
|
||||
resets.append(resets_at)
|
||||
for part in assistant_parts(event):
|
||||
if line := part_line(part, PRINTED_TOOL_INPUT):
|
||||
print(line, flush=True)
|
||||
say(line, effects, stdout=True)
|
||||
return worker_outcome(proc.wait(), result, resets)
|
||||
|
||||
|
||||
@@ -42,7 +40,7 @@ def wait_for_memory(effects: Effects) -> None:
|
||||
said = False
|
||||
while (memory := effects.memory()) is not None and not memory.has_room():
|
||||
if not said:
|
||||
print(f"waiting to start the worker until at least {ROOM_SHARE:.0%} of the machine's memory is available; {memory.available // 1024} MiB of {memory.total // 1024} MiB is available now", file=sys.stderr, flush=True)
|
||||
say(f"waiting to start the worker until at least {ROOM_SHARE:.0%} of the machine's memory is available; {memory.available // 1024} MiB of {memory.total // 1024} MiB is available now", effects)
|
||||
said = True
|
||||
effects.sleep(MEMORY_POLL)
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class Effects:
|
||||
execv: typing.Callable[[str, list[str]], None]
|
||||
git: Git
|
||||
input: typing.Callable[[str], str]
|
||||
# A date and time in the machine's zone, as `2026-10-28 11:46:01`. lilleman chose this spelling and local time over UTC on 2026-10-28, since the human reads these on their own clock.
|
||||
local_time: typing.Callable[[float], str]
|
||||
# The machine's memory; None where it cannot be read.
|
||||
memory: typing.Callable[[], Memory | None]
|
||||
@@ -68,7 +69,7 @@ def system_effects() -> Effects:
|
||||
execv=os.execv,
|
||||
git=git_repo.git,
|
||||
input=input,
|
||||
local_time=lambda seconds: time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(seconds)),
|
||||
local_time=lambda seconds: time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds)),
|
||||
memory=read_memory,
|
||||
now=time.time,
|
||||
on_terminal=lambda: sys.stdin.isatty() and sys.stdout.isatty(),
|
||||
@@ -87,3 +88,10 @@ def run_python(args: list[str], cwd: str, timeout: float) -> subprocess.Complete
|
||||
return subprocess.CompletedProcess(command, 1, "", f"could not start: {failure}")
|
||||
except subprocess.TimeoutExpired:
|
||||
return subprocess.CompletedProcess(command, 1, "", f"stopped after {timeout} s")
|
||||
|
||||
|
||||
def say(text: str, effects: Effects, *, stdout: bool = False) -> None:
|
||||
"""Prints text on stderr, or on stdout where stdout, opening the first line of words with the machine's local time. Blank lines before those words stay blank, and later lines get no time."""
|
||||
body = text.lstrip("\n")
|
||||
blanks = text[: len(text) - len(body)]
|
||||
print(f"{blanks}{effects.local_time(effects.now())} {body}", file=sys.stdout if stdout else sys.stderr, flush=True)
|
||||
|
||||
@@ -117,7 +117,6 @@ Rerunning resumes any open session.
|
||||
"""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.routing import after_unfinished, first_route, kept, routed_item
|
||||
@@ -129,7 +128,7 @@ from loop_claude.project.checkout import checkout_root
|
||||
from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG
|
||||
from chunk_pick import default_plan, DefaultPlan
|
||||
from git_repo import default_ref
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from loop_claude.verdicts import Finished, Unfinished
|
||||
from loop_claude.project.model_choice import get_or_ask_models
|
||||
@@ -158,7 +157,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
|
||||
except KeyboardInterrupt:
|
||||
stop = Stop(130, "")
|
||||
if stop.reason:
|
||||
print(stop.reason, file=sys.stderr if stop.code else sys.stdout)
|
||||
say(stop.reason, effects, stdout=not stop.code)
|
||||
return stop.code
|
||||
|
||||
|
||||
@@ -187,8 +186,8 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
# After the reads above, so a loop that stops on one makes no worktree.
|
||||
facts, item = chunk_start(session, launcher.with_name("chunk-preflight"), loop_run.root, effects)
|
||||
project = project_rung(models.worker)
|
||||
route = routed(loop_run.route, project, models.worker, lambda: archived_route(archive_folder, session), item)
|
||||
print(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", flush=True)
|
||||
route = routed(loop_run.route, project, models.worker, lambda: archived_route(archive_folder, session, effects), item)
|
||||
say(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", effects, stdout=True)
|
||||
concluded = run_cycle(Cycle(effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project=project, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence))
|
||||
if isinstance(concluded, Stop):
|
||||
return concluded
|
||||
@@ -248,27 +247,27 @@ def archive_step(archive_folder: pathlib.Path, session: Session, task: str, befo
|
||||
if after is None or after.worker_line() == before.worker_line():
|
||||
return None
|
||||
path = transcript_file(session)
|
||||
failure = archive(archive_folder, path, task, outcomes.stepped_up(after.worker_line()), effects.now()) if path else None
|
||||
failure = archive(archive_folder, path, task, outcomes.stepped_up(after.worker_line()), effects.now(), lambda text: say(text, effects)) if path else None
|
||||
return Stop(1, failure.reason) if failure else None
|
||||
|
||||
|
||||
def archived_route(archive_folder: pathlib.Path, session: Session) -> Route | None:
|
||||
def archived_route(archive_folder: pathlib.Path, session: Session, effects: Effects) -> Route | None:
|
||||
"""The route the latest verdict archived for the session's open chunk names; None for a chunk not yet judged."""
|
||||
transcript = transcript_file(session)
|
||||
worker = latest_worker(archive_folder, transcript) if transcript else None
|
||||
if isinstance(worker, Failure):
|
||||
print(f"routing the chunk afresh: {worker.reason}", file=sys.stderr)
|
||||
say(f"routing the chunk afresh: {worker.reason}", effects)
|
||||
return None
|
||||
route = route_from(worker) if worker else None
|
||||
if worker and route is None:
|
||||
print(f"routing the chunk afresh: the archive's latest Worker: line names no route loop-claude can read: {worker}", file=sys.stderr)
|
||||
say(f"routing the chunk afresh: the archive's latest Worker: line names no route loop-claude can read: {worker}", effects)
|
||||
return route
|
||||
|
||||
|
||||
def chunk_start(session: Session, preflight: pathlib.Path, root: str, effects: Effects) -> tuple[str, typing.Callable[[], Item | None]]:
|
||||
"""The facts for a fresh worker's prompt, empty where the session is open, and the reader of the item that routes the chunk. The reader reads the default branch as last fetched: for a fresh chunk, by the preflight that runs first; for an open session, which runs none, by whatever fetched last."""
|
||||
facts = "" if session_open(session) else chunk_facts(preflight, root, effects)
|
||||
return facts, lambda: plan_item(fetched_plan(root))
|
||||
return facts, lambda: plan_item(fetched_plan(root), effects)
|
||||
|
||||
|
||||
def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str:
|
||||
@@ -285,8 +284,9 @@ def fetched_plan(root: str) -> DefaultPlan | Failure:
|
||||
return ref if isinstance(ref, Failure) else default_plan(root, ref)
|
||||
|
||||
|
||||
def plan_item(plan: DefaultPlan | Failure) -> Item | None:
|
||||
def plan_item(plan: DefaultPlan | Failure, effects: Effects) -> Item | None:
|
||||
"""The item that routes a chunk, chunk_pick.chunk_item's pick from the default branch; None without one, so the chunk runs on the project's rung."""
|
||||
# It prints the reason itself, through effects, like the other loop-claude functions that print. todo.md item 51 moves them all to one injected effect, so changing this one alone would be undone.
|
||||
if isinstance(plan, Failure):
|
||||
item: Item | Failure | None = plan
|
||||
elif isinstance(plan.todo, Failure):
|
||||
@@ -294,7 +294,7 @@ def plan_item(plan: DefaultPlan | Failure) -> Item | None:
|
||||
else:
|
||||
item = routed_item(plan.todo, plan.cut)
|
||||
if isinstance(item, Failure):
|
||||
print(f"routing on the project's rung: {item.reason}", file=sys.stderr)
|
||||
say(f"routing on the project's rung: {item.reason}", effects)
|
||||
return None
|
||||
return item
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import sys
|
||||
import types
|
||||
import typing
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from model_routing.route import Route
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
@@ -84,7 +84,7 @@ def exec_if_edited(launcher: pathlib.Path, baseline: str, loop_run: LoopRun, eff
|
||||
return None
|
||||
trial = effects.python([str(launcher), "--help"], loop_run.root)
|
||||
if trial.returncode != 0:
|
||||
print(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", file=sys.stderr)
|
||||
say(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", effects)
|
||||
return None
|
||||
try:
|
||||
effects.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(loop_run))])
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
"""Every CYCLES_PER_CHECK cycles across all projects, measure the archive's routing figures, keep them at its root, and interrupt the human with each call for a routing change not raised before: docs/decisions.md → `routing:`."""
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from routing_figures import archive
|
||||
from routing_figures.measure import calls, due, render, totals
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from loop_claude.cycle.interrupt import hand_over
|
||||
from loop_claude.paths import Paths
|
||||
@@ -18,7 +17,7 @@ def check_routing(root: pathlib.Path, rung: Rung, paths: Paths, effects: Effects
|
||||
with archive.locked(root) as held:
|
||||
new = new_calls(root, paths, effects) if held else []
|
||||
if isinstance(new, Failure):
|
||||
print(f"routing figures: {new.reason}", file=sys.stderr)
|
||||
say(f"routing figures: {new.reason}", effects)
|
||||
return None
|
||||
return raise_calls(root, new, rung, paths, effects) if new else None
|
||||
|
||||
@@ -32,7 +31,7 @@ def new_calls(root: pathlib.Path, paths: Paths, effects: Effects) -> list[str] |
|
||||
kept = archive.raised(root)
|
||||
if isinstance(kept, Failure):
|
||||
return kept
|
||||
print(f"\n=== cycle {cycle} across loop-claude's archive: measuring the routing figures ===", flush=True)
|
||||
say(f"\n=== cycle {cycle} across loop-claude's archive: measuring the routing figures ===", effects, stdout=True)
|
||||
measured = archive.measure_archive(root, str(paths.home), kept.since)
|
||||
if isinstance(measured, Failure):
|
||||
return measured
|
||||
@@ -46,14 +45,14 @@ def new_calls(root: pathlib.Path, paths: Paths, effects: Effects) -> list[str] |
|
||||
def raise_calls(root: pathlib.Path, new: list[str], rung: Rung, paths: Paths, effects: Effects) -> Stop | None:
|
||||
"""Puts the calls to the human through a claude in this setup's checkout, where the routing decision lives. Off a terminal they are only said, and stay in the figures, raised at the next measurement on a terminal."""
|
||||
listed = "".join(f"- {call}\n" for call in new)
|
||||
print(f"\nloop-claude's routing figures call for a routing change:\n{listed}The figures: {root / archive.FIGURES}", file=sys.stderr)
|
||||
say(f"\nloop-claude's routing figures call for a routing change:\n{listed}The figures: {root / archive.FIGURES}", effects)
|
||||
if not effects.on_terminal():
|
||||
print("Not on a terminal: the calls are raised again at the next measurement.", file=sys.stderr)
|
||||
say("Not on a terminal: the calls are raised again at the next measurement.", effects)
|
||||
return None
|
||||
prompt = f"Put these calls for a routing change from loop-claude's figures to the human, and change nothing until they answer:\n{listed}The figures are in {root / archive.FIGURES}. The ladder, its steps and the delegation rule are docs/decisions.md → `routing:`, and a change to them is the human's. Record what they decide as ~/.claude/CLAUDE.md says; the next chunk of this repo files the plan item for these calls."
|
||||
if unstarted := hand_over(rung, [prompt], str(paths.claude_dir), paths, {}, effects):
|
||||
return Stop(1, f"could not start claude for the routing calls: {unstarted.reason}")
|
||||
# Raised once the human has seen them, answered or not: an unanswered call reaches the plan through AGENTS.md, so it is not asked twice.
|
||||
if unmarked := archive.mark_raised(root, new, utc(effects.now())):
|
||||
print(f"routing figures: {unmarked.reason}", file=sys.stderr)
|
||||
say(f"routing figures: {unmarked.reason}", effects)
|
||||
return None
|
||||
|
||||
@@ -5,7 +5,7 @@ import sys
|
||||
import typing
|
||||
|
||||
from claude_code.model_catalog import catalog_models
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.effects import Effects, say
|
||||
from failure import Failure
|
||||
from loop_claude.stop import needs_human, needs_terminal, Stop
|
||||
from loop_claude.paths import Paths
|
||||
@@ -44,7 +44,7 @@ def get_or_ask_model(project_key: str, paths: Paths, effects: Effects) -> str |
|
||||
return models
|
||||
if failure := replace_json(saved, {**models, project_key: chosen}, indent="\t", sort_keys=True):
|
||||
return Stop(1, f"could not save the model in {saved}: {failure.reason}")
|
||||
print(f"{project_key} runs on {chosen}", file=sys.stderr)
|
||||
say(f"{project_key} runs on {chosen}", effects)
|
||||
return chosen
|
||||
|
||||
|
||||
@@ -65,20 +65,17 @@ def ask_for_model(project_key: str, saved: pathlib.Path, folder: pathlib.Path, e
|
||||
if stop := needs_terminal(f"pick {project_key}'s model, or merge {{\"{project_key}\": \"<model>\"}} into {saved}", effects.on_terminal()):
|
||||
return stop
|
||||
offered = catalog_models(folder)
|
||||
print(f"\nThe model to run {project_key} on, saved in {saved}:", file=sys.stderr)
|
||||
for number, (model_id, label) in enumerate(offered, 1):
|
||||
print(f" {number}. {label} ({model_id})", file=sys.stderr)
|
||||
if not offered:
|
||||
print(f" no model catalog cached in {folder}", file=sys.stderr)
|
||||
choices = [f" {number}. {label} ({model_id})" for number, (model_id, label) in enumerate(offered, 1)] or [f" no model catalog cached in {folder}"]
|
||||
say("\n".join([f"\nThe model to run {project_key} on, saved in {saved}:", *choices]), effects)
|
||||
while True:
|
||||
try:
|
||||
answer = effects.input(f"{'A number, or any' if offered else 'A'} name claude --model takes: ")
|
||||
except EOFError:
|
||||
print(file=sys.stderr)
|
||||
print(file=sys.stderr) # Ends the prompt's line. It isn't a message, so it gets no time.
|
||||
return needs_human(f"pick {project_key}'s model", "the input ended")
|
||||
picked = model_picked(answer, offered)
|
||||
if isinstance(picked, Failure):
|
||||
print(picked.reason, file=sys.stderr)
|
||||
say(picked.reason, effects)
|
||||
elif picked:
|
||||
return picked
|
||||
|
||||
|
||||
@@ -157,8 +157,11 @@ class Run:
|
||||
code: int
|
||||
sleeps: list
|
||||
starts: list
|
||||
# stderr and stdout are without the local time that opens each message loop-claude prints; raw_stderr and raw_stdout keep it.
|
||||
stderr: str
|
||||
stdout: str
|
||||
raw_stderr: str
|
||||
raw_stdout: str
|
||||
|
||||
def roles(self):
|
||||
return [call["role"] for call in self.calls]
|
||||
@@ -228,8 +231,10 @@ class Checkout:
|
||||
code=code,
|
||||
sleeps=[event["sleep"] for event in started if "sleep" in event],
|
||||
starts=[event["argv"] for event in started if "argv" in event],
|
||||
stderr=stderr,
|
||||
stdout=stdout,
|
||||
stderr=unstamped(stderr),
|
||||
stdout=unstamped(stdout),
|
||||
raw_stderr=stderr,
|
||||
raw_stdout=stdout,
|
||||
)
|
||||
|
||||
def run_on_terminal(self, command, cwd, typed, stdout_on_terminal, before_typing, typed_early):
|
||||
@@ -295,6 +300,13 @@ class Checkout:
|
||||
return outcomes
|
||||
|
||||
|
||||
STAMP = r"\d{4}-\d\d-\d\d \d\d:\d\d:\d\d"
|
||||
|
||||
|
||||
def unstamped(text):
|
||||
return re.sub(rf"(?m)^{STAMP} ", "", text)
|
||||
|
||||
|
||||
def argument(call, flag):
|
||||
return call["argv"][call["argv"].index(flag) + 1] if flag in call["argv"] else None
|
||||
|
||||
@@ -311,7 +323,7 @@ class Premises(unittest.TestCase):
|
||||
outside.mkdir()
|
||||
run = checkout.run([], cwd=outside)
|
||||
self.assertEqual((run.code, run.calls), (1, []))
|
||||
self.assertIn("not a git repository", run.stderr)
|
||||
self.assertRegex(run.raw_stderr, rf"(?m)^{STAMP} .*not a git repository")
|
||||
readmes = {
|
||||
None: "README.md in {root}: No such file or directory - no premises.",
|
||||
b"# P\n## Goals\n1. g\xff\n## Audience\nme\n": "README.md in {root} is not UTF-8 on line 3 - no premises.",
|
||||
@@ -396,6 +408,7 @@ class Cycles(unittest.TestCase):
|
||||
self.assertNotIn("landed-it", run.calls[5]["stdin"])
|
||||
self.assertEqual([path.name for path in checkout.transcripts()[0].parent.iterdir()], [checkout.transcripts()[0].name])
|
||||
self.assertIn("=== cycle 3, worker on worker-model ===", run.stdout)
|
||||
self.assertEqual(len(re.findall(rf"(?m)^{STAMP} === cycle 3, worker on worker-model ===$", run.raw_stdout)), 1)
|
||||
copies = {verdict.removeprefix(f"Task: {TASK}\n\n"): copy for copy, verdict in checkout.archived().items()}
|
||||
self.assertEqual(sorted(copies), [f"<UTC> Stopped: Ctrl-C\n\nWorker: {OFF_LADDER}\n", f"<UTC> Verdict: finished\n\nEvidence:\n> landed-it\n\nJudge: judge-model\nWorker: {OFF_LADDER}\n", f"<UTC> Verdict: unfinished\n\nEvidence:\n> started\n\nJudge: judge-model\nWorker: {OFF_LADDER}\n"])
|
||||
self.assertIn('"text": "landed-it"', copies[f"<UTC> Verdict: finished\n\nEvidence:\n> landed-it\n\nJudge: judge-model\nWorker: {OFF_LADDER}\n"])
|
||||
@@ -584,7 +597,7 @@ class Cycles(unittest.TestCase):
|
||||
self.assertEqual(run.code, 130)
|
||||
self.assertEqual(run.roles(), ["worker"] * 5 + ["judge"] * 2 + ["worker"])
|
||||
self.assertEqual([round(seconds, -1) for seconds in run.sleeps], [60, 60, 3720, 60, 600])
|
||||
self.assertIn(f"the worker hit a usage limit (You've hit your session limit); retrying at {datetime.datetime.fromtimestamp(resets_at + 120, datetime.timezone.utc):%Y-%m-%d %H:%M} UTC\n", run.stderr)
|
||||
self.assertIn(f"the worker hit a usage limit (You've hit your session limit); retrying at {datetime.datetime.fromtimestamp(resets_at + 120, datetime.timezone.utc):%Y-%m-%d %H:%M:%S}\n", run.stderr)
|
||||
self.assertIn("the judge hit a usage limit (You've hit your session limit); retrying at ", run.stderr)
|
||||
|
||||
def test_retries_the_judge_alone_when_its_verdict_quotes_nothing_in_the_transcript(self):
|
||||
@@ -691,6 +704,7 @@ class Interrupt(unittest.TestCase):
|
||||
self.assertEqual(verdict, f"Task: {TASK}\n\n<UTC> Verdict: interrupt\n\nA or B?\n\nEvidence:\n> Shall I use A or B?\n\nJudge: judge-model\nWorker: {OFF_LADDER}\n\n<UTC> Stopped: the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal\n\nWorker: {OFF_LADDER}\n")
|
||||
self.assertEqual(stat.S_IMODE((checkout.temp / "deep").stat().st_mode), 0o700)
|
||||
self.assertIn(f"transcript: {checkout.archive() / 'proj'}/", run.stderr)
|
||||
self.assertRegex(run.raw_stderr, rf"(?m)^{STAMP} transcript: ")
|
||||
session = argument(run.calls[0], "--session-id")
|
||||
run = checkout.run(steps, terminal_input="", stdout_on_terminal=False)
|
||||
self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"]))
|
||||
|
||||
@@ -10,6 +10,7 @@ import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
import unittest.mock
|
||||
import uuid
|
||||
@@ -19,7 +20,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
from routing_figures import archive, measure
|
||||
from loop_claude.project import checkout, model_choice, records
|
||||
from chunk_pick import DefaultPlan, LastCut
|
||||
from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python
|
||||
from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python, say, system_effects
|
||||
from claude_code import entries, reply, session
|
||||
from loop_claude import escalation_mark, paths, routing
|
||||
from failure import Failure
|
||||
@@ -46,6 +47,8 @@ OPUS_179_AT_6 = '{"model": "claude-opus-5-5", "effort": "medium", "item": 179, "
|
||||
|
||||
CWD = pathlib.Path("/c")
|
||||
NOW = 1790000000
|
||||
# How a line said at NOW opens, with FakeEffects' local_time.
|
||||
STAMP = f"<{NOW}>"
|
||||
|
||||
|
||||
def assistant(*parts):
|
||||
@@ -437,7 +440,7 @@ class Cycles(unittest.TestCase):
|
||||
fake = FakeEffects(streams=[worker, worker], claude=[judged("interrupt"), judged("unfinished")], inputs=["Use B."])
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).verdict, Unfinished("working", entries_read=6))
|
||||
self.assertIn("\nWhich one?\n", said.getvalue())
|
||||
self.assertIn(f"\n{STAMP} Which one?\n", said.getvalue())
|
||||
self.assertEqual(fake.made("claude_on_terminal"), [])
|
||||
resumed = fake.made("stream_claude")[1]
|
||||
self.assertEqual(resumed[resumed.index("--resume") + 1], str(self.session.id))
|
||||
@@ -504,7 +507,7 @@ class Cycles(unittest.TestCase):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse B. Use A.")), Stop(2, "the human is needed to answer the question above, but nothing was typed"))
|
||||
self.assertEqual(len(fake.made("stream_claude")), 1)
|
||||
self.assertIn("\nWhich one?\n", said.getvalue())
|
||||
self.assertIn(f"\n{STAMP} Which one?\n", said.getvalue())
|
||||
self.assertNotIn("Use ... A.", said.getvalue())
|
||||
|
||||
@unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory")
|
||||
@@ -554,7 +557,40 @@ class Retried(unittest.TestCase):
|
||||
results = [Limited(NOW + 3600, "You've hit your session limit"), "done"]
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
retry.retried("judge", lambda: results.pop(0), FakeEffects().effects())
|
||||
self.assertEqual(said.getvalue(), f"the judge hit a usage limit (You've hit your session limit); retrying at <{NOW + 3720}>\n")
|
||||
self.assertEqual(said.getvalue(), f"{STAMP} the judge hit a usage limit (You've hit your session limit); retrying at <{NOW + 3720}>\n")
|
||||
|
||||
|
||||
class Said(unittest.TestCase):
|
||||
def test_opens_a_line_with_the_local_time_of_the_effects_clock(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr, contextlib.redirect_stdout(io.StringIO()) as stdout:
|
||||
say("hello", FakeEffects().effects())
|
||||
self.assertEqual((stderr.getvalue(), stdout.getvalue()), (f"{STAMP} hello\n", ""))
|
||||
|
||||
def test_stamps_only_the_first_line_of_a_question_after_its_blank_line(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
say("\nWhich one?\n\nA or B?", FakeEffects().effects())
|
||||
self.assertEqual(stderr.getvalue(), f"\n{STAMP} Which one?\n\nA or B?\n")
|
||||
|
||||
def test_says_on_stdout_where_asked(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr, contextlib.redirect_stdout(io.StringIO()) as stdout:
|
||||
say("\n=== cycle 2 ===", FakeEffects().effects(), stdout=True)
|
||||
self.assertEqual((stderr.getvalue(), stdout.getvalue()), ("", f"\n{STAMP} === cycle 2 ===\n"))
|
||||
|
||||
def test_keeps_the_indent_of_the_first_line_after_the_time(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
say("\n indented", FakeEffects().effects())
|
||||
self.assertEqual(stderr.getvalue(), f"\n{STAMP} indented\n")
|
||||
|
||||
def test_flushes_so_piped_lines_arrive_when_said(self):
|
||||
flushes = []
|
||||
|
||||
class Counting(io.StringIO):
|
||||
def flush(self):
|
||||
flushes.append(self.getvalue())
|
||||
|
||||
with contextlib.redirect_stderr(Counting()):
|
||||
say("hello", FakeEffects().effects())
|
||||
self.assertEqual(flushes, [f"{STAMP} hello\n"])
|
||||
|
||||
|
||||
class Limits(unittest.TestCase):
|
||||
@@ -607,12 +643,12 @@ class Interrupts(unittest.TestCase):
|
||||
|
||||
def test_stops_off_a_terminal_before_asking(self):
|
||||
fake = FakeEffects(on_terminal=False)
|
||||
self.assertEqual(self.put(fake), (Stop(2, "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal"), "\nWhich one?\n"))
|
||||
self.assertEqual(self.put(fake), (Stop(2, "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal"), f"\n{STAMP} Which one?\n"))
|
||||
self.assertEqual(fake.calls, [])
|
||||
|
||||
def test_returns_the_line_typed_after_the_question_stripped_dropping_what_was_typed_before(self):
|
||||
fake = FakeEffects(inputs=[" Use B. "])
|
||||
self.assertEqual(self.put(fake), ("Use B.", "\nWhich one?\n"))
|
||||
self.assertEqual(self.put(fake), ("Use B.", f"\n{STAMP} Which one?\n"))
|
||||
self.assertEqual(fake.calls, [("discard_typed", None), ("input", "Answer (/talk opens claude, Enter stops the loop): ")])
|
||||
|
||||
def test_talks_on_talk_or_at_once_where_the_answer_is_not_asked_for_here(self):
|
||||
@@ -626,7 +662,7 @@ class Interrupts(unittest.TestCase):
|
||||
def test_stops_on_an_empty_answer_or_the_inputs_end(self):
|
||||
for typed, why, said in ((" ", "nothing was typed", ""), (EOFError(), "the input ended", "\n")):
|
||||
with self.subTest(why=why):
|
||||
self.assertEqual(self.put(FakeEffects(inputs=[typed])), (Stop(2, f"the human is needed to answer the question above, but {why}"), f"\nWhich one?\n{said}"))
|
||||
self.assertEqual(self.put(FakeEffects(inputs=[typed])), (Stop(2, f"the human is needed to answer the question above, but {why}"), f"\n{STAMP} Which one?\n{said}"))
|
||||
|
||||
def test_stops_when_nothing_was_typed_in_the_session(self):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
@@ -956,15 +992,15 @@ class Routing(unittest.TestCase):
|
||||
|
||||
class RouteSources(unittest.TestCase):
|
||||
def test_routes_on_the_plan_item_and_says_why_it_routes_on_the_projects_rung(self):
|
||||
self.assertIsNone(main.plan_item(DefaultPlan("", NO_CUT)))
|
||||
self.assertEqual(main.plan_item(DefaultPlan(TODO, LastCut("v0.1.0", "", 3, [TODO]))).id, 3)
|
||||
self.assertIsNone(main.plan_item(DefaultPlan(TODO, LastCut("v0.2.0", "", 3, [TODO]))))
|
||||
self.assertIsNone(main.plan_item(DefaultPlan("", NO_CUT), FakeEffects().effects()))
|
||||
self.assertEqual(main.plan_item(DefaultPlan(TODO, LastCut("v0.1.0", "", 3, [TODO])), FakeEffects().effects()).id, 3)
|
||||
self.assertIsNone(main.plan_item(DefaultPlan(TODO, LastCut("v0.2.0", "", 3, [TODO])), FakeEffects().effects()))
|
||||
unreadable = Failure("git show origin/main:todo.md printed text that is not UTF-8")
|
||||
for plan, said in ((DefaultPlan(TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |"), NO_CUT), "routing on the project's rung: item 3's L 'x' is not a whole number from 1 to 4\n"), (DefaultPlan(unreadable, NO_CUT), f"routing on the project's rung: {unreadable.reason}\n"), (Failure("no origin remote"), "routing on the project's rung: no origin remote\n")):
|
||||
with self.subTest(said=said):
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
self.assertIsNone(main.plan_item(plan))
|
||||
self.assertTrue(stderr.getvalue().startswith(said), stderr.getvalue())
|
||||
self.assertIsNone(main.plan_item(plan, FakeEffects().effects()))
|
||||
self.assertTrue(stderr.getvalue().startswith(f"{STAMP} {said}"), stderr.getvalue())
|
||||
|
||||
def test_resumes_on_the_archived_route_and_says_why_it_routes_afresh(self):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
@@ -973,28 +1009,28 @@ class RouteSources(unittest.TestCase):
|
||||
transcript = pathlib.Path(home, "projects", "-fake", f"{opened.id}.jsonl")
|
||||
route = Route(Rung("claude-opus-5-5", "high"), 3, 4, 5)
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
self.assertIsNone(main.archived_route(archive, opened))
|
||||
self.assertIsNone(main.archived_route(archive, opened, FakeEffects().effects()))
|
||||
transcript.parent.mkdir(parents=True)
|
||||
transcript.write_text(json.dumps({"type": "queue-operation", "timestamp": "1"}) + "\n")
|
||||
self.assertIsNone(main.archived_route(archive, opened))
|
||||
self.assertIsNone(main.archived_route(archive, opened, FakeEffects().effects()))
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(route.worker_line(), "working", "j", ""), NOW))
|
||||
with contextlib.redirect_stderr(stderr):
|
||||
self.assertEqual(main.archived_route(archive, opened), route)
|
||||
self.assertEqual(main.archived_route(archive, opened, FakeEffects().effects()), route)
|
||||
self.assertEqual(stderr.getvalue(), "")
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.stepped_up(WorkerLine('{"model": "claude-opus-5-5", "rung": 3}')), NOW + 1))
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
self.assertIsNone(main.archived_route(archive, opened))
|
||||
self.assertEqual(stderr.getvalue(), 'routing the chunk afresh: the archive\'s latest Worker: line names no route loop-claude can read: {"model": "claude-opus-5-5", "rung": 3}\n')
|
||||
self.assertIsNone(main.archived_route(archive, opened, FakeEffects().effects()))
|
||||
self.assertEqual(stderr.getvalue(), f'{STAMP} routing the chunk afresh: the archive\'s latest Worker: line names no route loop-claude can read: {{"model": "claude-opus-5-5", "rung": 3}}\n')
|
||||
(chunk,) = archive.iterdir()
|
||||
chunk.chmod(0)
|
||||
try:
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
self.assertIsNone(main.archived_route(archive, opened))
|
||||
self.assertIsNone(main.archived_route(archive, opened, FakeEffects().effects()))
|
||||
finally:
|
||||
chunk.chmod(0o700)
|
||||
self.assertTrue(stderr.getvalue().startswith("routing the chunk afresh: could not read the archive"), stderr.getvalue())
|
||||
self.assertTrue(stderr.getvalue().startswith(f"{STAMP} routing the chunk afresh: could not read the archive"), stderr.getvalue())
|
||||
|
||||
|
||||
class Steps(unittest.TestCase):
|
||||
@@ -1033,11 +1069,11 @@ class Steps(unittest.TestCase):
|
||||
self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(before.worker_line(), "working", "j", ""), NOW))
|
||||
after = main.after_verdict(main.LoopRun(cycle_number=1, root="/r", task="Do it.", unfinished_evidence=""), self.OPUS, run.Concluded(Unfinished("working", 4), before))
|
||||
self.assertIsNone(main.archive_step(archive, opened, "Do it.", before, after.route, FakeEffects().effects()))
|
||||
self.assertEqual(main.archived_route(archive, opened), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4))
|
||||
self.assertEqual(main.archived_route(archive, opened, FakeEffects().effects()), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4))
|
||||
self.assertIsNone(main.archive_step(archive, opened, "Do it.", after.route, after.route, FakeEffects().effects()))
|
||||
finished = main.after_verdict(after, self.OPUS, run.Concluded(Finished("done"), after.route))
|
||||
self.assertIsNone(main.archive_step(archive, opened, "Do it.", after.route, finished.route, FakeEffects().effects()))
|
||||
self.assertEqual(main.archived_route(archive, opened), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4))
|
||||
self.assertEqual(main.archived_route(archive, opened, FakeEffects().effects()), Route(Rung("claude-opus-5-5", "high"), 3, 3, 4))
|
||||
blocked = pathlib.Path(home, "blocked")
|
||||
blocked.write_text("")
|
||||
stop = main.archive_step(blocked, opened, "Do it.", before, after.route, FakeEffects().effects())
|
||||
@@ -1055,7 +1091,7 @@ class Steps(unittest.TestCase):
|
||||
self.assertIsNone(write.archive(archive, str(transcript), "Do it.", outcomes.unfinished(before.worker_line(), "working", "j", ""), NOW))
|
||||
after = main.after_verdict(main.LoopRun(cycle_number=1, root="/r", task="Do it.", unfinished_evidence=""), self.OPUS, run.Concluded(Unfinished("working", highest_escape_and_impact_taken_in=6), before))
|
||||
self.assertIsNone(main.archive_step(archive, opened, "Do it.", before, after.route, FakeEffects().effects()))
|
||||
self.assertEqual(main.archived_route(archive, opened), Route(self.OPUS, 3, 3, 4, escape_and_impact_taken_in=6))
|
||||
self.assertEqual(main.archived_route(archive, opened, FakeEffects().effects()), Route(self.OPUS, 3, 3, 4, escape_and_impact_taken_in=6))
|
||||
|
||||
|
||||
class ChunkFacts(unittest.TestCase):
|
||||
@@ -1089,6 +1125,17 @@ class ChunkFacts(unittest.TestCase):
|
||||
self.assertEqual((resumed.made("python"), facts), ([], ""))
|
||||
|
||||
|
||||
class LocalTime(unittest.TestCase):
|
||||
def test_renders_seconds_in_the_machines_zone(self):
|
||||
# A POSIX zone two hours ahead of UTC, so a time in UTC would read 14:13:20. Cleanups run last in, first out: the zone is restored before time.tzset makes the clock read it again.
|
||||
self.addCleanup(time.tzset)
|
||||
zone = unittest.mock.patch.dict(os.environ, {"TZ": "XXX-2"})
|
||||
zone.start()
|
||||
self.addCleanup(zone.stop)
|
||||
time.tzset()
|
||||
self.assertEqual(system_effects().local_time(NOW), "2026-09-21 16:13:20")
|
||||
|
||||
|
||||
class PythonEffect(unittest.TestCase):
|
||||
def test_runs_a_script_in_the_given_directory(self):
|
||||
with tempfile.TemporaryDirectory() as cwd:
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count, and the findings the rounds reported. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`."""
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count against its cap, and the findings the rounds reported. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`."""
|
||||
import dataclasses
|
||||
import re
|
||||
|
||||
from review_passes import PASSES
|
||||
|
||||
# The most rounds a pass takes before the run asks the human, per `docs/decisions.md` → `review: a pass gets at most three rounds per chunk; …`. rule-hook's `round-cap` refuses a round title past it, and `larv-review round-count` marks a pass at or past it.
|
||||
CAP = 3
|
||||
# The most rounds a pass takes per chunk, per `docs/decisions.md` → `review: a pass gets at most two rounds per chunk, …`. rule-hook's `round-cap` refuses a round commit that `past_cap` finds takes its pass past it, and `larv-review round-count` marks a pass that reached it.
|
||||
CAP = 2
|
||||
ROUND = re.compile(r"^Answer (.+?) round ([0-9]+):", re.IGNORECASE)
|
||||
# What follows a round title's colon: the round's 🔴 and 🟡 counts, then how many of them a reviewer marked `[misread]`, a count that titles from before it lack, then `;` and its summary, if any.
|
||||
FINDINGS = re.compile(r" ([0-9]+) 🔴, ([0-9]+) 🟡(?: \(([0-9]+) misread\))?(?:;|$)")
|
||||
@@ -36,10 +36,10 @@ def lacks_counts(title: str) -> bool:
|
||||
return ROUND.match(title) is not None and ((counts := title_counts(title)) is None or counts.misread is None)
|
||||
|
||||
|
||||
def past_cap(title: str) -> bool:
|
||||
"""Whether title is a round title numbered past CAP."""
|
||||
def past_cap(title: str, earlier: list[str]) -> bool:
|
||||
"""Whether title is a round title that takes its pass past CAP, as round_counts counts title among the branch's earlier commit titles."""
|
||||
named = ROUND.match(title)
|
||||
return named is not None and int(named.group(2)) > CAP
|
||||
return named is not None and round_counts([*earlier, title])[named.group(1).lower()] > CAP
|
||||
|
||||
|
||||
def title_counts(title: str) -> Findings | None:
|
||||
|
||||
@@ -48,6 +48,7 @@ from failure import Failure
|
||||
from rule_hook.override_log import Log, log_path, logged, print_overrides, write_override
|
||||
from rule_hook.reviewer_report import report_breaches
|
||||
from rule_hook.reviewer_rung import reviewer_breaches
|
||||
from rule_hook.round_cap import round_cap_breaches
|
||||
from shell_command import simple_commands
|
||||
from rule_hook.todo_check import todo_breaches
|
||||
|
||||
@@ -111,7 +112,7 @@ def answer(checked: Checked, what: str, now: float) -> int:
|
||||
|
||||
def bash_breaches(command: str, cwd: str, home: str) -> list[Breach]:
|
||||
simples = simple_commands(command, cwd, home)
|
||||
return command_breaches(command, simples, home) + [breach for commit in commits(simples, home) for breach in todo_breaches(commit.directory)]
|
||||
return command_breaches(command, simples, home) + [breach for commit in commits(simples, home) for breach in round_cap_breaches(commit) + todo_breaches(commit.directory)]
|
||||
|
||||
|
||||
def read_breaches(call: Call, home: str) -> list[Breach]:
|
||||
|
||||
@@ -6,6 +6,7 @@ import sys
|
||||
import typing
|
||||
|
||||
from rule_hook.rules import Breach
|
||||
from git_repo import default_ref
|
||||
from rule_hook.git import existing, git
|
||||
from failure import Failure
|
||||
from utc_stamp import utc
|
||||
@@ -100,10 +101,10 @@ def print_overrides(directory: str) -> int:
|
||||
if unread:
|
||||
print(f"rule-hook overrides cannot read the branch's reflog, so it cannot tell which overrides are this chunk's: {unread.reason}", file=sys.stderr)
|
||||
return 1
|
||||
default = local_default_branch(directory)
|
||||
default = default_ref(directory, guarded=True)
|
||||
log = pathlib.Path(common) / LOG
|
||||
entries = [parsed_entry(line) for line in log.read_text(encoding="utf-8").splitlines()] if log.is_file() else []
|
||||
on_default = (lambda commit: holds(directory, default, commit)) if default else (lambda commit: False)
|
||||
on_default = (lambda commit: False) if isinstance(default, Failure) else (lambda commit: holds(directory, default, commit))
|
||||
for entry in entries:
|
||||
if entry and this_chunks(entry, set(str(reflog).split()), branch, on_default):
|
||||
print(entry.line(), end="")
|
||||
@@ -119,9 +120,5 @@ def unread_reflog(reflog: str | Failure, head: str | Failure) -> Failure | None:
|
||||
return None if head in reflog.split() else Failure("it does not hold HEAD")
|
||||
|
||||
|
||||
def local_default_branch(directory: str) -> str | None:
|
||||
return next((name for name in ("origin/HEAD", "main", "master") if not isinstance(git(directory, "rev-parse", "--verify", "--quiet", name), Failure)), None)
|
||||
|
||||
|
||||
def holds(directory: str, descendant: str, ancestor: str) -> bool:
|
||||
return bool(ancestor) and not isinstance(git(directory, "merge-base", "--is-ancestor", ancestor, descendant), Failure)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
from rule_hook.rules import Breach
|
||||
from round_titles import CAP, past_cap, ROUND, round_counts
|
||||
from git_command import Commit
|
||||
from failure import Failure
|
||||
import git_repo
|
||||
|
||||
|
||||
def round_cap_breaches(commit: Commit) -> list[Breach]:
|
||||
"""A breach where the commit's title takes its pass past the cap, counted with the branch's earlier round commits."""
|
||||
if not any(ROUND.match(message) for message in commit.messages):
|
||||
return []
|
||||
earlier = earlier_titles(commit.directory, commit.amends)
|
||||
refused = [(named.group(1).lower(), message) for message in commit.messages if (named := ROUND.match(message)) and past_cap(message, earlier)]
|
||||
return [Breach("round-cap", refusal(name, message, earlier), commit.directory) for name, message in refused]
|
||||
|
||||
|
||||
def refusal(name: str, title: str, earlier: list[str]) -> str:
|
||||
"""Why title, a round title of the pass name, is refused, listing the pass's round commits counted, and how to commit the fixes in hand."""
|
||||
counted = [earlier_title for earlier_title in earlier if (named := ROUND.match(earlier_title)) and named.group(1).lower() == name]
|
||||
listed = ", ".join(f"`{counted_title}`" for counted_title in counted) or "none found"
|
||||
return f"this would be {name}'s round {round_counts([*counted, title])[name]}, past its {CAP}; {name}'s round commits on this branch: {listed}. Fold the fixes into its last round commit with `git commit --amend` where that is the newest commit, or commit them under a title that doesn't open `Answer <pass> round`; they merge once the gate passes"
|
||||
|
||||
|
||||
def earlier_titles(directory: str, amends: bool) -> list[str]:
|
||||
"""The branch's titles, less the one an --amend replaces; none where git cannot list them within 5 seconds or the checkout records no default branch for origin, so the title's own number still counts.
|
||||
|
||||
Run guarded, as the hook runs git, which neither fetches nor asks origin: the default branch is as last fetched."""
|
||||
default = git_repo.default_ref(directory, guarded=True)
|
||||
titles = default if isinstance(default, Failure) else git_repo.branch_titles(default, directory, timeout=5, guarded=True)
|
||||
if isinstance(titles, Failure):
|
||||
return []
|
||||
return titles[1:] if amends else titles
|
||||
@@ -3,7 +3,7 @@ import posixpath
|
||||
import re
|
||||
import typing
|
||||
|
||||
from round_titles import CAP, lacks_counts, past_cap
|
||||
from round_titles import CAP, lacks_counts
|
||||
from git_command import commits
|
||||
from rule_hook.heavy_command import heavy
|
||||
from shell_command import launched, Simple, tool_name
|
||||
@@ -64,9 +64,11 @@ RULES: dict[RuleName, Rule] = {
|
||||
"an Agent call, in a claude loop-claude started, whose subagent type is an agent under agents/, or whose prompt opens with seat-prompts.md's opening sentence or the one larv-review's Security section sets",
|
||||
overridable=False,
|
||||
),
|
||||
# The cap holds with no ask, so no marker waives it.
|
||||
"round-cap": Rule(
|
||||
f"a larv-review pass takes at most {CAP} rounds per chunk, so a commit titled `Answer <pass> round <n>:` with <n> past {CAP} waits for the human's yes, which the override reason quotes",
|
||||
"a git commit whose message opens `Answer <pass> round <n>:`",
|
||||
f"a larv-review pass takes at most {CAP} rounds per chunk, and none after them: the fixes answering its last round merge once the gate passes",
|
||||
"a git commit whose message opens `Answer <pass> round <n>:`, counted with the pass's round commits on the branch since the default branch as last fetched, less the one an --amend replaces",
|
||||
overridable=False,
|
||||
),
|
||||
"round-title-counts": Rule(
|
||||
"a larv-review round's commit title gives the counts of 🔴 and 🟡 findings the round reported, and how many of them a reviewer marked `[misread]`, at most the two together, such as `Answer stability round 1: 1 🔴, 2 🟡 (1 misread); flag a deleted test`, since score-outcomes counts them",
|
||||
@@ -150,8 +152,6 @@ def command_breaches(command: str, simples: list[Simple], home: str) -> list[Bre
|
||||
breaches.append(Breach("commit-one-line", "pass the message as one -m '<line>', not from a file", commit.directory))
|
||||
elif len(commit.messages) > 1 or any("\n" in message.strip() for message in commit.messages):
|
||||
breaches.append(Breach("commit-one-line", "pass the message as one -m '<line>', with no heredoc, second -m or newline", commit.directory))
|
||||
if any(past_cap(message) for message in commit.messages):
|
||||
breaches.append(Breach("round-cap", f"the pass has had its {CAP} rounds; ask the human, and quote the yes in the override", commit.directory))
|
||||
if any(lacks_counts(message) for message in commit.messages):
|
||||
breaches.append(Breach("round-title-counts", "open the summary after the round's colon with `<k> 🔴, <m> 🟡 (<j> misread);`, where <j> is at most <k> + <m>", commit.directory))
|
||||
return breaches
|
||||
|
||||
@@ -51,21 +51,25 @@ def git(cwd: str, *args: str) -> str:
|
||||
|
||||
class Commits(unittest.TestCase):
|
||||
def test_cd_and_dash_capital_c_move_the_commit(self):
|
||||
self.assertEqual(committed("cd a && git -C ~/b commit -am 'x'"), [Commit("/h/b", ["x"], False)])
|
||||
self.assertEqual(committed("cd a && git -C ~/b commit -am 'x'"), [Commit("/h/b", ["x"], False, False)])
|
||||
self.assertEqual(committed("cd a && git -c x=y -C b commit -m x")[0].directory, "/r/a/b")
|
||||
|
||||
def test_each_message_spelling_is_read(self):
|
||||
self.assertEqual(commit_message(["--message=a", "-m", "b=c", "--message", "c", "-mz", "-am", "d"]), (["a", "b=c", "c", "z", "d"], False))
|
||||
self.assertEqual(commit_message(["--message=a", "-m", "b=c", "--message", "c", "-mz", "-am", "d"]), (["a", "b=c", "c", "z", "d"], False, False))
|
||||
|
||||
def test_an_amend_is_seen(self):
|
||||
self.assertEqual([commit.amends for commit in committed("git commit --amend -m x && git commit -m y")], [True, False])
|
||||
self.assertEqual(commit_message(["--", "--amend"]), ([], False, False), "after --, --amend names a path")
|
||||
|
||||
def test_a_file_message_is_seen(self):
|
||||
self.assertEqual(commit_message(["-F", "-"]), ([], True))
|
||||
self.assertEqual(commit_message(["--file=x"]), ([], True))
|
||||
self.assertEqual(commit_message(["-F", "-"]), ([], True, False))
|
||||
self.assertEqual(commit_message(["--file=x"]), ([], True, False))
|
||||
|
||||
def test_other_git_commands_are_no_commit(self):
|
||||
self.assertEqual(committed("git log --grep commit; echo git commit"), [])
|
||||
|
||||
def test_a_line_break_or_a_comment_separates_commands(self):
|
||||
self.assertEqual(committed("cd a # go there\nGIT_EDITOR=true git commit -m x"), [Commit("/r/a", ["x"], False)])
|
||||
self.assertEqual(committed("cd a # go there\nGIT_EDITOR=true git commit -m x"), [Commit("/r/a", ["x"], False, False)])
|
||||
|
||||
def test_a_commit_after_a_heredoc_or_a_blank_line_is_seen(self):
|
||||
self.assertEqual(len(committed("cat <<EOF > notes\nhello\nEOF\ngit commit -m a")), 1)
|
||||
@@ -81,15 +85,15 @@ class Commits(unittest.TestCase):
|
||||
self.assertEqual(segments("echo hi > f arg"), [["echo", "hi", "arg"]])
|
||||
for redirect in [">", ">>", "<", "<<<", "<>", ">&", "<&", ">|", "&>", "&>>"]:
|
||||
with self.subTest(redirect):
|
||||
self.assertEqual(committed(f"git {redirect} /tmp/x commit -m hi"), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(committed("git commit >&2 -m hi 2>&1"), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(committed("> out git commit -m hi"), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(committed(f"git {redirect} /tmp/x commit -m hi"), [Commit("/r", ["hi"], False, False)])
|
||||
self.assertEqual(committed("git commit >&2 -m hi 2>&1"), [Commit("/r", ["hi"], False, False)])
|
||||
self.assertEqual(committed("> out git commit -m hi"), [Commit("/r", ["hi"], False, False)])
|
||||
|
||||
def test_a_separator_glued_to_a_redirect_still_ends_the_command(self):
|
||||
self.assertEqual(segments("echo a > f; echo b | cat &> g\nls"), [["echo", "a"], ["echo", "b"], ["cat"], ["ls"]])
|
||||
for command in ["echo a &</dev/null git commit -m hi", "echo a;>f git commit -m hi"]:
|
||||
with self.subTest(command):
|
||||
self.assertEqual(committed(command), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(committed(command), [Commit("/r", ["hi"], False, False)])
|
||||
|
||||
|
||||
class CommandBreaches(unittest.TestCase):
|
||||
@@ -128,18 +132,6 @@ class CommandBreaches(unittest.TestCase):
|
||||
with self.subTest(command):
|
||||
self.assertEqual(checked(command), [])
|
||||
|
||||
def test_a_round_title_past_round_3_breaks_round_cap(self):
|
||||
self.assertEqual(checked("git commit -m 'Answer stability round 4: 0 🔴, 1 🟡 (0 misread); fix the parser'"), ["round-cap"])
|
||||
self.assertEqual(checked("git commit -m 'Answer stability round 3: 0 🔴, 1 🟡 (0 misread); fix the parser'"), [])
|
||||
|
||||
def test_a_round_cap_breach_names_the_commit_s_checkout(self):
|
||||
command = "git -C /x commit -m 'Answer stability round 4: 0 🔴, 1 🟡 (0 misread); fix'"
|
||||
self.assertEqual([(breach.rule, breach.directory) for breach in command_breaches(command, simple_commands(command, "/r", "/h"), "/h")], [("round-cap", "/x")])
|
||||
|
||||
def test_an_override_quoting_the_human_s_yes_lets_a_round_past_the_cap_through(self):
|
||||
command = "git commit -m 'Answer stability round 4: 0 🔴, 1 🟡 (0 misread); fix' # rule-override round-cap: the human answered 'yes, one more'"
|
||||
self.assertFalse(check(command_breaches(command, simple_commands(command, "/r", "/h"), "/h"), command, False, True).blocked)
|
||||
|
||||
def test_an_attribution_breaks_only_in_a_git_gh_or_tea_command(self):
|
||||
self.assertEqual(checked(f"tea pr create --description '{TRAILER}'"), ["no-ai-attribution"])
|
||||
self.assertEqual(checked(f"grep -rn '{TRAILER}' ."), [])
|
||||
@@ -664,6 +656,54 @@ class Hook(unittest.TestCase):
|
||||
call = {"cwd": self.repo, "tool_input": {"file_path": f"{self.repo}/.gitignore", "new_string": "d", "old_string": "a"}, "tool_name": "Edit"}
|
||||
self.assertEqual(hook(call, self.repo).returncode, 2)
|
||||
|
||||
def round_commit(self, title: str, given: str = "") -> subprocess.CompletedProcess:
|
||||
return hook({"cwd": self.repo, "tool_input": {"command": f"git commit {given}-m '{title}'"}, "tool_name": "Bash"}, self.repo)
|
||||
|
||||
def test_a_round_commit_past_round_2_is_refused_and_offers_no_override(self):
|
||||
ran = self.round_commit("Answer stability round 3: 0 🔴, 1 🟡 (0 misread); fix # rule-override round-cap: the human said yes")
|
||||
self.assertEqual(ran.returncode, 2)
|
||||
self.assertIn("Blocked by rule round-cap: this would be stability's round 3, past its 2", ran.stderr)
|
||||
self.assertNotIn("rule-override", ran.stderr)
|
||||
self.assertEqual(self.round_commit("Answer stability round 2: 0 🔴, 1 🟡 (0 misread); fix").returncode, 0)
|
||||
|
||||
def test_a_third_round_commit_of_a_pass_on_the_branch_is_refused_whatever_its_number(self):
|
||||
for title in ["Answer stability round 1: 1 🔴, 0 🟡 (0 misread); a", "Answer prose round 1: 0 🔴, 1 🟡 (0 misread); b", "Answer stability round 2: 0 🔴, 1 🟡 (0 misread); c"]:
|
||||
git(self.repo, "commit", "-q", "--allow-empty", "-m", title)
|
||||
ran = self.round_commit("Answer stability round 2: 0 🔴, 0 🟡 (0 misread); d")
|
||||
self.assertEqual(ran.returncode, 2)
|
||||
self.assertIn("stability's round commits on this branch: `Answer stability round 2: 0 🔴, 1 🟡 (0 misread); c`, `Answer stability round 1: 1 🔴, 0 🟡 (0 misread); a`", ran.stderr)
|
||||
self.assertIn("`git commit --amend` where that is the newest commit", ran.stderr)
|
||||
self.assertEqual(self.round_commit("Answer prose round 2: 0 🔴, 0 🟡 (0 misread); d").returncode, 0)
|
||||
self.assertEqual(self.round_commit("Answer stability round 2: 0 🔴, 1 🟡 (0 misread); c, reworded", "--amend --allow-empty ").returncode, 0, "an amend replaces the commit it counts")
|
||||
git(self.repo, "commit", "-q", "--allow-empty", "-m", "fix a typo")
|
||||
self.assertEqual(self.round_commit("Answer stability round 2: 0 🔴, 1 🟡 (0 misread); e", "--amend --allow-empty ").returncode, 2, "an amend replaces the newest commit, not the oldest")
|
||||
|
||||
def test_a_stalled_origin_holds_up_neither_a_round_commit_nor_the_overrides_listing(self):
|
||||
git(self.repo, "config", "protocol.ext.allow", "always")
|
||||
git(self.repo, "remote", "add", "origin", "ext::sleep 30")
|
||||
self.assertEqual(self.round_commit("Answer stability round 1: 0 🔴, 1 🟡 (0 misread); a").returncode, 0)
|
||||
hook({"cwd": self.repo, "tool_input": {"command": "git commit -m a -m b # rule-override commit-one-line: a body is needed"}, "tool_name": "Bash"}, self.repo)
|
||||
listed = subprocess.run([str(HOOK), "overrides"], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True, timeout=10).stdout
|
||||
self.assertIn("\tcommit-one-line\ta body is needed\t", listed)
|
||||
|
||||
def test_round_commits_merged_in_from_the_default_branch_do_not_count(self):
|
||||
git(self.repo, "checkout", "-q", "main")
|
||||
for title in ["Answer stability round 1: 0 🔴, 1 🟡 (0 misread); a", "Answer stability round 2: 0 🔴, 1 🟡 (0 misread); b"]:
|
||||
git(self.repo, "commit", "-q", "--allow-empty", "-m", title)
|
||||
git(self.repo, "checkout", "-q", "chunk")
|
||||
git(self.repo, "merge", "-q", "--no-ff", "-m", "Merge main", "main")
|
||||
git(self.repo, "branch", "-f", "main", "main~2")
|
||||
self.assertEqual(self.round_commit("Answer stability round 1: 0 🔴, 1 🟡 (0 misread); c").returncode, 0, "a stale default branch still leaves another chunk's rounds out")
|
||||
|
||||
def test_a_stale_local_main_does_not_stand_in_for_a_default_branch_origin_left_unrecorded(self):
|
||||
git(self.repo, "checkout", "-q", "main")
|
||||
for title in ["Answer stability round 1: 0 🔴, 1 🟡 (0 misread); a", "Answer stability round 2: 0 🔴, 1 🟡 (0 misread); b"]:
|
||||
git(self.repo, "commit", "-q", "--allow-empty", "-m", title)
|
||||
git(self.repo, "checkout", "-q", "-B", "chunk", "main")
|
||||
git(self.repo, "branch", "-f", "main", "main~2")
|
||||
git(self.repo, "remote", "add", "origin", f"{self.repo}/gone.git")
|
||||
self.assertEqual(self.round_commit("Answer stability round 1: 0 🔴, 1 🟡 (0 misread); c").returncode, 0, "another chunk's rounds, fast-forwarded into the default branch, are not this chunk's")
|
||||
|
||||
def test_a_commit_while_an_unranked_todo_has_changes_is_blocked(self):
|
||||
pathlib.Path(self.repo, "docs").mkdir()
|
||||
for name, content in [("README.md", README), ("docs/decisions.md", DECISIONS), ("todo.md", TODO)]:
|
||||
|
||||
@@ -87,6 +87,11 @@ class StalledOrigin(unittest.TestCase):
|
||||
self.assertIsInstance(ref, Failure)
|
||||
self.assertIn("stopped after 0.5 s", ref.reason)
|
||||
|
||||
def test_reading_the_default_branch_guarded_asks_no_one_and_fails(self):
|
||||
ref = git_repo.default_ref(self.root, 0.5, guarded=True)
|
||||
self.assertIsInstance(ref, Failure)
|
||||
self.assertIn("origin records no default branch", ref.reason)
|
||||
|
||||
def test_fetching_the_default_branch_fails_after_the_timeout(self):
|
||||
with contextlib.chdir(self.root):
|
||||
found = git_repo.default_branch(stale_ok=True, timeout=0.5)
|
||||
|
||||
@@ -23,11 +23,16 @@ class Rounds(unittest.TestCase):
|
||||
|
||||
|
||||
class Cap(unittest.TestCase):
|
||||
def test_finds_a_round_title_past_round_3(self):
|
||||
self.assertTrue(past_cap("Answer stability round 4: 0 🔴, 1 🟡; fix"))
|
||||
self.assertTrue(past_cap("answer full scan round 10: x"))
|
||||
self.assertFalse(past_cap("Answer stability round 3: 0 🔴, 1 🟡; fix"))
|
||||
self.assertFalse(past_cap("Answer the 4 questions"))
|
||||
def test_finds_a_round_title_past_round_2(self):
|
||||
self.assertTrue(past_cap("Answer stability round 3: 0 🔴, 1 🟡; fix", []))
|
||||
self.assertTrue(past_cap("answer full scan round 10: x", []))
|
||||
self.assertFalse(past_cap("Answer stability round 2: 0 🔴, 1 🟡; fix", []))
|
||||
self.assertFalse(past_cap("Answer the 3 questions", []))
|
||||
|
||||
def test_counts_the_pass_s_earlier_round_commits(self):
|
||||
self.assertTrue(past_cap("Answer stability round 2: x", ["Answer stability round 2: y", "Answer stability round 1: z"]), "a third commit, though titled round 2")
|
||||
self.assertTrue(past_cap("Answer stability round 1: x", ["Answer Stability round 2: y", "answer stability round 1: z"]), "case is ignored")
|
||||
self.assertFalse(past_cap("Answer stability round 2: x", ["Answer prose round 1: y", "Answer principles round 2: z", "Answer stability round 1: w"]))
|
||||
|
||||
|
||||
class RoundFindings(unittest.TestCase):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import hashlib
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from transcript_archive.location import chunk_folder, outcomes_of
|
||||
from failure import Failure
|
||||
@@ -11,8 +11,8 @@ from transcript_archive.outcomes import TASK
|
||||
from utc_stamp import utc
|
||||
|
||||
|
||||
def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, at: float) -> Failure | None:
|
||||
"""Keeps the transcript at path, its outcomes file and its session's files in project_archive, in the layout this package's docstring gives; the failure that stopped it, or None. The outcome is stamped and appended to the outcomes file, which opens with the task only when the copy is new."""
|
||||
def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, at: float, note: typing.Callable[[str], None] = lambda text: None) -> Failure | None:
|
||||
"""Keeps the transcript at path, its outcomes file and its session's files in project_archive, in the layout this package's docstring gives; the failure that stopped it, or None. The outcome is stamped and appended to the outcomes file, which opens with the task only when the copy is new. Where a new copy lands, note is told where."""
|
||||
try:
|
||||
with open(path, "rb") as handle:
|
||||
raw = handle.read()
|
||||
@@ -32,7 +32,7 @@ def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, a
|
||||
for dest, data in ((outcomes, f"{TASK}{task}\n\n{stamped}\n".encode()), (copy, raw)):
|
||||
if unwritten := replace_file(dest, data):
|
||||
return unarchived(dest, unwritten.reason)
|
||||
print(f"transcript: {copy}", file=sys.stderr)
|
||||
note(f"transcript: {copy}")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -2848,3 +2848,53 @@ Junior A, decided by:
|
||||
- Locality: `bin/rule_hook/repeat_read.py:29` `repeat_breaches`: needs lines through one past the last shown and a mtime formatted as a transcript stamp, both set up by main.py
|
||||
- Locality, Shape: `bin/routing_figures/measure.py:205` `results`: one line over the shared `tool_result`, where cde7720 held a private copy of the parsing
|
||||
- Shape: `bin/rule_hook/repeat_read.py:87` `results_on`: an unnamed four-field tuple unpacked by position, and `written` names a path here but the override text in main.py
|
||||
|
||||
## 2026-10-28T17:21:57Z, PR #390 at 3ef4790, against 47a4075
|
||||
|
||||
Ruling: better
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Mid A | better | better | same | same | better |
|
||||
| Inherited architect | same | better | same | better | better |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- Navigation, Locality, Overall: `bin/rule_hook/round_cap.py:8` `round_cap_breaches`: a refusal by round-cap is traced to a module named after the rule, wired like `todo_check.py`, where the base mixed it into `command_breaches`
|
||||
- Locality, Overall: `bin/git_repo.py:81` `branch_titles`: round-count and the hook read the branch's round titles through one function, so they agree by construction
|
||||
- Locality: `bin/rule_hook/override_log.py:104` `print_overrides`: the second definition of the default branch, `local_default_branch`, is gone
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- Locality, Self-sufficiency, Overall: `bin/git_repo.py:81` `branch_titles`: the hook and round-count now count rounds one way, with first parents, where the base's two rules disagreed
|
||||
- Locality, Overall: `bin/rule_hook/override_log.py:104` `print_overrides`: one default-branch lookup instead of a quietly different local one
|
||||
- Self-sufficiency, Overall: `bin/rule_hook/round_cap.py:24` `earlier_titles`: the docstring states both fail-open cases, and the refusal names the counted commits and both ways out
|
||||
- Self-sufficiency: `skills/larv-review/SKILL.md:78` "Cap": the ask, yes, one-more-round loop is gone, though the bullet now packs four ideas
|
||||
- Locality: `bin/git_repo.py:63` `default_ref`: `guarded=True` means both safe git options and never asking origin, kept at each call site; where it rots first
|
||||
- Locality: `bin/rule_hook/main.py:113` `bash_breaches`: round-cap sits apart from its sibling round-title-counts in `command_breaches`, a split no comment states
|
||||
|
||||
## 2026-10-28T17:54:03Z, PR #391 at f1d749e, against 9014fd0
|
||||
|
||||
Ruling: better
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Mid A | same | better | same | same | better |
|
||||
| Inherited architect | better | better | same | same | better |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- Locality, Overall: `bin/loop_claude/effects.py:93` `say`: every message goes through one function that adds the time, picks stderr or stdout and always flushes; before, each call site chose its own stream and flush, so the order of stdout and stderr lines depended on hidden buffering
|
||||
- Locality: `bin/claude_code/trust.py:10` `trust`: reports through a `note` callable the caller passes, so the call shows where its output goes
|
||||
- Locality: `bin/transcript_archive/write.py:14` `archive`: same, but its default `note` silently drops the `transcript: …` line for a caller that leaves it out
|
||||
- Self-sufficiency: `bin/loop_claude/effects.py:40` `Effects.local_time`: the new comment gives the format and why it is local time
|
||||
- Self-sufficiency: `bin/loop_claude/loop/main.py:289` `plan_item`: the new comment sends a cold reader to the plan, and "one injected effect" is unclear beside `say`
|
||||
- Shape: `bin/loop_claude/cycle/run.py:85` `archived_stop`: the same `lambda text: say(text, effects)` is written out five times and `archive` grows to six parameters
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- Navigation, Locality, Overall: `bin/loop_claude/effects.py:93` `say`: about 30 `print` calls over nine files, disagreeing on flushing and streams, now go through one function whose docstring states the contract
|
||||
- Locality: `bin/claude_code/trust.py:10` `trust`: wrote to `sys.stderr` itself before; now takes a `note` callback, so the caller decides where its words go
|
||||
- Locality: `bin/transcript_archive/write.py:14` `archive`: the same change, but its silent default `note` drops the `transcript: <path>` line for a new caller without a word
|
||||
- Shape: `bin/loop_claude/cycle/run.py:85` `archived_stop`: the same lambda is copied seven times across `run.py`, `loop/main.py` and `cycle/interrupt.py`, which roughly cancels the cleaner output path
|
||||
- Self-sufficiency: `bin/loop_claude/loop/main.py:289` `plan_item`: its comment sends the reader to the plan and reads oddly now that every message goes through `say`
|
||||
|
||||
+8
-8
@@ -145,19 +145,19 @@ Valid while no published standard sets either number, the reading-cost window st
|
||||
|
||||
2026-10-08, lilleman. Serves goal 1.4: run beside the full scan, `/security-review` started seconds apart from it each round and returned a near-identical report. Valid while the full scan covers what `/security-review` reports.
|
||||
|
||||
## review: a fix for a 🔴 or 🟡 reruns the pass that found it and each pass whose row in `larv-review` §3's re-entry table the fix meets; from round 2 a pass reviews only the answers to its last round's findings and any other pass's fix that re-entered it; a fix for a 🟢, a ❓ or a prose finding reruns none
|
||||
## review: a fix for a 🔴 or 🟡 reruns the pass that found it, unless that pass is at its cap, and each pass whose row in `larv-review` §3's re-entry table the fix meets; from round 2 a pass reviews only the answers to its last round's findings and any other pass's fix that re-entered it; a fix for a 🟢, a ❓ or a prose finding reruns none
|
||||
|
||||
2026-10-08, lilleman. Serves goal 1.4. An audit of the four costliest archived chunks found nearly every finding that mattered in a pass's first round; when every fix, a nit's included, re-entered review, later rounds mostly re-checked the last fix, reworded what an earlier round wrote, or contradicted another round on the same line. A round 2 caught real bugs only where a fix changed behaviour, so stability still reruns on every fix that does, and security on every fix that opens an untrusted-input boundary or touches authn/authz, secrets or crypto. Valid while round-2 reviews of nit and prose fixes keep changing nothing a user would notice.
|
||||
|
||||
2026-10-13, lilleman through todo item 97. Serves goals 1.4 and 1.5. From round 2 a pass reviews only how the chunk answered its previous round, each fix and each dismissal with its reason, and reports only one that is plainly wrong or worse than the change it answered. A fix from another pass that re-enters it is still reviewed as a first round would review it, limited to its lines. Reviewing all that changed had a reviewer find new gaps in each round's fixes, so a pass ran to its cap. Valid while round-2 findings outside a round's answers keep changing nothing a user would notice.
|
||||
|
||||
## review: a pass gets at most three rounds per chunk; instead of a fourth, the run asks the human
|
||||
## review: a pass gets at most two rounds per chunk, with no third and no ask for one; the fixes answering round 2 merge once the gate passes
|
||||
|
||||
2026-09-28, lilleman. Serves goal 1. One counter per pass per chunk, so no fix bounces between two passes without end. Valid while one human answers the ask, in the session or from the unmerged PR.
|
||||
2026-10-28, lilleman through todo item 246. Serves goals 1 and 1.4. One counter per pass per chunk, so no fix bounces between two passes without end. lilleman measured every repo's round titles since 2026-10-21. Round 1 ran 357 times and found 59 🔴. Round 2 ran about 200 times and found 12 🔴, mostly in round 1's fixes. Rounds 3 and later ran about 110 times and found no 🔴, at about $125 of review at list prices, and asks for a fourth or fifth round were 24 of the 59 interrupts. The cap had stood at three because a lower cap would ask the human more often; once nothing asks, that reason is gone. A rerun one rung up belongs to the round it reruns, so it doesn't count toward the cap: `review: a reviewer or comprehension seat that rules the work below standard`.
|
||||
|
||||
The cap stays at three, lilleman ruled through todo item 97: a lower cap would ask the human more often, against goal 1, and a third round reviews only the answers to round 2's findings, so it costs little. A rerun one rung up belongs to the round it reruns, so it counts toward no cap: `review: a reviewer or comprehension seat that rules the work below standard`.
|
||||
rule-hook's `round-cap` refuses a round commit that would take its pass past round 2, and no override waives it. It counts the pass's round commits on the branch as `larv-review round-count` does, so a third commit titled round 2 is refused too. The hook must not fetch, so it lists the branch's commits since the default branch as last fetched. It follows first parents, so the round commits that a merge of a newer default branch brought in don't count as this chunk's. It leaves out the commit an `--amend` replaces. Where git cannot list the branch's commits, within 5 seconds or because origin records no default branch, it counts the title's own number alone, so a slow or unset lookup doesn't block the commit.
|
||||
|
||||
rule-hook's `round-cap` refuses a round commit titled past round 3 unless its override reason quotes the human's yes (lilleman, todo item 214). It reads only the title's number, so a fourth commit titled round 3 passes it, while `larv-review round-count` marks that pass past the cap; `todo.md` item 220 closes the gap.
|
||||
Valid while the defects that later commits fix in a finished chunk's code, which `todo.md` item 247 counts, don't rise per chunk.
|
||||
|
||||
## review: a pass skips only on a precedent: a decision, or a plan item crediting the pass, that the repo held before the chunk began
|
||||
|
||||
@@ -187,7 +187,7 @@ Valid while the ladder orders its rungs by competence.
|
||||
|
||||
## review: an ask no user answers leaves the PR unmerged
|
||||
|
||||
2026-09-30, claude. Serves goal 1: the round cap, a BLOCK's restructure, Stage 0's questions and a goal conflict are the human's call, and an unmerged PR is what brings it to them; merging would make the call for them. Where an option reviews more — run the pass, fix a finding no goal lets the run decline — the run takes it; a ❓, or a fix changing a goal or a decision, is filed in `todo.md`, which reaches the human without holding the chunk. Valid while a human reads every unmerged PR an unattended run leaves.
|
||||
2026-09-30, claude. Serves goal 1: a BLOCK's restructure, Stage 0's questions and a goal conflict are the human's call, and an unmerged PR is what brings it to them; merging would make the call for them. Where an option reviews more — run the pass, fix a finding no goal lets the run decline — the run takes it; a ❓, or a fix changing a goal or a decision, is filed in `todo.md`, which reaches the human without holding the chunk. Valid while a human reads every unmerged PR an unattended run leaves.
|
||||
|
||||
## review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses its Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`
|
||||
|
||||
@@ -353,7 +353,7 @@ Valid while a model switch inside a session discards its prompt cache.
|
||||
|
||||
## rule-hook: a PreToolUse hook enforces each rule a program can check, a `# rule-override <rule>: <reason>` marker overrides one, and larv-review's overrides pass rules on each override before merge
|
||||
|
||||
2026-10-12, lilleman. Serves goals 1.2 and 1.3. Anthropic's best-practices page calls `CLAUDE.md` advisory and hooks deterministic, so a rule that must hold every time moves into `bin/rule-hook`, and `CLAUDE.md` keeps it only where the hook cannot check it. A Claude Code hook ties the check to one vendor ("Prefer the vendor-neutral option", `principles/technical-principles.md`), which is the target itself here: this repo configures Claude Code. What the tie buys: the hook blocks before a write lands, Edit and Write calls included, in every project with no per-repo install; a git `commit-msg` hook sees only commits, and CI sees them only after the push. The hook checks each write, so the agent fixes the line it just wrote; checking the staged diff at commit time would also cover files a Bash command writes, at the cost of later feedback. The marker's spelling was picked by a panel of three fresh readers, two to one. Each override is logged in the checkout's git directory, which is never pushed (goal 4). The plan had loop-claude's judge to rule on overrides inside a loop; lilleman approved larv-review's overrides pass in every run, because it rules before merge and an outrageous override still reaches the human through its ask. 2026-10-16, lilleman, answering plan item 166: `reviewer-rung` is the one rule no marker overrides; the comment above it in `bin/rule_hook/rules.py` says why. Valid while a PreToolUse hook that exits 2 blocks the call and hands its stderr to the model, and while an agent commits through Claude Code's Bash tool.
|
||||
2026-10-12, lilleman. Serves goals 1.2 and 1.3. Anthropic's best-practices page calls `CLAUDE.md` advisory and hooks deterministic, so a rule that must hold every time moves into `bin/rule-hook`, and `CLAUDE.md` keeps it only where the hook cannot check it. A Claude Code hook ties the check to one vendor ("Prefer the vendor-neutral option", `principles/technical-principles.md`), which is the target itself here: this repo configures Claude Code. What the tie buys: the hook blocks before a write lands, Edit and Write calls included, in every project with no per-repo install; a git `commit-msg` hook sees only commits, and CI sees them only after the push. The hook checks each write, so the agent fixes the line it just wrote; checking the staged diff at commit time would also cover files a Bash command writes, at the cost of later feedback. The marker's spelling was picked by a panel of three fresh readers, two to one. Each override is logged in the checkout's git directory, which is never pushed (goal 4). The plan had loop-claude's judge to rule on overrides inside a loop; lilleman approved larv-review's overrides pass in every run, because it rules before merge and an outrageous override still reaches the human through its ask. 2026-10-16, lilleman, answering plan item 166: no marker overrides `reviewer-rung`; the comment above it in `bin/rule_hook/rules.py` says why. Valid while a PreToolUse hook that exits 2 blocks the call and hands its stderr to the model, and while an agent commits through Claude Code's Bash tool.
|
||||
|
||||
## rules/: `CLAUDE.md` holds the worker's rules that no file path can scope, and each topic's rules for the worker live in a `rules/` file that Claude Code loads by its `paths:` frontmatter
|
||||
|
||||
@@ -433,7 +433,7 @@ A finding against a principle names it, so the worker reads only that one when i
|
||||
|
||||
The item also cut the rule that a session proposes new rules for `CLAUDE.md` and `rules/` and restructures them after each change: changes to these rules go through this repo's chunks and their reviews, like any other change.
|
||||
|
||||
Valid while review rounds per pass do not rise. A principle found late, such as functional core, can cost a rewrite within a pass's three rounds. `todo.md` item 105 compares rounds per pass and reading cost in loop-claude's archive for the five chunks before and after this one.
|
||||
Valid while review rounds per pass do not rise. A principle found late, such as functional core, can cost a rewrite within a pass's two rounds. `todo.md` item 105 compares rounds per pass and reading cost in loop-claude's archive for the five chunks before and after this one.
|
||||
|
||||
## workflow-bench/: the remote may show the bench cases' names and commit SHAs
|
||||
|
||||
|
||||
@@ -895,3 +895,15 @@ Read most (opens and searches):
|
||||
Read most (opens and searches):
|
||||
|
||||
- `rules/decisions.md` 1
|
||||
|
||||
## Reading cost, chunk c49a63a648d0, finished 2026-10-28T16:32:11Z
|
||||
|
||||
118558 new input tokens before the first commit.
|
||||
|
||||
## Reading cost, chunk 96afddd04db4, finished 2026-10-28T17:23:03Z
|
||||
|
||||
105744 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `rules/todo-items.md` 4
|
||||
|
||||
@@ -71,14 +71,13 @@ Give a reviewer without Bash the branch diff and `git ls-files`'s output in its
|
||||
|
||||
**Round cap.**
|
||||
|
||||
- **Round.** A round is one review by a pass's reviewer: the first, each re-entry, and the rerun after the architect returns Stage 0 questions ("Architecture" below). A relaunch one rung up ("Rung up" below) stays in its round.
|
||||
- **Auto-reviewer.** The external auto-reviewer (§4) is a pass of its own, each review it posts a round. Its count is the number of its reviews on the PR, less its reviews of a `Record the comprehension check:` commit, and `round-count` doesn't list it. A commit that answers one of its rounds takes an ordinary title, not an `Answer <pass> round` one, and a round that changed nothing gets no commit.
|
||||
- **Round.** A round is one review by a pass's reviewer: the first and each re-entry. The rerun after the architect returns Stage 0 questions ("Architecture" below) and a relaunch one rung up ("Rung up" below) stay in their round.
|
||||
- **Auto-reviewer.** The external auto-reviewer (§4) is a pass of its own, each review it posts, up to the cap, a round. Its count is the number of its reviews on the PR, less its reviews of a `Record the comprehension check:` commit, and `round-count` doesn't list it. A commit that answers one of its rounds takes an ordinary title, not an `Answer <pass> round` one, and a round that changed nothing gets no commit.
|
||||
- **Count.** Close each round of a pass other than the auto-reviewer with one commit that holds the round's fixes. Title it `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); …`: `<pass>` is the pass's name in lower case, such as `full scan`, `<k>` and `<m>` are the 🔴 and 🟡 findings all the round's reviewers reported, and `<j>` is how many of those they marked `[misread]` (review-findings.md → "Misread"); a reviewer that marks none, such as `/security-review`, adds 0. Example: `Answer stability round 1: 1 🔴, 2 🟡 (1 misread); flag a deleted test`. A round that changed nothing gets an empty commit (`git commit --allow-empty`). Push the commits when §4 runs next, where there is a remote. `~/.claude/bin/larv-review round-count` prints each pass's count and marks a pass at the cap.
|
||||
- **Done.** A pass is done when its latest round leaves no 🔴 or 🟡 standing: none was reported, or each was shown factually wrong, declined, filed, or named under the bar per "Findings", or settled in the PR summary per "Comprehension check" → "Places", or, for the prose pass, fixed. Resolve that round's 🟢s and ❓s per "Findings" too.
|
||||
- **Cap.** A pass takes at most three rounds per chunk. Instead of a fourth, list what is open and ask the user. For the auto-reviewer, ask before the push that would summon its fourth, and hold the fixes unpushed until the answer.
|
||||
- **Answer.** A yes grants that pass one more round, after which the ask repeats; a no leaves the PR unmerged. rule-hook refuses a round commit titled past round 3 unless its `round-cap` override quotes the yes.
|
||||
- **Done.** A pass is done when its latest round leaves no 🔴 or 🟡 standing: none was reported, or each was shown factually wrong, declined, filed, or named under the bar per "Findings", or settled in the PR summary per "Comprehension check" → "Places", or, for the prose pass and a pass at its cap, fixed. Resolve that round's 🟢s and ❓s per "Findings" too.
|
||||
- **Cap.** A pass takes at most two rounds per chunk; don't ask the user for a third. Answer its second round's findings per "Findings": those fixes merge once the gate passes, unreviewed by that pass. rule-hook's `round-cap` refuses a round commit that would take a pass past two, and no override waives it. A review the auto-reviewer posts after its second isn't a round: fix none of it and rerun no pass for it, but file a security finding it raises per `~/.claude/CLAUDE.md` → "Working loop", and any other 🔴 in `todo.md`.
|
||||
|
||||
**Re-entry.** A fix is a change no pass has seen. A fix for a 🟢, a ❓ or a prose finding reruns no pass, whatever it changes. A round's fixes for 🔴 and 🟡 findings re-enter together: run every pass that a row below names for any of them, a done pass included, in the waves of "Waves", then §4. A pass at its cap gets "Round cap" → "Cap"'s ask instead.
|
||||
**Re-entry.** A fix is a change no pass has seen. A fix for a 🟢, a ❓ or a prose finding reruns no pass, whatever it changes. A round's fixes for 🔴 and 🟡 findings re-enter together: run every pass that a row below names for any of them, a done pass included, in the waves of "Waves", then §4. A pass at its cap doesn't run again ("Round cap" → "Cap").
|
||||
|
||||
| The fix | Reruns |
|
||||
|---------|--------|
|
||||
@@ -172,7 +171,7 @@ Launch prose-reviewer with what the diff touched and every section this review c
|
||||
4. Watch the forge's checks until every one passes. A red check is a finding.
|
||||
5. No CI configured → the gate is local tests only; note it in the summary.
|
||||
6. Everything green → mark the PR ready, dropping any `WIP:`/`Draft:` title prefix.
|
||||
7. **External auto-reviewer**, when the repo has one — its config file (`.coderabbit.yaml` and the like), or its comments on earlier PRs; none → skip it, say so. Marking the PR ready is what summons it. Wait up to **10 minutes** for its first review, checking about once a minute; nothing by then → note it in the summary and carry on, never waiting twice. Its rounds, §3 → "Round cap". Once it has reviewed, each later return here, after a fix re-entered per §3, waits up to **5 minutes** for its re-review of the new commit.
|
||||
7. **External auto-reviewer**, when the repo has one — its config file (`.coderabbit.yaml` and the like), or its comments on earlier PRs; none → skip it, say so. Marking the PR ready is what summons it. Wait up to **10 minutes** for its first review, checking about once a minute; nothing by then → note it in the summary and carry on, never waiting twice. Its rounds, §3 → "Round cap". Once it has reviewed, each later return here before its cap, after a fix re-entered per §3, waits up to **5 minutes** for its re-review of the new commit.
|
||||
|
||||
## 5. Goal alignment, then merge
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 246 | 0.4.0 | | owner | **Give each review pass at most two rounds per chunk, with no third round and no ask for one: a fix answering round 2 merges once the gate passes.** | 3 | 2 | 3 | 6 | 3 | 1.2 by 5, 1.5 by 3, 1.4 by 2 | 10.0 |
|
||||
| 244 | 0.4.0 | | owner | **Open every line loop-claude prints to its terminal with the machine's local time, as in `2026-10-28 11:46:01`.** | 2 | 2 | 1 | 3 | 3 | 1.5 by 2 | 1.9 |
|
||||
| 247 | 0.4.0 | | owner | **Count each finished chunk's escaped defects, the later commits that fix code it shipped, in `score-outcomes` and the routing figures.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4 | 1.7 |
|
||||
| 243 | 0.4.0 | | owner | **Show every loop-claude on the machine that waits for the human in one terminal app, and let the human answer each one there, `/talk` included.** | 4 | 2 | 3 | 7 | 6 | 1.5 by 4 | 0.9 |
|
||||
| 226 | 0.5.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 |
|
||||
@@ -64,7 +62,6 @@
|
||||
| 77 | 0.6.0 | | | **Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.** | 4 | 2 | 1 | 5 | 6 | 1.1 by 7, 1.4 by 7 | 3.2 |
|
||||
| 4 | 0.6.0 | | | **Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.** | 3 | 2 | 3 | 6 | 3 | 1.1 by 3 | 3.2 |
|
||||
| 187 | 0.6.0 | | | **Count the tokens a worker spends reading reviewers' reports, so goal 1.4's signal shows whether report files lowered what a review costs the worker's context.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 3.0 |
|
||||
| 220 | 0.6.0 | | decision | **Have rule-hook also count a pass's earlier round commits on the branch, so a fourth commit titled round 3 is refused too.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3 | 3.0 |
|
||||
| 149 | 0.6.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 3.0 |
|
||||
| 165 | 0.6.0 | | | **Make this repo's tests assert the facts a prompt or help text carries in place of its sentences, and drop the tests that scan source or assert a constant.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4, 1.4 by 3 | 2.9 |
|
||||
| 151 | 0.6.0 | | decision | **Keep 10 to 20 settled decisions per project as its goals' test set, and rerun them after a goal changes.** | 3 | 2 | 2 | 5 | 5 | 1.2 by 7 | 2.9 |
|
||||
@@ -82,19 +79,6 @@
|
||||
|
||||
## Details
|
||||
|
||||
### 246. Give each review pass at most two rounds per chunk, with no third round and no ask for one: a fix answering round 2 merges once the gate passes.
|
||||
|
||||
lilleman's call, 2026-10-28, from a measurement of every repo's round titles since 2026-10-21. Round 1 ran 357 times and found 59 🔴. Round 2 ran about 200 times and found 12 🔴, mostly in round 1's fixes. Rounds 3 and later ran about 110 times and found no 🔴, at about $125 of review at list prices. Asks for a fourth or fifth round were 24 of the 59 interrupts in that time. Until this ships, lilleman answered no to a fourth principles round in PR #387, due only to tests a stability fix added after principles approved the code twice, and had the chunk merge without it.
|
||||
|
||||
- Replace `docs/decisions.md` → `review: a pass gets at most three rounds per chunk; instead of a fourth, the run asks the human` with the new cap, and update its title in `AGENTS.md`. Its reason for three, that a lower cap asks the human more often, no longer holds once nothing asks.
|
||||
- Change `skills/larv-review/SKILL.md` → "Round cap" → "Cap", and every place it says three rounds or a fourth: the auto-reviewer included.
|
||||
- Have rule-hook's `round-cap` refuse a round commit titled past round 2, with no override. Settle item 220 inside this change, since it guards the same cap; drop it if this change makes it moot.
|
||||
- `bin/round_titles.py:4` `CAP` and `bin/rule_hook/rules.py:55` `round-title-counts` are places the comprehension seats found hard: the cap lives in SKILL.md prose while the code only counts. Make them easier to read.
|
||||
|
||||
### 244. Open every line loop-claude prints to its terminal with the machine's local time, as in `2026-10-28 11:46:01`.
|
||||
|
||||
lilleman's call, 2026-10-28, who also chose the spelling: `YYYY-MM-DD HH:MM:SS` in the machine's local time, never UTC, so the human sees when each line happened, such as how long a question has waited. Today about 27 `print` calls across `bin/loop_claude/` write bare lines to stderr. Route them through one function that adds the stamp, taking the time from `Effects.now` so tests can fix it. A line of a multi-line message, such as a question, gets the stamp only on its first line.
|
||||
|
||||
### 247. Count each finished chunk's escaped defects, the later commits that fix code it shipped, in `score-outcomes` and the routing figures.
|
||||
|
||||
lilleman's call, 2026-10-28. Escaped defects are the counter-signal of goals 1 and 1.1, and nothing counts them, so nobody can tell whether review spending prevents defects or only polishes. A review costs about 56% of a chunk's dollars. Count, for each finished chunk, the later commits on the default branch that fix lines it added: a fix item's chunk, a `defect` item, or a 🔴 marked `[misread]` whose lines `git blame` traces to the earlier chunk. Show the count per chunk and its median per rung in `score-outcomes` and `routing-figures.md`, so a cheaper review pipeline can be judged against it. Measure on every project in loop-claude's archive.
|
||||
@@ -350,10 +334,6 @@ Today the folder is the SHA-256 of the transcript's first timestamped line, whic
|
||||
|
||||
Before PR #310, reports reached the worker as the Agent call's result, a median 19k tokens per chunk (2026-10-08, 68 archived transcripts). Now a reviewer returns its verdict and one line per finding, and the worker reads a 🔴 or 🟡 finding's entry from the report file. `reading-cost` counts only tracked files (`bin/reading_cost/measure.py`), and `routing-figures` counts only the Agent call's result (`bin/routing_figures/measure.py`), so neither sees the report reads. Found by the architecture review of PR #310.
|
||||
|
||||
### 220. Have rule-hook also count a pass's earlier round commits on the branch, so a fourth commit titled round 3 is refused too.
|
||||
|
||||
Found by the principles pass of PR #360 (item 214). rule-hook's `round-cap` reads only the number in the title being committed (`bin/round_titles.py` `past_cap`), while `larv-review round-count` (`round_counts`) also counts repeated numbers, so a fourth commit titled `Answer stability round 3: …` passes the hook. Have `bash_breaches` in `bin/rule_hook/main.py` read the titles of `<default branch>..HEAD` in each round commit's checkout, with the hook's guarded git (`bin/rule_hook/git.py`), and refuse the commit when `round_counts(titles)` already holds 3 for its pass. The hook must not fetch from origin, as `git_repo.default_branch` does; it already has a lookup that needs no fetch, `local_default_branch` in `bin/rule_hook/override_log.py`. A `git commit --amend` must not count the commit it replaces. Hard part: the hook runs on every commit, so a slow or failing lookup must not block the commit. The change touches `bin/round_titles.py` `CAP`, which the comprehension seats found hard; make it easier to read.
|
||||
|
||||
### 149. Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.
|
||||
|
||||
A release's capacity is a sum of its items' cost, as the formula counts it. Each project states its own; the human sets the first value per project. Nothing is deleted by score.
|
||||
@@ -394,7 +374,7 @@ The key names the project's session, archive folder and models entry. `project_k
|
||||
|
||||
### 51. Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.
|
||||
|
||||
"Functional core, imperative shell", in `principles/technical-principles.md`: `archive`, `trust`, `retried`, the worker, `put_question` and `model_choice` print to stderr themselves, and the tests swap the global stream.
|
||||
"Functional core, imperative shell", in `principles/technical-principles.md`: `retried`, the worker, `put_question`, `model_choice` and `say` print to stderr themselves, and the tests swap the global stream.
|
||||
|
||||
### 169. Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user