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)