Name what the premises lack when loop-claude exits without them
This commit is contained in:
@@ -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.
|
||||
|
||||
+7
-4
@@ -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']}"
|
||||
|
||||
|
||||
|
||||
+28
-2
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user