make(Kernel::class)->bootstrap(); use Illuminate\Contracts\Console\Kernel; use Illuminate\Support\Facades\DB; $identity = DB::selectOne('select current_database() as name, inet_server_port() as port'); throw_unless($identity->name === 'continuity_20261120_test' && (int) $identity->port === 55441, RuntimeException::class, 'Isolated QA only'); $slices = json_decode(file_get_contents(dirname(__DIR__).'/outputs/demography-d01-d06-20261120/source-slices.json'), true, 512, JSON_THROW_ON_ERROR); $checked = 0; foreach ($slices as $slice) { $batch = DB::table('demographic_imports')->where('sha256', $slice['sha256'])->first(); throw_unless($batch && $batch->file_name === $slice['file'], RuntimeException::class, 'Original provenance missing'); foreach ($slice['records'] as $row) { $stored = DB::table('demographic_observations as o')->join('geo_locations as g', 'g.id', '=', 'o.geo_location_id') ->where('o.import_id', $batch->id)->where('o.sheet', $row['sheet'])->where('o.cell', $row['cell'])->first(['o.*', 'g.name']); throw_unless($stored && $stored->name === $row['territory'] && $stored->numeric_value === $row['numeric_value'] && $stored->original_value === $row['original_value'], RuntimeException::class, 'Observation mismatch'); $checked++; } } echo json_encode(['database' => $identity->name, 'port' => $identity->port, 'exact_observations_checked' => $checked, 'mismatches' => 0, 'writes' => false, 'traceability_preserved' => true], JSON_PRETTY_PRINT).PHP_EOL;