commit compras5 2911
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-29 19:49:19 +02:00
parent a935499d64
commit 96b30368bc
96 changed files with 3397 additions and 111 deletions
+62
View File
@@ -0,0 +1,62 @@
<?php
require dirname(__DIR__).'/vendor/autoload.php';
$root = dirname(__DIR__);
if (count($argv) !== 2 || $argv[1] !== '--apply-authorized') {
throw new LogicException('Explicit authorized interface publication required.');
}
$planPath = $root.'/docs/proofs/analytics-print-publication-proposal.json';
$plan = json_decode(file_get_contents($planPath), true, 512, JSON_THROW_ON_ERROR);
$approval = json_decode(file_get_contents($root.'/docs/proofs/analytics-print-publication-authorization.json'), true, 32, JSON_THROW_ON_ERROR);
$resultPath = $root.'/docs/proofs/analytics-print-publication.json';
if ($approval['state'] !== 'approved' || $approval['scope'] !== $plan['scope']
|| ! hash_equals($approval['proposal_sha256'], hash_file('sha256', $planPath)) || is_file($resultPath)
|| realpath($root) !== realpath('C:/laragon/www/compras')
|| $plan['candidate_root'] !== 'storage/framework/testing/sgc-analytics-print-qa-20261129') {
throw new LogicException('Interface publication scope or previous result differs.');
}
$candidate = $root.'/'.$plan['candidate_root'];
$manifestPath = $root.'/public/build/manifest.json';
if (! hash_equals($plan['previous_manifest_sha256'], hash_file('sha256', $manifestPath))
|| ! hash_equals($plan['manifest_sha256'], hash_file('sha256', $candidate.'/manifest.json'))) {
throw new LogicException('Reviewed interface manifest changed.');
}
$settingsPath = 'C:/laragon/data/sgf-tempo/secrets/payables-demo-compras.json';
$protected = [$root.'/.env', $settingsPath, $root.'/public/build/fonts-manifest.json'];
$hashes = array_map(static fn ($file) => hash_file('sha256', $file), $protected);
foreach ($plan['files'] as $file => $hash) {
if (! str_starts_with($file, 'assets/') || str_contains($file, '..') || ! hash_equals($hash, hash_file('sha256', $candidate.'/'.$file))
|| (is_file($root.'/public/build/'.$file) && ! hash_equals($hash, hash_file('sha256', $root.'/public/build/'.$file)))) {
throw new LogicException('Interface candidate missing or existing immutable asset differs.');
}
}
$backup = 'C:/laragon/data/compras/backups/analytics-print-'.gmdate('Ymd-His').'-'.bin2hex(random_bytes(6));
if (! mkdir($backup, 0700, true) || ! copy($manifestPath, $backup.'/manifest.before.json')
|| ! hash_equals($plan['previous_manifest_sha256'], hash_file('sha256', $backup.'/manifest.before.json'))) {
throw new LogicException('Interface manifest recovery copy failed.');
}
foreach ($plan['files'] as $file => $hash) {
$target = $root.'/public/build/'.$file;
if (! is_file($target) && ! copy($candidate.'/'.$file, $target)) {
throw new LogicException('Interface asset copy failed before manifest selection.');
}
if (! hash_equals($hash, hash_file('sha256', $target))) {
throw new LogicException('Published asset bytes differ.');
}
}
$temporary = $manifestPath.'.analytics-'.bin2hex(random_bytes(6)).'.tmp';
if (! copy($candidate.'/manifest.json', $temporary)
|| ! hash_equals($plan['manifest_sha256'], hash_file('sha256', $temporary))
|| ! hash_equals($plan['previous_manifest_sha256'], hash_file('sha256', $manifestPath))
|| ! rename($temporary, $manifestPath)) {
throw new LogicException('Atomic interface manifest selection failed.');
}
if ($hashes !== array_map(static fn ($file) => hash_file('sha256', $file), $protected)) {
throw new LogicException('Protected configuration changed; inspect without overwriting concurrent edits.');
}
$result = ['date' => gmdate('c'), 'state' => 'passed', 'authorization' => 'analytics-print-publication-authorization.json',
'manifest_sha256' => $plan['manifest_sha256'], 'previous_manifest_sha256' => $plan['previous_manifest_sha256'],
'backup_directory' => $backup, 'assets_verified' => count($plan['files']), 'old_assets_preserved' => true,
'database_commands_or_settings_changes' => false, 'public_runtime_activation' => false, 'application_complete' => false];
file_put_contents($resultPath, json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL);
echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL;