Answer architecture round 1: 1 🔴, 2 🟡; split the filter's pure core out of main, stage settings.json before Update's move, read the stored settings in a repo check

This commit is contained in:
2026-10-21 21:38:50 +02:00
parent 7c3800337a
commit 7665087e1e
6 changed files with 54 additions and 27 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
## 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:
- `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. Update now starts with that `git add`: without it, the move drops the machine's model. An update to a release that changes `settings.json` drops the model either way. 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.
+3 -2
View File
@@ -60,16 +60,17 @@ Have git store `settings.json` without `"model"`, so a model you pick with `/mod
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.
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. A pull that changes `settings.json` then drops the model; pick it again with `/model`.
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 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:
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`. Git counts a model pick as such a change until `git add settings.json`, so stage it first. Where the tag changes `settings.json`, the move still 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
git add settings.json
git fetch --tags origin
git status
```
+21
View File
@@ -0,0 +1,21 @@
import pathlib
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from git_repo import git
from repo_checks.test_python_floor import ROOT
from settings_filter import cleaned
class Settings(unittest.TestCase):
def test_the_stored_settings_hold_no_model_and_sorted_keys(self):
# The index, not the working file: the working file holds this machine's model in Claude Code's key order.
stored = git("show", ":settings.json", cwd=str(ROOT))
self.assertIsInstance(stored, str, stored)
self.assertEqual(stored, cleaned(stored))
def test_the_readme_installs_the_filter_git_attributes_name(self):
self.assertIn("settings.json filter=settings\n", (ROOT / ".gitattributes").read_text(encoding="utf-8"))
self.assertIn("git config filter.settings.clean bin/settings_filter.py\n", (ROOT / "README.md").read_text(encoding="utf-8"))
+8 -4
View File
@@ -9,11 +9,15 @@ import json
import sys
def main() -> None:
settings = json.load(sys.stdin)
def cleaned(written: str) -> str:
"""settings.json as git stores it: without "model", every key sorted."""
settings = json.loads(written)
settings.pop("model", None)
json.dump(settings, sys.stdout, ensure_ascii=False, indent=2, sort_keys=True)
sys.stdout.write("\n")
return json.dumps(settings, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
def main() -> None:
sys.stdout.write(cleaned(sys.stdin.read()))
if __name__ == "__main__":
+20 -19
View File
@@ -5,14 +5,11 @@ 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"
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from settings_filter import cleaned
def cleaned(text):
return subprocess.run([sys.executable, FILTER], input=text, capture_output=True, check=True, text=True).stdout
FILTER = pathlib.Path(__file__).resolve().parent / "settings_filter.py"
class Clean(unittest.TestCase):
@@ -20,35 +17,39 @@ class Clean(unittest.TestCase):
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"))
def test_keeps_text_outside_ascii(self):
self.assertEqual(cleaned('{"name": "Lilleman på Larv"}'), '{\n "name": "Lilleman på Larv"\n}\n')
class Checkout(unittest.TestCase):
def test_a_model_pick_and_claude_codes_key_order_leave_nothing_to_commit(self):
def test_a_model_pick_in_claude_codes_key_order_leaves_nothing_to_commit_and_outlasts_an_update(self):
with tempfile.TemporaryDirectory() as repo:
def git(*args):
return subprocess.run(["git", "-C", repo, *args], capture_output=True, check=True, text=True).stdout
return subprocess.run(["git", "-C", repo, "-c", "user.name=t", "-c", "user.email=t@t", *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:])
git("config", "filter.settings.clean", "bin/settings_filter.py")
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))
git("commit", "-qm", "settings")
git("tag", "v1")
(pathlib.Path(repo) / "other").write_text("")
git("add", "other")
git("commit", "-qm", "a tag that leaves settings.json alone")
git("tag", "v2")
git("checkout", "-q", "v1")
picked = json.dumps({"theme": "dark", "model": "opus[1m]", "env": {}}, indent=2)
settings.write_text(picked)
self.assertEqual(git("diff"), "")
# git status lists a file whose size changed until it is staged; staging adds no change.
# README → Update: git status lists a file whose size changed until it is staged; staging adds no change, and keeps the model through the move.
git("add", "settings.json")
self.assertEqual(git("status", "--porcelain"), "")
git("checkout", "-q", "-f", "v2")
self.assertEqual(settings.read_text(), picked)
if __name__ == "__main__":
+1 -1
View File
@@ -164,7 +164,7 @@ Three places carry the rule. `rules/todo-items.md` states it and loads with `tod
## 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`.
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. Until then, Update's `git checkout -f` rewrites the file and drops the model, so Update stages it first. A move or pull that changes `settings.json` drops the machine's model either way. The effort keys, `effortLevel` and `modelSettings`, stay synced: the routing decision on a chunk's worker rung relies on "`settings.json` runs Opus 5.5 at xhigh". Valid while Claude Code writes the model it picks into `settings.json`.
## the repo may name bender, bender-infra and ai-sandbox