Stop domain-wheel collecting and age-band years in prompts. Ask until the training gate, then discriminate until convergence, then deliver a range plus a concrete follow-up. Reserve holdout only with four dated events. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
2.1 KiB
TypeScript
41 lines
2.1 KiB
TypeScript
import assert from "node:assert/strict";
|
||
import test from "node:test";
|
||
|
||
import { holdoutEventIds, holdoutReservationStatus, splitHoldoutEvents } from "../src/lib/rectification-agentic/core/split-holdout.ts";
|
||
|
||
test("holdout fallback reserves a month-or-better event, not a trailing year event", () => {
|
||
const events = splitHoldoutEvents([
|
||
{ id: "job-a", domain: "career", year: 2018, precision: "month" },
|
||
{ id: "job-b", domain: "career", year: 2020, precision: "day" },
|
||
{ id: "love-a", domain: "relationship", year: 2016, precision: "year" },
|
||
{ id: "love-b", domain: "relationship", year: 2022, precision: "year" },
|
||
]);
|
||
assert.deepEqual([...holdoutEventIds(events)], ["job-b"]);
|
||
assert.equal(events.find((item) => item.id === "love-b")?.usage, "training");
|
||
assert.equal(events.filter((item) => item.usage === "training").length, 3);
|
||
});
|
||
|
||
test("singleton-domain holdout still prefers that domain when training would stay at three", () => {
|
||
const events = splitHoldoutEvents([
|
||
{ id: "edu", domain: "education", year: 2016, precision: "year" },
|
||
{ id: "job-a", domain: "career", year: 2018, precision: "month" },
|
||
{ id: "job-b", domain: "career", year: 2020, precision: "month" },
|
||
{ id: "love", domain: "relationship", year: 2021, precision: "year" },
|
||
]);
|
||
assert.deepEqual([...holdoutEventIds(events)], ["edu"]);
|
||
});
|
||
|
||
test("three dated events stay in training and do not reserve a holdout", () => {
|
||
const events = splitHoldoutEvents([
|
||
{ id: "edu", domain: "education", year: 2016, precision: "month" },
|
||
{ id: "job", domain: "career", year: 2018, precision: "month" },
|
||
{ id: "love", domain: "relationship", year: 2021, precision: "year" },
|
||
]);
|
||
// 原值: 3 件留 1 件 holdout,训练只剩 2,训练门关
|
||
// 新值: 不足 4 件不留 holdout,3 件全进训练
|
||
// 原因: 用户给了门槛件数却被 holdout 卡住(BUG-647)
|
||
assert.equal(holdoutEventIds(events).size, 0);
|
||
assert.equal(events.filter((item) => item.usage === "training").length, 3);
|
||
assert.equal(holdoutReservationStatus(events), "not_reserved_min_events");
|
||
});
|