diff options
| author | soryu <soryu@soryu.co> | 2026-02-03 23:49:08 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-03 23:49:19 +0000 |
| commit | c732dd048128808cd9f67f6e1176a5b565df5678 (patch) | |
| tree | 6ebf359c9c3f2d8aca264c53da6367b7f0af5fc8 /makima/src/db/models.rs | |
| parent | 9ebc9724afcc0482a8e7cd2369c06208fedbcbd1 (diff) | |
| download | soryu-c732dd048128808cd9f67f6e1176a5b565df5678.tar.gz soryu-c732dd048128808cd9f67f6e1176a5b565df5678.zip | |
Allow chain creation via web interface
Diffstat (limited to 'makima/src/db/models.rs')
| -rw-r--r-- | makima/src/db/models.rs | 107 |
1 files changed, 106 insertions, 1 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index 45ddb52..eeb30e4 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -2767,7 +2767,7 @@ pub struct ChainGraphNode { } /// Edge in chain DAG graph -#[derive(Debug, Serialize, ToSchema)] +#[derive(Debug, Clone, Serialize, ToSchema)] #[serde(rename_all = "camelCase")] pub struct ChainGraphEdge { pub from: Uuid, @@ -2942,6 +2942,111 @@ pub struct ChainEditorEdge { } // ============================================================================= +// Chain Contract Definitions (stored specs for on-demand contract creation) +// ============================================================================= + +/// Contract definition within a chain - stored spec before actual contract is created +#[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct ChainContractDefinition { + pub id: Uuid, + pub chain_id: Uuid, + pub name: String, + pub description: Option<String>, + pub contract_type: String, + pub initial_phase: Option<String>, + /// Names of other definitions this depends on + #[sqlx(default)] + pub depends_on_names: Vec<String>, + /// Task definitions as JSON: [{name, plan}, ...] + pub tasks: Option<serde_json::Value>, + /// Deliverable definitions as JSON: [{id, name, priority}, ...] + pub deliverables: Option<serde_json::Value>, + /// Position in GUI editor + pub editor_x: Option<f64>, + pub editor_y: Option<f64>, + pub order_index: i32, + pub created_at: DateTime<Utc>, +} + +/// Request to add a contract definition to a chain +#[derive(Debug, Clone, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct AddContractDefinitionRequest { + pub name: String, + pub description: Option<String>, + #[serde(default = "default_contract_type")] + pub contract_type: String, + pub initial_phase: Option<String>, + /// Names of other definitions this depends on + pub depends_on: Option<Vec<String>>, + /// Task definitions + pub tasks: Option<Vec<CreateChainTaskRequest>>, + /// Deliverable definitions + pub deliverables: Option<Vec<CreateChainDeliverableRequest>>, + /// Position in GUI editor + pub editor_x: Option<f64>, + pub editor_y: Option<f64>, +} + +fn default_contract_type() -> String { + "simple".to_string() +} + +/// Request to update a contract definition +#[derive(Debug, Clone, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct UpdateContractDefinitionRequest { + pub name: Option<String>, + pub description: Option<String>, + pub contract_type: Option<String>, + pub initial_phase: Option<String>, + pub depends_on: Option<Vec<String>>, + pub tasks: Option<Vec<CreateChainTaskRequest>>, + pub deliverables: Option<Vec<CreateChainDeliverableRequest>>, + pub editor_x: Option<f64>, + pub editor_y: Option<f64>, +} + +/// Response when starting a chain +#[derive(Debug, Clone, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct StartChainResponse { + pub chain_id: Uuid, + pub supervisor_task_id: Option<Uuid>, + /// Root contracts created (those with no dependencies) + pub contracts_created: Vec<Uuid>, + pub status: String, +} + +/// Graph node for definitions (before contracts are created) +#[derive(Debug, Clone, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct ChainDefinitionGraphNode { + pub id: Uuid, + pub name: String, + pub contract_type: String, + pub x: f64, + pub y: f64, + /// Whether this definition has been instantiated as a contract + pub is_instantiated: bool, + /// The contract ID if instantiated + pub contract_id: Option<Uuid>, + pub contract_status: Option<String>, +} + +/// Graph response for definitions +#[derive(Debug, Clone, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct ChainDefinitionGraphResponse { + pub chain_id: Uuid, + pub chain_name: String, + pub chain_status: String, + pub nodes: Vec<ChainDefinitionGraphNode>, + pub edges: Vec<ChainGraphEdge>, +} + +// ============================================================================= // Unit Tests // ============================================================================= |
