From 83298bed3d7ef2ad5c9d2466232145782ead5f2a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:08:14 +0100 Subject: [PATCH 01/13] Make chunk-preflight report space-indented code with no setting that says so, and narrow the tabs principle's override --- bin/chunk_preflight/facts.py | 12 +++- bin/chunk_preflight/gathered.py | 3 + bin/chunk_preflight/indentation.py | 56 ++++++++++++++++ bin/chunk_preflight/main.py | 8 ++- bin/chunk_preflight/test_chunk_preflight.py | 30 +++++++++ bin/chunk_preflight/test_indentation.py | 72 +++++++++++++++++++++ principles/technical-principles.md | 3 +- 7 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 bin/chunk_preflight/indentation.py create mode 100644 bin/chunk_preflight/test_indentation.py diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index 806b0029..d7121a4e 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -5,6 +5,7 @@ from release_plan.next_chunk import cut_name, NextChunk, NoItem from release_plan.release_standing import dated_cut, LastCut, unreleased_entries, UNSEEN_RELEASES from failure import Failure from forge.commands import Forge +from chunk_preflight.indentation import SpaceIndented from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran from text_files.markdown_text import listed, quoted from chunk_preflight.choices import PULLS_LIST @@ -19,7 +20,7 @@ def render(found: Gathered) -> list[str]: """One `- ` line per fact, then the item's tagline and detail, the detail of each item that may join its chunk, and what each tool printed.""" note = [f"- {found.note}"] if found.note else [] unseen = [f"- {UNSEEN_RELEASES}"] if found.plan_outside else [] - head = [*note, f"- {last_release(found.default, found.cut)}", *unseen, *merge_lines(found)] + head = [*note, f"- {last_release(found.default, found.cut)}", *unseen, *merge_lines(found), *indentation_lines(found.indentation)] paths = f"- The project's config puts its files and plan at: {'; '.join(f'{setting} {path}' for setting, path in found.places.items())}." texts = f"- The project's config sets: {'; '.join(f'{setting} {text}' for setting, text in found.texts.items())}." if isinstance(found.item, NoItem): @@ -38,6 +39,15 @@ def merge_lines(found: Gathered) -> list[str]: return [*left, *over, *unread] +def indentation_lines(found: SpaceIndented | Failure | None) -> list[str]: + """The one fact about indentation: the project's code is space-indented with no setting that says so. It only reports: a client's repo belongs to its team.""" + if isinstance(found, Failure): + return [f"- Whether the project's code is space-indented cannot be read: {found.reason}"] + if found is None: + return [] + return [f"- The project's code is space-indented ({found.spaced} lines against {found.tabbed} with tabs), and no `.editorconfig` with `indent_style` nor formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) says so. The technical principles indent with hard tabs unless a setting a tool reads, plus a decision in `docs/decisions.md` that names the reason, overrides that. Either convert the code to tabs, or record the override in `.editorconfig` and a decision."] + + def last_release(default: str, release: LastCut) -> str: if isinstance(release.tag, Failure): return f"Last version cut: cannot be read: {release.tag.reason}" diff --git a/bin/chunk_preflight/gathered.py b/bin/chunk_preflight/gathered.py index 00f81899..b7de48b8 100644 --- a/bin/chunk_preflight/gathered.py +++ b/bin/chunk_preflight/gathered.py @@ -6,6 +6,7 @@ from failure import Failure from forge.commands import Forge from release_plan.release_standing import LastCut from release_plan.next_chunk import NextChunk, NoItem +from chunk_preflight.indentation import SpaceIndented @dataclasses.dataclass(frozen=True) @@ -75,3 +76,5 @@ class Gathered: merges_unread: Failure | None = None # The worktrees `chunk-pr clean` is still to remove. left: tuple[LeftWorktree, ...] = () + # The line counts of the project's code where it is space-indented with no setting that says so, or why they cannot be read; None where it is not. + indentation: SpaceIndented | Failure | None = None diff --git a/bin/chunk_preflight/indentation.py b/bin/chunk_preflight/indentation.py new file mode 100644 index 00000000..4a73e4c0 --- /dev/null +++ b/bin/chunk_preflight/indentation.py @@ -0,0 +1,56 @@ +"""Whether a project's code is space-indented with no tool setting that says so. + +The technical principles indent with hard tabs by default, and let a setting a tool reads override that. Code that is mostly space-indented, with no such setting, reads as a first session's habit that later sessions followed, not as a choice.""" +import dataclasses +import os +import pathlib +import re + +from failure import Failure +from git_cli.git_repo import git + +# The files the project's language tooling covers. Markdown, JSON and YAML are not code: their indentation is a format's. +CODE = re.compile(r".*\.(py|js|mjs|cjs|jsx|ts|tsx|rs|go|php|java|kt|kts|scala|rb|c|h|cc|cpp|hpp|cs|swift|sh|bash|lua|ex|exs|dart|vue|svelte)", re.IGNORECASE) +# Committed copies of other people's code follow their authors' style. +VENDORED = re.compile(r"(^|/)(vendor|node_modules|third_party)/") +# The files whose key says how to indent: an `.editorconfig` with `indent_style`, rustfmt's `hard_tabs`, Prettier's `useTabs` in its own files or a `package.json`, Biome's `indentStyle`. +SETTINGS = ( + (re.compile(r"\.editorconfig"), "indent_style"), + (re.compile(r"\.?rustfmt\.toml"), "hard_tabs"), + (re.compile(r"\.prettierrc(\.\w+)?|prettier\.config\.\w+|package\.json"), "useTabs"), + (re.compile(r"biome\.jsonc?"), "indentStyle"), +) +# Two spaces is the narrowest space indent; a lone leading space aligns a comment's continuation. +SPACED_LINE = re.compile(r"^ {2,}\S", re.MULTILINE) +TABBED_LINE = re.compile(r"^\t+\S", re.MULTILINE) + + +@dataclasses.dataclass(frozen=True) +class SpaceIndented: + """Lines of tracked code that start with spaces, and lines that start with tabs.""" + spaced: int + tabbed: int + + +def space_indented(base: pathlib.Path, timeout: float | None = None) -> SpaceIndented | Failure | None: + """The line counts of the tracked code under base where it has more space-indented lines than tab-indented ones and no tracked file sets the indent; None where it doesn't, or has no code; a Failure where a file cannot be read.""" + tracked = git("ls-files", "-z", cwd=str(base), timeout=timeout) + if isinstance(tracked, Failure): + return tracked + spaced = tabbed = 0 + for name in filter(None, tracked.split("\0")): + code = CODE.fullmatch(name) and not VENDORED.search(name) + key = next((key for pattern, key in SETTINGS if pattern.fullmatch(name.rsplit("/", 1)[-1])), None) + path = base / name + if not (code or key) or not os.path.isfile(path): + continue + try: + text = path.read_text(encoding="utf-8", errors="replace") + except OSError as failure: + return Failure(f"cannot read {name}: {failure}") + if key and key in text: + return None + if code: + spaced += len(SPACED_LINE.findall(text)) + tabbed += len(TABBED_LINE.findall(text)) + return SpaceIndented(spaced, tabbed) if spaced > tabbed else None diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index 9487ea08..30bc9ce5 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -21,6 +21,11 @@ and prints that the release reviews and the cuts are the human's to call. It pri finished on the branch of an open pull request that is not a draft, where the checkout holds the plan. Where no item of the release can start and one awaits such a merge, it names those pull requests and says the working loop stops there; +- where the project's tracked code (the files its language tooling covers, not Markdown, JSON or + YAML) has more space-indented than tab-indented lines, and neither an `.editorconfig` with + `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome + `indentStyle`) says so, one line naming the technical principles' hard-tabs default and the two + ways out. It only reports; - the next release and its first item that does not wait, the item loop-claude routes on, with its L and E + I; with --item , the plan item of that ID instead, which loop-claude names in a window named for an item. An item waits while it is marked question, while an item still in todo.md @@ -93,6 +98,7 @@ from git_cli import epic_branch from failure import Failure from forge.commands import Forge, forge_of, Run, runner from chunk_preflight.gathered import Gathered, ItemFacts, LeftWorktree, NamedPath, Ran, Worktree +from chunk_preflight.indentation import space_indented from chunk_preflight.facts import JOINING_DETAILS, render from project_config.main import located from forge.pulls import merged_pull @@ -165,7 +171,7 @@ def preflight(root: pathlib.Path, timeout: float, make: bool, item_id: int | Non item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout, make, epic_branch_of(config)) # A `checkout:` path lands in the worktree the chunk works in. made = located(str(item.worktree.path), pathlib.Path.home()) if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else config - return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts, merges_unread=held.merges_unread, left=left_worktrees(root, forge_run) if config.merge == "human" else ())) + return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts, merges_unread=held.merges_unread, left=left_worktrees(root, forge_run) if config.merge == "human" else (), indentation=space_indented(item.worktree.path if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else root, timeout))) def epic_branch_of(config: ProjectConfig) -> str | None | Failure: diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index ed6a98bb..01ec521f 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -22,6 +22,7 @@ from release_plan.release_standing import LastCut, UNSEEN_RELEASES from release_plan.awaiting_merge import marked from release_plan import next_chunk from chunk_preflight.facts import open_pulls, render +from chunk_preflight.indentation import SpaceIndented from plan_store.todo_md import plan_of from chunk_preflight.choices import worktree_add, worktree_on, worktrees from project_config.doubles import write_config @@ -801,6 +802,35 @@ class Running(unittest.TestCase): self.assertIsNone(line_count(folder)) +class IndentationFact(unittest.TestCase): + def said(self, indentation): + found = dataclasses.replace(gathered(item_facts()), indentation=indentation) + return [line for line in render(found) if "indent" in line] + + def test_names_the_counts_the_principle_and_the_two_ways_out(self): + (line,) = self.said(SpaceIndented(spaced=120, tabbed=3)) + self.assertIn("space-indented (120 lines against 3 with tabs)", line) + self.assertIn("The technical principles indent with hard tabs", line) + self.assertIn("convert the code to tabs, or record the override in `.editorconfig` and a decision", line) + + def test_says_nothing_where_the_code_is_not_space_indented_and_why_where_it_cannot_be_read(self): + self.assertEqual(self.said(None), []) + self.assertEqual(self.said(Failure("cannot read a.py: denied")), ["- Whether the project's code is space-indented cannot be read: cannot read a.py: denied"]) + + def test_prints_it_from_a_checkout_of_spaced_code_and_only_then(self): + tabbed = Repo(self) + self.assertNotIn("space-indented", tabbed.preflight().stdout) + spaced = Repo(self) + spaced.write(spaced.root, "src/app.py", "def run():\n if True:\n return 1\n") + spaced.commit(spaced.root, "spaces") + done = spaced.preflight() + self.assertEqual(done.returncode, 0, done.stderr) + self.assertIn("- The project's code is space-indented (2 lines against 0 with tabs)", done.stdout) + spaced.write(spaced.root, ".editorconfig", "[*]\nindent_style = space\n") + spaced.commit(spaced.root, "setting") + self.assertNotIn("space-indented", spaced.preflight().stdout) + + class BesideTest(unittest.TestCase): """The fact that names the items that may start chunks beside the next one.""" # Items 3 and 4 touch other parts of one file, and item 6 touches what item 3 does. diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py new file mode 100644 index 00000000..018db070 --- /dev/null +++ b/bin/chunk_preflight/test_indentation.py @@ -0,0 +1,72 @@ +import os +import pathlib +import subprocess +import sys +import tempfile +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from chunk_preflight.indentation import space_indented, SpaceIndented +from failure import Failure +from test_env import isolated_env + +TABBED = "def run():\n\tif True:\n\t\treturn 1\n" +SPACED = "def run():\n if True:\n return 1\n" + + +class SpaceIndentation(unittest.TestCase): + """Each case is a fake checkout whose tracked files are those given.""" + + def checkout(self, **files): + temp = tempfile.TemporaryDirectory() + self.addCleanup(temp.cleanup) + root = pathlib.Path(os.path.realpath(temp.name)) + for name, text in files.items(): + path = root / name.replace("__", "/") + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(text) + subprocess.run(["git", "init", "--quiet"], cwd=root, check=True, env=isolated_env()) + subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=isolated_env()) + return root + + def test_stays_silent_for_code_indented_with_tabs(self): + self.assertIsNone(space_indented(self.checkout(**{"app.py": TABBED}))) + + def test_counts_the_lines_of_code_indented_with_spaces_where_no_tool_setting_says_so(self): + root = self.checkout(**{"app.py": SPACED, "lib__more.rs": SPACED, "web__page.ts": TABBED, "README.md": SPACED}) + self.assertEqual(space_indented(root), SpaceIndented(spaced=4, tabbed=2)) + + def test_stays_silent_where_a_tool_reads_a_setting_that_says_so(self): + settings = { + "editorconfig": (".editorconfig", "[*]\nindent_style = space\n"), + "rustfmt": ("rustfmt.toml", "hard_tabs = false\n"), + "prettier": (".prettierrc.json", '{"useTabs": false}\n'), + "prettier in package.json": ("package.json", '{"prettier": {"useTabs": false}}\n'), + "biome": ("biome.jsonc", '{"formatter": {"indentStyle": "space"}}\n'), + "a nested editorconfig": ("src__.editorconfig", "indent_style = space\n"), + } + for label, (name, text) in settings.items(): + with self.subTest(label): + self.assertIsNone(space_indented(self.checkout(**{"app.py": SPACED, name: text}))) + + def test_reports_a_file_that_names_no_such_setting(self): + for name, text in ((".editorconfig", "[*]\nend_of_line = lf\n"), ("package.json", '{"name": "x"}\n'), ("notes.txt", "indent_style = space\n")): + with self.subTest(name): + self.assertIsInstance(space_indented(self.checkout(**{"app.py": SPACED, name: text})), SpaceIndented) + + def test_stays_silent_for_a_repo_without_code(self): + self.assertIsNone(space_indented(self.checkout(**{"README.md": SPACED, "data.json": SPACED, "ci.yml": SPACED}))) + + def test_leaves_out_vendored_code(self): + self.assertIsNone(space_indented(self.checkout(**{"vendor__lib.py": SPACED, "web__node_modules__x__index.js": SPACED}))) + + def test_stays_silent_where_tabs_are_as_many_as_spaces(self): + self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": TABBED}))) + + def test_says_why_it_cannot_read_a_checkout(self): + self.assertIsInstance(space_indented(pathlib.Path("/nonexistent-checkout")), Failure) + + +if __name__ == "__main__": + unittest.main() diff --git a/principles/technical-principles.md b/principles/technical-principles.md index bde9eb8c..aa8b2f4f 100644 --- a/principles/technical-principles.md +++ b/principles/technical-principles.md @@ -70,6 +70,7 @@ - Enumerate the cases that can go wrong and return them as explicit results (e.g. a result DTO with an optional error), so failure is part of the signature instead of a hidden second channel. - try/catch lives only at the edges, wrapped tightly around the call that can actually throw (DB, HTTP, filesystem), converting the exception into an explicit result right there. Pure functions and core logic never throw or catch for control flow. - A function that both returns a result and throws for some inputs has two error channels; collapse to one. Throw only for a truly unrecoverable state. + - Where code branches on why a call failed, it reads a status code, an exit code the tool documents, or a typed error. It reads message text only where the tool documents that text as unique to one cause, and treats every other failure as unknown, which stops the run rather than guessing. Older versions of a CLI often print one message for a missing image, a refused credential and a failed request. * Commands and Queries Separation (CQS)-ish - Queries must never modify data, commands may only return data that is the result of their change. * Copy important contextual information on buisness transactions and equal data, instead of referencing it. @@ -117,4 +118,4 @@ - A Python script with a `#!/usr/bin/env python3` shebang runs identically across systems where shell dialects and builtins differ. - Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. * Indent with hard tabs by default. - - A project's own settings win: `.editorconfig`, linter/formatter config (Prettier, `rustfmt.toml`, …), or the surrounding file's existing indentation. + - Only a setting a tool reads overrides it: `.editorconfig` or a formatter's config (Prettier, `rustfmt.toml`, Biome, …), plus a decision in `docs/decisions.md` that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, doesn't. Output formats a spec fixes, such as a spelling's JSON, are outside the rule. `chunk-preflight` reports space-indented code that has no such setting. -- 2.52.0 From e785ce8f6be474002a34b28da86fefc8fff06d77 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:16:10 +0100 Subject: [PATCH 02/13] Sort the new imports by first binding --- bin/chunk_preflight/facts.py | 2 +- bin/chunk_preflight/main.py | 2 +- bin/chunk_preflight/test_chunk_preflight.py | 2 +- bin/chunk_preflight/test_indentation.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index d7121a4e..38541271 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -5,10 +5,10 @@ from release_plan.next_chunk import cut_name, NextChunk, NoItem from release_plan.release_standing import dated_cut, LastCut, unreleased_entries, UNSEEN_RELEASES from failure import Failure from forge.commands import Forge -from chunk_preflight.indentation import SpaceIndented from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran from text_files.markdown_text import listed, quoted from chunk_preflight.choices import PULLS_LIST +from chunk_preflight.indentation import SpaceIndented from plan.release import version diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index 30bc9ce5..a58f166a 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -98,7 +98,6 @@ from git_cli import epic_branch from failure import Failure from forge.commands import Forge, forge_of, Run, runner from chunk_preflight.gathered import Gathered, ItemFacts, LeftWorktree, NamedPath, Ran, Worktree -from chunk_preflight.indentation import space_indented from chunk_preflight.facts import JOINING_DETAILS, render from project_config.main import located from forge.pulls import merged_pull @@ -107,6 +106,7 @@ from release_plan.next_chunk import NextChunk, NoItem, plan_name, planned from release_plan.release_standing import project_plan from project_config.settings import ProjectConfig from chunk_preflight.choices import pulls_command, worktree_add, worktree_on, worktrees +from chunk_preflight.indentation import space_indented from project_config import templates BIN = pathlib.Path(__file__).resolve().parents[1] diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index 01ec521f..f23f23ac 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -22,8 +22,8 @@ from release_plan.release_standing import LastCut, UNSEEN_RELEASES from release_plan.awaiting_merge import marked from release_plan import next_chunk from chunk_preflight.facts import open_pulls, render -from chunk_preflight.indentation import SpaceIndented from plan_store.todo_md import plan_of +from chunk_preflight.indentation import SpaceIndented from chunk_preflight.choices import worktree_add, worktree_on, worktrees from project_config.doubles import write_config diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py index 018db070..f2c5bba2 100644 --- a/bin/chunk_preflight/test_indentation.py +++ b/bin/chunk_preflight/test_indentation.py @@ -7,9 +7,9 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from chunk_preflight.indentation import space_indented, SpaceIndented from failure import Failure from test_env import isolated_env +from chunk_preflight.indentation import space_indented, SpaceIndented TABBED = "def run():\n\tif True:\n\t\treturn 1\n" SPACED = "def run():\n if True:\n return 1\n" -- 2.52.0 From 8ce06dd983a641f63e3f467b8c18ce3b59641713 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:31:04 +0100 Subject: [PATCH 03/13] Kill the surviving mutants of the indentation check --- bin/chunk_preflight/test_indentation.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py index f2c5bba2..e6902346 100644 --- a/bin/chunk_preflight/test_indentation.py +++ b/bin/chunk_preflight/test_indentation.py @@ -45,6 +45,7 @@ class SpaceIndentation(unittest.TestCase): "prettier in package.json": ("package.json", '{"prettier": {"useTabs": false}}\n'), "biome": ("biome.jsonc", '{"formatter": {"indentStyle": "space"}}\n'), "a nested editorconfig": ("src__.editorconfig", "indent_style = space\n"), + "an editorconfig two folders down": ("src__web__.editorconfig", "indent_style = space\n"), } for label, (name, text) in settings.items(): with self.subTest(label): @@ -64,6 +65,26 @@ class SpaceIndentation(unittest.TestCase): def test_stays_silent_where_tabs_are_as_many_as_spaces(self): self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": TABBED}))) + def test_sums_the_tabbed_lines_of_every_file(self): + self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": SPACED, "c.py": TABBED, "d.py": TABBED, "e.py": TABBED}))) + + def test_skips_a_tracked_file_that_is_gone_from_the_disk(self): + root = self.checkout(**{"a.py": SPACED, "gone.py": SPACED}) + (root / "gone.py").unlink() + self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0)) + + def test_reads_a_file_that_is_not_utf8(self): + root = self.checkout(**{"a.py": ""}) + (root / "a.py").write_bytes(b"\xff\xfe\n x\n y\n") + self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0)) + + @unittest.skipIf(os.geteuid() == 0, "root reads any file") + def test_names_a_file_it_cannot_read(self): + root = self.checkout(**{"a.py": SPACED}) + (root / "a.py").chmod(0) + self.addCleanup((root / "a.py").chmod, 0o644) + self.assertEqual(space_indented(root), Failure(f"cannot read a.py: [Errno 13] Permission denied: '{root}/a.py'")) + def test_says_why_it_cannot_read_a_checkout(self): self.assertIsInstance(space_indented(pathlib.Path("/nonexistent-checkout")), Failure) -- 2.52.0 From d107ae0bb7cc5a6ed3d9fa365651f147a20721f8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:31:52 +0100 Subject: [PATCH 04/13] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20the=20pass?= =?UTF-8?q?=20found=20nothing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From bbaa56d0eca207352b77151247c25100da9a934a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:51:44 +0100 Subject: [PATCH 05/13] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20skip=20vend?= =?UTF-8?q?ored=20settings=20files,=20test=20the=20worktree=20read,=20use?= =?UTF-8?q?=20assert=5Fnot=5Froot,=20read=20a=20file=20name=20that=20is=20?= =?UTF-8?q?not=20UTF-8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/chunk_preflight/indentation.py | 8 +++++--- bin/chunk_preflight/test_chunk_preflight.py | 9 +++++++++ bin/chunk_preflight/test_indentation.py | 18 ++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/bin/chunk_preflight/indentation.py b/bin/chunk_preflight/indentation.py index 4a73e4c0..86ac098b 100644 --- a/bin/chunk_preflight/indentation.py +++ b/bin/chunk_preflight/indentation.py @@ -34,12 +34,14 @@ class SpaceIndented: def space_indented(base: pathlib.Path, timeout: float | None = None) -> SpaceIndented | Failure | None: """The line counts of the tracked code under base where it has more space-indented lines than tab-indented ones and no tracked file sets the indent; None where it doesn't, or has no code; a Failure where a file cannot be read.""" - tracked = git("ls-files", "-z", cwd=str(base), timeout=timeout) + tracked = git("ls-files", "-z", cwd=str(base), timeout=timeout, errors="replace") if isinstance(tracked, Failure): return tracked spaced = tabbed = 0 for name in filter(None, tracked.split("\0")): - code = CODE.fullmatch(name) and not VENDORED.search(name) + if VENDORED.search(name): + continue + code = CODE.fullmatch(name) key = next((key for pattern, key in SETTINGS if pattern.fullmatch(name.rsplit("/", 1)[-1])), None) path = base / name if not (code or key) or not os.path.isfile(path): @@ -47,7 +49,7 @@ def space_indented(base: pathlib.Path, timeout: float | None = None) -> SpaceInd try: text = path.read_text(encoding="utf-8", errors="replace") except OSError as failure: - return Failure(f"cannot read {name}: {failure}") + return Failure(f"{name}: {failure}") if key and key in text: return None if code: diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index f23f23ac..2afb7443 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -830,6 +830,15 @@ class IndentationFact(unittest.TestCase): spaced.commit(spaced.root, "setting") self.assertNotIn("space-indented", spaced.preflight().stdout) + def test_reads_the_item_worktree_made_off_origins_default_branch_not_the_checkout(self): + repo = Repo(self) + repo.write(repo.root, "src/app.py", "def run():\n if True:\n return 1\n") + repo.commit(repo.root, "spaces, not pushed") + self.assertIn("space-indented", repo.preflight().stdout) + done = repo.preflight("--worktree") + self.assertEqual(done.returncode, 0, done.stderr) + self.assertNotIn("space-indented", done.stdout, "the worktree holds origin/main, whose code is indented with tabs") + class BesideTest(unittest.TestCase): """The fact that names the items that may start chunks beside the next one.""" diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py index e6902346..9b8e1015 100644 --- a/bin/chunk_preflight/test_indentation.py +++ b/bin/chunk_preflight/test_indentation.py @@ -8,7 +8,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure -from test_env import isolated_env +from test_env import assert_not_root, isolated_env from chunk_preflight.indentation import space_indented, SpaceIndented TABBED = "def run():\n\tif True:\n\t\treturn 1\n" @@ -59,8 +59,16 @@ class SpaceIndentation(unittest.TestCase): def test_stays_silent_for_a_repo_without_code(self): self.assertIsNone(space_indented(self.checkout(**{"README.md": SPACED, "data.json": SPACED, "ci.yml": SPACED}))) - def test_leaves_out_vendored_code(self): + def test_leaves_out_vendored_code_and_the_settings_files_it_holds(self): self.assertIsNone(space_indented(self.checkout(**{"vendor__lib.py": SPACED, "web__node_modules__x__index.js": SPACED}))) + vendored = self.checkout(**{"a.py": SPACED, "vendor__lib__.editorconfig": "indent_style = space\n", "third_party__x__package.json": '{"useTabs": false}'}) + self.assertEqual(space_indented(vendored), SpaceIndented(spaced=2, tabbed=0)) + + def test_reads_a_checkout_with_a_file_name_that_is_not_utf8(self): + root = self.checkout(**{"a.py": SPACED}) + (root / os.fsdecode(b"caf\xe9.py")).write_text(SPACED) + subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=isolated_env()) + self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0)) def test_stays_silent_where_tabs_are_as_many_as_spaces(self): self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": TABBED}))) @@ -78,12 +86,14 @@ class SpaceIndentation(unittest.TestCase): (root / "a.py").write_bytes(b"\xff\xfe\n x\n y\n") self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0)) - @unittest.skipIf(os.geteuid() == 0, "root reads any file") def test_names_a_file_it_cannot_read(self): + assert_not_root(self) root = self.checkout(**{"a.py": SPACED}) (root / "a.py").chmod(0) self.addCleanup((root / "a.py").chmod, 0o644) - self.assertEqual(space_indented(root), Failure(f"cannot read a.py: [Errno 13] Permission denied: '{root}/a.py'")) + failed = space_indented(root) + self.assertIsInstance(failed, Failure) + self.assertTrue(failed.reason.startswith("a.py: "), failed.reason) def test_says_why_it_cannot_read_a_checkout(self): self.assertIsInstance(space_indented(pathlib.Path("/nonexistent-checkout")), Failure) -- 2.52.0 From 86f67899f62f6767e32843ba7e8ef330420ea041 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:52:03 +0100 Subject: [PATCH 06/13] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20tell=20t?= =?UTF-8?q?he=20worker=20what=20to=20do=20with=20the=20fact,=20name=20the?= =?UTF-8?q?=20decision=20log,=20say=20what=20a=20space-indented=20file=20k?= =?UTF-8?q?eeps=20meanwhile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/chunk_preflight/facts.py | 4 ++-- bin/chunk_preflight/test_chunk_preflight.py | 2 +- principles/technical-principles.md | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index 38541271..a8fc9ce0 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -40,12 +40,12 @@ def merge_lines(found: Gathered) -> list[str]: def indentation_lines(found: SpaceIndented | Failure | None) -> list[str]: - """The one fact about indentation: the project's code is space-indented with no setting that says so. It only reports: a client's repo belongs to its team.""" + """The fact about indentation, where the project's code is space-indented and no setting sets the indent, else why that cannot be read. It reports only and never fails the run, since a client's repo belongs to its team.""" if isinstance(found, Failure): return [f"- Whether the project's code is space-indented cannot be read: {found.reason}"] if found is None: return [] - return [f"- The project's code is space-indented ({found.spaced} lines against {found.tabbed} with tabs), and no `.editorconfig` with `indent_style` nor formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) says so. The technical principles indent with hard tabs unless a setting a tool reads, plus a decision in `docs/decisions.md` that names the reason, overrides that. Either convert the code to tabs, or record the override in `.editorconfig` and a decision."] + return [f"- The project's code is space-indented ({found.spaced} lines against {found.tabbed} with tabs), and neither an `.editorconfig` with `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the indent. The technical principles indent with hard tabs unless a setting a tool reads, plus a decision in the project's decision log that names the reason, overrides that. Don't reindent in a chunk with another purpose. Where the plan holds no item for either way out, file one: convert the code to tabs, or record the override in `.editorconfig` and a decision."] def last_release(default: str, release: LastCut) -> str: diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index 2afb7443..44a76492 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -811,7 +811,7 @@ class IndentationFact(unittest.TestCase): (line,) = self.said(SpaceIndented(spaced=120, tabbed=3)) self.assertIn("space-indented (120 lines against 3 with tabs)", line) self.assertIn("The technical principles indent with hard tabs", line) - self.assertIn("convert the code to tabs, or record the override in `.editorconfig` and a decision", line) + self.assertIn("file one: convert the code to tabs, or record the override in `.editorconfig` and a decision", line) def test_says_nothing_where_the_code_is_not_space_indented_and_why_where_it_cannot_be_read(self): self.assertEqual(self.said(None), []) diff --git a/principles/technical-principles.md b/principles/technical-principles.md index aa8b2f4f..3157a948 100644 --- a/principles/technical-principles.md +++ b/principles/technical-principles.md @@ -70,7 +70,7 @@ - Enumerate the cases that can go wrong and return them as explicit results (e.g. a result DTO with an optional error), so failure is part of the signature instead of a hidden second channel. - try/catch lives only at the edges, wrapped tightly around the call that can actually throw (DB, HTTP, filesystem), converting the exception into an explicit result right there. Pure functions and core logic never throw or catch for control flow. - A function that both returns a result and throws for some inputs has two error channels; collapse to one. Throw only for a truly unrecoverable state. - - Where code branches on why a call failed, it reads a status code, an exit code the tool documents, or a typed error. It reads message text only where the tool documents that text as unique to one cause, and treats every other failure as unknown, which stops the run rather than guessing. Older versions of a CLI often print one message for a missing image, a refused credential and a failed request. + - Where code branches on why a call failed, it reads a status code, an exit code the tool documents, or a typed error. It reads message text only where the tool documents that text as unique to one cause, and treats every other failure as unknown, which stops the run. * Commands and Queries Separation (CQS)-ish - Queries must never modify data, commands may only return data that is the result of their change. * Copy important contextual information on buisness transactions and equal data, instead of referencing it. @@ -118,4 +118,6 @@ - A Python script with a `#!/usr/bin/env python3` shebang runs identically across systems where shell dialects and builtins differ. - Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. * Indent with hard tabs by default. - - Only a setting a tool reads overrides it: `.editorconfig` or a formatter's config (Prettier, `rustfmt.toml`, Biome, …), plus a decision in `docs/decisions.md` that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, doesn't. Output formats a spec fixes, such as a spelling's JSON, are outside the rule. `chunk-preflight` reports space-indented code that has no such setting. + - Overriding it takes two things: a setting a tool reads (`.editorconfig` or a formatter's config, such as Prettier, `rustfmt.toml` or Biome) and a decision in the decision log that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, doesn't override it. + - Files whose format fixes their indentation, such as YAML (no tabs) or a spelling's JSON, are outside the rule. + - A file already indented with spaces keeps them until the project converts it or records the override, so no file mixes the two. `chunk-preflight` reports a project in that state where `.editorconfig`, `rustfmt.toml`, Prettier and Biome set nothing about it. -- 2.52.0 From 42c5ff83256e5c86cf62ebbe62852a569a248414 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:52:45 +0100 Subject: [PATCH 07/13] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=205=20=F0=9F=9F=A1=20(0=20misread);=20say=20what?= =?UTF-8?q?=20the=20check=20counts=20and=20what=20a=20setting=20does,=20an?= =?UTF-8?q?d=20tighten=20the=20docstrings=20and=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/chunk_preflight/gathered.py | 2 +- bin/chunk_preflight/indentation.py | 8 ++++---- bin/chunk_preflight/main.py | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/chunk_preflight/gathered.py b/bin/chunk_preflight/gathered.py index b7de48b8..051d3fda 100644 --- a/bin/chunk_preflight/gathered.py +++ b/bin/chunk_preflight/gathered.py @@ -76,5 +76,5 @@ class Gathered: merges_unread: Failure | None = None # The worktrees `chunk-pr clean` is still to remove. left: tuple[LeftWorktree, ...] = () - # The line counts of the project's code where it is space-indented with no setting that says so, or why they cannot be read; None where it is not. + # The line counts of the project's code where it is space-indented and no setting sets the indent, or why they cannot be read; None where it is not. indentation: SpaceIndented | Failure | None = None diff --git a/bin/chunk_preflight/indentation.py b/bin/chunk_preflight/indentation.py index 86ac098b..6f445152 100644 --- a/bin/chunk_preflight/indentation.py +++ b/bin/chunk_preflight/indentation.py @@ -1,4 +1,4 @@ -"""Whether a project's code is space-indented with no tool setting that says so. +"""Whether a project's code is space-indented where no tool setting sets the indent. The technical principles indent with hard tabs by default, and let a setting a tool reads override that. Code that is mostly space-indented, with no such setting, reads as a first session's habit that later sessions followed, not as a choice.""" import dataclasses @@ -9,11 +9,11 @@ import re from failure import Failure from git_cli.git_repo import git -# The files the project's language tooling covers. Markdown, JSON and YAML are not code: their indentation is a format's. +# Files of common programming languages, by extension. Markdown, JSON and YAML aren't code: a format fixes their indentation. CODE = re.compile(r".*\.(py|js|mjs|cjs|jsx|ts|tsx|rs|go|php|java|kt|kts|scala|rb|c|h|cc|cpp|hpp|cs|swift|sh|bash|lua|ex|exs|dart|vue|svelte)", re.IGNORECASE) # Committed copies of other people's code follow their authors' style. VENDORED = re.compile(r"(^|/)(vendor|node_modules|third_party)/") -# The files whose key says how to indent: an `.editorconfig` with `indent_style`, rustfmt's `hard_tabs`, Prettier's `useTabs` in its own files or a `package.json`, Biome's `indentStyle`. +# The key that, present in a file of that name, means the project sets its indent, whatever the key's value. Prettier also reads `package.json`. SETTINGS = ( (re.compile(r"\.editorconfig"), "indent_style"), (re.compile(r"\.?rustfmt\.toml"), "hard_tabs"), @@ -33,7 +33,7 @@ class SpaceIndented: def space_indented(base: pathlib.Path, timeout: float | None = None) -> SpaceIndented | Failure | None: - """The line counts of the tracked code under base where it has more space-indented lines than tab-indented ones and no tracked file sets the indent; None where it doesn't, or has no code; a Failure where a file cannot be read.""" + """The line counts of the tracked code under base, where it has more space-indented than tab-indented lines and no tracked file holds an indent key; else None. A Failure where git cannot list the files or a file cannot be read.""" tracked = git("ls-files", "-z", cwd=str(base), timeout=timeout, errors="replace") if isinstance(tracked, Failure): return tracked diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index a58f166a..607dc661 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -21,11 +21,12 @@ and prints that the release reviews and the cuts are the human's to call. It pri finished on the branch of an open pull request that is not a draft, where the checkout holds the plan. Where no item of the release can start and one awaits such a merge, it names those pull requests and says the working loop stops there; -- where the project's tracked code (the files its language tooling covers, not Markdown, JSON or - YAML) has more space-indented than tab-indented lines, and neither an `.editorconfig` with - `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome - `indentStyle`) says so, one line naming the technical principles' hard-tabs default and the two - ways out. It only reports; +- where the project's tracked code (files of common programming languages, by extension; not + Markdown, JSON or YAML, nor anything under vendor/, node_modules/ or third_party/) has more + space-indented than tab-indented lines, and neither an `.editorconfig` with `indent_style` nor a + formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the + indent, one line naming the technical principles' hard-tabs default and the two ways out. It + reports only, and never fails the run; - the next release and its first item that does not wait, the item loop-claude routes on, with its L and E + I; with --item , the plan item of that ID instead, which loop-claude names in a window named for an item. An item waits while it is marked question, while an item still in todo.md -- 2.52.0 From c4c2508488186e99cd8c1e108db19b571ae5e170 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 15:55:32 +0100 Subject: [PATCH 08/13] Sort test_indentation's imports by first binding --- bin/chunk_preflight/test_indentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py index 9b8e1015..549420fe 100644 --- a/bin/chunk_preflight/test_indentation.py +++ b/bin/chunk_preflight/test_indentation.py @@ -7,8 +7,8 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from failure import Failure from test_env import assert_not_root, isolated_env +from failure import Failure from chunk_preflight.indentation import space_indented, SpaceIndented TABBED = "def run():\n\tif True:\n\t\treturn 1\n" -- 2.52.0 From 237a3e05ff5cb36bddf4cf3b12d13d4659e7f171 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 16:07:21 +0100 Subject: [PATCH 09/13] Order the vendored-settings test so a skipped file doesn't hide a break --- bin/chunk_preflight/test_indentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py index 549420fe..eeb594d9 100644 --- a/bin/chunk_preflight/test_indentation.py +++ b/bin/chunk_preflight/test_indentation.py @@ -61,7 +61,7 @@ class SpaceIndentation(unittest.TestCase): def test_leaves_out_vendored_code_and_the_settings_files_it_holds(self): self.assertIsNone(space_indented(self.checkout(**{"vendor__lib.py": SPACED, "web__node_modules__x__index.js": SPACED}))) - vendored = self.checkout(**{"a.py": SPACED, "vendor__lib__.editorconfig": "indent_style = space\n", "third_party__x__package.json": '{"useTabs": false}'}) + vendored = self.checkout(**{"z.py": SPACED, "vendor__lib__.editorconfig": "indent_style = space\n", "third_party__x__package.json": '{"useTabs": false}'}) self.assertEqual(space_indented(vendored), SpaceIndented(spaced=2, tabbed=0)) def test_reads_a_checkout_with_a_file_name_that_is_not_utf8(self): -- 2.52.0 From a8dc5867a7b4139a3f84628c52e65db3c83ef773 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 16:08:59 +0100 Subject: [PATCH 10/13] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20approved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 0b891b06d8402b1b5dd972305fa8f585c30abdb5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 16:08:59 +0100 Subject: [PATCH 11/13] =?UTF-8?q?Answer=20prose=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20say=20what?= =?UTF-8?q?=20the=20tabs=20rule=20leaves=20out,=20and=20when=20chunk-prefl?= =?UTF-8?q?ight=20reports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/chunk_preflight/indentation.py | 2 +- principles/technical-principles.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/chunk_preflight/indentation.py b/bin/chunk_preflight/indentation.py index 6f445152..51c3f6dc 100644 --- a/bin/chunk_preflight/indentation.py +++ b/bin/chunk_preflight/indentation.py @@ -9,7 +9,7 @@ import re from failure import Failure from git_cli.git_repo import git -# Files of common programming languages, by extension. Markdown, JSON and YAML aren't code: a format fixes their indentation. +# Files of common programming languages, by extension. The check skips Markdown, JSON and YAML, which are prose or data. CODE = re.compile(r".*\.(py|js|mjs|cjs|jsx|ts|tsx|rs|go|php|java|kt|kts|scala|rb|c|h|cc|cpp|hpp|cs|swift|sh|bash|lua|ex|exs|dart|vue|svelte)", re.IGNORECASE) # Committed copies of other people's code follow their authors' style. VENDORED = re.compile(r"(^|/)(vendor|node_modules|third_party)/") diff --git a/principles/technical-principles.md b/principles/technical-principles.md index 3157a948..50bcdedd 100644 --- a/principles/technical-principles.md +++ b/principles/technical-principles.md @@ -119,5 +119,5 @@ - Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. * Indent with hard tabs by default. - Overriding it takes two things: a setting a tool reads (`.editorconfig` or a formatter's config, such as Prettier, `rustfmt.toml` or Biome) and a decision in the decision log that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, doesn't override it. - - Files whose format fixes their indentation, such as YAML (no tabs) or a spelling's JSON, are outside the rule. - - A file already indented with spaces keeps them until the project converts it or records the override, so no file mixes the two. `chunk-preflight` reports a project in that state where `.editorconfig`, `rustfmt.toml`, Prettier and Biome set nothing about it. + - A format that forbids tabs, such as YAML, and output a spec fixes, such as a JSON example it prints, are outside the rule. + - A file already indented with spaces keeps them until the project converts it or records the override, so no file mixes the two. `chunk-preflight` reports a project whose code is mostly indented with spaces where `.editorconfig`, `rustfmt.toml`, Prettier and Biome set nothing about it. -- 2.52.0 From e3616bdd833777ca788fbc6bb92bf3dd226b86e8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 16:17:53 +0100 Subject: [PATCH 12/13] Finish item 542 in the plan --- CHANGELOG.md | 1 + todo.md | 19 ------------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4bce196..1cbfab72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `chunk-preflight` reports a project whose tracked code is mostly space-indented while no `.editorconfig` or formatter setting sets the indent, and the technical principles' hard-tabs default is overridden only by such a setting plus a recorded decision. - `chunk-pr push` waits for the forge to show the pushed commit as the head of the branch's open pull request before it asks for a review, and fails naming the pull request where the forge does not. - `chunk-pr merge` honours `merge = "human"` and `wait-for-approval` for a chunk whose recorded base is origin's default branch. - larv-review's claimed-output step runs each claim in a fresh clone, without the ignored files earlier runs wrote, and checks claims about what a command writes. diff --git a/todo.md b/todo.md index 3f0d51ef..88151c14 100644 --- a/todo.md +++ b/todo.md @@ -14,7 +14,6 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 477 | 0.17.0 | | question | **Rewrite `## Goals` and `## Audience` for a setup others install and run apart from their own `~/.claude`.** | 1 | 1 | 2 | 2 | 2 | | 0.0 | | 478 | 0.17.0 | | question | **Name the project, its repo and its two commands, today proposed as `do-release` and `do-epic`.** | 1 | 1 | 2 | 2 | 1 | | 0.0 | -| 542 | 0.17.0 | | | **Make chunk-preflight report a project whose code is space-indented with no `.editorconfig` or formatter setting that says so, and narrow the tabs principle to explicit overrides.** | 2 | 2 | 3 | 5 | 4 | 1.1 by 4 | 1.2 | | 523 | 0.17.0 | | | **Make the security pass and stability-reviewer check that a new secret's docs name its scope and its reach, such as the other repositories its account can use.** | 1 | 1 | 2 | 2 | 1 | 1.1 by 2 | 0.9 | | 547 | 0.17.0 | | | **Add a technical principle: tell a failure's cause from a status code or a typed error, never from a tool's message text unless the tool documents that text as unique to the cause.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.9 | | 541 | 0.17.0 | | | **Find a Gitea pull request by its branch and head however many pull requests are newer, so `chunk-pr clean`, `chunk-pr merge` and `chunk-preflight` see an older one.** | 2 | 2 | 3 | 5 | 2 | 1 by 2 | 0.8 | @@ -119,24 +118,6 @@ Part of the standalone-install plan lilleman approved on 2026-11-20. `do-release Part of the standalone-install plan lilleman approved on 2026-11-20. Later items say `do-release` and `do-epic` for the names this item picks. The names set the install folders, such as `~/.config/do-release/`, so items 482, 485 and 496, and every item they block, wait for them. -### 542. Make chunk-preflight report a project whose code is space-indented with no `.editorconfig` or formatter setting that says so, and narrow the tabs principle to explicit overrides. - -`principles/technical-principles.md` says "Indent with hard tabs by default. A project's own settings win: `.editorconfig`, linter/formatter config, or the surrounding file's existing indentation." The last clause lets a first session set spaces and every later session follow it, and nothing checks that anyone chose it. adf-codec's `AGENTS.md` has said "Two-space indent" since its first commit, with no reason, and 177 code files, 14,500 indented lines, followed it. A survey of the projects on this machine on 2026-11-26 found the same in plainpages, scheduler (`rustfmt.toml` doesn't set `hard_tabs`), oss-opportunity-research, secondhand-watch and playwright-for-agents. Only plainpages-plugin-fastjira says so in an `.editorconfig`. - -Two changes, the tool first: - -- `chunk-preflight` prints one fact where the project's tracked code (the files its language tooling covers, not Markdown, JSON or YAML) has more space-indented than tab-indented lines, and neither an `.editorconfig` with `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) says so. The fact names the principle and the two ways out: convert to tabs, or record the override in `.editorconfig` and a decision. It reports and never fails, since a client's repo belongs to its team. -- The principle's override clause counts only a setting a tool reads, `.editorconfig` or a formatter's config, plus a decision in `docs/decisions.md` that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, no longer overrides it. Output formats a spec fixes, such as a spelling's JSON, are outside the rule. - -Test it with a fake checkout per case: tabs, spaces with a setting, spaces without one, and a repo of Markdown only. - -Touches: - -- `bin/chunk_preflight/facts.py` -- `bin/chunk_preflight/gathered.py` -- `bin/chunk_preflight/test_chunk_preflight.py` -- `principles/technical-principles.md`: `* Indent with hard tabs by default.` (small) - ### 523. Make the security pass and stability-reviewer check that a new secret's docs name its scope and its reach, such as the other repositories its account can use. An outside reviewer found it on a client project's PR that added a secret: a Gitea token documented as able to run Actions on one repository, "and nothing wider". The token reaches every repository its owning account can, so the docs had to require a dedicated account with access to that repository only. Neither `/security-review` nor stability-reviewer raised it. Where a change adds a secret or a token, ask each to check that the doc beside it states what the credential can reach, not only what the change uses it for. -- 2.52.0 From a5b75eab86077dd7c8ce1a6b19f0fe02849995f3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 27 Nov 2026 16:17:53 +0100 Subject: [PATCH 13/13] Finish item 547 in the plan --- CHANGELOG.md | 1 + todo.md | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cbfab72..e8838b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- The technical principles ask code to read why a call failed from a status code, a documented exit code or a typed error, and not from message text. - `chunk-preflight` reports a project whose tracked code is mostly space-indented while no `.editorconfig` or formatter setting sets the indent, and the technical principles' hard-tabs default is overridden only by such a setting plus a recorded decision. - `chunk-pr push` waits for the forge to show the pushed commit as the head of the branch's open pull request before it asks for a review, and fails naming the pull request where the forge does not. - `chunk-pr merge` honours `merge = "human"` and `wait-for-approval` for a chunk whose recorded base is origin's default branch. diff --git a/todo.md b/todo.md index 88151c14..6394897f 100644 --- a/todo.md +++ b/todo.md @@ -15,7 +15,6 @@ | 477 | 0.17.0 | | question | **Rewrite `## Goals` and `## Audience` for a setup others install and run apart from their own `~/.claude`.** | 1 | 1 | 2 | 2 | 2 | | 0.0 | | 478 | 0.17.0 | | question | **Name the project, its repo and its two commands, today proposed as `do-release` and `do-epic`.** | 1 | 1 | 2 | 2 | 1 | | 0.0 | | 523 | 0.17.0 | | | **Make the security pass and stability-reviewer check that a new secret's docs name its scope and its reach, such as the other repositories its account can use.** | 1 | 1 | 2 | 2 | 1 | 1.1 by 2 | 0.9 | -| 547 | 0.17.0 | | | **Add a technical principle: tell a failure's cause from a status code or a typed error, never from a tool's message text unless the tool documents that text as unique to the cause.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.9 | | 541 | 0.17.0 | | | **Find a Gitea pull request by its branch and head however many pull requests are newer, so `chunk-pr clean`, `chunk-pr merge` and `chunk-preflight` see an older one.** | 2 | 2 | 3 | 5 | 2 | 1 by 2 | 0.8 | | 545 | 0.17.0 | | | **Have chunk-preflight name each next-release item with no `Touches:` list while others wait, and have loop-claude launch a subagent that writes the lists before it starts the next chunk.** | 3 | 2 | 3 | 6 | 6 | 1.1 by 4 | 0.6 | | 539 | 0.17.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test kept in a file of its own.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 | @@ -122,18 +121,6 @@ Part of the standalone-install plan lilleman approved on 2026-11-20. Later items An outside reviewer found it on a client project's PR that added a secret: a Gitea token documented as able to run Actions on one repository, "and nothing wider". The token reaches every repository its owning account can, so the docs had to require a dedicated account with access to that repository only. Neither `/security-review` nor stability-reviewer raised it. Where a change adds a secret or a token, ask each to check that the doc beside it states what the credential can reach, not only what the change uses it for. -### 547. Add a technical principle: tell a failure's cause from a status code or a typed error, never from a tool's message text unless the tool documents that text as unique to the cause. - -An outside auto-reviewer found a fault that our passes missed. A script told a missing container image apart from one it couldn't read by matching the text a CLI printed on stderr. Older versions of that CLI print the same text for a missing image, a refused credential and a failed request. So the script read "no access" as "missing" and went on as if the image didn't exist. The stability and security passes both read the code and took the message at its word. - -The fix asked the registry's HTTP API for the status instead: 404 is missing, and any other failure stops the run. The principle makes that the rule. Where code branches on why a call failed, it reads a status code, an exit code the tool documents, or a typed error. It reads message text only where the tool documents that text as unique to one cause, and it treats every other failure as unknown, which stops the run rather than guessing. - -No deterministic check fits: a linter can't tell whether a string match on output decides a failure's cause. Reviewers apply the principles, so a principle is the first place that fits. - -Touches: - -- `principles/technical-principles.md`: `Handle errors explicitly, as values — avoid the exception path.` (small) - ### 541. Find a Gitea pull request by its branch and head however many pull requests are newer, so `chunk-pr clean`, `chunk-pr merge` and `chunk-preflight` see an older one. Today `pull_at` in `bin/forge/pulls.py` reads only Gitea's first page of 50 pull requests, open or closed, and looks for the branch among them. A pull request with 50 newer ones in that state is missed. PR #652 here merged after 50+ newer PRs had closed, and `chunk-pr clean` then said "no merged pull request from filing-prose-reentry", leaving the worktree and branch to remove by hand. The same lookup serves `open_pull`, so `ready` and `merge` miss an old open one too, and `chunk-preflight` misses a merged chunk's worktree. -- 2.52.0