fix(rectification): bind quality cards to the followup probe
Independent Staging Quality Gate / validate (push) Successful in 23m15s
Independent Staging Quality Gate / publish (push) Failing after 36s

Graduation no longer gets the college-experience question, and identical D24 splits only ask once.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-04 23:47:47 +08:00
parent 73c2a1a51e
commit 40c623edf6
9 changed files with 462 additions and 9 deletions
@@ -100,6 +100,7 @@ export type ChoiceCardFollowup = Readonly<{
choice_kind?: EventProbeChoiceKind;
style_options?: readonly EventProbeStyleOption[];
semantic_key?: string;
probe_id?: string;
}>;
export type ChoiceCardEvidence = Readonly<{
@@ -230,12 +231,28 @@ function followupDomain(followup: ChoiceCardFollowup): string | null {
return THEME_DOMAIN[followup.ask_theme] ?? null;
}
function probeMatchesId(item: DiscriminatingEventProbe, probeId: string): boolean {
return item.semantic_key === probeId;
}
function pickProbe(
probes: readonly DiscriminatingEventProbe[] | undefined,
domain: string | null,
followup?: ChoiceCardFollowup,
): DiscriminatingEventProbe | null {
if (!probes?.length) return null;
const probeId = followup?.probe_id?.trim() ?? "";
const semanticKey = followup?.semantic_key?.trim() ?? "";
const hasKey = Boolean(probeId || semanticKey);
if (probeId) {
const byId = probes.find((item) => probeMatchesId(item, probeId));
if (byId) return byId;
}
if (semanticKey) {
const keyed = probes.find((item) => item.semantic_key === semanticKey);
if (keyed) return keyed;
}
if (hasKey) return null;
const inDomain = domain ? probes.filter((item) => item.domain === domain) : [...probes];
const pool = inDomain.length > 0 ? inDomain : probes;
if (followup?.choice_kind === "event_quality") {
@@ -244,10 +261,6 @@ function pickProbe(
);
if (quality) return quality;
}
if (followup?.semantic_key) {
const keyed = pool.find((item) => item.semantic_key === followup.semantic_key);
if (keyed) return keyed;
}
return pool[0] ?? probes[0] ?? null;
}
@@ -386,8 +399,10 @@ export function buildChoiceFrame(
const skipQuestion = skipThisProbe
|| followup.intent === "out_of_sample_check"
|| followup.source === "oos_blind";
const probeKey = followup.semantic_key?.trim() || followup.probe_id?.trim() || "";
const questionBase = `${followup.method_id}:${followup.ask_theme}:${scoring ? "score" : "holdout"}`;
return {
question_id: `${followup.method_id}:${followup.ask_theme}:${scoring ? "score" : "holdout"}`,
question_id: probeKey ? `${questionBase}:${probeKey}` : questionBase,
method_id: followup.method_id,
period: periodFor(input.evidence, domain, input.probes, input.birthDate, followup),
prompt: hypothesis.prompt,