feat(rectification): range delivery needs 4 dated events across 3 domains (R1, BUG-1193)

Product decision 2026-10-02 (TASK-upstream-sync5 R1): a time range is offered
only with at least 4 dated, primary-scoreable events covering 3 domains,
counted on all of them (training + reserved holdout). Was 3 training events /
2 domains in three TS copies and the Python acceptance gate while the policy
file already said 4/3.

- One definition: references/rectification_policy.v1.json
  (minConfirmationEvents / minConfirmationDomains). TS core/types MIN_DATED_*,
  rectification-decision MIN_STANDALONE_*, evidence-model MIN_ACCEPTANCE_*,
  the convergence evaluator and the post-inference trainingGateOpen all read
  it; Python decision_policy MIN_ACCEPTANCE_* alias MIN_CONFIRMATION_*.
- Python receipt counts all scoreable events / domains for event_quality and
  domain_diversity; decision policy identity v3 -> v4 (candidate UUIDs carry
  it). Candidate scores unchanged (77 v5 cases A/B identical), so the
  algorithm stays rectification-v5-matrix-scoring-10.
- Memoization golden v3 written by write_golden; v2 frozen by sha256 with a
  test that its scores equal v3 and only the receipt policy moved.
- Collect gap copy names the exact gap ("再来两件……其中至少一件不是……")
  instead of always "再来一件"; VOICE.md updated. Legacy life-events form copy
  4/3 as well.
- 30 frontend test files, 4 Python tests: fixtures extended to the same
  scenario at 4/3, or assertions changed with 原值/新值/原因 notes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
