From b5811ad26a94f48ddab45251e44861f5595a7b95 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 8 May 2026 11:29:20 +0100 Subject: feat(directives): unified contracts surface — backbone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the backbone PR for the unified directive workflow. A directive holds a sequence of contracts; each contract is a spec body whose execution drives tasks in the directive's shared worktree. Lifecycle (Lock & Start, queue scheduler, drag-reorder) lands in follow-ups. What's in this PR: - Migration adds `position` (queue order) and `merge_mode` (shared|own_pr) columns to directive_documents. The actual table rename is deferred — the legacy `contracts` table from the old contracts system still exists, and the rename collision waits for Phase 5 to drop legacy contracts. - Repository: list orders by position; create assigns next-position; update accepts merge_mode; new reorder_directive_document_position shifts siblings inside a transaction. - HTTP: endpoints aliased under /api/v1/directives/{id}/contracts and /api/v1/contracts/{id}/... with a new /contracts/{id}/reorder. - Frontend: api types renamed `DirectiveContract*` (avoiding the legacy `Contract` type collision); document-directives.tsx imports via aliases so the rest of the file is untouched. Internal struct + table names stay `DirectiveDocument` / `directive_documents` until the legacy contracts cleanup. Co-Authored-By: Claude Opus 4.7 (1M context) --- makima/src/server/mod.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'makima/src/server/mod.rs') diff --git a/makima/src/server/mod.rs b/makima/src/server/mod.rs index dd79ddf..68d3dea 100644 --- a/makima/src/server/mod.rs +++ b/makima/src/server/mod.rs @@ -214,27 +214,35 @@ pub fn make_router(state: SharedState) -> Router { ) .route("/directives/{id}/dogs/{dog_id}/orders", get(directives::list_dog_orders)) .route("/directives/{id}/dogs/{dog_id}/pick-up-orders", post(directives::pick_up_dog_orders)) - // Directive document endpoints (multi-document directive contracts). + // Contract endpoints (the unified directive contracts surface). + // The handler module + DB column names are still + // "directive_documents" for now — the user-facing names ("contract" + // in URLs / structs / UI) are aligned here while the deeper rename + // waits for legacy contracts removal (Phase 5). .route( - "/directives/{directive_id}/documents", + "/directives/{directive_id}/contracts", get(directive_documents::list_documents) .post(directive_documents::create_document), ) .route( - "/directive-documents/{document_id}", + "/contracts/{document_id}", get(directive_documents::get_document) .patch(directive_documents::update_document), ) .route( - "/directive-documents/{document_id}/ship", + "/contracts/{document_id}/ship", post(directive_documents::ship_document), ) .route( - "/directive-documents/{document_id}/archive", + "/contracts/{document_id}/archive", post(directive_documents::archive_document), ) .route( - "/directive-documents/{document_id}/tasks", + "/contracts/{document_id}/reorder", + post(directive_documents::reorder_contract), + ) + .route( + "/contracts/{document_id}/tasks", get(directive_documents::list_document_tasks), ) // Order endpoints -- cgit v1.2.3