fix(report): render-only items from the astrologer's 11-25 comparison (BUG-2377–2386)
- 2377 appendix yoga table: kind, formation, also-needs, condition and meaning source (book title only) - 2378 Saham trace: A, B, C, A − B + C, arc test, +30°, final value - 2379 daridra_2 「第二宫主落陷…」 no longer classified as Neecha Bhanga - 2380 Neecha variant names on page titles; Raja add-on line - 2381 Pancha Mahapurusha page agrees with its basis; degree, Moolatrikona, same-fact line - 2382 no book/page "Source:" lines in the body Yoga Expression chapter - 2383 yoga pages state participants' combustion, Shadbala, functional role - 2384 unresolved-rule records stay backstage (packet only) - 2385 Neecha verified state matches the row's own fallen planet - 2386 no hedge line for uncomputed Neecha notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
This commit is contained in:
@@ -32337,3 +32337,88 @@
|
||||
- **防复发**:夹具测试钉住「每条不绑定行星的规则、每个类别都有非空图」与「见证星不出落陷卡」。
|
||||
- **关联记录**:BUG-2268、BUG-2280、BUG-2303、BUG-2379(报告侧同类判定)。报告侧 `scripts/report_render/neecha_witness.py::_neecha_row_verified` 仍按 `planet in _row_planets(row)` 认行(见证星也会命中),已转报告窗口,本次未改。
|
||||
- **修复版本**:1.4(staging)。
|
||||
|
||||
## BUG-2377 | 附录 Yoga 总表只有名称、类别、行星,看不出形成状态、还需要什么和出处
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:占星师 2026-11-25 对照(M01、M02、M05):附录「瑜伽条目」56 行只有三列;正文候选表 21 行,两表的取舍关系没有说明;每条格局的条件出处和含义出处在报告里看不到(检测器都返回了)。
|
||||
- **修复**:负责人 2026-11-25「显示层的也做了吧」。识别的书名含 Phaladeepika(BUG-2388 的三种互换格局用);形成状态优先读 `formation_assessment`(按具名定义成立)。新文件 `report_render/yoga_appendix_fields.py`,附录表加「类型(具名格局/结构观察)」「形成状态」「还需要」「条件出处」「含义出处」五列,表前一句说明本表与正文候选表的关系。出处只给书名:不写页码、PDF 页、行号、表号(BUG-2129),不写软件库名(BUG-2115);本地规则写「本地结构规则,没有具名出处」。只在附录,正文不加。
|
||||
- **验证**:`tests/test_report_render_density_2377_2384.py`(两张公开盘表头与说明,表内无页码 / PDF / 行号 / 库名;书名提取单测)。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2378 | Saham 公式追踪只有规则和最终值,看不到中间步骤
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:占星师对照(M13):年运和本命 Saham 追踪表只有名称、规则、昼夜、最终黄经;「+30°」写进规则文字,看不出是否真的加了、为什么加。
|
||||
- **根因**:`tajika.py` 交给 `attach_formula_traces` 的 `formula_meta` 只留了 4 个字段,算出的 A、B、C 黄经、A − B + C 和弧判断都丢了。
|
||||
- **修复**:`formula_meta` 带上 `operand_longitudes` / `base_longitude` / `arc_passes_c`;`annual_native/saham_traces.py` 写入追踪;`parity_chapters._trace_table` 有步骤时列 A、B、C、A − B + C、「C 在 B→A 弧上」、「加 30°」、最终黄经,表前一句写算法;本地旧 Saham 没有步骤时只列规则和值。最终值不变。
|
||||
- **验证**:同一测试文件(虚构数值逐列断言;两张公开盘中英文都有步骤表)。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2379 | 「第二宫主落陷且在第6、8或12宫」被当成落陷取消,表里写「见证星本次未返回」
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:核对占星师 M04 时发现:参与星表多出一行「落陷取消(水星);化解条件的见证星:本次未返回」,附录总表也把它列成落陷取消。
|
||||
- **根因**:`neecha_witness.is_neecha_bhanga_row` 与 `pl9_interpretation_packs._is_neecha_bhanga` 只要名称里有「落陷」就当落陷取消;Daridra 观察 `daridra_2` 的中文名正好含这两个字,于是被当作落陷取消,并入水星的落陷取消页。
|
||||
- **修复**:只认取消本身(neecha / nicha / 落陷取消 / 落陷化解 / neecha_bhanga);两处共用 `is_neecha_bhanga_row`。
|
||||
- **验证**:同一测试文件;对照盘只剩 3 个真正的落陷取消页。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2380 | 落陷取消页标题写「规则版本 1/2」,看不出是哪种判法;王者格附加条件不显示
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:占星师对照(M04)。
|
||||
- **修复**:已知判法写名称:「常规化解条件」「互换星座的变体」(仍不写书名),未知判法继续编号;页面加一句王者格附加位置条件满足或不满足(不满足时:「这里是落陷得到缓解,不算王者格」)。标签「落陷;有缓解」不变。
|
||||
- **验证**:同一测试文件;`tests/test_report_astro_review_2110.py` 原断言(未知判法「规则版本 2」)仍通过。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2381 | Sasa 页说「没有逐条核对具名定义」,同一报告的依据段却写「必要定义已满足」;缺度数和同一事实说明
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:占星师对照(M03)。
|
||||
- **根因**:Pancha Mahapurusha 主检测器(入庙或入旺且在上升起的角宫,即具名定义全部条件)没有 `formation_assessment`,页面落到「还没有逐条核对」。
|
||||
- **修复**:`main_detector:pancha_mahapurusha:*` 页按具名定义成立;依据段加星座内度数和 Moolatrikona;页面加一句「同一个土星位置也是这几条的依据:…,它们说的是同一个事实,不另算一次支持」。
|
||||
- **验证**:同一测试文件。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2382 | 正文「Yoga 作用路径」每段印「来源:…印刷页…文件页」,共 51 行
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:核对 M03 时发现:11-24 移植的 `yoga_expression_paths.py` 在正文每条路径后印书名和页码,违反负责人规则(BUG-2129 不写书名页码;11-24 出处只放附录和模型输入)。
|
||||
- **修复**:正文不再印这一行;每条格局的书名在附录 Yoga 总表(BUG-2377),数据包里的 `source` 字段保留给模型。
|
||||
- **验证**:同一测试文件(两张公开盘正文没有「Source:」/「来源:」行)。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2383 | Yoga 页对参与星写「未评估:燃烧、Shadbala、功能吉凶」,而这些都已算出
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:占星师对照(M06):对照盘 52 行。
|
||||
- **根因**:检测器在 Shadbala 之前运行,`strength_factors.unassessed_layers` 带着这几层;上游的「Shadbala 后重算 Yoga」改冻结引擎,负责人未批。
|
||||
- **修复**:显示层从报告已有的数据(本命行星燃烧、Shadbala 总分与门槛、功能吉凶)补一句「参与星本身:…」,这三层从「未评估」里去掉;Vimsopaka、相位强弱、格局综合强度、应期照旧列出。不改检测结果。
|
||||
- **验证**:同一测试文件(虚构单测;两张公开盘不再出现「未评估:燃烧」)。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2384 | 没有得出结论的规则(Nishkapata、Anapathya)报告里查不到
|
||||
|
||||
- **状态**:resolved(待 staging 验收)——按负责人规则只留后台
|
||||
- **现象**:占星师对照(M08):怕被读成「这张盘没有这类主题」。
|
||||
- **处理**:记录本来就在数据包 `yoga.yoga_evaluation`(模型可读)。按负责人「不向用户展示未判定 / 待核内容」的规则,不在用户报告里加列表;测试钉住数据包仍带这些记录、报告不出现。附录 Yoga 总表的状态措辞也避开「待核 / 未选定」类说法。
|
||||
- **验证**:同一测试文件。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2385 | 落陷星的「已核」判断按「在不在行的行星列表里」,见证星本身落陷时会被别人的化解行判成已缓解
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:协调窗口修 BUG-2387(星盘页把见证星当成落陷)时指出,报告侧 `neecha_witness._neecha_row_verified` 用 `planet in _row_planets(row)`;没有 `formation_evidence.planet` 的旧行会把见证星也算进去。本次对照盘与两张公开盘实际输出未受影响(只有真正落陷的星有「落陷;有缓解」)。
|
||||
- **修复**:新函数 `_row_fallen`:取该行自己的落陷星(`formation_evidence.planet` 或 `planet`);没有写明时只在行里只有一颗星时才算。
|
||||
- **验证**:`tests/test_report_render_density_2377_2384.py`;`test_report_neecha_state_2165.py` 等落陷相关测试通过。
|
||||
- **关联记录**:BUG-2387(星盘页同类问题)、BUG-2303。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
## BUG-2386 | 落陷注释「这次没有计算,这不表示没有缓解条件」是两可说法
|
||||
|
||||
- **状态**:resolved(待 staging 验收)
|
||||
- **现象**:协调窗口指出 `neecha_witness.NEECHA_REASONS["not_computed"]` 的句子违反负责人「不加两可说法」规则(BUG-2280 同一规则)。
|
||||
- **修复**:改为只写「{行星}落陷。」/ "{planet} is debilitated."。
|
||||
- **验证**:`tests/test_report_neecha_short_cell_2155.py` 三处按原值/新值/原因更新。
|
||||
- **修复版本**:分支 `claude/report-audit-1125`。
|
||||
|
||||
@@ -75,6 +75,26 @@ def _plus_thirty(meta: dict) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _steps(meta: dict | None) -> dict:
|
||||
"""BUG-2378 (占星师 2026-11-25 M13): the operands, the value before the +30° test, the test and its result."""
|
||||
if not isinstance(meta, dict):
|
||||
return {}
|
||||
values = meta.get("operand_longitudes")
|
||||
if not isinstance(values, dict):
|
||||
return {}
|
||||
steps = {
|
||||
"operands": list(meta.get("formula_operands") or ()),
|
||||
"operand_longitudes": {key: round(float(value), 4) for key, value in values.items()
|
||||
if isinstance(value, (int, float)) and not isinstance(value, bool)},
|
||||
"plus_thirty": _plus_thirty(meta),
|
||||
}
|
||||
if isinstance(meta.get("base_longitude"), (int, float)):
|
||||
steps["base_longitude"] = round(float(meta["base_longitude"]), 4)
|
||||
if isinstance(meta.get("arc_passes_c"), bool):
|
||||
steps["arc_passes_c"] = meta["arc_passes_c"]
|
||||
return steps
|
||||
|
||||
|
||||
def attach_formula_traces(
|
||||
results: dict[str, Any],
|
||||
*,
|
||||
@@ -92,6 +112,7 @@ def attach_formula_traces(
|
||||
"rule": _rule_text(punya),
|
||||
"phase": "day" if is_day else "night",
|
||||
"longitude": results["punya_saham"].get("longitude"),
|
||||
**_steps(punya),
|
||||
})
|
||||
for key, day_pair, night_pair in _LOCAL:
|
||||
item = results.get(key)
|
||||
@@ -109,6 +130,7 @@ def attach_formula_traces(
|
||||
"rule": rule,
|
||||
"phase": "day" if is_day else "night",
|
||||
"longitude": item.get("longitude"),
|
||||
**_steps(meta),
|
||||
})
|
||||
results["formula_traces"] = traces
|
||||
return traces
|
||||
|
||||
@@ -970,6 +970,7 @@ def build_yoga_interpretation_pack(
|
||||
*,
|
||||
language: str = "zh",
|
||||
neecha_states: dict[str, str] | None = None,
|
||||
planet_facts: dict[str, dict] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Pages for yogas the detector already returned."""
|
||||
|
||||
@@ -1049,11 +1050,21 @@ def build_yoga_interpretation_pack(
|
||||
by_key[key] = entry
|
||||
by_name.setdefault((name, key[-1]), entry)
|
||||
entries.append(entry)
|
||||
# BUG-2380 (M04): the Raja add-on is its own field on her Neecha rows.
|
||||
_royal = (raw.get("formation_evidence") or {}).get("royal_yoga_candidate") if isinstance(raw.get("formation_evidence"), dict) else None
|
||||
if isinstance(_royal, bool) and entry.get("royal") is not True:
|
||||
entry["royal"] = _royal
|
||||
# BUG-2233: what the three-part page needs — whether the named definition is confirmed, and the
|
||||
# limits the detector returned with the row.
|
||||
assessment = raw.get("formation_assessment") if isinstance(raw.get("formation_assessment"), dict) else {}
|
||||
if assessment.get("status") == "formed_under_source":
|
||||
entry["formed_under_source"] = True
|
||||
# BUG-2381 (占星师 2026-11-25 M03): the Pancha Mahapurusha detector checks the whole named definition
|
||||
# (the planet in its own sign or exaltation, in a kendra from the Lagna); its basis section says
|
||||
# "Required definition satisfied", so the page must not say the definition was not checked.
|
||||
if rule_id.startswith("main_detector:pancha_mahapurusha:") and len(planets) == 1:
|
||||
entry["formed_under_source"] = True
|
||||
entry["mahapurusha_planet"] = planets[0]
|
||||
# BUG-2300: the engine withheld this rule's traditional effect (her effect_assessment /
|
||||
# method_review / combustion gates, upstream 58f37ee5b). The page keeps the gate; a row with
|
||||
# one of her five effect statuses wins over a method or combustion review.
|
||||
@@ -1153,7 +1164,7 @@ def build_yoga_interpretation_pack(
|
||||
# BUG-2292 (占星师 2026-11-23 信息密度交接 §2 格局强弱关联): what supports and what limits this
|
||||
# yoga's planets, what to read with them, and what was not assessed — from the engine's own
|
||||
# strength_factors. Was: not shown anywhere.
|
||||
strength_text = _yoga_strength_text(entry.get("strength_factors"), language)
|
||||
strength_text = _yoga_strength_text(entry.get("strength_factors"), language, planet_facts, planets)
|
||||
if strength_text:
|
||||
sections["strength"] = strength_text
|
||||
else:
|
||||
@@ -1201,6 +1212,23 @@ def build_yoga_interpretation_pack(
|
||||
)
|
||||
if entry.get("evidence_identity") and _mangal_detected(yogas_doshas_snapshot):
|
||||
sections["same_fact"] = MARS_SAME_FACT_NOTE["zh" if zh else "en"]["yoga"]
|
||||
if entry.get("mahapurusha_planet"):
|
||||
# BUG-2381 (M03): the same placement feeds other single-planet rows; say they are one fact.
|
||||
planet = entry["mahapurusha_planet"]
|
||||
others = []
|
||||
for raw_other in _list(yoga_snapshot.get("detected_yogas")):
|
||||
if not isinstance(raw_other, dict) or str(raw_other.get("rule_id") or "").startswith("main_detector:pancha_mahapurusha"):
|
||||
continue
|
||||
if _page_planets(raw_other) == [planet] and not _is_neecha_bhanga(raw_other):
|
||||
other_name = _yoga_name(raw_other, language)
|
||||
if other_name not in others:
|
||||
others.append(other_name)
|
||||
if others:
|
||||
joined = ("、" if zh else ", ").join(others)
|
||||
sections["same_fact"] = (
|
||||
f"同一个{_planet(planet, language)}位置也是这几条的依据:{joined}。它们说的是同一个事实,不另算一次支持。" if zh
|
||||
else f"The same {planet} placement also underlies: {joined}. They state one fact and do not add separate support."
|
||||
)
|
||||
if neecha_page:
|
||||
# BUG-2110 (占星师 2026-11-21 B): the page lists the original debilitation position, then
|
||||
# each satisfied condition with its own witness, then the overall meaning and limits; the
|
||||
@@ -1231,6 +1259,7 @@ def build_yoga_interpretation_pack(
|
||||
+ f"落陷星:{planet_names or '未列出'}。化解条件的见证星:{witness_list_text(roles, language)}。"
|
||||
+ numbered
|
||||
+ "一颗星满足几项条件仍只算一颗星;自我参照的条件只记原始条件。"
|
||||
+ _NEECHA_ROYAL_WORDS.get(entry.get("royal"), ("", ""))[0]
|
||||
)
|
||||
parts = [f"当前大运重叠(落陷星):{'、'.join(_planet(item, language) for item in hit['fallen'])}。"] if hit["fallen"] else []
|
||||
if witness_line:
|
||||
@@ -1245,6 +1274,7 @@ def build_yoga_interpretation_pack(
|
||||
+ f"Fallen planet: {planet_names or 'not listed'}. Witnesses of the cancellation conditions: {witness_list_text(roles, language)}."
|
||||
+ numbered
|
||||
+ " One planet meeting several conditions is still one planet; a self-reference condition is recorded only."
|
||||
+ _NEECHA_ROYAL_WORDS.get(entry.get("royal"), ("", ""))[1]
|
||||
)
|
||||
parts = [f"Current Dasha overlap (fallen planet): {', '.join(hit['fallen'])}."] if hit["fallen"] else []
|
||||
if witness_line:
|
||||
@@ -1314,6 +1344,18 @@ NEECHA_SUMMARY = {
|
||||
_ZH_ORDINALS = ("一", "二", "三", "四", "五", "六", "七", "八", "九", "十")
|
||||
|
||||
|
||||
_NEECHA_ROYAL_WORDS = {
|
||||
True: ("另外满足王者格的附加位置条件(Neecha Bhanga Raja Yoga)。",
|
||||
" The additional placement condition for a Raja Yoga is also met (Neecha Bhanga Raja Yoga)."),
|
||||
False: ("王者格的附加位置条件不满足,所以这里是落陷得到缓解,不算王者格。",
|
||||
" The additional placement condition for a Raja Yoga is not met, so this is a mitigated debilitation, not a Raja Yoga."),
|
||||
}
|
||||
_NEECHA_VARIANT_WORDS = {
|
||||
"light_on_life_p295": ("常规化解条件", "standard cancellation conditions"),
|
||||
"exchange_variant": ("互换星座的变体", "sign-exchange variant"),
|
||||
}
|
||||
|
||||
|
||||
def _neecha_profile(raw: dict) -> str:
|
||||
"""The rule version a Neecha Bhanga row was evaluated under ('' when the row does not say)."""
|
||||
evidence = raw.get("formation_evidence") if isinstance(raw.get("formation_evidence"), dict) else {}
|
||||
@@ -1384,7 +1426,67 @@ def _strength_factor_text(factor: dict, language: str) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def _yoga_strength_text(factors: Any, language: str) -> str:
|
||||
def _yoga_planet_facts(packet: dict) -> dict[str, dict]:
|
||||
"""BUG-2383 (占星师 2026-11-25 M06): each planet's combustion, Shadbala and functional role, already computed."""
|
||||
scores = _dict(_worksheets(packet).get("strengths_and_scores"))
|
||||
chart = _dict(_planets(packet))
|
||||
strength = _dict(_dict(scores.get("shadbala")).get("planets"))
|
||||
functional = _dict(scores.get("functional_benefic_malefic"))
|
||||
roles = {}
|
||||
for key, role in (("functional_benefics", "benefic"), ("functional_malefics", "malefic"), ("functional_neutrals", "neutral")):
|
||||
for name in functional.get(key) or []:
|
||||
roles[str(name)] = role
|
||||
facts: dict[str, dict] = {}
|
||||
for name in ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu"):
|
||||
row = {}
|
||||
if isinstance(_dict(chart.get(name)).get("combust"), bool):
|
||||
row["combust"] = chart[name]["combust"]
|
||||
power = _dict(strength.get(name))
|
||||
if isinstance(power.get("total_rupas"), (int, float)) and isinstance(power.get("min_required"), (int, float)):
|
||||
row["rupas"], row["minimum"] = float(power["total_rupas"]), float(power["min_required"])
|
||||
if name in roles:
|
||||
row["role"] = roles[name]
|
||||
if row:
|
||||
facts[name] = row
|
||||
return facts
|
||||
|
||||
|
||||
_ROLE_WORDS = {"benefic": ("功能吉星", "functional benefic"), "malefic": ("功能凶星", "functional malefic"),
|
||||
"neutral": ("功能中性", "functionally neutral")}
|
||||
|
||||
|
||||
def _planet_state_text(planets: list, facts: dict, language: str) -> tuple[str, set[str]]:
|
||||
"""The participants' own combustion, Shadbala and functional role, and which layers that covers."""
|
||||
zh = language == "zh"
|
||||
covered: set[str] = set()
|
||||
texts = []
|
||||
for name in planets or []:
|
||||
row = _dict((facts or {}).get(name))
|
||||
if not row:
|
||||
continue
|
||||
bits = []
|
||||
if "combust" in row:
|
||||
bits.append(("燃烧" if row["combust"] else "未燃烧") if zh else ("combust" if row["combust"] else "not combust"))
|
||||
if "rupas" in row:
|
||||
bits.append(f"力量 {row['rupas']:.2f} Rupa(最低 {row['minimum']:g})" if zh
|
||||
else f"Shadbala {row['rupas']:.2f} Rupas (minimum {row['minimum']:g})")
|
||||
if "role" in row:
|
||||
bits.append(_ROLE_WORDS[row["role"]][0 if zh else 1])
|
||||
if bits:
|
||||
texts.append(f"{_planet(name, language)}{':' if zh else ': '}{','.join(bits) if zh else ', '.join(bits)}")
|
||||
if texts:
|
||||
names = [name for name in planets or [] if _dict((facts or {}).get(name))]
|
||||
if all("combust" in facts[name] for name in names):
|
||||
covered.add("combustion")
|
||||
if all("rupas" in facts[name] for name in names):
|
||||
covered.add("Shadbala")
|
||||
if all("role" in facts[name] for name in names):
|
||||
covered.add("functional_benefic_malefic")
|
||||
text = (f"参与星本身:{';'.join(texts)}。" if zh else f"The planets themselves: {'; '.join(texts)}.") if texts else ""
|
||||
return text, covered
|
||||
|
||||
|
||||
def _yoga_strength_text(factors: Any, language: str, planet_facts: dict | None = None, planets: list | None = None) -> str:
|
||||
"""BUG-2292: the engine's strength_factors of one yoga, in plain words; nothing when it returned none."""
|
||||
if not isinstance(factors, dict):
|
||||
return ""
|
||||
@@ -1402,8 +1504,13 @@ def _yoga_strength_text(factors: Any, language: str) -> str:
|
||||
texts.append(text)
|
||||
if texts:
|
||||
parts.append(f"{label_zh}:{';'.join(texts)}。" if zh else f"{label_en}: {'; '.join(texts)}.")
|
||||
state_text, covered = _planet_state_text(planets or [], planet_facts or {}, language)
|
||||
if state_text:
|
||||
parts.append(state_text)
|
||||
unassessed = []
|
||||
for layer in factors.get("unassessed_layers") or []:
|
||||
if str(layer).split(".")[-1] in covered:
|
||||
continue
|
||||
word = _UNASSESSED_WORD.get(str(layer).split(".")[-1])
|
||||
if word and (word[0] if zh else word[1]) not in unassessed:
|
||||
unassessed.append(word[0] if zh else word[1])
|
||||
@@ -1476,8 +1583,11 @@ def _yoga_page_titles(entries: list[dict], language: str) -> list[str]:
|
||||
label = planet_names
|
||||
if len(versions) > 1:
|
||||
# BUG-2129: versions are numbered; the title never names a book.
|
||||
# BUG-2380 (占星师 2026-11-25 M04): name the variant (still no book), number only an unknown one.
|
||||
variant = _NEECHA_VARIANT_WORDS.get(str(entry.get("profile") or ""))
|
||||
label += (";" if zh else "; ") + (
|
||||
f"规则版本 {versions.index(entry) + 1}" if zh else f"rule version {versions.index(entry) + 1}"
|
||||
(variant[0] if zh else variant[1]) if variant
|
||||
else (f"规则版本 {versions.index(entry) + 1}" if zh else f"rule version {versions.index(entry) + 1}")
|
||||
)
|
||||
titles.append(f"落陷取消({label})" if zh else f"Neecha Bhanga ({label})")
|
||||
continue
|
||||
@@ -1558,8 +1668,12 @@ def _page_combination(raw: dict, language: str) -> str:
|
||||
|
||||
|
||||
def _is_neecha_bhanga(raw: dict) -> bool:
|
||||
blob = " ".join(str(raw.get(key) or "") for key in ("name", "name_cn", "type", "category", "subtype")).lower()
|
||||
return "neecha" in blob or "nicha" in blob or "落陷" in blob
|
||||
# BUG-2379: one predicate for every table and page (the bare word 「落陷」 also names daridra_2).
|
||||
try:
|
||||
from scripts.report_render.neecha_witness import is_neecha_bhanga_row
|
||||
except ModuleNotFoundError: # pragma: no cover - scripts/ on sys.path
|
||||
from report_render.neecha_witness import is_neecha_bhanga_row
|
||||
return is_neecha_bhanga_row(raw)
|
||||
|
||||
|
||||
def _yoga_name(raw: dict, language: str) -> str:
|
||||
@@ -2668,6 +2782,7 @@ def attach_full_data_interpretation(packet: dict) -> dict:
|
||||
active,
|
||||
language=language,
|
||||
neecha_states=nb_states,
|
||||
planet_facts=_yoga_planet_facts(packet),
|
||||
)
|
||||
# BUG-2089: the dated Sade Sati segments travel with the packet (reader body and the
|
||||
# fact tables read them); computed once per packet.
|
||||
|
||||
@@ -127,11 +127,22 @@ def _neecha_row_verified(planet: Any, layer: dict) -> bool:
|
||||
rows = [row for row in layer.get("rows") or [] if isinstance(row, dict)]
|
||||
rows += [_record(item.get("row")) for item in layer.get("same_fact_rows") or [] if isinstance(item, dict)]
|
||||
for row in rows:
|
||||
if is_neecha_bhanga_row(row) and planet in _row_planets(row) and yoga_status(row)[0] == "formed_under_source":
|
||||
if is_neecha_bhanga_row(row) and _row_fallen(row) == planet and yoga_status(row)[0] == "formed_under_source":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _row_fallen(row: dict) -> Any:
|
||||
"""BUG-2385: the row's own fallen planet. A witness listed in ``planets`` (even a debilitated one) is not
|
||||
the planet this row mitigates; a row without a named fallen planet counts only when it lists one planet."""
|
||||
fallen = _record(row.get("formation_evidence")).get("planet") or row.get("planet")
|
||||
if fallen in PLANETS:
|
||||
return fallen
|
||||
listed = row.get("planets")
|
||||
planets = [name for name in listed if name in PLANETS] if isinstance(listed, (list, tuple, dict)) else []
|
||||
return planets[0] if len(planets) == 1 else None
|
||||
|
||||
|
||||
def _her_neecha_rows(planet: Any, layer: dict) -> list[dict]:
|
||||
"""BUG-2303: the yoga layer's rows of her Neecha Bhanga rules for the debilitated ``planet``."""
|
||||
rows = [row for row in layer.get("rows") or [] if isinstance(row, dict)]
|
||||
@@ -254,8 +265,9 @@ NEECHA_NOTE = {
|
||||
"en": "{planet} is mitigated: the conditions and witnesses are on the \"{title}\" page under Yoga interpretation, and the original debilitation stands.",
|
||||
},
|
||||
"not_computed": {
|
||||
"zh": "{planet}的落陷取消条件这次没有计算,这不表示没有缓解条件。",
|
||||
"en": "The cancellation conditions for {planet}'s debilitation were not computed this time; this does not mean there are none.",
|
||||
# BUG-2386 原值「…这次没有计算,这不表示没有缓解条件。」/ 新值:只写落陷 / 原因:负责人不加两可说法(BUG-2280 同一规则)。
|
||||
"zh": "{planet}落陷。",
|
||||
"en": "{planet} is debilitated.",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -369,7 +381,10 @@ def _planet(name: Any, language: str) -> str:
|
||||
def is_neecha_bhanga_row(row: Any) -> bool:
|
||||
row = _record(row)
|
||||
blob = " ".join(str(row.get(key) or "") for key in ("name", "name_cn", "type", "category", "subtype", "rule_id")).lower()
|
||||
return "neecha" in blob or "nicha" in blob or "落陷" in blob
|
||||
# BUG-2379: the bare word 「落陷」 also names other rules (daridra_2 「第二宫主落陷且在第6、8或12宫」), which were
|
||||
# then shown as a Neecha Bhanga with "witnesses not returned". Only the cancellation itself counts.
|
||||
return ("neecha" in blob or "nicha" in blob or "落陷取消" in blob or "落陷化解" in blob
|
||||
or "neecha_bhanga" in blob or "nicha_bhanga" in blob)
|
||||
|
||||
|
||||
def row_object_planets(row: Any) -> list[str]:
|
||||
|
||||
@@ -1708,17 +1708,52 @@ def _tripataki(packet: dict, language: str) -> str:
|
||||
|
||||
def _trace_table(traces: Any, language: str) -> str:
|
||||
rows = []
|
||||
if isinstance(traces, list):
|
||||
for item in traces:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
rows.append({
|
||||
"name": item.get("name"),
|
||||
"rule": item.get("rule"),
|
||||
"phase": _phase_word(item.get("phase"), language),
|
||||
"longitude": item.get("longitude"),
|
||||
})
|
||||
return _rows_from(rows, language, [("name", "text"), ("rule", "text"), ("phase", "text"), ("longitude", "text")])
|
||||
stepped = isinstance(traces, list) and any(isinstance(item, dict) and item.get("operand_longitudes") for item in traces)
|
||||
if not stepped:
|
||||
if isinstance(traces, list):
|
||||
for item in traces:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
rows.append({
|
||||
"name": item.get("name"),
|
||||
"rule": item.get("rule"),
|
||||
"phase": _phase_word(item.get("phase"), language),
|
||||
"longitude": item.get("longitude"),
|
||||
})
|
||||
return _rows_from(rows, language, [("name", "text"), ("rule", "text"), ("phase", "text"), ("longitude", "text")])
|
||||
# BUG-2378 (M13): the steps — A, B, C, A − B + C, whether C lies on the arc from B to A, +30°, final value.
|
||||
zh = language == "zh"
|
||||
yes, no = ("是", "否") if zh else ("Yes", "No")
|
||||
body = []
|
||||
for item in traces:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
values = item.get("operand_longitudes") if isinstance(item.get("operand_longitudes"), dict) else {}
|
||||
if not values:
|
||||
# A local Saham with no stored steps: its rule, then the value.
|
||||
body.append([show(item.get("name"), language), _phase_word(item.get("phase"), language),
|
||||
show(item.get("rule"), language), "—", "—", "—", "—", "—", show(item.get("longitude"), language)])
|
||||
continue
|
||||
names = dict(zip(("A", "B", "C"), item.get("operands") or ()))
|
||||
cells = []
|
||||
for key in ("A", "B", "C"):
|
||||
value = values.get(key)
|
||||
label = _vivah_name(names.get(key), language).replace("_", " ") if names.get(key) else key
|
||||
cells.append(f"{label} {value:.4f}" if isinstance(value, (int, float)) else undetermined(language))
|
||||
base = item.get("base_longitude")
|
||||
arc = item.get("arc_passes_c")
|
||||
body.append([
|
||||
show(item.get("name"), language), _phase_word(item.get("phase"), language), *cells,
|
||||
f"{base:.4f}" if isinstance(base, (int, float)) else undetermined(language),
|
||||
(yes if arc else no) if isinstance(arc, bool) else undetermined(language),
|
||||
yes if item.get("plus_thirty") else no,
|
||||
show(item.get("longitude"), language),
|
||||
])
|
||||
head = (["名称", "昼夜", "A", "B", "C", "A − B + C", "C 在 B→A 弧上", "加 30°", "最终黄经"] if zh
|
||||
else ["Name", "Phase", "A", "B", "C", "A − B + C", "C on arc B→A", "+30°", "Final longitude"])
|
||||
note = ("算法:A − B + C;C 不在从 B 顺黄道到 A 的弧上时再加 30°。" if zh
|
||||
else "Rule: A − B + C; when C is not on the forward arc from B to A, add 30°.")
|
||||
return note + "\n\n" + _md_table(head, body)
|
||||
|
||||
|
||||
def _annual_numeric(packet: dict, language: str) -> str:
|
||||
@@ -2959,16 +2994,46 @@ YOGA_CATEGORIES: dict[str, tuple[str, str]] = {
|
||||
|
||||
|
||||
def _canonical_yogas(packet: dict, language: str) -> str:
|
||||
"""Every row the yoga check returned, with its kind, formation, missing inputs and sources (BUG-2377)."""
|
||||
try:
|
||||
from .yoga_appendix_fields import condition_source, formation_text, kind_text, meaning_source, missing_text
|
||||
except ImportError: # pragma: no cover
|
||||
from report_render.yoga_appendix_fields import condition_source, formation_text, kind_text, meaning_source, missing_text
|
||||
zh = language == "zh"
|
||||
rows = []
|
||||
named = 0
|
||||
for item in _detected_yoga_rows(packet):
|
||||
named += item.get("claim_kind") == "named_yoga_candidate"
|
||||
rows.append([
|
||||
_english_safe(_public_yoga_name(item, language), language),
|
||||
show(_pair(YOGA_CATEGORIES, item.get("category"), language), language),
|
||||
_yoga_planets_cell(item, language),
|
||||
kind_text(item, language),
|
||||
formation_text(item, language),
|
||||
missing_text(item, language),
|
||||
condition_source(item, language),
|
||||
meaning_source(item, language),
|
||||
])
|
||||
if not rows:
|
||||
return _blank(language, ["name", "category", "planet"])
|
||||
return _md_table([lab("name", language), lab("category", language), lab("planet", language)], rows)
|
||||
# M02: how this table relates to the candidate tables in the body.
|
||||
note = (
|
||||
f"本表列出 Yoga 检查返回的全部 {len(rows)} 行:具名格局 {named} 行,其余是结构观察;落陷化解按每颗落陷星各一行。"
|
||||
"正文的候选瑜伽总表只列具名格局,并把指同一组星盘事实的几行合成一行,所以行数比本表少。"
|
||||
"「还需要」指这条规则判断时还要用到的一项;出处只列书名。"
|
||||
if zh else
|
||||
f"This table lists all {len(rows)} rows the yoga check returned: {named} named yogas, the rest structural observations, "
|
||||
"and one Neecha Bhanga row per debilitated planet. The candidate tables in the body list named yogas only and merge rows "
|
||||
"that rest on the same chart facts, so they have fewer rows. \"Also needs\" names what the rule further uses; "
|
||||
"sources give the book title only."
|
||||
)
|
||||
headers = [lab("name", language), lab("category", language), lab("planet", language)] + (
|
||||
["类型", "形成状态", "还需要", "条件出处", "含义出处"] if zh
|
||||
else ["Kind", "Formation", "Also needs", "Condition source", "Meaning source"]
|
||||
)
|
||||
# The rules evaluated without a conclusion (her M08) stay in the packet's yoga_evaluation for the model;
|
||||
# they are not listed in the reader's report (owner rule: no withheld / unresolved lines for users).
|
||||
return note + "\n\n" + _md_table(headers, rows)
|
||||
|
||||
|
||||
def _occupants(packet: dict, language: str) -> str:
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
"""BUG-2377 (占星师 2026-11-25 M01 / M02 / M05; M08's unresolved rules stay backstage, BUG-2384): per-yoga fields for the appendix yoga table.
|
||||
|
||||
The detector already returns, per row, what kind of statement it is, whether the rule's conditions are all met,
|
||||
which inputs were missing, and where the condition and the meaning come from. The appendix table showed only
|
||||
name, category and planet. These helpers turn those fields into reader words.
|
||||
|
||||
Sources follow the owner's rules: only in appendix data chapters (2026-11-24), book title only — no page, PDF
|
||||
page, line number or table number (BUG-2129), no software library names (BUG-2115).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
KIND_WORDS = {
|
||||
"named_yoga_candidate": ("具名格局", "Named yoga"),
|
||||
"structural_observation": ("结构观察", "Structural observation"),
|
||||
}
|
||||
FORMATION_WORDS = {
|
||||
"conditions_met": ("规则条件都满足", "All rule conditions met"),
|
||||
"incomplete_conditions": ("部分条件满足", "Some conditions met"),
|
||||
"method_requires_review": ("不计为成立(判法不止一种)", "Not counted as formed (more than one way to judge it)"),
|
||||
}
|
||||
_MISSING_WORDS = {
|
||||
"source_admitted_composite_strength_profile": ("综合强弱的判法", "a way to judge overall strength"),
|
||||
"source_admitted_favourable_position_profile": ("「有利位置」的判法", "a way to judge a favourable position"),
|
||||
"neechamsa_scope_and_referents_source_choice": ("落陷分区的判断范围", "the scope of the debilitated division"),
|
||||
"benefic_amsa_source_scope": ("吉星分区的判断范围", "the scope of a benefic division"),
|
||||
"saturn_d3_dispositor": ("土星在 D3 的定位星", "Saturn's dispositor in D3"),
|
||||
}
|
||||
_MISSING_DEFAULT = ("规则用到的另一项输入", "another input the rule uses")
|
||||
_PLANETS_ZH = {"Sun": "太阳", "Moon": "月亮", "Mars": "火星", "Mercury": "水星", "Jupiter": "木星", "Venus": "金星",
|
||||
"Saturn": "土星", "Rahu": "罗睺", "Ketu": "计都"}
|
||||
|
||||
# Book titles a source string may name, in reader words. Anything else is a local rule with no named source.
|
||||
_BOOKS = (
|
||||
(re.compile(r"Three Hundred Important Combinations|^BVR-|^Raman\d|^B\.V\. Raman|^Raman,"), ("B.V. Raman《三百个重要组合》", "B.V. Raman, Three Hundred Important Combinations")),
|
||||
(re.compile(r"Light on Life"), ("《Light on Life》", "Light on Life")),
|
||||
(re.compile(r"PVR Integrated Approach|Integrated Approach"), ("P.V.R. Narasimha Rao《Vedic Astrology: An Integrated Approach》", "P.V.R. Narasimha Rao, Vedic Astrology: An Integrated Approach")),
|
||||
(re.compile(r"^BPHS$"), ("《BPHS》", "BPHS")),
|
||||
(re.compile(r"Phaladeepika|Phaladipika"), ("《Phaladeepika》", "Phaladeepika")),
|
||||
(re.compile(r"^经典$"), ("经典文献", "classical texts")),
|
||||
)
|
||||
_NO_SOURCE = ("本地结构规则,没有具名出处", "local structural rule; no named source")
|
||||
_NOT_LISTED = ("—", "—")
|
||||
|
||||
|
||||
def _pick(pair: tuple[str, str], language: str) -> str:
|
||||
return pair[0] if language == "zh" else pair[1]
|
||||
|
||||
|
||||
def kind_text(row: dict, language: str) -> str:
|
||||
return _pick(KIND_WORDS.get(str(row.get("claim_kind")), _NOT_LISTED), language)
|
||||
|
||||
|
||||
def formation_text(row: dict, language: str) -> str:
|
||||
assessment = row.get("formation_assessment") if isinstance(row.get("formation_assessment"), dict) else {}
|
||||
if assessment.get("status") == "formed_under_source":
|
||||
return "按具名定义成立" if language == "zh" else "Formed under the named definition"
|
||||
return _pick(FORMATION_WORDS.get(str(row.get("formation_status")), _NOT_LISTED), language)
|
||||
|
||||
|
||||
def missing_text(row: dict, language: str) -> str:
|
||||
items = [item for item in row.get("missing_inputs") or [] if isinstance(item, str) and item]
|
||||
if not items:
|
||||
return "—"
|
||||
words = []
|
||||
for item in items:
|
||||
owner, _, key = item.rpartition(".")
|
||||
text = _pick(_MISSING_WORDS.get(key, _MISSING_DEFAULT), language)
|
||||
if owner in _PLANETS_ZH:
|
||||
text = f"{_PLANETS_ZH[owner]}:{text}" if language == "zh" else f"{owner}: {text}"
|
||||
if text not in words:
|
||||
words.append(text)
|
||||
return (";" if language == "zh" else "; ").join(words)
|
||||
|
||||
|
||||
def source_text(value: Any, language: str) -> str:
|
||||
"""The book a source string names, without pages or line numbers; a local rule says so."""
|
||||
if not isinstance(value, str) or not value.strip():
|
||||
return "—"
|
||||
text = value.strip()
|
||||
for pattern, pair in _BOOKS:
|
||||
if pattern.search(text):
|
||||
return _pick(pair, language)
|
||||
return _pick(_NO_SOURCE, language)
|
||||
|
||||
|
||||
def condition_source(row: dict, language: str) -> str:
|
||||
return source_text(row.get("source_reference") or row.get("source"), language)
|
||||
|
||||
|
||||
def meaning_source(row: dict, language: str) -> str:
|
||||
if row.get("meaning_source_reference"):
|
||||
return source_text(row.get("meaning_source_reference"), language)
|
||||
# The rule entry carries its own meaning: same place as the condition.
|
||||
if row.get("traditional_effects") or row.get("effects"):
|
||||
return "同条件出处" if language == "zh" else "same as condition source"
|
||||
return "—"
|
||||
@@ -1990,6 +1990,10 @@ def calc_all_sahams(planet_lons: Dict[str, float],
|
||||
'formula_operands': trace.get('formula_operands'),
|
||||
'formula_variant': trace.get('formula_variant'),
|
||||
'zodiacal_order_exception_applied': trace.get('zodiacal_order_exception_applied'),
|
||||
# BUG-2378: the steps travel to the report's formula trace (operands, A − B + C, arc test).
|
||||
'operand_longitudes': trace.get('operand_longitudes'),
|
||||
'base_longitude': trace.get('base_longitude'),
|
||||
'arc_passes_c': trace.get('arc_passes_c'),
|
||||
}
|
||||
results[result_key] = _saham_dict(trace['longitude'], label, interpretation, trace=trace)
|
||||
|
||||
|
||||
@@ -156,8 +156,13 @@ def build_expression_paths(modules, pages=()):
|
||||
angular = None if not ctx or p not in ctx.planets else ctx.house_of(p) in (1, 4, 7, 10)
|
||||
dignity = None if angular is None else ctx.is_own_sign(p) or ctx.is_exalted(p)
|
||||
state = 'unknown' if angular is None else 'full' if angular and dignity else 'not_met'
|
||||
# BUG-2381 (占星师 2026-11-25 M03): the degree and the dignity word stand beside the two conditions.
|
||||
_deg = (positions.get(p) or {}).get('degree_in_sign')
|
||||
_mt = 'Moolatrikona' in str((positions.get(p) or {}).get('status') or '')
|
||||
_where = _position(ctx, p) + (f'; {float(_deg):.2f}° in sign' if isinstance(_deg, (int, float)) else '') + ('; Moolatrikona' if _mt else '')
|
||||
_where_zh = _position(ctx, p) + (f';星座内 {float(_deg):.2f}°' if isinstance(_deg, (int, float)) else '') + (';Moolatrikona(本垣)' if _mt else '')
|
||||
rows.append(_row('mahapurusha_definition', pair(name+' Yoga', name+' Yoga'), 'capacity', natal, state,
|
||||
[pair(_position(ctx, p), _position(ctx, p)),
|
||||
[pair(_where, _where_zh),
|
||||
pair(f'Angular house: {angular}; own sign or exaltation: {dignity}.',
|
||||
f'角宫:{angular};入庙或入旺:{dignity}。')],
|
||||
pair('The two required conditions are evaluated separately. A favourable dignity alone is not this named Yoga.',
|
||||
@@ -488,7 +493,9 @@ def render_expression_paths(pack, language='en'):
|
||||
lines+=['#### '+say(r['title']),'',say(states[r['state']])+'. '+(meaning if meaning not in seen_meanings else ''),'',
|
||||
('范围:' if zh else 'Scope: ')+say(r['scope']),'']
|
||||
lines += ['- '+say(f) for f in r['facts']]
|
||||
lines += ['',limit if limit not in seen_limits else '', '', ('来源:' if zh else 'Source: ')+say(r['source'])+'.','']
|
||||
# BUG-2382: no book or page in the report body (owner 2026-11-21 BUG-2129, 2026-11-24 density rule 3);
|
||||
# each yoga's book is in the appendix yoga table, and the packet keeps r['source'] for the model.
|
||||
lines += ['',limit if limit not in seen_limits else '', '']
|
||||
seen_meanings.add(meaning);seen_limits.add(limit)
|
||||
if not pack.get('rows'):
|
||||
lines += ['本节缺少已计算的星盘资料,不能判定成立或不成立。' if zh else 'Calculated chart information is unavailable for this section; neither formation nor non-formation can be established.','']
|
||||
|
||||
@@ -78,11 +78,11 @@ def test_notes_under_a_table() -> None:
|
||||
# BUG-2303 原值「¹ 缓解条件和见证星见…;缓解不是新的尊贵等级,原始的落陷不变。」/ 新值:与检出一样的一句 / 原因:同上
|
||||
"木星有缓解:化解条件和见证星见「瑜伽解释」里的「落陷取消(木星)」;原始的落陷不变。",
|
||||
"火星有缓解:按另一种读法,化解条件成立;原始的落陷不变。", # BUG-2280 原值「火星「缓解条件待核」:…不按已缓解处理。」
|
||||
"土星的落陷取消条件这次没有计算,这不表示没有缓解条件。",
|
||||
"土星落陷。", # BUG-2386 原值「土星的落陷取消条件这次没有计算,这不表示没有缓解条件。」/ 原因:负责人不加两可说法
|
||||
]
|
||||
en = neecha_table_notes(list(statuses), statuses, states, "en")
|
||||
assert en[0].startswith("Jupiter is mitigated: the conditions and witnesses are on the \"Neecha Bhanga (Jupiter)\" page")
|
||||
assert en[2] == "The cancellation conditions for Saturn's debilitation were not computed this time; this does not mean there are none."
|
||||
assert en[2] == "Saturn is debilitated." # BUG-2386
|
||||
assert neecha_table_notes(["Sun"], {"Sun": "入旺(Exalted)"}, states, "zh") == []
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ def test_candidate_state_in_a_rendered_table() -> None:
|
||||
uncomputed = {"worksheets": {"d1_rasi_bhava": {"planets": {"Mars": {"status": "落陷(Debilitated)"}}}}}
|
||||
lines = _dignity_section(uncomputed, "en")
|
||||
assert any("| Debilitated |" in line for line in lines)
|
||||
assert "The cancellation conditions for Mars's debilitation were not computed this time; this does not mean there are none." in lines
|
||||
assert "Mars is debilitated." in lines # BUG-2386
|
||||
|
||||
|
||||
@pytest.mark.parametrize("language", ["zh", "en"])
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
"""占星师 2026-11-25 对照的显示层补充(负责人 11-25「显示层的也做了吧」):BUG-2377–2384。
|
||||
|
||||
只用虚构数据和公开盘(Steve Jobs / Barack Obama,AA)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from scripts import pl9_interpretation_packs as packs
|
||||
from scripts.annual_native.saham_traces import attach_formula_traces
|
||||
from scripts.report_render import yoga_appendix_fields as fields
|
||||
from scripts.report_render.neecha_witness import is_neecha_bhanga_row
|
||||
from scripts.report_render.parity_chapters import _trace_table
|
||||
from tests.public_chart_reports import public_chart_reports
|
||||
|
||||
PUBLIC = ("steve_jobs_1955_aa", "barack_obama_1961_aa")
|
||||
|
||||
|
||||
def test_appendix_yoga_table_has_kind_formation_missing_and_sources() -> None:
|
||||
"""BUG-2377 (M01 / M02 / M05)."""
|
||||
for case in PUBLIC:
|
||||
_packet, chinese, english = public_chart_reports(case)
|
||||
assert "| Name | Category | Planet | Kind | Formation | Also needs | Condition source | Meaning source |" in english
|
||||
assert "| 名称 | 类别 | 行星 | 类型 | 形成状态 | 还需要 | 条件出处 | 含义出处 |" in chinese
|
||||
assert "The candidate tables in the body list named yogas only" in english
|
||||
table = english.split("### Canonical Yoga Rows", 1)[1].split("\n## ", 1)[0]
|
||||
# Book titles only: no page, PDF page, line number or software name.
|
||||
assert not re.search(r"\bpp?\.\s?\d|PDF|\bL\d{3,}|printed|PyJHora|corpus", table)
|
||||
|
||||
|
||||
def test_source_text_keeps_the_book_only() -> None:
|
||||
assert fields.source_text("Light on Life, printed p.295 / corpus PDF p.318, L11018-L11046; x", "en") == "Light on Life"
|
||||
assert fields.source_text("B.V. Raman / PyJHora", "en") == "B.V. Raman, Three Hundred Important Combinations"
|
||||
assert fields.source_text("BVR-15: L4 and L9 in mutual Kendras", "zh") == "B.V. Raman《三百个重要组合》"
|
||||
assert fields.source_text("Local structural predicate; former Yoga name …", "zh") == "本地结构规则,没有具名出处"
|
||||
assert fields.source_text("Phaladeepika 6", "zh") == "《Phaladeepika》"
|
||||
assert fields.formation_text({"formation_assessment": {"status": "formed_under_source"}}, "zh") == "按具名定义成立"
|
||||
assert fields.missing_text({"missing_inputs": ["Venus.source_admitted_composite_strength_profile"]}, "zh") == "金星:综合强弱的判法"
|
||||
|
||||
|
||||
def test_saham_table_shows_the_steps() -> None:
|
||||
"""BUG-2378 (M13): A, B, C, A − B + C, the arc test, +30°, final."""
|
||||
results = {"punya_saham": {"name": "Punya Saham", "longitude": 328.5349}}
|
||||
meta = {"punya_saham": {"formula_operands": ["Sun", "Saturn", "Ascendant"], "zodiacal_order_exception_applied": True,
|
||||
"operand_longitudes": {"A": 4.9501, "B": 344.8214, "C": 278.4062},
|
||||
"base_longitude": 298.5349, "arc_passes_c": False, "longitude": 328.5349}}
|
||||
traces = attach_formula_traces(results, is_day=False, formula_meta=meta)
|
||||
assert traces[0]["plus_thirty"] is True and traces[0]["base_longitude"] == 298.5349
|
||||
text = _trace_table(traces, "en")
|
||||
assert "| Name | Phase | A | B | C | A − B + C | C on arc B→A | +30° | Final longitude |" in text
|
||||
assert "| Punya Saham | Night | Sun 4.9501 | Saturn 344.8214 | Ascendant 278.4062 | 298.5349 | No | Yes | 328.5349 |" in text
|
||||
for case in PUBLIC:
|
||||
_packet, chinese, english = public_chart_reports(case)
|
||||
assert "C on arc B→A" in english and "C 在 B→A 弧上" in chinese
|
||||
|
||||
|
||||
def test_second_lord_debilitated_is_not_a_neecha_bhanga() -> None:
|
||||
"""BUG-2379: the bare word 「落陷」 does not make a cancellation row."""
|
||||
daridra = {"rule_id": "daridra_2", "name": "Second lord debilitated in house 6, 8 or 12 (structural observation)",
|
||||
"name_cn": "第二宫主落陷且在第6、8或12宫(结构观察)", "planets": ["Mercury"]}
|
||||
assert not is_neecha_bhanga_row(daridra) and not packs._is_neecha_bhanga(daridra)
|
||||
assert is_neecha_bhanga_row({"rule_id": "neechabhanga_basic", "name": "Neecha Bhanga"})
|
||||
assert is_neecha_bhanga_row({"name": "落陷取消", "name_cn": "落陷取消"})
|
||||
|
||||
|
||||
def test_neecha_variant_names_and_raja_line() -> None:
|
||||
"""BUG-2380 (M04)."""
|
||||
base = {"rule_id": "neechabhanga_basic", "name": "Neecha Bhanga", "name_cn": "落陷取消", "planets": ["Mercury", "Jupiter"],
|
||||
"category": "nicha_bhanga", "combination": "水星落陷于双鱼座", "combination_en": "Mercury debilitated in Pisces",
|
||||
"formation_evidence": {"planet": "Mercury", "profile": "light_on_life_p295", "royal_yoga_candidate": False,
|
||||
"cancellation_reasons": [{"condition": "dispositor_aspect", "planet": "Jupiter"}]}}
|
||||
exchange = {**base, "rule_id": "neechabhanga_parivartana", "name": "Neecha Bhanga (Exchange Variant)",
|
||||
"formation_evidence": {**base["formation_evidence"], "profile": "exchange_variant",
|
||||
"cancellation_reasons": [{"condition": "dispositor_exchange", "planet": "Jupiter"}]}}
|
||||
pages = packs.build_yoga_interpretation_pack({"detected_yogas": [base, exchange]}, {}, set(), language="zh")["pages"]
|
||||
names = [page["name"] for page in pages]
|
||||
assert names == ["落陷取消(水星;常规化解条件)", "落陷取消(水星;互换星座的变体)"], names
|
||||
assert "王者格的附加位置条件不满足" in pages[0]["sections"]["roles"]
|
||||
|
||||
|
||||
def test_mahapurusha_page_agrees_with_its_basis_and_names_the_same_fact() -> None:
|
||||
"""BUG-2381 (M03)."""
|
||||
sasa = {"rule_id": "main_detector:pancha_mahapurusha:saturn", "name": "Sasa Yoga", "name_cn": "萨萨格局",
|
||||
"planets": ["Saturn"], "category": "mahapurusha", "combination": "土星在第7宫水瓶座(入庙)",
|
||||
"combination_en": "Saturn in house 7, Aquarius (own sign)", "strength_factors": {}}
|
||||
kalatra = {"rule_id": "kalatra_yoga_7_kendra", "name": "Kalatra Yoga (7th Lord in Kendra)", "name_cn": "伴侣格局(七宫主在角宫)",
|
||||
"planets": ["Saturn"], "category": "marriage", "combination": "七宫主土星在第7宫"}
|
||||
pages = packs.build_yoga_interpretation_pack({"detected_yogas": [sasa, kalatra]}, {}, set(), language="en")["pages"]
|
||||
page = next(page for page in pages if page["name"].startswith("Sasa"))
|
||||
assert page["sections"]["formation"] == "Configuration: met under the yoga's named definition."
|
||||
assert "The same Saturn placement also underlies: Kalatra Yoga (7th Lord in Kendra)" in page["sections"]["same_fact"]
|
||||
|
||||
|
||||
def test_body_has_no_book_source_lines() -> None:
|
||||
"""BUG-2382: the Yoga Expression chapter in the body prints no 'Source:' line with book pages."""
|
||||
for case in PUBLIC:
|
||||
_packet, chinese, english = public_chart_reports(case)
|
||||
body_en = english.split("## Structured Data Appendix", 1)[0]
|
||||
body_zh = chinese.split("## 结构化数据附录", 1)[0] if "## 结构化数据附录" in chinese else chinese
|
||||
assert not re.search(r"^Source: ", body_en, re.M)
|
||||
assert not re.search(r"^来源:", body_zh, re.M)
|
||||
assert "printed pp." not in body_en
|
||||
|
||||
|
||||
def test_yoga_pages_state_the_participants_own_condition() -> None:
|
||||
"""BUG-2383 (M06): combustion, Shadbala and functional role come from the chart, not 'not assessed'."""
|
||||
facts = {"Sun": {"combust": False, "rupas": 8.34, "minimum": 6.5, "role": "benefic"}}
|
||||
text = packs._yoga_strength_text({"unassessed_layers": ["combustion", "Shadbala", "functional_benefic_malefic", "event_timing"]},
|
||||
"en", facts, ["Sun"])
|
||||
assert "The planets themselves: Sun: not combust, Shadbala 8.34 Rupas (minimum 6.5), functional benefic." in text
|
||||
assert text.endswith("Not assessed for this yoga: event timing.")
|
||||
for case in PUBLIC:
|
||||
_packet, chinese, english = public_chart_reports(case)
|
||||
assert "Not assessed for this yoga: combustion" not in english
|
||||
assert "这一条还没有评估:燃烧" not in chinese
|
||||
|
||||
|
||||
def test_unresolved_rules_stay_backstage() -> None:
|
||||
"""BUG-2384 (M08): rules evaluated without a conclusion stay in the packet for the model, not in the reader's report."""
|
||||
for case in PUBLIC:
|
||||
packet, chinese, english = public_chart_reports(case)
|
||||
assert "yoga_evaluation" in packet["worksheets"]["advanced_systems"]["yoga"]
|
||||
assert "without a conclusion" not in english and "没有得出结论的规则" not in chinese
|
||||
for text in fields.FORMATION_WORDS.values():
|
||||
assert not re.search(r"待核|未解决|还没核实|未选定", text[0])
|
||||
|
||||
|
||||
def test_a_debilitated_witness_is_not_verified_by_another_planets_row() -> None:
|
||||
"""BUG-2385: Jupiter (debilitated) witnessing Mars's cancellation is not itself mitigated by that row."""
|
||||
from scripts.report_render.neecha_witness import _row_fallen
|
||||
|
||||
mars_row = {"rule_id": "neechabhanga_basic", "name": "Neecha Bhanga", "planets": ["Moon", "Mars", "Jupiter"],
|
||||
"formation_evidence": {"planet": "Mars"}}
|
||||
assert _row_fallen(mars_row) == "Mars"
|
||||
assert _row_fallen({"name": "Neecha Bhanga", "planets": ["Moon", "Jupiter"]}) is None
|
||||
assert _row_fallen({"name": "Neecha Bhanga", "planets": ["Jupiter"]}) == "Jupiter"
|
||||
@@ -178,8 +178,12 @@ def test_natal_presence_not_activation_or_date_fabrication():
|
||||
def test_bilingual_identity_negation_dates_and_no_engineering_leak():
|
||||
pack=build_expression_paths(fixture());en=render_expression_paths(pack);zh=render_expression_paths(pack,'zh')
|
||||
assert not re.search(r'[\u4e00-\u9fff]',en)
|
||||
for token in ['2026-01-01','2029-01-01','11.7.3(1)']:
|
||||
for token in ['2026-01-01','2029-01-01']:
|
||||
assert token in en and token in zh
|
||||
# 原值:'11.7.3(1)' 也须出现在正文;新值:正文不印出处,出处留在数据包 rows[].source;
|
||||
# 原因:BUG-2382,负责人规则「出处只放附录和模型输入」(BUG-2129 / 2026-11-24)。
|
||||
assert '11.7.3(1)' not in en and '11.7.3(1)' not in zh
|
||||
assert any('11.7.3(1)' in str(row.get('source')) for row in pack.get('rows', []))
|
||||
assert 'Venus' in en and '金星' in zh
|
||||
# 本站:'/' + 'Users/' 拆开写,避免仓库隐私扫描把这条「不得出现」的断言当成家目录路径(上游原文是连写)。
|
||||
for token in ['schema','rule_id','source_partial','own_sign_terminal','/' + 'Users/','trace']:
|
||||
|
||||
Reference in New Issue
Block a user