Name each file of the setup as the setup's, and a config's as setup:<path>
CI / tests (pull_request) Successful in 4m42s

This commit is contained in:
2026-12-04 04:23:17 +01:00
parent eff57c1dfd
commit 6dd2787e7b
41 changed files with 220 additions and 156 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ FINISHED_RULES = (
"finished=true when the chunk is complete: merged, or nothing remains that the worker could do on "
"its own. Even then, it is finished only once {answers_recorded}.\n\n"
"An answer counts as recorded where the premises or the records above already hold it, the human's rules "
"(~/.claude/CLAUDE.md, ~/.claude/rules/, the project's review standards, each headed by its path) included. "
"(the setup's CLAUDE.md, the setup's rules/, the project's review standards, each headed by its path) included. "
"It also counts where the transcript shows the worker writing it into {answer_destinations}, "
"but not into one of the human's rules.\n\n"
"finished=false when work remains that a further run can "
+1 -1
View File
@@ -274,7 +274,7 @@ class ACycleOfAChunkWithoutARepo(BuildEpicTest):
self.description = DESCRIPTION + "\n## Scoring\nE + I, bar 4.\n\n## Decisions\n### Merges squash\nAlways.\n"
(self.home / ".local" / "share" / "build-release" / "claude-home").mkdir(parents=True)
(self.home / ".local" / "share" / "build-release" / "claude-home" / "CLAUDE.md").write_text("# Global\n", encoding="utf-8")
self.assertEqual(self.cycle().records, "From the epic ABC-12's description, ## Scoring:\nE + I, bar 4.\n\nFrom the epic ABC-12's description, ## Decisions:\n### Merges squash\nAlways.\n\nFrom ~/.claude/CLAUDE.md:\n# Global")
self.assertEqual(self.cycle().records, "From the epic ABC-12's description, ## Scoring:\nE + I, bar 4.\n\nFrom the epic ABC-12's description, ## Decisions:\n### Merges squash\nAlways.\n\nFrom the setup's CLAUDE.md:\n# Global")
def test_stops_where_a_section_of_the_epics_records_cannot_be_read(self) -> None:
self.description = DESCRIPTION + "\n## Scoring\nA.\n\n## Scoring\nB.\n"
+1 -1
View File
@@ -181,7 +181,7 @@ Exit 1, saying why, when:
- a chunk's window cannot be started, as when the project's config cannot be read, or the tmux
session runs another checkout's chunks
- the tmux session cannot be put on the terminal
- the goals file, or AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/*.md or
- the goals file, or AGENTS.md, docs/decisions.md, the setup's CLAUDE.md, the setup's rules/*.md or
the project's review standards where they exist, cannot be read or is not UTF-8
- no config names the checkout, its config cannot be read, or the goals file holds no premises
- the models file cannot be read or written
+1 -1
View File
@@ -472,7 +472,7 @@ class Cycles(unittest.TestCase):
self.assertIn("as the work remaining:\n\n> started\n\n", 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\n\nFrom ~/.claude/CLAUDE.md:\n# Global instructions", run.calls[1]["stdin"])
self.assertIn("From docs/decisions.md:\n# Decisions\n\nFrom the setup's CLAUDE.md:\n# Global instructions", 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"])
+8 -5
View File
@@ -1,10 +1,10 @@
from collections.abc import Mapping
import pathlib
from loop_state.paths import CLAUDE_HOME
from failure import Failure
from project_config.main import located
from chunk_driver.project.text_file import read_utf8
from loop_state.paths import RELEASE_ROOT
from record_store.stores import store
# The records the judge reads beside the premises, by the name that heads each, with the setting in the project's config that places it; then the human's rules below.
@@ -17,7 +17,9 @@ HUMAN_RULES_FILE = "CLAUDE.md"
HUMAN_RULE_DIR = "rules"
# How the judge's prompt names the records above, in the order it reads them.
RECORDS_NAMED = "the project's working rules and decisions, then the human's rules for every project"
HUMAN_RULE_NAMES = (f"~/{CLAUDE_HOME}/{HUMAN_RULES_FILE}", f"~/{CLAUDE_HOME}/{HUMAN_RULE_DIR}/", "the project's review standards")
# How prose names a file of the setup wherever its clone lies: the setup's CLAUDE.md → "Vocabulary", "setup".
SETUPS = "the setup's"
HUMAN_RULE_NAMES = (f"{SETUPS} {HUMAN_RULES_FILE}", f"{SETUPS} {HUMAN_RULE_DIR}/", "the project's review standards")
CONSEQUENCE = "the judge cannot read the records"
@@ -55,7 +57,8 @@ def file_text(path: pathlib.Path) -> str | Failure:
def named(rule: pathlib.Path, home: pathlib.Path, claude_dir: pathlib.Path) -> str:
"""rule's path as the human writes it: under ~/.claude, or ~/ for the rest of home, or else in full."""
if rule.is_relative_to(claude_dir):
return f"~/{CLAUDE_HOME}/{rule.relative_to(claude_dir)}"
"""rule's path as the human writes it: as the setup's where it lies in claude_dir, the loop's Claude home, or in the clone, or ~/ for the rest of home, or else in full."""
for setup in (claude_dir, RELEASE_ROOT):
if rule.is_relative_to(setup):
return f"{SETUPS} {rule.relative_to(setup)}"
return f"~/{rule.relative_to(home)}" if rule.is_relative_to(home) else str(rule)
+22 -14
View File
@@ -9,53 +9,61 @@ from project_config.doubles import configured
from failure import Failure
from agent_cycle import judge
from chunk_driver.project import records
from loop_state.paths import RELEASE_ROOT
class Records(unittest.TestCase):
def test_heads_each_record_by_its_name_the_humans_rules_last(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
claude_md = pathlib.Path(root, "home", "setup", "CLAUDE.md")
config = configured(self, pathlib.Path(root), home=claude_md.parents[1]) / "config.toml"
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "")
claude_md.parent.mkdir(parents=True)
claude_md.write_text("# Global\n")
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "From ~/.claude/CLAUDE.md:\n# Global")
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "From the setup's CLAUDE.md:\n# Global")
pathlib.Path(root, "docs").mkdir()
pathlib.Path(root, "docs", "decisions.md").write_text("# Decisions\n")
pathlib.Path(root, "AGENTS.md").write_text("\n# Rules\n")
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global")
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom the setup's CLAUDE.md:\n# Global")
pathlib.Path(claude_md.parent, "rules").mkdir()
pathlib.Path(claude_md.parent, "rules", "todo-items.md").write_text("# Todo\n")
pathlib.Path(claude_md.parent, "rules", "goals-and-audience.md").write_text("# Goals\n")
pathlib.Path(claude_md.parent, "rules", "notes.txt").write_text("not a rule\n")
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards").mkdir(parents=True)
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/goals-and-audience.md:\n# Goals\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments"))
config.write_text(config.read_text().replace('"~/.claude/skills/larv-review/standards"', '"~/review-standards"'))
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith("From the setup's CLAUDE.md:\n# Global\n\nFrom the setup's rules/goals-and-audience.md:\n# Goals\n\nFrom the setup's rules/todo-items.md:\n# Todo\n\nFrom the setup's skills/larv-review/standards/comments.md:\n# Comments"))
config.write_text(config.read_text().replace('"~/setup/skills/larv-review/standards"', '"~/review-standards"'))
pathlib.Path(claude_md.parents[1], "review-standards").mkdir()
pathlib.Path(claude_md.parents[1], "review-standards", "quality.md").write_text("# Ours\n")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith("From ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/review-standards/quality.md:\n# Ours"), "the config's standards folder replaces the default")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith("From the setup's rules/todo-items.md:\n# Todo\n\nFrom ~/review-standards/quality.md:\n# Ours"), "the config's standards folder replaces the default")
config.write_text(config.read_text().replace('"~/review-standards"', f'"{root}/standards"'))
pathlib.Path(root, "standards").mkdir()
pathlib.Path(root, "standards", "quality.md").write_text("# Elsewhere\n")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).endswith(f"From {root}/standards/quality.md:\n# Elsewhere"), "a folder outside home is named in full")
config.write_text(config.read_text().replace('"checkout:AGENTS.md"', '"checkout:docs/decisions.md"'))
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From AGENTS.md and docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global"), "a file the config names for two records appears once")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From AGENTS.md and docs/decisions.md:\n# Decisions\n\nFrom the setup's CLAUDE.md:\n# Global"), "a file the config names for two records appears once")
config.write_text(config.read_text().replace('"checkout:docs/decisions.md"', '"checkout:AGENTS.md"', 1))
config.write_text(config.read_text().replace('"checkout:AGENTS.md"', '"folder:AGENTS.md"').replace('"checkout:docs/decisions.md"', '"folder:log/decisions.md"'))
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From ~/.claude/CLAUDE.md:\n# Global"), "the checkout's AGENTS.md and docs/decisions.md are its owners'")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From the setup's CLAUDE.md:\n# Global"), "the checkout's AGENTS.md and docs/decisions.md are its owners'")
pathlib.Path(config.parent, "log").mkdir()
pathlib.Path(config.parent, "log", "decisions.md").write_text("# Ours\n")
pathlib.Path(config.parent, "AGENTS.md").write_text("# Our rules\n")
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From AGENTS.md:\n# Our rules\n\nFrom docs/decisions.md:\n# Ours\n\nFrom ~/.claude/CLAUDE.md:\n# Global"))
self.assertTrue(records.read_records(root, claude_md.parents[1], {}, claude_md.parent).startswith("From AGENTS.md:\n# Our rules\n\nFrom docs/decisions.md:\n# Ours\n\nFrom the setup's CLAUDE.md:\n# Global"))
config.unlink()
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"no config names the checkout {root}: write {claude_md.parents[1]}/.config/build-release/<key>/config.toml, as `project-config --help` shows - the judge cannot read the records."))
def test_names_a_file_of_the_setup_alike_in_the_loops_home_and_in_the_clone(self):
home = pathlib.Path("/home/kim")
for rule in (home / "share" / "claude-home" / "rules" / "todo-items.md", RELEASE_ROOT / "rules" / "todo-items.md"):
self.assertEqual(records.named(rule, home, home / "share" / "claude-home"), "the setup's rules/todo-items.md")
self.assertEqual(records.named(home / "standards" / "prose.md", home, home / "share" / "claude-home"), "~/standards/prose.md")
self.assertEqual(records.named(pathlib.Path("/srv/standards/prose.md"), home, home / "share" / "claude-home"), "/srv/standards/prose.md")
def test_puts_the_records_handed_in_first_and_reads_only_the_humans_rules_without_a_checkout(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
claude_md = pathlib.Path(root, "home", "setup", "CLAUDE.md")
configured(self, pathlib.Path(root), home=claude_md.parents[1])
claude_md.parent.mkdir(parents=True)
claude_md.write_text("# Global\n")
@@ -65,12 +73,12 @@ class Records(unittest.TestCase):
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
pathlib.Path(root, "AGENTS.md").write_text("# Rules\n")
first = (("the epic ABC-1's description, ## Decisions", "Squash.\n"), ("the epic ABC-1's description, ## Scoring", " \n"))
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom AGENTS.md:\n# Rules\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments")
self.assertEqual(records.read_records(None, claude_md.parents[1], {}, claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo")
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom AGENTS.md:\n# Rules\n\nFrom the setup's CLAUDE.md:\n# Global\n\nFrom the setup's rules/todo-items.md:\n# Todo\n\nFrom the setup's skills/larv-review/standards/comments.md:\n# Comments")
self.assertEqual(records.read_records(None, claude_md.parents[1], {}, claude_md.parent, first), "From the epic ABC-1's description, ## Decisions:\nSquash.\n\nFrom the setup's CLAUDE.md:\n# Global\n\nFrom the setup's rules/todo-items.md:\n# Todo")
def test_stops_on_a_record_it_cannot_read(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
claude_md = pathlib.Path(root, "home", "setup", "CLAUDE.md")
configured(self, pathlib.Path(root), home=claude_md.parents[1])
claude_md.mkdir(parents=True)
self.assertEqual(records.read_records(root, claude_md.parents[1], {}, claude_md.parent), Failure(f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records."))
@@ -82,7 +90,7 @@ class Records(unittest.TestCase):
def test_stops_on_a_rule_it_cannot_read(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
claude_md = pathlib.Path(root, "home", "setup", "CLAUDE.md")
configured(self, pathlib.Path(root), home=claude_md.parents[1])
rules = pathlib.Path(claude_md.parent, "rules")
rules.mkdir(parents=True)
+2 -2
View File
@@ -13,8 +13,8 @@ import typing
from failure import Failure
from text_files.file_writes import replace_file
# What the home links to in the clone: the instruction files Claude Code reads from its home.
LINKED = ("CLAUDE.md", "agents", "rules", "skills")
# What the home links to in the clone: the instruction files Claude Code reads from its home, and the two folders those files name beside them. So a claude opens every file of the setup in its own home: the setup's CLAUDE.md → "Vocabulary", "setup".
LINKED = ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills")
# Stands for the clone's folder in the clone's settings.json. Every value that holds it is a shell command, such as a hook's.
CLONE = "{clone}"
# The file in the home that names the clone and the commit the home was built from.
+3 -3
View File
@@ -25,7 +25,7 @@ class Home(unittest.TestCase):
self.temp = pathlib.Path(tempfile.mkdtemp())
self.addCleanup(subprocess.run, ["rm", "-rf", str(self.temp)])
self.clone = self.temp / "the clone"
for folder in ("agents", "rules", "skills"):
for folder in ("agents", "bin", "principles", "rules", "skills"):
(self.clone / folder).mkdir(parents=True)
(self.clone / "CLAUDE.md").write_text("# The setup's rules\n", encoding="utf-8")
(self.clone / "settings.json").write_text(json.dumps(SETTINGS), encoding="utf-8")
@@ -49,10 +49,10 @@ class Home(unittest.TestCase):
read: dict[str, object] = json.loads((self.home / "settings.json").read_text(encoding="utf-8"))
return read
def test_a_new_home_links_the_clones_instruction_files(self) -> None:
def test_a_new_home_links_each_folder_of_the_setup_that_an_instruction_file_names(self) -> None:
self.assertIsNone(self.unready())
for name in ("CLAUDE.md", "agents", "rules", "skills"):
for name in ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills"):
self.assertTrue((self.home / name).is_symlink(), name)
self.assertEqual((self.home / name).resolve(), (self.clone / name).resolve())
self.assertEqual((self.home / "CLAUDE.md").read_text(encoding="utf-8"), "# The setup's rules\n")
+1 -1
View File
@@ -174,7 +174,7 @@ class Main(unittest.TestCase):
self.assertIn("The reference judge, claude-opus-5-5 at xhigh effort, reproduced 2.", out)
self.assertIn("claude-fable-5-2 at low effort, a rung a review climbs to, missed 0.\nclaude-fable-5-2 at medium effort, a rung a review climbs to, missed 1:", out)
self.assertTrue(out.endswith("returns every verdict the reference judge reproduces: claude-opus-5-5 at medium effort\n"))
for said in ("The task the worker was given:\nDo it.", "1. Ship.", "From ~/.claude/CLAUDE.md:\nBe kind."):
for said in ("The task the worker was given:\nDo it.", "1. Ship.", "From the setup's CLAUDE.md:\nBe kind."):
with self.subTest(said=said):
self.assertIn(said, self.prompts[0])
# The premises head the prompt and the records follow them.
+7 -4
View File
@@ -16,19 +16,22 @@ comprehension-history = "folder:docs/comprehension-history.md"
reading-cost = "folder:docs/reading-cost.md"
changelog = "checkout:CHANGELOG.md"
goals-and-audience = "folder:goals.md"
principles = "~/.claude/principles"
standards = "~/.claude/skills/larv-review/standards"
principles = "setup:principles"
standards = "setup:skills/larv-review/standards"
"""
JIRA_PLAN = "jira:https://acme.atlassian.net/browse/ABC-12"
JIRA_SCORING = 'jira-score-formula = "100 * V / (2**S + 8)"\njira-score-bar = 1\n'
# Where a test's config places the setup's folders: under the test's home, so no test reads the clone it runs in.
SETUP = "~/setup"
def write_config(home: pathlib.Path, checkout: pathlib.Path, goals: str = "checkout:README.md") -> pathlib.Path:
"""A config under home that names checkout, every setting inside it but goals-and-audience; for the tests of each tool that reads the config."""
"""A config under home that names checkout, every setting inside it but goals-and-audience, principles and standards, which lie in SETUP; for the tests of each tool that reads the config."""
folder = config_folder({}, home) / checkout.name
folder.mkdir(parents=True, exist_ok=True)
(folder / "config.toml").write_text(CLIENT.replace('"~/code/acme-billing"', f'"{checkout}"').replace('"folder:', '"checkout:').replace('"checkout:goals.md"', f'"{goals}"'), encoding="utf-8")
(folder / "config.toml").write_text(CLIENT.replace('"~/code/acme-billing"', f'"{checkout}"').replace('"folder:', '"checkout:').replace('"setup:', f'"{SETUP}/').replace('"checkout:goals.md"', f'"{goals}"'), encoding="utf-8")
return folder
+4 -3
View File
@@ -10,8 +10,9 @@ Run inside a checkout, or a worktree of one. It finds the config that names the
and project-config doesn't read anything from it, so no project may use `build-epic` as its key.
The config is TOML. `checkout` names the project's main checkout, and every setting in the example below is a path:
"checkout:<path>" inside the checkout, "folder:<path>" inside the config's own folder, or one that
starts with / or ~/. In a worktree, a "checkout:" path is the worktree's own file.
"checkout:<path>" inside the checkout, "folder:<path>" inside the config's own folder,
"setup:<path>" inside the clone of this setup whose tool reads the config, or one that starts with
/ or ~/. In a worktree, a "checkout:" path is the worktree's own file.
checkout = "~/code/acme-billing"
plan = "folder:todo.md"
@@ -23,7 +24,7 @@ starts with / or ~/. In a worktree, a "checkout:" path is the worktree's own fil
changelog = "checkout:CHANGELOG.md"
goals-and-audience = "folder:goals.md"
principles = "folder:principles"
standards = "~/.claude/skills/larv-review/standards"
standards = "setup:skills/larv-review/standards"
`principles` and `standards` name the folders the reviewers hold the project to: the technical
principles and the review standards. A standards folder must hold quality.md, prose.md, comments.md
+4 -3
View File
@@ -10,7 +10,7 @@ import re
import tomllib
import typing
from loop_state.paths import config_folder
from loop_state.paths import config_folder, RELEASE_ROOT
from failure import Failure
from plan.formula import parse_formula
from plan.todo_table import SHAPE
@@ -25,7 +25,7 @@ SITE = r"https://[A-Za-z0-9.-]+(?::[0-9]+)?"
# Every path a project sets, by its role. Three readers, seated as the human who writes the config, picked the spelling from four candidates. They picked role names over file names, which a client's project doesn't share.
SETTINGS = ("plan", "working-rules", "decisions", "score-anchors", "comprehension-history", "reading-cost", "changelog", "goals-and-audience", "principles", "standards")
# They also picked a prefix over bare relative paths: each line says its own place, and a relative path with no prefix fails instead of landing somewhere by default.
SPELLING = '"checkout:<path>" for a path in the checkout, "folder:<path>" for one in the config\'s folder, or a path that starts with / or ~/'
SPELLING = '"checkout:<path>" for a path in the checkout, "folder:<path>" for one in the config\'s folder, "setup:<path>" for one in the setup\'s clone, or a path that starts with / or ~/'
# A path setting a project may leave out: the file of KEY=value credentials its tools read. It has no default either: a project without it asks for no credentials, and never reads another project's.
ENV_FILE = "env-file"
# An optional setting: the service that sends the loop's DMs to the human, one of NOTIFIERS. A project that names none gets no DMs, so a client's env file of Jira credentials is never read for a chat token.
@@ -475,7 +475,8 @@ def placed(value: object, top: pathlib.Path, folder: pathlib.Path, home: pathlib
"""The path a setting's value spells, or None where it doesn't spell one. A prefixed path stays inside its place."""
if not isinstance(value, str):
return None
for prefix, place in (("checkout:", top), ("folder:", folder)):
# "setup:" is the clone this tool runs from, so a config holds wherever that clone lies. Five readers, seated as people who write a config and as claudes that read one, each picked the prefix over a path in the loop's Claude home and over the clone's path written out.
for prefix, place in (("checkout:", top), ("folder:", folder), ("setup:", RELEASE_ROOT)):
if value.startswith(prefix):
inside = pathlib.PurePosixPath(value.removeprefix(prefix))
return None if inside.is_absolute() or ".." in inside.parts or not inside.parts else place / inside
+5 -3
View File
@@ -12,6 +12,7 @@ from project_config.doubles import CLIENT, JIRA_PLAN, JIRA_SCORING
from failure import Failure
from test_env import isolated_env
from project_config.main import located, title_templates
from loop_state.paths import RELEASE_ROOT
from project_config.templates import Titles
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-config"
@@ -50,8 +51,8 @@ class LoadTest(ConfigCase):
self.assertEqual(found.paths["plan"], folder / "todo.md")
self.assertEqual(found.paths["decisions"], folder / "docs" / "decisions.md")
self.assertEqual(found.paths["changelog"], self.checkout / "CHANGELOG.md")
self.assertEqual(found.paths["principles"], self.home / ".claude" / "principles")
self.assertEqual(found.paths["standards"], self.home / ".claude" / "skills" / "larv-review" / "standards")
self.assertEqual(found.paths["principles"], RELEASE_ROOT / "principles")
self.assertEqual(found.paths["standards"], RELEASE_ROOT / "skills" / "larv-review" / "standards")
self.assertEqual(tuple(found.paths), SETTINGS)
def test_the_build_epic_folder_is_no_projects_config_so_it_needs_no_checkout(self) -> None:
@@ -191,7 +192,7 @@ class LoadTest(ConfigCase):
self.assertIsNone(found.tracked("plan"), "the config's folder is outside the checkout")
def test_an_absolute_checkout_and_path_are_taken_as_written(self) -> None:
self.write("acme", CLIENT.replace("~/code/acme-billing", str(self.checkout)).replace("~/.claude/principles", "/srv/principles"))
self.write("acme", CLIENT.replace("~/code/acme-billing", str(self.checkout)).replace("setup:principles", "/srv/principles"))
found = load(self.checkout, self.checkout, self.home, {})
assert isinstance(found, ProjectConfig), found
self.assertEqual(found.paths["principles"], pathlib.Path("/srv/principles"))
@@ -235,6 +236,7 @@ class LoadTest(ConfigCase):
"a value that is not text": ("plan = 3\n", "`plan`"),
"a path that leaves the folder": ('plan = "folder:../other/todo.md"\n', "`plan`"),
"a path that leaves the checkout": ('plan = "checkout:../todo.md"\n', "`plan`"),
"a path that leaves the setup": ('plan = "setup:../todo.md"\n', "`plan`"),
"an empty path": ('plan = "folder:"\n', "`plan`"),
}
for case, (line, named) in cases.items():
+2 -2
View File
@@ -15,7 +15,7 @@ STANDARDS = "skills/larv-review/standards"
RULE_DIRS = (HUMAN_RULE_DIR, STANDARDS)
RULE_PATH = rf"(?:{'|'.join(map(re.escape, RULE_DIRS))})/[\w-]+\.md"
NAMES = r'("[^"]+"(?:,? (?:and )?"[^"]+")*)'
CITATION = re.compile(rf'`?(?:~/\.claude/)?(CLAUDE\.md|{RULE_PATH})`? → {NAMES}')
CITATION = re.compile(rf'`?(CLAUDE\.md|{RULE_PATH})`? → {NAMES}')
# A citation of a file in whichever folder the project's config names as `standards`, checked against the folder this repo ships.
STANDARD_CITATION = re.compile(rf"the review standards' `([\w-]+\.md)` → {NAMES}")
HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE)
@@ -24,7 +24,7 @@ DECISION_CITATION = re.compile(r"`?docs/decisions\.md`? → `([^`]+)`")
DECISION_TITLE = re.compile(r"^## (.+)$", re.MULTILINE)
LISTED_TITLE = re.compile(r"^- (.+)$", re.MULTILINE)
NAME = re.compile(r'"([^"]+)"')
RULE_FILE = re.compile(rf"(?<![\w/.-])(?:~/\.claude/)?({RULE_PATH})")
RULE_FILE = re.compile(rf"(?<![\w/.-])({RULE_PATH})")
STRAY = re.compile(rf'(?:CLAUDE\.md|{RULE_PATH})(?!`? → "|:\d)[^\n"]{{1,5}}"')
+29
View File
@@ -0,0 +1,29 @@
import re
import unittest
from git_cli.git_repo import git
from repo_checks import ROOT
# A file of the setup spelled by a place in the person's own Claude home, where no release lies: a tool, or an instruction file. A session the loop starts has the release's tools on PATH, so prose names a tool bare, and names any other file as the setup's `CLAUDE.md` → "Vocabulary", "setup" says. Both hold wherever the release is cloned.
BY_ITS_FOLDER = re.compile(r"(?:~|\$HOME)/\.claude/(?:CLAUDE\.md|(?:agents|bin|principles|rules|skills)\b[\w.<>*/-]*)")
# The plan, the changelog and the records, then the dated benches and trials: their text names a file as it was spelled when the line was written, and nobody rewrites it.
HISTORY = ("CHANGELOG.md", "docs/", "todo.md", "reviewer-merge-trials/", "workflow-bench/")
class SetupFilesNamedWhereverTheCloneLies(unittest.TestCase):
def test_no_tracked_file_names_a_file_of_the_setup_by_the_persons_own_claude_home(self) -> None:
tracked = git("ls-files", cwd=str(ROOT))
self.assertIsInstance(tracked, str, tracked)
found = []
for name in str(tracked).splitlines():
path = ROOT / name
if name.startswith(HISTORY) or name == "bin/repo_checks/test_setup_files_named.py" or not path.is_file():
continue
for number, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), 1):
found += [f"{name}:{number}: {spelled}" for spelled in BY_ITS_FOLDER.findall(line)]
self.assertEqual(found, [], "name a tool bare, as in `todo-item`, and any other file as the setup's: the setup's `rules/todo-items.md`, never a path into `~/.claude`")
if __name__ == "__main__":
unittest.main()
-37
View File
@@ -1,37 +0,0 @@
import re
import unittest
from git_cli.git_repo import git
from repo_checks import ROOT
# A tool spelled by its place in an install folder, as opposed to a source file under bin/, which a reader opens by its path. A session the loop starts has the release's tools on PATH, so prose names a tool bare, and works wherever the release is installed.
BY_ITS_FOLDER = re.compile(r"(?:~|\$HOME)/\.claude/bin/[\w.<>-]+(?![\w.<>/-])")
# The plan, the changelog and the records: their text names a tool as it was spelled when the line was written, and nobody rewrites it.
HISTORY = ("CHANGELOG.md", "docs/", "todo.md")
# The lines a person runs in their own shell or a crontab, which lack the tools: no step puts one on their `PATH`.
BY_HAND = {
"README.md": {"$HOME/.claude/bin/compress-archives", "~/.claude/bin/<tool>", "~/.claude/bin/build-release", "~/.claude/bin/deploy-release", "~/.claude/bin/notify", "~/.claude/bin/project-config", "~/.claude/bin/self-update"},
"presentation/README.md": {"~/.claude/bin/run-heavy"},
"presentation/build-pdf.py": {"~/.claude/bin/run-heavy"},
}
# settings.json names its hooks and its status line by their folder, and the test of the reviewer hook quotes it. Claude Code reads the file in every session, also one the human starts without the tools on PATH. A hook it cannot find doesn't refuse anything, so a bare name there would switch rule-hook off in that session.
SETTINGS = ("settings.json", "bin/review_rules/test_reviewer_context.py")
class ToolsNamedBare(unittest.TestCase):
def test_no_tracked_file_names_a_tool_by_its_install_folder(self) -> None:
tracked = git("ls-files", cwd=str(ROOT))
self.assertIsInstance(tracked, str, tracked)
found = []
for name in str(tracked).splitlines():
path = ROOT / name
if name.startswith(HISTORY) or name in SETTINGS or name == "bin/repo_checks/test_tools_named_bare.py" or not path.is_file():
continue
for number, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), 1):
found += [f"{name}:{number}: {spelled}" for spelled in BY_ITS_FOLDER.findall(line) if spelled not in BY_HAND.get(name, ())]
self.assertEqual(found, [], "name each tool bare, as in `todo-item`")
if __name__ == "__main__":
unittest.main()
+2 -2
View File
@@ -11,7 +11,7 @@ from text_files.markdown_text import section
SECTIONS = ("Shared goal", "Prose", "Vocabulary")
# The text calls the file the setup's, the word that file uses for the release's rules, and names no install folder: a release may be installed anywhere.
# The text calls the file the setup's, the word that file uses for the release's rules, and names the loop's Claude home as the place to open one: a reviewer without a shell cannot learn where `XDG_DATA_HOME` puts that home.
def reviewer_context(claude_dir: pathlib.Path) -> str | Failure:
"""SECTIONS of the CLAUDE.md in claude_dir, the loop's Claude home, as a reviewer is told them; a Failure where the file or a section is missing."""
path = claude_dir / "CLAUDE.md"
@@ -22,7 +22,7 @@ def reviewer_context(claude_dir: pathlib.Path) -> str | Failure:
found = {name: section(text, re.escape(name)) for name in SECTIONS}
if missing := [name for name, lines in found.items() if lines is None]:
return Failure(f"{path} holds no section {', '.join(missing)}")
return "\n\n".join(["You start without the setup's `CLAUDE.md`. These sections of it hold for you:", *("\n".join([f"## {name}", *lines]).strip() for name, lines in found.items() if lines is not None)])
return "\n\n".join([f"You start without the setup's `CLAUDE.md`. Open a file of the setup under {claude_dir}/. These sections of that `CLAUDE.md` hold for you:", *("\n".join([f"## {name}", *lines]).strip() for name, lines in found.items() if lines is not None)])
def starts_bare(agent: str, claude_dir: pathlib.Path) -> bool:
+1 -1
View File
@@ -23,7 +23,7 @@ class ReviewerContext(unittest.TestCase):
(self.claude_dir / "agents" / f"{agent}.md").write_text(f"---\nname: {agent}\nomitClaudeMd: true\n---\n\nReview.\n")
def test_holds_the_shared_goal_prose_and_vocabulary_sections_and_none_of_the_workers(self):
self.assertEqual(reviewer_context(self.claude_dir), "You start without the setup's `CLAUDE.md`. These sections of it hold for you:\n\n## Shared goal\n\nCode health.\n\n## Prose\n\nWrite short.\n\n## Vocabulary\n\n- **chunk** — a unit.")
self.assertEqual(reviewer_context(self.claude_dir), f"You start without the setup's `CLAUDE.md`. Open a file of the setup under {self.claude_dir}/. These sections of that `CLAUDE.md` hold for you:\n\n## Shared goal\n\nCode health.\n\n## Prose\n\nWrite short.\n\n## Vocabulary\n\n- **chunk** — a unit.")
def test_a_heading_inside_a_code_fence_does_not_end_a_section(self):
(self.claude_dir / "CLAUDE.md").write_text("## Shared goal\n\n```\n## Not a heading\n```\n\nstill the goal\n\n## Prose\n\np\n\n## Vocabulary\n\nv\n")
+13 -2
View File
@@ -13,11 +13,12 @@ from git_cli.git_repo import Git, top
from git_cli import git_repo
from task_bench.bench_folder import held
from review_rules.review_folder import made_review_folder
from loop_state.paths import paths_from, with_release_tools
from loop_state.paths import paths_from
from transcript_archive.project_key import project_key
from model_routing.ladder_file import project_ladder
from chunk_driver.project.model_choice import read_models_file
from model_routing.ladder import Rung
from loop_effects.effects import system_effects
DIGEST = "digest.md"
PROMPT = pathlib.Path(__file__).with_name("gather-prompt.md")
@@ -58,7 +59,17 @@ def gather(env: typing.Mapping[str, str], home: pathlib.Path, claude: Claude) ->
def run_claude(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedProcess[str]:
return subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(os.environ), input=prompt, text=True)
"""Runs the gathering claude as the loop runs each of its own: in the loop's Claude home, built or refreshed first, with the release's tools first on its `PATH`."""
effects = system_effects(pathlib.Path.home(), os.environ)
return once_ready(effects.claude_home, effects.claude)(args, cwd, prompt)
def once_ready(unready: typing.Callable[[], str | None], claude: Claude) -> Claude:
"""claude, started only where unready gives no reason why it cannot run yet; else a failed run that says the reason."""
def run(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedProcess[str]:
reason = unready()
return subprocess.CompletedProcess(args, 1, "", reason) if reason else claude(args, cwd, prompt)
return run
def project_rung(home: pathlib.Path, env: typing.Mapping[str, str], git: Git) -> Rung | Failure:
+20 -6
View File
@@ -14,7 +14,7 @@ BIN = pathlib.Path(__file__).resolve().parents[2]
sys.path.insert(0, str(BIN))
from failure import Failure
from task_bench.figures.gather import gather, PROMPT
from task_bench.figures.gather import gather, once_ready, PROMPT
from test_env import isolated_env
from task_bench import main
@@ -69,6 +69,12 @@ class GatherTest(unittest.TestCase):
self.assertEqual((self.calls[0][0][2], self.calls[0][1], self.calls[0][2].endswith("\n\nworktree's\n")), ("claude-opus-5-5", str(worktree), True))
self.assertEqual((bench.exists(), self.bench.exists()), (False, True))
def test_the_claude_starts_only_once_the_loops_claude_home_is_ready_and_a_home_that_is_not_keeps_the_folder(self):
found = gather(self.env, self.home, once_ready(lambda: "nobody is signed in to the loop's Claude home", self.claude))
self.assertEqual((found.reason if isinstance(found, Failure) else found, self.calls), (f"nobody is signed in to the loop's Claude home\nThe digest stays in {self.bench} until the next bench: run `task-bench gather` again.", []))
self.assertNotIsInstance(gather(self.env, self.home, once_ready(lambda: None, self.claude)), Failure)
self.assertEqual(len(self.calls), 1)
def test_refuses_without_a_digest_and_starts_no_claude(self):
(self.bench / "digest.md").unlink()
found = gather(self.env, self.home, self.claude)
@@ -143,15 +149,23 @@ class GatherTest(unittest.TestCase):
class RunClaude(unittest.TestCase):
def test_runs_claude_in_the_folder_with_the_prompt_and_the_releases_tools_first_on_its_path(self):
def test_runs_claude_in_the_loops_claude_home_once_it_is_built_with_the_prompt_and_the_releases_tools_first_on_its_path(self):
with tempfile.TemporaryDirectory() as folder:
claude = pathlib.Path(folder, "claude")
claude.write_text('#!/bin/sh\necho "$PWD $* $(cat) $PATH"\n')
claude.write_text("""#!/bin/sh
case "$*" in
"auth status") echo '{"loggedIn": true}' ;;
plugin*) ;;
*) echo "$PWD $* $(cat) $PATH $CLAUDE_CONFIG_DIR" ;;
esac
""")
claude.chmod(0o755)
# A process of its own, so the test changes no PATH but that process's.
# A process of its own, so the test changes no PATH and no home but that process's.
call = f"import sys; sys.path.insert(0, {str(BIN)!r}); from task_bench.figures.gather import run_claude; print(run_claude(['-p'], {folder!r}, 'asked').stdout, end='')"
done = subprocess.run([sys.executable, "-c", call], capture_output=True, env={"PATH": f"{folder}:/usr/bin:/bin"}, text=True)
self.assertEqual(done.stdout, f"{os.path.realpath(folder)} -p asked {BIN}:{folder}:/usr/bin:/bin\n", done.stderr)
done = subprocess.run([sys.executable, "-c", call], capture_output=True, env={"HOME": folder, "PATH": f"{folder}:/usr/bin:/bin"}, text=True)
home = pathlib.Path(folder, ".local/share/build-release/claude-home")
self.assertEqual(done.stdout, f"{os.path.realpath(folder)} -p asked {BIN}:{folder}:/usr/bin:/bin {home}\n", done.stderr)
self.assertTrue((home / "CLAUDE.md").is_symlink())
if __name__ == "__main__":
+2 -2
View File
@@ -162,7 +162,7 @@ table's header and its three All rows. The entry's heading gives the current UTC
features the heading reads `task-bench features of <branch>: ...` instead, for one of data sources `task-bench data-sources
of <branch>: ...`, and for one of shipped features `task-bench shipped-features of <branch>: ...`. No tool reads the entry as a ruling or a scoring run. The bench's last line says where the entry went. A bench that fails or stops doesn't record anything.
`task-bench gather`, run in the same checkout, turns the digest into plan items. It starts a claude on the project's rung, the
`task-bench gather`, run in the same checkout, turns the digest into plan items. It starts a claude in the loop's Claude home, on the project's rung, the
cheapest rung of the model build-release runs the project on, with the digest and the prompt in bin/task_bench/figures/gather-prompt.md.
That claude files an item with `todo-item add` for each place the runs show to be hard, and leaves the plan's file uncommitted.
gather prints that claude's answer and removes the bench's folder. Where claude fails, the folder stays, for another try.
@@ -185,7 +185,7 @@ With --record-figures it also exits 1, saying why: before it plants a bug, where
cannot be read; and after the bench, where the history already holds that branch's bench of those two commits or cannot be
written. The folder then still holds the bench's results.
gather exits 1, saying why, outside a checkout, without a digest, where build-release has saved no model for the project or the
model is not on its routing ladder, and where its claude fails or hits a usage limit.
model is not on its routing ladder, and where the loop's Claude home is not ready or its claude fails or hits a usage limit.
"""
import dataclasses
import functools