Give the judge what the project records and ten times more of the chunk's transcript
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
Decisions live in `docs/decisions.md`:
|
||||
|
||||
- larv-review: a project under the comprehension floor is fixed at the capping dimension
|
||||
- loop-claude: a judge decides each interrupt from the transcript and the README's premises; the worker's own account of which goal settles a choice decides nothing
|
||||
- loop-claude: a judge decides each interrupt from the transcript, the README's premises and the project's records; the worker's own account of which goal settles a choice decides nothing
|
||||
- loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it
|
||||
- loop-claude: before an interrupt, it marks the checkout and each of its worktrees trusted in `~/.claude.json`
|
||||
- bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- `loop-claude`'s judge reads the project's `AGENTS.md`, `docs/decisions.md` and `docs/decisions/*.md` beside the README's goals and audience, and does not interrupt for a choice they settle. It judges the transcript's last 400,000 characters, up from 40,000. `loop-claude` exits 1 when one of those files cannot be read or is not UTF-8.
|
||||
- `loop-claude` waits out a usage limit and retries: 2 minutes past the reset, or every 10 minutes when the reset time is unknown. A limit is not a failure, and restarts the count of three failures in a row. It prints what claude said about the limit and when the next try is due.
|
||||
- Add the official plugin marketplace and install every plugin `settings.json` enables (README → Install): `claude-security`, `code-review` and `rust-analyzer-lsp`, which needs `rust-analyzer` on `PATH` for Rust projects. With `claude-security`, larv-review's full security scan runs once you confirm its cost; an unattended larv-review reports the scan as not run. `settings.json` silences the plugin's scan tip after `git push`.
|
||||
- systems-architect and product-owner-reviewer can no longer edit what they review; stability-reviewer keeps its shell to run tests, and loses Claude Code's file-editing tools.
|
||||
|
||||
@@ -10,18 +10,20 @@ from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
JUDGED_TRANSCRIPT_TAIL = 40000
|
||||
# About 100,000 tokens, so the prompt fits a 200,000-token context; the largest session rendered here was 364,000 on 2026-10-03.
|
||||
JUDGED_TRANSCRIPT_TAIL = 400000
|
||||
|
||||
JUDGE_RULES = (
|
||||
"Decide whether the human must now be interrupted. interrupt=true when any of these appear:\n"
|
||||
"- the agent asks the human anything, seeks approval, or says a decision is the human's\n"
|
||||
"- it carried on under an assumption that decides the deliverable and that the human could "
|
||||
"reasonably reject; a caveat about transient state it then handled is not one\n"
|
||||
"- it carried on under an assumption that decides the deliverable, that the human could "
|
||||
"reasonably reject and that neither README.md nor the project's records settle; a caveat about "
|
||||
"transient state it then handled is not one\n"
|
||||
"- it is blocked on something only the human can supply: a credential, a version bump, a release "
|
||||
"ready to cut, a choice outside the repo\n"
|
||||
"- it flags that the goals, the plan or the task itself is unclear, missing or in need of change\n"
|
||||
"- it chose between alternatives the README text does not discriminate between - it does not "
|
||||
"rule the rejected one out - and the choice materially changes the deliverable\n"
|
||||
"- it chose between alternatives that neither README.md nor the project's records discriminate "
|
||||
"between - neither rules the rejected one out - and the choice materially changes the deliverable\n"
|
||||
"interrupt=false otherwise. Bookkeeping the agent settled silently - what to document, wording, "
|
||||
"where a note goes - is not on its own a reason to interrupt. The human may have replied inside the transcript, on a [human] line: judge only what "
|
||||
"is still open, never a question they already answered there.\n"
|
||||
@@ -49,7 +51,7 @@ JUDGE_SCHEMA = {
|
||||
}
|
||||
|
||||
|
||||
def judge(root: str, task: str, premises: str, rendered_transcript: str, model: str, effects: Effects) -> Verdict | Stop:
|
||||
def judge(root: str, task: str, premises: str, records: str, rendered_transcript: str, model: str, effects: Effects) -> Verdict | Stop:
|
||||
# No tools, so the verdict rests on the transcript grounded() checks it against; no persistence, so its runs stay out of the session picker.
|
||||
args = [
|
||||
"-p",
|
||||
@@ -60,7 +62,7 @@ def judge(root: str, task: str, premises: str, rendered_transcript: str, model:
|
||||
"--permission-mode", "bypassPermissions",
|
||||
"--tools", "",
|
||||
]
|
||||
prompt = judge_prompt(task, premises, rendered_transcript)
|
||||
prompt = judge_prompt(task, premises, records, rendered_transcript)
|
||||
return retried("judge", lambda: run_judge(root, args, prompt, rendered_transcript, effects), effects)
|
||||
|
||||
|
||||
@@ -83,9 +85,10 @@ def run_judge(root: str, args: list[str], prompt: str, rendered_transcript: str,
|
||||
return verdict
|
||||
|
||||
|
||||
def judge_prompt(task: str, premises: str, rendered_transcript: str) -> str:
|
||||
def judge_prompt(task: str, premises: str, records: str, rendered_transcript: str) -> str:
|
||||
return (
|
||||
f"From README.md:\n{premises}\n\n"
|
||||
f"The project's records, its working rules and decisions:\n{records or 'none'}\n\n"
|
||||
f"The task an agent was given:\n{task}\n\n"
|
||||
# The tail, where an interrupt or a finish lands; the session's transcript grows cycle over cycle.
|
||||
f"What the agent did and said, and what the human typed on [human] lines, latest last:\n{rendered_transcript[-JUDGED_TRANSCRIPT_TAIL:]}\n\n"
|
||||
|
||||
@@ -24,6 +24,7 @@ class Cycle:
|
||||
paths: Paths
|
||||
premises: str
|
||||
project_key: str
|
||||
records: str
|
||||
root: str
|
||||
session: Session
|
||||
task: str
|
||||
@@ -75,7 +76,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
|
||||
entries = read_transcript(transcript_path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, entries.reason)
|
||||
verdict = judge(cycle.root, cycle.task, cycle.premises, render(entries), cycle.models.judge, cycle.effects)
|
||||
verdict = judge(cycle.root, cycle.task, cycle.premises, cycle.records, render(entries), cycle.models.judge, cycle.effects)
|
||||
return verdict if isinstance(verdict, Stop) else Ruled(verdict)
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ usage: loop-claude <task>
|
||||
|
||||
Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the
|
||||
premises; the task runs at the checkout root. Each cycle a worker runs the task; a judge then reads
|
||||
the transcript against the premises and rules whether the chunk, the work of one PR, is finished.
|
||||
the transcript's last 400,000 characters against the premises and the project's records, AGENTS.md,
|
||||
docs/decisions.md and docs/decisions/*.md where they exist, and rules whether the chunk, the work of
|
||||
one PR, is finished. A choice the premises or the records settle is not asked again.
|
||||
A question only the human can answer, or a release ready to cut, is an interrupt: `claude --resume`
|
||||
on the terminal, every worktree first marked trusted in ~/.claude.json. An unfinished chunk resumes
|
||||
its session next cycle; the next chunk starts a fresh session.
|
||||
@@ -34,6 +36,7 @@ Exit 1, saying why, when:
|
||||
- no task is given
|
||||
- git cannot start or finds no checkout
|
||||
- README.md holds no premises
|
||||
- AGENTS.md or a decision file cannot be read, or is not UTF-8
|
||||
- the models file cannot be read or written
|
||||
- claude leaves no transcript
|
||||
- a transcript cannot be read or archived
|
||||
@@ -71,6 +74,7 @@ from loop_claude.paths import Paths
|
||||
from loop_claude.project.checkout import checkout_root, project_key
|
||||
from loop_claude.project.model_choice import get_or_ask_models
|
||||
from loop_claude.project.premises import read_premises
|
||||
from loop_claude.project.records import read_records
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
@@ -98,11 +102,14 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
premises = read_premises(loop_run.root)
|
||||
if isinstance(premises, Stop):
|
||||
return premises
|
||||
records = read_records(loop_run.root)
|
||||
if isinstance(records, Stop):
|
||||
return records
|
||||
models = get_or_ask_models(key, paths, env, effects)
|
||||
if isinstance(models, Stop):
|
||||
return models
|
||||
print(f"\n=== cycle {loop_run.cycle_number} ===", flush=True)
|
||||
if stop := run_cycle(Cycle(effects=effects, models=models, paths=paths, premises=premises, project_key=key, root=loop_run.root, session=session, task=loop_run.task)):
|
||||
if stop := run_cycle(Cycle(effects=effects, models=models, paths=paths, premises=premises, project_key=key, records=records, root=loop_run.root, session=session, task=loop_run.task)):
|
||||
return stop
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import pathlib
|
||||
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
def read_records(root: str) -> str | Stop:
|
||||
"""AGENTS.md and the decision log, each headed by its path; a file the project lacks is left out."""
|
||||
project = pathlib.Path(root)
|
||||
paths = [project / "AGENTS.md", project / "docs" / "decisions.md", *sorted(project.glob("docs/decisions/*.md"))]
|
||||
records = []
|
||||
for path in paths:
|
||||
name = path.relative_to(project)
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
except OSError as failure:
|
||||
return Stop(1, f"{name} in {root}: {failure.strerror} - the judge cannot read the project's records.")
|
||||
except UnicodeDecodeError as failure:
|
||||
line = failure.object.count(b"\n", 0, failure.start) + 1
|
||||
return Stop(1, f"{name} is not UTF-8 on line {line} - the judge cannot read the project's records.")
|
||||
records.append(f"From {name}:\n{text.strip()}")
|
||||
return "\n\n".join(records)
|
||||
+22
-2
@@ -24,7 +24,7 @@ from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.limited import Limited
|
||||
from loop_claude.loop import main, reload
|
||||
from loop_claude.project import checkout, model_choice, premises
|
||||
from loop_claude.project import checkout, model_choice, premises, records
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
CWD = pathlib.Path("/c")
|
||||
@@ -156,7 +156,7 @@ class Cycles(unittest.TestCase):
|
||||
self.session = session.session_for("proj", self.paths)
|
||||
|
||||
def cycle(self, fake):
|
||||
return run.Cycle(effects=fake.effects(), models=model_choice.Models("judge-model", "worker-model"), paths=self.paths, premises="## Goals", project_key="proj", root=str(self.home), session=self.session, task="Do it.")
|
||||
return run.Cycle(effects=fake.effects(), models=model_choice.Models("judge-model", "worker-model"), paths=self.paths, premises="## Goals", project_key="proj", records="", root=str(self.home), session=self.session, task="Do it.")
|
||||
|
||||
def archived_verdicts(self):
|
||||
return sorted(path.read_text() for path in (self.paths.transcript_archive / "proj").glob("*/*.verdict.md"))
|
||||
@@ -348,6 +348,24 @@ class WorkerArgs(unittest.TestCase):
|
||||
self.assertNotIn("Do it.", " ".join(resumed))
|
||||
|
||||
|
||||
class Records(unittest.TestCase):
|
||||
def test_heads_each_record_the_project_has_by_its_path(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self.assertEqual(records.read_records(root), "")
|
||||
pathlib.Path(root, "docs", "decisions").mkdir(parents=True)
|
||||
pathlib.Path(root, "docs", "decisions", "b.md").write_text("# B\n")
|
||||
pathlib.Path(root, "docs", "decisions", "a.md").write_text("# A\n")
|
||||
pathlib.Path(root, "AGENTS.md").write_text("\n# Rules\n")
|
||||
self.assertEqual(records.read_records(root), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions/a.md:\n# A\n\nFrom docs/decisions/b.md:\n# B")
|
||||
|
||||
def test_stops_on_a_record_it_cannot_read(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True)
|
||||
self.assertEqual(records.read_records(root), Stop(1, f"docs/decisions.md in {root}: Is a directory - the judge cannot read the project's records."))
|
||||
pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n")
|
||||
self.assertEqual(records.read_records(root), Stop(1, "AGENTS.md is not UTF-8 on line 2 - the judge cannot read the project's records."))
|
||||
|
||||
|
||||
class Sections(unittest.TestCase):
|
||||
def test_keeps_every_headed_section_with_its_bodies(self):
|
||||
text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority\n\n## Empty\n\n## Audience\nme\n## Audience\nagain\n# Appendix\nnot audience\n"
|
||||
@@ -513,6 +531,8 @@ class ExitContract(unittest.TestCase):
|
||||
("project/premises.py", "read_premises", "1", "f'README.md has no ##", premises_),
|
||||
("project/premises.py", "read_premises", "1", "f'README.md has ## {name} more than once", premises_),
|
||||
("project/premises.py", "read_premises", "1", "f'README.md has nothing under", premises_),
|
||||
("project/records.py", "read_records", "1", 'f"{name} in {root}:', "AGENTS.md or a decision file cannot be read, or is not UTF-8"),
|
||||
("project/records.py", "read_records", "1", 'f"{name} is not UTF-8', "AGENTS.md or a decision file cannot be read, or is not UTF-8"),
|
||||
]
|
||||
root = pathlib.Path(main.__file__).parents[1]
|
||||
found = []
|
||||
|
||||
@@ -323,6 +323,8 @@ class Cycles(unittest.TestCase):
|
||||
def test_resumes_the_session_while_unfinished_and_starts_it_fresh_after_finishing(self):
|
||||
checkout = Checkout(self)
|
||||
(checkout.root / "sub").mkdir()
|
||||
(checkout.root / "docs").mkdir()
|
||||
(checkout.root / "docs" / "decisions.md").write_text("# Decisions\n")
|
||||
run = checkout.run([
|
||||
worker(say="started"), judge(evidence="started"),
|
||||
worker(say="landed-it", siblings=True), judge(finished=True, evidence="landed-it"),
|
||||
@@ -341,6 +343,7 @@ class Cycles(unittest.TestCase):
|
||||
self.assertNotIn(TASK, argument(workers[1], "-p"))
|
||||
self.assertEqual({call["cwd"] for call in run.calls}, {str(checkout.root)})
|
||||
self.assertIn("1. Work.", run.calls[1]["stdin"])
|
||||
self.assertIn("From docs/decisions.md:\n# Decisions", run.calls[1]["stdin"])
|
||||
self.assertEqual({argument(call, "--model") for call in workers}, {"worker-model"})
|
||||
self.assertEqual({argument(call, "--model") for call in run.calls if call["role"] == "judge"}, {"judge-model"})
|
||||
self.assertIn("landed-it", run.calls[3]["stdin"])
|
||||
@@ -428,9 +431,9 @@ class Cycles(unittest.TestCase):
|
||||
|
||||
def test_hands_the_judge_the_tail_of_a_long_transcript(self):
|
||||
checkout = Checkout(self)
|
||||
run = checkout.run([worker(say="early " * 20000 + "LATE")])
|
||||
run = checkout.run([worker(say="early " * 80000 + "LATE")])
|
||||
self.assertIn("LATE", run.calls[1]["stdin"])
|
||||
self.assertLess(run.calls[1]["stdin"].count("early"), 20000)
|
||||
self.assertEqual(run.calls[1]["stdin"].count("early"), (400000 - len("LATE")) // len("early "))
|
||||
self.assertTrue(run.calls[1]["stdin"].rstrip().endswith("an open PR, a review not yet run, CI not yet reported."))
|
||||
|
||||
def test_skips_a_malformed_transcript_or_stream_line(self):
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@
|
||||
|
||||
2026-09-20, lilleman. Serves goal 4. Across six projects scored with the four seats, Locality or Self-sufficiency capped every seat and Navigation capped none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats.
|
||||
|
||||
## loop-claude: a judge decides each interrupt from the transcript and the README's premises; the worker's own account of which goal settles a choice decides nothing
|
||||
## loop-claude: a judge decides each interrupt from the transcript, the README's premises and the project's records; the worker's own account of which goal settles a choice decides nothing
|
||||
|
||||
2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. On 2026-10-01 lilleman decided the judge is to read `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2); `todo.md` item 7 ends the README-only bar. Valid while the worker's self-report stays unreliable.
|
||||
2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. On 2026-10-01 lilleman decided the judge is to read `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2). The records settle a choice the worker made or an assumption it carried on under; a question the worker itself asks still interrupts, since a worker left unanswered would ask it again next cycle. Valid while the worker's self-report stays unreliable.
|
||||
|
||||
## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
| ID | Release | Exempt | Item | R | S | A | G | Goals | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|
|
||||
| 1 | 0.1.0 | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 2, 3 | 27.8 |
|
||||
| 7 | 0.1.0 | decision | **Give the judge the project's recorded decisions, and ask it whether anything the project records settles a choice.** | 3 | 4 | 8 | 8 | 4.2 | 19.0 |
|
||||
| 8 | 0.1.0 | | **Judge a cycle on more than the transcript's last 40,000 characters.** | 4 | 5 | 7 | 8 | 4.2 | 15.8 |
|
||||
| 13 | 0.1.0 | decision | **Make larv-review §3 applicable on its own, cite its rules by name, and say where a pass's round count is recorded.** | 3 | 5 | 6 | 7 | 4.1 | 15.6 |
|
||||
| 23 | 0.1.0 | | **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** | 3 | 4 | 7 | 8 | 4.4 | 13.5 |
|
||||
| 21 | 0.1.0 | | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 6 | 7 | 4.3 | 12.9 |
|
||||
@@ -46,14 +44,6 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost
|
||||
|
||||
2026-10-02, the human: ai-sandbox is the VM `loop-claude` will run on, hosted on the server bender. bender-infra, the infrastructure-as-code project that manages bender, will back up ai-sandbox's data volume once ai-sandbox is rebuilt. The item waits for the human to say the rebuild has landed. Before writing the README line, check that `~/.claude` lives on that volume and that the backup is private and encrypted at rest.
|
||||
|
||||
### 7. Give the judge the project's recorded decisions, and ask it whether anything the project records settles a choice.
|
||||
|
||||
Today it reads only the README's Goals and Audience (`premises.py`) and cannot see an answer recorded in `docs/decisions.md` or `AGENTS.md`, so it can interrupt the human again for a question already answered. Revise the decision "loop-claude: a judge decides each interrupt from the transcript and the README's premises; the worker's own account of which goal settles a choice decides nothing" to match.
|
||||
|
||||
### 8. Judge a cycle on more than the transcript's last 40,000 characters.
|
||||
|
||||
`judge_prompt` cuts the transcript there. The session spans every cycle of the chunk, so a decision made early in a long run is never judged, and the human is not interrupted for it. Larger chunks make runs longer.
|
||||
|
||||
### 13. Make larv-review §3 applicable on its own, cite its rules by name, and say where a pass's round count is recorded.
|
||||
|
||||
Applying one rule of "Round cap", "Re-entry" or "Findings" takes `review-findings.md`, `CLAUDE.md` → "Vocabulary" and the decision log open beside it. The rules cite each other by number ("Round cap" rule 6), so a renumbering breaks a citation silently. Nothing says where a pass's round count is recorded, so a resumed or compacted session loses it.
|
||||
|
||||
Reference in New Issue
Block a user