Today's fix covers every way a container run can END: the agent now hands the bind-mounted worktree back to the daemon's UID on every exit via a defer in runTask (internal/app/agentworker/task_execution.go), not only on the CommitAll/Push success path.
What is still broken: a container that is SIGKILLed never runs that defer -- docker kill, a max_uptime expiry, a daemon crash. The worktree is then left with root-owned directories (node_modules, bin/, any build output the root agent created), and the daemon runs as its own non-root host user, so it cannot unlink inside them. The retry path is honest about it now (worktree refresh reports 'permission denied' instead of the old masked 'branch already exists'), but retry still cannot start: worktree.Manager.Prepare -> resetOnto -> cleanUntracked fails before the branch is touched, and DeleteWorktree/Cleanup fails the same way.
Reproduced: create a directory owned by root:root with content inside a prepared worktree, then call Prepare again. 'clear abandoned worktree files: unlinkat
/: permission denied'.
Options, none of them free:
Daemon-side repair is impossible without privilege (chown needs CAP_CHOWN, and the daemon deliberately does not run as root).
A startup reconcile inside the container (archie-agent chowns the worktree to WORKTREE_UID before running the task) would repair leftovers from a previous killed container, at the cost of a full tree walk on every task start and a repair-at-the-consumer layer.
Run the agent container as the daemon's UID (--user): removes the ownership mismatch entirely, but the image installs languages at runtime via uv/npm/go as root, so this needs the image reworked.
Treat an un-cleanable worktree as 'recreate from scratch': os.RemoveAll fails for the same reason, so this does not work either.
Acceptance: a task whose previous attempt's container was SIGKILLed can be retried without manual host intervention, and the chosen mechanism is documented in docs/architecture/observability.md or ARCHITECTURE.md.
Close reason
A permission-denied worktree is chowned by a throwaway root container and retried once.
Imported from beads archie-core-zcg8 · GitHub #867 · type bug · priority P2 · created 2026-09-17 · closed 2026-10-10
Today's fix covers every way a container run can END: the agent now hands the bind-mounted worktree back to the daemon's UID on every exit via a defer in runTask (internal/app/agentworker/task_execution.go), not only on the CommitAll/Push success path.
What is still broken: a container that is SIGKILLed never runs that defer -- docker kill, a max_uptime expiry, a daemon crash. The worktree is then left with root-owned directories (node_modules, bin/, any build output the root agent created), and the daemon runs as its own non-root host user, so it cannot unlink inside them. The retry path is honest about it now (worktree refresh reports 'permission denied' instead of the old masked 'branch already exists'), but retry still cannot start: worktree.Manager.Prepare -> resetOnto -> cleanUntracked fails before the branch is touched, and DeleteWorktree/Cleanup fails the same way.
Reproduced: create a directory owned by root:root with content inside a prepared worktree, then call Prepare again. 'clear abandoned worktree files: unlinkat <dir>/<file>: permission denied'.
Options, none of them free:
1. Daemon-side repair is impossible without privilege (chown needs CAP_CHOWN, and the daemon deliberately does not run as root).
2. A startup reconcile inside the container (archie-agent chowns the worktree to WORKTREE_UID before running the task) would repair leftovers from a previous killed container, at the cost of a full tree walk on every task start and a repair-at-the-consumer layer.
3. Run the agent container as the daemon's UID (--user): removes the ownership mismatch entirely, but the image installs languages at runtime via uv/npm/go as root, so this needs the image reworked.
4. Treat an un-cleanable worktree as 'recreate from scratch': os.RemoveAll fails for the same reason, so this does not work either.
Acceptance: a task whose previous attempt's container was SIGKILLed can be retried without manual host intervention, and the chosen mechanism is documented in docs/architecture/observability.md or ARCHITECTURE.md.
### Close reason
A permission-denied worktree is chowned by a throwaway root container and retried once.
---
_Imported from beads `archie-core-zcg8` · GitHub #867 · type bug · priority P2 · created 2026-09-17 · closed 2026-10-10_
sam
added the bugmedium labels 2026-10-27 13:41:24 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Today's fix covers every way a container run can END: the agent now hands the bind-mounted worktree back to the daemon's UID on every exit via a defer in runTask (internal/app/agentworker/task_execution.go), not only on the CommitAll/Push success path.
What is still broken: a container that is SIGKILLed never runs that defer -- docker kill, a max_uptime expiry, a daemon crash. The worktree is then left with root-owned directories (node_modules, bin/, any build output the root agent created), and the daemon runs as its own non-root host user, so it cannot unlink inside them. The retry path is honest about it now (worktree refresh reports 'permission denied' instead of the old masked 'branch already exists'), but retry still cannot start: worktree.Manager.Prepare -> resetOnto -> cleanUntracked fails before the branch is touched, and DeleteWorktree/Cleanup fails the same way.
Reproduced: create a directory owned by root:root with content inside a prepared worktree, then call Prepare again. 'clear abandoned worktree files: unlinkat
/: permission denied'.Options, none of them free:
Acceptance: a task whose previous attempt's container was SIGKILLed can be retried without manual host intervention, and the chosen mechanism is documented in docs/architecture/observability.md or ARCHITECTURE.md.
Close reason
A permission-denied worktree is chowned by a throwaway root container and retried once.
Imported from beads
archie-core-zcg8· GitHub #867 · type bug · priority P2 · created 2026-09-17 · closed 2026-10-10