Merge pull request 'Run every tool's git through git_repo.git, with rule-hook's guards as an option' (#333) from item-114 into main
This commit was merged in pull request #333.
This commit is contained in:
+29
-7
@@ -1,21 +1,43 @@
|
||||
"""Run git, in the current directory or a given one, and read the checkout, its default branch and its files."""
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from failure import Failure
|
||||
|
||||
# A -c outranks the checkout's own config. Each transport gets its own line, since a config's protocol.<name>.allow outranks protocol.allow.
|
||||
GUARD_SETTINGS = [
|
||||
"core.fsmonitor=false",
|
||||
"log.showSignature=false",
|
||||
"protocol.allow=never",
|
||||
"protocol.ext.allow=never",
|
||||
"protocol.file.allow=never",
|
||||
"protocol.git.allow=never",
|
||||
"protocol.http.allow=never",
|
||||
"protocol.https.allow=never",
|
||||
"protocol.ssh.allow=never",
|
||||
]
|
||||
|
||||
def git(*args: str, cwd: str | None = None, timeout: float | None = None) -> str | Failure:
|
||||
"""What git printed, run in cwd, else in the current directory. A Failure where git cannot start, exits non-zero, prints text that is not UTF-8, or still runs after timeout seconds, which stops it."""
|
||||
|
||||
def git(*args: str, cwd: str | None = None, timeout: float | None = None, guarded: bool = False) -> str | Failure:
|
||||
"""What git printed, run in cwd, else in the current directory.
|
||||
|
||||
A Failure where git cannot start, exits non-zero, prints text that is not UTF-8, or still runs after timeout seconds, which stops it.
|
||||
guarded turns off the fsmonitor, the signature check, each transport GUARD_SETTINGS names and a partial clone's fetch of its missing objects. It is for a checkout whose config may name a program.
|
||||
"""
|
||||
command = " ".join(args)
|
||||
guards = [option for setting in GUARD_SETTINGS for option in ("-c", setting)] if guarded else []
|
||||
# GIT_NO_LAZY_FETCH needs git 2.44.
|
||||
env = {**os.environ, "GIT_NO_LAZY_FETCH": "1"} if guarded else None
|
||||
try:
|
||||
ran = subprocess.run(["git", *args], capture_output=True, cwd=cwd, encoding="utf-8", timeout=timeout)
|
||||
ran = subprocess.run(["git", *guards, *args], capture_output=True, cwd=cwd, encoding="utf-8", env=env, timeout=timeout)
|
||||
except UnicodeDecodeError as failure:
|
||||
return Failure(f"git {' '.join(args)} printed text that is not UTF-8: {failure}")
|
||||
return Failure(f"git {command} printed text that is not UTF-8: {failure}")
|
||||
except (OSError, ValueError) as failure:
|
||||
return Failure(f"git could not start: {failure}")
|
||||
return Failure(f"git {command} could not start: {failure}")
|
||||
except subprocess.TimeoutExpired:
|
||||
return Failure(f"git {' '.join(args)}: stopped after {timeout} s")
|
||||
return ran.stdout if ran.returncode == 0 else Failure(f"git {' '.join(args)}: {ran.stderr.strip()}")
|
||||
return Failure(f"git {command}: stopped after {timeout} s")
|
||||
return ran.stdout if ran.returncode == 0 else Failure(f"git {command}: {ran.stderr.strip()}")
|
||||
|
||||
|
||||
def top() -> str | Failure:
|
||||
|
||||
@@ -6,10 +6,19 @@ import termios
|
||||
import time
|
||||
import typing
|
||||
|
||||
from failure import Failure
|
||||
import git_repo
|
||||
|
||||
# Seconds before a Python script loop-claude runs is stopped, so a hung one, such as chunk-preflight, cannot hold the loop.
|
||||
PYTHON_TIMEOUT = 600
|
||||
|
||||
|
||||
class Git(typing.Protocol):
|
||||
"""Runs git in cwd, as git_repo.git does."""
|
||||
|
||||
def __call__(self, *args: str, cwd: str) -> str | Failure: ...
|
||||
|
||||
|
||||
class Streaming(typing.Protocol):
|
||||
"""A started claude whose stream-json lines arrive as it works."""
|
||||
|
||||
@@ -25,7 +34,7 @@ class Effects:
|
||||
# Drops what was typed on the terminal and not yet read.
|
||||
discard_typed: typing.Callable[[], None]
|
||||
execv: typing.Callable[[str, list[str]], None]
|
||||
git: typing.Callable[[list[str], str], subprocess.CompletedProcess[str]]
|
||||
git: Git
|
||||
input: typing.Callable[[str], str]
|
||||
local_time: typing.Callable[[float], str]
|
||||
now: typing.Callable[[], float]
|
||||
@@ -54,7 +63,7 @@ def system_effects() -> Effects:
|
||||
claude_on_terminal=lambda args, cwd, env: subprocess.run(["claude", *args], cwd=cwd, env={**os.environ, **env}).returncode,
|
||||
discard_typed=lambda: termios.tcflush(sys.stdin, termios.TCIFLUSH),
|
||||
execv=os.execv,
|
||||
git=lambda args, cwd: subprocess.run(["git", *args], capture_output=True, cwd=cwd, text=True),
|
||||
git=git_repo.git,
|
||||
input=input,
|
||||
local_time=lambda seconds: time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(seconds)),
|
||||
now=time.time,
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
def checkout_root(cwd: pathlib.Path, effects: Effects) -> str | Stop:
|
||||
try:
|
||||
found = effects.git(["rev-parse", "--show-toplevel"], str(cwd))
|
||||
except OSError as failure:
|
||||
return Stop(1, f"could not start git: {failure.strerror}")
|
||||
if found.returncode != 0:
|
||||
return Stop(1, found.stderr.strip())
|
||||
return found.stdout.strip()
|
||||
found = effects.git("rev-parse", "--show-toplevel", cwd=str(cwd))
|
||||
return Stop(1, found.reason) if isinstance(found, Failure) else found.strip()
|
||||
|
||||
|
||||
def worktrees(root: str, effects: Effects) -> list[str]:
|
||||
found = [root]
|
||||
try:
|
||||
listing = effects.git(["worktree", "list", "--porcelain"], root)
|
||||
except OSError:
|
||||
return found
|
||||
if listing.returncode == 0:
|
||||
found += [line.split(" ", 1)[1] for line in listing.stdout.splitlines() if line.startswith("worktree ")]
|
||||
return sorted(set(found))
|
||||
listing = effects.git("worktree", "list", "--porcelain", cwd=root)
|
||||
listed = [] if isinstance(listing, Failure) else [line.split(" ", 1)[1] for line in listing.splitlines() if line.startswith("worktree ")]
|
||||
return sorted({root, *listed})
|
||||
|
||||
@@ -327,7 +327,7 @@ class Premises(unittest.TestCase):
|
||||
(checkout.temp / "fake-bin" / "git").unlink()
|
||||
run = checkout.run([worker()])
|
||||
self.assertEqual((run.code, run.calls), (1, []))
|
||||
self.assertEqual(run.stderr.strip(), "could not start git: No such file or directory")
|
||||
self.assertTrue(run.stderr.startswith("git rev-parse --show-toplevel could not start: "), run.stderr)
|
||||
|
||||
def test_makes_no_worktree_for_a_readme_without_premises(self):
|
||||
checkout = Checkout(self)
|
||||
|
||||
@@ -64,7 +64,7 @@ class FakeEffects:
|
||||
claude_on_terminal=self.on_terminal_claude,
|
||||
discard_typed=lambda: self.calls.append(("discard_typed", None)),
|
||||
execv=self.execv,
|
||||
git=lambda args, cwd: self.answer("git", args),
|
||||
git=lambda *args, cwd: self.answer("git", list(args)),
|
||||
input=lambda prompt: self.answer("input", prompt),
|
||||
local_time=lambda seconds: f"<{seconds}>",
|
||||
now=lambda: NOW,
|
||||
@@ -233,7 +233,7 @@ class Cycles(unittest.TestCase):
|
||||
with open(session.transcript_file(self.session), "a") as handle:
|
||||
handle.write(json.dumps(human("the second")) + "\n")
|
||||
return 0
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("finished")], inputs=["/talk"], on_terminal_claude=[answer], git=[ran()])
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("finished")], inputs=["/talk"], on_terminal_claude=[answer], git=[""])
|
||||
cycle = dataclasses.replace(self.cycle(fake), anchor=Rung("claude-opus-5-5", "medium"), route=Route(Rung("claude-haiku-5-5", "max"), 163, 1, 5))
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertEqual(run.run_cycle(cycle).verdict, Finished("working"))
|
||||
@@ -329,7 +329,7 @@ class Cycles(unittest.TestCase):
|
||||
with open(session.transcript_file(self.session), "a") as handle:
|
||||
handle.write(json.dumps(human("the second")) + "\n")
|
||||
return 0
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("unfinished")], inputs=["/talk"], on_terminal_claude=[answer], git=[ran()])
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt"), judged("unfinished")], inputs=["/talk"], on_terminal_claude=[answer], git=[""])
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).verdict, Unfinished("working", entries_read=4))
|
||||
self.assertEqual(self.archived_outcomes(), ["Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n", "Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n\nJudge: judge-model\nWorker: worker-model\n"])
|
||||
@@ -454,7 +454,7 @@ class Cycles(unittest.TestCase):
|
||||
with open(session.transcript_file(self.session), "a") as handle:
|
||||
handle.write(json.dumps(human("cut")) + "\n")
|
||||
return 0
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt", release_ready=True), judged("finished")], on_terminal_claude=[answer], git=[ran()])
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("interrupt", release_ready=True), judged("finished")], on_terminal_claude=[answer], git=[""])
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).verdict, Finished("working"))
|
||||
self.assertEqual(fake.made("input"), [])
|
||||
@@ -595,7 +595,7 @@ class Interrupts(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
path = pathlib.Path(home, "t.jsonl")
|
||||
path.write_text(json.dumps(human("a")) + "\n")
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[ran()])
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[""])
|
||||
stop = interrupt.talk(home, uuid7(), Rung("m", "high"), str(path), paths.paths_from(pathlib.Path(home)), {}, fake.effects())
|
||||
self.assertEqual(fake.made("claude_on_terminal")[0][:4], ["--model", "m", "--effort", "high"])
|
||||
self.assertEqual(stop, Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed"))
|
||||
@@ -604,7 +604,7 @@ class Interrupts(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
path = pathlib.Path(home, "t.jsonl")
|
||||
path.write_text(json.dumps(human("a")) + "\n")
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[ran()])
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[""])
|
||||
handed = {"LOOP_CLAUDE_PROJECT_RUNG": "claude-opus-5-5 at medium effort", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort"}
|
||||
interrupt.talk(home, uuid7(), Rung("claude-haiku-5-5", "max"), str(path), paths.paths_from(pathlib.Path(home)), handed, fake.effects())
|
||||
self.assertEqual(fake.terminal_environments, [handed])
|
||||
@@ -646,7 +646,7 @@ class RoutingCheck(unittest.TestCase):
|
||||
|
||||
def test_hands_the_terminal_over_once_for_each_new_call(self):
|
||||
self.chunks(5, 4)
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[ran()])
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[""])
|
||||
stop, said = self.check(fake)
|
||||
self.assertIsNone(stop)
|
||||
call = "Explore subagents' reports took more of the worker's context than their searches would have."
|
||||
@@ -663,7 +663,7 @@ class RoutingCheck(unittest.TestCase):
|
||||
def test_stamps_the_figures_and_the_calls_raised_when_it_measures(self):
|
||||
self.chunks(5, 4)
|
||||
(self.root / "routing-calls-raised.md").write_text("# Routing calls raised\n\n- 2026-10-14T10:02:00Z Reset\n")
|
||||
self.check(FakeEffects(on_terminal_claude=[0], git=[ran()]))
|
||||
self.check(FakeEffects(on_terminal_claude=[0], git=[""]))
|
||||
figures = (self.root / "routing-figures.md").read_text()
|
||||
self.assertIn(f"Measured {utc(NOW)}, at cycle 20 across", figures)
|
||||
self.assertIn("that finished after the reset of 2026-10-14T10:02:00Z", figures)
|
||||
@@ -689,7 +689,7 @@ class RoutingCheck(unittest.TestCase):
|
||||
|
||||
def test_stops_when_claude_cannot_start_for_the_calls(self):
|
||||
self.chunks(5, 4)
|
||||
stop, _ = self.check(FakeEffects(on_terminal_claude=[OSError(2, "No such file or directory")], git=[ran()]))
|
||||
stop, _ = self.check(FakeEffects(on_terminal_claude=[OSError(2, "No such file or directory")], git=[""]))
|
||||
self.assertEqual(stop, Stop(1, "could not start claude for the routing calls: No such file or directory"))
|
||||
|
||||
@unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory")
|
||||
@@ -1459,8 +1459,7 @@ class ExitContract(unittest.TestCase):
|
||||
("loop/main.py", "loop_run_from", "1", 'f"the edited loop-claude cannot read the state', "a reload cannot read the state the running script handed it"),
|
||||
("loop/reload.py", "exec_if_edited", "1", "f'could not reload loop-claude:", "python cannot start for a reload"),
|
||||
("loop/routing_check.py", "raise_calls", "1", "f'could not start claude for the routing calls:", "claude cannot start for an interrupt"),
|
||||
("project/checkout.py", "checkout_root", "1", "f'could not start git:", git),
|
||||
("project/checkout.py", "checkout_root", "1", "found.stderr.strip()", git),
|
||||
("project/checkout.py", "checkout_root", "1", "found.reason", git),
|
||||
("project/model_choice.py", "get_or_ask_model", "1", "f'could not save the model in", models_),
|
||||
("project/model_choice.py", "read_models_file", "1", 'f"could not read {saved}: {getattr(', models_),
|
||||
("project/model_choice.py", "read_models_file", "1", "f'could not read {saved}: not an object", models_),
|
||||
@@ -1514,7 +1513,7 @@ class JudgeFailures(unittest.TestCase):
|
||||
|
||||
class Worktrees(unittest.TestCase):
|
||||
def test_lists_the_root_alone_when_git_cannot_start(self):
|
||||
fake = FakeEffects(git=[FileNotFoundError(2, "No such file or directory")])
|
||||
fake = FakeEffects(git=[Failure("git worktree list --porcelain could not start: [Errno 2] No such file or directory: 'git'")])
|
||||
self.assertEqual(checkout.worktrees("/r", fake.effects()), ["/r"])
|
||||
|
||||
|
||||
|
||||
+13
-21
@@ -25,19 +25,20 @@ single tracked file.
|
||||
Below the table it names:
|
||||
- each run it skipped because its commit is not in the checkout;
|
||||
- each run it could not score because its places name no measured unit, or every one;
|
||||
- each file left out of its run because it does not parse on this Python.
|
||||
- each file left out of its run because git's output for it is not UTF-8, because git cannot show
|
||||
it, or because it does not parse on this Python.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the history
|
||||
cannot be read, or no scoring run could be scored.
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, a tracked
|
||||
file's name is not UTF-8, the history cannot be read, or no scoring run could be scored.
|
||||
"""
|
||||
import pathlib
|
||||
import statistics
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from metric_bench.bench import bench, co_changed, medians, METRICS, RunScores, Score, tracked_places
|
||||
from comprehension_history import entries, Entry
|
||||
from failure import Failure
|
||||
from git_repo import git
|
||||
from metric_bench.python_units import measured, python_units, Unit
|
||||
|
||||
|
||||
@@ -66,7 +67,7 @@ def read_history(given: pathlib.Path | None) -> tuple[str, pathlib.Path, str] |
|
||||
"""The checkout that holds the history, the history's path and its text."""
|
||||
if given and not given.parent.is_dir():
|
||||
return Failure(f"could not read {given}: no folder {given.parent}")
|
||||
found = git(["rev-parse", "--show-toplevel"], str(given.parent) if given else None)
|
||||
found = git("rev-parse", "--show-toplevel", cwd=str(given.parent) if given else None)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
history = given or pathlib.Path(found.strip(), "docs", "comprehension-history.md")
|
||||
@@ -89,7 +90,7 @@ def bench_runs(text: str, top: str) -> tuple[list[tuple[str, RunScores]], list[s
|
||||
rows = []
|
||||
notes = []
|
||||
for run in scored_runs(entries(text)):
|
||||
if isinstance(missing := git(["cat-file", "-e", f"{run.commit}^{{commit}}"], top), Failure):
|
||||
if isinstance(missing := git("cat-file", "-e", f"{run.commit}^{{commit}}", cwd=top), Failure):
|
||||
notes.append(f"Skipped, its commit is not in {top}: {run.heading} ({missing.reason})")
|
||||
continue
|
||||
scored = run_scores(run, top)
|
||||
@@ -109,23 +110,22 @@ def noted(notes: list[str]) -> str:
|
||||
|
||||
|
||||
def run_scores(run: Entry, top: str) -> tuple[RunScores | None, list[str]] | Failure:
|
||||
"""The run's scores, and why each file that does not parse was left out."""
|
||||
listed = git(["ls-tree", "-r", "-z", "--name-only", run.commit], top)
|
||||
"""The run's scores, and why each file left out was: git could not show it as UTF-8, or it does not parse."""
|
||||
# A tracked name that is not UTF-8 fails the run rather than reading with its bytes replaced: every tool in bin/ but the status line, item 204's, reads git's output through git_repo.git's one contract.
|
||||
listed = git("ls-tree", "-r", "-z", "--name-only", run.commit, cwd=top)
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
tracked = list(filter(None, listed.split("\0")))
|
||||
units: list[Unit] = []
|
||||
unparsed = []
|
||||
for path in filter(measured, tracked):
|
||||
source = git(["show", f"{run.commit}:{path}"], top)
|
||||
if isinstance(source, Failure):
|
||||
return source
|
||||
found = python_units(path, source)
|
||||
source = git("show", f"{run.commit}:{path}", cwd=top)
|
||||
found = source if isinstance(source, Failure) else python_units(path, source)
|
||||
if isinstance(found, Failure):
|
||||
unparsed.append(found.reason)
|
||||
else:
|
||||
units += found
|
||||
log = git(["-c", "core.quotePath=false", "log", "--no-merges", "--format=tformat:@@", "--name-only", run.commit], top)
|
||||
log = git("-c", "core.quotePath=false", "log", "--no-merges", "--format=tformat:@@", "--name-only", run.commit, cwd=top)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
places, dropped = tracked_places(run.scored_places, tracked)
|
||||
@@ -147,14 +147,6 @@ def cell(score: Score) -> str:
|
||||
return "constant" if score.constant else f"AUC {score.auc:.2f}, top k {score.top_k:.2f}"
|
||||
|
||||
|
||||
def git(args: list[str], cwd: str | None) -> str | Failure:
|
||||
try:
|
||||
ran = subprocess.run(["git", *args], capture_output=True, cwd=cwd, encoding="utf-8", errors="replace")
|
||||
except OSError as failure:
|
||||
return Failure(f"could not start git: {failure.strerror}")
|
||||
return ran.stdout if ran.returncode == 0 else Failure(f"git {' '.join(args)}: {ran.stderr.strip()}")
|
||||
|
||||
|
||||
def failed(failure: Failure) -> int:
|
||||
print(failure.reason, file=sys.stderr)
|
||||
return 1
|
||||
|
||||
@@ -247,6 +247,19 @@ class BlackBox(unittest.TestCase):
|
||||
ran = self.run_tool(top)
|
||||
self.assertIn("Not scored, its places name no measured unit or every one: 2026-10-07T12:00:00Z, PR #0", ran.stdout)
|
||||
|
||||
def test_leaves_out_and_names_a_file_that_is_not_utf_8(self):
|
||||
top = self.project("")
|
||||
pathlib.Path(top, "b.py").write_bytes(b"# caf\xe9\n")
|
||||
env = isolated_env()
|
||||
subprocess.run(["git", "add", "b.py"], cwd=top, check=True, env=env)
|
||||
subprocess.run(["git", "commit", "-qm", "b"], cwd=top, check=True, env=env)
|
||||
commit = subprocess.run(["git", "rev-parse", "--short", "HEAD"], cwd=top, check=True, capture_output=True, text=True, env=env).stdout.strip()
|
||||
pathlib.Path(top, "docs", "comprehension-history.md").write_text(f"# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at {commit}\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(top)
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
self.assertIn("Left out of 2026-10-08T12:50:49Z, PR #1", ran.stdout)
|
||||
self.assertIn("b.py", ran.stdout.split("Left out of")[1])
|
||||
|
||||
def test_reads_the_checkout_that_holds_a_history_named_from_elsewhere(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(tempfile.gettempdir(), str(pathlib.Path(top, "docs", "comprehension-history.md")))
|
||||
|
||||
+11
-12
@@ -25,7 +25,6 @@ archive or the record cannot be read or written, or a figure in the record canno
|
||||
import dataclasses
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
@@ -33,6 +32,7 @@ from reading_cost.measure import Checkout, measure, Reading
|
||||
from failure import Failure
|
||||
from reading_cost.figures import figure, merged, readings_of, RECORD, RESET, trend, unheld
|
||||
from transcript_archive.read import finished_chunks, read_threads
|
||||
from git_repo import git
|
||||
from transcript_archive.location import project_archive
|
||||
from file_writes import replace_file
|
||||
from utc_stamp import utc
|
||||
@@ -112,18 +112,17 @@ def failed(failure: Failure) -> int:
|
||||
|
||||
|
||||
def located() -> Checkout | Failure:
|
||||
try:
|
||||
found = subprocess.run(["git", "rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir"], capture_output=True, text=True)
|
||||
if found.returncode != 0:
|
||||
return Failure(found.stderr.strip())
|
||||
top, common = found.stdout.splitlines()
|
||||
listed = subprocess.run(["git", "ls-files", "-z"], capture_output=True, cwd=top, text=True)
|
||||
except (OSError, ValueError) as failure:
|
||||
return Failure(f"could not find the checkout: {failure}")
|
||||
if listed.returncode != 0:
|
||||
return Failure(listed.stderr.strip())
|
||||
found = git("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir")
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
if len(lines := found.splitlines()) != 2:
|
||||
return Failure(f"git rev-parse printed {found!r}, not a checkout's top folder and git directory on two lines")
|
||||
top, common = lines
|
||||
listed = git("ls-files", "-z", cwd=top)
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
# The common dir is the main checkout's .git, whichever worktree runs this.
|
||||
return Checkout(top, str(pathlib.Path(common).parent), frozenset(filter(None, listed.stdout.split("\0"))))
|
||||
return Checkout(top, str(pathlib.Path(common).parent), frozenset(filter(None, listed.split("\0"))))
|
||||
|
||||
|
||||
def read_record(record: pathlib.Path) -> str | Failure:
|
||||
|
||||
@@ -15,7 +15,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
from transcript_archive.write import archive
|
||||
from reading_cost.measure import Checkout, Reading
|
||||
from failure import Failure
|
||||
from reading_cost import figures, measure
|
||||
from reading_cost import figures, main, measure
|
||||
from transcript_archive.read import finished_chunks, FinishedChunk
|
||||
from test_env import isolated_env
|
||||
from transcript_archive import outcomes
|
||||
@@ -160,5 +160,29 @@ class ReadingCostTool(unittest.TestCase):
|
||||
self.assertIn("not a git repository", ran.stderr)
|
||||
|
||||
|
||||
class Located(unittest.TestCase):
|
||||
def test_lists_the_whole_checkout_from_a_folder_inside_it(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
root = pathlib.Path(temp.name).resolve()
|
||||
(root / "sub").mkdir()
|
||||
(root / "a.txt").write_text("a")
|
||||
(root / "sub" / "b.txt").write_text("b")
|
||||
for args in (("init", "--quiet"), ("add", ".")):
|
||||
subprocess.run(["git", *args], check=True, cwd=root, env=isolated_env())
|
||||
with contextlib.chdir(root / "sub"):
|
||||
found = main.located()
|
||||
self.assertEqual(found, Checkout(str(root), str(root), frozenset({"a.txt", "sub/b.txt"})))
|
||||
|
||||
def test_fails_in_a_checkout_whose_path_holds_a_newline(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
root = pathlib.Path(temp.name, "a\nb")
|
||||
root.mkdir()
|
||||
subprocess.run(["git", "init", "--quiet"], check=True, cwd=root, env=isolated_env())
|
||||
with contextlib.chdir(root):
|
||||
self.assertIsInstance(main.located(), Failure)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -147,7 +147,7 @@ def chunk_rounds(reviewer: str, checkout: str, chunk: pathlib.Path) -> list[Roun
|
||||
|
||||
|
||||
def code_of(found: Round, effects: Effects) -> Code | Failure:
|
||||
"""Where, and at which commits, found's reviewer read the code, as the archive lets it be found again: the prompt's removed worktree, and the commits authored by then.
|
||||
"""Where, and at which commits, found's reviewer read the code, as the archive lets it be found again: the folder rounds.reviewed_path guesses from the prompt, and the commits authored by then.
|
||||
|
||||
Recording the reviewed commit at review time would need no such reading, but then no round archived before that change could be replayed. A wrong guess costs no rung: the reference reviewer, replayed on that code, finds fewer findings on record, and no rung is held to those.
|
||||
"""
|
||||
@@ -156,12 +156,12 @@ def code_of(found: Round, effects: Effects) -> Code | Failure:
|
||||
path = reviewed_path(found.prompt, found.root, os.path.exists)
|
||||
if path is None:
|
||||
return Failure("the prompt names neither one removed worktree nor the checkout")
|
||||
default = git(effects, found.root, "symbolic-ref", "--short", "refs/remotes/origin/HEAD")
|
||||
default = effects.git("symbolic-ref", "--short", "refs/remotes/origin/HEAD", cwd=found.root)
|
||||
if isinstance(default, Failure):
|
||||
return default
|
||||
default = default.strip().removeprefix("origin/")
|
||||
log = git(effects, found.root, "log", "--format=%H %at", f"refs/remotes/origin/{default}")
|
||||
main_line = git(effects, found.root, "log", "--first-parent", "--format=%H %at", f"refs/remotes/origin/{default}")
|
||||
log = effects.git("log", "--format=%H %at", f"refs/remotes/origin/{default}", cwd=found.root)
|
||||
main_line = effects.git("log", "--first-parent", "--format=%H %at", f"refs/remotes/origin/{default}", cwd=found.root)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
if isinstance(main_line, Failure):
|
||||
@@ -248,7 +248,7 @@ def clone_reviewed(found: Round, code: Code, clone: str, effects: Effects) -> Fa
|
||||
("-C", clone, "update-ref", f"refs/heads/{code.default}", code.base),
|
||||
("-C", clone, "checkout", "--quiet", *(("-B", found.branch) if found.branch and found.branch != code.default else ("--detach",)), code.reviewed),
|
||||
):
|
||||
if isinstance(ran := git(effects, found.root, *command), Failure):
|
||||
if isinstance(ran := effects.git(*command, cwd=found.root), Failure):
|
||||
return ran
|
||||
return None
|
||||
|
||||
@@ -270,11 +270,3 @@ def match(findings: tuple[str, ...], replay_report: str, root: str, rung: Rung,
|
||||
if not isinstance(numbers, list) or not all(isinstance(n, int) for n in numbers):
|
||||
return Failure(f"the match replied: {json.dumps(reply)}")
|
||||
return {n - 1 for n in numbers if 1 <= n <= len(findings)}
|
||||
|
||||
|
||||
def git(effects: Effects, cwd: str, *args: str) -> str | Failure:
|
||||
try:
|
||||
ran = effects.git(list(args), cwd)
|
||||
except OSError as failure:
|
||||
return Failure(f"git {' '.join(args)} could not start in {cwd}: {failure.strerror}")
|
||||
return ran.stdout if ran.returncode == 0 else Failure(f"git {' '.join(args)}: {ran.stderr.strip()}")
|
||||
|
||||
@@ -142,15 +142,6 @@ class Match(unittest.TestCase):
|
||||
self.assertIsInstance(self.run_match(json.dumps({"type": "result", "structured_output": output})), Failure)
|
||||
|
||||
|
||||
class Git(unittest.TestCase):
|
||||
def test_says_why_git_cannot_start_in_a_directory_that_is_gone(self):
|
||||
def gone(args, cwd):
|
||||
raise FileNotFoundError(2, "No such file or directory")
|
||||
|
||||
ran = main.git(dataclasses.replace(system_effects(), git=gone), "/code/gone", "log")
|
||||
self.assertEqual(ran, Failure("git log could not start in /code/gone: No such file or directory"))
|
||||
|
||||
|
||||
def unused(*_):
|
||||
raise AssertionError("not called")
|
||||
|
||||
|
||||
+4
-11
@@ -1,20 +1,13 @@
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
from failure import Failure
|
||||
|
||||
# A -c given here outranks the checkout's own config, which may allow one transport by name; GIT_NO_LAZY_FETCH needs git 2.44.
|
||||
GUARDS = [option for setting in ["core.fsmonitor=false", "log.showSignature=false", "protocol.allow=never", *(f"protocol.{name}.allow=never" for name in ("ext", "file", "git", "http", "https", "ssh"))] for option in ("-c", setting)]
|
||||
import git_repo
|
||||
|
||||
|
||||
def git(directory: str, *args: str) -> str | Failure:
|
||||
# The hook runs git in a checkout the call has not yet been allowed to touch, whose config could name a program: no fsmonitor, no signature check, and no fetch of a partial clone's missing objects through its transport.
|
||||
try:
|
||||
ran = subprocess.run(["git", *GUARDS, "-C", directory, *args], capture_output=True, env={**os.environ, "GIT_NO_LAZY_FETCH": "1"}, text=True)
|
||||
except OSError as failure:
|
||||
return Failure(f"git could not start: {failure}")
|
||||
return ran.stdout.strip() if ran.returncode == 0 else Failure(f"git {' '.join(args)}: {ran.stderr.strip()}")
|
||||
"""What git printed in directory, stripped, run guarded: the hook runs git in a checkout the call has not yet been allowed to touch."""
|
||||
ran = git_repo.git(*args, cwd=directory, guarded=True)
|
||||
return ran if isinstance(ran, Failure) else ran.strip()
|
||||
|
||||
|
||||
def existing(directory: str) -> str:
|
||||
|
||||
@@ -18,6 +18,7 @@ from test_env import isolated_env
|
||||
from model_routing import ladder
|
||||
from rule_hook.override_log import LogLine, parsed_entry, this_chunks
|
||||
from rule_hook.reviewer_rung import reviewer_breaches
|
||||
from rule_hook.git import git as rule_hook_git
|
||||
from model_routing.ladder import Rung
|
||||
from shell_command import simple_commands
|
||||
|
||||
@@ -288,6 +289,10 @@ class Hook(unittest.TestCase):
|
||||
git(self.repo, "commit", "-q", "--allow-empty", "-m", "base")
|
||||
git(self.repo, "checkout", "-q", "-b", "chunk")
|
||||
|
||||
def test_runs_git_guarded(self):
|
||||
git(self.repo, "config", "core.fsmonitor", "/bin/false")
|
||||
self.assertEqual(rule_hook_git(self.repo, "config", "core.fsmonitor"), "false")
|
||||
|
||||
def listed(self) -> str:
|
||||
return subprocess.run([str(HOOK), "overrides"], capture_output=True, check=True, cwd=self.repo, env=isolated_env(), text=True).stdout
|
||||
|
||||
|
||||
@@ -26,6 +26,51 @@ class Git(unittest.TestCase):
|
||||
self.assertIn("latin", done.reason)
|
||||
self.assertIn("UTF-8", done.reason)
|
||||
|
||||
def test_says_which_command_could_not_start_in_a_directory_that_is_gone(self):
|
||||
done = git_repo.git("log", cwd="/code/gone")
|
||||
self.assertIsInstance(done, Failure)
|
||||
self.assertTrue(done.reason.startswith("git log could not start: "), done.reason)
|
||||
self.assertIn("/code/gone", done.reason)
|
||||
|
||||
|
||||
class Guarded(unittest.TestCase):
|
||||
"""A checkout whose own config may name a program for git to run."""
|
||||
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.root = temp.name
|
||||
self.config("init", "--quiet")
|
||||
|
||||
def config(self, *args):
|
||||
subprocess.run(["git", *args], capture_output=True, check=True, cwd=self.root)
|
||||
|
||||
def test_runs_a_command_that_needs_no_transport(self):
|
||||
self.assertEqual(git_repo.git("rev-parse", "--is-inside-work-tree", cwd=self.root, guarded=True), "true\n")
|
||||
|
||||
def test_refuses_each_transport_the_checkout_allows_by_name(self):
|
||||
# Port 1 refuses a connection, so a transport let through fails without the refusal named.
|
||||
for name, url in (("ext", "ext::true"), ("file", f"file://{self.root}"), ("git", "git://127.0.0.1:1/x"), ("http", "http://127.0.0.1:1/x"), ("https", "https://127.0.0.1:1/x"), ("ssh", "ssh://127.0.0.1:1/x")):
|
||||
with self.subTest(name):
|
||||
self.config("config", f"protocol.{name}.allow", "always")
|
||||
done = git_repo.git("ls-remote", url, cwd=self.root, guarded=True)
|
||||
self.assertIsInstance(done, Failure)
|
||||
self.assertIn(f"transport '{name}' not allowed", done.reason)
|
||||
|
||||
def test_refuses_a_transport_it_does_not_name(self):
|
||||
done = git_repo.git("ls-remote", "ftp://127.0.0.1:1/x", cwd=self.root, guarded=True)
|
||||
self.assertIsInstance(done, Failure)
|
||||
self.assertIn("transport 'ftp' not allowed", done.reason)
|
||||
|
||||
def test_turns_off_the_fsmonitor_and_signature_check_the_checkout_turns_on(self):
|
||||
self.config("config", "core.fsmonitor", "/bin/false")
|
||||
self.config("config", "log.showSignature", "true")
|
||||
self.assertEqual(git_repo.git("config", "core.fsmonitor", cwd=self.root, guarded=True), "false\n")
|
||||
self.assertEqual(git_repo.git("config", "log.showSignature", cwd=self.root, guarded=True), "false\n")
|
||||
|
||||
def test_stops_a_partial_clone_fetching_its_missing_objects(self):
|
||||
self.assertEqual(git_repo.git("-c", "alias.lazy=!printenv GIT_NO_LAZY_FETCH", "lazy", cwd=self.root, guarded=True), "1\n")
|
||||
|
||||
|
||||
class StalledOrigin(unittest.TestCase):
|
||||
"""A checkout whose origin, run through git's ext transport, answers nothing for 10 s, and which records no default branch for it."""
|
||||
|
||||
@@ -2435,3 +2435,30 @@ Inherited architect, would restructure first:
|
||||
- `bin/loop_claude/cycle/judge.py:68` `Reply.bundled`: the taken-in L and E + I are bundled in the judge's reply and taken in on Route and in routing.taken_in
|
||||
- `bin/model_routing/route.py:86` `Route.__str__`: the archive's text format is written in two modules and parsed back by ROUTED, routing_figures, reading_cost, score_outcomes and judge_replay
|
||||
- `bin/todo_table.py:89` `OLD_SHAPE`: the old todo.md shape is the largest dead weight in rank_todo.py
|
||||
|
||||
## 2026-10-21T18:16:09Z, PR #333 at 7c7a398, against fda48ac
|
||||
|
||||
Ruling: better
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Mid A | same | better | better | better | better |
|
||||
| Inherited architect | better | better | better | better | better |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- Locality, Shape: `bin/git_repo.py:22` `git`: now the one git runner, with a guarded flag and GUARD_SETTINGS giving each transport its own line and saying why, where four more wrappers each had their own failure text and decoding
|
||||
- Shape, Locality: `bin/loop_claude/effects.py:16` `Git`: the effect returns str | Failure like everywhere else, removing checkout.py's try/except OSError and returncode handling
|
||||
- Shape: `bin/rule_hook/git.py:7` `git`: a dense one-line GUARDS comprehension became a thin call with guarded=True whose docstring says why
|
||||
- Self-sufficiency: `bin/rule_hook/rules.py:64` `OVERRIDE`: the new comment explains the lazy reason, the lookahead and the stripped -->
|
||||
- Self-sufficiency: `CLAUDE.md:108` "Vocabulary": now defines judge's records, paired ruling, place, scoring run and seat
|
||||
- Self-sufficiency: `bin/metric_bench/main.py:114` `run_scores`: a small pull the other way, the comment cites plan item 204
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- Navigation, Shape, Overall: `bin/git_repo.py:22` `git`: four places that started git with differently worded errors now go through one function, and the hardening is one named list instead of a one-line comprehension
|
||||
- Locality, Shape: `bin/loop_claude/effects.py:16` `Git`: Effects.git returns str | Failure, so checkout.py and review_replay drop their own exception and returncode conventions
|
||||
- Locality: `bin/metric_bench/main.py:112` `run_scores`: what the tool does on bad input is stated in its help, not hidden in a private wrapper's errors="replace"
|
||||
- Self-sufficiency: `CLAUDE.md:105` "Vocabulary": defines the comprehension terms the charter used without defining, and rules.py's OVERRIDE gains its explanation
|
||||
- Self-sufficiency: `bin/metric_bench/main.py:114` `run_scores`: a small cost, "item 204's" points to a plan item a code reader can't resolve
|
||||
- Locality: `bin/rule_hook/git.py:7` `git`: a small cost, the guards no longer sit beside the hook that needs them, though both docstrings say why
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
2026-09-20, lilleman. Serves goal 1. Across six projects scored with the four seats, Locality or Self-sufficiency was the lowest dimension at every seat and Navigation at none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats.
|
||||
|
||||
2026-10-15, lilleman: an item that lifts the lowest dimension scores G 9, since the lowest dimension caps the overall and lifting it is worth the most to the floor. PR #257's scoring run found Shape lowest, at 6.25. The Shape items are `todo.md` items 114, 124 and 125. When PR #283 replaces G, the chunk that ships it carries this rule into the new score.
|
||||
2026-10-15, lilleman: an item that lifts the lowest dimension scores G 9, since the lowest dimension caps the overall and lifting it is worth the most to the floor. PR #257's scoring run found Shape lowest, at 6.25. The Shape items left are `todo.md` items 124 and 125. When PR #283 replaces G, the chunk that ships it carries this rule into the new score.
|
||||
|
||||
2026-10-16, PR #283: such an item moves each goal it cites by 9, in place of G 9. lilleman, answering that PR's review: such items compete with the others like any item, so they no longer rank first.
|
||||
|
||||
|
||||
@@ -681,3 +681,7 @@ Read most (opens and searches):
|
||||
## Reading cost, chunk 299b4aa74f32, finished 2026-10-21T16:53:41Z
|
||||
|
||||
250555 new input tokens before the first commit.
|
||||
|
||||
## Reading cost, chunk 5a330b55cc88, finished 2026-10-21T17:22:55Z
|
||||
|
||||
230039 new input tokens before the first commit.
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
|
||||
`Bar = 0.1`
|
||||
|
||||
`Next ID = 204`
|
||||
`Next ID = 206`
|
||||
|
||||
## Items
|
||||
|
||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 114 | 0.3.0 | | decision | **Run git through `git_repo.py` in `rule_hook`, `metric_bench`, `reading_cost`, `review_replay` and `loop_claude`, keeping rule-hook's guards as an option, so one module owns how a tool runs git.** | 3 | 1 | 3 | 5 | 4 | code health by 9, 1.4 by 9 | 32.9 |
|
||||
| 120 | 0.3.0 | | | **Rewrite larv-review §3's "Round cap" and "Re-entry" as one table that says, for each kind of fix, which passes rerun and what a round reviews.** | 2 | 2 | 3 | 5 | 4 | code health by 6, 1.2 by 6, 1.4 by 6 | 26.0 |
|
||||
| 21 | 0.3.0 | | defect | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 3 | 7 | 3 | 2 by 5 | 22.5 |
|
||||
| 29 | 0.3.0 | | | **Make the contributor a standing member of every project's audience, unless its README voids code health.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 5, 1.4 by 5 | 13.7 |
|
||||
@@ -37,11 +36,13 @@
|
||||
| 6 | 0.4.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 |
|
||||
| 66 | 0.4.0 | | principle | **Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 |
|
||||
| 1 | 0.5.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 |
|
||||
| 204 | 0.5.0 | | | **Read the status line's branch through `git_repo.git`, so no tool in `bin/` runs git outside it.** | 1 | 2 | 1 | 2 | 1 | code health by 3 | 21.6 |
|
||||
| 125 | 0.5.0 | | decision | **Give "record", "outcome" and "places" one meaning each across `bin/`, and rename `bin/larv_review/git.py` by what it holds.** | 3 | 1 | 3 | 5 | 5 | code health by 9, 1.4 by 9 | 19.7 |
|
||||
| 172 | 0.5.0 | | | **Name the project's rung `project` across `bin/loop_claude`, in place of `anchor`, as `bin/model_routing/ladder.py` names it.** | 2 | 1 | 3 | 4 | 3 | code health by 3, 1.4 by 3 | 16.5 |
|
||||
| 190 | 0.5.0 | | | **Rewrite the `docs/decisions.md` entries `todo.md: one table …` and `loop-claude: a judge decides …` as the current state, so a reader no longer replays superseded paragraphs to learn what holds.** | 2 | 2 | 1 | 3 | 3 | code health by 3, 1.4 by 2 | 15.5 |
|
||||
| 82 | 0.5.0 | | principle | **Sort `AGENTS.md`'s decision titles and `docs/decisions.md`'s entries by title.** | 2 | 2 | 1 | 3 | 4 | code health by 4, 1.4 by 4 | 14.6 |
|
||||
| 137 | 0.5.0 | | | **Archive a chunk's route as a record loop-claude reads back field by field, in place of the `Worker:` prose `ROUTED` parses, and name `stepped` and the judge's `bundled` by what they do.** | 4 | 2 | 3 | 7 | 4 | code health by 4, 1.4 by 4 | 14.6 |
|
||||
| 205 | 0.5.0 | | | **Rewrite the comprehension-floor decision's 2026-10-15 paragraph as the rule that holds, so it no longer scores G 9 after PR #283 replaced G.** | 1 | 2 | 1 | 2 | 1 | code health by 2 | 14.4 |
|
||||
| 123 | 0.5.0 | | | **Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.** | 2 | 1 | 2 | 3 | 5 | code health by 5, 1.4 by 5 | 11.0 |
|
||||
| 124 | 0.5.0 | | decision | **Group the shared modules at `bin/`'s root into packages named by purpose, so the root holds only launchers and stand-alone tools.** | 4 | 1 | 3 | 6 | 6 | code health by 9, 1.4 by 9 | 11.0 |
|
||||
| 132 | 0.5.0 | | | **Lift each dimension still under the comprehension floor after release 0.2.0's scoring run, at the places that run names.** | 3 | 2 | 2 | 5 | 5 | code health by 5, 1.4 by 5 | 11.0 |
|
||||
@@ -92,12 +93,6 @@
|
||||
|
||||
## Details
|
||||
|
||||
### 114. Run git through `git_repo.py` in `rule_hook`, `metric_bench`, `reading_cost`, `review_replay` and `loop_claude`, keeping rule-hook's guards as an option, so one module owns how a tool runs git.
|
||||
|
||||
Shape is the lowest dimension, so this item moves code health by 9, per `docs/decisions.md` → `larv-review: within a chunk lifting a project towards the comprehension floor, work on the project's lowest-scoring dimension comes first, and the floor doesn't block anything`.
|
||||
|
||||
The comprehension seats on PR #254 found five git runners with different contracts: `git_repo.git`, `rule_hook/git.py`'s guarded one, `metric_bench/main.py`'s, `reading_cost/main.py`'s `located` and `loop_claude/effects.py`'s. PR #276 added a sixth, `review_replay/main.py`'s `git`. The inherited architect of PR #257's scoring run named `bin/git_repo.py:8` `git` again. Make `git_repo.git` easier to read.
|
||||
|
||||
### 120. Rewrite larv-review §3's "Round cap" and "Re-entry" as one table that says, for each kind of fix, which passes rerun and what a round reviews.
|
||||
|
||||
Junior A, Mid A and the maintainability senior of PR #257's scoring run named `skills/larv-review/SKILL.md:63` "Round cap" hardest, two of them with `:74` "Re-entry"; the inherited architect named `:71` "Cap". A reader holds the trigger table's "a fix, only where …" clauses, the cap, later rounds' scope and the prose, 🟢 and ❓ exceptions at once. Junior A could not say what a fix to a stability 🟡 that also touches a comment reruns. Make those sections easier to read.
|
||||
@@ -200,6 +195,10 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost
|
||||
|
||||
The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3).
|
||||
|
||||
### 204. Read the status line's branch through `git_repo.git`, so no tool in `bin/` runs git outside it.
|
||||
|
||||
`bin/statusline.py`'s `current_branch` runs git with its own contract: errors replaced, stderr dropped, no Failure. Every other tool in `bin/` runs git through `bin/git_repo.py`'s `git`; `workflow-bench/` runs git its own way on purpose. Keep the status line showing no branch where git fails.
|
||||
|
||||
### 125. Give "record", "outcome" and "places" one meaning each across `bin/`, and rename `bin/larv_review/git.py` by what it holds.
|
||||
|
||||
Shape is the lowest dimension, so this item moves code health by 9, per `docs/decisions.md` → `larv-review: within a chunk lifting a project towards the comprehension floor, work on the project's lowest-scoring dimension comes first, and the floor doesn't block anything`.
|
||||
@@ -222,6 +221,10 @@ Found by the prose review of PR #312, which judged both entries to read as amend
|
||||
|
||||
PR #262's paired ruling found the project reads worse: a rerun resumes on its rung only by parsing `Rung.__str__`'s and `Route.__str__`'s wording back with `bin/loop_claude/routing.py`'s `ROUTED`, a string contract over four files, where a reword silently routes afresh. Write the route as a structured line, such as JSON after `Worker:`, that `transcript_archive` reads into fields. `stepped` both raises to a bundled item's rung and counts towards a one-rung step; `Reply.bundled` names neither L nor highest. Make `bin/loop_claude/loop/main.py`'s `run_loop` easier to read where it threads the route. The structured line must keep the escalation's mark, archived today as `escalated at transcript entry N`: without it, a trigger that already stepped the worker could step it again.
|
||||
|
||||
### 205. Rewrite the comprehension-floor decision's 2026-10-15 paragraph as the rule that holds, so it no longer scores G 9 after PR #283 replaced G.
|
||||
|
||||
`docs/decisions.md` → `larv-review: within a chunk lifting a project towards the comprehension floor, …`: its 2026-10-15 paragraph says such an item scores G 9 and that PR #283 will replace G; the next paragraph says PR #283 did. A reader replays both to learn the rule. Item 190 rewrites two other entries this way.
|
||||
|
||||
### 123. Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.
|
||||
|
||||
Three seats of PR #257's scoring run named `bin/comprehension_history.py:106` `latest_places`; the logic it rests on is `:114` `worse_places` and `:126` `worse_votes`. They regex the markdown the module writes. `worse_votes` keeps a seat's first row through `setdefault`, because the votes table comes first. `worse_places` recovers the seat with `label.split(",")[0]`. `Entry` still holds scoring seats' places for rulings recorded before PR #255. Make these functions easier to read.
|
||||
@@ -432,7 +435,7 @@ The key names the project's session, archive folder and models entry. `project_k
|
||||
|
||||
### 155. Lower the reading cost of the files a chunk reads most before its first commit.
|
||||
|
||||
`bin/reading-cost` on 2026-10-21: the median of the last 5 chunks is 163,028 new input tokens before their first commit, up from 133,110 for the 5 before them. Read most over the last 5, by opens and searches: `rules/decisions.md` 1. The chunk that ships this item runs `bin/reading-cost --reset`.
|
||||
`bin/reading-cost` on 2026-10-21: the median of the last 5 chunks is 230,039 new input tokens before their first commit, up from 115,559 for the 5 before them. Read most over the last 5, by opens and searches: `rules/decisions.md` 1. The chunk that ships this item runs `bin/reading-cost --reset`.
|
||||
|
||||
### 51. Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user