fix(rectification): dedupe same-domain probe years and drop unanchored style cards (BUG-559)

Pass asked probe keys into the engine without changing result fingerprints, block nearby years already asked, and require a dated same-domain ledger event before rendering varga_style cards.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-06 23:03:11 +08:00
co-authored by Cursor
parent 150d7ef189
commit 3a9ae736e1
8 changed files with 372 additions and 9 deletions
+59
View File
@@ -1060,6 +1060,65 @@ class QualityDistinguishDedupeTests(unittest.TestCase):
])
self.assertEqual(len(over_cap), MAX_QUALITY_DISTINGUISH_PROBES)
def test_asked_career_month_probe_blocks_same_and_nearby_years(self) -> None:
from scripts.rectification.event_probes import (
asked_years_for_domain,
_existence_blocked_years,
nearby_ledger_note,
)
years = asked_years_for_domain(["career.2022.05.dasha_boundary"], "career")
self.assertEqual(years, {2022})
self.assertEqual(_existence_blocked_years("career", years), {2021, 2022, 2023})
self.assertEqual(asked_years_for_domain(["career.2022.05.dasha_boundary"], "finance"), set())
note = nearby_ledger_note(
[{
"domain": "relocation",
"date_start": "2022-07-01",
"precision": "month",
}],
domain="career",
year=2022,
month=5,
)
self.assertIn("2022 年 7 月", note)
self.assertNotIn("summary", note)
def test_asked_career_month_probe_is_not_reemitted_for_same_or_nearby_year(self) -> None:
from unittest.mock import patch
from scripts.rectification import event_probes as probes_mod
built = {
"static_contexts": [
_context("05:13", d4_asc=0, sun_house=4, sun_varga_sign=3, moon=100.0),
_context("05:40", d4_asc=1, sun_house=10, sun_varga_sign=9, moon=101.0),
]
}
def fake_vim(_birth_date: str, moon: float, _lo: int, _hi: int) -> list[date]:
return [date(2018, 5, 15)] if moon <= 100.0 else [date(2019, 5, 20)]
def fake_narayana(_asc: int, planets: dict, _birth_date: str, _lo: int, _hi: int) -> list[date]:
moon = float(planets.get("Moon") or 0)
return [date(2018, 5, 15)] if moon <= 100.0 else [date(2019, 5, 20)]
def fake_score(context: dict, *, birth_date: str, domain: str, year: int, month: int | None = None) -> dict:
del birth_date, domain, context
if year in {2018, 2019} and month == 5:
return {"rule_ids": ["vim_ad_domain_lord"]}
return {"rule_ids": ["no_domain_activation"]}
request = _request(asked_probe_keys=["career.2018.05.dasha_boundary"])
with (
patch.object(probes_mod, "_vim_start_dates", side_effect=fake_vim),
patch.object(probes_mod, "_narayana_start_dates", side_effect=fake_narayana),
patch.object(probes_mod, "_score_year", side_effect=fake_score),
):
probes = _probes(request, built, ["05:13", "05:40"], "05:13")
career = [item for item in probes if item["domain"] == "career"]
self.assertFalse(any(item["year"] in {2017, 2018, 2019} for item in career), career)
if __name__ == "__main__":
unittest.main()