From 5e84736672f1094ab0bab69a43a4eef676eaf9d5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 11:47:23 +0200 Subject: [PATCH 1/4] Keep formats.py to Claude Code's shapes, with paths and file reads at their callers --- bin/loop_claude/claude_code/formats.py | 29 ++++---------------------- bin/loop_claude/claude_code/session.py | 10 +++++---- bin/loop_claude/paths.py | 9 +++----- bin/loop_claude/project/models.py | 11 +++++++++- todo.md | 1 - 5 files changed, 23 insertions(+), 37 deletions(-) diff --git a/bin/loop_claude/claude_code/formats.py b/bin/loop_claude/claude_code/formats.py index 50138367..a1417da7 100644 --- a/bin/loop_claude/claude_code/formats.py +++ b/bin/loop_claude/claude_code/formats.py @@ -1,26 +1,9 @@ -"""Every Claude Code format loop-claude reads, each under a sample of it, as Claude Code 2.1.284 writes it.""" -import glob +"""Every Claude Code shape loop-claude reads, each under a sample of it, as Claude Code 2.1.284 writes it.""" import json -import os from loop_claude.outcome import Failure -def locations(home): - return home / ".claude.json", home / ".claude" / "cache" / "model-catalog", home / ".claude" / "projects" - - -# /-home-me-code-log/.jsonl -def transcript_path(claude_code_transcripts, session_id): - hit = glob.glob(os.path.join(glob.escape(str(claude_code_transcripts)), "*", f"{session_id}.jsonl")) - return hit[0] if hit else "" - - -# .jsonl, /subagents/, and from older versions .superseded-1789290815002/ and .orphaned-*.jsonl -def session_files(transcript): - return glob.glob(glob.escape(transcript.removesuffix(".jsonl")) + "*") - - def parse(raw): try: entry = json.loads(raw) @@ -114,14 +97,10 @@ def mark_trusted(config, roots): # /*.json: {"fetchedAt": 1790618085238, "catalog": {"config": {"models": [{"id": "claude-opus-5-5", "name": "Opus 5.5", ...}]}}} -def catalog(folder): +def catalog(files): + """The (id, name) of each model in the newest of the parsed catalog files.""" newest = {} - for path in folder.glob("*.json"): - try: - with open(path, encoding="utf-8") as handle: - data = json.load(handle) - except (OSError, ValueError): - continue + for data in files: if isinstance(data, dict) and isinstance(data.get("fetchedAt"), (int, float)) and data["fetchedAt"] > newest.get("fetchedAt", -1): newest = data models = newest diff --git a/bin/loop_claude/claude_code/session.py b/bin/loop_claude/claude_code/session.py index 2ffe5d8b..659267f6 100644 --- a/bin/loop_claude/claude_code/session.py +++ b/bin/loop_claude/claude_code/session.py @@ -1,12 +1,11 @@ import dataclasses +import glob import os import pathlib import shutil import sys import uuid -from loop_claude.claude_code.formats import session_files, transcript_path - NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec") @@ -24,15 +23,18 @@ def session_for(project, paths): return Session(id=uuid.uuid5(NAMESPACE, name), claude_code_transcripts=paths.claude_code_transcripts, name=name) +# /-home-me-code-log/.jsonl def transcript_file(session): - return transcript_path(session.claude_code_transcripts, session.id) + hit = glob.glob(os.path.join(glob.escape(str(session.claude_code_transcripts)), "*", f"{session.id}.jsonl")) + return hit[0] if hit else "" def delete_session(session): path = transcript_file(session) if not path: return - for sibling in session_files(path): + # .jsonl, /subagents/, and from older versions .superseded-1789290815002/ and .orphaned-*.jsonl + for sibling in glob.glob(glob.escape(path.removesuffix(".jsonl")) + "*"): try: shutil.rmtree(sibling) if os.path.isdir(sibling) else os.remove(sibling) except OSError as failure: diff --git a/bin/loop_claude/paths.py b/bin/loop_claude/paths.py index 6f670603..e93065b8 100644 --- a/bin/loop_claude/paths.py +++ b/bin/loop_claude/paths.py @@ -1,8 +1,6 @@ import dataclasses import pathlib -from loop_claude.claude_code.formats import locations - @dataclasses.dataclass(frozen=True) class Paths: @@ -16,12 +14,11 @@ class Paths: def paths_from(home, env): claude = home / ".claude" - claude_json, model_catalog, claude_code_transcripts = locations(home) return Paths( archive=pathlib.Path(env["LOOP_CLAUDE_TRANSCRIPTS"]).expanduser() if env.get("LOOP_CLAUDE_TRANSCRIPTS") else claude / "loop-claude-transcripts", - claude_code_transcripts=claude_code_transcripts, - claude_json=claude_json, + claude_code_transcripts=claude / "projects", + claude_json=home / ".claude.json", code=home / "code", - model_catalog=model_catalog, + model_catalog=claude / "cache" / "model-catalog", models_file=claude / "loop-claude-models.json", ) diff --git a/bin/loop_claude/project/models.py b/bin/loop_claude/project/models.py index 127c0392..0225210e 100644 --- a/bin/loop_claude/project/models.py +++ b/bin/loop_claude/project/models.py @@ -57,10 +57,19 @@ def read_models(saved): return models +def read_catalog(folder): + for path in folder.glob("*.json"): + try: + with open(path, encoding="utf-8") as handle: + yield json.load(handle) + except (OSError, ValueError): + continue + + def ask_model(name, saved, folder): if stop := human_needed.off_terminal(f"pick {name}'s model, or merge {{\"{name}\": \"\"}} into {saved}"): return stop - offered = catalog(folder) + offered = catalog(read_catalog(folder)) print(f"\nThe model to run {name} on, saved in {saved}:", file=sys.stderr) for number, (model_id, label) in enumerate(offered, 1): print(f" {number}. {label} ({model_id})", file=sys.stderr) diff --git a/todo.md b/todo.md index 2087f0a2..df4c920f 100644 --- a/todo.md +++ b/todo.md @@ -8,7 +8,6 @@ The rebuild lifts every dimension, one chunk per item, until the last item opens The places the panel on `rebuild` at 2f9ab2f named (`docs/decisions.md`), capping dimension first: -- **Keep `formats.py` to Claude Code's shapes: `locations` into `paths.py`, `catalog`'s file reads out.** Three seats found paths and I/O in a file named for formats. - **Group `bin/loop_claude/`'s top-level modules, and name `claude_runs` apart from `claude_code`.** Two seats: eleven modules of mixed altitude side by side. - **Say at `written_by_human` why a `<` prefix marks Claude Code's own entry, and at `trust` why a failure only warns.** Three seats found either only in `CHANGELOG.md`. - **Say in the README why the tests run on the host and need `uv`.** Two seats: `CLAUDE.md` says never run a runtime on the host, and only `test_python_floor.py` says what `uv` is for. -- 2.52.0 From 29495b1e7daa6c54131d3aca604dacb6d9020e8f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 11:48:54 +0200 Subject: [PATCH 2/4] Read the model catalog in claude_code/catalog.py --- bin/loop_claude/claude_code/catalog.py | 16 ++++++++++++++++ bin/loop_claude/project/models.py | 13 ++----------- 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 bin/loop_claude/claude_code/catalog.py diff --git a/bin/loop_claude/claude_code/catalog.py b/bin/loop_claude/claude_code/catalog.py new file mode 100644 index 00000000..f50873b3 --- /dev/null +++ b/bin/loop_claude/claude_code/catalog.py @@ -0,0 +1,16 @@ +import json + +from loop_claude.claude_code.formats import catalog + + +def offered_models(folder): + return catalog(read_catalog(folder)) + + +def read_catalog(folder): + for path in folder.glob("*.json"): + try: + with open(path, encoding="utf-8") as handle: + yield json.load(handle) + except (OSError, ValueError): + continue diff --git a/bin/loop_claude/project/models.py b/bin/loop_claude/project/models.py index 0225210e..6bae6c7c 100644 --- a/bin/loop_claude/project/models.py +++ b/bin/loop_claude/project/models.py @@ -3,7 +3,7 @@ import json import sys from loop_claude import human_needed -from loop_claude.claude_code.formats import catalog +from loop_claude.claude_code.catalog import offered_models from loop_claude.file_writes import replace_json from loop_claude.outcome import Stop @@ -57,19 +57,10 @@ def read_models(saved): return models -def read_catalog(folder): - for path in folder.glob("*.json"): - try: - with open(path, encoding="utf-8") as handle: - yield json.load(handle) - except (OSError, ValueError): - continue - - def ask_model(name, saved, folder): if stop := human_needed.off_terminal(f"pick {name}'s model, or merge {{\"{name}\": \"\"}} into {saved}"): return stop - offered = catalog(read_catalog(folder)) + offered = offered_models(folder) print(f"\nThe model to run {name} on, saved in {saved}:", file=sys.stderr) for number, (model_id, label) in enumerate(offered, 1): print(f" {number}. {label} ({model_id})", file=sys.stderr) -- 2.52.0 From c2be13efd52f8b2671c3fec60291a056169566dd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 11:50:16 +0200 Subject: [PATCH 3/4] Name formats.models_in by what it returns, and read the catalog in one function --- bin/loop_claude/claude_code/catalog.py | 10 ++++------ bin/loop_claude/claude_code/formats.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bin/loop_claude/claude_code/catalog.py b/bin/loop_claude/claude_code/catalog.py index f50873b3..b3ebe58a 100644 --- a/bin/loop_claude/claude_code/catalog.py +++ b/bin/loop_claude/claude_code/catalog.py @@ -1,16 +1,14 @@ import json -from loop_claude.claude_code.formats import catalog +from loop_claude.claude_code.formats import models_in def offered_models(folder): - return catalog(read_catalog(folder)) - - -def read_catalog(folder): + files = [] for path in folder.glob("*.json"): try: with open(path, encoding="utf-8") as handle: - yield json.load(handle) + files.append(json.load(handle)) except (OSError, ValueError): continue + return models_in(files) diff --git a/bin/loop_claude/claude_code/formats.py b/bin/loop_claude/claude_code/formats.py index a1417da7..d4a8377d 100644 --- a/bin/loop_claude/claude_code/formats.py +++ b/bin/loop_claude/claude_code/formats.py @@ -97,7 +97,7 @@ def mark_trusted(config, roots): # /*.json: {"fetchedAt": 1790618085238, "catalog": {"config": {"models": [{"id": "claude-opus-5-5", "name": "Opus 5.5", ...}]}}} -def catalog(files): +def models_in(files): """The (id, name) of each model in the newest of the parsed catalog files.""" newest = {} for data in files: -- 2.52.0 From aba2a98d7eaec02da7c2cff7368b1e19fe8a645c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 29 Sep 2026 11:53:46 +0200 Subject: [PATCH 4/4] Name formats.py's samples by what they are, put Session's lifetime on Session, and file the prose pass's places --- bin/loop_claude/claude_code/formats.py | 6 +++--- bin/loop_claude/claude_code/session.py | 2 +- todo.md | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/loop_claude/claude_code/formats.py b/bin/loop_claude/claude_code/formats.py index d4a8377d..a274b6dc 100644 --- a/bin/loop_claude/claude_code/formats.py +++ b/bin/loop_claude/claude_code/formats.py @@ -1,4 +1,4 @@ -"""Every Claude Code shape loop-claude reads, each under a sample of it, as Claude Code 2.1.284 writes it.""" +"""Claude Code's JSON shapes loop-claude handles, each under a sample of it, as Claude Code 2.1.284 writes it.""" import json from loop_claude.outcome import Failure @@ -84,7 +84,7 @@ def structured_output(stdout): return (parse(stdout) or {}).get("structured_output") -# ~/.claude.json: {"projects": {"/home/me/code/log": {"hasTrustDialogAccepted": true, ...}}, ...} +# Claude Code's config: {"projects": {"/home/me/code/log": {"hasTrustDialogAccepted": true, ...}}, ...} def mark_trusted(config, roots): projects = config.get("projects", {}) if isinstance(config, dict) else None if not isinstance(projects, dict): @@ -96,7 +96,7 @@ def mark_trusted(config, roots): return {**config, "projects": {**projects, **marked}}, untrusted -# /*.json: {"fetchedAt": 1790618085238, "catalog": {"config": {"models": [{"id": "claude-opus-5-5", "name": "Opus 5.5", ...}]}}} +# A model catalog file: {"fetchedAt": 1790618085238, "catalog": {"config": {"models": [{"id": "claude-opus-5-5", "name": "Opus 5.5", ...}]}}} def models_in(files): """The (id, name) of each model in the newest of the parsed catalog files.""" newest = {} diff --git a/bin/loop_claude/claude_code/session.py b/bin/loop_claude/claude_code/session.py index 659267f6..c2834a50 100644 --- a/bin/loop_claude/claude_code/session.py +++ b/bin/loop_claude/claude_code/session.py @@ -11,13 +11,13 @@ NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec") @dataclasses.dataclass(frozen=True) class Session: + """Exists while its transcript does.""" id: uuid.UUID claude_code_transcripts: pathlib.Path name: str def session_for(project, paths): - """Exists while its transcript does.""" # "A " is the human's cue in the session picker that the session is the loop's. name = f"A {project} loop-claude" return Session(id=uuid.uuid5(NAMESPACE, name), claude_code_transcripts=paths.claude_code_transcripts, name=name) diff --git a/todo.md b/todo.md index df4c920f..79f50f58 100644 --- a/todo.md +++ b/todo.md @@ -20,3 +20,8 @@ The places the panel on `rebuild` at 2f9ab2f named (`docs/decisions.md`), cappin - **Show the judge's reply when `loop-claude` rejects its verdict.** Its stdout is discarded, so a judge that failed three times running leaves nothing to diagnose. - **Back up `loop-claude`'s transcript archive to a destination other than this repo's remote.** - **Make the contributor a standing member of every project's audience, dropped only where `## Audience` says maintainability does not matter.** `CLAUDE.md`'s premises rule states it; larv-review's comprehension floor names the contributor as the reader it serves, so the floor gates every chunk while the contributor stands and a project that drops them skips it. +- **Give `docs/decisions.md`'s comprehension-floor and vocabulary entries a premise that has not already expired, with the floor's rule first and its runs' scores as a table, and give the rebuild entry's warning placement its own heading and index line.** A prose pass found both "Valid until the next scoring run" outlived by three runs. +- **Move larv-review's reasons for `/security-review` and for the premises chunk's review into `docs/decisions.md`, and inline in `review-findings.md` what a round is.** A prose pass found rejected alternatives at the rule, and a pointer back to `SKILL.md`, which points here. +- **Cut `comprehension-panel`'s run history and the restated description, `systems-architect.md`'s "one home" line, and split its Reasonability Review steps 4 and 5.** A prose pass found them carrying nothing the instructions need. +- **Keep `outcome.Failure`'s docstring to what a failure is, without naming `retried`.** A value type naming its consumer. +- **Say in `AGENTS.md` that only the rebuild's last chunk opens `rebuild`'s PR into main.** Today it reads as every chunk doing so. -- 2.52.0