Skip to main content

ag_session/
env.rs

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