ag_session/env.rs
1//! Execution locations, independent of agent conversations and permissions.
2
3use std::path::PathBuf;
4
5use serde::{Deserialize, Serialize};
6
7use crate::SessionId;
8
9/// Stable identity and lifecycle owner of an execution environment.
10///
11/// The existing session worktree is shared by all tasks in that session.
12/// Its identity uses the full persisted session ID, never the shortened branch
13/// name or a filesystem path. Session setup and cleanup remain authoritative;
14/// finishing a task does not release the environment.
15#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
16pub enum EnvId {
17 /// A local worktree owned by one session and shared by its tasks.
18 SessionWorktree(SessionId),
19}
20
21/// Host-resolved local environment for execution in a shared session worktree.
22///
23/// Hosts validate the workspace before constructing this value. Resolution
24/// neither provisions a checkout nor grants permissions. Paths describe the
25/// current host, not durable identity or a security sandbox. Separate task
26/// worktrees and remote execution are not supported yet.
27#[derive(Clone, Debug, Eq, PartialEq)]
28pub struct ResolvedEnv {
29 /// Validated session branch in the shared repository.
30 pub branch: String,
31 /// Working directory passed to execution, preserving the host's path.
32 pub folder: PathBuf,
33 /// Stable environment identity and cleanup owner.
34 pub id: EnvId,
35 /// Canonical main checkout protected by isolation checks, if non-bare.
36 pub main_checkout: Option<PathBuf>,
37}