agentstategraph_tasks/
error.rs1use thiserror::Error;
4
5use crate::types::{TaskId, TaskStatus};
6
7#[derive(Debug, Error)]
8pub enum TaskStoreError {
9 #[error("plan not found: {0}")]
10 PlanNotFound(String),
11
12 #[error("summary required to close a plan")]
13 SummaryRequired,
14
15 #[error("cannot close plan '{plan}': {reason}")]
16 CannotClose { plan: String, reason: String },
17
18 #[error("plan already exists: {0}")]
19 PlanAlreadyExists(String),
20
21 #[error("task not found: {plan}/{id:?}")]
22 TaskNotFound { plan: String, id: TaskId },
23
24 #[error("invalid state transition: {from:?} -> {to:?}")]
25 InvalidTransition { from: TaskStatus, to: TaskStatus },
26
27 #[error("task is blocked by: {blockers:?}")]
28 Blocked { blockers: Vec<TaskId> },
29
30 #[error("task references blocker(s) that no longer exist in the plan: {blockers:?}")]
31 BlockerNotFound { blockers: Vec<TaskId> },
32
33 #[error("proof required for transition to done")]
34 ProofRequired,
35
36 #[error("parent task not found: {0:?}")]
37 ParentNotFound(TaskId),
38
39 #[error("parent task is itself a subtask (nesting limit is 2): {0:?}")]
40 ParentIsSubtask(TaskId),
41
42 #[error("reason required for abandonment")]
43 ReasonRequired,
44
45 #[error("a task's title must not be blank")]
46 TitleRequired,
47
48 #[error("notes are {len} bytes; a task's notes hold at most {max} bytes")]
49 NotesTooLong { len: usize, max: usize },
50
51 #[error("blockers would form a cycle, leaving these tasks blocked for good: {cycle:?}")]
52 BlockerCycle { cycle: Vec<TaskId> },
53
54 #[error("invalid task id format: {0}")]
55 InvalidTaskId(String),
56
57 #[error("invalid blocker id {0:?}: blocker ids must match ^t-\\d{{1,9}}$ (e.g. \"t-007\")")]
58 InvalidBlockerId(String),
59
60 #[error("write conflict: too many concurrent writers for this plan")]
61 WriteConflict,
62
63 #[error("repository error: {0}")]
64 Repo(String),
65
66 #[error("serialization error: {0}")]
67 Serde(#[from] serde_json::Error),
68}
69
70impl From<agentstategraph::RepoError> for TaskStoreError {
71 fn from(e: agentstategraph::RepoError) -> Self {
72 TaskStoreError::Repo(e.to_string())
73 }
74}