Ports _calc_native_panchavargiya_bala and its helpers verbatim from upstream yinduzhanxing c7117f92 (astrologer round-5 Q5). calc_panchadhikari_year_lord now scores candidates with it (engine tajika_native_five_fold); the D1/D2/D3/D9/D12 dignity proxy no longer selects a year lord, and a missing annual planet blocks instead of falling back to it. Basis note reads 「按 Tajika 五分力量」 / "by Tajika five-fold strength". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
103 lines
5.9 KiB
Python
103 lines
5.9 KiB
Python
"""Year lord shows its selection basis on every surface (BUG-1212 → BUG-1214).
|
||
|
||
Astrologer rulings 2026-10-03 甲11 and round-4 Q3: Muntha = natal Lagna +
|
||
completed years (kept); the year lord is chosen by the Panchadhikari rule
|
||
(`tajika_year_lord`), and the card and both report editions carry its
|
||
one-sentence basis instead of the BUG-1212 "Muntha lord for now" label.
|
||
Fictional chart.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import copy
|
||
import re
|
||
from datetime import datetime
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
from scripts.consultation_native_layers import build_annual_tajika
|
||
from scripts.pl9_reader_export import _pl9_export_markdown_for_edition
|
||
from scripts.solar_return import SIGNS, solar_return_full_report
|
||
from tests.test_report_english_edition import CASES, _packet
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
|
||
|
||
@pytest.fixture(autouse=True)
|
||
def _native_panchavargiya(monkeypatch):
|
||
# Product path: Tajika five-fold Panchavargiya unless the research opt-in is set.
|
||
monkeypatch.delenv("JYOTISH_YEAR_LORD_PYJHORA_REFERENCE", raising=False)
|
||
|
||
|
||
def test_report_shows_the_basis_in_both_editions() -> None:
|
||
# 原值:两版都断言「暂用 Muntha 主星;占星师口径为 Panchavargiya,待接入」
|
||
# 新值:断言 Panchadhikari 选法依据一句话(中文版含「年盘上升」与「本地近似计算」,
|
||
# 英文版是同一句的英文、不含中文)
|
||
# 原因:BUG-1214 接入 Panchadhikari 年主选法,去掉 BUG-1212 的暂用标注(任务书 T2)
|
||
packet = _packet(CASES["day"])
|
||
zh = _pl9_export_markdown_for_edition(copy.deepcopy(packet), "reader_main")
|
||
english = copy.deepcopy(packet)
|
||
english["report_language"] = "en"
|
||
en = _pl9_export_markdown_for_edition(english, "reader_main")
|
||
zh_rows = [line for line in zh.splitlines() if line.startswith("| Selection basis |")]
|
||
en_rows = [line for line in en.splitlines() if line.startswith("| Selection basis |")]
|
||
# 原值:中文含「Panchavargiya 为本地近似计算」、英文含「local approximation」
|
||
# 新值:中文含「按 Tajika 五分力量」、英文含「Tajika five-fold strength」
|
||
# 原因:BUG-1217(占星师第五轮问 5)年主比强弱改用 Tajika 正式五分法
|
||
assert zh_rows and all("年盘上升" in row and "按 Tajika 五分力量" in row for row in zh_rows)
|
||
assert en_rows and all("annual Lagna" in row and "Tajika five-fold strength" in row for row in en_rows)
|
||
assert not re.search(r"[\u4e00-\u9fff]", "\n".join(en_rows))
|
||
assert "暂用 Muntha 主星" not in zh
|
||
assert zh.count("| Varshesha |") == zh.count("| Selection basis |")
|
||
|
||
|
||
def test_consultation_annual_card_carries_the_basis() -> None:
|
||
case = CASES["day"]
|
||
payload = {key: case[key] for key in ("year", "month", "day", "hour", "minute", "second", "lat", "lon", "tz", "ayanamsa", "node_mode")}
|
||
from scripts.jyotish_engine import compute_chart_data
|
||
chart, *_ = compute_chart_data(case["year"], case["month"], case["day"], case["hour"], case["minute"],
|
||
case["lat"], case["lon"], case["tz"], ayanamsa_name=case["ayanamsa"])
|
||
annual = build_annual_tajika(payload, chart, reference=datetime(2026, 10, 3))
|
||
assert annual["status"] == "parameter_sensitive"
|
||
# 原值:varshesha_basis == YEAR_LORD_BASIS(「暂用 Muntha 主星…待接入」)
|
||
# 新值:varshesha_basis 是年主选法依据一句话(tajika_year_lord.selection_basis_text)
|
||
# 原因:BUG-1214(任务书 T2)
|
||
assert "年盘上升" in annual["varshesha_basis"] and "暂用" not in annual["varshesha_basis"]
|
||
# 原值 endswith「(Panchavargiya 为本地近似计算)」/ 新值 endswith「(按 Tajika 五分力量)」/ 原因 BUG-1217
|
||
assert annual["varshesha_basis"].endswith("(按 Tajika 五分力量)")
|
||
card = (ROOT / "frontend/src/lib/consultation-evidence-card.ts").read_text(encoding="utf-8")
|
||
assert '"varshesha", "varshesha_basis"' in card
|
||
workflow = (ROOT / "frontend/src/mastra/consultation-workflow.ts").read_text(encoding="utf-8")
|
||
assert '"varsheshabasis"' in workflow
|
||
|
||
|
||
def test_main_path_muntha_is_natal_lagna_plus_completed_years() -> None:
|
||
from scripts.jyotish_engine import compute_chart_data
|
||
|
||
case = CASES["day"]
|
||
report = solar_return_full_report(case["year"], case["month"], case["day"], case["hour"], case["minute"],
|
||
case["lat"], case["lon"], case["tz"], 2026, ayanamsa_name="raman")
|
||
_chart, natal_asc, *_ = compute_chart_data(case["year"], case["month"], case["day"], case["hour"], case["minute"],
|
||
case["lat"], case["lon"], case["tz"], ayanamsa_name="raman")
|
||
muntha = report["muntha"]
|
||
completed = 2026 - case["year"]
|
||
assert (muntha["natal_asc_sign_idx"], muntha["age"]) == (natal_asc, completed)
|
||
assert muntha["muntha_sign_idx"] == (natal_asc + completed) % 12
|
||
assert muntha["muntha_sign"] == SIGNS[muntha["muntha_sign_idx"]]
|
||
# 原值:年主 == Muntha 主星
|
||
# 新值:年主由 Panchadhikari 选出;Muntha 主星一定在候选里(来源 muntha_lord),
|
||
# 候选 Muntha 用的是「本命上升 + 已满年数」
|
||
# 原因:BUG-1214(第四轮问 3)
|
||
year_lord = report["year_lord"]
|
||
assert year_lord["muntha_basis"] == "natal_ascendant_plus_completed_years"
|
||
assert year_lord["muntha_sign_idx"] == muntha["muntha_sign_idx"]
|
||
planets = {row["planet"] for row in year_lord["candidates"]}
|
||
assert muntha["muntha_lord"] in planets and year_lord["year_lord"] in planets
|
||
|
||
|
||
def test_sun_sign_muntha_variant_is_off_the_main_path() -> None:
|
||
pattern = re.compile(r"^\s*(from\s+(scripts\.)?muntha\s+import|import\s+(scripts\.)?muntha\b)|_load_local_module\(['\"]muntha['\"]\)", re.MULTILINE)
|
||
offenders = [path.name for path in (ROOT / "scripts").glob("*.py") if path.name != "muntha.py" and pattern.search(path.read_text(encoding="utf-8"))]
|
||
assert offenders == []
|