pub struct TaskState {
pub goal: String,
pub criteria: Vec<String>,
pub plan: Vec<PlanStep>,
pub current_step: Option<usize>,
pub progress: String,
pub scratchpad: String,
pub blocked_on: Vec<String>,
pub directives: Vec<String>,
pub preserved_refs: Vec<String>,
pub recent_actions: Vec<String>,
pub compression_log: Vec<CompressionEntry>,
}Expand description
Persistent task state that lives in the working partition.
Survives compression, renewal, and wake/resume cycles because the working
partition is compressible = false.
Fields§
§goal: StringPrimary objective for this run. Set at run_started, immutable thereafter.
criteria: Vec<String>Acceptance criteria copied from RunStarted.
plan: Vec<PlanStep>Ordered plan steps.
current_step: Option<usize>Index of the step currently executing (0-based). None before planning.
progress: StringFree-text progress note updated after each significant action.
scratchpad: StringEphemeral scratch space for model use. Cleared on renewal. NOT used by the compression pipeline (use compression_log instead).
blocked_on: Vec<String>Reasons the current step cannot proceed.
directives: Vec<String>Durable user directives / standing constraints (e.g. mid-task corrections, “don’t do X”).
Promoted here from the ephemeral signal channel so they survive compression AND renewal
like the goal does — without this, the most recent user command loses salience exactly at
the compaction/renewal boundaries between consecutive contexts (the “goal drift” failure).
Bounded + recency-ordered (oldest dropped past MAX_DIRECTIVES); newest last.
preserved_refs: Vec<String>Call IDs or artifact hashes that must be preserved from compression.
recent_actions: Vec<String>Rolling log of recent task activity — one entry per turn, each a compact summary of that
turn’s tool calls (e.g. “module_read, module_list”). Kernel-maintained from REAL tool
activity (not model-curated), so the State turn always shows forward motion even when the
model never maintains plan. Lives in the volatile State turn (out of the cacheable prefix),
so updating it never churns the prompt cache. Bounded + recency-ordered; newest last.
compression_log: Vec<CompressionEntry>Append-only log of all compression events. Never overwritten. Rendered into systemVolatile so the model always sees compression history.
Implementations§
Source§impl TaskState
impl TaskState
Sourcepub fn format_compact(&self) -> String
pub fn format_compact(&self) -> String
Compact text block for embedding in system_text.
Returns an empty string when the task has not been initialised.
Sourcepub fn record_directive(&mut self, text: impl Into<String>)
pub fn record_directive(&mut self, text: impl Into<String>)
Record a durable user directive (deduped against the most recent, recency-capped at
MAX_DIRECTIVES). Newest is appended last; the oldest is dropped past the cap so the
channel stays bounded across a long session.
Sourcepub fn note_actions(&mut self, summary: impl Into<String>)
pub fn note_actions(&mut self, summary: impl Into<String>)
Record one turn’s tool activity into the recency log (kernel-driven). summary is a compact
string of the turn’s task tool names; blank input is ignored. Bounded at
MAX_RECENT_ACTIONS (oldest dropped past the cap).
Sourcepub fn log_compression(&mut self, action: &str, summary: String)
pub fn log_compression(&mut self, action: &str, summary: String)
Append a compression event to the log. Never overwrites existing entries.
pub fn apply(&mut self, update: TaskUpdate)
Sourcepub fn open_steps(&self) -> Vec<String>
pub fn open_steps(&self) -> Vec<String>
Open steps (not yet done), for renewal handoff.