Files
Jyotisha/frontend/src/lib/rectification-agentic/v9/adult-floor.ts
T
Jesse_ChenandCursor a43a6db884
Independent Staging Quality Gate / validate (push) Successful in 14m8s
Independent Staging Quality Gate / publish (push) Successful in 10m21s
fix(rectification): three-column candidate compare card (BUG-597, BUG-598)
Replace the minute-row delivery card with up to three compare columns so users can pick the time that fits, and apply the adult-year floor on inspect fallbacks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 00:12:20 +08:00

31 lines
989 B
TypeScript

/**
* Domain age floors for existence probes. Shared by method-followup
* ranking and inspectDiscriminatorProbes so the inspect fallback cannot
* re-ask a year the follow-up path already filtered.
*/
export const DOMAIN_AGE_LO: Readonly<Record<string, number>> = {
education: 16,
relocation: 18,
relationship: 21,
career: 22,
finance: 22,
health_pressure: 16,
};
export function birthYearFromDate(birthDate: string | null | undefined): number | null {
if (!birthDate || birthDate.length < 4 || !/^\d{4}/.test(birthDate)) return null;
const year = Number(birthDate.slice(0, 4));
return year >= 1900 && year <= 2100 ? year : null;
}
export function probeBelowAdultFloor(
probe: { domain: string; year: number },
birthDate?: string | null,
): boolean {
const birthYear = birthYearFromDate(birthDate);
const floor = DOMAIN_AGE_LO[probe.domain];
if (birthYear === null || floor == null || !probe.year) return false;
return probe.year < birthYear + floor;
}