From c732dd048128808cd9f67f6e1176a5b565df5678 Mon Sep 17 00:00:00 2001 From: soryu Date: Tue, 3 Feb 2026 23:49:08 +0000 Subject: Allow chain creation via web interface --- .../20260203100000_chain_definitions.sql | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 makima/migrations/20260203100000_chain_definitions.sql (limited to 'makima/migrations') diff --git a/makima/migrations/20260203100000_chain_definitions.sql b/makima/migrations/20260203100000_chain_definitions.sql new file mode 100644 index 0000000..9b47279 --- /dev/null +++ b/makima/migrations/20260203100000_chain_definitions.sql @@ -0,0 +1,32 @@ +-- Chain contract definitions - stores contract specs before actual contracts are created +-- This enables on-demand contract creation when dependencies are met +CREATE TABLE IF NOT EXISTS chain_contract_definitions ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + chain_id UUID NOT NULL REFERENCES chains(id) ON DELETE CASCADE, + name VARCHAR(255) NOT NULL, + description TEXT, + contract_type VARCHAR(32) NOT NULL DEFAULT 'simple', -- simple/specification/execute + initial_phase VARCHAR(32) DEFAULT 'plan', + -- Dependencies by name (resolved to IDs when contract is created) + depends_on_names TEXT[] DEFAULT '{}', + -- Task definitions as JSON array: [{name, plan}, ...] + tasks JSONB DEFAULT '[]', + -- Deliverable definitions as JSON array: [{id, name, priority}, ...] + deliverables JSONB DEFAULT '[]', + -- Position for GUI editor + editor_x FLOAT DEFAULT 0, + editor_y FLOAT DEFAULT 0, + -- Order for display/processing + order_index INTEGER NOT NULL DEFAULT 0, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX idx_chain_contract_definitions_chain_id ON chain_contract_definitions(chain_id); + +-- Add supervisor and retry control to chains +ALTER TABLE chains ADD COLUMN IF NOT EXISTS supervisor_task_id UUID REFERENCES tasks(id) ON DELETE SET NULL; +ALTER TABLE chains ADD COLUMN IF NOT EXISTS max_retries INTEGER NOT NULL DEFAULT 3; + +-- Add definition link and retry tracking to chain_contracts +ALTER TABLE chain_contracts ADD COLUMN IF NOT EXISTS definition_id UUID REFERENCES chain_contract_definitions(id) ON DELETE SET NULL; +ALTER TABLE chain_contracts ADD COLUMN IF NOT EXISTS retry_count INTEGER NOT NULL DEFAULT 0; -- cgit v1.2.3