Skip to main content

rightkit_agent_engine_protocol/
task.rs

1use serde::{Deserialize, Serialize};
2
3/// The state of a task in the DAG.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub enum TaskState {
7    /// Not yet done — work hasn't started, or evidence is stale.
8    Open,
9    /// Some weighted DoneWhen predicates are satisfied, but not all.
10    InProgress,
11    /// Blocked because at least one dependency task is not Done.
12    Blocked,
13    /// DoneWhen predicate holds AND all deps are Done.
14    Done,
15    /// The task failed and requires repair or replanning.
16    Failed,
17    /// The task was explicitly stopped by its owner.
18    Cancelled,
19    /// The task has been escalated to another role or human.
20    Escalated,
21    /// The task has been decomposed into child tasks.
22    Split,
23    /// The task has been merged into another task.
24    Merged,
25}
26
27/// A predicate that must hold for the task to be considered done.
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(rename_all = "camelCase")]
30pub struct DoneWhenPredicate {
31    pub predicate: String,
32    pub weight: f64,
33}
34
35/// The result of evaluating a completion predicate.
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub struct CompletionPredicateResult {
39    pub predicate: String,
40    pub weight: f64,
41    pub satisfied: bool,
42}
43
44/// A single node in the task DAG.
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(rename_all = "camelCase")]
47pub struct TaskNode {
48    pub id: String,
49    pub title: String,
50    /// Ids of tasks that must be Done before this task can transition to Done.
51    #[serde(default)]
52    pub deps: Vec<String>,
53    /// Opaque predicate string interpreted by the evaluator.
54    pub done_when: String,
55    #[serde(default)]
56    pub done_when_predicates: Vec<DoneWhenPredicate>,
57    /// Current computed state.
58    pub state: TaskState,
59    #[serde(default)]
60    pub category: String,
61    #[serde(default)]
62    pub estimated_duration: String,
63    #[serde(default)]
64    pub assigned_role: String,
65    #[serde(default)]
66    pub escalation_path: String,
67    #[serde(default)]
68    pub open_questions: Vec<String>,
69    pub created_at: String,
70    pub updated_at: String,
71}