SELECT json_build_object(
    'schema_version', (SELECT max(version) FROM schema_versions),
    'shipment_count', (SELECT count(*) FROM shipments),
    'event_count', (SELECT count(*) FROM shipment_events),
    'ledger_count', (SELECT count(*) FROM recovery_ledger),
    'max_sequence', (SELECT max(sequence) FROM recovery_ledger),
    'known_pre_backup_present', EXISTS (
        SELECT 1 FROM shipments WHERE external_id = 'shipment-100'
    ),
    'post_backup_present', EXISTS (
        SELECT 1 FROM shipments WHERE external_id = 'shipment-102'
    ),
    'business_ids', (
        SELECT json_agg(external_id ORDER BY external_id) FROM shipments
    )
);
