fix(rectification): bump scoring identity to scoring-11 after D5/D11 (BUG-1260)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -31,9 +31,9 @@ def test_fixed_scoring_identity_is_exposed_without_changing_input_contract():
|
||||
ALGORITHM_VERSION, INPUT_CONTRACT_VERSION, calculation_spec, sha256,
|
||||
)
|
||||
|
||||
# 原值: "rectification-v5-matrix-scoring-9";新值: "...-scoring-10";原因: 功能吉凶 v2 改变同输入分数,
|
||||
# 按「打分语义变化必须 bump」先例升算法身份(BUG-1181);输入合同 v5 与日期窗合同不变。
|
||||
assert engine_scoring_versions()["algorithm_version"] == ALGORITHM_VERSION == "rectification-v5-matrix-scoring-10"
|
||||
# 原值: "rectification-v5-matrix-scoring-10";新值: "...-scoring-11";原因: D5/D11 映射改变学业与财务分盘得分
|
||||
# (BUG-1260),同输入分数变了,按 BUG-1181 升算法身份;输入合同 v5 与日期窗合同不变。
|
||||
assert engine_scoring_versions()["algorithm_version"] == ALGORITHM_VERSION == "rectification-v5-matrix-scoring-11"
|
||||
assert INPUT_CONTRACT_VERSION == "rectification-calculation-spec-v5"
|
||||
request = {"birth_date": "2000-03-01", "start_time": "00:00", "end_time": "00:02",
|
||||
"lat": 0.0, "lon": 0.0, "tz": 0.0, "events": []}
|
||||
|
||||
@@ -30,6 +30,12 @@ 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.
|
||||
|
||||
Current golden tests/golden/rectification_engine_memoization_v4.json
|
||||
(2026-10-07, BUG-1260) was written by ``write_golden`` after the D5/D11
|
||||
mappings changed education and finance varga points for this same request.
|
||||
The algorithm is rectification-v5-matrix-scoring-11. Policy stays v4.
|
||||
v3 stays byte-for-byte and is pinned 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
|
||||
@@ -68,20 +74,24 @@ import scripts.rectification.scoring_service as scoring_service
|
||||
import shadbala
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v3.json"
|
||||
GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v4.json"
|
||||
V3_GOLDEN_PATH = ROOT / "tests" / "golden" / "rectification_engine_memoization_v3.json"
|
||||
V3_GOLDEN_SHA256 = "7064f30bea3a7bcd8058fdcb6b52484a96a09767c0c289e0d71f3e2368fc8d45"
|
||||
V3_SOURCE_COMMIT = "7fb165ecf66ba1726f2fc74ffa2353fadc65ba39"
|
||||
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"
|
||||
# 原值: rectification-v5-matrix-scoring-10;新值: ...-scoring-11;原因: D5/D11 改变同输入分数(BUG-1260)。
|
||||
CURRENT_ALGORITHM_VERSION = "rectification-v5-matrix-scoring-11"
|
||||
FROZEN_TODAY = date(2026, 9, 16)
|
||||
TIMING_KEYS = frozenset({"column_compare_ms"})
|
||||
HISTORICAL_SOURCE_COMMIT = "a8d29d1b6cc37ff865ddec6c8bccdf9aa889ee53"
|
||||
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"
|
||||
# D5/D11 mapping commit that moves these scores (BUG-1260). The v4 file is
|
||||
# written later on this branch; v3 keeps its own source commit below.
|
||||
SOURCE_COMMIT = "db68e90816d462b0c17b4f84a0d19df83010fbce"
|
||||
CACHE_LAYER_KEYS = (
|
||||
"ashtakavarga_result",
|
||||
"shadbala_result",
|
||||
@@ -265,7 +275,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 / policy-v4 golden; identity is spelled out, not trusted."""
|
||||
"""Compare with the scoring-11 / 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"}],
|
||||
@@ -300,7 +310,7 @@ def _assert_dated_payload_against_golden(actual: dict[str, Any], expected: dict[
|
||||
|
||||
|
||||
def test_historical_scoring_8_golden_is_frozen_and_no_longer_current() -> None:
|
||||
"""BUG-1181: the old golden stays byte-identical; current scores moved, hence scoring-10."""
|
||||
"""BUG-1181: the scoring-8 golden stays byte-identical and is not the current payload."""
|
||||
raw = HISTORICAL_GOLDEN_PATH.read_bytes()
|
||||
assert hashlib.sha256(raw).hexdigest() == HISTORICAL_GOLDEN_SHA256
|
||||
historical = json.loads(raw)
|
||||
@@ -313,14 +323,15 @@ def test_historical_scoring_8_golden_is_frozen_and_no_longer_current() -> None:
|
||||
|
||||
|
||||
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."""
|
||||
"""BUG-1193: v2 stays byte-identical; scores equal v3 (both scoring-10), 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"))
|
||||
current = json.loads(V3_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
|
||||
# 原值: 与 CURRENT_ALGORITHM_VERSION 相同;新值: 两者都是 scoring-10;原因: 当前身份已是 scoring-11,v2/v3 仍是当时的 scoring-10。
|
||||
assert previous["candidate_feature_snapshot"]["algorithm_version"] == "rectification-v5-matrix-scoring-10"
|
||||
assert current["candidate_feature_snapshot"]["algorithm_version"] == "rectification-v5-matrix-scoring-10"
|
||||
_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
|
||||
@@ -332,6 +343,20 @@ def test_previous_policy_v3_golden_is_frozen_with_identical_scores() -> None:
|
||||
_assert_memoization_payloads(current, previous)
|
||||
|
||||
|
||||
def test_scoring_10_golden_is_frozen_and_scores_moved() -> None:
|
||||
"""BUG-1260: v3 stays byte-identical; D5/D11 moved this request, hence scoring-11."""
|
||||
raw = V3_GOLDEN_PATH.read_bytes()
|
||||
assert hashlib.sha256(raw).hexdigest() == V3_GOLDEN_SHA256
|
||||
previous = json.loads(raw)
|
||||
current = json.loads(GOLDEN_PATH.read_text(encoding="utf-8"))
|
||||
assert previous["source_commit"] == V3_SOURCE_COMMIT
|
||||
assert previous["candidate_feature_snapshot"]["algorithm_version"] == "rectification-v5-matrix-scoring-10"
|
||||
assert current["candidate_feature_snapshot"]["algorithm_version"] == CURRENT_ALGORITHM_VERSION
|
||||
assert current["source_commit"] == SOURCE_COMMIT
|
||||
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))
|
||||
|
||||
@@ -21,8 +21,8 @@ class RelativeSupportScaleTest(unittest.TestCase):
|
||||
# 原值: 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")
|
||||
# 原值: -10;新值: -11;原因: D5/D11 改变同输入分数(BUG-1260),策略 v4 与相对支持口径不变。
|
||||
self.assertEqual(ALGORITHM_VERSION, "rectification-v5-matrix-scoring-11")
|
||||
self.assertEqual(RELATIVE_SUPPORT_MODE, "proportional")
|
||||
|
||||
def test_offset_top_two_lead_is_at_least_proportional(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user