0', 'AND audit_job_id IS NOT NULL', "kind = 'service_compensation'", ] as $contract) { $assert(str_contains($schema, $contract), 'Service compensation schema lost contract: ' . $contract); } foreach ([ 'chk_cloud_service_compensation_scope', 'chk_cloud_service_compensation_request', 'chk_cloud_service_compensation_window', 'chk_cloud_service_compensation_counts', 'chk_cloud_service_compensation_state', 'chk_cloud_service_compensation_terminal', 'chk_cloud_service_compensation_item_state', 'chk_cloud_service_compensation_item_window', 'chk_cloud_service_compensation_item_lease', 'chk_cloud_service_compensation_item_terminal', 'chk_cloud_service_compensation_item_applied', 'chk_cloud_service_compensation_item_error', 'chk_cloud_service_compensation_recipient_status', 'chk_cloud_service_compensation_recipient_payload', 'chk_cloud_service_compensation_recipient_shape', ] as $check) { $assert(str_contains($setup, "'" . $check . "'"), 'CloudSetup lost service compensation check: ' . $check); } foreach ([ "'columns' => ['id', 'incident_key']", "'columns' => ['incident_key', 'instance_id']", "'columns' => ['state', 'available_at', 'id']", "'columns' => ['state', 'lease_until', 'id']", "'columns' => ['instance_id', 'state', 'id']", "'columns' => ['batch_id', 'user_id']", "'columns' => ['status', 'available_at', 'id']", "'columns' => ['status', 'lease_until', 'id']", "'fk_cloud_service_compensation_item_batch'", "'fk_cloud_service_compensation_recipient_batch'", ] as $setupContract) { $assert(str_contains($setup, $setupContract), 'CloudSetup lost service compensation contract: ' . $setupContract); } $targetShape = preg_match( '/CONSTRAINT chk_cloud_job_target_shape CHECK \((.*?)\n \),\n CONSTRAINT chk_cloud_job_effect_shape/s', $schema, $targetMatch ) === 1 ? $targetMatch[1] : ''; $assert($targetShape !== '' && str_contains($targetShape, "kind = 'service_compensation'") && str_contains($targetShape, 'parent_job_id IS NULL') && str_contains($targetShape, 'instance_id IS NOT NULL'), 'Local compensation audit jobs are rejected by the cloud-job target shape.'); $assert(str_contains($setup, "'cloud_service_compensation_item_open'") && str_contains($setup, "'columns' => ['instance_id', 'state', 'id']"), 'CloudSetup lost the open-compensation fence index contract.'); $assert(str_contains($setup, "SCHEMA_VERSION = 'go-agent-wss-v35-service-compensations'"), 'CloudSetup schema version was not advanced for service compensation.'); echo "Service compensation schema contracts passed.\n";