From bd1f21fe387ec57da76c300cbb1ebc0db48553a7 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 8 May 2026 12:12:21 +0100 Subject: feat(contracts): lifecycle — Lock/Start/Pause/Complete/Unlock + queue scheduler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the contract lifecycle layer on top of the unified-contracts backbone (#128). State machine: draft → queued → active → shipped → archived At most one contract per directive sits in `active` at any time — the queue is serialised because each directive owns a single shared worktree. Repository helpers handle the transition checks AND auto-promote the next-up `queued` contract whenever the active slot frees (pause / complete / unlock-from-active / archive-from-active). Endpoints (all under /api/v1/contracts/{id}): POST /start draft → queued | active (depending on slot) POST /pause active → queued; promotes next queued POST /complete active → shipped; optional pr_url + pr_branch POST /unlock queued | active → draft; promotes if was active Frontend wiring: * `DirectiveContractStatus` now includes `queued`. * Migration adds `queued` to the CHECK constraint on directive_documents.status. * `ContractHeader` component renders breadcrumb + status pill + status-driven action buttons + a merge-mode (shared / own_pr) radio. Merge mode is editable only while draft / queued so a running flow's branch target can't change mid-stream. * RepositoryError gains a `Validation(String)` arm; the three existing exhaustive matches (files, mesh, versions) get a 400 BAD_REQUEST response for it. Drag-to-reorder UI deferred to a small follow-up — the backend endpoint already exists from the backbone PR. Co-Authored-By: Claude Opus 4.7 (1M context) --- makima/src/server/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'makima/src/server/mod.rs') diff --git a/makima/src/server/mod.rs b/makima/src/server/mod.rs index 68d3dea..a3a1886 100644 --- a/makima/src/server/mod.rs +++ b/makima/src/server/mod.rs @@ -241,6 +241,22 @@ pub fn make_router(state: SharedState) -> Router { "/contracts/{document_id}/reorder", post(directive_documents::reorder_contract), ) + .route( + "/contracts/{document_id}/start", + post(directive_documents::start_contract), + ) + .route( + "/contracts/{document_id}/pause", + post(directive_documents::pause_contract), + ) + .route( + "/contracts/{document_id}/complete", + post(directive_documents::complete_contract), + ) + .route( + "/contracts/{document_id}/unlock", + post(directive_documents::unlock_contract), + ) .route( "/contracts/{document_id}/tasks", get(directive_documents::list_document_tasks), -- cgit v1.2.3