fix(codex): align with the standard SessionDirTemplate pattern
Codex was the only agent that bind-mounted its host home into the
container via an explicit `Mounts: [{home}/.codex → /root/.codex]`
entry, while every other ACP agent uses `SessionConfig.SessionDirTemplate`
+ `SessionDirTarget`. Move codex onto the same surface so the
host-state isolation work in the next commit covers it uniformly.
This change alone does not stop the host-state leak — the bind mount
still resolves to the host's ~/.codex for now — but it removes the
last agent-specific branch in the runtime config so the docker
container manager can apply one rule for all agents.
This commit is contained in:
@@ -88,13 +88,19 @@ func (a *CodexACP) Runtime() *RuntimeConfig {
|
||||
Env: map[string]string{},
|
||||
Mounts: []MountTemplate{
|
||||
{Source: "{workspace}", Target: "/workspace"},
|
||||
{Source: "{home}/.codex", Target: "/root/.codex"},
|
||||
},
|
||||
ResourceLimits: ResourceLimits{MemoryMB: 4096, CPUCores: 2.0, Timeout: time.Hour},
|
||||
Protocol: agent.ProtocolACP,
|
||||
SessionConfig: SessionConfig{
|
||||
NativeSessionResume: true,
|
||||
CanRecover: &canRecover,
|
||||
// Use the same SessionDirTemplate pattern every other ACP agent
|
||||
// uses; the docker container manager wires this into a kandev-owned
|
||||
// per-container session dir, isolated from the host's ~/.codex
|
||||
// (which carries host-absolute rollout paths in state.db that
|
||||
// don't resolve inside the container).
|
||||
SessionDirTemplate: "{home}/.codex",
|
||||
SessionDirTarget: "/root/.codex",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package agents
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCodexACPRuntimeNoLongerBindMountsHostHome(t *testing.T) {
|
||||
a := NewCodexACP()
|
||||
rt := a.Runtime()
|
||||
|
||||
for _, m := range rt.Mounts {
|
||||
if strings.Contains(m.Source, "{home}") {
|
||||
t.Fatalf("codex Mounts unexpectedly references {home}: %+v", m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodexACPSessionDirTemplate(t *testing.T) {
|
||||
a := NewCodexACP()
|
||||
cfg := a.Runtime().SessionConfig
|
||||
|
||||
if cfg.SessionDirTemplate != "{home}/.codex" {
|
||||
t.Fatalf("SessionDirTemplate = %q, want %q", cfg.SessionDirTemplate, "{home}/.codex")
|
||||
}
|
||||
if cfg.SessionDirTarget != "/root/.codex" {
|
||||
t.Fatalf("SessionDirTarget = %q, want %q", cfg.SessionDirTarget, "/root/.codex")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user