diff options
| author | soryu <soryu@soryu.co> | 2026-02-03 23:49:08 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-03 23:49:19 +0000 |
| commit | c732dd048128808cd9f67f6e1176a5b565df5678 (patch) | |
| tree | 6ebf359c9c3f2d8aca264c53da6367b7f0af5fc8 /makima/migrations/20260203100000_chain_definitions.sql | |
| parent | 9ebc9724afcc0482a8e7cd2369c06208fedbcbd1 (diff) | |
| download | soryu-c732dd048128808cd9f67f6e1176a5b565df5678.tar.gz soryu-c732dd048128808cd9f67f6e1176a5b565df5678.zip | |
Allow chain creation via web interface
Diffstat (limited to 'makima/migrations/20260203100000_chain_definitions.sql')
| -rw-r--r-- | makima/migrations/20260203100000_chain_definitions.sql | 32 |
1 files changed, 32 insertions, 0 deletions
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; |
