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>
31 lines
989 B
TypeScript
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;
|
|
}
|