Answer the architecture pass's first round
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import json
|
||||
|
||||
|
||||
def parse(raw: str | bytes) -> dict | None:
|
||||
def parse_entry(raw: str | bytes) -> dict | None:
|
||||
try:
|
||||
entry = json.loads(raw)
|
||||
except ValueError:
|
||||
@@ -91,4 +91,4 @@ def ends_stream(event: dict) -> bool:
|
||||
|
||||
# {"type": "result", "structured_output": {"evidence": "...", ...}, ...}
|
||||
def structured_output(stdout: str) -> object:
|
||||
return (parse(stdout) or {}).get("structured_output")
|
||||
return (parse_entry(stdout) or {}).get("structured_output")
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import json
|
||||
|
||||
from loop_claude.claude_code.entries import assistant_parts, human_text, parse, part_text, tool_call
|
||||
from loop_claude.claude_code.entries import assistant_parts, human_text, parse_entry, part_text, tool_call
|
||||
from loop_claude.failure import Failure
|
||||
|
||||
JUDGED_TOOL_INPUT = 400
|
||||
|
||||
|
||||
def read(path: str) -> list[dict] | Failure:
|
||||
def read_transcript(path: str) -> list[dict] | Failure:
|
||||
try:
|
||||
with open(path, "rb") as handle:
|
||||
return [entry for raw in handle if (entry := parse(raw))]
|
||||
return [entry for raw in handle if (entry := parse_entry(raw))]
|
||||
except OSError as failure:
|
||||
return Failure(f"could not read the transcript {path}: {failure.strerror}")
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from loop_claude.claude_code.transcript import human_turns, read
|
||||
from loop_claude.claude_code.transcript import human_turns, read_transcript
|
||||
from loop_claude.claude_code.trust import trust
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.project.checkout import checkouts
|
||||
from loop_claude.project.checkout import worktrees
|
||||
from loop_claude.stop import Stop, needs_human, needs_terminal
|
||||
|
||||
ANSWER_QUESTION = "answer the question above"
|
||||
@@ -16,8 +16,8 @@ def interrupt(root: str, session_id: uuid.UUID, model: str, path: str, question:
|
||||
print(f"\n{question}", file=sys.stderr)
|
||||
if stop := needs_terminal(ANSWER_QUESTION, effects.on_terminal()):
|
||||
return stop
|
||||
trust(paths.claude_json, checkouts(root, effects))
|
||||
entries = read(path)
|
||||
trust(paths.claude_json, worktrees(root, effects))
|
||||
entries = read_transcript(path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, entries.reason)
|
||||
before = human_turns(entries)
|
||||
@@ -25,7 +25,7 @@ def interrupt(root: str, session_id: uuid.UUID, model: str, path: str, question:
|
||||
effects.claude_on_terminal(["--model", model, "--permission-mode", "bypassPermissions", "--resume", str(session_id)], root)
|
||||
except OSError as failure:
|
||||
return Stop(1, f"could not start claude for the interrupt: {failure.strerror}")
|
||||
entries = read(path)
|
||||
entries = read_transcript(path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
|
||||
return None if human_turns(entries) > before else needs_human(ANSWER_QUESTION, "the interrupt ended with nothing typed")
|
||||
|
||||
@@ -9,6 +9,8 @@ from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
JUDGED_TRANSCRIPT_TAIL = 40000
|
||||
|
||||
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"
|
||||
@@ -81,7 +83,7 @@ def judge_prompt(task: str, premises: str, rendered_transcript: str) -> str:
|
||||
f"From README.md:\n{premises}\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[-40000:]}\n\n"
|
||||
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"
|
||||
f"{JUDGE_RULES}"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
ATTEMPTS = 3
|
||||
RETRY_DELAY_SECONDS = 60
|
||||
T = typing.TypeVar("T")
|
||||
|
||||
|
||||
@@ -15,7 +17,7 @@ def retried(who: str, attempt: typing.Callable[[], T | Failure], effects: Effect
|
||||
result = attempt()
|
||||
if not isinstance(result, Failure):
|
||||
return result
|
||||
if failures == 3:
|
||||
if failures == ATTEMPTS:
|
||||
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)
|
||||
effects.sleep(60)
|
||||
effects.sleep(RETRY_DELAY_SECONDS)
|
||||
|
||||
@@ -2,7 +2,7 @@ import dataclasses
|
||||
import typing
|
||||
|
||||
from loop_claude.claude_code.session import Session, delete_session, session_open, transcript_file
|
||||
from loop_claude.claude_code.transcript import read, render
|
||||
from loop_claude.claude_code.transcript import read_transcript, render
|
||||
from loop_claude.cycle.archive import archive
|
||||
from loop_claude.cycle.interrupt import interrupt
|
||||
from loop_claude.cycle.judge import judge
|
||||
@@ -12,7 +12,7 @@ from loop_claude.cycle.worker import run_worker, worker_args
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.project.models import Models
|
||||
from loop_claude.project.model_choice import Models
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ def work(cycle: Cycle) -> WorkerRan | Stop:
|
||||
|
||||
|
||||
def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
|
||||
entries = read(transcript_path)
|
||||
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)
|
||||
|
||||
@@ -66,6 +66,7 @@ def transition(state: State, event: Event) -> State:
|
||||
return Finishing(transcript_path)
|
||||
case Judging(), Ruled(Unfinished()):
|
||||
return Ended()
|
||||
# The interrupt is a whole claude session on the terminal, so the judge rules again on what it left.
|
||||
case Interrupting(transcript_path), Answered():
|
||||
return Judging(transcript_path)
|
||||
case Finishing(), Archived():
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from loop_claude.claude_code.entries import assistant_parts, ends_stream, parse
|
||||
from loop_claude.claude_code.entries import assistant_parts, ends_stream, parse_entry
|
||||
from loop_claude.claude_code.session import Session
|
||||
from loop_claude.claude_code.transcript import part_line
|
||||
from loop_claude.effects import Effects
|
||||
@@ -14,7 +14,7 @@ def run_worker(root: str, args: list[str], effects: Effects) -> Failure | None:
|
||||
return Failure(f"could not start claude: {failure.strerror}")
|
||||
done = False
|
||||
for raw in proc.lines():
|
||||
event = parse(raw) or {}
|
||||
event = parse_entry(raw) or {}
|
||||
done = done or ends_stream(event)
|
||||
for part in assistant_parts(event):
|
||||
if line := part_line(part, PRINTED_TOOL_INPUT):
|
||||
|
||||
@@ -30,12 +30,12 @@ Exit 2: the human is needed, to pick the model or answer an interrupt, and stdin
|
||||
terminal, the input ends, or the interrupt ended with nothing typed. Rerunning resumes any
|
||||
open session.
|
||||
|
||||
Each project has one session, "A <path> loop-claude", <path> being the checkout relative to ~/code,
|
||||
Each project has one session, "A <key> loop-claude", <key> being the checkout relative to ~/code,
|
||||
or to / outside it, deleted when the chunk finishes. At every interrupt and when the chunk finishes
|
||||
its transcript is copied to $LOOP_CLAUDE_TRANSCRIPTS/<path>/<sha256>.jsonl (default
|
||||
its transcript is copied to $LOOP_CLAUDE_TRANSCRIPTS/<key>/<sha256>.jsonl (default
|
||||
~/.claude/loop-claude-transcripts), the verdict beside it in <sha256>.verdict.md.
|
||||
|
||||
Every claude it starts runs the project's model, saved per <path> in ~/.claude/loop-claude-models.json
|
||||
Every claude it starts runs the project's model, saved per <key> in ~/.claude/loop-claude-models.json
|
||||
and read each cycle; a project without an entry, as on its first run, is asked for one.
|
||||
LOOP_CLAUDE_JUDGE_MODEL overrides it for the judge, LOOP_CLAUDE_WORKER_MODEL for the worker and the
|
||||
interrupt; with both set, nothing is asked.
|
||||
@@ -54,7 +54,7 @@ from loop_claude.effects import Effects
|
||||
from loop_claude.loop.reload import RELOAD_FLAG, LoopRun, decode_handed, exec_if_edited, fingerprint
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.project.checkout import checkout_root, project_key
|
||||
from loop_claude.project.models import models_for
|
||||
from loop_claude.project.model_choice import get_or_ask_models
|
||||
from loop_claude.project.premises import read_premises
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
@@ -83,7 +83,7 @@ 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
|
||||
models = models_for(key, paths, env, effects)
|
||||
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)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
"""A loop runs unattended for hours, often on its own checkout: a reload puts an edit to loop-claude to work at the next cycle without the human rerunning it."""
|
||||
import dataclasses
|
||||
import hashlib
|
||||
import json
|
||||
@@ -46,6 +45,7 @@ def fingerprint(launcher: pathlib.Path) -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
# A loop runs unattended for hours, often on its own checkout: a reload puts an edit to loop-claude to work without the human rerunning it.
|
||||
def exec_if_edited(launcher: pathlib.Path, baseline: str, loop_run: LoopRun, effects: Effects) -> Stop | None:
|
||||
if fingerprint(launcher) == baseline:
|
||||
return None
|
||||
|
||||
@@ -14,7 +14,7 @@ def checkout_root(cwd: pathlib.Path, effects: Effects) -> str | Stop:
|
||||
return found.stdout.strip()
|
||||
|
||||
|
||||
def checkouts(root: str, effects: Effects) -> list[str]:
|
||||
def worktrees(root: str, effects: Effects) -> list[str]:
|
||||
found = [root]
|
||||
try:
|
||||
listing = effects.git(["worktree", "list", "--porcelain"], root)
|
||||
|
||||
@@ -4,7 +4,7 @@ import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.claude_code.catalog import catalog_models
|
||||
from loop_claude.claude_code.model_catalog import catalog_models
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.file_writes import replace_json
|
||||
@@ -18,17 +18,17 @@ class Models:
|
||||
worker: str
|
||||
|
||||
|
||||
def models_for(project_key: str, paths: Paths, env: typing.Mapping[str, str], effects: Effects) -> Models | Stop:
|
||||
def get_or_ask_models(project_key: str, paths: Paths, env: typing.Mapping[str, str], effects: Effects) -> Models | Stop:
|
||||
judge, worker = env.get("LOOP_CLAUDE_JUDGE_MODEL"), env.get("LOOP_CLAUDE_WORKER_MODEL")
|
||||
if judge and worker:
|
||||
return Models(judge, worker)
|
||||
chosen = saved_model(project_key, paths, effects)
|
||||
chosen = get_or_ask_model(project_key, paths, effects)
|
||||
if isinstance(chosen, Stop):
|
||||
return chosen
|
||||
return Models(judge or chosen, worker or chosen)
|
||||
|
||||
|
||||
def saved_model(project_key: str, paths: Paths, effects: Effects) -> str | Stop:
|
||||
def get_or_ask_model(project_key: str, paths: Paths, effects: Effects) -> str | Stop:
|
||||
saved = paths.models_file
|
||||
models = read_models_file(saved)
|
||||
if isinstance(models, Stop):
|
||||
+49
-38
@@ -19,7 +19,7 @@ from loop_claude.cycle.verdicts import Finished, Interrupt, Unfinished
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.loop import main, reload
|
||||
from loop_claude.project import checkout, models, premises
|
||||
from loop_claude.project import checkout, model_choice, premises
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
CWD = pathlib.Path("/c")
|
||||
@@ -145,7 +145,7 @@ class Cycles(unittest.TestCase):
|
||||
self.session = session.session_for("proj", self.paths)
|
||||
|
||||
def cycle(self, fake):
|
||||
return run.Cycle(effects=fake.effects(), models=models.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", 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"))
|
||||
@@ -228,19 +228,19 @@ class ModelPrompt(unittest.TestCase):
|
||||
OFFERED = [("claude-opus-5-5", "Opus 5.5"), ("claude-haiku-4-5", "Haiku 4.5")]
|
||||
|
||||
def test_reads_a_number_as_the_offered_model_and_anything_else_as_a_name(self):
|
||||
self.assertEqual(models.model_picked(" 2 ", self.OFFERED), "claude-haiku-4-5")
|
||||
self.assertEqual(models.model_picked("opus", self.OFFERED), "opus")
|
||||
self.assertEqual(models.model_picked("3", []), "3")
|
||||
self.assertEqual(models.model_picked("3", self.OFFERED), Failure("pick 1 to 2"))
|
||||
self.assertIsNone(models.model_picked(" ", self.OFFERED))
|
||||
self.assertEqual(model_choice.model_picked(" 2 ", self.OFFERED), "claude-haiku-4-5")
|
||||
self.assertEqual(model_choice.model_picked("opus", self.OFFERED), "opus")
|
||||
self.assertEqual(model_choice.model_picked("3", []), "3")
|
||||
self.assertEqual(model_choice.model_picked("3", self.OFFERED), Failure("pick 1 to 2"))
|
||||
self.assertIsNone(model_choice.model_picked(" ", self.OFFERED))
|
||||
|
||||
def test_asks_again_until_an_answer_picks_a_model(self):
|
||||
with tempfile.TemporaryDirectory() as empty:
|
||||
fake = FakeEffects(inputs=["", "my-model"])
|
||||
self.assertEqual(models.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), fake.effects()), "my-model")
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), fake.effects()), "my-model")
|
||||
self.assertEqual(len(fake.made("input")), 2)
|
||||
fake = FakeEffects(inputs=[EOFError()])
|
||||
self.assertEqual(models.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended"))
|
||||
self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended"))
|
||||
|
||||
|
||||
class WorkerArgs(unittest.TestCase):
|
||||
@@ -307,9 +307,9 @@ class PartLine(unittest.TestCase):
|
||||
|
||||
class Parse(unittest.TestCase):
|
||||
def test_yields_only_json_objects(self):
|
||||
self.assertEqual(entries.parse('{"type": "user"}'), {"type": "user"})
|
||||
self.assertIsNone(entries.parse("not json"))
|
||||
self.assertIsNone(entries.parse("[1, 2]"))
|
||||
self.assertEqual(entries.parse_entry('{"type": "user"}'), {"type": "user"})
|
||||
self.assertIsNone(entries.parse_entry("not json"))
|
||||
self.assertIsNone(entries.parse_entry("[1, 2]"))
|
||||
|
||||
|
||||
class MarkTrusted(unittest.TestCase):
|
||||
@@ -368,40 +368,51 @@ class LoopRuns(unittest.TestCase):
|
||||
|
||||
class ExitContract(unittest.TestCase):
|
||||
def test_every_exit_1_stop_has_its_clause_in_help(self):
|
||||
read, task, git, premises_ = "a transcript cannot be read or archived", "no task is given", "git cannot start or finds no checkout", "README.md holds no premises"
|
||||
models_, retries = "the models file cannot be read or written", "the worker or the judge fails three times running"
|
||||
# Per function, the --help clause of each Stop it returns with an exit code other than 0, 2 or 130, in source order.
|
||||
clauses = {
|
||||
("cycle/interrupt.py", "interrupt"): (read, read, "claude cannot start for an interrupt"),
|
||||
("cycle/retry.py", "retried"): (retries,),
|
||||
("cycle/run.py", "ask"): (read,),
|
||||
("cycle/run.py", "close"): (read, "a finished chunk's session cannot be deleted"),
|
||||
("cycle/run.py", "rule"): (read,),
|
||||
("cycle/run.py", "work"): ("claude leaves no transcript",),
|
||||
("loop/main.py", "loop_run_from"): (task, "a reload cannot read the cycle number, checkout root and task"),
|
||||
("loop/reload.py", "exec_if_edited"): ("python cannot start for a reload",),
|
||||
("project/checkout.py", "checkout_root"): (git, git),
|
||||
("project/models.py", "read_models_file"): (models_, models_),
|
||||
("project/models.py", "saved_model"): (models_,),
|
||||
("project/premises.py", "read_premises"): (premises_,) * 5,
|
||||
}
|
||||
read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "README.md holds no premises"
|
||||
models_ = "the models file cannot be read or written"
|
||||
# Each Stop with an exit code other than 0, 2 or 130, in source order, by the start of its reason, with its --help clause.
|
||||
clauses = [
|
||||
("cycle/interrupt.py", "interrupt", "entries.reason", read),
|
||||
("cycle/interrupt.py", "interrupt", "f'could not start claude for the interrupt:", "claude cannot start for an interrupt"),
|
||||
("cycle/interrupt.py", "interrupt", "f'could not tell whether you typed anything:", read),
|
||||
("cycle/retry.py", "retried", "f'the {who} failed three times running:", "the worker or the judge fails three times running"),
|
||||
("cycle/run.py", "work", "f'claude left no transcript for session", "claude leaves no transcript"),
|
||||
("cycle/run.py", "rule", "entries.reason", read),
|
||||
("cycle/run.py", "ask", "failure.reason", read),
|
||||
("cycle/run.py", "close", "failure.reason", read),
|
||||
("cycle/run.py", "close", "failure.reason", "a finished chunk's session cannot be deleted"),
|
||||
("loop/main.py", "loop_run_from", "__doc__.strip()", "no task is given"),
|
||||
("loop/main.py", "loop_run_from", "f'the reload cannot read the cycle number,", "a reload cannot read the cycle number, checkout root and task"),
|
||||
("loop/reload.py", "exec_if_edited", "f'could not reload loop-claude:", "python cannot start for a reload"),
|
||||
("project/checkout.py", "checkout_root", "f'could not start git:", git),
|
||||
("project/checkout.py", "checkout_root", "found.stderr.strip()", git),
|
||||
("project/model_choice.py", "get_or_ask_model", "f'could not save the model in", models_),
|
||||
("project/model_choice.py", "read_models_file", 'f"could not read {saved}: {getattr(', models_),
|
||||
("project/model_choice.py", "read_models_file", "f'could not read {saved}: not an object", models_),
|
||||
("project/premises.py", "read_premises", "f'README.md in {root}:", premises_),
|
||||
("project/premises.py", "read_premises", "f'README.md is not UTF-8", premises_),
|
||||
("project/premises.py", "read_premises", "f'README.md has no ##", premises_),
|
||||
("project/premises.py", "read_premises", "f'README.md has ## {name} more than once", premises_),
|
||||
("project/premises.py", "read_premises", "f'README.md has nothing under", premises_),
|
||||
]
|
||||
root = pathlib.Path(main.__file__).parents[1]
|
||||
found = {}
|
||||
found = []
|
||||
for path in sorted(root.rglob("*.py")):
|
||||
for function in ast.walk(ast.parse(path.read_text())):
|
||||
if isinstance(function, ast.FunctionDef):
|
||||
stops = [call for call in ast.walk(function) if isinstance(call, ast.Call) and getattr(call.func, "id", None) == "Stop" and not (isinstance(call.args[0], ast.Constant) and call.args[0].value in (0, 2, 130))]
|
||||
if stops:
|
||||
found[(str(path.relative_to(root)), function.name)] = len(stops)
|
||||
self.assertEqual(found, {site: len(said) for site, said in clauses.items()})
|
||||
functions = [node for node in ast.walk(ast.parse(path.read_text())) if isinstance(node, ast.FunctionDef)]
|
||||
stops = [(call.lineno, function.name, ast.unparse(call.args[1])) for function in functions for call in ast.walk(function) if isinstance(call, ast.Call) and getattr(call.func, "id", None) == "Stop" and not (isinstance(call.args[0], ast.Constant) and call.args[0].value in (0, 2, 130))]
|
||||
found += [(str(path.relative_to(root)), function, reason) for _, function, reason in sorted(stops)]
|
||||
self.assertEqual(len(found), len(clauses), found)
|
||||
for (path, function, reason), (want_path, want_function, reason_start, _) in zip(found, clauses):
|
||||
self.assertEqual((path, function), (want_path, want_function))
|
||||
self.assertTrue(reason.startswith(reason_start), f"{path} {function}: {reason}")
|
||||
help_exit_1 = main.__doc__[main.__doc__.index("Exit 1"):main.__doc__.index("Exit 2")]
|
||||
self.assertEqual([clause for said in clauses.values() for clause in said if f"- {clause}" not in help_exit_1], [])
|
||||
self.assertEqual([clause for *_, clause in clauses if f"- {clause}" not in help_exit_1], [])
|
||||
|
||||
|
||||
class Checkouts(unittest.TestCase):
|
||||
def test_lists_the_root_alone_when_git_cannot_start(self):
|
||||
fake = FakeEffects(git=[FileNotFoundError(2, "No such file or directory")])
|
||||
self.assertEqual(checkout.checkouts("/r", fake.effects()), ["/r"])
|
||||
self.assertEqual(checkout.worktrees("/r", fake.effects()), ["/r"])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
### Under the comprehension floor
|
||||
|
||||
The panels on `rebuild` at 8585257 and on PR #182 named these under Self-sufficiency and Locality, the two dimensions under the floor. Scores: `docs/decisions.md` → "comprehension floor".
|
||||
The 2026-10-02 panel on PR #187 named this under Self-sufficiency, the one dimension under the floor. Scores: `docs/decisions.md` → "comprehension floor".
|
||||
|
||||
- **Name `loop_claude`'s modules and words by what each holds.** The 2026-10-01 panel misread `formats.py` (it holds every Claude Code shape, `mark_trusted` and `models_in` included), `steps.py`, `outcome.py` and `human_needed.py`. "Project", "transcripts", "verdict" and "model" each name two or three things. Goal 4.1.
|
||||
- **State in `reload.py` why a loop reloads its own script, and tie each exit-1 clause of `--help` to the `Stop` that produces it.** Two seats found the reload's purpose nowhere in the code, and one could keep the exit contract true only by grepping every `Stop(1`. Name what a reload could not read, and its likely cause, in both `--help` and the reload's error: "loop run" is defined nowhere a reader looks. Goal 4.1.
|
||||
- **Make larv-review §3 readable without another file open.** 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. Goal 4.1.
|
||||
|
||||
### The rest
|
||||
|
||||
@@ -19,6 +18,7 @@ The panels on `rebuild` at 8585257 and on PR #182 named these under Self-suffici
|
||||
- **Make the small changes filed against the review's rules.** Goals 4.1 and 4.4.
|
||||
- Make the contributor a standing member of every project's audience. A project drops them only where its `## Audience` says maintainability does not matter. State that in `CLAUDE.md`'s goals-and-audience rule, and have larv-review's comprehension floor name the contributor as the reader it serves. The floor then gates every chunk while the contributor stands, and a project that drops them skips it.
|
||||
- **Clean up the rules, skills, agents, plan and decision log.** Goal 4.1.
|
||||
- `docs/decisions.md`: order the entries and the `AGENTS.md` index by one key.
|
||||
- `docs/decisions.md`: give the comprehension-floor and vocabulary entries a premise that has not expired. Both say "Valid until the next scoring run", and every run since has passed it. Put the floor's rule first and its runs' scores in a table.
|
||||
- `comprehension-panel`: cut the run history and the restated description. They carry nothing the instructions need.
|
||||
- `systems-architect.md`: cut the "one home" line, and break Reasonability Review's steps 4 and 5 into shorter points each.
|
||||
@@ -30,7 +30,16 @@ The panels on `rebuild` at 8585257 and on PR #182 named these under Self-suffici
|
||||
- Sort `worker_args`' flags and the globs in `catalog.py` and `session.py`.
|
||||
- Write `"bypassPermissions"` once for every claude `loop-claude` starts.
|
||||
- Keep the judge's evidence and model in each archived `.verdict.md`.
|
||||
- Move the test helpers `ROOT` and `readme_floor` out of `test_python_floor.py`, which two other tests import them from.
|
||||
- Move the test helpers `ROOT` and `readme_floor` out of `test_python_floor.py`, which two other tests import them from, and have `test_citations.py` use that `ROOT`.
|
||||
- **Make the small fixes filed by the 2026-10-02 principles audit against `bin/`.** Goal 4.1.
|
||||
- Have `Session` carry the project key, so `Cycle` cannot hold a key and a session for different projects.
|
||||
- Inject the black-box tests' sleep through `Effects.sleep`; today `SITECUSTOMIZE` swaps `time.sleep` in the child process.
|
||||
- Return a `Failure` from `replace_file` when removing the staged file fails too.
|
||||
- Tell a catalog file that cannot be read from no catalog: today the prompt says none is cached.
|
||||
- Sort `transcript_file`'s glob, and delete a session's files under every project folder that holds its id.
|
||||
- Give `decode_handed` its one type, `LoopRun`.
|
||||
- **Give each cycle phase one name across its state, step and event.** Today `Judging` runs `rule` and yields `Ruled`, and `Finishing` runs `close`, which also deletes the session, and yields `Archived`. Goal 4.1.
|
||||
- **Copy the transcript archive off the machine, or say in README how it is backed up.** It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost disk loses every unattended run's record. Goal 2.
|
||||
- **Inject output and storage into `Effects`, and test what each step prints.** `print` and `open` are called directly across `bin/loop_claude/`, so the stderr lines of the CLI contract can be checked only through the black-box tests. Goal 4.1.
|
||||
- **Read transcript and stream entries into typed values where they are read.** `transcript.read` and `run_worker` pass raw `dict`s, so about ten accessors in `entries.py` re-check shapes deep inside and mypy cannot check `render`, `human_turns` or `run_worker`. Goal 4.1.
|
||||
- **Measure test coverage in the suite, and fail on a drop.** Nothing measures it, so "Test coverage should not decline" cannot be held. Goal 4.1.
|
||||
@@ -39,7 +48,7 @@ The panels on `rebuild` at 8585257 and on PR #182 named these under Self-suffici
|
||||
- **Archive a finished chunk's subagent transcripts before `delete_session` removes them.** Today only `<id>.jsonl` is copied, so every reviewer's full run in an unattended chunk is lost. Goal 2.
|
||||
- **Enable the `claude-security` plugin in `settings.json`, or drop larv-review's full-scan row.** No machine has it enabled, so every chunk that fires the pass skips it. Goal 4.1.
|
||||
- **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** On this repo the frontend, REST and logging auditors each read the whole project to report "does not apply", and one 🟢 fix reruns ten whole-project reads. Goal 4.4.
|
||||
- **Give `settings.json`'s model one writer.** Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice. Goal 4.3.
|
||||
- **Give `settings.json`'s model one writer, and sort its keys.** Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice. Goal 4.3.
|
||||
- **Rewrite `statusline.sh` in Python, and test it.** It needs `jq` and GNU `date` on every machine, `eval`s jq output, has three near-identical usage blocks and no test. Goal 1.
|
||||
- **Say in `systems-architect.md` that a REST API's `/v1/` prefix is not versioning machinery to defer.** Its "defer the versioning story" can be read against `principles/rest-apis.md`, which requires the prefix from the start. Goal 4.3.
|
||||
- **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. Goal 4.2.
|
||||
|
||||
Reference in New Issue
Block a user