Answer stability round 1: 0 🔴, 1 🟡 (0 misread); say the checkout's commits, not git, hold no version of a file outside it, and find a symlinked config folder
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Each change a chunk makes to a file the project's config keeps in its own folder, such as a plan there, is committed in that folder's git repo under the title of the chunk's commit in the checkout. rule-hook checks the plan's ranking on a commit there, as it does in the checkout, where before it refused such a commit.
|
||||
- The loop commits each change it makes to a file in the config's folder, such as a plan kept there, in that folder's git repo, titled as it titles its commits in the checkout. rule-hook ranks the plan on such a commit; before, it refused the commit.
|
||||
- Every tool, prompt, rule and skill reads and writes the plan, `AGENTS.md`, the records and the changelog at the paths the project's config names. A plan outside the checkout is read as it stands; the tools that need a file's commits say what they leave undone for it, and the loop goes on.
|
||||
- loop-claude, `rank_todo.py`, `todo-item` and rule-hook's `todo.md` checks now fail in a checkout no config names: write a config for each project, with `goals-and-audience = "checkout:README.md"` where its goals stay in its README. They read the goals and audience from the file that setting names, in place of `README.md`. `larv-review reviewer-header` names it on a `Goals and audience:` line, and the reviewers read it from there. A client's project can keep the file, named `goals.md`, in its config's folder, and void code health there as a README can.
|
||||
- Reviewers read the technical principles from the folder a project's config sets as `principles`, in place of `~/.claude/principles/`. `larv-review reviewer-header` names the folder on a `Technical principles:` line and fails where no config sets it, or the folder is missing or empty. Write a config for each project before its next review; a project that keeps today's principles sets `principles = "~/.claude/principles"`.
|
||||
|
||||
@@ -89,12 +89,12 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i
|
||||
|
||||
## Git, commits, and PRs
|
||||
- Mark no commit, PR, issue comment or file as the work of Claude, Anthropic or an agent.
|
||||
- Where the project's config keeps a file in its own folder, `~/.claude-projects/<key>/`, such as the plan or a record, commit each change the chunk makes to that file in the folder's git repo, under the title the chunk's commit in the checkout gives the same change. Commit on that repo's only branch, never on the chunk's branch: one loop runs per project. A dropped item's commit there is titled `Drop item <ID>: <why>` too, and rule-hook checks the plan's ranking there as it does in the checkout.
|
||||
- Commit message and PR title: **one line**, prefixed with the ticket ID when the work has one. Example: `ABC-123 - Regression tests for GET /v4/clients`. Never include the repo/project name (like "twu-4") — we're already in that context.
|
||||
- When the work has a ticket, read it before starting: verify the change matches it and pull useful context from it.
|
||||
- PR summary: short and concise. No test plan (it lives in the ticket), no link to the ticket (it's in the title).
|
||||
- Branch for a ticket: exactly the ticket ID, nothing more. `ABC-123`, never `ABC-123-some-description`.
|
||||
- Branch for a `todo.md` item without a ticket: `item-<ID>`, in the worktree `<checkout>-item-<ID>` beside the checkout, as `chunk-preflight` makes them.
|
||||
- Where the project's config keeps a file in the config's folder, `~/.claude-projects/<key>/`, such as the plan or a record, commit each change you make to that file in the folder's own git repo, on its only branch. Title that commit as you would title the change in the checkout: where a commit in the checkout goes with it, give it the same title.
|
||||
- Use `gh` on GitHub remotes and `tea` on Gitea remotes (e.g. `gitea.larvit.se`) — same command shape: `tea pr list|create`, `tea issue`, `tea release`, `tea api`. Everything in this section applies to both.
|
||||
- On GitHub and Gitea, open a chunk's pull request as a draft, mark it ready and merge it with `~/.claude/bin/chunk-pr`, which picks `gh` or `tea` from the remote; `chunk-pr --help` says how. Once it has merged, run `chunk-pr clean` in the chunk's worktree: it removes the worktree and the branch and fast-forwards the main checkout.
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ To get loop-claude's questions and stops as Mattermost DMs from a bot, write the
|
||||
|
||||
### Set up a project
|
||||
|
||||
Each project the loop runs in has a folder, `~/.claude-projects/<key>/`, where `<key>` is the project's name, and a config in it, `config.toml`. The folder is a git repo of its own, so the config has a history and a client's files never enter this repo. Each change a chunk makes to a file there, such as the plan, is committed in that repo under the title of the chunk's commit in the checkout. A project is a whole git checkout, never a subfolder of one.
|
||||
Each project the loop runs in has a folder, `~/.claude-projects/<key>/`, where `<key>` is the project's name, and a config in it, `config.toml`. The folder is a git repo of its own, so the config has a history and a client's files never enter this repo. The loop commits each change it makes to a file there, such as the plan, in that repo, titled as its commits in the checkout. A project is a whole git checkout, never a subfolder of one.
|
||||
|
||||
The config names the project's main checkout and the path of every file the loop keeps for it. No setting has a default: `project-config` fails and names each setting a config leaves out. A path is `checkout:<path>` inside the checkout, `folder:<path>` inside the config's folder, or one that starts with `/` or `~/`. Every tool reads and writes each file at the path its setting gives, and `chunk-preflight` and `todo-item` print those paths for the agents. Keep each file's name, such as `todo.md`: the rules for a file load by its name. A project of your own keeps every file but the principles in its checkout:
|
||||
|
||||
@@ -94,7 +94,7 @@ goals-and-audience = "checkout:README.md"
|
||||
principles = "~/.claude/principles"
|
||||
```
|
||||
|
||||
For a client's project, use one sandbox VM per client, so that one client's code, transcripts and credentials never share a machine with another's. What the client's repo should not hold lives in the config's folder, at paths written as `folder:<path>`, as `project-config --help` shows: the plan, the working rules in an `AGENTS.md` I write for the agents, the records, and the goals and audience, as `goals-and-audience = "folder:goals.md"`. Name that file `goals.md`, so the rules for goals and audience load when an agent writes it. A file outside the checkout has no commits, so four things are not supported for it yet. `score-outcomes` and loop-claude's routing figures count a project's chunks only where `todo.md`, `docs/comprehension-history.md` and `docs/reading-cost.md` are at those paths in the checkout; otherwise each says so, and the loop goes on. For a plan or a comprehension history outside the checkout, `larv-review` says it cannot tell whether a scoring run is owed, and for such a history it cannot find a paired ruling's base. For a plan outside the checkout, chunk-preflight and loop-claude don't see a release whose last item has shipped, and say that its release review and its cut are yours to call. And rule-hook checks a plan outside the checkout on every call, not only when it changed.
|
||||
For a client's project, use one sandbox VM per client, so that one client's code, transcripts and credentials never share a machine with another's. What the client's repo should not hold lives in the config's folder, at paths written as `folder:<path>`, as `project-config --help` shows: the plan, the working rules in an `AGENTS.md` I write for the agents, the records, and the goals and audience, as `goals-and-audience = "folder:goals.md"`. Name that file `goals.md`, so the rules for goals and audience load when an agent writes it. A file outside the checkout has no commits in the checkout's history, so four things are not supported for it yet. `score-outcomes` and loop-claude's routing figures count a project's chunks only where `todo.md`, `docs/comprehension-history.md` and `docs/reading-cost.md` are at those paths in the checkout; otherwise each says so, and the loop goes on. For a plan or a comprehension history outside the checkout, `larv-review` says it cannot tell whether a scoring run is owed, and for such a history it cannot find a paired ruling's base. For a plan outside the checkout, chunk-preflight and loop-claude don't see a release whose last item has shipped, and say that its release review and its cut are yours to call. And rule-hook checks a plan outside the checkout on every call, not only when it changed.
|
||||
|
||||
```sh
|
||||
mkdir -p ~/.claude-projects/acme && cd ~/.claude-projects/acme
|
||||
|
||||
@@ -14,7 +14,7 @@ SETTINGS = ("plan", "working-rules", "decisions", "score-anchors", "comprehensio
|
||||
# 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 ~/'
|
||||
|
||||
# Where a project keeps a file, for a tool that reads it at a commit: a path from the checkout's top, as git names it; or, outside the checkout, the file itself, which the tool reads as it stands, since git holds no version of it.
|
||||
# Where a project keeps a file, for a tool that reads it at a commit: a path from the checkout's top, as git names it; or, outside the checkout, the file itself, which the tool reads as it stands, since the checkout's commits hold no version of it.
|
||||
Place = str | pathlib.Path
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ProjectConfig:
|
||||
paths: dict[str, pathlib.Path]
|
||||
|
||||
def tracked(self, setting: str) -> str | None:
|
||||
"""setting's path from top, as git names a file in a commit; None where the config puts it outside the checkout, where git holds no version of it."""
|
||||
"""setting's path from top, as git names a file in a commit; None where the config puts it outside the checkout, whose commits hold no version of it."""
|
||||
path = self.paths[setting]
|
||||
return path.relative_to(self.top).as_posix() if path.is_relative_to(self.top) else None
|
||||
|
||||
@@ -65,9 +65,10 @@ def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectCo
|
||||
|
||||
|
||||
def held(folder: pathlib.Path, home: pathlib.Path) -> ProjectConfig | Failure | None:
|
||||
"""The config folder holds, as its project's main checkout reads it; None where folder is not a config's folder under home."""
|
||||
file = folder / CONFIG
|
||||
if folder.resolve().parent != (home / PROJECTS).resolve() or not file.is_file():
|
||||
"""The config in folder, read as its project's main checkout reads it; None where folder is not a config's folder under home."""
|
||||
# Matched on resolved paths, as git names a folder, so a config's folder reached through a symlink is still found.
|
||||
file = next((file for file in (home / PROJECTS).glob(f"*/{CONFIG}") if file.parent.resolve() == folder.resolve()), None)
|
||||
if file is None:
|
||||
return None
|
||||
config = read(file, home)
|
||||
return config if isinstance(config, Failure) else load(config[0], config[0], home)
|
||||
|
||||
@@ -9,8 +9,8 @@ import unittest.mock
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from failure import Failure
|
||||
from test_env import isolated_env
|
||||
from project_config.settings import held, load, ProjectConfig
|
||||
from test_env import isolated_env
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-config"
|
||||
|
||||
@@ -178,13 +178,21 @@ class HeldTest(ConfigCase):
|
||||
assert isinstance(found, ProjectConfig), found
|
||||
self.assertEqual((found.folder, found.top, found.paths["plan"]), (folder, self.checkout, folder / "todo.md"), "the config's ~/ checkout read under home")
|
||||
|
||||
def test_only_a_folder_under_the_projects_folder_that_holds_a_config_is_one(self) -> None:
|
||||
def test_a_folder_holds_no_config_unless_it_is_under_the_projects_folder_and_has_one(self) -> None:
|
||||
self.assertIsNone(held(self.home / ".claude-projects" / "empty", self.home), "no config.toml")
|
||||
elsewhere = self.home / "code" / "acme"
|
||||
elsewhere.mkdir()
|
||||
(elsewhere / "config.toml").write_text(CLIENT, encoding="utf-8")
|
||||
self.assertIsNone(held(elsewhere, self.home), "a config.toml outside ~/.claude-projects/")
|
||||
|
||||
def test_a_configs_folder_reached_through_a_symlink_holds_its_config(self) -> None:
|
||||
target = self.home / "kept" / "acme"
|
||||
target.mkdir(parents=True)
|
||||
(target / "config.toml").write_text(CLIENT, encoding="utf-8")
|
||||
(self.home / ".claude-projects").mkdir()
|
||||
(self.home / ".claude-projects" / "acme").symlink_to(target)
|
||||
self.assertIsInstance(held(target, self.home), ProjectConfig, "git names the folder by its resolved path")
|
||||
|
||||
|
||||
class ToolTest(ConfigCase):
|
||||
def run_tool(self, *args: str, cwd: pathlib.Path | None = None) -> subprocess.CompletedProcess[str]:
|
||||
|
||||
@@ -81,7 +81,7 @@ RULES: dict[RuleName, Rule] = {
|
||||
),
|
||||
"todo-rank-check": Rule(
|
||||
"while todo.md has changes, staged or not, a git commit waits until rank_todo.py --check passes on it: the checkout's own bin/rank_todo.py where the checkout is of this setup's repo, else ~/.claude/bin/rank_todo.py",
|
||||
"a git commit in a checkout whose todo.md has changes, and every git commit where the project's config puts todo.md outside the checkout, where no commit says whether it changed; also a git commit in the config's folder, `~/.claude-projects/<key>/`, whose todo.md has changes there",
|
||||
"a git commit in a checkout whose todo.md has changes, and every git commit where the project's config puts todo.md outside the checkout, where the checkout's commits don't say whether it changed; and a git commit in the config's folder, `~/.claude-projects/<key>/`, whose todo.md has changes",
|
||||
),
|
||||
}
|
||||
# The lookahead ends each reason at the next marker on its line, or at the line's end. The reason is lazy, so it stops at the next marker instead of running on and swallowing the markers after it.
|
||||
|
||||
@@ -939,9 +939,14 @@ class TodoRankCheck(unittest.TestCase):
|
||||
git(folder, "add", "-A")
|
||||
git(folder, "commit", "-q", "-m", "plan")
|
||||
self.assertEqual(self.details(folder), [], "committed, so unchanged")
|
||||
|
||||
def test_an_unreadable_config_does_not_block_a_commit_in_its_folder(self):
|
||||
self.changed_plan(f"{self.folder}/clone", self.STUB)
|
||||
folder = str(self.config.parent)
|
||||
git(folder, "init", "-q", "-b", "main")
|
||||
self.config.write_text("checkout = 3\n")
|
||||
(self.config.parent / "todo.md").write_text("# changed\n")
|
||||
self.assertEqual(self.details(folder), [], "a config to fix doesn't block the commit that fixes it")
|
||||
self.assertEqual(self.details(folder), [], "the commit that fixes the config goes through")
|
||||
|
||||
def test_a_commit_in_the_configs_folder_of_another_repo_checks_its_plan_with_the_hooks_ranking(self):
|
||||
self.changed_plan(self.other, self.STUB)
|
||||
|
||||
@@ -20,7 +20,7 @@ OWN_CHECK_SECONDS = 20
|
||||
|
||||
|
||||
def todo_breaches(directory: str, own: pathlib.Path = OWN) -> list[Breach]:
|
||||
"""Why the plan of directory's project is not ranked, where the plan has changed; the plan is the todo.md its config names. directory may also be a config's folder, which commits its own files."""
|
||||
"""Why the plan of directory's project is not ranked, where the plan has changed; the plan is the todo.md its config names. directory may also be in a config's folder, a git repo of its own."""
|
||||
top = guarded_git(directory, "rev-parse", "--show-toplevel")
|
||||
if isinstance(top, Failure):
|
||||
return []
|
||||
@@ -33,16 +33,16 @@ def todo_breaches(directory: str, own: pathlib.Path = OWN) -> list[Breach]:
|
||||
unconfigured = pathlib.Path(top) / "todo.md"
|
||||
return [Breach("todo-rank-check", config.reason, top)] if unconfigured.is_file() and changed(top, unconfigured, "todo.md") else []
|
||||
todo, tracked = config.paths["plan"], config.tracked("plan")
|
||||
# A plan outside the checkout has no commit to differ from, so it is checked on every call.
|
||||
# A plan outside the checkout has no commit in the checkout to differ from, so it is checked on every call.
|
||||
if not todo.is_file() or (tracked is not None and not changed(top, todo, tracked)):
|
||||
return []
|
||||
return [Breach("todo-rank-check", line, top) for line in check_failures(top, todo, config, own)]
|
||||
|
||||
|
||||
def folder_breaches(top: str, config: ProjectConfig | Failure, own: pathlib.Path) -> list[Breach]:
|
||||
"""Why the plan in top, a config's folder and a git repo of its own, is not ranked, where the plan has changed there; checked as a commit in the project's checkout would check it.
|
||||
"""Why the plan kept in top, a config's folder, is not ranked, where the plan has changed in that folder's repo; ranked as for a commit in the project's checkout.
|
||||
|
||||
A config that cannot be read doesn't block anything here, so that the commit fixing it goes through."""
|
||||
A config that fails to load doesn't block anything here, so that the commit that fixes it goes through."""
|
||||
if isinstance(config, Failure) or not config.paths["plan"].is_relative_to(config.folder):
|
||||
return []
|
||||
todo = config.paths["plan"]
|
||||
|
||||
Reference in New Issue
Block a user