diff --git a/AGENTS.md b/AGENTS.md index ee700c08..b8bf121e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,6 +7,7 @@ Decisions live in `docs/decisions.md`: - loop-claude: one session per project, at a fixed id - loop-claude: the trust file is rewritten before an interrupt - loop-claude: a reload into an older file is unsupported +- loop-claude: a wrong-shape trust file gets one message, naming the shape - bin/: host python, no container - comprehension floor: the 2026-09-25 four-seat score is the ratchet, and 0.1.0 waits on what caps it - larv-review: a re-entered loop takes a fresh round cap diff --git a/bin/loop-claude b/bin/loop-claude index 56d2a54f..988cb0f1 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -415,7 +415,10 @@ def trust(paths): except (OSError, ValueError) as failure: print(f"could not read {config}: {getattr(failure, 'strerror', failure)}", file=sys.stderr) return - projects = data.setdefault("projects", {}) + projects = data.setdefault("projects", {}) if isinstance(data, dict) else None + if not isinstance(projects, dict) or not all(isinstance(record, dict) for record in projects.values()): + print(f"could not read {config}: not an object whose \"projects\" maps paths to objects", file=sys.stderr) + return granted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")] if not granted: return diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index ac03aafc..a8f78c20 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -223,6 +223,12 @@ class Trust(unittest.TestCase): with contextlib.redirect_stderr(io.StringIO()) as err: loop.trust(["/a"]) self.assertIn(f"could not read {config}: ", err.getvalue()) + for shape in ([], {"projects": []}, {"projects": {"/a": 1}}): + config.write_text(json.dumps(shape)) + with contextlib.redirect_stderr(io.StringIO()) as err: + loop.trust(["/a"]) + self.assertEqual(err.getvalue(), f"could not read {config}: not an object whose \"projects\" maps paths to objects\n") + self.assertEqual(json.loads(config.read_text()), shape) data = {"other": 1, "projects": {"/a": {"hasTrustDialogAccepted": True, "kept": 2}}} config.write_text(json.dumps(data)) with contextlib.redirect_stderr(io.StringIO()) as err: diff --git a/docs/decisions.md b/docs/decisions.md index 9764e8a5..4a4beb26 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -16,6 +16,10 @@ 2026-09-21, lilleman; the lost-write risk accepted 2026-09-24 by larv-review. Serves goal 4. A write by another claude inside `trust`'s read-modify-write window is lost. Valid while no flag skips the dialog. +## loop-claude: a wrong-shape trust file gets one message, naming the shape + +2026-09-26, larv-review, declining a product-owner nit. Serves goal 4 through the comprehension floor below. `trust` says `not an object whose "projects" maps paths to objects` for every wrong shape; naming the failing path would add a branch to `trust`, the unit three of four seats least want to modify, and the interrupt still lands in Claude Code's own dialog. Valid while `trust` caps the floor. + ## bin/: host python, no container 2026-09-24, larv-review. Serves goals 1 and 4. The tools drive the host's claude CLI and read the host's session files, which a container cannot see; the tests run the same way. Valid while claude runs on the host. diff --git a/todo.md b/todo.md index eb3e6ed1..48402339 100644 --- a/todo.md +++ b/todo.md @@ -4,5 +4,4 @@ Ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- 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. - State in `docs/decisions.md` the oldest Python `bin/` must parse on, today unstated and 3.11 by the last review.