fix(rectification): bump scoring identity to scoring-11 after D5/D11 (BUG-1260)

This commit is contained in:
jesse-ux
2026-10-07 17:47:00 +08:00
parent 5eb11e7cd1
commit d46f9675aa
10 changed files with 6978 additions and 33 deletions
@@ -1071,7 +1071,7 @@ export async function runV9Diagnostics(input: {
// Keep the receipt default aligned with Python's ALGORITHM_VERSION; persisted
// receipts retain their original identity (this is not a Skill/open gate).
export const v9EngineVersion = (): string =>
process.env.RECTIFICATION_ENGINE_VERSION?.trim() || "rectification-v5-matrix-scoring-10";
process.env.RECTIFICATION_ENGINE_VERSION?.trim() || "rectification-v5-matrix-scoring-11";
export type V9RangeReading = Readonly<{
stableThemes: readonly string[];
File diff suppressed because it is too large Load Diff
@@ -22,13 +22,14 @@ test("dated contract is a generation threshold, not one literal", () => {
}
});
test("receipt default and Python identity agree on scoring-10", (t) => {
test("receipt default and Python identity agree on scoring-11", (t) => {
const saved = process.env.RECTIFICATION_ENGINE_VERSION;
delete process.env.RECTIFICATION_ENGINE_VERSION;
t.after(() => { if (saved === undefined) delete process.env.RECTIFICATION_ENGINE_VERSION; else process.env.RECTIFICATION_ENGINE_VERSION = saved; });
assert.equal(v9EngineVersion(), "rectification-v5-matrix-scoring-10");
// 原值: rectification-v5-matrix-scoring-10;新值: ...-scoring-11;原因: D5/D11 改变同输入分数(BUG-1260)。
assert.equal(v9EngineVersion(), "rectification-v5-matrix-scoring-11");
const python = readFileSync(new URL("../../scripts/rectification/scoring_service.py", import.meta.url), "utf8");
assert.match(python, /^ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"$/m);
assert.match(python, /^ALGORITHM_VERSION = "rectification-v5-matrix-scoring-11"$/m);
});
test("no source file compares the algorithm identity with a scoring-N literal", () => {
@@ -73,3 +74,16 @@ test("a scoring-9 history opens read-only under scoring-10 and offers a recompar
// Its candidates still parse as dated (generation >= 9), so the opened history keeps civil dates.
assert.ok(dossier.latestResult!.candidates.every((candidate) => typeof candidate.candidate_date === "string"));
});
test("a scoring-10 history opens read-only under scoring-11 and offers a recompare (BUG-621)", () => {
const historical = JSON.parse(readFileSync(new URL("./fixtures/rectification-midnight-date-anchor.delivery.scoring-10.native.json", import.meta.url), "utf8")).response;
assert.equal(historical.algorithm_version, "rectification-v5-matrix-scoring-10");
const latest = { ...historical, candidates: historical.candidate_decisions };
const dossier = parseV9CaseDossier(dossierFixture({ stage: "minute", latestResult: latest }));
assert.ok(dossier);
assert.equal(dossier.latestResult?.algorithmVersion, "rectification-v5-matrix-scoring-10");
const policyVersion = historical.decision_policy_version;
const underEleven = resultIdentityView(dossier, { algorithmVersion: "rectification-v5-matrix-scoring-11", policyVersion });
assert.deepEqual([underEleven.read_only, underEleven.can_recompare, underEleven.algorithm_version], [true, true, "rectification-v5-matrix-scoring-10"]);
assert.ok(dossier.latestResult!.candidates.every((candidate) => typeof candidate.candidate_date === "string"));
});
@@ -31,18 +31,21 @@ const golden = JSON.parse(readFileSync(new URL(
// Historical golden identity stays fixed; it must not be relabeled as the live engine.
const CURRENT = "rectification-v5-matrix-scoring-8";
const PREVIOUS = "rectification-v5-matrix-scoring-7";
// 原值: LIVE_CURRENT = "rectification-v5-matrix-scoring-9"(liveGolden 同时充当「当前版本」)
// 新值: LIVE_CURRENT = "...-scoring-10";scoring-9 的 dated golden 留作历史(DATED_HISTORICAL),
// 当前版本另有真实引擎生成的 scoring-10 dated golden(currentGolden)
// 原因: 功能吉凶 v2 改变同输入分数,按「打分语义变化必须 bump」升算法身份(BUG-1181)
const LIVE_CURRENT = "rectification-v5-matrix-scoring-10";
// 原值: LIVE_CURRENT = "rectification-v5-matrix-scoring-10";新值: "...-scoring-11";
// scoring-10 dated golden 留作历史,当前版本另有真实引擎生成的 scoring-11 golden。
// 原因: D5/D11 改变同输入分数(BUG-1260),按 BUG-1181 升算法身份。
const LIVE_CURRENT = "rectification-v5-matrix-scoring-11";
const DATED_HISTORICAL = "rectification-v5-matrix-scoring-9";
const SCORING_10 = "rectification-v5-matrix-scoring-10";
const liveGolden = JSON.parse(readFileSync(new URL(
"./fixtures/rectification-midnight-date-anchor.delivery.native.json", import.meta.url,
), "utf8"));
const currentGolden = JSON.parse(readFileSync(new URL(
const scoring10Golden = JSON.parse(readFileSync(new URL(
"./fixtures/rectification-midnight-date-anchor.delivery.scoring-10.native.json", import.meta.url,
), "utf8"));
const currentGolden = JSON.parse(readFileSync(new URL(
"./fixtures/rectification-midnight-date-anchor.delivery.scoring-11.native.json", import.meta.url,
), "utf8"));
const envKeys = [
"RECTIFICATION_ENGINE_VERSION", "RECTIFICATION_ALGORITHM_VERSION",
"RECTIFICATION_DECISION_POLICY_VERSION",
@@ -69,8 +72,9 @@ test("receipt default matches the cross-midnight native scoring version without
assert.equal(golden.score.algorithm_version, CURRENT);
assert.equal(golden.versions.algorithm_version, CURRENT);
const python = readFileSync(new URL("../../scripts/rectification/scoring_service.py", import.meta.url), "utf8");
assert.match(python, /ALGORITHM_VERSION = "rectification-v5-matrix-scoring-10"/);
assert.match(python, /ALGORITHM_VERSION = "rectification-v5-matrix-scoring-11"/);
assert.equal(liveGolden.response.algorithm_version, DATED_HISTORICAL);
assert.equal(scoring10Golden.response.algorithm_version, SCORING_10);
assert.equal(currentGolden.response.algorithm_version, LIVE_CURRENT);
const fingerprints = { evidenceLedgerFingerprint: "e".repeat(64), candidateRangeFingerprint: "c".repeat(64) };
const live = {
@@ -79,9 +83,17 @@ test("receipt default matches the cross-midnight native scoring version without
};
const historical = { ...fingerprints, algorithmVersion: CURRENT, policyVersion: golden.versions.decision_policy_version };
assert.equal(cachedEngineScoreIsReusable(historical, fingerprints, live), false);
// BUG-1181: a scoring-9 cache (old functional grouping) is not current under scoring-10.
// BUG-1181 / BUG-1260: scoring-9 and scoring-10 caches are not current under scoring-11.
assert.equal(cachedEngineScoreIsReusable({ ...historical, algorithmVersion: DATED_HISTORICAL }, fingerprints, live), false);
assert.equal(cachedEngineScoreIsReusable({ ...historical, algorithmVersion: LIVE_CURRENT }, fingerprints, live), true);
assert.equal(cachedEngineScoreIsReusable({ ...historical, algorithmVersion: SCORING_10 }, fingerprints, live), false);
// 原值: 只把 algorithmVersion 改成 LIVE_CURRENT 即可复用(当时 golden 的策略与旧 fixture 相同)
// 新值: 复用还要带上当前 golden 的 policyVersion
// 原因: scoring-11 回执的策略是 policy-v4,旧跨午夜 fixture 的策略不是这一版(BUG-1260)
assert.equal(cachedEngineScoreIsReusable({
...historical,
algorithmVersion: LIVE_CURRENT,
policyVersion: live.policyVersion,
}, fingerprints, live), true);
assert.equal(historical.algorithmVersion, CURRENT, "checking live identity never relabels history");
// A receipt default must not become an environment override for cache identity.
assert.deepEqual(liveEngineScoringIdentityFromEnv({}), { algorithmVersion: null, policyVersion: null });
@@ -97,9 +97,9 @@ for (const option of ["A", "B", "C", "skip_probe"] as const) test(`D1 initial no
assert.equal(midnightSideChoice(current.case.candidate_range), null);
});
// BUG-1181: the scoring-10 golden (real engine, functional profile v2) must parse as dated too;
// a literal "=== scoring-9" check would have turned it into a legacy same-day result.
for (const fixture of ["rectification-midnight-date-anchor.delivery.native.json", "rectification-midnight-date-anchor.delivery.scoring-10.native.json"]) test(`native golden crosses engine parsing, inference and dated delivery without reanchoring (${fixture})`, async () => {
// BUG-1181: scoring-9 and later goldens must parse as dated.
// 原值: native + scoring-10;新值: 再加 scoring-11;原因: D5/D11 升到 scoring-11(BUG-1260),旧文件仍要按日期窗打开。
for (const fixture of ["rectification-midnight-date-anchor.delivery.native.json", "rectification-midnight-date-anchor.delivery.scoring-10.native.json", "rectification-midnight-date-anchor.delivery.scoring-11.native.json"]) test(`native golden crosses engine parsing, inference and dated delivery without reanchoring (${fixture})`, async () => {
const golden = JSON.parse(readFileSync(new URL(`./fixtures/${fixture}`, import.meta.url), "utf8"));
const originalFetch = globalThis.fetch;
globalThis.fetch = (async () => new Response(JSON.stringify(golden.response), { status: 200 })) as typeof fetch;