-- Add validation configuration for checkpoint contracts
-- Checkpoint contracts validate outputs of upstream dependencies before allowing downstream to proceed

-- Add validation column to store checkpoint validation config as JSON
ALTER TABLE chain_contract_definitions ADD COLUMN IF NOT EXISTS validation JSONB DEFAULT NULL;

-- Add comment explaining the validation schema
COMMENT ON COLUMN chain_contract_definitions.validation IS 'Validation config for checkpoint contracts: {checkDeliverables: bool, runTests: bool, checkContent: string, onFailure: "block"|"retry"|"warn", maxRetries: int}';

-- Add validation_status to chain_contracts to track checkpoint pass/fail
ALTER TABLE chain_contracts ADD COLUMN IF NOT EXISTS validation_status VARCHAR(32) DEFAULT NULL;
COMMENT ON COLUMN chain_contracts.validation_status IS 'For checkpoint contracts: "pending", "passed", "failed"';

-- Add validation_result to store detailed validation output
ALTER TABLE chain_contracts ADD COLUMN IF NOT EXISTS validation_result JSONB DEFAULT NULL;
COMMENT ON COLUMN chain_contracts.validation_result IS 'Detailed validation results from checkpoint contract';
