53 lines
2.7 KiB
PHP
53 lines
2.7 KiB
PHP
<?php
|
|
|
|
/** PostgreSQL migration functions survive table refreshes across different Pest kernels.
|
|
* @param list<list<string>> $commands
|
|
*/
|
|
function landedQaCommandIsolationVerified(array $commands): bool
|
|
{
|
|
return count(array_filter($commands, fn ($command) => ($command[1] ?? '') === 'vendor/bin/pest')) <= 1;
|
|
}
|
|
|
|
/** Test-only protocol: a successful exit without verification receipts is not a passing proof.
|
|
* @param list<string> $command
|
|
*/
|
|
function landedQaReceiptsVerified(array $command, string $output): bool
|
|
{
|
|
$records = array_values(array_filter(array_map(fn ($line) => json_decode($line, true), explode("\n", $output)), 'is_array'));
|
|
$contains = static function (callable $test) use ($records): bool {
|
|
foreach ($records as $record) {
|
|
if ($test($record)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
};
|
|
$mode = ($command[1] ?? '') === 'vendor/bin/pest' ? 'pest' : ($command[3] ?? '');
|
|
if ($mode === 'migrate') {
|
|
return $contains(fn ($row) => ($row['isolated_schema_prepared'] ?? false) === true);
|
|
}
|
|
if ($mode === 'race') {
|
|
foreach (['same_operation', 'conflicting_plan_version', 'same_source_different_plan'] as $scenario) {
|
|
$matches = array_values(array_filter($records, fn ($row) => ($row['scenario'] ?? null) === $scenario));
|
|
if (count($matches) !== 1 || ($matches[0]['blocked_writers_observed'] ?? 0) < 2
|
|
|| ($matches[0]['commands'] ?? 0) !== 1 || ($matches[0]['audits'] ?? 0) !== 1
|
|
|| ($matches[0]['statuses'] ?? null) !== ($scenario === 'same_operation' ? [200, 200] : [200, 409])) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return $contains(fn ($row) => ($row['old_runtime_rejected_before_balance'] ?? false) === true && ($row['status'] ?? 0) === 503);
|
|
}
|
|
if ($mode === 'landed-costs') {
|
|
return $contains(fn ($row) => ($row['post_extension_restore_all_tables_equal'] ?? false) === true
|
|
&& ($row['recovered_operation_replay_no_effects'] ?? false) === true && ($row['pre_extension_schema_data_balance_restored'] ?? false) === true)
|
|
&& $contains(fn ($row) => ($row['private_original_versions_restored'] ?? 0) === 2 && ($row['source_loss_detected'] ?? false) === true
|
|
&& ($row['separate_private_root_restored'] ?? false) === true && ($row['native_authorized_evidence_resolved'] ?? false) === true)
|
|
&& $contains(fn ($row) => ($row['isolated_restore_removed'] ?? false) === true);
|
|
}
|
|
|
|
return $mode === 'pest' && $contains(fn ($row) => ($row['tool'] ?? null) === 'pest' && ($row['result'] ?? null) === 'passed'
|
|
&& ($row['tests'] ?? 0) > 0 && ($row['passed'] ?? 0) === $row['tests']);
|
|
}
|