Expand description
Coder session state machine, event stream, and persistence.
A session moves Created → ContractProposed → ContractConfirmed → Running → NeedsApproval → Merged, with Failed/Abandoned as the other terminal
states. Every transition is validated, emitted as a CoderEvent, audited
to the event log, and snapshotted as JSON under the state dir so a daemon
restart can at least report orphaned sessions (full resume is out of scope).
Structs§
- Agent
Build Progress - Live progress for an Agent-project build.
- Coder
Event - One event in a session’s stream.
seqis monotonically increasing per session so clients can resume from a cursor after reconnect. - Coder
Session - A coding session. Serializes to the JSON snapshot persisted on every
transition; the live worktree handle is process-only (
#[serde(skip)]). - Event
Sink - Per-session event fanout + audit. Emits to the registered emitter (WS subscribers) and journals the audit-relevant subset to a JSONL event log.
- Integrated
Subtask - One subtask whose patch reached the session worktree, and the files it wrote.
- NoChange
Finding - A nominated (or accepted) “no code should change” conclusion.
- NoChange
Nomination - What the model actually said when it called
report_no_change. - Session
Retention - Retention policy for the coder state dir, from
~/.car/coder.toml. - User
Input Gate - Mid-session user-input rendezvous.
Enums§
- Adoption
Outcome - What
adopt_orphaned_sessionsdecided about one on-disk snapshot. - Agent
Build Phase - The phase an Agent-project build is currently executing.
- Approval
Kind - Which gate a
NeedsApprovalsession is sitting on. - Coder
Event Kind - What happened. Serialized with
"type": "snake_case_name"for WS clients. - Coder
State - Session lifecycle states.
- Contract
Provenance - Where an outcome contract’s bytes came from.
- Needs
You - What a session is waiting on a human for, right now.
- NoChange
Kind - Why a session concluded no code should change.
- NoChange
Verification - What makes a
NoChangeKindverdict trustworthy. - Sweep
Scope - Delete session snapshots (and their journals) beyond the retention caps.
Functions§
- adopt_
orphaned_ sessions - Adopt crash/restart-orphaned coder sessions at daemon boot.
- can_
transition - Whether
from → tois a legal transition. Any non-terminal state may move toFailed(errors happen anywhere) orAbandoned(user cancel); terminal states never move. - default_
state_ dir coderunder the CAR state root (~/.car/coderunlessCAR_HOMEmoves the root) — session snapshots, event journals, and worktrees. This is only the default;CAR_CODER_STATE_DIRstill overrides it outright incoder_state_dir.- gc_
sessions - gc_
sessions_ with_ age_ floor gc_sessionswith a minimum age for every deletion candidate.- needs_
you_ from - Derive
NeedsYoufrom the three facts that decide it. Split out from the live registry so the table indocs/proposals/coder-board-wire-contract.md§1 is directly testable without a daemon.
Type Aliases§
- Cancel
Flag - Cooperative cancellation flag, checked between turns and checks.
- Event
Emitter - Callback receiving every
CoderEvent(WS fanout, CLI rendering, tests).