$value) { putenv($key.'='.$value); $_ENV[$key] = $_SERVER[$key] = $value; } require $root.'/vendor/autoload.php'; $app = require $root.'/bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); if (DB::getDriverName() !== 'pgsql' || DB::connection()->getDatabaseName() !== $proof['database']) { throw new LogicException('Review verification database mismatch.'); } $request = DB::table('requisitions')->where('id', $proof['synthetic_fixture']['draft'])->first(); $plan = json_decode($request->budget_distribution_preparation, true, 32, JSON_THROW_ON_ERROR); if ((int) $request->process_version !== 3 || $request->status !== 'draft' || count($plan['allocations']) !== 2 || array_column($plan['allocations'], 'subtotal_minor') !== [5000, 5000] || array_column($plan['allocations'], 'total_minor') !== [5000, 5000] || DB::table('budget_distributions')->where('requisition_id', $request->id)->exists() || DB::table('audit_logs')->where('requisition_id', $request->id)->where('action', 'requisition.allocations_prepared')->count() !== 2) { throw new RuntimeException('Browser correction did not preserve the draft, exact values and absence of financial effects.'); } echo json_encode(['native_browser_draft_saved' => true, 'version' => 3, 'failed_attempt_no_effects' => true, 'two_explicit_allocations' => true, 'no_reservation_on_prepare' => true], JSON_THROW_ON_ERROR).PHP_EOL; if (in_array('--amended', $argv, true)) { $order = DB::table('purchase_orders')->where('id', $proof['synthetic_fixture']['foreign_order'])->first(); $source = DB::table('budget_distributions')->where('requisition_id', $order->requisition_id)->first(); $current = json_decode($source->snapshot, true, 32, JSON_THROW_ON_ERROR); $original = json_decode(DB::table('budget_distribution_events')->where('distribution_id', $source->id)->where('kind', 'commit')->value('snapshot'), true, 32, JSON_THROW_ON_ERROR); $document = json_decode($order->snapshot, true, 32, JSON_THROW_ON_ERROR); $values = array_column($current['allocations'], 'total_minor'); sort($values); if ($current['amendment_version'] !== 1 || $values !== [4999, 5001] || array_column($original['allocations'], 'total_minor') !== [5000, 5000] || array_sum(array_column($current['allocations'], 'subtotal_minor')) !== 10000 || $document['budget_control']['plan_hash'] !== $original['plan_hash'] || $document['exchange_basis']['rate'] !== '1.0000000000' || $order->currency !== 'USD' || (int) $order->total_minor !== 10000 || DB::table('budget_distribution_events')->where('distribution_id', $source->id)->count() !== 4 || DB::table('audit_logs')->where('requisition_id', $order->requisition_id)->where('action', 'budget.distribution_amended')->count() !== 1) { throw new RuntimeException('Native browser amendment did not preserve the original document, exact total, version and history.'); } if (DB::table('invoices')->count() !== 0 || DB::table('purchase_awards')->where('requisition_id', $proof['synthetic_fixture']['award'])->exists()) { throw new RuntimeException('Read-only invoice/adjudication review unexpectedly registered a business document.'); } echo json_encode(['native_browser_finance_amendment' => true, 'version' => 1, 'original_commitment_and_rate_preserved' => true, 'one_amendment_and_audit' => true], JSON_THROW_ON_ERROR).PHP_EOL; }