diff --git a/hive-c0re/src/lifecycle.rs b/hive-c0re/src/lifecycle.rs index 2b9656d..e5ee15b 100644 --- a/hive-c0re/src/lifecycle.rs +++ b/hive-c0re/src/lifecycle.rs @@ -742,8 +742,29 @@ fn set_nspawn_flags( let path = format!("/etc/nixos-containers/{container}.conf"); let original = std::fs::read_to_string(&path).with_context(|| format!("read {path}"))?; + + // Compute mount points: for sub-agents, bind /agents// with state+claude inside. + // For manager, use the old structure with /root/.claude and /state. + let agent_mount_base = if container == MANAGER_NAME { + None // Manager has no agent-specific mount + } else { + // Strip the "h-" prefix from container name to get agent name + let agent_name = container.strip_prefix(AGENT_PREFIX).unwrap_or(container); + Some(format!("/agents/{agent_name}")) + }; + + // For sub-agents: bind /agents// containing state and claude + // For manager: use old /state and /root/.claude mounts + let (notes_mount, claude_mount) = if let Some(ref mount_base) = agent_mount_base { + // Sub-agent: state at /agents//state, claude at /agents//claude + (format!("{mount_base}/state"), format!("{mount_base}/claude")) + } else { + // Manager: keep current structure + (CONTAINER_NOTES_MOUNT.to_owned(), CONTAINER_CLAUDE_MOUNT.to_owned()) + }; + let mut binds = format!( - "--bind={runtime}:{CONTAINER_RUNTIME_MOUNT} --bind={claude}:{CONTAINER_CLAUDE_MOUNT} --bind={notes}:{CONTAINER_NOTES_MOUNT} --bind={shared}:{CONTAINER_SHARED_MOUNT}", + "--bind={runtime}:{CONTAINER_RUNTIME_MOUNT} --bind={claude}:{claude_mount} --bind={notes}:{notes_mount} --bind={shared}:{CONTAINER_SHARED_MOUNT}", runtime = runtime_dir.display(), claude = claude_dir.display(), notes = notes_dir.display(),