Open claude on a terminal with CLAUDE_CODE_SANDBOXED set, and stop writing ~/.claude.json

This commit is contained in:
2026-10-30 21:31:44 +01:00
parent 28b714d5ca
commit 0a0a2207c9
15 changed files with 22 additions and 135 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ Decisions live in `docs/decisions.md`:
- larv-review: within a chunk lifting a project towards the comprehension floor, work on the project's lowest-scoring dimension comes first, and the floor doesn't block anything - larv-review: within a chunk lifting a project towards the comprehension floor, work on the project's lowest-scoring dimension comes first, and the floor doesn't block anything
- loop-claude: a `claude` that cannot start is a failed worker run, retried - loop-claude: a `claude` that cannot start is a failed worker run, retried
- loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md`, `~/.claude/rules/` and larv-review's standards, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing - loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md`, `~/.claude/rules/` and larv-review's standards, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing
- loop-claude: before it or loop-inbox opens claude on a terminal, it marks the checkout and each of its worktrees trusted in `~/.claude.json` - loop-claude: every claude it or loop-inbox opens on a terminal has `CLAUDE_CODE_SANDBOXED` set, so Claude Code skips its trust dialog, and loop-claude doesn't write `~/.claude.json`
- loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes - loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes
- loop-claude: every claude it starts bypasses permissions inside its sandbox - loop-claude: every claude it starts bypasses permissions inside its sandbox
- loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it
+1
View File
@@ -5,6 +5,7 @@
- A release review now fixes the findings of its architecture and principles passes in the release it reviews. Before, it filed each one in `todo.md`, so the release held the drift the review had found. It files only three kinds of finding, each under the release being reviewed: one whose fix needs a human answer, marked `question`; one whose fix adds a feature; and one whose fix the five rounds cannot finish. Until each is done, the release isn't ready to cut. - A release review now fixes the findings of its architecture and principles passes in the release it reviews. Before, it filed each one in `todo.md`, so the release held the drift the review had found. It files only three kinds of finding, each under the release being reviewed: one whose fix needs a human answer, marked `question`; one whose fix adds a feature; and one whose fix the five rounds cannot finish. Until each is done, the release isn't ready to cut.
- In a repo with no tag yet, `chunk-preflight` now calls a release finished once `todo.md` files no item under it: its release review is due, and no later release's item is taken. Before, it lost sight of such a release. - In a repo with no tag yet, `chunk-preflight` now calls a release finished once `todo.md` files no item under it: its release review is due, and no later release's item is taken. Before, it lost sight of such a release.
- In a run `loop-claude` started, `rule-hook` now refuses a `/security-review` or `/claude-security` Skill call that the worker makes in its own context on a rung below the project's. It also refuses one from any subagent whose prompt doesn't open with `You are the security pass for this chunk.`, since that subagent's rung is unchecked. The refusal says to invoke the skill from a subagent on the project's rung, its prompt opening with that sentence. Before, only an Agent call that launched the security pass was held to that rung. - In a run `loop-claude` started, `rule-hook` now refuses a `/security-review` or `/claude-security` Skill call that the worker makes in its own context on a rung below the project's. It also refuses one from any subagent whose prompt doesn't open with `You are the security pass for this chunk.`, since that subagent's rung is unchecked. The refusal says to invoke the skill from a subagent on the project's rung, its prompt opening with that sentence. Before, only an Agent call that launched the security pass was held to that rung.
- `loop-claude` and `loop-inbox` no longer write `~/.claude.json`. Each claude they open on a terminal, for `/talk`, a release ready to cut or a routing call, now has `CLAUDE_CODE_SANDBOXED=1` set, so Claude Code skips its trust dialog. Before, loop-claude marked the checkout and each worktree trusted in that file, and a write Claude Code made at the same moment could be lost. Claude Code doesn't document the variable: where a version drops it, the trust dialog comes back.
## 0.4.0 ## 0.4.0
+1 -10
View File
@@ -6,7 +6,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from claude_code import entries, reply, transcript, trust from claude_code import entries, reply, transcript
from failure import Failure from failure import Failure
@@ -132,14 +132,5 @@ class ClaudeReply(unittest.TestCase):
self.assertEqual(reply.claude_reply(self.claude(FileNotFoundError(2, "No such file or directory")), [], "/r", "p", "claude"), Failure("could not start claude: No such file or directory")) self.assertEqual(reply.claude_reply(self.claude(FileNotFoundError(2, "No such file or directory")), [], "/r", "p", "claude"), Failure("could not start claude: No such file or directory"))
class MarkTrusted(unittest.TestCase):
def test_returns_the_updated_config_and_leaves_the_one_it_was_handed(self):
config = {"other": 1, "projects": {"/a": {"hasTrustDialogAccepted": True}, "/b": {"kept": True}}}
handed = json.dumps(config)
self.assertEqual(trust.mark_trusted(config, ["/a", "/b", "/c"]), ({"other": 1, "projects": {"/a": {"hasTrustDialogAccepted": True}, "/b": {"hasTrustDialogAccepted": True, "kept": True}, "/c": {"hasTrustDialogAccepted": True}}}, ["/b", "/c"]))
self.assertEqual(json.dumps(config), handed)
self.assertEqual(trust.mark_trusted({}, ["/a"]), ({"projects": {"/a": {"hasTrustDialogAccepted": True}}}, ["/a"]))
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
-38
View File
@@ -1,38 +0,0 @@
import json
import pathlib
import typing
from failure import Failure
from file_writes import replace_json
# A failure only warns: claude still opens, and the human answers Claude Code's trust dialog.
def trust(config: pathlib.Path, roots: list[str], note: typing.Callable[[str], None]) -> None:
try:
with open(config, encoding="utf-8") as handle:
data = json.load(handle)
except (OSError, ValueError) as failure:
note(f"could not read {config}: {getattr(failure, 'strerror', failure)}")
return
marked = mark_trusted(data, roots)
if isinstance(marked, Failure):
note(f"could not read {config}: {marked.reason}")
return
updated, untrusted = marked
if not untrusted:
return
if unwritten := replace_json(config, updated, indent=2):
note(f"could not write {config}: {unwritten.reason}")
return
note("trusted for the interrupt: " + ", ".join(untrusted))
# Claude Code's config: {"projects": {"/home/me/code/log": {"hasTrustDialogAccepted": true, ...}}, ...}
def mark_trusted(config: object, roots: list[str]) -> tuple[dict, list[str]] | Failure:
if not isinstance(config, dict) or not isinstance(projects := config.get("projects", {}), dict):
return Failure('not an object whose "projects" is an object')
if (wrong := next((path for path, settings in projects.items() if not isinstance(settings, dict)), None)) is not None:
return Failure(f"projects[{json.dumps(wrong)}] is not an object")
untrusted = [path for path in roots if not projects.get(path, {}).get("hasTrustDialogAccepted")]
marked = {path: {**projects.get(path, {}), "hasTrustDialogAccepted": True} for path in untrusted}
return {**config, "projects": {**projects, **marked}}, untrusted
+1 -1
View File
@@ -82,7 +82,7 @@ def claude_open(ask: Ask, where: OpenOnTerminal | OpenInInbox, session: WorkerSe
match where: match where:
case OpenOnTerminal(): case OpenOnTerminal():
shown(paths.waiting, dataclasses.replace(ask, state=where), effects) shown(paths.waiting, dataclasses.replace(ask, state=where), effects)
if unstarted := hand_over(session.claude_command(), paths, effects): if unstarted := hand_over(session.claude_command(), effects):
return Stop(1, f"could not start claude for the interrupt: {unstarted.reason}") return Stop(1, f"could not start claude for the interrupt: {unstarted.reason}")
case OpenInInbox(pid): case OpenInInbox(pid):
make_way(paths.waiting, ask, pid, effects) make_way(paths.waiting, ask, pid, effects)
+6 -8
View File
@@ -1,12 +1,9 @@
"""Opens claude on the terminal for the human. It sits outside cycle/, since loop-inbox's /talk and the loop's routing calls open claude too.""" """Opens claude on the terminal for the human. It sits outside cycle/, since loop-inbox's /talk and the loop's routing calls open claude too."""
import dataclasses import dataclasses
from loop_claude.effects import Effects, say from loop_claude.effects import Effects
from failure import Failure from failure import Failure
from loop_claude.paths import Paths
from model_routing.ladder import Rung from model_routing.ladder import Rung
from claude_code.trust import trust
from loop_claude.project.checkout import worktrees
@dataclasses.dataclass(frozen=True) @dataclasses.dataclass(frozen=True)
@@ -21,11 +18,12 @@ def claude_args(rung: Rung, args: list[str]) -> list[str]:
return [*rung.flags(), "--permission-mode", "bypassPermissions", *args] return [*rung.flags(), "--permission-mode", "bypassPermissions", *args]
def hand_over(command: ClaudeCommand, paths: Paths, effects: Effects) -> Failure | None: # CLAUDE_CODE_SANDBOXED, which Claude Code doesn't document, skips its trust dialog without writing ~/.claude.json:
"""Marks trusted the checkout that command runs in, and each of its worktrees, then runs claude on the terminal as command says; the failure is why claude could not start.""" # docs/decisions.md → `loop-claude: every claude it or loop-inbox opens on a terminal has CLAUDE_CODE_SANDBOXED set, …`.
trust(paths.claude_json, worktrees(command.cwd, effects), lambda text: say(text, effects)) def hand_over(command: ClaudeCommand, effects: Effects) -> Failure | None:
"""Runs claude on the terminal as command says; the failure is why claude could not start."""
try: try:
effects.claude_on_terminal(command.args, command.cwd, command.env) effects.claude_on_terminal(command.args, command.cwd, {**command.env, "CLAUDE_CODE_SANDBOXED": "1"})
except OSError as failure: except OSError as failure:
return Failure(str(failure.strerror)) return Failure(str(failure.strerror))
return None return None
+2 -2
View File
@@ -30,8 +30,8 @@ interrupts of every loop on the machine. The first answer counts, from either pl
discuss first. Once that claude exits, the judge rules on what was typed there. discuss first. Once that claude exits, the judge rules on what was typed there.
- Enter alone, on loop-claude's terminal: stops the loop. - Enter alone, on loop-claude's terminal: stops the loop.
A release ready to cut opens that session on the terminal at once, since only the human may cut it; A release ready to cut opens that session on the terminal at once, since only the human may cut it;
loop-inbox lists it too. Before claude opens, the checkout and each of its worktrees are marked loop-inbox lists it too. That claude opens without Claude Code's trust dialog. While claude is
trusted in ~/.claude.json. While claude is open, Ctrl-C reaches it alone, and the loop goes on. open, Ctrl-C reaches it alone, and the loop goes on.
While it runs, loop-claude also lists itself in loop-inbox, with the todo.md items its chunk takes, While it runs, loop-claude also lists itself in loop-inbox, with the todo.md items its chunk takes,
as bin/loop_claude/running_loops.py describes. as bin/loop_claude/running_loops.py describes.
+1 -1
View File
@@ -55,7 +55,7 @@ def raise_calls(root: pathlib.Path, checkout: str, session: str, new: list[str],
prompt = f"Put these calls for a routing change from loop-claude's figures to the human, and change nothing until they answer:\n{bullets}The figures are in {root / archive.FIGURES}. The ladder, its steps and the delegation rule are docs/decisions.md → `routing:`, and a change to them is the human's. Record what they decide as ~/.claude/CLAUDE.md says; the next chunk of this repo files the plan item for these calls." prompt = f"Put these calls for a routing change from loop-claude's figures to the human, and change nothing until they answer:\n{bullets}The figures are in {root / archive.FIGURES}. The ladder, its steps and the delegation rule are docs/decisions.md → `routing:`, and a change to them is the human's. Record what they decide as ~/.claude/CLAUDE.md says; the next chunk of this repo files the plan item for these calls."
ask = Ask(effects.new_id(), session, checkout, question, effects.now(), OpenOnTerminal()) ask = Ask(effects.new_id(), session, checkout, question, effects.now(), OpenOnTerminal())
with listed(paths.waiting, ask, effects): with listed(paths.waiting, ask, effects):
unstarted = hand_over(ClaudeCommand(claude_args(rung, [prompt]), str(paths.claude_dir), {}), paths, effects) unstarted = hand_over(ClaudeCommand(claude_args(rung, [prompt]), str(paths.claude_dir), {}), effects)
if unstarted: if unstarted:
return Stop(1, f"could not start claude for the routing calls: {unstarted.reason}") return Stop(1, f"could not start claude for the routing calls: {unstarted.reason}")
# Raised once the human has seen them, answered or not: an unanswered call reaches the plan through AGENTS.md, so it is not asked twice. # Raised once the human has seen them, answered or not: an unanswered call reaches the plan through AGENTS.md, so it is not asked twice.
-2
View File
@@ -6,7 +6,6 @@ import pathlib
class Paths: class Paths:
claude_code_transcripts: pathlib.Path claude_code_transcripts: pathlib.Path
claude_dir: pathlib.Path claude_dir: pathlib.Path
claude_json: pathlib.Path
home: pathlib.Path home: pathlib.Path
model_catalog: pathlib.Path model_catalog: pathlib.Path
models_file: pathlib.Path models_file: pathlib.Path
@@ -19,7 +18,6 @@ def paths_from(home: pathlib.Path) -> Paths:
return Paths( return Paths(
claude_code_transcripts=claude / "projects", claude_code_transcripts=claude / "projects",
claude_dir=claude, claude_dir=claude,
claude_json=home / ".claude.json",
home=home, home=home,
model_catalog=claude / "cache" / "model-catalog", model_catalog=claude / "cache" / "model-catalog",
models_file=claude / "loop-claude-models.json", models_file=claude / "loop-claude-models.json",
-4
View File
@@ -11,7 +11,3 @@ def checkout_root(cwd: pathlib.Path, effects: Effects) -> str | Stop:
return Stop(1, found.reason) if isinstance(found, Failure) else found.strip() return Stop(1, found.reason) if isinstance(found, Failure) else found.strip()
def worktrees(root: str, effects: Effects) -> list[str]:
listing = effects.git("worktree", "list", "--porcelain", cwd=root)
listed = [] if isinstance(listing, Failure) else [line.split(" ", 1)[1] for line in listing.splitlines() if line.startswith("worktree ")]
return sorted({root, *listed})
+5 -51
View File
@@ -39,7 +39,7 @@ argv = sys.argv[1:]
role = "judge" if "--json-schema" in argv else "worker" if "-p" in argv else "interrupt" role = "judge" if "--json-schema" in argv else "worker" if "-p" in argv else "interrupt"
scenario = pathlib.Path(os.environ["FAKE_CLAUDE_SCENARIO"]) scenario = pathlib.Path(os.environ["FAKE_CLAUDE_SCENARIO"])
steps = json.loads(scenario.read_text()) steps = json.loads(scenario.read_text())
call = {{"argv": argv, "cwd": os.getcwd(), "role": role, "ctrl_c_ignored": signal.getsignal(signal.SIGINT) == signal.SIG_IGN}} call = {{"argv": argv, "cwd": os.getcwd(), "role": role, "ctrl_c_ignored": signal.getsignal(signal.SIGINT) == signal.SIG_IGN, "sandboxed": os.environ.get("CLAUDE_CODE_SANDBOXED")}}
# The items each loop lists in loop-inbox as this claude starts. # The items each loop lists in loop-inbox as this claude starts.
call["running"] = [json.loads(path.read_text())["items"] for path in sorted((pathlib.Path.home() / ".local" / "state" / "loop-claude").glob("*.running"))] call["running"] = [json.loads(path.read_text())["items"] for path in sorted((pathlib.Path.home() / ".local" / "state" / "loop-claude").glob("*.running"))]
if role == "judge": if role == "judge":
@@ -776,9 +776,8 @@ class Interrupt(unittest.TestCase):
def test_hands_the_terminal_over_and_exits_2_when_nothing_is_typed(self): def test_hands_the_terminal_over_and_exits_2_when_nothing_is_typed(self):
checkout = Checkout(self) checkout = Checkout(self)
checkout.git("commit", "--allow-empty", "--quiet", "-m", "start") checkout.git("commit", "--allow-empty", "--quiet", "-m", "start")
checkout.git("worktree", "add", "--quiet", str(checkout.home / "code" / "proj-wt")) claude_json = json.dumps({"projects": {str(checkout.root): {"kept": True}}})
checkout.claude_json().write_text(json.dumps({"other": 1, "projects": {str(checkout.root): {"kept": True}}})) checkout.claude_json().write_text(claude_json)
checkout.claude_json().chmod(0o644)
asked = [worker(say="Shall I use A or B?"), judge(interrupt=True, evidence="Shall I use A or B?", question="A or B?")] asked = [worker(say="Shall I use A or B?"), judge(interrupt=True, evidence="Shall I use A or B?", question="A or B?")]
(checkout.root / "sub").mkdir() (checkout.root / "sub").mkdir()
run = checkout.run([*asked, interrupt(type="B"), judge(evidence="B"), worker()], cwd=checkout.root / "sub", terminal_input="/talk\n", before_typing=ANSWERING) run = checkout.run([*asked, interrupt(type="B"), judge(evidence="B"), worker()], cwd=checkout.root / "sub", terminal_input="/talk\n", before_typing=ANSWERING)
@@ -790,12 +789,8 @@ class Interrupt(unittest.TestCase):
self.assertEqual(argument(run.calls[2], "--model"), "worker-model") self.assertEqual(argument(run.calls[2], "--model"), "worker-model")
self.assertNotIn("-p", handed) self.assertNotIn("-p", handed)
self.assertIn("[human] B", run.calls[3]["stdin"]) self.assertIn("[human] B", run.calls[3]["stdin"])
trusted = json.loads(checkout.claude_json().read_text()) self.assertEqual(run.calls[2]["sandboxed"], "1")
self.assertEqual(trusted["other"], 1) self.assertEqual(checkout.claude_json().read_text(), claude_json)
self.assertEqual(trusted["projects"][str(checkout.root)], {"hasTrustDialogAccepted": True, "kept": True})
self.assertEqual(trusted["projects"][str(checkout.home / "code" / "proj-wt")], {"hasTrustDialogAccepted": True})
self.assertEqual(stat.S_IMODE(checkout.claude_json().stat().st_mode), 0o644)
self.assertIn(f"trusted for the interrupt: {checkout.root}, {checkout.home / 'code' / 'proj-wt'}\n", run.stderr)
for transcript in checkout.transcripts(): for transcript in checkout.transcripts():
transcript.unlink() transcript.unlink()
@@ -815,47 +810,6 @@ class Interrupt(unittest.TestCase):
self.assertFalse(run.calls[2]["ctrl_c_ignored"]) self.assertFalse(run.calls[2]["ctrl_c_ignored"])
self.assertIn("[human] B", run.calls[3]["stdin"]) self.assertIn("[human] B", run.calls[3]["stdin"])
def test_says_why_the_trust_file_cannot_be_read_and_leaves_it_as_it_was(self):
checkout = Checkout(self)
asked = [worker(say="A or B?"), judge(interrupt=True, evidence="A or B?", question="A or B?"), interrupt()]
root = json.dumps(str(checkout.root))
shapes = {
None: "No such file or directory",
"{": "Expecting property name enclosed in double quotes: line 1 column 2 (char 1)",
"[]": 'not an object whose "projects" is an object',
'{"projects": []}': 'not an object whose "projects" is an object',
f'{{"projects": {{{root}: 1}}}}': f"projects[{root}] is not an object",
}
for text, said in shapes.items():
with self.subTest(said=said):
checkout.claude_json().unlink(missing_ok=True)
if text is not None:
checkout.claude_json().write_text(text)
run = checkout.run(asked, terminal_input="/talk\n", before_typing=ANSWERING)
self.assertEqual(run.code, 2)
self.assertIn(f"could not read {checkout.claude_json()}: {said}\n", run.stderr)
self.assertEqual(checkout.claude_json().read_text() if checkout.claude_json().exists() else None, text)
trusted = json.dumps({"projects": {str(checkout.root): {"hasTrustDialogAccepted": True}}})
checkout.claude_json().write_text(trusted)
run = checkout.run(asked, terminal_input="/talk\n", before_typing=ANSWERING)
self.assertNotIn(str(checkout.claude_json()), run.stderr)
self.assertNotIn("trusted for the interrupt", run.stderr)
self.assertEqual(checkout.claude_json().read_text(), trusted)
@unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory")
def test_says_why_the_trust_file_cannot_be_written(self):
checkout = Checkout(self)
checkout.claude_json().write_text("{}")
asked = [worker(say="A or B?"), judge(interrupt=True, evidence="A or B?", question="A or B?"), interrupt()]
checkout.run(asked[:2])
checkout.home.chmod(0o500)
self.addCleanup(checkout.home.chmod, 0o700)
run = checkout.run([worker(), *asked[1:]], terminal_input="/talk\n", before_typing=ANSWERING)
self.assertEqual(run.code, 2)
self.assertIn(f"could not write {checkout.claude_json()}: Permission denied\n", run.stderr)
self.assertEqual(checkout.claude_json().read_text(), "{}")
@unittest.skipIf(os.geteuid() == 0, "root reads an unreadable file") @unittest.skipIf(os.geteuid() == 0, "root reads an unreadable file")
def test_exits_1_when_the_transcript_cannot_be_read_after_the_interrupt(self): def test_exits_1_when_the_transcript_cannot_be_read_after_the_interrupt(self):
checkout = Checkout(self) checkout = Checkout(self)
-6
View File
@@ -1890,11 +1890,5 @@ class JudgeFailures(unittest.TestCase):
self.assertEqual([clause for *_, clause in clauses if clause not in judge_clause], []) self.assertEqual([clause for *_, clause in clauses if clause not in judge_clause], [])
class Worktrees(unittest.TestCase):
def test_lists_the_root_alone_when_git_cannot_start(self):
fake = FakeEffects(git=[Failure("git worktree list --porcelain could not start: [Errno 2] No such file or directory: 'git'")])
self.assertEqual(checkout.worktrees("/r", fake.effects()), ["/r"])
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
+1 -1
View File
@@ -168,7 +168,7 @@ def opened(screen_off: typing.Callable[[], typing.ContextManager[None]], paths:
return f"Could not open claude for {ask.root}: the loop was answered elsewhere or stopped, or didn't respond within {MAKE_WAY_SECONDS:g} s. If it is still listed, pick it again." return f"Could not open claude for {ask.root}: the loop was answered elsewhere or stopped, or didn't respond within {MAKE_WAY_SECONDS:g} s. If it is still listed, pick it again."
with screen_off(): with screen_off():
try: try:
unstarted = hand_over(ask.state.talk, paths, effects) unstarted = hand_over(ask.state.talk, effects)
finally: finally:
unsent = send(folder, ask, ClaudeEnded()) unsent = send(folder, ask, ClaudeEnded())
# The loop goes on only where the human typed in the worker's session, as interrupt.human_typed checks. # The loop goes on only where the human typed in the worker's session, as interrupt.human_typed checks.
+3 -5
View File
@@ -54,13 +54,11 @@ The cap is 5, `bin/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: by the
2026-10-17, lilleman, todo item 168. The human answers an interrupt on loop-claude's terminal, and the worker resumes headless with the answer in a `-p` prompt. The judge reads that answer as a `[human]` line, not a `[loop]` one, so it holds the chunk open until the answer is recorded, as it does for an answer typed in claude. 2026-10-17, lilleman, todo item 168. The human answers an interrupt on loop-claude's terminal, and the worker resumes headless with the answer in a `-p` prompt. The judge reads that answer as a `[human]` line, not a `[loop]` one, so it holds the chunk open until the answer is recorded, as it does for an answer typed in claude.
## loop-claude: before it or loop-inbox opens claude on a terminal, it marks the checkout and each of its worktrees trusted in `~/.claude.json` ## loop-claude: every claude it or loop-inbox opens on a terminal has `CLAUDE_CODE_SANDBOXED` set, so Claude Code skips its trust dialog, and loop-claude doesn't write `~/.claude.json`
2026-09-21, lilleman. Serves goal 1. `claude --resume` re-enters the worktree the worker last entered, recorded in the transcript's `worktree-state` entry, and Claude Code asks trust per path, so trusting the checkout alone still lands the human in the dialog. Trusting every worktree `git worktree list` names spares reading which one from the transcript. Since the human answers an interrupt on loop-claude's own terminal (todo item 168), claude opens there only for `/talk`, a release ready to cut and the routing calls, and the trust is marked only then. Valid while resume re-enters a recorded worktree and trust is kept per path. 2026-09-21, lilleman. Serves goal 1. `claude --resume` re-enters the worktree the worker last entered, recorded in the transcript's `worktree-state` entry, and Claude Code asks trust per path, so a claude opened on the checkout alone still lands the human in the trust dialog. Since the human answers an interrupt on loop-claude's own terminal (todo item 168), claude opens there only for `/talk`, a release ready to cut and the routing calls.
2026-09-30, lilleman. A write by another claude inside `trust`'s read-modify-write window is lost, a risk larv-review accepted on 2026-09-24. Claude Code owns and writes `~/.claude.json`, so `loop-claude` is to move out of it, bringing each case that must stay to the human. Stands until `todo.md` item 6 ends it. 2026-10-30, lilleman, todo item 6. Serves goal 1. Until then loop-claude marked each worktree trusted in `~/.claude.json`, reading the file, changing it and writing it back. Claude Code owns and writes that file, so a write it made in between was lost. Claude Code 2.1.314 treats every folder as trusted while `CLAUDE_CODE_SANDBOXED` is set, and doesn't persist that trust: a claude opened so in a new folder showed no dialog, and Claude Code recorded the folder untrusted. `hand_over` sets it for every claude it opens. The variable is true here, since loop-claude runs only in the sandbox README → Install names (`loop-claude: every claude it starts bypasses permissions inside its sandbox`). Claude Code doesn't document it. Where a later version drops it, the dialog comes back on those terminals, and nothing is lost. Valid while Claude Code honours `CLAUDE_CODE_SANDBOXED`.
2026-10-28, lilleman, todo item 243. `/talk` from loop-inbox opens claude in loop-inbox's terminal, through loop-claude's `hand_over`, which marks the trust just before. It adds a second writer to `~/.claude.json`, under the same risk, until item 6 ends it.
## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes ## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes
-5
View File
@@ -12,7 +12,6 @@
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---| |---|---|---|---|---|---|---|---|---|---|---|---|
| 6 | 0.5.0 | | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 3 | 3 | 3 | 7 | 3 | 1.1 by 5 | 5.3 |
| 257 | 0.5.0 | | | **Make `chunk-preflight` create the item's worktree and branch only when loop-claude starts a worker on it, so a run for the facts alone leaves nothing to remove.** | 3 | 2 | 3 | 6 | 4 | 1.5 by 2 | 1.3 | | 257 | 0.5.0 | | | **Make `chunk-preflight` create the item's worktree and branch only when loop-claude starts a worker on it, so a run for the facts alone leaves nothing to remove.** | 3 | 2 | 3 | 6 | 4 | 1.5 by 2 | 1.3 |
| 226 | 0.6.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 | | 226 | 0.6.0 | | question | **Answer whether rule-hook's `run-heavy` rule should also catch a mutation run or docker build behind `uv run`, `poetry run`, `python3 -m`, `sudo`, `docker image build` and `docker compose up --build`, or narrow the `machine load:` decision's wording.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 2, 1.5 by 2 | 4.0 |
| 248 | 0.6.0 | | question | **Answer whether the `rule-hook:` decision should name every rule that takes no override, `repeat-read`, `reviewer-report` and `reviewer-rung`, with each one's reason.** | 1 | 2 | 1 | 2 | 1 | 1.2 by 2 | 3.3 | | 248 | 0.6.0 | | question | **Answer whether the `rule-hook:` decision should name every rule that takes no override, `repeat-read`, `reviewer-report` and `reviewer-rung`, with each one's reason.** | 1 | 2 | 1 | 2 | 1 | 1.2 by 2 | 3.3 |
@@ -76,10 +75,6 @@
## Details ## Details
### 6. Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.
Claude Code owns that file and writes it. `trust` reads it, changes it and writes it back, so a write that lands in between is lost.
### 257. Make `chunk-preflight` create the item's worktree and branch only when loop-claude starts a worker on it, so a run for the facts alone leaves nothing to remove. ### 257. Make `chunk-preflight` create the item's worktree and branch only when loop-claude starts a worker on it, so a run for the facts alone leaves nothing to remove.
Found in fejkdata.dev on 2026-10-29 and 2026-10-30. Two runs of `chunk-preflight` by hand, made to read its facts and not to start a chunk, each added the sibling worktree `fejkdata.dev-item-20` and the branch `item-20` at `origin/main`, and the session had to remove both. `bin/chunk_preflight/main.py` makes the worktree whenever the plan has an item, since loop-claude runs it as a chunk starts (`bin/loop_claude/loop/main.py` → `chunk_start`) and the worker then works in that worktree. It takes no argument and exits 1 on one, so a caller cannot ask for the facts alone. Make the worktree, `reading-cost`, `larv-review places` and the other tools it runs in the worktree opt-in, loop-claude's call asking for them; a bare run prints the facts and says no worktree was made. Update `--help`, the docstring and the worker prompt that tells the worker its worktree exists. Item 256 removes the case that made most of these worktrees, a pick the worker must not take. Found in fejkdata.dev on 2026-10-29 and 2026-10-30. Two runs of `chunk-preflight` by hand, made to read its facts and not to start a chunk, each added the sibling worktree `fejkdata.dev-item-20` and the branch `item-20` at `origin/main`, and the session had to remove both. `bin/chunk_preflight/main.py` makes the worktree whenever the plan has an item, since loop-claude runs it as a chunk starts (`bin/loop_claude/loop/main.py` → `chunk_start`) and the worker then works in that worktree. It takes no argument and exits 1 on one, so a caller cannot ask for the facts alone. Make the worktree, `reading-cost`, `larv-review places` and the other tools it runs in the worktree opt-in, loop-claude's call asking for them; a bare run prints the facts and says no worktree was made. Update `--help`, the docstring and the worker prompt that tells the worker its worktree exists. Item 256 removes the case that made most of these worktrees, a pick the worker must not take.