summaryrefslogtreecommitdiff
path: root/makima/src/daemon
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-31 22:53:28 +0000
committersoryu <soryu@soryu.co>2026-01-31 22:54:50 +0000
commit44bb3fe07ab191abd8260af6975bc175c223878e (patch)
tree1d7dd73756345f3671af32cc84b9b4235d34d173 /makima/src/daemon
parenta6e36a8bfecb9ebe6c7b135b9e01557f7ebc3e58 (diff)
downloadsoryu-44bb3fe07ab191abd8260af6975bc175c223878e.tar.gz
soryu-44bb3fe07ab191abd8260af6975bc175c223878e.zip
feat: Add contract management system improvements (Phase 1)makima/contract-management-improvements
- Add docs/contract-management-spec.md with full system design - Add docs/plans/implementation-plan.md with 5-phase rollout plan - Add validate_deliverable() function and use in mark_deliverable_complete - Add PhaseChangeResult enum and change_contract_phase_with_version() with FOR UPDATE locking - Enforce phase_guard at API level for all callers This addresses critical issues in contract management: - Deliverable validation to prevent marking non-existent deliverables complete - Version conflict detection for phase changes with row locking - Phase guard enforcement at API level (applies to all callers including supervisors) - Comprehensive specification and implementation plan for future phases
Diffstat (limited to 'makima/src/daemon')
-rw-r--r--makima/src/daemon/api/supervisor.rs21
-rw-r--r--makima/src/daemon/cli/supervisor.rs5
2 files changed, 26 insertions, 0 deletions
diff --git a/makima/src/daemon/api/supervisor.rs b/makima/src/daemon/api/supervisor.rs
index c841b21..c2da1db 100644
--- a/makima/src/daemon/api/supervisor.rs
+++ b/makima/src/daemon/api/supervisor.rs
@@ -233,22 +233,43 @@ impl ApiClient {
}
/// Advance contract to a new phase.
+ ///
+ /// When `confirmed` is false and phase_guard is enabled, returns a response with
+ /// `status: "pending_confirmation"` containing deliverables for user review.
+ /// When `confirmed` is true, proceeds with the phase transition.
pub async fn supervisor_advance_phase(
&self,
contract_id: Uuid,
phase: &str,
+ confirmed: bool,
) -> Result<JsonValue, ApiError> {
#[derive(Serialize)]
struct AdvancePhaseRequest {
phase: String,
+ confirmed: bool,
}
let req = AdvancePhaseRequest {
phase: phase.to_string(),
+ confirmed,
};
self.post(&format!("/api/v1/contracts/{}/phase", contract_id), &req)
.await
}
+ /// Request phase advancement without confirmation (for phase_guard check).
+ ///
+ /// This method calls `supervisor_advance_phase` with `confirmed=false`.
+ /// If phase_guard is enabled, the response will have `status: "pending_confirmation"`
+ /// and the caller should prompt the user for confirmation before calling again with
+ /// `confirmed=true`.
+ pub async fn supervisor_request_phase_advance(
+ &self,
+ contract_id: Uuid,
+ phase: &str,
+ ) -> Result<JsonValue, ApiError> {
+ self.supervisor_advance_phase(contract_id, phase, false).await
+ }
+
/// Get individual task details.
pub async fn supervisor_get_task(&self, task_id: Uuid) -> Result<JsonValue, ApiError> {
self.get(&format!("/api/v1/mesh/tasks/{}", task_id)).await
diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs
index 9ad7aef..cb84ffa 100644
--- a/makima/src/daemon/cli/supervisor.rs
+++ b/makima/src/daemon/cli/supervisor.rs
@@ -218,6 +218,11 @@ pub struct AdvancePhaseArgs {
/// The phase to advance to (specify, plan, execute, review)
#[arg(index = 1)]
pub phase: String,
+
+ /// Confirm the phase transition (required when phase_guard is enabled).
+ /// Without this flag, the command will return deliverables for review.
+ #[arg(long, short = 'y')]
+ pub confirmed: bool,
}
/// Arguments for mark-deliverable command.