Files
Jyotisha/tests/test_narayana_method_status_bug1732.py
T
ClaudeandClaude Opus 5.5 8a958b5a65
Independent Staging Quality Gate / validate-frontend (push) Successful in 5m19s
Independent Staging Quality Gate / validate-python (push) Successful in 6m49s
Independent Staging Quality Gate / publish (push) Successful in 3m22s
fix(narayana): separate AD start step from AD direction in method_status
ad_start (小运起点) is its own step: an unresolved MD-vs-7th comparison or its
lord blocks ad_start (ad_direction not_reached); Saturn + Ketu in the MD sign
blocks ad_direction. Card step names, narayanaStepsToName, timing whitelist,
contract wording, golden (TTL=0) and fixtures updated.

占星师 2026-11-09 第七轮回复 R2 选 D;产品负责人同意 (BUG-1830)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-09 16:21:06 +08:00

102 lines
6.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""BUG-1732 (astrologer ruling 2026-11-07, Q1): the Narayana row names which step
is undetermined or disputed, from the engine's own result. Fictional charts only."""
from __future__ import annotations
import random
import sys
from datetime import datetime
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
import narayana_legacy_label as label # noqa: E402
from narayana_dasha import narayana_dasha_full_report # noqa: E402
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
def test_steps_are_the_four_named_ones_and_come_from_the_engine():
view = label.rath_narayana_view(3, LONS, current_age=40.0, birth_year=1980)
status = view["method_status"]
# 原值:四步 ("seed", "years", "dual_lord", "ad_direction") / 新值:加 start(出生起点) / 原因:占星师 2026-11-08 第五轮裁定 1
# 原值(2):("seed", "years", "dual_lord", "ad_direction", "start") / 新值(2):加 ad_start(小运起点)在 ad_direction 前 /
# 原因(2):占星师 2026-11-09 第七轮回复 R2 选 D;产品负责人同意:小运起点与小运方向分开点名。
assert tuple(status["steps"]) == ("seed", "years", "dual_lord", "ad_start", "ad_direction", "start")
assert status["chat_use"] == "single_system_candidate"
# 原值:status 恒为 disputed(B3/B4 未裁) / 新值:有点名步骤时 disputed,否则 determined / 原因:占星师 2026-11-08 第五轮裁定 1
assert status["status"] == ("disputed" if status["unresolved_steps"] else "determined")
# 原值:小运方向是否 disputed 看书中两种说法的方向是否不同 / 新值:看换成该说法后当前小运是否改变 / 原因:占星师 2026-11-08 第五轮裁定 1
rows = {row["profile"]: row for row in view["profile_steps"]["steps"]["ad_direction"]["comparisons"]}
assert (status["steps"]["ad_direction"]["status"] == "disputed") == any(row["differs"] for row in rows.values())
assert status["steps"]["seed"]["status"] == "determined"
# 原值:text == NARAYANA_CANDIDATE_TEXT(「……尚有方法或实现分歧……单体系候选窗口……」)
# 新值:她第五轮句式,原因按点名步骤填 / 原因:占星师 2026-11-08 第五轮裁定 1
assert status["text"] == label.narayana_candidate_text(status["steps"])
assert "暂不作为双体系确认" in status["text"] and status["text"].startswith("Vimshottari 提供主要时间框架。")
# 原值:open_items == [B3/B4],steps "unknown" / 新值:B3/B4 已裁,无开放项 / 原因:占星师 2026-11-08 第五轮裁定 1
assert status["open_items"] == []
def test_named_steps_are_exactly_the_disputed_or_blocked_ones():
# 原值:引擎点不出步骤时 unresolved_steps == "unknown" / 新值:五步逐一判定,点不出即为 []
# 原因:占星师 2026-11-08 第五轮裁定 1(每步有具名 profile,不再有 unknown)
random.seed(7)
seen_unknown = seen_named = False
for _ in range(200):
lons = {p: random.uniform(0, 360) for p in ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu")}
lons["Ketu"] = (lons["Rahu"] + 180) % 360
try:
# 出生时刻给出(start 步骤才有依据;占星师 2026-11-08 第五轮裁定 1(e))。
view = label.rath_narayana_view(random.randrange(12), lons, current_age=random.uniform(5, 80), birth_year=1960,
birth_datetime=datetime(1960, 1, 1, 12, 0))
except Exception: # noqa: BLE001 - product_narayana turns this into blocked
continue
status = view["method_status"]
# 原值:("undetermined", "disputed", "blocked")。新值:加 partially_blocked(当前大运早于未决年长,之后日期 blocked)。
# 原因:占星师 2026-11-08 第六轮 R2 局部传播。
named = [n for n, s in status["steps"].items()
if s["status"] in ("undetermined", "disputed", "blocked", "partially_blocked")]
if named:
seen_named = True
assert status["unresolved_steps"] == named
else:
seen_unknown = True
assert status["unresolved_steps"] == []
assert seen_unknown and seen_named
def test_seed_tie_is_blocked_no_judgment_and_no_legacy_stand_in():
original = label.rath_narayana_view
def tie(*args, **kwargs):
result = {"seed_selection": {"status": "tie", "reason": "all_seven_general_levels_tie"},
"alternatives": {"Cancer": {}, "Capricorn": {}}, "mahadasha": None}
return {"profile": "sanjay_rath", "status": "parameter_sensitive", "reason": "all_seven_general_levels_tie",
"used_for_scoring": False,
"method_status": {**label.narayana_method_status(result), "status": "blocked",
"chat_use": "no_judgment", "text": label.NARAYANA_BLOCKED_TEXT}}
label.rath_narayana_view = tie
try:
legacy = narayana_dasha_full_report(lagna_sign_idx=3, planet_lons=LONS, current_age=40.0, birth_year=1980)
product = label.product_narayana(legacy, 3, LONS, current_age=40.0, birth_year=1980)
finally:
label.rath_narayana_view = original
status = product["method_status"]
assert product["status"] == "blocked" and "current_dasha" not in product
assert status["chat_use"] == "no_judgment"
# 原值:undetermined / 新值:blocked(来源版定不出即 blocked) / 原因:占星师 2026-11-08 第五轮裁定 1
assert status["steps"]["seed"]["status"] == "blocked"
assert status["steps"]["years"]["status"] == "not_reached"
assert status["unresolved_steps"] == ["seed"]
assert "不拿旧算法补位" in status["text"]
def test_engine_exception_is_blocked_with_unknown_steps():
status = label.narayana_method_status(None, blocked_reason="TypeError")
assert status["status"] == "blocked" and status["unresolved_steps"] == "unknown"
assert all(step["status"] == "blocked" for step in status["steps"].values())