Run the first chunk in the gate, and record what loads from the person's own home

This commit is contained in:
2026-12-04 06:53:09 +01:00
parent 66705ca616
commit ecbbe98823
4 changed files with 17 additions and 9 deletions
+2
View File
@@ -328,6 +328,8 @@ Test on the host with `bin/run-tests`, which runs pytest through `uvx`, pinned i
The commands in this section name their tools bare, as Tools says. CI runs `ci.sh` on every pull request, and `main` doesn't merge anything until it passes. The script runs the same tests on the committed HEAD in a pinned Python container. Run it under `run-heavy` to reproduce a CI failure, with Docker on `PATH` and its socket at `/var/run/docker.sock`, which the container shares.
`ci.sh` then runs `first-chunk-e2e/run`, which checks goals 2 and 3 as a newcomer meets them. It builds a container that holds what Install asks for and a stock Claude Code with a `~/.claude` of its own, clones the committed HEAD there, and has `build-release` run a task in a small project. A mock Messages API answers claude as a worker that is done and as a judge that rules the chunk finished, so the run needs no sign-in. It fails unless the chunk finishes on the setup's instructions, no request holds an instruction from the container's `~/.claude`, and that folder and `~/.claude.json` hold what they held before. Run it under `run-heavy` too. It needs the network: the image fetches Claude Code, and `build-release` installs the plugins.
To mutation-test the lines a branch changes, run `run-heavy mutate-changes --prefix 'uvx --python "$(command -v python3)" --with pytest==9.2.0 --from "mutmut>=3,<4"'` in its checkout.
To bench how hard the code is to fix a bug in, build the image first, with `run-heavy docker build --quiet --memory 2g --memory-swap 2g -t dev-factory-task-bench task-bench-image`. Then run `task-bench --image dev-factory-task-bench --prefix 'uvx --python "$(command -v python3)" --with pytest==9.2.0 --from "mutmut>=3,<4"' --test 'python -m pytest -q -p no:cacheprovider -n 4 bin --ignore=bin/adf_codec --ignore=bin/run_tests --ignore=bin/repo_checks/test_types.py --deselect bin/plan/test_touches.py::PredictedTest --deselect bin/loop_effects/test_effects.py::ChildShells'` in this checkout, under `run-heavy`. A scoring run starts it with `--record-figures` added. The bench runs the tests with no network, so the image holds everything they need. The `--test` leaves out the tests that need docker or `uvx`, and `ChildShells`, which needs `docker run --init` to reap its processes: `bin/run-tests` on the host runs those.
+2
View File
@@ -18,3 +18,5 @@ git bundle create - HEAD | docker run --rm -i ${CI_CONTAINER:+--name "$CI_CONTAI
# On a failure, the CI log shows the whole pytest output, which run-tests saved to its log file.
PATH="$HOME/.local/bin:$PATH" bin/run-tests || { cat /tmp/run-tests-*.log; exit 1; }
'
# Then a newcomer's first chunk, in a container that holds only a stock Claude Code: first-chunk-e2e/run says what it checks.
sh first-chunk-e2e/run
+1
View File
@@ -132,6 +132,7 @@ The cap is 5, `bin/plan/todo_table.py`'s `BUNDLE_MAX_R`, from the same chunks: b
2026-11-20, lilleman's standalone-install plan. Serves goal 3, which keeps the setup out of the human's `~/.claude`, and goal 5: a home of its own keeps the loop's transcripts and token apart from the human's. The plan therefore runs every claude the loop starts in a home of its own, and doesn't load the setup with `--plugin-dir`, `--settings` and `--append-system-prompt-file` over the human's home. The probes ran on Claude Code 2.1.330, on throwaway homes, never the human's. A mock Messages API at `ANTHROPIC_BASE_URL` recorded each request and answered the first with a tool call that reads a file, so the system prompt and the tool results show what loaded, with no real token. A bullet that names 2.1.336 was probed on that version instead. Each result holds for the version it was probed on; repeat the probes when the version changes.
- **Loads from `$CLAUDE_CONFIG_DIR`:** `CLAUDE.md` (in the system prompt), `rules/*.md` (one with `paths:` entered the context after the model read a matching file, not before), `agents/`, `skills/`, the hooks of `settings.json` (a `SessionStart` hook ran) and plugins. `claude plugin marketplace add` and `claude plugin install` write to `<home>/plugins`, and the installed plugin's skill is listed. `.claude.json` lands in the home too, so the human's `~/.claude.json` stays theirs.
- **The human's own `~/.claude/CLAUDE.md` and `~/.claude/rules/` load too, unless the home's settings exclude them.** 2026-12-04, found by `first-chunk-e2e/run` on Claude Code 2.1.336: claude reads `.claude/CLAUDE.md` and `.claude/rules/` in every folder above its working folder as project instructions, and the human's home folder is above each of their projects. Both reached the worker's request in the loop's home. A `SessionStart` hook in the human's `~/.claude/settings.json` didn't run. So `bin/claude_home` writes `claudeMdExcludes` into the home's `settings.json`, naming everything under the human's `~/.claude`, after which neither loads. Not tested: a `CLAUDE.md` in the human's home folder itself, which is outside their Claude home.
- **The loop's home signs in by `/login`.** 2026-12-03, lilleman, planning 0.18.0: the human signs in once, in a claude started with `CLAUDE_CONFIG_DIR` naming the loop's home, and makes and keeps no long-lived token file. `bin/claude_home` asks `claude auth status` before a command starts a chunk. Probed on Claude Code 2.1.336 in a throwaway home: signed out, it prints JSON with `loggedIn: false` and exits 1. Not tested: where the home keeps the sign-in. The token below stays the way a container signs in, as task-bench does.
- **Signs in by `CLAUDE_CODE_OAUTH_TOKEN`:** the request carried `Authorization: Bearer <token>` with the `oauth-2025-04-20` beta, and `claude auth status` said `loggedIn: true, authMethod: oauth_token`. The home didn't hold a credentials file. Without the variable the home is `loggedIn: false`. Not tested: that Anthropic accepts a real token, since `claude setup-token` needs the human's browser sign-in. The authentication docs say the token lasts one year and can only make model requests; neither is tested, and the first real run shows whether it signs in.
- **`--bare` can't use that token.** With `CLAUDE_CODE_OAUTH_TOKEN`, it says `Not logged in · Please run /login` and doesn't send a request. With `ANTHROPIC_API_KEY` it signs in, but doesn't load anything from the home (`CLAUDE.md`, rules, agents or skills) and offers only Bash, Edit and Read. So a container that signs in by a long-lived token runs without `--bare`; its fresh home is empty, so nothing of the human's loads there either. The project's `CLAUDE.md` loads from the working folder, and its `AGENTS.md` only where the project has no `CLAUDE.md`.
+12 -9
View File
@@ -24,7 +24,8 @@ OWN_RULE = "Open every reply with the newcomer's own greeting."
OWN_HOOK_RAN = HOME / "own-hook-ran"
OWN_FILES = {
"CLAUDE.md": OWN_INSTRUCTION + "\n",
"rules/greeting.md": OWN_RULE + "\n",
# In two parts, since bin/repo_checks/test_citations.py reads a rule file's path written whole as one of the setup's.
os.path.join("rules", "greeting.md"): OWN_RULE + "\n",
"settings.json": json.dumps({"hooks": {"SessionStart": [{"hooks": [{"type": "command", "command": f"touch {OWN_HOOK_RAN}"}]}]}}) + "\n",
}
# A heading of the setup's CLAUDE.md, which the worker's request holds where the loop's home loaded.
@@ -106,11 +107,14 @@ def windows() -> str:
return "\n".join(subprocess.run(["tmux", "capture-pane", "-p", "-J", "-S", "-200", "-t", pane], capture_output=True, text=True).stdout.strip() for pane in listed)
def model_typed(deadline: float) -> None:
"""Types the project's model into the chunk's window once build-release asks for it there."""
def chunk_awaited() -> None:
"""Types the project's model into the chunk's window once build-release asks for it there, then waits until the chunk finishes or PATIENCE runs out."""
deadline = time.monotonic() + PATIENCE
while MODEL_QUESTION not in windows() and time.monotonic() < deadline:
time.sleep(1)
subprocess.run(["tmux", "send-keys", "-t", "loop-first-project:", MODEL, "Enter"], capture_output=True)
while not chunk_finished() and time.monotonic() < deadline:
time.sleep(1)
def failures(requests: mock_messages_api.Requests, before: dict[str, str]) -> list[str]:
@@ -144,12 +148,11 @@ def main() -> int:
# The token signs claude in, as docs/decisions.md → `Claude Code in a home of its own` found; the mock doesn't check it.
env = {**os.environ, "ANTHROPIC_BASE_URL": f"http://127.0.0.1:{server.server_port}", "CLAUDE_CODE_OAUTH_TOKEN": "mock-token"}
started = subprocess.run([str(CLONE / "bin" / "build-release"), "Write a note of what the project is for."], cwd=PROJECT, env=env, stdin=subprocess.DEVNULL)
deadline = time.monotonic() + PATIENCE
if started.returncode == 0:
model_typed(deadline)
while started.returncode == 0 and not chunk_finished() and time.monotonic() < deadline:
time.sleep(1)
found = [f"build-release exited {started.returncode}"] if started.returncode else failures(requests, before)
if started.returncode:
found = [f"build-release exited {started.returncode}"]
else:
chunk_awaited()
found = failures(requests, before)
subprocess.run(["tmux", "kill-server"], capture_output=True)
for failure in found:
print(f"FAILED: {failure}", file=sys.stderr)