feat(narayana): show the Sanjay Rath version beside the legacy one (T4, BUG-1218)
Display only; scoring and timing conclusions keep the legacy algorithm. narayana_legacy_label attaches a Rath view (seed, deciding level, direction, 24 MDs, running MD/AD) under modules.narayana_dasha.rath for the consultation modules, full reading Step 4.13 and the CLI. Reference report: one summary line under the legacy line plus Rath MD / running-MD AD tables (English terms added). Evidence card: narayana_rath (label, seed sign, level, running MD) on timing / annual cards only — other cards sit at 11,979 of 12,000 characters. Goldens re-captured from the real engine. 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:
co-authored by
Claude Opus 5.5
parent
3264831a23
commit
bf8d704708
@@ -61,3 +61,56 @@ def test_kn_rao_never_names_narayana_on_user_visible_surfaces() -> None:
|
||||
ROOT / "scripts/narayana_dasha.py", ROOT / "scripts/cmd_narayana_dasha.py"]
|
||||
hits = [path.name for path in surfaces if pattern.search(path.read_text(encoding="utf-8"))]
|
||||
assert hits == []
|
||||
|
||||
|
||||
# ── BUG-1218 (T4): Sanjay Rath version shown beside the legacy one ──
|
||||
|
||||
def test_full_reading_carries_the_rath_view_and_leaves_the_legacy_result_alone() -> None:
|
||||
from scripts.jyotish_engine import cmd_full_reading
|
||||
from scripts.narayana_dasha import narayana_dasha_full_report
|
||||
from scripts.narayana_legacy_label import RATH_LABEL_ZH
|
||||
|
||||
reading = cmd_full_reading(type("Args", (), dict(CASES["day"]))())
|
||||
module = reading["modules"]["narayana_dasha"]
|
||||
rath = module["rath"]
|
||||
assert rath["algorithm_label"] == RATH_LABEL_ZH and rath["used_for_scoring"] is False
|
||||
assert rath["profile"] == "sanjay_rath" and rath["seed_sign"] and rath["strength_level_decided"] in range(1, 8)
|
||||
assert len(rath["mahadasha"]) == 24 and len(rath["current_md_antardasha"]) == 12
|
||||
# Attaching the Rath view leaves every legacy field exactly as it was.
|
||||
from scripts.narayana_legacy_label import label_legacy_narayana
|
||||
lons = {"Sun": 10.0, "Moon": 100.0, "Mars": 200.0, "Mercury": 20.0, "Jupiter": 250.0,
|
||||
"Venus": 340.0, "Saturn": 300.0, "Rahu": 50.0, "Ketu": 230.0} # fictional
|
||||
base = narayana_dasha_full_report(lagna_sign_idx=3, planet_lons=lons, current_age=40.0, birth_year=1980)
|
||||
with_rath = label_legacy_narayana(copy.deepcopy(base), lagna_sign_idx=3, planet_lons=lons, current_age=40.0, birth_year=1980)
|
||||
without = label_legacy_narayana(copy.deepcopy(base))
|
||||
assert "rath" not in without
|
||||
assert {key: value for key, value in with_rath.items() if key != "rath"} == without
|
||||
|
||||
|
||||
def test_reference_edition_shows_both_and_english_terms_cover_the_rath_lines() -> None:
|
||||
from scripts.narayana_legacy_label import rath_report_lines_zh
|
||||
from scripts.pl9_reader_english_terms import PHRASES_EN, REGEX_EN
|
||||
|
||||
packet = _packet(CASES["day"])
|
||||
zh = _pl9_export_markdown_for_edition(copy.deepcopy(packet), "reference")
|
||||
legacy = zh.index(f"- 算法:{LEGACY_NOTE_ZH}")
|
||||
rath = zh.index("- 并列:Sanjay Rath 版(并列参考,未进打分与时间轴结论):起运宫 ")
|
||||
assert legacy < rath
|
||||
assert "| Rath MD | 星座 | 宫主 | 起始年龄 | 结束年龄 | 年数 |" in zh and "| Rath AD | 星座 | 起始年龄 | 结束年龄 |" in zh
|
||||
view = packet["worksheets"]["timing_and_predictive_systems"]["narayana_dasha"]["rath"]
|
||||
for line in rath_report_lines_zh(view):
|
||||
text = line
|
||||
for pattern, target in REGEX_EN:
|
||||
text = pattern.sub(target, text)
|
||||
for source, target in PHRASES_EN:
|
||||
text = text.replace(source, target)
|
||||
assert not re.search(r"[一-鿿]", text), text
|
||||
|
||||
|
||||
def test_consultation_modules_carry_the_rath_view() -> None:
|
||||
golden = json.loads((ROOT / "frontend/tests/fixtures/consult-evidence-card-golden.json").read_text(encoding="utf-8"))
|
||||
for chart in golden["charts"]:
|
||||
for route in ("workflow", "annual_workflow", "timing_workflow"):
|
||||
module = chart[route]["chart"]["modules"]["narayana_dasha"]
|
||||
assert module["profile"] == LEGACY_PROFILE
|
||||
assert module["rath"]["used_for_scoring"] is False and module["rath"]["current_dasha"]["md"]["sign"]
|
||||
|
||||
@@ -222,8 +222,29 @@ def test_table25_sub_periods_24_of_36() -> None:
|
||||
assert (gemini["stronger_sign"], gemini["strength_level_decided"], gemini["start_sign"]) == ("Sagittarius", 5, "Cancer")
|
||||
|
||||
|
||||
def test_rath_profile_is_not_wired_into_any_product_path() -> None:
|
||||
def test_rath_profile_is_display_only() -> None:
|
||||
"""原值:没有任何脚本导入 narayana_rath(`users == []`)
|
||||
新值:只有展示层 narayana_legacy_label 导入它;冻结的打分文件与 rectification/ 都不导入展示层或 Rath 模块
|
||||
原因:BUG-1218 T4(产品负责人 2026-10-03 晚恢复 T4):Rath 版与旧算法并列显示,打分与时间轴结论仍用旧算法"""
|
||||
pattern = re.compile(r"\bnarayana_rath\b")
|
||||
users = sorted(path.name for path in (ROOT / "scripts").rglob("*.py")
|
||||
if path.name != "narayana_rath.py" and pattern.search(path.read_text(encoding="utf-8")))
|
||||
assert users == []
|
||||
assert users == ["narayana_legacy_label.py"]
|
||||
frozen = json.loads((ROOT / "references/rectification_sealed_holdout.v1.json").read_text(encoding="utf-8"))
|
||||
scoring = set(_production_files(frozen)) | {str(p.relative_to(ROOT)) for p in (ROOT / "scripts/rectification").rglob("*.py")}
|
||||
display = re.compile(r"\b(narayana_rath|narayana_legacy_label)\b")
|
||||
assert sorted(path for path in scoring if display.search((ROOT / path).read_text(encoding="utf-8"))) == []
|
||||
|
||||
|
||||
def _production_files(record) -> list:
|
||||
found = []
|
||||
if isinstance(record, dict):
|
||||
for key, value in record.items():
|
||||
if key == "production_scoring_files" and isinstance(value, list):
|
||||
found.extend(value)
|
||||
else:
|
||||
found.extend(_production_files(value))
|
||||
elif isinstance(record, list):
|
||||
for value in record:
|
||||
found.extend(_production_files(value))
|
||||
return found
|
||||
|
||||
Reference in New Issue
Block a user