-- Add autonomous_loop column to contracts table
-- When enabled, tasks for this contract will automatically restart with --continue
-- if they exit without a COMPLETION_GATE indicating ready: true.

ALTER TABLE contracts
ADD COLUMN IF NOT EXISTS autonomous_loop BOOLEAN NOT NULL DEFAULT FALSE;

-- Add autonomous_loop column to tasks table for per-task override
ALTER TABLE tasks
ADD COLUMN IF NOT EXISTS autonomous_loop BOOLEAN NOT NULL DEFAULT FALSE;

COMMENT ON COLUMN contracts.autonomous_loop IS 'Whether tasks for this contract should run in autonomous loop mode';
COMMENT ON COLUMN tasks.autonomous_loop IS 'Whether this task should run in autonomous loop mode (overrides contract setting if set)';
