From 825872acc2f120156b9cd9538e9681e3b03a36e3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 26 Sep 2026 14:59:30 +0200 Subject: [PATCH] Exit with a message when README.md is not UTF-8 --- CHANGELOG.md | 2 +- bin/loop-claude | 2 ++ bin/test_loop_claude.py | 2 ++ todo.md | 1 - 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79fde370..ad17929f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,4 +13,4 @@ - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. - `settings.json`, the agents and the status line run on any machine unedited; the status line shows reset times in the machine's own time zone. -- `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. +- `loop-claude`'s no-premises exit names what is wrong: `README.md` the OS cannot open or that is not UTF-8, a `## Goals` or `## Audience` heading missing or repeated, or nothing under one. diff --git a/bin/loop-claude b/bin/loop-claude index 4afdffda..8776c751 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -165,6 +165,8 @@ def read_premises(root): found = sections(open(os.path.join(root, "README.md"), encoding="utf-8").read()) except OSError as failure: sys.exit(f"README.md in {root}: {failure.strerror} - no premises.") + except UnicodeDecodeError as failure: + sys.exit(f"README.md is not UTF-8 at byte {failure.start} - no premises.") for name in ("Goals", "Audience"): bodies = found.get(name, []) if not bodies: diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index ffe8742f..43774feb 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -57,6 +57,8 @@ class ReadPremises(unittest.TestCase): os.mkdir(readme) self.assertIn("Is a directory", self.exit_message(root)) os.rmdir(readme) + open(readme, "wb").write(b"# T\n## Goals\n1. g\xff\n## Audience\nme\n") + self.assertIn("README.md is not UTF-8 at byte 17", self.exit_message(root)) for text, missing in texts.items(): with self.subTest(missing=missing): open(readme, "w").write(text) diff --git a/todo.md b/todo.md index ee8aea46..b8cf4494 100644 --- a/todo.md +++ b/todo.md @@ -4,6 +4,5 @@ Ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- 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. - Say `could not read` when `~/.claude.json` parses to anything but an object whose `projects` maps paths to objects, today a traceback before the interrupt.