Agent containers bind-mount the worktree from the host at /data/worktree, where the owning UID differs from the container user's UID. Git refuses to operate in such directories ("fatal: detected dubious ownership in repository"), and the Go toolchain calls git for VCS status during go build/go test/go vet.
This means every gate — baseline gate, build gate, TDD repro gate — fails immediately, before any real work begins. Agents burn tokens trying to fix the environment instead of working on the assigned issue.
Evidence
Task for issue #441 burned 557K tokens across 29 iterations and parked with gate_failed_final — the agent never reached the actual multi-forge fix
go build within the container fails with error obtaining VCS status: exit status 128
The agent's uncommitted build_test.go recognized the real cause: "A pre-existing git dubious-ownership issue causes the build to fail"
Fix
Add git config --global --add safe.directory /data/worktree at archie-agent startup. The worktree mount path is always /data/worktree (storage.WorktreeMountDir). The command is best-effort: if git isn't installed, the agent logs a warning and continues — it remains usable for repos without gate commands.
Files
cmd/archie-agent/main.go: run git safe.directory config after logger init
Close reason
Fixed: internal/infrastructure/agentgit/safety.go's MarkSafe adds the mounted worktree to git's global safe.directory list, and it is wired into the actual agent-container startup path -- internal/app/agentworker/worker.go:63,84 calls dependencies.markSafe(ctx, workDir, log) unconditionally in run(), before NATS connect and before any gate executes. Confirmed by grep this is the only non-test call site (worker.go), so it isn't dead/unwired code. go test ./internal/infrastructure/agentgit/... and ./internal/app/agentworker/... -race -count=1 both pass, including worker_test.go coverage that exercises the run() path with markSafe wired in. This matches the exact fix archie-core-1786749700606-6-bf6aa32d already describes as done ('#468 ... resolved by safe.directory').
Imported from beads archie-core-1786637501304-434-efae0b99 · GitHub #468 · type bug · priority P2 · created 2026-08-12 · closed 2026-08-15
## Problem
Agent containers bind-mount the worktree from the host at `/data/worktree`, where the owning UID differs from the container user's UID. Git refuses to operate in such directories ("fatal: detected dubious ownership in repository"), and the Go toolchain calls git for VCS status during `go build`/`go test`/`go vet`.
This means every gate — baseline gate, build gate, TDD repro gate — fails immediately, before any real work begins. Agents burn tokens trying to fix the environment instead of working on the assigned issue.
## Evidence
- Task for issue #441 burned 557K tokens across 29 iterations and parked with `gate_failed_final` — the agent never reached the actual multi-forge fix
- `go build` within the container fails with `error obtaining VCS status: exit status 128`
- The agent's uncommitted `build_test.go` recognized the real cause: "A pre-existing git dubious-ownership issue causes the build to fail"
## Fix
Add `git config --global --add safe.directory /data/worktree` at archie-agent startup. The worktree mount path is always `/data/worktree` (storage.WorktreeMountDir). The command is best-effort: if git isn't installed, the agent logs a warning and continues — it remains usable for repos without gate commands.
## Files
- `cmd/archie-agent/main.go`: run git safe.directory config after logger init
### Close reason
Fixed: internal/infrastructure/agentgit/safety.go's MarkSafe adds the mounted worktree to git's global safe.directory list, and it is wired into the actual agent-container startup path -- internal/app/agentworker/worker.go:63,84 calls dependencies.markSafe(ctx, workDir, log) unconditionally in run(), before NATS connect and before any gate executes. Confirmed by grep this is the only non-test call site (worker.go), so it isn't dead/unwired code. go test ./internal/infrastructure/agentgit/... and ./internal/app/agentworker/... -race -count=1 both pass, including worker_test.go coverage that exercises the run() path with markSafe wired in. This matches the exact fix archie-core-1786749700606-6-bf6aa32d already describes as done ('#468 ... resolved by safe.directory').
---
_Imported from beads `archie-core-1786637501304-434-efae0b99` · GitHub #468 · type bug · priority P2 · created 2026-08-12 · closed 2026-08-15_
sam
added the mediumbug labels 2026-10-27 13:38:28 +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.
Problem
Agent containers bind-mount the worktree from the host at
/data/worktree, where the owning UID differs from the container user's UID. Git refuses to operate in such directories ("fatal: detected dubious ownership in repository"), and the Go toolchain calls git for VCS status duringgo build/go test/go vet.This means every gate — baseline gate, build gate, TDD repro gate — fails immediately, before any real work begins. Agents burn tokens trying to fix the environment instead of working on the assigned issue.
Evidence
gate_failed_final— the agent never reached the actual multi-forge fixgo buildwithin the container fails witherror obtaining VCS status: exit status 128build_test.gorecognized the real cause: "A pre-existing git dubious-ownership issue causes the build to fail"Fix
Add
git config --global --add safe.directory /data/worktreeat archie-agent startup. The worktree mount path is always/data/worktree(storage.WorktreeMountDir). The command is best-effort: if git isn't installed, the agent logs a warning and continues — it remains usable for repos without gate commands.Files
cmd/archie-agent/main.go: run git safe.directory config after logger initClose reason
Fixed: internal/infrastructure/agentgit/safety.go's MarkSafe adds the mounted worktree to git's global safe.directory list, and it is wired into the actual agent-container startup path -- internal/app/agentworker/worker.go:63,84 calls dependencies.markSafe(ctx, workDir, log) unconditionally in run(), before NATS connect and before any gate executes. Confirmed by grep this is the only non-test call site (worker.go), so it isn't dead/unwired code. go test ./internal/infrastructure/agentgit/... and ./internal/app/agentworker/... -race -count=1 both pass, including worker_test.go coverage that exercises the run() path with markSafe wired in. This matches the exact fix archie-core-1786749700606-6-bf6aa32d already describes as done ('#468 ... resolved by safe.directory').
Imported from beads
archie-core-1786637501304-434-efae0b99· GitHub #468 · type bug · priority P2 · created 2026-08-12 · closed 2026-08-15