From e00be74c8b575c725829677aadeb755ee81454d0 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 8 May 2026 11:29:56 +0100 Subject: feat(directives): unified contracts surface — backbone (#128) 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/db/models.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'makima/src/db/models.rs') diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index 18f3435..fcccd05 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -2938,10 +2938,16 @@ pub struct UpdateDirectiveStepRequest { // Directive Document Types // ============================================================================= -/// A directive document — one of N markdown documents owned by a directive. -/// The user calls these "directive contracts". Each document has its own -/// lifecycle (draft → active → shipped → archived) and may be attached to a -/// PR. Multiple documents can be active under the same directive at once. +/// A directive document — the user-facing "contract" in the unified +/// directive UI. One of N specs owned by a directive. Each runs +/// sequentially in the directive's shared worktree (or, when +/// `merge_mode = 'own_pr'`, on its own branch). `position` defines +/// queue order. +/// +/// Naming note: this struct stays `DirectiveDocument` internally because +/// a legacy `Contract` struct (from the pre-directive contracts system) +/// still exists. The API and frontend expose this as "Contract"; the +/// table/struct rename lands once legacy contracts are dropped (Phase 5). #[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)] #[serde(rename_all = "camelCase")] pub struct DirectiveDocument { @@ -2956,6 +2962,12 @@ pub struct DirectiveDocument { pub shipped_at: Option>, pub archived_at: Option>, pub version: i32, + /// Queue position within the parent directive (0-indexed). Lower + /// numbers run earlier; only one contract is active at a time. + pub position: i32, + /// Where this contract's commits land. `shared` (default): the + /// directive's branch. `own_pr`: a contract-specific branch + PR. + pub merge_mode: String, pub created_at: DateTime, pub updated_at: DateTime, } -- cgit v1.2.3