461 lines
14 KiB
Rust
461 lines
14 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::fmt;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ToDoMode {
|
|
Discussion,
|
|
Finalized,
|
|
}
|
|
|
|
impl Default for ToDoMode {
|
|
fn default() -> Self {
|
|
ToDoMode::Discussion
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for ToDoMode {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
ToDoMode::Discussion => write!(f, "discussion"),
|
|
ToDoMode::Finalized => write!(f, "finalized"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for ToDoMode {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"discussion" => Ok(ToDoMode::Discussion),
|
|
"finalized" => Ok(ToDoMode::Finalized),
|
|
_ => Err(format!("unknown mode: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ToDoStatus {
|
|
Pending,
|
|
InProgress,
|
|
Completed,
|
|
Blocked,
|
|
ReadyForAgent,
|
|
Delegated,
|
|
Failed,
|
|
PendingApproval,
|
|
Draft,
|
|
/// Agent succeeded and reported mutations; awaiting mutation review/approval.
|
|
ChangesPending,
|
|
/// Mutations have been approved; awaiting application and validation.
|
|
ChangesApproved,
|
|
}
|
|
|
|
impl Default for ToDoStatus {
|
|
fn default() -> Self {
|
|
ToDoStatus::Pending
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for ToDoStatus {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
ToDoStatus::Pending => write!(f, "pending"),
|
|
ToDoStatus::InProgress => write!(f, "in_progress"),
|
|
ToDoStatus::Completed => write!(f, "completed"),
|
|
ToDoStatus::Blocked => write!(f, "blocked"),
|
|
ToDoStatus::ReadyForAgent => write!(f, "ready_for_agent"),
|
|
ToDoStatus::Delegated => write!(f, "delegated"),
|
|
ToDoStatus::Failed => write!(f, "failed"),
|
|
ToDoStatus::Draft => write!(f, "draft"),
|
|
ToDoStatus::PendingApproval => write!(f, "pending_approval"),
|
|
ToDoStatus::ChangesPending => write!(f, "changes_pending"),
|
|
ToDoStatus::ChangesApproved => write!(f, "changes_approved"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for ToDoStatus {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"pending" => Ok(ToDoStatus::Pending),
|
|
"in_progress" => Ok(ToDoStatus::InProgress),
|
|
"completed" => Ok(ToDoStatus::Completed),
|
|
"blocked" => Ok(ToDoStatus::Blocked),
|
|
"ready_for_agent" => Ok(ToDoStatus::ReadyForAgent),
|
|
"delegated" => Ok(ToDoStatus::Delegated),
|
|
"failed" => Ok(ToDoStatus::Failed),
|
|
"draft" => Ok(ToDoStatus::Draft),
|
|
"pending_approval" => Ok(ToDoStatus::PendingApproval),
|
|
"changes_pending" => Ok(ToDoStatus::ChangesPending),
|
|
"changes_approved" => Ok(ToDoStatus::ChangesApproved),
|
|
_ => Err(format!("unknown status: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum TaskStatus {
|
|
Pending,
|
|
Running,
|
|
Completed,
|
|
Failed,
|
|
}
|
|
|
|
impl Default for TaskStatus {
|
|
fn default() -> Self {
|
|
TaskStatus::Pending
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for TaskStatus {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
TaskStatus::Pending => write!(f, "pending"),
|
|
TaskStatus::Running => write!(f, "running"),
|
|
TaskStatus::Completed => write!(f, "completed"),
|
|
TaskStatus::Failed => write!(f, "failed"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for TaskStatus {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"pending" => Ok(TaskStatus::Pending),
|
|
"running" => Ok(TaskStatus::Running),
|
|
"completed" => Ok(TaskStatus::Completed),
|
|
"failed" => Ok(TaskStatus::Failed),
|
|
_ => Err(format!("unknown status: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum ModelType {
|
|
Llm,
|
|
CodeGen,
|
|
Vision,
|
|
Audio,
|
|
Text,
|
|
Embedding,
|
|
}
|
|
|
|
impl fmt::Display for ModelType {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
ModelType::Llm => write!(f, "llm"),
|
|
ModelType::CodeGen => write!(f, "codegen"),
|
|
ModelType::Vision => write!(f, "vision"),
|
|
ModelType::Audio => write!(f, "audio"),
|
|
ModelType::Text => write!(f, "text"),
|
|
ModelType::Embedding => write!(f, "embedding"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for ModelType {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"llm" => Ok(ModelType::Llm),
|
|
"codegen" => Ok(ModelType::CodeGen),
|
|
"vision" => Ok(ModelType::Vision),
|
|
"audio" => Ok(ModelType::Audio),
|
|
"text" => Ok(ModelType::Text),
|
|
"embedding" => Ok(ModelType::Embedding),
|
|
_ => Err(format!("unknown model type: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum DocType {
|
|
ApiDoc,
|
|
Readme,
|
|
CodeComment,
|
|
Architecture,
|
|
Other(String),
|
|
}
|
|
|
|
impl fmt::Display for DocType {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
DocType::ApiDoc => write!(f, "api_doc"),
|
|
DocType::Readme => write!(f, "readme"),
|
|
DocType::CodeComment => write!(f, "code_comment"),
|
|
DocType::Architecture => write!(f, "architecture"),
|
|
DocType::Other(s) => write!(f, "other:{}", s),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum PromptType {
|
|
Authority,
|
|
Confirm,
|
|
Select,
|
|
}
|
|
|
|
impl fmt::Display for PromptType {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
PromptType::Authority => write!(f, "authority"),
|
|
PromptType::Confirm => write!(f, "confirm"),
|
|
PromptType::Select => write!(f, "select"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum PromptOption {
|
|
Accept,
|
|
Deny,
|
|
AcceptAlways,
|
|
Forbid,
|
|
Yes,
|
|
No,
|
|
OptionA,
|
|
OptionB,
|
|
OptionC,
|
|
}
|
|
|
|
impl fmt::Display for PromptOption {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
PromptOption::Accept => write!(f, "accept"),
|
|
PromptOption::Deny => write!(f, "deny"),
|
|
PromptOption::AcceptAlways => write!(f, "accept_always"),
|
|
PromptOption::Forbid => write!(f, "forbid"),
|
|
PromptOption::Yes => write!(f, "yes"),
|
|
PromptOption::No => write!(f, "no"),
|
|
PromptOption::OptionA => write!(f, "option_a"),
|
|
PromptOption::OptionB => write!(f, "option_b"),
|
|
PromptOption::OptionC => write!(f, "option_c"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum TaskResultType {
|
|
Success,
|
|
Error,
|
|
Split,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ToDoSource {
|
|
User,
|
|
Planner,
|
|
Automation,
|
|
Delegation,
|
|
}
|
|
|
|
impl Default for ToDoSource {
|
|
fn default() -> Self {
|
|
ToDoSource::User
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for ToDoSource {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
ToDoSource::User => write!(f, "user"),
|
|
ToDoSource::Planner => write!(f, "planner"),
|
|
ToDoSource::Automation => write!(f, "automation"),
|
|
ToDoSource::Delegation => write!(f, "delegation"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for ToDoSource {
|
|
type Err = String;
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"user" => Ok(ToDoSource::User),
|
|
"planner" => Ok(ToDoSource::Planner),
|
|
"automation" => Ok(ToDoSource::Automation),
|
|
"delegation" => Ok(ToDoSource::Delegation),
|
|
_ => Err(format!("unknown todo source: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ExecutionKind {
|
|
Manual,
|
|
Planner,
|
|
Build,
|
|
TestEvaluation,
|
|
TestImplementation,
|
|
Documentation,
|
|
Explore,
|
|
}
|
|
|
|
impl Default for ExecutionKind {
|
|
fn default() -> Self {
|
|
ExecutionKind::Manual
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for ExecutionKind {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
ExecutionKind::Manual => write!(f, "manual"),
|
|
ExecutionKind::Planner => write!(f, "planner"),
|
|
ExecutionKind::Build => write!(f, "build"),
|
|
ExecutionKind::TestEvaluation => write!(f, "test_evaluation"),
|
|
ExecutionKind::TestImplementation => write!(f, "test_implementation"),
|
|
ExecutionKind::Documentation => write!(f, "documentation"),
|
|
ExecutionKind::Explore => write!(f, "explore"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for ExecutionKind {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"manual" => Ok(ExecutionKind::Manual),
|
|
"planner" => Ok(ExecutionKind::Planner),
|
|
"build" => Ok(ExecutionKind::Build),
|
|
"test_evaluation" => Ok(ExecutionKind::TestEvaluation),
|
|
"test_implementation" => Ok(ExecutionKind::TestImplementation),
|
|
"documentation" => Ok(ExecutionKind::Documentation),
|
|
"explore" => Ok(ExecutionKind::Explore),
|
|
_ => Err(format!("unknown execution kind: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Lifecycle stage of a mutation set reported by an agent.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum MutationLifecycle {
|
|
/// Agent generated mutations but they have not yet been staged for review.
|
|
Generated,
|
|
/// Mutations are staged and ready for human or agent-flow review.
|
|
Staged,
|
|
/// Mutations have been reviewed (may follow with approve/reject).
|
|
Reviewed,
|
|
/// Mutations have been approved for application.
|
|
Approved,
|
|
/// Mutations have been applied to the working tree.
|
|
Applied,
|
|
/// Applied mutations have passed validation (tests, checks).
|
|
Validated,
|
|
/// Mutations have been committed.
|
|
Committed,
|
|
/// Mutations were rejected.
|
|
Rejected,
|
|
}
|
|
|
|
impl Default for MutationLifecycle {
|
|
fn default() -> Self {
|
|
MutationLifecycle::Generated
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for MutationLifecycle {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
MutationLifecycle::Generated => write!(f, "generated"),
|
|
MutationLifecycle::Staged => write!(f, "staged"),
|
|
MutationLifecycle::Reviewed => write!(f, "reviewed"),
|
|
MutationLifecycle::Approved => write!(f, "approved"),
|
|
MutationLifecycle::Applied => write!(f, "applied"),
|
|
MutationLifecycle::Validated => write!(f, "validated"),
|
|
MutationLifecycle::Committed => write!(f, "committed"),
|
|
MutationLifecycle::Rejected => write!(f, "rejected"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for MutationLifecycle {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"generated" => Ok(MutationLifecycle::Generated),
|
|
"staged" => Ok(MutationLifecycle::Staged),
|
|
"reviewed" => Ok(MutationLifecycle::Reviewed),
|
|
"approved" => Ok(MutationLifecycle::Approved),
|
|
"applied" => Ok(MutationLifecycle::Applied),
|
|
"validated" => Ok(MutationLifecycle::Validated),
|
|
"committed" => Ok(MutationLifecycle::Committed),
|
|
"rejected" => Ok(MutationLifecycle::Rejected),
|
|
_ => Err(format!("unknown mutation lifecycle: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Controls how task completion depends on mutation lifecycle.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum CompletionPolicy {
|
|
/// Mutations are auto-applied without review; task completes after validation.
|
|
AutoApply,
|
|
/// Mutations require human/agent-flow approval before application.
|
|
ApprovalRequired,
|
|
/// Mutations are recorded but never applied (sandbox-only).
|
|
DryRun,
|
|
/// No mutations expected; task completes when agent succeeds.
|
|
DocumentationOnly,
|
|
}
|
|
|
|
impl Default for CompletionPolicy {
|
|
fn default() -> Self {
|
|
CompletionPolicy::ApprovalRequired
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for CompletionPolicy {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
CompletionPolicy::AutoApply => write!(f, "auto_apply"),
|
|
CompletionPolicy::ApprovalRequired => write!(f, "approval_required"),
|
|
CompletionPolicy::DryRun => write!(f, "dry_run"),
|
|
CompletionPolicy::DocumentationOnly => write!(f, "documentation_only"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::str::FromStr for CompletionPolicy {
|
|
type Err = String;
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
match s {
|
|
"auto_apply" => Ok(CompletionPolicy::AutoApply),
|
|
"approval_required" => Ok(CompletionPolicy::ApprovalRequired),
|
|
"dry_run" => Ok(CompletionPolicy::DryRun),
|
|
"documentation_only" => Ok(CompletionPolicy::DocumentationOnly),
|
|
_ => Err(format!("unknown completion policy: {}", s)),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum TestStrategy {
|
|
Unit,
|
|
Integration,
|
|
E2e,
|
|
Property,
|
|
Manual,
|
|
}
|
|
|
|
impl std::fmt::Display for TestStrategy {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
TestStrategy::Unit => write!(f, "unit"),
|
|
TestStrategy::Integration => write!(f, "integration"),
|
|
TestStrategy::E2e => write!(f, "e2e"),
|
|
TestStrategy::Property => write!(f, "property"),
|
|
TestStrategy::Manual => write!(f, "manual"),
|
|
}
|
|
}
|
|
}
|