container: give agent runs docker, gh auth and a git identity - #104
Merged
Merged
Conversation
A headless run started by the scheduler or the Pebble worker had none of the three. GH_TOKEN was exported only inside the Freeshard cycle, which is disabled on the VM (CLAYDE_FS_ENABLED=false), so `gh` was unauthenticated and the `!gh auth git-credential` helper could not push. No git identity was configured anywhere, so any commit failed with "Author identity unknown". And the image carried no docker client, which the app-repository update pass needs for `docker compose pull --dry-run`. bootstrap_process_env() now does the first two at both entry points instead of as a side effect of one loop, and the image gets the Docker CLI plus Compose plugin talking to the host socket through the host's docker group. CLAUDE.md already described the first two as if they were already true. The socket is the full one: an agent in this container can control every container on the host. Deliberate, weighed against running the update pass outside the container entirely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A headless run started by the scheduler or the Pebble worker could not commit, could not push, and could not talk to Docker. Verified in the running container on the VM today:
gh auth status→ not logged into any GitHub hosts.GH_TOKENis exported only insiderun_cycle()of the Freeshard loop, and that loop is off on the VM (CLAYDE_FS_ENABLED=false), so nothing ever set it. The credential helper is!gh auth git-credential, so pushes fail too.git commitin the container → Author identity unknown. Nouser.name/user.emailis configured anywhere, althoughCLAYDE_GIT_NAMEandCLAYDE_GIT_EMAILexist in config.dockerbinary in the image.CLAUDE.mdalready documented the first two as if they were true (lines 5 and 148). This makes them true.The motivating case is running the app-repository
update-appspass as a weekly scheduled task:update/update.py applygates every app ondocker compose pull --dry-run, then commits, pushes and opens a PR.What changed
config.bootstrap_process_env()exportsGH_TOKENand sets the global git identity from settings. Called from both entry points (orchestrator._run_with_pebble,freeshard.entry.run_loop) instead of happening as a side effect of one loop; the in-cycle export and its test move here.docker-ce-cli+docker-compose-pluginfrom Docker's Debian repo, codename taken from/etc/os-releaseso a base-image bump does not silently break it.docker-compose.ymlmounts/var/run/docker.sockand adds the host's docker group viagroup_add: ["${DOCKER_GID:-111}"], needed because the container runs as uid 1000.The socket is the full one. An agent in this container can control every container on the host. That is deliberate and was weighed against running the update pass outside the container; a read-only socket proxy would also work if we later want it.
Verified before opening this PR
Built the Docker-install layer on
python:3.13-slimand ran the resulting client against the host daemon as uid 1000:docker --version/docker compose versionin the built imagedocker versionas-u 1000:1000 --group-add 111--group-addpermission denied ... unix:///var/run/docker.sockdocker compose pull --dry-run -qon a rendered app template (audiobookshelf:2.36.0)manifest unknownThe last two are the gate
update.pydepends on, and they discriminate.uv run pytest: 418 passed.Deploy note
~/clayde/docker-compose.ymlon the VM is maintained by hand and needs the same two edits, plusDOCKER_GID=111in~/clayde/.env(this host'sgetent group docker). The container must be recreated, not just restarted, for the mount to apply.Recommended reading order
src/clayde/config.py— the new functionsrc/clayde/orchestrator.py,src/clayde/freeshard/entry.py— call sitessrc/clayde/freeshard/loop.py— the removed duplicateDockerfile,docker-compose.ymltests/test_config.py,tests/freeshard/test_loop.py