From 17dd4470560f9dec26eade0238732441de18b70f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:21:57 +0200 Subject: [PATCH 1/5] Name what the premises lack when loop-claude exits without them --- CHANGELOG.md | 1 + bin/loop-claude | 11 +++++++---- bin/test_loop_claude.py | 30 ++++++++++++++++++++++++++++-- todo.md | 1 - 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec2d4392..f02acd8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,3 +20,4 @@ - `CLAUDE.md`'s negation rule opens with its scope: prose describing the code as it stands. - `larv-review`'s comprehension floor has its own heading under the architecture pass; why a project under it is fixed at the capping dimension is a decision in `docs/decisions.md`. - `review-protocol.md` says only what a reviewer records; the decision log's home and shape stay under `CLAUDE.md`. +- `loop-claude`'s no-premises exit names what is missing: `README.md` itself, a `## Goals` or `## Audience` heading, or the body under one. diff --git a/bin/loop-claude b/bin/loop-claude index a922efdb..c90be2e9 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -93,16 +93,19 @@ def sections(text): current = None elif current and line.strip(): found[current].append(line) - return {name: "\n".join(body) for name, body in found.items() if body} + return {name: "\n".join(body) for name, body in found.items()} def read_premises(): try: found = sections(open("README.md", encoding="utf-8").read()) except OSError: - found = {} - if not found.get("Goals") or not found.get("Audience"): - sys.exit("README.md needs ## Goals and ## Audience - no premises.") + sys.exit(f"no README.md in {os.getcwd()} - no premises.") + for name in ("Goals", "Audience"): + if name not in found: + sys.exit(f"README.md has no ## {name} heading - no premises.") + if not found[name]: + sys.exit(f"README.md has nothing under ## {name} - no premises.") return f"## Goals\n{found['Goals']}\n\n## Audience\n{found['Audience']}" diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 9119a880..44f6fa47 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -26,9 +26,35 @@ def human(content): class Sections(unittest.TestCase): - def test_keeps_only_headed_sections_with_a_body(self): + def test_keeps_every_headed_section_with_its_body(self): text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority\n\n## Empty\n\n## Audience\nme\n# Appendix\nnot audience\n" - self.assertEqual(loop.sections(text), {"Goals": "1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority", "Audience": "me"}) + self.assertEqual(loop.sections(text), {"Goals": "1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority", "Empty": "", "Audience": "me"}) + + +class ReadPremises(unittest.TestCase): + def test_names_what_is_missing(self): + cases = [ + (None, "no README.md in"), + ("# T\n## Audience\nme\n", "no ## Goals heading"), + ("# T\n## Goals\n\n## Audience\nme\n", "nothing under ## Goals"), + ("# T\n## Goals\n1. g\n", "no ## Audience heading"), + ("# T\n## Goals\n1. g\n## Audience\n", "nothing under ## Audience"), + ] + with tempfile.TemporaryDirectory() as root: + previous = os.getcwd() + os.chdir(root) + try: + for text, missing in cases: + if text is not None: + open("README.md", "w").write(text) + with self.assertRaises(SystemExit) as stopped: + loop.read_premises() + self.assertIn(missing, stopped.exception.code) + self.assertTrue(stopped.exception.code.endswith("no premises.")) + open("README.md", "w").write("# T\n## Goals\n1. g\n## Audience\nme\n") + self.assertEqual(loop.read_premises(), "## Goals\n1. g\n\n## Audience\nme") + finally: + os.chdir(previous) class Render(unittest.TestCase): diff --git a/todo.md b/todo.md index 4b5a2adb..b7430933 100644 --- a/todo.md +++ b/todo.md @@ -4,7 +4,6 @@ Ordered by how many seats of the 2026-09-24 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- Make the missing-premises exit name what is missing: `README.md` itself, a `## Goals` or `## Audience` heading, or a body under one; today all three print the same line. - Spell the false-claim rule once under `CLAUDE.md` → "Comments and documentation" with its tie-break, the doc corrected unless consumers rely on what it promises, and cite it from "Working with the codebase", "Working loop" and the README paragraph; today four spellings, two of which disagree on which side to fix. - Derive `project()` from the checkout root, today `os.getcwd()`, so `loop-claude` run from a subdirectory joins the root's session. - Settle whether the "Expect the codebase to get smaller" bullet under `CLAUDE.md` → "One spelling per goal" names an action, and cut it if it is a forecast. -- 2.52.0 From e74b52a640094253737a14db8ed984445f2182a7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:26:17 +0200 Subject: [PATCH 2/5] Let the OS name a README.md read failure and reject a repeated premises heading --- bin/loop-claude | 23 ++++++++++-------- bin/test_loop_claude.py | 53 ++++++++++++++++++++++------------------- todo.md | 1 + 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index c90be2e9..ca737123 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -87,26 +87,29 @@ def sections(text): for line in text.splitlines(): fenced ^= line.startswith("```") if not fenced and line.startswith("## "): - current = line.strip()[3:] - found[current] = [] + current = [] + found.setdefault(line.strip()[3:], []).append(current) elif not fenced and line.startswith("# "): current = None - elif current and line.strip(): - found[current].append(line) - return {name: "\n".join(body) for name, body in found.items()} + elif current is not None and line.strip(): + current.append(line) + return {name: ["\n".join(body) for body in bodies] for name, bodies in found.items()} def read_premises(): try: found = sections(open("README.md", encoding="utf-8").read()) - except OSError: - sys.exit(f"no README.md in {os.getcwd()} - no premises.") + except OSError as failure: + sys.exit(f"README.md in {os.getcwd()}: {failure.strerror} - no premises.") for name in ("Goals", "Audience"): - if name not in found: + bodies = found.get(name, []) + if not bodies: sys.exit(f"README.md has no ## {name} heading - no premises.") - if not found[name]: + if len(bodies) > 1: + sys.exit(f"README.md has ## {name} twice - no premises.") + if not bodies[0]: sys.exit(f"README.md has nothing under ## {name} - no premises.") - return f"## Goals\n{found['Goals']}\n\n## Audience\n{found['Audience']}" + return f"## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}" def project(): diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 44f6fa47..e2e0453d 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -1,3 +1,4 @@ +import contextlib import importlib.machinery import importlib.util import json @@ -26,35 +27,37 @@ def human(content): class Sections(unittest.TestCase): - def test_keeps_every_headed_section_with_its_body(self): - text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority\n\n## Empty\n\n## Audience\nme\n# Appendix\nnot audience\n" - self.assertEqual(loop.sections(text), {"Goals": "1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority", "Empty": "", "Audience": "me"}) + def test_keeps_every_headed_section_with_its_bodies(self): + text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority\n\n## Empty\n\n## Audience\nme\n## Audience\nagain\n# Appendix\nnot audience\n" + self.assertEqual(loop.sections(text), {"Goals": ["1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority"], "Empty": [""], "Audience": ["me", "again"]}) class ReadPremises(unittest.TestCase): + def exit_message(self): + with self.assertRaises(SystemExit) as stopped: + loop.read_premises() + self.assertTrue(stopped.exception.code.endswith("no premises.")) + return stopped.exception.code + def test_names_what_is_missing(self): - cases = [ - (None, "no README.md in"), - ("# T\n## Audience\nme\n", "no ## Goals heading"), - ("# T\n## Goals\n\n## Audience\nme\n", "nothing under ## Goals"), - ("# T\n## Goals\n1. g\n", "no ## Audience heading"), - ("# T\n## Goals\n1. g\n## Audience\n", "nothing under ## Audience"), - ] - with tempfile.TemporaryDirectory() as root: - previous = os.getcwd() - os.chdir(root) - try: - for text, missing in cases: - if text is not None: - open("README.md", "w").write(text) - with self.assertRaises(SystemExit) as stopped: - loop.read_premises() - self.assertIn(missing, stopped.exception.code) - self.assertTrue(stopped.exception.code.endswith("no premises.")) - open("README.md", "w").write("# T\n## Goals\n1. g\n## Audience\nme\n") - self.assertEqual(loop.read_premises(), "## Goals\n1. g\n\n## Audience\nme") - finally: - os.chdir(previous) + texts = { + "# T\n## Audience\nme\n": "no ## Goals heading", + "# T\n## Goals\n\n## Audience\nme\n": "nothing under ## Goals", + "# T\n## Goals\n1. g\n": "no ## Audience heading", + "# T\n## Goals\n1. g\n## Audience\n": "nothing under ## Audience", + "# T\n## Goals\n1. g\n## Audience\nme\n## Goals\n": "## Goals twice", + } + with tempfile.TemporaryDirectory() as root, contextlib.chdir(root): + self.assertIn(f"README.md in {os.getcwd()}: No such file or directory", self.exit_message()) + os.mkdir("README.md") + self.assertIn("Is a directory", self.exit_message()) + os.rmdir("README.md") + for text, missing in texts.items(): + with self.subTest(missing=missing): + open("README.md", "w").write(text) + self.assertIn(missing, self.exit_message()) + open("README.md", "w").write("# T\n## Goals\n1. g\n## Audience\nme\n") + self.assertEqual(loop.read_premises(), "## Goals\n1. g\n\n## Audience\nme") class Render(unittest.TestCase): diff --git a/todo.md b/todo.md index b7430933..3866655c 100644 --- a/todo.md +++ b/todo.md @@ -8,3 +8,4 @@ Ordered by how many seats of the 2026-09-24 scoring panel (`docs/decisions.md`) - Derive `project()` from the checkout root, today `os.getcwd()`, so `loop-claude` run from a subdirectory joins the root's session. - Settle whether the "Expect the codebase to get smaller" bullet under `CLAUDE.md` → "One spelling per goal" names an action, and cut it if it is a forecast. - Re-run the four-seat scoring panel and record the score in `docs/decisions.md`; the target is every dimension at 7.0 or above. +- Exit `loop-claude` with a message, today a traceback, when `README.md` is not UTF-8. -- 2.52.0 From 33621cc6ffc902b02f4050877931329e56066a53 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:26:26 +0200 Subject: [PATCH 3/5] Say in the CHANGELOG that a repeated heading is rejected --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f02acd8c..1a129bc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,4 +20,4 @@ - `CLAUDE.md`'s negation rule opens with its scope: prose describing the code as it stands. - `larv-review`'s comprehension floor has its own heading under the architecture pass; why a project under it is fixed at the capping dimension is a decision in `docs/decisions.md`. - `review-protocol.md` says only what a reviewer records; the decision log's home and shape stay under `CLAUDE.md`. -- `loop-claude`'s no-premises exit names what is missing: `README.md` itself, a `## Goals` or `## Audience` heading, or the body under one. +- `loop-claude`'s no-premises exit names what is wrong: `README.md` unreadable, a `## Goals` or `## Audience` heading missing or repeated, or nothing under one. -- 2.52.0 From b52cecb89557a5ac6f2d4a39f2dad3107f2f9e6a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:29:38 +0200 Subject: [PATCH 4/5] Say a repeated heading appears more than once, a count the exit does not check --- CHANGELOG.md | 2 +- bin/loop-claude | 2 +- bin/test_loop_claude.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a129bc8..ad2f91ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,4 +20,4 @@ - `CLAUDE.md`'s negation rule opens with its scope: prose describing the code as it stands. - `larv-review`'s comprehension floor has its own heading under the architecture pass; why a project under it is fixed at the capping dimension is a decision in `docs/decisions.md`. - `review-protocol.md` says only what a reviewer records; the decision log's home and shape stay under `CLAUDE.md`. -- `loop-claude`'s no-premises exit names what is wrong: `README.md` unreadable, a `## Goals` or `## Audience` heading missing or repeated, or nothing under one. +- `loop-claude`'s no-premises exit names what is wrong: `README.md` the OS cannot open, a `## Goals` or `## Audience` heading missing or repeated, or nothing under one. diff --git a/bin/loop-claude b/bin/loop-claude index ca737123..6e371597 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -106,7 +106,7 @@ def read_premises(): if not bodies: sys.exit(f"README.md has no ## {name} heading - no premises.") if len(bodies) > 1: - sys.exit(f"README.md has ## {name} twice - no premises.") + sys.exit(f"README.md has ## {name} more than once - no premises.") if not bodies[0]: sys.exit(f"README.md has nothing under ## {name} - no premises.") return f"## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}" diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index e2e0453d..030010cd 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -45,7 +45,7 @@ class ReadPremises(unittest.TestCase): "# T\n## Goals\n\n## Audience\nme\n": "nothing under ## Goals", "# T\n## Goals\n1. g\n": "no ## Audience heading", "# T\n## Goals\n1. g\n## Audience\n": "nothing under ## Audience", - "# T\n## Goals\n1. g\n## Audience\nme\n## Goals\n": "## Goals twice", + "# T\n## Goals\n1. g\n## Audience\nme\n## Goals\n": "## Goals more than once", } with tempfile.TemporaryDirectory() as root, contextlib.chdir(root): self.assertIn(f"README.md in {os.getcwd()}: No such file or directory", self.exit_message()) -- 2.52.0 From ffe3f1c1e5448c23bce9d0a53ec7b3489bb6fc0c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 08:32:33 +0200 Subject: [PATCH 5/5] File the rule-wording gaps the prose pass found --- todo.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/todo.md b/todo.md index 3866655c..acc0953a 100644 --- a/todo.md +++ b/todo.md @@ -4,8 +4,9 @@ Ordered by how many seats of the 2026-09-24 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- Spell the false-claim rule once under `CLAUDE.md` → "Comments and documentation" with its tie-break, the doc corrected unless consumers rely on what it promises, and cite it from "Working with the codebase", "Working loop" and the README paragraph; today four spellings, two of which disagree on which side to fix. +- Spell the false-claim rule once under `CLAUDE.md` → "Comments and documentation", covering what a program prints, with its tie-break, the doc corrected unless consumers rely on what it promises, and cite it from "Working with the codebase", "Working loop" and the README paragraph; today four spellings, two of which disagree on which side to fix. - Derive `project()` from the checkout root, today `os.getcwd()`, so `loop-claude` run from a subdirectory joins the root's session. - Settle whether the "Expect the codebase to get smaller" bullet under `CLAUDE.md` → "One spelling per goal" names an action, and cut it if it is a forecast. - Re-run the four-seat scoring panel and record the score in `docs/decisions.md`; the target is every dimension at 7.0 or above. - Exit `loop-claude` with a message, today a traceback, when `README.md` is not UTF-8. +- Say under `CLAUDE.md` → "One spelling per goal" that one spelling in two places is the same case, and what its rejection names. -- 2.52.0