json_decode(file_get_contents($root.'/'.$path), true, 64, JSON_THROW_ON_ERROR); $artifact = $read('docs/proofs/rq01-distribution-artifact.json'); $rehearsal = $read('docs/proofs/rq01-distribution-pilot-preparation.json'); if ($rehearsal['status'] !== 'restored_pilot_rehearsal_passed_not_installed' || ! $rehearsal['restored_database_removed']) { throw new LogicException('Successful same-role restored rehearsal required.'); } $candidate = 'storage/framework/testing/sgc-distribution-integrated-qa-20261122'; $manifest = $read($candidate.'/manifest.json'); $assets = []; foreach ($manifest as $entry) { foreach ([$entry['file'], ...($entry['css'] ?? []), ...($entry['assets'] ?? [])] as $file) { if (! preg_match('~^assets/[A-Za-z0-9_.-]+$~D', $file) || ! is_file($root.'/'.$candidate.'/'.$file)) { throw new LogicException('Candidate asset inventory mismatch.'); } $assets[$file] = hash_file('sha256', $root.'/'.$candidate.'/'.$file); } } ksort($assets); $files = ['scripts/prepare-budget-distribution-pilot.php', 'scripts/budget-distribution-pilot-http.mjs', 'app/Services/BudgetDistributionArtifact.php', 'app/Services/BudgetDistributionSchema.php', 'database/deployment-migrations/2026_11_22_000004_create_budget_distributions.php', 'app/Providers/AppServiceProvider.php', 'app/Services/RequisitionBudgetDistributions.php', 'app/Services/InvoiceBudgetDistributions.php', 'app/Services/CommonBudget.php', 'app/Services/BudgetWorkflow.php', 'app/Services/PurchaseWorkflow.php', 'app/Services/InvoiceWorkflow.php', 'app/Services/RequisitionWorkflow.php', 'app/Models/Requisition.php', 'app/Http/Controllers/RequisitionController.php', 'app/Http/Controllers/PurchaseController.php', 'app/Http/Controllers/InvoiceController.php', 'app/Http/Controllers/PurchaseProcessController.php', 'config/budget-distributions.php', 'config/common-budget.php', 'routes/web.php', 'docs/proofs/rq01-distribution-artifact.json']; $reviewed = []; foreach ($files as $file) { if (! is_file($root.'/'.$file)) { throw new LogicException('Required reviewed host file missing:'.$file); } $reviewed[$file] = hash_file('sha256', $root.'/'.$file); } foreach ($artifact['files'] as $file => $hash) { if (hash_file('sha256', $root.'/'.$artifact['path'].'/'.$file) !== $hash) { throw new LogicException('Frozen common source changed.'); } $reviewed[$artifact['path'].'/'.$file] = $hash; } $proposal = ['date' => '2026-11-22', 'status' => 'prepared_not_authorised_not_installed', 'environment' => 'http://127.0.0.1:8005', 'scope' => 'Install only the optional line/cost-centre distributions and explicit Finance amendments in the named SGC pilot; no SGF activation or business operations.', 'schema' => ['migration' => $rehearsal['migration'], 'migration_sha256' => $reviewed[$rehearsal['migration']], 'nullable_column' => 'requisitions.budget_distribution_preparation', 'new_empty_tables' => ['budget_distributions', 'budget_distribution_events', 'budget_distribution_entries', 'budget_distribution_consumptions']], 'release_path' => 'storage/app/private/releases/budget-distribution-'.substr($artifact['canonical_fingerprint'], 0, 16), 'artifact_manifest_sha256' => hash_file('sha256', $root.'/docs/proofs/rq01-distribution-artifact.json'), 'archive_sha256' => $artifact['archive_sha256'], 'candidate_path' => $candidate, 'candidate_manifest_sha256' => hash_file('sha256', $root.'/'.$candidate.'/manifest.json'), 'previous_manifest_sha256' => $rehearsal['pilot_manifest_sha256'], 'assets' => $assets, 'reviewed_files' => $reviewed, 'private_settings_changes' => ['COMMON_BUDGET_PATH' => 'Selected independent SGC release directory; original pinned package preserved', 'SGC_BUDGET_DISTRIBUTIONS_ENABLED' => 'true', 'SGC_BUDGET_DISTRIBUTIONS_MANIFEST' => 'Frozen manifest inside the selected release', 'SGC_BUDGET_DISTRIBUTIONS_MANIFEST_SHA256' => 'Exact artifact_manifest_sha256 above'], 'verification' => ['native_visual' => 'rq01-distribution-visual.json', 'financial_qa' => 'rq01-distribution-qa.json', 'same_role_pilot_restore' => 'rq01-distribution-pilot-preparation.json', 'runtime_integrity_log' => 'storage/logs/budget-distribution-release-integrity.txt', 'postgres_schema_and_contract_log' => 'storage/logs/budget-distribution-deployment-schema-pg.txt'], 'execution' => ['Exact separate approval bound to this proposal SHA-256', 'Fresh consistent backup and same-role restore before applying', 'Recheck pilot data and configuration under locks; refuse intervening changes', 'Apply only the staged migration, preserve all previous columns/data/FKs', 'Verify separately copied release and all asset bytes before switching manifest and four settings', 'Confirm named pilot HTTP and effective capability without business commands'], 'recovery' => ['Before use: previous settings and manifest preserved privately; new empty schema can remain', 'After distribution use: retain compatible runtime and append-only history; never select old runtime or restore a backup automatically', 'Any restore affecting later operations requires a separate reviewed decision'], 'excluded' => ['Real business operations, budgets, commitments, invoices, payments or accounting commands', 'Changes to roles or grants', 'SGF deployment or activation', 'Replacing published or pinned financial packages', 'MFA, inventory conversions, per-order limits, People formalisation', 'Production publication and enterprise acceptance']]; file_put_contents($root.'/docs/proofs/rq01-distribution-pilot-proposal.json', json_encode($proposal, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR).PHP_EOL); echo json_encode(['proposal_prepared' => true, 'assets' => count($assets), 'reviewed_files' => count($reviewed), 'proposal_sha256' => hash_file('sha256', $root.'/docs/proofs/rq01-distribution-pilot-proposal.json')], JSON_THROW_ON_ERROR).PHP_EOL;