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:
2026-11-13 02:10:33 +01:00
parent c180bda54b
commit 5c7969e7c8
8 changed files with 31 additions and 17 deletions
+6 -5
View File
@@ -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)
+10 -2
View File
@@ -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]:
+1 -1
View File
@@ -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.
+6 -1
View File
@@ -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)
+4 -4
View File
@@ -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"]