commit compras5 2711
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-27 20:19:21 +02:00
parent 7486007fcf
commit d58b75c87a
57 changed files with 2803 additions and 116 deletions
@@ -0,0 +1,81 @@
<?php
// Private review bundle only: no installed package, application configuration or database is changed.
$root = dirname(__DIR__);
$financial = realpath('C:/laragon/www/sgf-tempo/packages/budget-control');
if ($financial === false || str_replace('\\', '/', $financial) !== 'C:/laragon/www/sgf-tempo/packages/budget-control') {
throw new LogicException('Canonical financial source mismatch.');
}
$budgetFiles = ['bootstrap.php', 'README.md', 'src/BudgetContext.php', 'src/BudgetFailure.php', 'src/BudgetControl.php',
'src/BudgetDistributionPlan.php', 'src/BudgetDistributions.php', 'src/BudgetOrderParts.php', 'src/BudgetLandedCosts.php',
'src/BudgetLandedCostPlan.php', 'src/BudgetImportEstimate.php', 'src/BudgetRequisitionCycles.php'];
$purchasingFiles = ['bootstrap.php', 'README.md', 'module.json', 'src/ReplenishmentProjection.php', 'src/QuotationPricing.php',
'src/ProposalScoring.php', 'src/RequisitionPort.php', 'src/ExpiryRequisitionPort.php', 'src/RequisitionFailure.php', 'src/InternalRequisitions.php', 'src/Sourcing.php'];
$sources = [];
foreach (['budget-control' => [$financial, $budgetFiles], 'purchasing' => [$root.'/packages/purchasing', $purchasingFiles]] as $package => [$directory, $files]) {
foreach ($files as $file) {
$sources[$package.'/'.$file] = $directory.'/'.$file;
}
}
$schema = 'database/qa-migrations/2026_11_27_000001_add_requisition_cycles.php';
$sources[$schema] = $root.'/'.$schema;
$hashes = [];
foreach ($sources as $name => $source) {
if (! is_file($source) || is_link($source)) {
throw new RuntimeException('Missing canonical bundle file: '.$name);
}
$hashes[$name] = hash_file('sha256', $source);
}
$fingerprint = hash('sha256', json_encode($hashes, JSON_THROW_ON_ERROR));
$relative = 'storage/framework/testing/requisition-cycles-qa-'.substr($fingerprint, 0, 16);
$target = $root.'/'.$relative;
foreach ($sources as $name => $source) {
$destination = $target.'/'.$name;
if (! is_dir(dirname($destination)) && ! mkdir(dirname($destination), 0700, true)) {
throw new RuntimeException('Unable to create private cycle bundle.');
}
if (is_link($destination) || (is_file($destination) && hash_file('sha256', $destination) !== $hashes[$name])) {
throw new RuntimeException('Frozen cycle bundle differs; no file overwritten.');
}
if (! is_file($destination) && ! copy($source, $destination)) {
throw new RuntimeException('Cycle bundle copy failed.');
}
if (hash_file('sha256', $destination) !== $hashes[$name]) {
throw new RuntimeException('Cycle bundle verification failed.');
}
}
$manifest = ['contract' => 'COMMON-BUDGET-REQUISITION-CYCLES-QA-v1', 'status' => 'private_qa_not_installed', 'files' => $hashes];
$bytes = json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR).PHP_EOL;
if (is_file($target.'/manifest.json') && file_get_contents($target.'/manifest.json') !== $bytes) {
throw new RuntimeException('Frozen cycle manifest differs.');
}
file_put_contents($target.'/manifest.json', $bytes);
$archive = $target.'.zip';
if (! is_file($archive)) {
$zip = new ZipArchive;
if ($zip->open($archive, ZipArchive::CREATE | ZipArchive::EXCL) !== true) {
throw new RuntimeException('Unable to create private cycle archive.');
}
foreach ($sources as $name => $source) {
$zip->addFile($target.'/'.$name, $name);
}
$zip->addFile($target.'/manifest.json', 'manifest.json');
$zip->close();
}
$zip = new ZipArchive;
if ($zip->open($archive) !== true || $zip->numFiles !== count($sources) + 1 || $zip->getFromName('manifest.json') !== $bytes) {
throw new RuntimeException('Cycle archive inventory mismatch.');
}
foreach ($hashes as $name => $hash) {
if (hash('sha256', $zip->getFromName($name)) !== $hash) {
throw new RuntimeException('Cycle archive byte mismatch.');
}
}
$zip->close();
$proof = ['date' => '2026-11-27', 'status' => 'private_qa_prepared_not_installed', 'path' => $relative,
'manifest_sha256' => hash('sha256', $bytes), 'archive' => $relative.'.zip', 'archive_sha256' => hash_file('sha256', $archive),
'canonical_fingerprint' => $fingerprint, 'files' => $hashes, 'independent_financial_load_test' => 'pending',
'installed_packages_changed' => false, 'pilot_or_sgf_activation' => false];
file_put_contents($root.'/docs/proofs/requisition-expiry-artifact.json', json_encode($proof, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR).PHP_EOL);
echo json_encode(['private_cycle_bundle_prepared' => true, 'path' => $relative, 'files' => count($sources),
'manifest_sha256' => $proof['manifest_sha256'], 'archive_sha256' => $proof['archive_sha256']], JSON_THROW_ON_ERROR).PHP_EOL;
+54 -3
View File
@@ -105,6 +105,27 @@ try {
if (in_array('--requisition-cycles-focused', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/RequisitionBudgetCyclesTest.php']];
}
if (in_array('--requisition-cycles-artifact', $argv, true)) {
$artifact = json_decode(file_get_contents(base_path('docs/proofs/requisition-expiry-artifact.json')), true, 32, JSON_THROW_ON_ERROR);
if (! preg_match('~^storage/framework/testing/requisition-cycles-qa-[a-f0-9]{16}$~D', $artifact['path'] ?? '')
|| hash_file('sha256', base_path($artifact['path'].'/manifest.json')) !== $artifact['manifest_sha256']) {
throw new LogicException('Invalid private cycle artifact manifest.');
}
$manifest = json_decode(file_get_contents(base_path($artifact['path'].'/manifest.json')), true, 32, JSON_THROW_ON_ERROR);
if ($manifest['files'] !== $artifact['files'] || count($manifest['files']) !== 24) {
throw new LogicException('Private cycle artifact inventory mismatch.');
}
foreach ($manifest['files'] as $name => $hash) {
$resolved = realpath(base_path($artifact['path'].'/'.$name));
$boundary = realpath(base_path($artifact['path']));
if ($resolved === false || $boundary === false || ! str_starts_with($resolved, $boundary.DIRECTORY_SEPARATOR)
|| is_link(base_path($artifact['path'].'/'.$name)) || hash_file('sha256', $resolved) !== $hash) {
throw new LogicException('Private cycle artifact byte mismatch.');
}
}
$environment['COMMON_BUDGET_PATH'] = base_path($artifact['path'].'/budget-control');
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/RequisitionBudgetCyclesTest.php']];
}
if (in_array('--requisition-cycles-regression', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/RequisitionBudgetCyclesTest.php',
'tests/Feature/InternalRequisitionCandidateTest.php', 'tests/Feature/BudgetTest.php']];
@@ -116,6 +137,36 @@ try {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php',
'--filter=award starts a new approval cycle|distributed approved synthetic|native partial-order issuance|native partial-order receipts|native consolidated order retains|native partial-order cancellation']];
}
if (in_array('--consolidated-report-focused', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', 'tests/Feature/ProcurementPayableInsightsTest.php',
'--filter=native consolidated order retains|financial insights|divergent native position|native imported history|payment period follows|read composition rejects']];
}
if (in_array('--contract-report-focused', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php', 'tests/Feature/ProcurementReportsTest.php',
'--filter=per order global contract sums|award starts a new approval cycle|contract report preserves']];
}
if (in_array('--multi-order-review-focused', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php',
'--filter=native partial-order receipts and independent invoice|native consolidated order retains']];
}
if (in_array('--delivery-analysis-focused', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php',
'--filter=native delivery analysis|native consolidated order retains']];
}
if (in_array('--expense-allocation-focused', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/ExpenseAllocationsTest.php', 'tests/Feature/ProcurementPayableInsightsTest.php']];
}
if (in_array('--expense-native-regression', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/ReceiptFixtureConsistencyTest.php', 'tests/Feature/ReceiptStockTest.php', 'tests/Feature/InvoiceTest.php', 'tests/Feature/ExternalPaymentTest.php', 'tests/Feature/InventoryReversalsTest.php']];
}
if (in_array('--expense-allocation-concurrency', $argv, true)) {
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
[PHP_BINARY, 'tests/Concurrency/expense-allocation-worker.php', $database, 'race-expense']];
}
if (in_array('--expense-allocation-recovery', $argv, true)) {
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
[PHP_BINARY, 'tests/Concurrency/requisition-cycle-recovery-worker.php', $database, 'recover-expenses']];
}
if (in_array('--requisition-cycles-orders', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/PurchaseAwardOrderTest.php',
'--filter=native partial-order issuance commits only forty']];
@@ -160,7 +211,7 @@ try {
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
[PHP_BINARY, 'tests/Concurrency/import-legal-corpus-worker.php', $database, 'corpus', substr($corpusArguments[0], strlen('--legal-corpus-root='))]];
}
if (in_array('--legal-http', $argv, true) || in_array('--legal-native-review', $argv, true)) {
if (in_array('--legal-http', $argv, true) || in_array('--legal-native-review', $argv, true) || in_array('--expiry-native-review', $argv, true)) {
$values = [];
foreach (['--legal-corpus-root=', '--legal-http-candidate=', '--legal-http-manifest='] as $prefix) {
$matches = array_values(array_filter($argv, fn ($value) => str_starts_with($value, $prefix)));
@@ -170,7 +221,7 @@ try {
$values[] = substr($matches[0], strlen($prefix));
}
$commands = [[PHP_BINARY, 'tests/Concurrency/quotation-exchange-worker.php', $database, 'migrate'],
[PHP_BINARY, 'tests/Concurrency/import-legal-http-worker.php', $database, in_array('--legal-native-review', $argv, true) ? 'legal-review' : 'legal-http', ...$values]];
[PHP_BINARY, 'tests/Concurrency/import-legal-http-worker.php', $database, in_array('--expiry-native-review', $argv, true) ? 'expiry-review' : (in_array('--legal-native-review', $argv, true) ? 'legal-review' : 'legal-http'), ...$values]];
}
if (in_array('--bank-support-native-only', $argv, true)) {
$commands = [[PHP_BINARY, 'vendor/bin/pest', '--compact', 'tests/Feature/ImportBankSupportTest.php']];
@@ -318,7 +369,7 @@ try {
throw new LogicException('Each Pest kernel must use its own disposable PostgreSQL database.');
}
foreach ($commands as $command) {
$nativeReview = ($command[3] ?? '') === 'legal-review';
$nativeReview = in_array($command[3] ?? '', ['legal-review', 'expiry-review'], true);
$process = new Process($command, dirname(__DIR__), $environment, timeout: $nativeReview ? 3660 : 180);
$process->run($nativeReview ? function ($type, $buffer) {
echo $buffer;