pub struct Session {
pub id: String,
pub task: String,
pub agent: Option<String>,
pub project: Option<String>,
pub status: SessionStatus,
pub created_at: DateTime<Utc>,
pub mode: Option<HarnessMode>,
pub binding: ProjectBinding,
pub workstream_id: Option<WorkstreamId>,
pub result: Option<TaskResult>,
pub no_delegate: bool,
}Expand description
A daemon-owned session (vision spec Axiom 4).
Why: the wire type every session.* method (except send/attach/
detach, which acknowledge rather than return a session) sends back to
the caller — session.create, session.list, session.status.
What: id is a UUIDv4 string; agent/project are optional because
session.create does not require either in M1 (no real agent-loop
wiring yet); created_at is UTC. mode (#2059) is None until
task.run resolves and sets it (SessionRegistry::set_mode) — a session
that has never run a task has no mode, mirroring the same “None means
not yet run” convention session::transcript::TranscriptRecord already
uses for cost_usd.
binding is the session’s TYPED project binding (spec DOC-39 §5.5) — the
single object task.run and session.create now converge on. project
survives as the human display label but is no longer an independent source
of truth: it is DERIVED from binding (ProjectBinding::label) and so can
never again disagree with it. That derivation is the whole reconciliation —
previously session.create took a free-form label that was never validated
and never bound, while task.run took a path the label knew nothing about.
Test: model::tests::session_round_trips_through_json,
model::tests::projectless_session_round_trips.
Fields§
§id: String§task: String§agent: Option<String>§project: Option<String>Display label, derived from binding — see the struct docs. Kept for
wire compatibility with existing session.list/session.status
consumers that read a project name.
status: SessionStatus§created_at: DateTime<Utc>§mode: Option<HarnessMode>§binding: ProjectBindingThe typed three-state project binding. Defaults to projectless so an
older persisted/serialized Session without the field still reads back.
workstream_id: Option<WorkstreamId>(Issue #3298, DOC-48 §4.1) The workstream this session is bound to, if
any. None means projectless/unbound — a fully valid state (DOC-39
§4.2), not a missing one. Set exactly once, at creation
(session::protocol::create / task::protocol::task_run resolve
either an explicit workstream_id param or §4.2’s ambient
active-workstream default before calling
SessionRegistry::bind_workstream); there is no setter that changes
it afterward, mirroring binding’s own immutability convention — see
SessionRegistry::bind_workstream’s docs for the enforcement point.
#[serde(default)] keeps an older persisted/serialized Session
(predating this field) reading back as unbound.
result: Option<TaskResult>(#4351) The actionable outcome of this session’s last run — where the
change landed and whether it passed — set once the run reaches a
terminal state (crate::task::executor -> SessionRegistry:: set_task_result).
None until then, and OMITTED from the JSON entirely while None, so
every pre-#4351 consumer sees a byte-identical session.status
payload for a session that has never run. #[serde(default)] is the
other half: a persisted or hand-written snapshot predating this field
still reads back.
Test: model::tests::session_without_result_deserialises_and_omits_it,
model::tests::session_round_trips_with_a_result.
no_delegate: bool(#8184) Whether this session runs the SOLO agent — the #8031
single-agent shape, where the named agent carries its own tcode tools
and delegate_to_agent is never registered.
Why: an interactive tcode tui session has to read and edit files
itself (Claude Code’s basic loop), and the delegating PM registry has
no filesystem tools at all. The choice belongs to the SESSION rather
than to each task.run, so every turn of one conversation runs the
same agent shape and session.status/session.list can state which.
What: set once, at creation (SessionRegistry::create_with_delegation)
— session.create defaults it to true, task.run’s own mint path
carries that call’s no_delegate through. #[serde(default)] reads an
older serialized Session back as delegating, the pre-#8184 shape.
Test: session::protocol::tests::create_defaults_to_the_solo_agent,
session::protocol::tests::create_with_delegate_true_keeps_the_delegating_pm.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more