/**
 * P0-9 smoke test — runPendingChecks claim query filters deletedAt: null.
 *
 * After P2-1's atomic-claim refactor, the where-clause moved from a Prisma
 * findMany() to a raw SELECT inside a $transaction. This smoke now asserts
 * the SQL text instead of the JS where-clause shape.
 *
 * Run: npx tsx scripts/smoke/p0-9-softdelete.ts
 */
import './_lib';
import { ok, fail } from './_lib';
import { readFileSync } from 'fs';
import path from 'path';

function main(): void {
    const enginePath = path.resolve(__dirname, '../../src/lib/monitor-engine.ts');
    const src = readFileSync(enginePath, 'utf8');
    if (!/deletedAt IS NULL/i.test(src)) {
        fail('P0-9 softdelete', 'monitor-engine.ts no longer filters deletedAt IS NULL in the claim query');
    }
    ok('Claim query contains deletedAt IS NULL filter');
    if (!/active = TRUE/i.test(src)) {
        fail('P0-9 softdelete', 'lost active = TRUE filter');
    }
    ok('Claim query contains active = TRUE filter');
    ok('P0-9 softdelete', 'runPendingChecks still excludes soft-deleted monitors');
}

main();
