From a734bf1a472b19d63341769d26a66628575df7f4 Mon Sep 17 00:00:00 2001 From: soryu Date: Wed, 4 Feb 2026 01:07:14 +0000 Subject: Add chain checkpoint contracts --- makima/src/daemon/api/chain.rs | 26 +++++++++++++++ makima/src/daemon/cli/mod.rs | 14 ++++++++ makima/src/daemon/cli/supervisor.rs | 64 +++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) (limited to 'makima/src/daemon') diff --git a/makima/src/daemon/api/chain.rs b/makima/src/daemon/api/chain.rs index 7f7826f..c37c980 100644 --- a/makima/src/daemon/api/chain.rs +++ b/makima/src/daemon/api/chain.rs @@ -49,4 +49,30 @@ impl ApiClient { self.delete_with_response(&format!("/api/v1/chains/{}", chain_id)) .await } + + /// Start a chain (creates root contracts and optionally a supervisor). + pub async fn start_chain(&self, chain_id: Uuid) -> Result { + self.post_empty(&format!("/api/v1/chains/{}/start", chain_id)) + .await + } + + /// Start a chain with supervisor enabled. + pub async fn start_chain_with_supervisor( + &self, + chain_id: Uuid, + repository_url: Option<&str>, + ) -> Result { + #[derive(serde::Serialize)] + #[serde(rename_all = "camelCase")] + struct StartRequest<'a> { + with_supervisor: bool, + repository_url: Option<&'a str>, + } + let req = StartRequest { + with_supervisor: true, + repository_url, + }; + self.post(&format!("/api/v1/chains/{}/start", chain_id), &req) + .await + } } diff --git a/makima/src/daemon/cli/mod.rs b/makima/src/daemon/cli/mod.rs index 035a784..25163c2 100644 --- a/makima/src/daemon/cli/mod.rs +++ b/makima/src/daemon/cli/mod.rs @@ -170,6 +170,20 @@ pub enum SupervisorCommand { /// Mark a deliverable as complete MarkDeliverable(supervisor::MarkDeliverableArgs), + + // Chain supervisor commands (for chain-level orchestration) + + /// Get chain status with progress info + ChainStatus(supervisor::ChainStatusArgs), + + /// List contracts in the chain + ChainContracts(supervisor::ChainContractsArgs), + + /// Manually trigger chain progression + ChainProgress(supervisor::ChainProgressArgs), + + /// Get chain DAG visualization + ChainGraph(supervisor::ChainGraphArgs), } /// Contract subcommands for task-contract interaction. diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs index 6f19697..0b52c9c 100644 --- a/makima/src/daemon/cli/supervisor.rs +++ b/makima/src/daemon/cli/supervisor.rs @@ -445,3 +445,67 @@ pub struct ResumeContractArgs { #[arg(index = 1)] pub contract_id: Uuid, } + +// ============================================================================ +// Chain Supervisor Command Args +// ============================================================================ + +/// Common arguments for chain supervisor commands. +#[derive(Args, Debug, Clone)] +pub struct ChainSupervisorArgs { + /// API URL + #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp")] + pub api_url: String, + + /// API key for authentication + #[arg(long, env = "MAKIMA_API_KEY")] + pub api_key: String, + + /// Current task ID (the chain supervisor's own task ID) + #[arg(long, env = "MAKIMA_TASK_ID")] + pub self_task_id: Option, + + /// Chain ID + #[arg(long, env = "MAKIMA_CHAIN_ID")] + pub chain_id: Uuid, +} + +/// Arguments for chain-status command (get chain status with progress info). +#[derive(Args, Debug)] +pub struct ChainStatusArgs { + #[command(flatten)] + pub common: ChainSupervisorArgs, + + /// Include contract details + #[arg(long)] + pub verbose: bool, +} + +/// Arguments for chain-contracts command (list contracts in the chain). +#[derive(Args, Debug)] +pub struct ChainContractsArgs { + #[command(flatten)] + pub common: ChainSupervisorArgs, + + /// Filter by status (active, completed, failed) + #[arg(long)] + pub status: Option, +} + +/// Arguments for chain-progress command (manually trigger chain progression). +#[derive(Args, Debug)] +pub struct ChainProgressArgs { + #[command(flatten)] + pub common: ChainSupervisorArgs, +} + +/// Arguments for chain-graph command (get chain DAG visualization). +#[derive(Args, Debug)] +pub struct ChainGraphArgs { + #[command(flatten)] + pub common: ChainSupervisorArgs, + + /// Output format (ascii, json) + #[arg(long, default_value = "ascii")] + pub format: String, +} -- cgit v1.2.3