This commit is contained in:
Jesse_Chen
2026-10-03 00:08:00 +08:00
co-authored by Claude Opus 5.5
parent 7fb165ecf6
commit 758fee954b
37 changed files with 2270 additions and 97 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ Jyotisha 的可见文案是产品的一部分。正确性红线(真实性、
| 生成中输入框变灰,回车没反应 | 生成中仍可打字;回车后显示「已排队,回答结束后发出」,可撤回 | 对标主流对话产品,焦点不丢。 |
| 停止后出现红色告警条 | 已停止,已生成的内容保留;本次不会扣点。 | 停止是用户动作,不是出错。 |
| 打字回答发出后一直是「正在处理… / 正在分析…」,半分钟没有变化 | 发出即「收到,正在对照你的档案…」,随后按阶段换成「正在记下这件事…」「正在重新对照盘面…」「正在准备下一个问题…」。 | 发出后 300 ms 内要有一句确定的话;阶段由真实动作推动,只在活动行里,正文与历史里都没有(BUG-1047)。 |
| 也可以再说一件你记得大概时间的事。 / 还差带月份的经历,领域不限。 | 训练门开后给区间卡,并写「如果还记得……范围还能再收一截」。材料不够时只写记下了哪几件、再来一件不是这类的、至少两个具体例子;输入框占位「再说一件带年月的事」。 | 训练门未开时永远给结果或精确缺口;不说「领域不限」「做不了」。交付后采集线关完的邀请见下一行。 |
| 也可以再说一件你记得大概时间的事。 / 还差带月份的经历,领域不限。 | 训练门开后给区间卡,并写「如果还记得……范围还能再收一截」。材料不够时只写记下了哪几件、还差几件与还缺几个方面(门槛 4 件、3 个方面,2026-10-02 R1;例「再来两件记得大概年月的事,其中至少一件不是上学或工作的,就能开始筛」,只差一件时仍写「再来一件……」)、至少两个具体例子;输入框占位「再说一件带年月的事」。 | 训练门未开时永远给结果或精确缺口;不说「领域不限」「做不了」。交付后采集线关完的邀请见下一行。 |
| 能问的都问完了 / 你要是还记得确切哪一天的事,不限领域,说出来我接着算 | 还有题可问时:「现在还剩 04:51–05:11 里 5 个候选,再对照几件经历会更准」,下面是系统点名的题。答「有」之后是口述「大概哪年几月?」,在输入框打字回答,不再出「哪一类事 + 发生年月」的卡。七条线和跳过线的重问问完了(按时间段点名的引导题一次校正最多两道),或用户说「没有了」,就出目前范围卡。 | 有题就继续引导;年月阶段直接打字。没题了照常给结果,不写「未达门槛」,也不为凑门槛再追问。不承诺「再补几件就能定到分钟」。 |
| 2018 年 3 到 5 月之间,有没有入职、换工作或职责变重?(引擎其实不知道是哪一类) | 「2018 年 3 到 5 月之间,有没有什么事,比如搬家或开始长期住外地、开始认真关系、分手或结婚?」只有 D9 / D10 那两条轨道才点名领域。 | 边界只说得出「哪段时间」,说不出「哪一类事」。例子最多三个,只列用户还没拒答、也还没说过的领域。 |
| (录入卡)哪一类事 + 发生年月 | 答「有」后只剩口述「大概哪年几月?」,在输入框打字。 | 多余入口删除;年月阶段不再有第二套录入。账本仍记用户原话,不得复用题干例子列表。 |
@@ -4,6 +4,7 @@ import { useRef, useState } from "react";
import { lifeEventSchema } from "@/lib/birth-time-journey";
import type { LifeEvent } from "@/lib/birth-time-evidence";
import { ErrorToast } from "@/components/error-toast";
import { RECTIFICATION_POLICY } from "@/lib/rectification-policy";
type EventDraft = {
readonly rowId: string;
@@ -27,7 +28,7 @@ const domainOptions = [
{ value: "health_pressure", label: "健康、事故或低谷" },
] as const;
const initialDomains = ["education", "career", "relationship"] as const;
const initialDomains = ["education", "career", "relationship", "relocation"] as const;
function initialDrafts(events: readonly LifeEvent[]): readonly EventDraft[] {
if (events.length > 0) {
@@ -107,7 +108,7 @@ export function BirthTimeLifeEvents({
}
function removeDraft(rowId: string) {
setDrafts((current) => current.length <= 3
setDrafts((current) => current.length <= RECTIFICATION_POLICY.minConfirmationEvents
? current
: current.filter((draft) => draft.rowId !== rowId));
}
@@ -124,8 +125,8 @@ export function BirthTimeLifeEvents({
return;
}
const events = parsed.flatMap((item) => item.success ? [item.data] : []);
if (new Set(events.map((event) => event.domain)).size < 2) {
setError("请至少选择两个不同领域的经历,以便区分候选时间。");
if (new Set(events.map((event) => event.domain)).size < RECTIFICATION_POLICY.minConfirmationDomains) {
setError("请至少选择三个不同领域的经历,以便区分候选时间。");
return;
}
setError("");
@@ -139,7 +140,7 @@ export function BirthTimeLifeEvents({
<span>{drafts.length} / 6</span>
</div>
<p className="birth-time-evidence-note">
请填写至少三条、覆盖两个领域的经历。只使用日期和类型评分,不会从描述中猜测。
请填写至少四条、覆盖三个领域的经历。只使用日期和类型评分,不会从描述中猜测。
</p>
<div className="birth-time-event-list">
{drafts.map((draft, index) => (
@@ -4,7 +4,8 @@ import {
CONVERGENCE_LEAD,
CONVERGENCE_TOP_SHARE,
DEFAULT_MAX_DISCRIMINATION_ROUNDS,
MIN_TRAINING_EVENTS,
MIN_DATED_DOMAINS,
MIN_DATED_EVENTS,
STABLE_WINNER_ROUNDS,
type InferenceCandidate,
type InferenceEvent,
@@ -42,7 +43,8 @@ export function evaluateConvergence(state: Pick<
const active = rankActive(state.candidates);
const top = active[0] ?? null;
const runnerUp = active[1] ?? null;
const trainingCount = state.events.filter((item) => item.usage === "training").length;
const dated = state.events.filter((item) => item.usage === "training" || item.usage === "holdout");
const datedDomains = new Set(dated.map((item) => item.domain));
const unionRange = unionStillValidRange(state.candidates) ?? state.credible_range;
const equivalent = Boolean(
unionRange
@@ -64,7 +66,7 @@ export function evaluateConvergence(state: Pick<
const stable = winnerStable(state.rounds, top?.id ?? null);
const noCriticalConflict = (top?.strong_conflict_count ?? 0) === 0;
const holdoutPassed = state.holdout_passed;
const sufficient = trainingCount >= MIN_TRAINING_EVENTS;
const sufficient = dated.length >= MIN_DATED_EVENTS && datedDomains.size >= MIN_DATED_DOMAINS;
if (equivalent) {
return {
@@ -18,6 +18,8 @@ import { EFFECTIVE_ANSWER_SAFETY_CAP } from "../../birth-time-dynamic-stop-polic
import { RECTIFICATION_POLICY } from "../../rectification-policy.ts";
import {
DEFAULT_MAX_DISCRIMINATION_ROUNDS,
MIN_DATED_DOMAINS,
MIN_DATED_EVENTS,
type RectificationPhase,
type ResultStatus,
} from "./types.ts";
@@ -105,9 +107,9 @@ export function engineCapabilityCeilingFromReceipt(value: unknown): EngineCapabi
export const RECTIFICATION_TERMINATION_COPY = "当前最优结果是候选时间段,而不是已经确认的唯一出生分钟。临时代表时间仅用于下一轮验证与比较。";
/** Standalone range-delivery floor; the exact-minute confirmation gate remains 4/3. */
export const MIN_STANDALONE_DATED_EVENTS = 3;
export const MIN_STANDALONE_DATED_DOMAINS = 2;
/** Standalone range-delivery floor (R1: 4 dated events / 3 domains); same source as the confirmation gate. */
export const MIN_STANDALONE_DATED_EVENTS = MIN_DATED_EVENTS;
export const MIN_STANDALONE_DATED_DOMAINS = MIN_DATED_DOMAINS;
export type DecisionSessionOutcome =
| "collect_evidence"
@@ -5,13 +5,22 @@
* probe, assign scores, eliminate candidates, or declare convergence.
*/
import { RECTIFICATION_POLICY } from "../../rectification-policy.ts";
export const INFERENCE_ALGORITHM_VERSION = "rectification-inference-v1";
export const HIGH_INFORMATION_GAIN = 0.08;
export const DEFAULT_MAX_DISCRIMINATION_ROUNDS = 8;
export const CONVERGENCE_LEAD = 0.2;
export const CONVERGENCE_TOP_SHARE = 0.7;
export const STABLE_WINNER_ROUNDS = 2;
export const MIN_TRAINING_EVENTS = 3;
/**
* Range-delivery evidence floor (R1, 2026-10-02, BUG-1193): at least 4 dated,
* primary-scoreable events across 3 domains, counted on all of them (training
* plus the reserved holdout). The only source is
* `references/rectification_policy.v1.json`; Python reads the same file.
*/
export const MIN_DATED_EVENTS: number = RECTIFICATION_POLICY.minConfirmationEvents;
export const MIN_DATED_DOMAINS: number = RECTIFICATION_POLICY.minConfirmationDomains;
export const STRONG_CONFLICT_ELIMINATION_COUNT = 3;
export type RectificationPhase =
@@ -6,7 +6,12 @@
import { rangeDeliveryCollectClosed, USER_COLLECT_QUESTION } from "../user-copy.ts";
import { canonicalCollectDomain } from "./domain-alias.ts";
import { trainingScoreableGate } from "./evidence-model.ts";
import {
isPrimaryScoreableEvidence,
MIN_ACCEPTANCE_DOMAINS,
MIN_ACCEPTANCE_EVENTS,
trainingScoreableGate,
} from "./evidence-model.ts";
import { hasDatedTransition, signFromTransitions, validDatedTransitions, type TransitionSignLookup } from "../core/sign-from-transitions.ts";
export const COLLECT_KIND_ORDER = [
@@ -459,10 +464,39 @@ export function preciseGapNarration(
: covered.size > 1
? ""
: "";
const needOther = covered.size === 1
? `再来一件不是${KIND_LABEL[[...covered][0]]}的、记得大概年月的事就能开始筛,比如${exampleText}。`
: `再来一件记得大概年月的事就能开始筛,比如${exampleText}。`;
return `${recorded}${sameKind}${needOther}`;
return `${recorded}${sameKind}${evidenceGapAsk(evidence, covered)}比如${exampleText}。`;
}
const COUNT_WORD = ["零", "一", "两", "三", "四", "五", "六"] as const;
function countWord(value: number): string {
return COUNT_WORD[value] ?? String(value);
}
/**
* R1 (BUG-1193): name the exact gap to the 4-event / 3-domain floor instead
* of always asking for "one more". Counts follow trainingScoreableGate.
*/
function evidenceGapAsk(
evidence: readonly CollectionEvidence[],
covered: ReadonlySet<CollectKind>,
): string {
const primary = evidence.filter(isPrimaryScoreableEvidence);
const domains = new Set(primary.map((item) => item.domain));
const missingEvents = Math.max(0, MIN_ACCEPTANCE_EVENTS - primary.length);
const missingDomains = Math.max(0, MIN_ACCEPTANCE_DOMAINS - domains.size);
const total = Math.max(1, missingEvents, missingDomains);
const labels = [...covered].map((kind) => KIND_LABEL[kind]).join("或");
if (missingDomains === 0 || !labels) {
const spread = missingDomains > 1 ? `、至少涉及${countWord(missingDomains)}个方面` : "";
return `再来${countWord(total)}件记得大概年月的事${spread}${spread ? "," : ""}就能开始筛,`;
}
if (missingDomains === total) {
return total === 1
? `再来一件不是${labels}的、记得大概年月的事就能开始筛,`
: `再来${countWord(total)}件不是${labels}、彼此也不同类的、记得大概年月的事就能开始筛,`;
}
return `再来${countWord(total)}件记得大概年月的事,其中至少${countWord(missingDomains)}件不是${labels}的,就能开始筛,`;
}
export function moreCollectHint(
@@ -813,7 +813,7 @@ function evidenceStopInputs(evidence: DecisionDossier["evidence"]): {
const primary = evidence.filter(isPrimaryScoreableEvidence);
return {
// The standalone delivery floor is evaluated by decideRectification;
// trainingScoreableGate is a separate 3/2 engine-readiness check.
// trainingScoreableGate applies the same 4/3 floor (R1) for engine readiness.
datedEventCount: primary.length,
datedDomainCount: new Set(primary.map((item) => item.domain)).size,
};
@@ -1105,8 +1105,9 @@ export function decideAfterInferenceChange(input: {
birthTimeSource: normalizeBirthTimeSource(input.dossier.case.birthTimeSource),
};
}
const training = input.state.events.filter((item) => item.usage === "training");
const trainingDomains = new Set(training.map((item) => item.domain));
// R1: the floor counts every dated event (training + reserved holdout), like the Python receipt.
const dated = input.state.events.filter((item) => item.usage === "training" || item.usage === "holdout");
const datedDomains = new Set(dated.map((item) => item.domain));
const evidenceStops = evidenceStopInputs(input.dossier.evidence);
const userUncertaintyHigh = uncertaintyHighFromAnswers(input.state.answered_probes);
const contrastPacket = contrastPacketFromState(input.state);
@@ -1147,8 +1148,8 @@ export function decideAfterInferenceChange(input: {
return {
...decideRectification({
methodCoverageAll: blockingMethodsCovered(collecting.methods),
trainingGateOpen: training.length >= MIN_ACCEPTANCE_EVENTS
&& trainingDomains.size >= MIN_ACCEPTANCE_DOMAINS,
trainingGateOpen: dated.length >= MIN_ACCEPTANCE_EVENTS
&& datedDomains.size >= MIN_ACCEPTANCE_DOMAINS,
candidateScores: input.state.candidates
.filter((item) => item.status !== "eliminated")
.map((item) => ({ time: item.time, score: item.posterior_score, window_index: item.window_index })),
@@ -4,6 +4,7 @@
*/
import { z } from "zod";
import { splitHoldoutEvents, type DatedEventInput } from "../core/split-holdout.ts";
import { MIN_DATED_DOMAINS, MIN_DATED_EVENTS } from "../core/types.ts";
export const EVIDENCE_KINDS = [
"education_start",
@@ -230,9 +231,12 @@ export const NON_PRIMARY_SCORING_DOMAINS: ReadonlySet<string> = new Set([
"other",
]);
/** Same floors as `scripts/rectification/decision_policy.py`. Counted on training events only. */
export const MIN_ACCEPTANCE_EVENTS = 3;
export const MIN_ACCEPTANCE_DOMAINS = 2;
/**
* Same floors as `scripts/rectification/decision_policy.py` (R1: 4 / 3).
* Counted on all dated primary-scoreable events: training plus the reserved holdout.
*/
export const MIN_ACCEPTANCE_EVENTS = MIN_DATED_EVENTS;
export const MIN_ACCEPTANCE_DOMAINS = MIN_DATED_DOMAINS;
export function isBackgroundEvidenceKind(kind: EvidenceKind): boolean {
return BACKGROUND_ONLY_KINDS.has(kind);
@@ -280,9 +284,9 @@ function yearFromIso(value: string | null): number | null {
}
/**
* Discrimination requires 3 training events / 2 training domains.
* Holdout is reserved from the 4th dated event and does not count.
* 3 collected events all stay in training.
* Discrimination and range delivery require 4 dated events across 3 domains
* (R1). The holdout is still reserved from the 4th dated event; it counts
* toward the floor but never toward scoring.
*/
export function trainingScoreableGate(evidence: readonly ScoreableEvidence[]): Readonly<{
trainingCount: number;
@@ -300,14 +304,15 @@ export function trainingScoreableGate(evidence: readonly ScoreableEvidence[]): R
}));
const split = splitHoldoutEvents(dated);
const training = split.filter((item) => item.usage === "training");
const domains = new Set(training.map((item) => item.domain));
const trainingDomains = new Set(training.map((item) => item.domain));
const holdoutCount = split.filter((item) => item.usage === "holdout").length;
const datedDomains = new Set(scoreable.map((item) => item.domain));
return {
trainingCount: training.length,
trainingDomainCount: domains.size,
trainingDomainCount: trainingDomains.size,
holdoutCount,
holdoutStatus: holdoutCount > 0 ? "reserved" : "not_reserved_min_events",
open: training.length >= MIN_ACCEPTANCE_EVENTS && domains.size >= MIN_ACCEPTANCE_DOMAINS,
open: scoreable.length >= MIN_ACCEPTANCE_EVENTS && datedDomains.size >= MIN_ACCEPTANCE_DOMAINS,
};
}
@@ -71,6 +71,16 @@ const COLLECT_EVIDENCE = [
occurredTo: null,
eventKind: "relationship_start",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
id: "e-relocation",
status: "confirmed",
domain: "relocation",
datePrecision: "month",
occurredFrom: "2018-03-01",
occurredTo: null,
eventKind: "relocation",
},
] as const;
const OPENING_SKIPPED = {
@@ -96,6 +106,8 @@ function collectDecisionDossier(declinedTopics: ReadonlyArray<Record<string, unk
{ id: "e-career-exit", domain: "career", year: 2020, precision: "month" },
{ id: "e-rel-end", domain: "relationship", year: 2024, precision: "day" },
{ id: "e-rel-start", domain: "relationship", year: 2024, precision: "month" },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e-relocation", domain: "relocation", year: 2018, precision: "month" },
],
probes: [],
});
@@ -323,6 +323,8 @@ function twoProbeInference() {
{ id: "e3", domain: "relationship", year: 2024, precision: "month" },
{ id: "e4", domain: "career", year: 2026, precision: "day" },
{ id: "e5", domain: "relationship", year: 2024, precision: "day" },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e6", domain: "finance", year: 2022, precision: "month" },
],
probes: [RELOCATION_2015_PROBE, EDUCATION_2014_PROBE],
});
@@ -400,6 +402,21 @@ function fourEventRows() {
supersedes_evidence_id: null,
created_at: "2026-08-28T07:37:02.000Z",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
id: "00000000-0000-4000-8000-0000000000f1",
source_turn_id: TURN_ID,
subject: "self",
event_kind: "finance_gain",
domain: "finance",
occurred_from: "2022-03-01",
occurred_to: null,
date_precision: "month",
summary: "2022 年 3 月拿到一笔奖金",
status: "confirmed",
supersedes_evidence_id: null,
created_at: "2026-08-28T07:37:10.000Z",
},
];
}
@@ -467,6 +484,8 @@ function familyCollectInference() {
{ id: "e3", domain: "relationship", year: 2024, precision: "month" },
{ id: "e4", domain: "career", year: 2026, precision: "day" },
{ id: "e5", domain: "relationship", year: 2024, precision: "day" },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e6", domain: "finance", year: 2022, precision: "month" },
],
probes: [RELOCATION_2015_PROBE, YEARLESS_D24_PROBE],
});
@@ -524,6 +543,8 @@ function adoptionInference() {
{ id: "e2", domain: "career", year: 2024, precision: "day" },
{ id: "e3", domain: "relationship", year: 2024, precision: "month" },
{ id: "e4", domain: "relationship", year: 2024, precision: "day" },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e5", domain: "finance", year: 2022, precision: "month" },
],
probes: [RELOCATION_2015_PROBE],
}), "yes");
@@ -1745,6 +1766,8 @@ function lastVerifyDossier() {
{ id: "e3", domain: "relationship", year: 2024, precision: "month" },
{ id: "e4", domain: "career", year: 2026, precision: "day" },
{ id: "e5", domain: "relationship", year: 2024, precision: "day" },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e6", domain: "finance", year: 2022, precision: "month" },
],
probes: [EDUCATION_2014_PROBE],
});
@@ -80,6 +80,21 @@ const EVIDENCE = [
supersedes_evidence_id: null,
created_at: "2026-09-06T00:00:02.000Z",
},
// R1(BUG-1193):补第 4 件,保持原场景(块扫描门槛 4 件 3 域)。
{
id: "e-career",
source_turn_id: TURN_ID,
subject: "self",
event_kind: "career_entry",
domain: "career",
occurred_from: "2020-04-01",
occurred_to: "2020-04-30",
date_precision: "month",
summary: "career entry",
status: "confirmed",
supersedes_evidence_id: null,
created_at: "2026-09-06T00:00:03.000Z",
},
];
function blockPayload(extra: Record<string, unknown> = {}) {
@@ -195,7 +210,8 @@ test("unknown source opens a full-day block_scan window", () => {
);
});
test("three dated events in two domains ask a block choice and never adopt", () => {
// 原值: 题名「three dated events in two domains」/ 新值: 「four dated events in three domains」/ 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),块扫描门同口径
test("four dated events in three domains ask a block choice and never adopt", () => {
const parsed = parseV9CaseDossier(blockDossier());
assert.ok(parsed);
const decision = decideFromDossier(parsed);
@@ -63,7 +63,7 @@ const CANDIDATES = [
{ id: "05:15", time: "05:15", relative_support: 6 },
] as const;
const EVIDENCE = [
const BASE_EVIDENCE = [
{
id: "e-career-entry",
status: "confirmed",
@@ -102,8 +102,22 @@ const EVIDENCE = [
},
] as const;
// R1(BUG-1193):补第 3 域,保持原场景(原 4 件 2 域在旧门槛下训练门已开)。
const EVIDENCE = [
...BASE_EVIDENCE,
{
id: "e-finance",
status: "confirmed",
domain: "finance",
datePrecision: "month",
occurredFrom: "2022-03-01",
occurredTo: null,
eventKind: "finance_gain",
},
] as const;
const LIVE_CASE_EVIDENCE = [
...EVIDENCE,
...BASE_EVIDENCE,
{
id: "e-education",
status: "confirmed",
@@ -357,6 +371,8 @@ function revision5State(extraProbes: readonly ConflictProbe[] = []) {
{ id: "e-career-exit", domain: "career", year: 2020, precision: "month" },
{ id: "e-rel-end", domain: "relationship", year: 2024, precision: "day" },
{ id: "e-rel-start", domain: "relationship", year: 2024, precision: "month" },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e-finance", domain: "finance", year: 2022, precision: "month" },
],
probes,
});
@@ -477,7 +493,9 @@ test("revision 5 with uncovered relatives asks the dated family collect, not a y
const state = revision5State();
assert.equal(state.revision, 5);
assert.equal(state.answered_probes.length, 4);
assert.equal(state.events.find((item) => item.id === "e-rel-start")?.usage, "holdout");
// 原值: e-rel-start 为 holdout / 新值: 补的单件领域 e-finance 为 holdout(按领域分层留出单件域)/ 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),夹具补第 3 域
assert.equal(state.events.find((item) => item.id === "e-finance")?.usage, "holdout");
assert.equal(state.events.find((item) => item.id === "e-rel-start")?.usage, "training");
const unanswered = state.probes.filter((probe) => (
!state.answered_probes.some((item) => item.probe_id === probe.id)
));
@@ -1290,6 +1308,16 @@ test("yearless varga in another domain stays behind uncovered-method spoken coll
occurredTo: null,
eventKind: "education_start",
},
// R1(BUG-1193):补第 4 件,保持原场景(训练门已开)。
{
id: "e-career-2",
status: "confirmed",
domain: "career",
datePrecision: "year" as const,
occurredFrom: "2022-01-01",
occurredTo: null,
eventKind: "career_change",
},
{
id: "e-job",
status: "confirmed",
@@ -163,7 +163,17 @@ test("targeted collect names remaining split layers without inferred years", ()
// 原值: evidence = [educationStart, educationEnd, career](3 件 2 类,训练门已开)
// 新值: 毕业那件改成日期不明(不进训练门),门未开、覆盖的领域不变;门开的原夹具另断言池为空
// 原因: 门开后定向池恒空(BUG-1084,2026-09-29 D1);池本身的规则仍在门前生效,用门前夹具继续锁住
assert.deepEqual(targetedCollectPool(layers, [educationStart, educationEnd, career], [], ["04:48", "05:07"], 4), []);
// R1(BUG-1193):门开夹具补第 4 件 / 第 3 域(搬家),保持「门开后池为空」原场景。
const relocation = {
status: "confirmed",
domain: "relocation",
datePrecision: "month",
occurredFrom: "2022-07-01",
occurredTo: null,
eventKind: "relocation",
summary: "搬到外地",
} as const;
assert.deepEqual(targetedCollectPool(layers, [educationStart, educationEnd, career, relocation], [], ["04:48", "05:07"], 4), []);
const evidence = [educationStart, { ...educationEnd, datePrecision: "unknown", occurredFrom: null, occurredTo: null }, career];
const splitTimes = ["04:48", "05:07"] as const;
const pool = targetedCollectPool(layers, evidence, [], splitTimes, 4);
@@ -134,6 +134,8 @@ function inferenceState(
{ id: "e1", domain: "career", year: 2011, precision: "year", usage: "training" },
{ id: "e2", domain: "relationship", year: 2012, precision: "year", usage: "training" },
{ id: "e3", domain: "family", year: 2013, precision: "year", usage: "training" },
// R1(BUG-1193):补第 4 件(holdout),与 dossier 的 4 条证据一致,保持原场景。
{ id: "e4", domain: "education", year: 2014, precision: "year", usage: "holdout" },
],
probes: [],
answered_probes: answers,
@@ -279,8 +281,11 @@ test("additional score evidence never widens the credible range", () => {
test("insufficient standalone evidence keeps collecting", () => {
for (const item of [
{ reason: "insufficient_dated_events" as const, input: { datedEventCount: 2, datedDomainCount: 2 } },
{ reason: "insufficient_domains" as const, input: { datedEventCount: 3, datedDomainCount: 1 } },
// 原值: {2 件/2 域}→insufficient_dated_events,{3 件/1 域}→insufficient_domains
// 新值: {3 件/3 域}→insufficient_dated_events,{4 件/2 域}→insufficient_domains
// 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),两个分支各取门槛下方一格
{ reason: "insufficient_dated_events" as const, input: { datedEventCount: 3, datedDomainCount: 3 } },
{ reason: "insufficient_domains" as const, input: { datedEventCount: 4, datedDomainCount: 2 } },
]) {
const decision = decideRectification({ ...BASE_INPUT, ...item.input });
assert.equal(decision.nextAction, "ask_fact_collection");
@@ -298,8 +303,8 @@ test("exhausted evidence-state stops complete with a usable range and the fixed
{
reason: "tied_first",
input: {
datedEventCount: 3,
datedDomainCount: 2,
datedEventCount: 4, // R1(BUG-1193):门槛上 3/2 → 4/3,保持原场景。
datedDomainCount: 3,
candidateScores: [
{ time: "05:00", score: 34 },
{ time: "05:06", score: 34 },
@@ -310,7 +315,7 @@ test("exhausted evidence-state stops complete with a usable range and the fixed
},
{
reason: "user_uncertainty_too_high",
input: { datedEventCount: 3, datedDomainCount: 2, userUncertaintyHigh: true },
input: { datedEventCount: 4, datedDomainCount: 3, userUncertaintyHigh: true }, // R1(BUG-1193):3/2 → 4/3
},
];
@@ -355,8 +360,8 @@ test("stale snapshots cannot complete or adopt an evidence-stop range", () => {
test("an exact first-place tie is distinct from a narrow 34/33/33 lead", () => {
const narrowLead = decideRectification({
...BASE_INPUT,
datedEventCount: 3,
datedDomainCount: 2,
datedEventCount: 4, // R1(BUG-1193):门槛上 3/2 → 4/3,保持原场景。
datedDomainCount: 3,
});
assert.equal(narrowLead.separation.tiedForFirst, false);
assert.equal(narrowLead.stopReason, undefined);
@@ -364,8 +369,8 @@ test("an exact first-place tie is distinct from a narrow 34/33/33 lead", () => {
const exactTie = decideRectification({
...BASE_INPUT,
datedEventCount: 3,
datedDomainCount: 2,
datedEventCount: 4, // R1(BUG-1193):门槛上 3/2 → 4/3,保持原场景。
datedDomainCount: 3,
candidateScores: [
{ time: "05:00", score: 34 },
{ time: "05:06", score: 34 },
@@ -376,9 +381,14 @@ test("an exact first-place tie is distinct from a narrow 34/33/33 lead", () => {
assert.equal(exactTie.stopReason, "tied_first");
});
test("standalone delivery floor remains separate from exact-minute confirmation", () => {
assert.equal(MIN_STANDALONE_DATED_EVENTS, 3);
assert.equal(MIN_STANDALONE_DATED_DOMAINS, 2);
test("standalone delivery floor shares the 4/3 policy with exact-minute confirmation", () => {
// 原值: MIN_STANDALONE_DATED_EVENTS=3、MIN_STANDALONE_DATED_DOMAINS=2(区间门槛低于精确分钟确认门槛)
// 新值: 4、3,且与 RECTIFICATION_POLICY 同源
// 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),只保留 rectification_policy.v1.json 一处定义
assert.equal(MIN_STANDALONE_DATED_EVENTS, 4);
assert.equal(MIN_STANDALONE_DATED_DOMAINS, 3);
assert.equal(MIN_STANDALONE_DATED_EVENTS, RECTIFICATION_POLICY.minConfirmationEvents);
assert.equal(MIN_STANDALONE_DATED_DOMAINS, RECTIFICATION_POLICY.minConfirmationDomains);
assert.equal(RECTIFICATION_POLICY.minConfirmationEvents, 4);
assert.equal(RECTIFICATION_POLICY.minConfirmationDomains, 3);
});
@@ -393,10 +403,14 @@ test("dossier wiring counts only confirmed dated primary events", () => {
]));
assert.equal(decision.stopReason, "insufficient_dated_events");
// 原值: 3 条 career(3 件 1 域)→ insufficient_domains
// 新值: 4 条只覆盖 career + relationship(4 件 2 域)→ insufficient_domains
// 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),3 件会先落到 insufficient_dated_events
const oneDomain = decideFromDossier(dossier([
evidence("career", 1),
evidence("career", 2),
evidence("career", 3),
evidence("relationship", 4),
]));
assert.equal(oneDomain.stopReason, "insufficient_domains");
});
@@ -587,8 +601,8 @@ test("rectification label ladder follows evidence state and explicit adapter sup
const continuing = decideRectification({
...BASE_INPUT,
datedEventCount: 3,
datedDomainCount: 2,
datedEventCount: 4, // R1(BUG-1193):门槛上 3/2 → 4/3,保持原场景。
datedDomainCount: 3,
});
assert.equal(rectificationLabel({ decision: continuing }), "manual_pattern_consensus");
assert.equal(rectificationLabel({
@@ -602,8 +616,8 @@ test("rectification label ladder follows evidence state and explicit adapter sup
const tied = decideRectification({
...BASE_INPUT,
datedEventCount: 3,
datedDomainCount: 2,
datedEventCount: 4, // R1(BUG-1193):门槛上 3/2 → 4/3,保持原场景。
datedDomainCount: 3,
candidateScores: [
{ time: "05:00", score: 34 },
{ time: "05:06", score: 34 },
@@ -57,6 +57,14 @@ const DATED = [
occurredFrom: "2016-01-01",
occurredTo: "2016-12-31",
},
// R1(BUG-1193):补第 4 件,保持原场景(训练门已开)。
{
status: "confirmed",
domain: "career",
datePrecision: "year",
occurredFrom: "2021-01-01",
occurredTo: "2021-12-31",
},
{
status: "confirmed",
domain: "occupation",
@@ -325,7 +325,8 @@ test("user stop skips remaining collection and holdout when candidates already e
assert.equal(stopped.validated, false);
});
test("discrimination waits for three training events after reserving holdout", () => {
// 原值: 题名「waits for three training events」/ 新值: 「waits for four dated events across three domains」/ 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193)
test("discrimination waits for four dated events across three domains after reserving holdout", () => {
const two = trainingScoreableGate([
{ id: "e1", status: "confirmed", domain: "education", datePrecision: "month", occurredFrom: "2016-09-01", occurredTo: null },
{ id: "e2", status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2020-04-01", occurredTo: null },
@@ -347,12 +348,22 @@ test("discrimination waits for three training events after reserving holdout", (
// 原值: 3 件即预留 holdout,trainingCount=2,门关,等到第 4 件才区分
// 新值: 恰好 3 件全部进训练,门开,holdout 仅 ≥4 才预留
// 原因: BUG-647 训练门与 holdout 解耦
assert.equal(three.open, true);
// 原值: three.open=true / 新值: false / 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193);3 件仍全部进训练、不留 holdout
assert.equal(three.open, false);
assert.equal(three.holdoutCount, 0);
assert.equal(three.trainingCount, 3);
// 4 件 3 域:留出 1 件 holdout 后训练 3 件,门槛按训练 + holdout 计,门开
assert.equal(four.open, true);
assert.equal(four.trainingCount, 3);
assert.equal(four.holdoutCount, 1);
// R1(BUG-1193):4 件但只有 2 域,门仍关
const fourTwoDomains = trainingScoreableGate([
{ id: "e1", status: "confirmed", domain: "career", datePrecision: "month", occurredFrom: "2016-09-01", occurredTo: null },
{ id: "e2", status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2020-04-01", occurredTo: null },
{ id: "e3", status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2022-10-01", occurredTo: null },
{ id: "e4", status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2024-08-01", occurredTo: null },
]);
assert.equal(fourTwoDomains.open, false);
assert.equal(decideNextAction({
methodCoverageAll: true,
trainingGateOpen: two.open,
@@ -360,13 +371,14 @@ test("discrimination waits for three training events after reserving holdout", (
candidateScores: TIED,
discriminatorProbe: CONTRAST_PROBE,
}).type, "ask_fact_collection");
// 原值: ask_candidate_discriminator / 新值: ask_fact_collection / 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),3 件门未开
assert.equal(decideNextAction({
methodCoverageAll: true,
trainingGateOpen: three.open,
proposeAllowed: false,
candidateScores: TIED,
discriminatorProbe: CONTRAST_PROBE,
}).type, "ask_candidate_discriminator");
}).type, "ask_fact_collection");
assert.equal(decideNextAction({
methodCoverageAll: true,
trainingGateOpen: four.open,
@@ -86,8 +86,9 @@ function decideWithEngineCeiling(
candidateScores: SEPARATED,
holdoutValidation: "passed",
confirmationAllowed: true,
datedEventCount: 3,
datedDomainCount: 2,
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
datedEventCount: 4,
datedDomainCount: 3,
...overrides,
engineCeiling,
} as Parameters<typeof decideRectification>[0]);
@@ -104,9 +105,10 @@ test("invariant 1: TypeScript delivery capabilities never exceed the engine ceil
});
test("invariant 2: insufficient dated evidence never permits selection or adoption", () => {
for (const datedEventCount of [0, 2, 3]) {
for (const datedDomainCount of [0, 1, 2]) {
if (datedEventCount >= 3 && datedDomainCount >= 2) continue;
// 原值: 事件 [0,2,3] × 领域 [0,1,2],跳过 ≥3 件且 ≥2 域 / 新值: 事件 [0,2,3,4] × 领域 [0,1,2,3],跳过 ≥4 件且 ≥3 域(3 件 2 域现在也必须挡住) / 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193)
for (const datedEventCount of [0, 2, 3, 4]) {
for (const datedDomainCount of [0, 1, 2, 3]) {
if (datedEventCount >= 4 && datedDomainCount >= 3) continue;
const decision = decideWithEngineCeiling(ENGINE_OPEN, {
confirmationAllowed: false,
datedEventCount,
@@ -221,7 +221,8 @@ test("tied first place delivers a range even when narrowing flags are still open
candidateScores: TIED_CANDIDATES.map((item) => ({ time: item.time, score: item.relativeSupport })),
discriminatorProbe: null,
holdoutValidation: "unavailable",
datedEventCount: 3,
// R1(BUG-1193):补第 4 件,保持原场景。
datedEventCount: 4,
datedDomainCount: 3,
refreshExhausted: false,
targetedCollectExhausted: true,
@@ -184,6 +184,16 @@ const EVIDENCE = [
occurredTo: null,
eventKind: "relationship_end",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
id: "e-move-2016",
status: "confirmed",
domain: "relocation",
datePrecision: "month",
occurredFrom: "2016-09-01",
occurredTo: null,
eventKind: "relocation",
},
] as const;
function contrastFromConflict(probe: ConflictProbe): CandidateDiscriminatorProbe {
@@ -219,6 +229,8 @@ function deadlockDossier(): { dossier: DecisionDossier; state: ReturnType<typeof
{ id: "e-career-exit", domain: "career", year: 2020, precision: "month" },
{ id: "e-rel-start", domain: "relationship", year: 2024, precision: "month" },
{ id: "e-rel-end", domain: "relationship", year: 2024, precision: "day" },
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{ id: "e-move-2016", domain: "relocation", year: 2016, precision: "month" },
],
probes: [CAREER_2020_04, REL_2024_05, D24, D12, D9_STYLE_NO_OPTIONS, D10_STYLE_NO_OPTIONS],
answered_probes: [
@@ -392,6 +404,8 @@ test("clock-key varga_style without signs fail-closes to dated family collect in
{ id: "e-career-exit", domain: "career", year: 2020, precision: "month" },
{ id: "e-rel-start", domain: "relationship", year: 2024, precision: "month" },
{ id: "e-rel-end", domain: "relationship", year: 2024, precision: "day" },
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{ id: "e-move-2016", domain: "relocation", year: 2016, precision: "month" },
],
probes: [CAREER_2020_04, REL_2024_05, D24, D12, d9Clock, d10Clock],
answered_probes: [
@@ -312,6 +312,17 @@ const careerEvidence = {
created_at: "2026-08-12T10:00:09.000Z",
};
// R1(BUG-1193):第 4 件带日期经历(与 careerEvidence 同领域),让原 3 件 3 域的场景跨过 4 件 3 域门槛。
const careerChangeEvidence = {
...careerEvidence,
id: "44444444-4444-4444-8444-4444444444c2",
event_kind: "career_change",
occurred_from: "2022-03-01",
date_precision: "month",
summary: "2022年3月换工作",
created_at: "2026-08-12T10:00:10.000Z",
};
const methodCoverageTieEvidence = [
{ ...educationEvidence, domain: "education" },
{
@@ -899,7 +910,8 @@ test("read-case follows method plan and keeps D9/D10 type tables when SQL missin
const accounting = fakeAccounting({
...receiptHandlers,
get_agentic_rectification_case_dossier: () => dossierFixture({
evidence: [educationEvidence, familyEvidence, careerEvidence],
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
evidence: [educationEvidence, familyEvidence, careerEvidence, careerChangeEvidence],
conversationSummary: {
confirmed_evidence_summary: [],
pending_revisions: [],
@@ -1565,8 +1577,9 @@ test("public tool surface stays at 14 and new cases bind 10.0.26", () => {
engineCeiling: OPEN_ENGINE_CAPABILITY_CEILING,
methodCoverageAll: true,
trainingGateOpen: true,
datedEventCount: 3,
datedDomainCount: 2,
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
datedEventCount: 4,
datedDomainCount: 3,
candidateScores: exhaustedCandidates.map((item) => ({
time: item.time,
score: item.relativeSupport,
@@ -1775,7 +1788,11 @@ test("precision stage d4 asks home change not family, and d5 asks education", ()
});
assert.notEqual(legacyTheme.next_followup?.intent, "distinguish_candidates");
const d5 = buildMethodFollowupPlan({
evidence: covered.filter((item) => item.domain !== "education"),
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景(去掉学业后仍过门槛)。
evidence: [
...covered.filter((item) => item.domain !== "education"),
{ status: "confirmed" as const, domain: "relocation", datePrecision: "year" as const, occurredFrom: "2015-01-01", occurredTo: null },
],
precisionStage: "d5_refine",
});
// 原值: 训练门开后不再为未覆盖学业轮转采集
@@ -1964,6 +1981,8 @@ test("d9_refine after relationship still asks uncovered career first", () => {
{ status: "confirmed", domain: "education", datePrecision: "month", occurredFrom: "2020-06-01", occurredTo: null },
{ status: "confirmed", domain: "relationship", datePrecision: "day", occurredFrom: "2024-05-01", occurredTo: null },
{ status: "confirmed", domain: "relationship", datePrecision: "day", occurredFrom: "2024-08-08", occurredTo: null },
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景(事业仍未覆盖)。
{ status: "confirmed", domain: "relocation", datePrecision: "month", occurredFrom: "2012-08-01", occurredTo: null },
],
precisionStage: "d9_refine",
});
@@ -2852,6 +2871,8 @@ test("three dated events with one holdout keep collecting instead of discriminat
datedEvidence("education", "2016"),
datedEvidence("career", "2020"),
datedEvidence("relationship", "2024"),
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景(训练仍是 3 件,门开)。
datedEvidence("relocation", "2012"),
{
status: "confirmed" as const,
domain: "occupation",
@@ -2867,7 +2888,8 @@ test("three dated events with one holdout keep collecting instead of discriminat
// 原因: BUG-647
assert.equal(gate.open, true);
assert.equal(gate.trainingCount, 3);
assert.equal(gate.holdoutCount, 0);
// 原值: holdoutCount=0(3 件全训练) / 新值: 1(补的第 4 件起留 1 件 holdout,训练仍 3 件,BUG-647 的「holdout 不饿死训练」不变) / 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193)
assert.equal(gate.holdoutCount, 1);
const plan = buildMethodFollowupPlan({
evidence,
declinedTopics: [{ target_domain: "family", status: "declined" }],
@@ -3141,12 +3163,13 @@ test("offer-candidates may proceed once method coverage leftover collect is clos
const accounting = fakeAccounting({
...receiptHandlers,
get_agentic_rectification_case_dossier: () => dossierFixture({
evidence: [educationEvidence, relationshipEvidence, familyEvidence],
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
evidence: [educationEvidence, relationshipEvidence, familyEvidence, careerEvidence],
latestResult: candidateSnapshotFixture({
selectionAllowed: true,
representativeTime: "04:48",
evidenceLedgerFingerprint: scoreableFingerprintForRawEvidence(
[educationEvidence, relationshipEvidence, familyEvidence],
[educationEvidence, relationshipEvidence, familyEvidence, careerEvidence],
),
candidates: [
{ candidate_id: CANDIDATE_ID, rank: 1, time: "04:48", relative_support: 58, tied_minute_count: 1 },
@@ -259,7 +259,8 @@ test("D2 the skip re-ask and a pending year answer still hold the card", () => {
const yesOnWindow = [askedWindow(2019, 4, 6, "resolved")];
assert.equal(cardHoldingLinesExhausted(LAYERS, ALL_SEVEN, yesOnWindow, ["05:00", "05:15"], 3), false);
// Targeted lines still open: keep asking.
assert.equal(cardHoldingLinesExhausted(LAYERS, ALL_SEVEN.slice(0, 3), [], ["05:00", "05:15"], 3), true);
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景(门开、定向线未问完)。slice(0, 3) → slice(0, 4)。
assert.equal(cardHoldingLinesExhausted(LAYERS, ALL_SEVEN.slice(0, 4), [], ["05:00", "05:15"], 3), true);
// Before the training gate the re-ask still holds the card.
assert.equal(cardHoldingLinesExhausted(LAYERS, [], skipped, ["05:00", "05:15"], 3), false);
});
@@ -59,11 +59,13 @@ import {
const INVITE = /再补一件|补一件|再说一件|再对照几件经历|记得的人生经历|吻合率/;
/** Three scoreable events in two domains open the training gate (holdout needs a fourth). */
/** Four scoreable events in three domains open the training gate (R1, BUG-1193; the fourth is reserved as holdout). */
const GATE_OPEN: CollectionEvidence[] = [
{ status: "confirmed", domain: "education", datePrecision: "month", occurredFrom: "2012-06-01", occurredTo: null, eventKind: "education_completion" },
{ status: "confirmed", domain: "career", datePrecision: "month", occurredFrom: "2016-09-01", occurredTo: null, eventKind: "career_entry" },
{ status: "confirmed", domain: "career", datePrecision: "month", occurredFrom: "2019-10-01", occurredTo: null, eventKind: "career_change" },
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{ status: "confirmed", domain: "relocation", datePrecision: "month", occurredFrom: "2014-08-01", occurredTo: null, eventKind: "relocation" },
];
function skippedOnce(domain: CollectKind) {
@@ -228,9 +228,18 @@ test("dated occupation collect raises the training gate by one career event", ()
occurredFrom: "2020-06-01",
occurredTo: "2020-06-30",
eventKind: "education_completion",
}, {
// R1(BUG-1193):补第 3 件 / 第 2 域,让职业那一件仍是开门的最后一件(4 件 3 域)。
status: "confirmed" as const,
domain: "relocation",
datePrecision: "month" as const,
occurredFrom: "2018-07-01",
occurredTo: "2018-07-31",
eventKind: "relocation",
}];
const before = trainingScoreableGate(education);
assert.equal(before.trainingCount, 2);
// 原值: 2 / 新值: 3(补了一件搬家) / 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193)
assert.equal(before.trainingCount, 3);
assert.equal(before.open, false);
const remapped = applyOccupationCollectLedgerNorm(OCCUPATION_FOCUS, [datedOccupationInput()]);
const after = trainingScoreableGate([
@@ -244,7 +253,11 @@ test("dated occupation collect raises the training gate by one career event", ()
eventKind: item.eventKind,
})),
]);
assert.equal(after.trainingCount, before.trainingCount + 1);
// 原值: after.trainingCount === before.trainingCount + 1(3 件全训练)
// 新值: 训练 + holdout === before + 1,holdoutCount === 1(第 4 件起留 1 件 holdout,训练仍 3 件)
// 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193);门槛按训练 + holdout 计,职业那一件仍是开门的一件
assert.equal(after.trainingCount + after.holdoutCount, before.trainingCount + 1);
assert.equal(after.holdoutCount, 1);
assert.equal(after.trainingDomainCount, 2);
assert.equal(after.open, true);
});
@@ -62,6 +62,17 @@ const DATED_EVIDENCE = [
eventKind: "relocation",
summary: "搬家",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
id: "evidence-career-change",
status: "confirmed",
domain: "career",
datePrecision: "month",
occurredFrom: "2022-03-01",
occurredTo: null,
eventKind: "career_change",
summary: "换工作",
},
] as const;
function declineAllTargeted() {
@@ -110,6 +121,8 @@ function inference(overrides: Partial<InferenceState> = {}): InferenceState {
{ id: "e1", domain: "career", year: 2020, precision: "month", usage: "training" },
{ id: "e2", domain: "education", year: 2016, precision: "month", usage: "training" },
{ id: "e3", domain: "relocation", year: 2018, precision: "month", usage: "training" },
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{ id: "e4", domain: "career", year: 2022, precision: "month", usage: "holdout" },
],
probes: [],
answered_probes: [],
@@ -109,7 +109,18 @@ const careerLeave = {
eventKind: "career_exit",
summary: "2020年10月离职",
};
const EVIDENCE = [educationStart, educationEnd, careerIntern, careerLeave];
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
const relocationMove = {
id: "e-relocation",
status: "confirmed" as const,
domain: "relocation",
datePrecision: "month" as const,
occurredFrom: "2018-07-01",
occurredTo: null,
eventKind: "home_change",
summary: "2018年7月搬家",
};
const EVIDENCE = [educationStart, educationEnd, careerIntern, careerLeave, relocationMove];
function uuidAt(index: number) {
return `00000000-0000-4000-8000-${String(index + 1).padStart(12, "0")}`;
@@ -282,6 +293,8 @@ function liveState(answeredCount: number) {
{ id: educationEnd.id, domain: "education", year: 2020, precision: "month" as const, usage: "training" as const },
{ id: careerIntern.id, domain: "career", year: 2020, precision: "month" as const, usage: "training" as const },
{ id: careerLeave.id, domain: "career", year: 2020, precision: "month" as const, usage: "holdout" as const },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: relocationMove.id, domain: "relocation", year: 2018, precision: "month" as const, usage: "training" as const },
],
probes,
answered_probes: answered.map((probe) => ({
@@ -834,7 +847,8 @@ test("T4: exhausted refresh and declined targeted collect titles the card 目前
// 原因: BUG-654 卡片不得把当前范围写成结束
assert.equal(RECTIFICATION_USER_COPY.rangeDeliveryTitle, "目前范围");
const title = `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${delivery.range?.[0]}–${delivery.range?.[1]}(对照了 ${delivery.event_count} 件经历)`;
assert.match(title, /^目前范围 04:48–05:07(对照了 4 件经历)$/);
// 原值: 对照了 4 件经历 / 新值: 对照了 5 件经历 / 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),夹具补了第 3 域的一件搬家
assert.match(title, /^目前范围 04:48–05:07(对照了 5 件经历)$/);
assert.doesNotMatch(title, /这次给出|最终|结束| · /);
assert.match(delivery.narrow_hint ?? "", /现在还剩 04:48–05:07 里 6 个候选/);
// 原值: 收口改为不限领域的补充邀请
@@ -115,6 +115,17 @@ const EVIDENCE = [
eventKind: "relationship_end",
summary: "2024-08-08 relationship_end",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
id: "e-edu-start",
status: "confirmed" as const,
domain: "education",
datePrecision: "month" as const,
occurredFrom: "2015-09-01",
occurredTo: null,
eventKind: "education_start",
summary: "2015-09-01 education_start",
},
] as const;
const DUAL_EXIT = "可以先按当前区间看盘,也可以再补一件记得时间的经历";
@@ -290,6 +301,8 @@ function liveState(remaining: readonly ConflictProbe[]): InferenceState {
{ id: "e-career-exit", domain: "career", year: 2020, precision: "month" as const, usage: "training" as const },
{ id: "e-rel-start", domain: "relationship", year: 2024, precision: "month" as const, usage: "training" as const },
{ id: "e-rel-end", domain: "relationship", year: 2024, precision: "day" as const, usage: "training" as const },
// R1(BUG-1193):补第 3 域,保持原场景。
{ id: "e-edu-start", domain: "education", year: 2015, precision: "month" as const, usage: "training" as const },
],
probes,
answered_probes: answered,
@@ -44,6 +44,16 @@ const LEDGER = [
eventKind: "relationship_start",
summary: "确定关系",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
status: "confirmed",
domain: "relocation",
datePrecision: "month",
occurredFrom: "2018-07-01",
occurredTo: null,
eventKind: "relocation",
summary: "搬到外地",
},
] as const;
function contrastProbe(layer: "d9" | "d10") {
@@ -82,6 +82,16 @@ function planInput(askedProbeKeys: readonly string[] = []) {
eventKind: "relationship_start",
summary: "确定关系",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
status: "confirmed",
domain: "relocation",
datePrecision: "month",
occurredFrom: "2018-07-01",
occurredTo: null,
eventKind: "relocation",
summary: "搬到外地",
},
],
declinedTopics: [],
sessionOutcome: "discriminate_candidates" as const,
@@ -113,7 +123,8 @@ function tiedDecision(overrides: Partial<Parameters<typeof decideRectification>[
],
discriminatorProbe: null,
holdoutValidation: "unavailable",
datedEventCount: 3,
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
datedEventCount: 4,
datedDomainCount: 3,
targetedCollectExhausted: true,
refreshExhausted: true,
@@ -134,7 +145,8 @@ function convergingDecision(overrides: Partial<Parameters<typeof decideRectifica
],
discriminatorProbe: null,
holdoutValidation: "passed",
datedEventCount: 3,
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
datedEventCount: 4,
datedDomainCount: 3,
targetedCollectExhausted: true,
refreshExhausted: true,
@@ -348,6 +360,15 @@ test("range copy omits declined lines and closes when none remain", () => {
occurredTo: null,
eventKind: "relocation",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
status: "confirmed",
domain: "education",
datePrecision: "month",
occurredFrom: "2020-06-01",
occurredTo: null,
eventKind: "education_milestone",
},
];
const declined = [
{ questionId: "collect:targeted:relationship", status: "declined", target_kind: "targeted:relationship" },
@@ -62,8 +62,9 @@ function tiedInput(overrides: Partial<Parameters<typeof decideRectification>[0]>
trainingGateOpen: true,
candidateScores: TIED_THREE.map((item) => ({ time: item.time, score: item.score })),
holdoutValidation: "unavailable" as const,
datedEventCount: 3,
datedDomainCount: 2,
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
datedEventCount: 4,
datedDomainCount: 3,
inferenceCredibleRange: OPENING,
openingCandidateRange: OPENING,
...overrides,
@@ -110,7 +111,8 @@ test("tied first place with no probe and targeted collect exhausted delivers a r
test("a live first-place tie with remaining probes does not announce adopt_representative", () => {
const decision = decideRectification(tiedInput({
discriminatorProbe: DATED_PROBE,
datedEventCount: 3,
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
datedEventCount: 4,
targetedCollectExhausted: false,
refreshExhausted: false,
}));
@@ -184,6 +184,17 @@ const DATED_EVIDENCE = [
eventKind: "relocation",
summary: "2015年搬家",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景(PERSIST_EVIDENCE 由 3 件变 4 件)。
{
id: "e-promo",
status: "confirmed" as const,
domain: "career",
datePrecision: "month" as const,
occurredFrom: "2022-03-01",
occurredTo: null,
eventKind: "promotion",
summary: "2022年3月升职",
},
];
const PERSIST_EVIDENCE = DATED_EVIDENCE.filter((row) => row.domain !== "relationship");
@@ -1032,6 +1032,21 @@ test("delivery persist keeps three sentences when the model writes four", async
supersedes_evidence_id: null,
created_at: "2026-08-12T10:00:06.000Z",
},
// R1(BUG-1193):补第 4 件 / 第 3 域,保持原场景。
{
id: "e-promo",
source_turn_id: TURN_ID,
subject: "self",
event_kind: "promotion",
domain: "career",
occurred_from: "2019-03-01",
occurred_to: null,
date_precision: "month",
summary: "2019年3月升职",
status: "confirmed",
supersedes_evidence_id: null,
created_at: "2026-08-12T10:00:06.000Z",
},
],
}),
get_agentic_rectification_case_compute: () => computeFixture(),
+13 -8
View File
@@ -26,13 +26,16 @@ from scripts.rectification_policy import (
MIN_CONFIRMATION_MARGIN_PERCENT,
)
POLICY_VERSION = "rectification-candidate-policy-v3"
POLICY_VERSION = "rectification-candidate-policy-v4"
RECEIPT_VERSION = "candidate-decision-receipt-v2"
EXECUTION_LEDGER_VERSION = "rectification-execution-ledger-v2"
SCORE_QUANTUM = Decimal("0.0001")
TIE_ABSOLUTE_TOLERANCE = Decimal("0.0001")
MIN_ACCEPTANCE_EVENTS = 3
MIN_ACCEPTANCE_DOMAINS = 2
# R1 (2026-10-02, BUG-1193): a range is accepted only with at least 4 dated
# scoreable events across 3 domains, counted on all of them (training + the
# reserved holdout). Single definition: references/rectification_policy.v1.json.
MIN_ACCEPTANCE_EVENTS = MIN_CONFIRMATION_EVENTS
MIN_ACCEPTANCE_DOMAINS = MIN_CONFIRMATION_DOMAINS
MIN_DATE_QUALITY_MEAN = Decimal("0.65")
MIN_DIAGNOSTIC_RETENTION = Decimal("0.75")
MIN_ACCEPTANCE_MARGIN_PERCENT = Decimal("10")
@@ -543,17 +546,19 @@ def build_decision_receipt(
if str(event.get("id") or "") not in holdout
]
domains = sorted({event["domain"] for event in training_events})
scoreable_domains = sorted({event["domain"] for event in scoreable_events})
candidate_presence = _gate(bool(candidate_decisions), candidate_count=len(candidate_decisions))
event_quality = _gate(
len(training_events) >= MIN_ACCEPTANCE_EVENTS,
scoreable_event_count=len(training_events),
len(scoreable_events) >= MIN_ACCEPTANCE_EVENTS,
scoreable_event_count=len(scoreable_events),
training_event_count=len(training_events),
minimum=MIN_ACCEPTANCE_EVENTS,
)
domain_diversity = _gate(
len(domains) >= MIN_ACCEPTANCE_DOMAINS,
scoreable_domain_count=len(domains),
len(scoreable_domains) >= MIN_ACCEPTANCE_DOMAINS,
scoreable_domain_count=len(scoreable_domains),
minimum=MIN_ACCEPTANCE_DOMAINS,
domains=domains,
domains=scoreable_domains,
)
date_quality = _date_quality(training_events)
top_tied_count = candidate_decisions[0]["tied_minute_count"] if candidate_decisions else 0
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -226,7 +226,7 @@ def test_kp_only_missing_does_not_block_propose_or_engine_grant() -> None:
assert "missing_mandatory_layers" not in receipt["confirmation_reasons"]
def test_four_events_two_domains_selects_but_does_not_propose() -> None:
def test_four_events_two_domains_neither_selects_nor_proposes() -> None:
events = [
{
"id": "00000000-0000-4000-8000-000000000001",
@@ -277,7 +277,14 @@ def test_four_events_two_domains_selects_but_does_not_propose() -> None:
"primary_secondary_margin_percent": 10.27,
},
)
assert receipt["selection_allowed"] is True
# 原值: selection_allowed=True(区间门槛 3 件 2 域,4 件 2 域可选不可提议)
# 新值: selection_allowed=False,domain_diversity 不通过,原因 insufficient_domain_diversity
# 原因: R1 生时校正交付门槛 4 件 3 域(BUG-1193),2 个领域不再给区间
assert receipt["selection_allowed"] is False
assert receipt["gates"]["event_quality"]["passed"] is True
assert receipt["gates"]["domain_diversity"]["passed"] is False
assert receipt["gates"]["domain_diversity"]["minimum"] == 3
assert "insufficient_domain_diversity" in receipt["reasons"]
assert receipt["propose_allowed"] is False
assert receipt["gates"]["exact_confirmation"]["engine_granted"] is False
assert "insufficient_confirmation_domains" in receipt["confirmation_reasons"]
+40 -5
View File
@@ -20,6 +20,16 @@ input (candidate 12:00: 8.6274 -> 8.4977), which is why the algorithm identity
was bumped; it already carries the dated-v1 receipt metadata. Never rewrite it
in place: a future scoring change adds a v3 file and freezes this one.
Current golden tests/golden/rectification_engine_memoization_v3.json
(2026-10-02, BUG-1193, upstream sync 5) was written by ``write_golden`` after
R1 raised the range floor to 4 dated events / 3 domains. Candidate scores are
identical to v2 (the ported combustion / Chara Karaka / Yogini / Shodhana
changes do not feed the event matrix; 77 v5 cases A/B byte-identical), so the
algorithm stays scoring-10. Only the decision receipt moved: policy
rectification-candidate-policy-v3 -> v4, event_quality / domain_diversity
minimum 3/2 -> 4/3, and the representative candidate UUID (its namespace
carries the policy version). v2 is frozen by sha256 below.
Do not compare that payload with a whole-structure ``==``. Cross-machine
libm / pyswisseph rounding already drifted ``margin_percent`` by 1.1e-3
(TASK-rectification-engine-memoization-fix-20260915). Equivalence of the
@@ -58,15 +68,20 @@ import scripts.rectification.scoring_service as scoring_service
import shadbala
ROOT = Path(__file__).resolve().parents[1]
GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v2.json"
GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v3.json"
PREVIOUS_GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v2.json"
PREVIOUS_GOLDEN_SHA256 = "abb15efae4d86387d930cd463b82a22fe95ccd1779e85ca6cc4cdf07a063cb73"
PREVIOUS_SOURCE_COMMIT = "57782aea8ae28f5dd165a08d221ec27dbef391f8"
HISTORICAL_GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v1.json"
HISTORICAL_GOLDEN_SHA256 = "6266e448d7dad204b264cbe8f9bcf4c36e02286794764a94edb9e2ce4d0e3015"
CURRENT_ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"
FROZEN_TODAY = date(2026, 9, 16)
TIMING_KEYS = frozenset({"column_compare_ms"})
HISTORICAL_SOURCE_COMMIT = "a8d29d1b6cc37ff865ddec6c8bccdf9aa889ee53"
# Engine code of the v2 golden; the scoring-10 label is the BUG-1181 commit on top.
SOURCE_COMMIT = "57782aea8ae28f5dd165a08d221ec27dbef391f8"
CURRENT_POLICY_VERSION = "rectification-candidate-policy-v4"
# Engine code of the v3 golden: upstream-sync5 tip before R1; the policy-v4
# receipt (R1, BUG-1193) is the commit that adds the v3 file on top.
SOURCE_COMMIT = "7fb165ecf66ba1726f2fc74ffa2353fadc65ba39"
CACHE_LAYER_KEYS = (
"ashtakavarga_result",
"shadbala_result",
@@ -250,7 +265,7 @@ def _contexts_with_layer_cache_cleared(contexts: list[dict[str, Any]]) -> list[d
def _assert_dated_payload_against_golden(actual: dict[str, Any], expected: dict[str, Any]) -> None:
"""Compare with the scoring-10 golden; identity is spelled out, not trusted."""
"""Compare with the scoring-10 / policy-v4 golden; identity is spelled out, not trusted."""
metadata = {
"candidate_window_contract": "dated-v1",
"candidate_intervals": [{"start_at": "1990-01-01T12:00", "end_at": "1990-01-01T12:02"}],
@@ -276,7 +291,7 @@ def _assert_dated_payload_against_golden(actual: dict[str, Any], expected: dict[
).encode()).hexdigest()
result_id = uuid5(NAMESPACE_URL, f"{CURRENT_ALGORITHM_VERSION}:{fingerprint}")
representative_time = golden_receipt["representative_time"]
candidate_id = uuid5(NAMESPACE_URL, f"rectification-candidate-policy-v3:{result_id}:{representative_time}")
candidate_id = uuid5(NAMESPACE_URL, f"{CURRENT_POLICY_VERSION}:{result_id}:{representative_time}")
assert golden_receipt["representative_candidate_id"] == str(candidate_id)
assert receipt["representative_candidate_id"] == str(candidate_id)
# BUG-733/985: fingerprints hash unrounded floats; do not turn the
@@ -297,6 +312,26 @@ def test_historical_scoring_8_golden_is_frozen_and_no_longer_current() -> None:
_assert_memoization_payloads(current, historical)
def test_previous_policy_v3_golden_is_frozen_with_identical_scores() -> None:
"""BUG-1193: v2 stays byte-identical; scores equal v3 (no scoring-11), only the receipt policy moved."""
raw = PREVIOUS_GOLDEN_PATH.read_bytes()
assert hashlib.sha256(raw).hexdigest() == PREVIOUS_GOLDEN_SHA256
previous = json.loads(raw)
current = json.loads(GOLDEN_PATH.read_text(encoding="utf-8"))
assert previous["source_commit"] == PREVIOUS_SOURCE_COMMIT
assert previous["candidate_feature_snapshot"]["algorithm_version"] == CURRENT_ALGORITHM_VERSION
assert current["candidate_feature_snapshot"]["algorithm_version"] == CURRENT_ALGORITHM_VERSION
_assert_tiered_equal(current["candidate_scores"], previous["candidate_scores"], path="candidate_scores")
assert previous["decision_receipt"]["policy_version"] == "rectification-candidate-policy-v3"
assert current["decision_receipt"]["policy_version"] == CURRENT_POLICY_VERSION
assert previous["decision_receipt"]["gates"]["event_quality"]["minimum"] == 3
assert current["decision_receipt"]["gates"]["event_quality"]["minimum"] == 4
assert previous["decision_receipt"]["gates"]["domain_diversity"]["minimum"] == 2
assert current["decision_receipt"]["gates"]["domain_diversity"]["minimum"] == 3
with pytest.raises(AssertionError):
_assert_memoization_payloads(current, previous)
def test_score_candidates_matches_baseline_golden() -> None:
expected = json.loads(GOLDEN_PATH.read_text(encoding="utf-8"))
actual = json.loads(json.dumps(_golden_payload(), ensure_ascii=True))
+2 -1
View File
@@ -18,7 +18,8 @@ def _row(time: str, score: float) -> dict:
class RelativeSupportScaleTest(unittest.TestCase):
def test_holdout_gate_keeps_proportional_default(self) -> None:
self.assertEqual(POLICY_VERSION, "rectification-candidate-policy-v3")
# 原值: policy-v3;新值: policy-v4;原因: R1 区间门槛 4 件 3 域(BUG-1193),相对支持口径不变。
self.assertEqual(POLICY_VERSION, "rectification-candidate-policy-v4")
# Explicit date windows: scoring identity -8 -> -9, not a prior/policy change.
# 原值: -9;新值: -10;原因: 功能吉凶 v2 改变打分(BUG-1181),策略 v3 与相对支持口径不变。
self.assertEqual(ALGORITHM_VERSION, "rectification-v5-matrix-scoring-10")
+2 -1
View File
@@ -503,7 +503,8 @@ class RectificationV5ServicesTest(unittest.TestCase):
self.assertEqual(first["decision_receipt"], receipt)
# C2 holdout 校准:offset/softmax 覆盖下降,默认仍用 proportional,policy 不 bump
self.assertEqual(first["decision_policy_version"], "rectification-candidate-policy-v3")
# 原值: policy-v3;新值: policy-v4;原因: R1 区间门槛 3 件 2 域 → 4 件 3 域(BUG-1193),policy 身份随门槛 bump
self.assertEqual(first["decision_policy_version"], "rectification-candidate-policy-v4")
self.assertTrue(receipt["display_allowed"])
self.assertTrue(receipt["accept_allowed"])
self.assertFalse(receipt["confirm_allowed"])