Skip to main content

ag_protocol/
subtask.rs

1//! Orchestrator subtask model shared across protocol, coordinator, and UI
2//! code.
3
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7/// One proposed child session in an orchestrator decomposition plan.
8///
9/// Each subtask is executed unattended by its own child session in its own
10/// worktree, branched from the same base branch as its siblings. Children never
11/// coordinate with each other while running, so a subtask is only well-formed
12/// when its prompt is self-contained and its `touched_areas` do not overlap any
13/// sibling's.
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
15#[schemars(
16    title = "SubtaskItem",
17    description = "One proposed child session in an orchestrator decomposition plan. Each subtask \
18                   runs unattended in its own worktree branched from the same base branch, so it \
19                   must be completable without coordinating with its siblings."
20)]
21pub struct SubtaskItem {
22    /// Complete standalone prompt handed to the child session.
23    #[schemars(
24        title = "prompt",
25        description = "Complete standalone prompt for the child session. The child sees only this \
26                       prompt and the repository, so restate every constraint it needs instead of \
27                       referring back to the plan or to sibling subtasks."
28    )]
29    pub prompt: String,
30    /// Stable identifier for this subtask within one orchestration.
31    #[schemars(
32        title = "task_key",
33        description = "Short stable `kebab-case` identifier for this subtask, unique within the \
34                       plan. Reuse the exact same key when re-proposing a subtask so a retry \
35                       replaces the previous attempt instead of creating a duplicate."
36    )]
37    pub task_key: String,
38    /// Short human-readable subtask title.
39    #[schemars(
40        title = "title",
41        description = "Short human-readable title describing what this subtask delivers."
42    )]
43    pub title: String,
44    /// Literal repository-relative paths or directories this subtask expects
45    /// to change.
46    #[serde(default)]
47    #[schemars(
48        title = "touched_areas",
49        description = "Literal repository-relative file or directory paths this subtask expects \
50                       to modify. Wildcard patterns are not supported. These sets must not \
51                       overlap between subtasks in the same plan. Defaults to an empty list when \
52                       omitted, which is rejected as an unplanned subtask."
53    )]
54    pub touched_areas: Vec<String>,
55}