Give settings.json's model one writer per machine, and sort its keys

This commit is contained in:
2026-10-21 21:26:40 +02:00
parent 4fbe529cfe
commit 7c3800337a
11 changed files with 127 additions and 40 deletions
+1
View File
@@ -0,0 +1 @@
settings.json filter=settings
+2
View File
@@ -4,6 +4,7 @@
# un-ignore authored config only.
*
!.gitattributes
!.gitignore
!AGENTS.md
!CHANGELOG.md
@@ -67,6 +68,7 @@
!bin/score_outcomes/
!bin/score_outcomes/*.py
!bin/shell_command.py
!bin/settings_filter.py
!bin/statusline.py
!bin/subagent-rung
!bin/subagent_rung/
+2 -1
View File
@@ -26,6 +26,7 @@ Decisions live in `docs/decisions.md`:
- review: the premises chunk's whole review is the human's approval
- workflow-bench/: the remote may show the bench cases' names and commit SHAs
- settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped
- settings.json: each machine owns its model, and git's clean filter `bin/settings_filter.py` keeps it, and Claude Code's key order, out of every commit
- the repo may name bender, bender-infra and ai-sandbox
- todo.md: one table of items, scored by the formula it states, held to its bar and ranked by `bin/rank_todo.py`, which ranks each blocker above the items it blocks; each achieve goal weighs by its position, code health first and four times as heavy while the comprehension panel's overall is under 7.0 or unmeasured, then README.md's goals; the table's order is the plan's only order
- todo.md: only a session or subagent on the project's rung or above scores or reshapes the plan; one below it drafts new items and changes to filed ones for a subagent at or above that rung to apply and score, and removes finished ones
@@ -52,7 +53,7 @@ Decisions live in `docs/decisions.md`:
## Working rules
- `routing-calls-raised.md` sits at the root of loop-claude's archive (`$LOOP_CLAUDE_TRANSCRIPTS`, default `~/.claude/loop-claude-transcripts`). Each of its lines is a call or a `Reset`, with a stamp. A call is new when it is stamped after the latest `Reset` and after the latest stamp that `todo.md` or `docs/decisions.md` → `routing:` cites. When there are new calls, file one `todo.md` item to settle them, or refresh the item already filed. Its detail quotes those calls with their stamps, and the routed-chunks table of `routing-figures.md` beside it, never the project names its other tables hold. A change to the ladder, its steps or the delegation rule is the human's. The chunk that settles the calls cites the latest stamp it settled in `docs/decisions.md` → `routing:`, whatever the human decided, so they are not filed again. Once a chunk that changes the ladder, its steps or the delegation rule has merged, append `- <UTC time> Reset` to `routing-calls-raised.md`: the figures then count only chunks finished after it, and its calls may be raised again.
- When `~/.claude/settings.json` has uncommitted changes, commit them on a branch of their own and merge them through a PR: Claude Code writes that file from any session. Read their diff first. When it holds a credential, such as a token in `env` or `mcpServers`, ask the human to move it out of the file, and commit only once it is gone. A token in `env` moves to the shell profile; a server in `mcpServers` moves to `~/.claude.json` with `claude mcp add --scope user`.
- When `~/.claude/settings.json` has uncommitted changes, commit them on a branch of their own and merge them through a PR: Claude Code writes that file from any session. Read their diff first: an empty one is a model pick, which `git add settings.json` clears. When it holds a credential, such as a token in `env` or `mcpServers`, ask the human to move it out of the file, and commit only once it is gone. A token in `env` moves to the shell profile; a server in `mcpServers` moves to `~/.claude.json` with `claude mcp add --scope user`.
## Scoring run
+3
View File
@@ -2,6 +2,9 @@
## Unreleased
- `settings.json` no longer carries a model: each machine keeps the one you pick with `/model`. Git's clean filter `bin/settings_filter.py` drops `"model"` and sorts the keys, so neither a pick nor Claude Code's key order can reach a commit. After a pick, `git status` may still list `settings.json`; `git add settings.json` clears it, with nothing to commit. An update to a release that changes `settings.json` drops the machine's model. On upgrade, on each machine:
1. Turn the filter on in `~/.claude`: `git config filter.settings.clean bin/settings_filter.py`.
2. Pick a model with `/model`. Until you do, Claude Code runs its default model, where this repo set `opus` before.
- larv-review's "Re-entry" is now one table of which passes a fix reruns, and the pass table's triggers say only when a pass first runs. The rule is unchanged; a fix for a 🟢, a ❓ or a prose finding still reruns no pass.
## 0.2.0
+11 -2
View File
@@ -54,11 +54,19 @@ claude plugin install code-review@claude-plugins-official
claude plugin install rust-analyzer-lsp@claude-plugins-official
```
Have git store `settings.json` without `"model"`, so a model you pick with `/model` stays on this machine and never reaches a commit:
```sh
git config filter.settings.clean bin/settings_filter.py
```
After a pick, `git status` may still list `settings.json`, and `git pull` refuses to update it. `git add settings.json` clears that, with nothing to commit.
Link `loop-claude` onto `PATH`: `ln -s ~/.claude/bin/loop-claude ~/.local/bin/loop-claude`. Run `loop-claude` only in a sandbox with no direct access to a production environment, such as a dedicated VM: every claude it starts, the interactive ones included, skips every permission prompt.
## Update
Move a machine that takes tagged releases to the latest tag. The move discards every uncommitted change to a file the latest tag tracks, such as a `settings.json` Claude Code wrote. List the uncommitted changes to files the checkout tracks, and the tag it is on:
Move a machine that takes tagged releases to the latest tag. The move discards every uncommitted change to a file the latest tag tracks, such as a hook Claude Code wrote into `settings.json`. Where the tag changes `settings.json`, the move also drops this machine's model; pick it again with `/model`. List the uncommitted changes to files the checkout tracks, and the tag it is on:
```sh
cd ~/.claude
@@ -92,6 +100,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
- `review-replay <pass> <model>` replays a review pass's archived rounds from the projects run on the model, on the code each reviewed, and prints the lowest rung below the project's that, like each rung above it, finds every 🔴 and 🟡 the project's rung finds again; `review-replay --help` states the replay. Run it only in a sandbox, like loop-claude: each replayed reviewer skips every permission prompt, stability-reviewer has Bash, and an archived prompt may name paths on the host.
- `rule-hook [overrides]` blocks a tool call that breaks a rule a program can check, unless the call overrides the rule; `settings.json` → `hooks` runs it before each Bash, Edit, MultiEdit, Write and Agent call, and `rule-hook --help` states the rules and the override.
- `score-outcomes [L E I S]` lists the finished items whose guessed scores sit nearest the given ones, and the shipped items the project's `docs/score-anchors.md` names for each level of L, E and I, each with what its chunk measured; then the median outcome at each guessed R and S, and how well L, E and I each order the chunks by review rounds and 🔴 findings; `score-outcomes --help` states the measures.
- `settings_filter.py` is git's clean filter for `settings.json`: it drops `"model"` and sorts the keys. `.gitattributes` names it, and Install turns it on.
- `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it.
- `subagent-rung [--plan] <model> <L>` prints the Agent tool's model and effort for a subagent's task, picked by its L from the project's model, and with `--plan` never below the project's rung; `subagent-rung --help` states the rule.
@@ -110,7 +119,7 @@ pytest_add_cli_args=-k
Then, in the copy: `uvx --with pytest 'mutmut>=3,<4' run && uvx --with pytest 'mutmut>=3,<4' results`, and `uvx --with pytest 'mutmut>=3,<4' show <mutant>` to see a mutant's change. The config keys are mutmut 3's.
`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself.
`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself.
## Tracking a new file
+1 -1
View File
@@ -15,5 +15,5 @@ class Types(unittest.TestCase):
self.assertIsNotNone(floor, "README.md's Install names `Python 3.N or newer`")
if shutil.which("uv") is None:
self.fail("uv on PATH fetches mypy; see README.md's Test line")
ran = subprocess.run(["uv", "tool", "run", "--python", "%d.%d" % floor, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "--exclude", "/test_", "-p", "chunk_preflight", "-p", "claude_code", "-m", "comprehension_history", "-m", "git_repo", "-p", "judge_replay", "-p", "larv_review", "-p", "loop_claude", "-m", "markdown_text", "-p", "metric_bench", "-m", "project_key", "-m", "rank_todo", "-m", "round_titles", "-p", "reading_cost", "-p", "review_replay", "-p", "rule_hook", "-p", "rung_replay", "-p", "score_outcomes", "-p", "subagent_rung", "-m", "shell_command", "-m", "statusline", "-m", "todo_table", "-p", "transcript_archive", "-m", "utc_stamp"], capture_output=True, cwd=ROOT / "bin", text=True)
ran = subprocess.run(["uv", "tool", "run", "--python", "%d.%d" % floor, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "--exclude", "/test_", "-p", "chunk_preflight", "-p", "claude_code", "-m", "comprehension_history", "-m", "git_repo", "-p", "judge_replay", "-p", "larv_review", "-p", "loop_claude", "-m", "markdown_text", "-p", "metric_bench", "-m", "project_key", "-m", "rank_todo", "-m", "round_titles", "-p", "reading_cost", "-p", "review_replay", "-p", "rule_hook", "-p", "rung_replay", "-p", "score_outcomes", "-p", "subagent_rung", "-m", "settings_filter", "-m", "shell_command", "-m", "statusline", "-m", "todo_table", "-p", "transcript_archive", "-m", "utc_stamp"], capture_output=True, cwd=ROOT / "bin", text=True)
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
"""Git's clean filter for settings.json: drop "model" and sort every key.
Claude Code rewrites settings.json, in its own key order, whenever a model is
picked or a plugin installed. Each machine owns its model, so git stores the
file without it, and neither write shows as a change.
"""
import json
import sys
def main() -> None:
settings = json.load(sys.stdin)
settings.pop("model", None)
json.dump(settings, sys.stdout, ensure_ascii=False, indent=2, sort_keys=True)
sys.stdout.write("\n")
if __name__ == "__main__":
main()
+55
View File
@@ -0,0 +1,55 @@
import json
import pathlib
import subprocess
import sys
import tempfile
import unittest
BIN = pathlib.Path(__file__).resolve().parent
ROOT = BIN.parent
FILTER = BIN / "settings_filter.py"
INSTALL = "git config filter.settings.clean bin/settings_filter.py"
def cleaned(text):
return subprocess.run([sys.executable, FILTER], input=text, capture_output=True, check=True, text=True).stdout
class Clean(unittest.TestCase):
def test_drops_the_model_and_sorts_every_key(self):
written = '{"theme": "dark", "model": "opus[1m]", "env": {"B": "1", "A": "2"}}'
self.assertEqual(cleaned(written), '{\n "env": {\n "A": "2",\n "B": "1"\n },\n "theme": "dark"\n}\n')
def test_the_tracked_settings_hold_no_model_and_sorted_keys(self):
tracked = (ROOT / "settings.json").read_text(encoding="utf-8")
self.assertEqual(tracked, cleaned(tracked))
def test_the_readme_installs_the_filter_git_attributes_name(self):
self.assertIn(f"{INSTALL}\n", (ROOT / "README.md").read_text(encoding="utf-8"))
self.assertIn("settings.json filter=settings\n", (ROOT / ".gitattributes").read_text(encoding="utf-8"))
class Checkout(unittest.TestCase):
def test_a_model_pick_and_claude_codes_key_order_leave_nothing_to_commit(self):
with tempfile.TemporaryDirectory() as repo:
def git(*args):
return subprocess.run(["git", "-C", repo, *args], capture_output=True, check=True, text=True).stdout
git("init", "-q")
(pathlib.Path(repo) / "bin").mkdir()
(pathlib.Path(repo) / "bin" / "settings_filter.py").symlink_to(FILTER)
(pathlib.Path(repo) / ".gitattributes").write_text("settings.json filter=settings\n")
git(*INSTALL.split()[1:])
settings = pathlib.Path(repo) / "settings.json"
settings.write_text(cleaned('{"env": {}, "theme": "dark"}'))
git("add", ".")
git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "settings")
settings.write_text(json.dumps({"theme": "dark", "model": "opus[1m]", "env": {}}, indent=2))
self.assertEqual(git("diff"), "")
# git status lists a file whose size changed until it is staged; staging adds no change.
git("add", "settings.json")
self.assertEqual(git("status", "--porcelain"), "")
if __name__ == "__main__":
unittest.main()
+4
View File
@@ -162,6 +162,10 @@ Three places carry the rule. `rules/todo-items.md` states it and loads with `tod
2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 1: this setup is meant to run in a sandbox and to work autonomously, so tool access is granted by the sandbox, as "Always grant explicit access to data" in `principles/technical-principles.md` asks. Valid while every machine taking this checkout is such a sandbox.
## settings.json: each machine owns its model, and git's clean filter `bin/settings_filter.py` keeps it, and Claude Code's key order, out of every commit
2026-10-21, lilleman. Serves goal 2: Claude Code rewrites `"model"` in `settings.json` on every `/model` and plugin install, so a tracked model let one machine's pick override every other's. lilleman chose a model per machine over a synced one in `env.ANTHROPIC_MODEL`, which `/model` could not outlast past one session: it is simpler, and loop-claude picks each project's model in `~/.claude/loop-claude-models.json` anyway. The filter also sorts the keys, since each write puts them back in Claude Code's order. Git still lists `settings.json` after a pick that changes the file's size, and `git pull` refuses to update it, until `git add settings.json`, which stages no change. An Update to a tag that changes `settings.json` drops the machine's model. Valid while Claude Code writes the model it picks into `settings.json`.
## the repo may name bender, bender-infra and ai-sandbox
2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 4, which keeps credentials, transcripts and memory files off the remote; the names of the host, its infrastructure project and the sandbox VM are none of those. Valid while the repo names them without their addresses or credentials.
+28 -29
View File
@@ -1,63 +1,62 @@
{
"env": {
"CLAUDE_SECURITY_SCAN_TIP": "off"
},
"attribution": {
"sessionUrl": false
},
"includeCoAuthoredBy": false,
"permissions": {
"defaultMode": "auto",
"additionalDirectories": [
"~/.local/state/larv-review",
"~/code"
]
},
"model": "opus",
"awaySummaryEnabled": false,
"disableClaudeAiConnectors": true,
"statusLine": {
"type": "command",
"command": "~/.claude/bin/statusline.py",
"refreshInterval": 30
},
"effortLevel": "xhigh",
"enabledPlugins": {
"claude-security@claude-plugins-official": true,
"code-review@claude-plugins-official": true,
"frontend-design@claude-plugins-official": false,
"rust-analyzer-lsp@claude-plugins-official": true,
"code-review@claude-plugins-official": true
"rust-analyzer-lsp@claude-plugins-official": true
},
"env": {
"CLAUDE_SECURITY_SCAN_TIP": "off"
},
"extraKnownMarketplaces": {
"claude-plugins-official": {
"source": {
"source": "github",
"repo": "anthropics/claude-plugins-official"
"repo": "anthropics/claude-plugins-official",
"source": "github"
}
}
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|Edit|MultiEdit|Write|Agent",
"hooks": [
{
"type": "command",
"command": "~/.claude/bin/rule-hook",
"timeout": 30
"timeout": 30,
"type": "command"
}
]
],
"matcher": "Bash|Edit|MultiEdit|Write|Agent"
}
]
},
"effortLevel": "xhigh",
"includeCoAuthoredBy": false,
"mcpServers": {},
"modelSettings": {
"claude-fable-5-1": {
"effortLevel": "high"
}
},
"awaySummaryEnabled": false,
"tui": "fullscreen",
"permissions": {
"additionalDirectories": [
"~/.local/state/larv-review",
"~/code"
],
"defaultMode": "auto"
},
"skipDangerousModePermissionPrompt": true,
"skipWorkflowUsageWarning": true,
"statusLine": {
"command": "~/.claude/bin/statusline.py",
"refreshInterval": 30,
"type": "command"
},
"theme": "dark",
"mcpServers": {}
"tui": "fullscreen"
}
-7
View File
@@ -12,7 +12,6 @@
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 21 | 0.3.0 | | defect | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 3 | 7 | 3 | 2 by 5 | 22.5 |
| 29 | 0.3.0 | | | **Make the contributor a standing member of every project's audience, unless its README voids code health.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 5, 1.4 by 5 | 13.7 |
| 199 | 0.3.0 | | defect | **Start loop-claude's worker with `ScheduleWakeup` disallowed, so a worker that ends its turn on a question exits and the judge runs.** | 2 | 1 | 3 | 4 | 2 | 1.5 by 6, 1.2 by 3 | 11.8 |
| 170 | 0.3.0 | | decision | **Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 10 chunks have shipped under them, from how well L, E and I order their review rounds and 🔴 findings.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 3, 1.4 by 5 | 10.9 |
@@ -92,12 +91,6 @@
## Details
### 21. Give `settings.json`'s model one writer, and sort its keys.
A defect: goal 2, keeping the setup shareable between computers, does not hold while one machine's model choice overwrites every other's. Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice.
Every write Claude Code makes to the file rewrites `"model"`, `claude plugin install` included: Claude Code 2.1.288 turned `"opus"` into `"opus[1m]"`. Each write also puts the keys back in Claude Code's own order, so a sorted file stays sorted only until the next write.
### 29. Make the contributor a standing member of every project's audience, unless its README voids code health.
State that in `~/.claude/rules/goals-and-audience.md` → "Goals and Audience", and have larv-review's comprehension check name the contributor as the reader it serves. The `**Void:** code health` line (`~/.claude/CLAUDE.md` → "Shared goal") is the one place a project says maintainability does not matter: it drops the contributor. A project that opts out of the comprehension check must already write that line.