diff options
Diffstat (limited to 'makima/src/db/models.rs')
| -rw-r--r-- | makima/src/db/models.rs | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index d0a0bd6..9159fd5 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -531,6 +531,14 @@ pub struct Task { /// Standalone completed tasks can be dismissed by the user. #[serde(default)] pub hidden: bool, + + // Directive association + /// Directive this task belongs to (for directive-driven tasks) + #[serde(skip_serializing_if = "Option::is_none")] + pub directive_id: Option<Uuid>, + /// Directive step this task executes + #[serde(skip_serializing_if = "Option::is_none")] + pub directive_step_id: Option<Uuid>, } impl Task { @@ -656,6 +664,10 @@ pub struct CreateTaskRequest { /// Task ID whose worktree this task shares. When set, this task reuses the supervisor's /// worktree instead of creating its own, and should NOT have its worktree deleted during cleanup. pub supervisor_worktree_task_id: Option<Uuid>, + /// Directive this task belongs to (for directive-driven tasks) + pub directive_id: Option<Uuid>, + /// Directive step this task executes + pub directive_step_id: Option<Uuid>, } /// Request payload for updating a task @@ -2682,3 +2694,142 @@ mod tests { } // ============================================================================= +// Directive Types +// ============================================================================= + +/// A directive — a long-lived top-level entity for managing projects via a DAG of steps. +#[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct Directive { + pub id: Uuid, + pub owner_id: Uuid, + pub title: String, + pub goal: String, + /// Status: draft, active, idle, paused, archived + pub status: String, + pub repository_url: Option<String>, + pub local_path: Option<String>, + pub base_branch: Option<String>, + pub orchestrator_task_id: Option<Uuid>, + pub goal_updated_at: DateTime<Utc>, + pub started_at: Option<DateTime<Utc>>, + pub version: i32, + pub created_at: DateTime<Utc>, + pub updated_at: DateTime<Utc>, +} + +/// A step in a directive's DAG. +#[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct DirectiveStep { + pub id: Uuid, + pub directive_id: Uuid, + pub name: String, + pub description: Option<String>, + pub task_plan: Option<String>, + pub depends_on: Vec<Uuid>, + /// Status: pending, ready, running, completed, failed, skipped + pub status: String, + pub task_id: Option<Uuid>, + pub order_index: i32, + pub generation: i32, + pub started_at: Option<DateTime<Utc>>, + pub completed_at: Option<DateTime<Utc>>, + pub created_at: DateTime<Utc>, +} + +/// Directive with its steps for detail view. +#[derive(Debug, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct DirectiveWithSteps { + #[serde(flatten)] + pub directive: Directive, + pub steps: Vec<DirectiveStep>, +} + +/// Summary for directive list views. +#[derive(Debug, Clone, FromRow, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct DirectiveSummary { + pub id: Uuid, + pub owner_id: Uuid, + pub title: String, + pub goal: String, + pub status: String, + pub repository_url: Option<String>, + pub orchestrator_task_id: Option<Uuid>, + pub version: i32, + pub created_at: DateTime<Utc>, + pub updated_at: DateTime<Utc>, + pub total_steps: i64, + pub completed_steps: i64, + pub running_steps: i64, + pub failed_steps: i64, +} + +/// List response for directives. +#[derive(Debug, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct DirectiveListResponse { + pub directives: Vec<DirectiveSummary>, + pub total: i64, +} + +/// Request to create a new directive. +#[derive(Debug, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct CreateDirectiveRequest { + pub title: String, + pub goal: String, + pub repository_url: Option<String>, + pub local_path: Option<String>, + pub base_branch: Option<String>, +} + +/// Request to update a directive. +#[derive(Debug, Default, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct UpdateDirectiveRequest { + pub title: Option<String>, + pub goal: Option<String>, + pub status: Option<String>, + pub repository_url: Option<String>, + pub local_path: Option<String>, + pub base_branch: Option<String>, + pub orchestrator_task_id: Option<Uuid>, + pub version: Option<i32>, +} + +/// Request to update a directive's goal (triggers re-planning). +#[derive(Debug, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct UpdateGoalRequest { + pub goal: String, +} + +/// Request to create a directive step. +#[derive(Debug, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct CreateDirectiveStepRequest { + pub name: String, + pub description: Option<String>, + pub task_plan: Option<String>, + #[serde(default)] + pub depends_on: Vec<Uuid>, + #[serde(default)] + pub order_index: i32, + pub generation: Option<i32>, +} + +/// Request to update a directive step. +#[derive(Debug, Default, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct UpdateDirectiveStepRequest { + pub name: Option<String>, + pub description: Option<String>, + pub task_plan: Option<String>, + pub depends_on: Option<Vec<Uuid>>, + pub status: Option<String>, + pub task_id: Option<Uuid>, + pub order_index: Option<i32>, +} |
