Found while fixing #1664 — deliberately left out of that PR to keep the P0 data-loss fix tight.
Summary
Rename keeps the agent's Docker volumes under the pre-rename base (agent-{old}-workspace); the live container carries the mount forward, so the running agent is fine. But three code paths still derive the volume name by f-stringing the agent's current name, which for a renamed agent points at a volume that does not exist:
Fix
#1664 added the primitive: agent_ownership.volume_base_name (NULL ⇒ agent_name) + db.get_volume_base_name(agent). The purge path and the orphan sweep already resolve through it. These paths should too:
base = db.get_volume_base_name(agent_name) or agent_name
base_volumes = {f"agent-{base}-workspace": {"bind": "/home/developer", "mode": "rw"}}
A repo-wide grep for f"agent-{...}-workspace" is the audit — every site that means "this agent's volume" must go through get_volume_base_name, never the current name.
Repro
- Create agent
old, write files to its workspace.
- Rename
old → new.
- Soft-delete
new, then recover it via POST /api/admin/soft-deleted/agents/new/recover.
POST /api/agents/new/start → container comes up on a brand-new empty agent-new-workspace; the data sits unreferenced in agent-old-workspace.
Related
Found while fixing #1664 — deliberately left out of that PR to keep the P0 data-loss fix tight.
Summary
Rename keeps the agent's Docker volumes under the pre-rename base (
agent-{old}-workspace); the live container carries the mount forward, so the running agent is fine. But three code paths still derive the volume name by f-stringing the agent's current name, which for a renamed agent points at a volume that does not exist:services/agent_service/lifecycle.py::recreate_missing_container(bug(recovery): soft-delete recovery dead-ends —recovertells you tostart, butstart404s when the container is gone #1559 soft-delete recovery) —base_volumes = {f"agent-{agent_name}-workspace": ...}. Recovering a renamed, soft-deleted agent creates a fresh empty volume and starts the agent on it. The real data volume survives on disk (untouched, and bug: #1581 orphan-volume sweep can destroy a live renamed agent's home volume (rename keeps old volume name+label) #1664 keeps the sweep off it), but the agent comes back with an empty/home/developer— silently.services/agent_service/lifecycle.py::_read_template_yaml_from_volume(bug(recovery): soft-delete recovery dead-ends —recovertells you tostart, butstart404s when the container is gone #1559) — readstemplate.yamlfromagent-{agent_name}-workspace; for a renamed agent that volume is absent, so it falls back to defaults ({}) instead of the committed template metadata (agent-type / runtime).services/agent_service/deploy.py::_prepopulate_workspace_from_templateuses the same convention (fine today — deploy names are fresh — but it is the same latent assumption).Fix
#1664 added the primitive:
agent_ownership.volume_base_name(NULL ⇒agent_name) +db.get_volume_base_name(agent). The purge path and the orphan sweep already resolve through it. These paths should too:A repo-wide grep for
f"agent-{...}-workspace"is the audit — every site that means "this agent's volume" must go throughget_volume_base_name, never the current name.Repro
old, write files to its workspace.old→new.new, then recover it viaPOST /api/admin/soft-deleted/agents/new/recover.POST /api/agents/new/start→ container comes up on a brand-new emptyagent-new-workspace; the data sits unreferenced inagent-old-workspace.Related
volume_base_name+get_volume_base_namerecovertells you tostart, butstart404s when the container is gone #1559 (soft-delete recovery gap / recreate_missing_container)data_paths) — the data class at stake