fix(report): each rule of a shared chart fact keeps its own condition text (BUG-2113 follow-up)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
This commit is contained in:
@@ -28516,6 +28516,7 @@
|
||||
- 防复发:合并规则只挂在保留行下,不进证据目录。
|
||||
- 关联记录:BUG-2089、BUG-2106、BUG-1976。
|
||||
- 修复版本:`claude/same-fact-2113`。
|
||||
- 补充(2026-11-21):被并进来的规则改用各自的条件文字(问答可读性窗口 BUG-2110 的 `yoga_status_words.rule_condition_text`);它对认不出的定义返回「条件没有随报告列出」,这句不写进事实,改用共用的星盘事实。奥巴马盘:太阳瑜伽(太阳入角宫)=「太阳在第1、4、7、10宫之一」,太阳瑜伽(太阳入7宫)=「太阳在第7宫」。测试 `tests/test_reading_facts_2113.py` 新增一条。
|
||||
|
||||
## BUG-2114 | 年运报告的出生时间说明仍是旧句:整节看起来不可靠、不说是谁选的时间、写「另一种情景下的结论还没有评估」
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ from .evidence_grade import evidence_grades
|
||||
from .narayana_extras_store import ensure_narayana_report_extras
|
||||
from .parity_chapters import _VIMSOPAKA_DIGNITY
|
||||
from .technique_status_axes import technique_audit_axes
|
||||
from .yoga_status_words import rule_condition_text
|
||||
from .transit_natal_sign import (
|
||||
SADE_SATI_SCOPE_ZH, sade_sati_summary_zh, saturn_from_moon, slow_transit_key_dates, transit_natal_sign_facts,
|
||||
)
|
||||
@@ -37,6 +38,8 @@ try:
|
||||
from scripts.consult_facts.evidence_ids import dasha_id, house_id, point_id, shadbala_id, transit_id, yoga_id
|
||||
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution path
|
||||
from consult_facts.evidence_ids import dasha_id, house_id, point_id, shadbala_id, transit_id, yoga_id
|
||||
# BUG-2113 follow-up: the gap line rule_condition_text returns for definitions it cannot word.
|
||||
_RULE_CONDITION_GAP_ZH = "条件没有随报告列出"
|
||||
# BUG-1976: special-lagna keys named the way the chat facts name the same points.
|
||||
POINT_IDS = {"Indu_Lagna": "Indu", "Pranapada_Lagna": "Pranapada", "ViGhati_Lagna": "Vighati"}
|
||||
try:
|
||||
@@ -850,6 +853,21 @@ def _yogas(packet: dict) -> list[dict[str, Any]]:
|
||||
_LATIN_PLANET_AFTER_HAN = re.compile(r"(?<=[\u4e00-\u9fff])(?:Sun|Moon|Mars|Mercury|Jupiter|Venus|Saturn|Rahu|Ketu)(?![A-Za-z])")
|
||||
|
||||
|
||||
def _own_rule_condition(engine_row: dict[str, Any] | None, row: dict[str, Any]) -> str | None:
|
||||
"""Each merged rule's own condition (BUG-2113 follow-up, jyotisha-32's BUG-2110 rule_condition_text).
|
||||
|
||||
The shared report function only knows in_houses definitions and otherwise returns a gap line; that line is
|
||||
never written into the facts, so the rule falls back to the shared fact (the row's combination).
|
||||
"""
|
||||
for source in (engine_row, row):
|
||||
if isinstance(source, dict):
|
||||
text = rule_condition_text(source, "zh")
|
||||
if isinstance(text, str) and text.strip() and text != _RULE_CONDITION_GAP_ZH:
|
||||
return text
|
||||
combination = row.get("combination")
|
||||
return combination if isinstance(combination, str) else None
|
||||
|
||||
|
||||
def _same_fact_rule(evidence: Any, row: dict[str, Any], engine_rows: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
engine_row = _engine_row_for(evidence, engine_rows) if isinstance(evidence, dict) else None
|
||||
name_cn = engine_row.get("name_cn") if engine_row is not None else None
|
||||
@@ -860,7 +878,7 @@ def _same_fact_rule(evidence: Any, row: dict[str, Any], engine_rows: list[dict[s
|
||||
"rule_id": row.get("rule_id") if isinstance(row.get("rule_id"), str) else None,
|
||||
"name": row.get("name") if isinstance(row.get("name"), str) else None,
|
||||
"name_cn": name_cn,
|
||||
"conditions": row.get("combination") if isinstance(row.get("combination"), str) else None,
|
||||
"conditions": _own_rule_condition(engine_row, row),
|
||||
"effects_zh": [item for item in effects if isinstance(item, str) and item.strip()]
|
||||
if isinstance(effects, list) else None,
|
||||
})
|
||||
|
||||
@@ -59,3 +59,18 @@ def test_a_row_without_merged_rules_has_no_block() -> None:
|
||||
block = rf._same_fact_block({"rule_id": "a"}, {**row, "rule_id": "a", "same_fact": [{"rule_id": "b", "name_cn": "乙", "combination": "太阳Sun在第7宫"}]}, [])
|
||||
assert block["shared_fact_zh"] == "太阳在第7宫"
|
||||
assert [rule["rule_id"] for rule in block["rules"]] == ["a", "b"]
|
||||
|
||||
|
||||
def test_merged_rules_carry_their_own_condition_text() -> None:
|
||||
"""BUG-2113 follow-up: each rule's own condition (rule_condition_text), never the report's gap line."""
|
||||
from tests.test_reading_facts_2106 import _facts as built
|
||||
|
||||
facts = built("barack_obama_1961_aa")
|
||||
pairs = {}
|
||||
for entry in facts.get("yogas") or []:
|
||||
block = entry.get("same_fact") if isinstance(entry, dict) else None
|
||||
for rule in (block or {}).get("rules") or []:
|
||||
pairs[rule.get("rule_id")] = rule.get("conditions")
|
||||
assert pairs.get("surya_yoga_kendra") == "太阳在第1、4、7、10宫之一"
|
||||
assert pairs.get("surya_yoga_7") == "太阳在第7宫"
|
||||
assert all(value != "条件没有随报告列出" for value in pairs.values())
|
||||
|
||||
Reference in New Issue
Block a user