pub struct Unit {Show 42 fields
pub id: String,
pub title: String,
pub slug: Option<String>,
pub status: Status,
pub priority: u8,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub description: Option<String>,
pub acceptance: Option<String>,
pub notes: Option<String>,
pub design: Option<String>,
pub labels: Vec<String>,
pub assignee: Option<String>,
pub closed_at: Option<DateTime<Utc>>,
pub close_reason: Option<String>,
pub parent: Option<String>,
pub dependencies: Vec<String>,
pub verify: Option<String>,
pub fail_first: bool,
pub checkpoint: Option<String>,
pub attempts: u32,
pub max_attempts: u32,
pub claimed_by: Option<String>,
pub claimed_at: Option<DateTime<Utc>>,
pub is_archived: bool,
pub produces: Vec<String>,
pub requires: Vec<String>,
pub on_fail: Option<OnFailAction>,
pub on_close: Vec<OnCloseAction>,
pub history: Vec<RunRecord>,
pub outputs: Option<Value>,
pub max_loops: Option<u32>,
pub verify_timeout: Option<u64>,
pub unit_type: String,
pub last_verified: Option<DateTime<Utc>>,
pub stale_after: Option<DateTime<Utc>>,
pub paths: Vec<String>,
pub attempt_log: Vec<AttemptRecord>,
pub created_by: Option<String>,
pub feature: bool,
pub decisions: Vec<String>,
pub model: Option<String>,
}Expand description
A single unit of work managed by mana.
Units live on disk as Markdown files with YAML frontmatter.
All fields are serializable; optional fields are omitted from YAML
when None or empty to keep files readable.
Most callers should construct units via Unit::try_new and mutate
them through the high-level API functions in crate::api rather than
building them directly.
Fields§
§id: String§title: String§slug: Option<String>§status: Status§priority: u8§created_at: DateTime<Utc>§updated_at: DateTime<Utc>§description: Option<String>§acceptance: Option<String>§notes: Option<String>§design: Option<String>§labels: Vec<String>§assignee: Option<String>§closed_at: Option<DateTime<Utc>>§close_reason: Option<String>§parent: Option<String>§dependencies: Vec<String>§verify: Option<String>Shell command that must exit 0 to close the unit.
fail_first: boolWhether this unit was created with –fail-first (enforced TDD). Records that the verify command was proven to fail before creation.
checkpoint: Option<String>Git commit SHA recorded when verify was proven to fail at claim time. Proves the test was meaningful at the point work began.
attempts: u32How many times the verify command has been run.
max_attempts: u32Maximum verify attempts before escalation (default 3).
claimed_by: Option<String>Agent or user currently holding a claim on this unit.
claimed_at: Option<DateTime<Utc>>When the claim was acquired.
is_archived: boolWhether this unit has been moved to the archive.
produces: Vec<String>Artifacts this unit produces (types, functions, files). Used by decompose skill for dependency inference.
requires: Vec<String>Artifacts this unit requires from other units. Maps to dependencies via sibling produces.
on_fail: Option<OnFailAction>Declarative action to execute when verify fails.
on_close: Vec<OnCloseAction>Declarative actions to execute when this unit is closed. Runs after archive and post-close hook. Failures warn but don’t revert.
history: Vec<RunRecord>Structured history of verification runs.
outputs: Option<Value>Structured output from verify commands (arbitrary JSON).
max_loops: Option<u32>Maximum agent loops for this unit (overrides config default, 0 = unlimited).
verify_timeout: Option<u64>Timeout in seconds for the verify command (overrides config default). If the verify command exceeds this limit, it is killed and treated as failure.
unit_type: StringUnit type: ‘task’ (default) or ‘fact’ (verified knowledge).
last_verified: Option<DateTime<Utc>>Unix timestamp of last successful verify (for staleness detection).
stale_after: Option<DateTime<Utc>>When this fact becomes stale (created_at + TTL). Only meaningful for facts.
paths: Vec<String>File paths this unit is relevant to (for context relevance scoring).
attempt_log: Vec<AttemptRecord>Structured attempt tracking: [{num, outcome, notes}]. Tracks claim→close cycles for episodic memory.
created_by: Option<String>Identity of who created this unit (resolved from config/git/env).
feature: boolWhether this unit is a feature (product-level goal, human-only close).
decisions: Vec<String>Unresolved decisions that block autonomous execution. Each entry is a question that must be answered before an agent starts work. Empty list means no blocking decisions.
model: Option<String>Override model for this unit. Takes precedence over config-level model settings.
Used as {model} substitution in command templates.
Implementations§
Source§impl Unit
impl Unit
Sourcepub fn try_new(id: impl Into<String>, title: impl Into<String>) -> Result<Self>
pub fn try_new(id: impl Into<String>, title: impl Into<String>) -> Result<Self>
Create a new unit with sensible defaults. Returns an error if the ID is invalid.
Sourcepub fn new(id: impl Into<String>, title: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, title: impl Into<String>) -> Self
Create a new unit with sensible defaults.
Panics if the ID is invalid. Prefer try_new for fallible construction.
Sourcepub fn effective_max_loops(&self, config_max: u32) -> u32
pub fn effective_max_loops(&self, config_max: u32) -> u32
Get effective max_loops (per-unit override or config default). A value of 0 means unlimited.
Sourcepub fn effective_verify_timeout(
&self,
config_timeout: Option<u64>,
) -> Option<u64>
pub fn effective_verify_timeout( &self, config_timeout: Option<u64>, ) -> Option<u64>
Get effective verify_timeout: unit-level override, then config default, then None.
Sourcepub fn from_string(content: &str) -> Result<Self>
pub fn from_string(content: &str) -> Result<Self>
Parse a unit from a string (either YAML or Markdown with YAML frontmatter).
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Read a unit from a file (supports both YAML and Markdown with YAML frontmatter).
Sourcepub fn to_file(&self, path: impl AsRef<Path>) -> Result<()>
pub fn to_file(&self, path: impl AsRef<Path>) -> Result<()>
Write this unit to a file.
For .md files, writes markdown frontmatter format (YAML between --- delimiters
with description as the markdown body). For other extensions, writes pure YAML.
Sourcepub fn hash(&self) -> String
pub fn hash(&self) -> String
Calculate SHA256 hash of canonical form.
Used for optimistic locking. The hash is calculated from a canonical JSON representation with transient fields cleared.
Sourcepub fn from_file_with_hash(path: impl AsRef<Path>) -> Result<(Self, String)>
pub fn from_file_with_hash(path: impl AsRef<Path>) -> Result<(Self, String)>
Load unit with version hash for optimistic locking.
Returns the unit and its content hash as a tuple. The hash can be compared before saving to detect concurrent modifications.
Sourcepub fn apply_value(&mut self, field: &str, json_value: &str) -> Result<()>
pub fn apply_value(&mut self, field: &str, json_value: &str) -> Result<()>
Apply a JSON-serialized value to a field by name.
Used by conflict resolution to set a field to a chosen value.
The value should be JSON-serialized (e.g., "\"hello\"" for a string).
§Arguments
field- The field name to updatejson_value- JSON-serialized value to apply
§Returns
Ok(())on successErrif field is unknown or value cannot be deserialized