/**
 * Single source of truth for the raw-Heartbeat retention boundary.
 *
 * Raw `Heartbeat` rows are kept only RAW_RETENTION_DAYS; everything older
 * is rolled into `HeartbeatHourly` and the raw rows DELETEd (RollupService,
 * driven by /api/cron/cleanup — which uses this exact constant). Any query
 * that spans more than this window must read RAW for the recent side and
 * HOURLY for the older side, split at `rawBoundary()`, or it silently
 * truncates once cleanup runs.
 *
 * Keep this in lockstep with RAW_RETENTION_DAYS in
 * src/app/api/cron/cleanup/route.ts. They describe the same physical fact.
 */
export const RAW_RETENTION_DAYS = 7;

/** The instant before which raw Heartbeat rows no longer exist (older data is hourly-only). */
export function rawBoundary(): Date {
    return new Date(Date.now() - RAW_RETENTION_DAYS * 24 * 60 * 60 * 1000);
}
