diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 3c00161a7..d74824e52 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -32480,6 +32480,24 @@ - **未做(如实)**:其余约 140 条自定义规则仍没有 `participants_expr`,它们的图继续按句子推断并标「示意」;报告端(jyotisha-10)未读 `formation_note_zh`,需要报告窗口决定是否展示。 - **关联记录**:BUG-2387、BUG-2388、BUG-2353/2354(第九项,问答窗口)、BUG-2027、BUG-2301。 +## BUG-2394 | 报告没有显示 Raja 成立行的「实际作用有利有弊」说明;顺带修好 staging 上 7 个报告测试 + +- **状态**:resolved(staging 待推) +- **现象**:BUG-2392 让结构满足的 Raja 格局在引擎里成立,并在行上写 `formation_note_zh` / `formation_note_en`(参与宫主兼管第 6/8/12 宫)。星盘页和问答已读这两个字段,报告三处(正文候选瑜伽总表、瑜伽解释页构型句、附录格局表形成状态格)都没读,读者只看到「成立」。另:分文件重跑报告测试时,staging(不含本改动)上有 7 个报告测试文件失败。 +- **触发条件**:盘上有 Raja 结构规则成立,且参与宫主兼管第 6、8 或 12 宫(公开盘 Barack Obama:水星同时管第 6 宫)。 +- **根因**:字段是 BUG-2392 新加的,报告端渲染代码不认识它。7 个旧失败:① BUG-2366/2381/2382 直接改了占星师逐字复制的 `scripts/yoga_expression_paths.py`,违反「上游文件逐字一致、差异放本站文件」(负责人 2026-11-07),`test_the_module_is_upstream_verbatim` 失败;② BUG-2377 附录「瑜伽条目」表按 2026-11-24「出处只放附录数据章节」写书名,而 BUG-2129 / BUG-2122 的测试仍按 11-21 检查全文;③ BUG-2367「仅为细运主星」单元格,`test_report_fields_2065b` 未跟上;④ BUG-2266 中文表头改「最低线」、检查文字不再写 BPHS、参数敏感说明改写,`test_report_narayana_shadbala_20261111` 两条仍按旧表头和旧文字判断;⑥ 占星师规则文字「仅核对原书位置结构」「保留原书的…」在 Obama 报告里出现「原书」(BUG-2129 禁止);⑤ `test_report_status_words_20261111`(Python 与前端对 Neecha 成立行状态词不一致,非本窗口改动,转协调窗口)。这些改动当时只跑了快速门禁,相关文件没跑。 +- **修复**: + - `scripts/report_render/yoga_appendix_fields.py`:`formation_note` / `with_formation_note`,附录形成状态格在「按具名定义成立」后接说明。 + - `scripts/pl9_interpretation_packs.py`:成立行把说明记到页上,构型句后接说明。 + - `scripts/pl9_reader_export.py`:正文表成立行的说明接在「作用」格后(状态格只放固定状态词,BUG-2104)。 + - `scripts/yoga_expression_paths.py` 恢复为上游 58f37ee5b 原样;BUG-2366(分盘宫位按该分盘上升推算、未知时只写星座)、BUG-2381(Mahapurusha 度数与 Moolatrikona)、BUG-2382(正文不印「来源:」行)移到 `scripts/report_render/expression_paths_wiring.py`(`_fill_varga_houses`、`_drop_house_not_supplied`、`_mahapurusha_degree`、`render_paths`),报告输出不变。 + - `scripts/report_render/yoga_effect_gate.reader_text`:中文规则文字里的「原书」改为「原规则」(格局页各段与正文表格都经过它)。 + - 测试按原值/新值/原因更新:2129、2122 改为检查附录「瑜伽条目」表之外(`tests/public_chart_reports.without_appendix_yoga_sources`);2065b、2110 允许「仅为细运主星」;Shadbala 表头按「最低线」、达标按 `meets_minimum`、参数敏感说明取自 `row_check_text`;`test_yoga_expression_paths` 恢复上游断言。 +- **验证**:新测 `tests/test_report_formation_note_2394.py` 5 条(附录格、解释页、公开盘三处出现、上游渲染器原样而本站渲染去掉出处行、「原书」改写);逐文件重跑 59 个相关报告测试文件,除 `test_report_reader_wording_2104`、`test_report_status_words_20261111`(staging 上同样失败,协调窗口 BUG-2403 处理)外全部通过。 +- **防复发**:报告改动推送前跑相关报告测试文件,不只快速门禁;上游复制文件只在本站衔接文件里做差异。 +- **关联记录**:BUG-2392、BUG-2377、BUG-2369、BUG-2366、BUG-2381、BUG-2382、BUG-2367、BUG-2129、BUG-2266、BUG-2296。 +- **修复版本**:1.5(待发)。 + ## BUG-2390 | 发布前在同一个 SHA 上把完整检查再跑一遍,正式发布多等约 25 分钟 - **状态**:resolved(分支 `claude/ci-speed-2390`,待推) diff --git a/scripts/pl9_interpretation_packs.py b/scripts/pl9_interpretation_packs.py index d6b4243a5..5b12b83f5 100644 --- a/scripts/pl9_interpretation_packs.py +++ b/scripts/pl9_interpretation_packs.py @@ -1059,6 +1059,10 @@ def build_yoga_interpretation_pack( 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-2394: the engine's modifier note (BUG-2392) follows the formation sentence. + _note = raw.get("formation_note_zh" if language == "zh" else "formation_note_en") + if isinstance(_note, str) and _note.strip() and not entry.get("formation_note"): + entry["formation_note"] = _note.strip() # 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. @@ -1142,6 +1146,8 @@ def build_yoga_interpretation_pack( "构型:按该格局的具名定义,条件满足。" if entry.get("formed_under_source") else "构型:检测规则匹配到这个格局;是否完全符合它的具名定义,还没有逐条核对。" ) + if entry.get("formed_under_source") and entry.get("formation_note"): + sections["formation"] += entry["formation_note"] sections["limits"] = ( f"限制发挥的因素:{';'.join(limits)}。" if limits # BUG-2292: with the strength factors on the page, the planets' own state is the next line. @@ -1154,6 +1160,8 @@ def build_yoga_interpretation_pack( "Configuration: met under the yoga's named definition." if entry.get("formed_under_source") else "Configuration: the detection rule for this yoga matched; whether it fully meets the named definition has not been checked item by item." ) + if entry.get("formed_under_source") and entry.get("formation_note"): + sections["formation"] += " " + entry["formation_note"] sections["limits"] = ( f"What limits it: {'; '.join(limits)}." if limits else "What limits it: this row returned no reduction of the yoga itself; the planets' own strength is in the next paragraph." diff --git a/scripts/pl9_reader_export.py b/scripts/pl9_reader_export.py index 9066617dc..cf11c99ee 100644 --- a/scripts/pl9_reader_export.py +++ b/scripts/pl9_reader_export.py @@ -4182,6 +4182,17 @@ def render_pl9_parity_markdown(packet: dict) -> str: # BUG-2104: the English edition printed the raw key (`candidate`); now the reader text. state = yoga_status_cell(key, state_text, _lang) yoga_name, category_cell, strength, combination, effect_text = _yoga_row_cells(row) + # BUG-2394: a formed row's modifier note from the engine (BUG-2392) follows its effect text; + # the status column keeps only the fixed status words (BUG-2104). + if key == 'formed_under_source': + try: + from scripts.report_render.yoga_appendix_fields import formation_note + except ModuleNotFoundError: # pragma: no cover + from report_render.yoga_appendix_fields import formation_note + _note_row = evidence if isinstance(evidence, dict) and (evidence.get('formation_note_zh') or evidence.get('formation_note_en')) else row + _note = formation_note(_note_row, 'en' if _lang == 'en' else 'zh') + if _note and _note not in (effect_text or ''): + effect_text = f"{effect_text}{';' if _lang != 'en' else '; '}{_note}" if effect_text else _note # BUG-2089: other rule names that hit this same fact share the row; names and # each name's own effect text are listed side by side, nothing is counted twice. _others = [(list(_yoga_row_cells(other)), other) for other in _list(row.get('same_fact')) if isinstance(other, dict)] @@ -4229,10 +4240,10 @@ def render_pl9_parity_markdown(packet: dict) -> str: # one heading level down so it sits under this chapter. Sources stay (负责人 2026-11-24: appendix only). try: from report_render.expression_paths_wiring import stored_expression_paths as _stored_paths - from yoga_expression_paths import render_expression_paths as _render_paths + from report_render.expression_paths_wiring import render_paths as _render_paths except ImportError: # pragma: no cover - package import from scripts.report_render.expression_paths_wiring import stored_expression_paths as _stored_paths - from scripts.yoga_expression_paths import render_expression_paths as _render_paths + from scripts.report_render.expression_paths_wiring import render_paths as _render_paths _paths = _stored_paths(packet) if _paths and _paths.get('rows'): _rendered = _render_paths(_paths, 'en' if _lang == 'en' else 'zh').strip() diff --git a/scripts/report_render/expression_paths_wiring.py b/scripts/report_render/expression_paths_wiring.py index bf52c0afd..4f92cad5a 100644 --- a/scripts/report_render/expression_paths_wiring.py +++ b/scripts/report_render/expression_paths_wiring.py @@ -1,5 +1,7 @@ """BUG-2296 (占星师 2026-11-23 信息密度交接 §2–3, 产品负责人 2026-11-24「接着做」): this site's wiring for the astrologer's ``yoga_expression_paths`` module, which is copied verbatim from upstream 58f37ee5b. +Our product differences (BUG-2366 varga house, BUG-2381 Mahapurusha degree, BUG-2382 no body source line) live +here, so her file stays byte-identical (owner 2026-11-07: differences only in separate product files). Her module reads the full reading's modules. This file only adapts this site's shapes to hers, without changing any value: @@ -60,8 +62,31 @@ def _dasha(module: Any, pd_usable: bool) -> Any: return out +def _fill_varga_houses(varga_full: Any) -> Any: + """BUG-2366: varga rows carry sign_idx but no house; the house is counted from that varga's own + Ascendant (the data tables print it), so her module never writes 「宫位未提供」 for a known house.""" + if not isinstance(varga_full, dict): + return varga_full + out = {} + for key, varga in varga_full.items(): + if not isinstance(varga, dict): + out[key] = varga + continue + asc = _dict(varga.get("Ascendant")).get("sign_idx") + filled = {} + for name, item in varga.items(): + if (isinstance(item, dict) and item.get("house") is None and isinstance(item.get("sign_idx"), int) + and isinstance(asc, int)): + item = {**item, "house": (item["sign_idx"] - asc) % 12 + 1} + filled[name] = item + out[key] = filled + return out + + def expression_modules(full_reading: dict, pd_usable: bool) -> dict: modules = copy.copy(_dict(_dict(full_reading).get("modules"))) + if "varga_full" in modules: + modules["varga_full"] = _fill_varga_houses(modules["varga_full"]) if "functional_benefic_malefic" in modules: modules["functional_benefic_malefic"] = _functional(modules["functional_benefic_malefic"]) if "dasha" in modules: @@ -101,9 +126,65 @@ def compute_expression_paths(full_reading: dict, packet: dict) -> dict: paths.setdefault("status", "computed") paths["pd_used"] = pd_usable _translate_annual_values(paths) + _drop_house_not_supplied(paths) + _mahapurusha_degree(paths, _dict(_dict(shim["raw_full_reading"]["modules"].get("chart")).get("planets"))) return paths +def _drop_house_not_supplied(paths: dict) -> None: + """BUG-2366: a divisional fact whose house is still unknown says the sign only, not 「宫位未提供」.""" + for row in paths.get("rows") or []: + for fact in (row.get("facts") or []) if isinstance(row, dict) else []: + if isinstance(fact, dict): + if isinstance(fact.get("zh"), str): + fact["zh"] = fact["zh"].replace(",宫位未提供;", ";") + if isinstance(fact.get("en"), str): + fact["en"] = fact["en"].replace(", house not supplied;", ";") + + +def _mahapurusha_degree(paths: dict, positions: dict) -> None: + """BUG-2381 (占星师 2026-11-25 M03): the degree and the dignity word stand beside the two conditions.""" + for row in paths.get("rows") or []: + if not isinstance(row, dict) or row.get("kind") != "mahapurusha_definition" or not row.get("facts"): + continue + planet = (row.get("participants") or [None])[0] + data = _dict(positions.get(planet)) + degree = data.get("degree_in_sign") + moola = "Moolatrikona" in str(data.get("status") or "") + first = row["facts"][0] + if not isinstance(first, dict) or not str(first.get("en", "")).startswith(f"{planet}: "): + continue + if isinstance(degree, (int, float)): + first["en"] = f"{first['en']}; {float(degree):.2f}° in sign" + first["zh"] = f"{first['zh']};星座内 {float(degree):.2f}°" + if moola: + first["en"] = f"{first['en']}; Moolatrikona" + first["zh"] = f"{first['zh']};Moolatrikona(本垣)" + + +def render_paths(paths: dict, language: str) -> str: + """Her renderer, without the per-path 「来源:」 line: 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 stored rows keep ``source`` for the model.""" + try: + from scripts.yoga_expression_paths import render_expression_paths + except ModuleNotFoundError: # pragma: no cover - scripts/ on sys.path + from yoga_expression_paths import render_expression_paths + lines = render_expression_paths(paths, language).split("\n") + out: list[str] = [] + skip_blank = False + for line in lines: + if line.startswith("来源:") or line.startswith("Source: "): + skip_blank = True + continue + if skip_blank and line == "": + skip_blank = False + continue + skip_blank = False + out.append(line) + return "\n".join(out) + + # BUG-2291 follow-up: her annual rows translate only the affliction values she lists; this site's annual # producer also returns these two, which printed raw (「限制条件:retrograde」「dusthana_宫」). _AFFLICTION_ZH = {"retrograde": "逆行", "dusthana_house": "落在六、八、十二宫"} diff --git a/scripts/report_render/yoga_appendix_fields.py b/scripts/report_render/yoga_appendix_fields.py index d69ef0450..bb110f256 100644 --- a/scripts/report_render/yoga_appendix_fields.py +++ b/scripts/report_render/yoga_appendix_fields.py @@ -53,10 +53,27 @@ def kind_text(row: dict, language: str) -> str: return _pick(KIND_WORDS.get(str(row.get("claim_kind")), _NOT_LISTED), language) +def formation_note(row: Any, language: str) -> str: + """BUG-2394: the engine's plain modifier note on a formed row (BUG-2392, e.g. a Raja lord that also rules 6/8/12).""" + if not isinstance(row, dict): + return "" + note = row.get("formation_note_zh" if language == "zh" else "formation_note_en") + return note.strip() if isinstance(note, str) else "" + + +def with_formation_note(text: str, row: Any, language: str) -> str: + note = formation_note(row, language) + if not note or note in text: + return text + if language == "zh": + return f"{text.rstrip('。')}。{note}" + return f"{text.rstrip('.')}. {note}" + + 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 with_formation_note("按具名定义成立" if language == "zh" else "Formed under the named definition", row, language) return _pick(FORMATION_WORDS.get(str(row.get("formation_status")), _NOT_LISTED), language) diff --git a/scripts/report_render/yoga_effect_gate.py b/scripts/report_render/yoga_effect_gate.py index a77307bb0..630bb49d0 100644 --- a/scripts/report_render/yoga_effect_gate.py +++ b/scripts/report_render/yoga_effect_gate.py @@ -56,6 +56,9 @@ _PENDING_EN = _re.compile(r"pending review|under review|\bunresolved\b|not yet a def reader_text(text: Any, language: str = "zh") -> str: """``text`` without the clauses that tell the reader a qualifier is still being decided (BUG-2304).""" value = str(text or "") + if language != "en": + # BUG-2394: her rule texts say 「原书」 (「仅核对原书位置结构」); the report names no book (BUG-2129). + value = value.replace("原书", "原规则") pattern = _PENDING_ZH if language != "en" else _PENDING_EN if not pattern.search(value): return value diff --git a/scripts/yoga_expression_paths.py b/scripts/yoga_expression_paths.py index a332af185..11b8e910c 100644 --- a/scripts/yoga_expression_paths.py +++ b/scripts/yoga_expression_paths.py @@ -156,13 +156,8 @@ 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(_where, _where_zh), + [pair(_position(ctx, p), _position(ctx, p)), 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.', @@ -304,18 +299,9 @@ def build_expression_paths(modules, pages=()): if not item: varga=next((v for k,v in (modules.get('varga_full') or {}).items() if k.startswith(div+'_')), {}) item=varga.get(p) if isinstance(varga,dict) else None - # BUG-2366: varga_full rows carry sign_idx but no house; the house is counted from - # that varga's own Ascendant (the data tables print it), never left as "not supplied". - asc=(varga.get('Ascendant') or {}) if isinstance(varga,dict) else {} - if item and item.get('house') is None and isinstance(item.get('sign_idx'),int) and isinstance(asc.get('sign_idx'),int): - item={**item,'house':(item['sign_idx']-asc['sign_idx'])%12+1} if item and item.get('sign'): - if item.get('house') is not None: - facts.append(pair(f'{div}: {p} in {item["sign"]}, house {item["house"]}; separate divisional scope.', - f'{div}:{p}在{item["sign"]},第{item["house"]}宫;属于独立分盘范围。')) - else: - facts.append(pair(f'{div}: {p} in {item["sign"]}; separate divisional scope.', - f'{div}:{p}在{item["sign"]};属于独立分盘范围。')) + facts.append(pair(f'{div}: {p} in {item["sign"]}, house {item.get("house", "not supplied")}; separate divisional scope.', + f'{div}:{p}在{item["sign"]},宫位{item.get("house", "未提供")};属于独立分盘范围。')) chain=chains.get(p) or [];state=chain_state(chain) path=' → '.join([x['planet'] for x in chain]+[chain[-1]['dispositor']]) if chain and state!='missing' else 'unavailable' facts.append(pair(f'Dispositor path: {path}; termination: {state}. A link does not automatically transmit beneficial results.', @@ -493,9 +479,7 @@ 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']] - # 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 '', ''] + lines += ['',limit if limit not in seen_limits else '', '', ('来源:' if zh else 'Source: ')+say(r['source'])+'.',''] 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.',''] diff --git a/tests/public_chart_reports.py b/tests/public_chart_reports.py index df22d1bdb..3b42bd855 100644 --- a/tests/public_chart_reports.py +++ b/tests/public_chart_reports.py @@ -30,3 +30,18 @@ def public_chart_reports(case_id: str) -> tuple[dict, str, str]: english_packet["report_language"] = "en" english = _pl9_export_markdown_for_edition(english_packet, "full_data") return packet, chinese, english + + +def without_appendix_yoga_sources(markdown: str) -> str: + """The report minus the appendix yoga table (「瑜伽条目」 / "Canonical Yoga Rows"). + + Owner 2026-11-24 (density handoff rule 3): a yoga's book source may appear only in the appendix data + chapters; that table carries 条件出处 / 含义出处 (BUG-2377). Everything else stays book-free (BUG-2129). + """ + for heading in ("\n### 瑜伽条目\n", "\n### Canonical Yoga Rows\n"): + start = markdown.find(heading) + if start < 0: + continue + ends = [index for index in (markdown.find("\n## ", start + 1), markdown.find("\n### ", start + 1)) if index > 0] + markdown = markdown[:start] + (markdown[min(ends):] if ends else "") + return markdown diff --git a/tests/test_report_astro_review_2110.py b/tests/test_report_astro_review_2110.py index bc4f42673..a626ab261 100644 --- a/tests/test_report_astro_review_2110.py +++ b/tests/test_report_astro_review_2110.py @@ -185,7 +185,11 @@ def test_house_lord_column_asks_about_all_three_dasha_levels(case_id): assert len(starts) == 2 for start in starts: cells = [lines[start + 2 + offset].rstrip(" |").rsplit("| ", 1)[-1] for offset in range(12)] - assert set(cells) <= ({"是", "否"} if language == "zh" else {"Yes", "No"}) and len(set(cells)) == 2, cells + # 原值:只允许「是/否」 / 新值:另允许 PD 不稳定时的「仅为细运主星」 / 原因:BUG-2367 起 PD 主星只在 + # 出生时刻范围稳定时算作当前主星,否则单独写明(staging 上此断言自 BUG-2367 起失败,BUG-2394 补)。 + pd_only = {"仅为细运主星(按填写的出生时刻)"} if language == "zh" else {"PD only, at the entered birth minute"} + assert set(cells) <= ({"是", "否"} if language == "zh" else {"Yes", "No"}) | pd_only, cells + assert {"是", "否"} <= set(cells) if language == "zh" else {"Yes", "No"} <= set(cells), cells # The BUG-2076 sentence elsewhere stays. assert ("这只说明这条直接路径没有对上" in markdown) if language == "zh" else ("not a current Dasha lord" in markdown) # No current dasha returned: unknown, never 「否」. diff --git a/tests/test_report_conditional_dasha_pvr_2122.py b/tests/test_report_conditional_dasha_pvr_2122.py index 07f522add..95039a88f 100644 --- a/tests/test_report_conditional_dasha_pvr_2122.py +++ b/tests/test_report_conditional_dasha_pvr_2122.py @@ -11,7 +11,7 @@ from __future__ import annotations from scripts.report_render import parity_chapters as pc from scripts.report_render.conditional_dasha_applicability import applicability_rows from scripts.report_render.conditional_dasha_pvr_2014 import pvr_variant_rows -from tests.public_chart_reports import public_chart_reports +from tests.public_chart_reports import public_chart_reports, without_appendix_yoga_sources PERIOD = [{"lord": "Sun", "start_date": "2000-01-01", "end_date": "2006-01-01"}] # 原值: ", PVR unified nakshatra-dasa reading (2014)" /「,PVR 统一星宿大运读法(2014)」 @@ -139,7 +139,9 @@ def test_public_fixtures_show_both_readings_in_both_editions() -> None: # 原值: assert "Unified Nakshatra Dasa Approach" in en and … in zh(表注写文章名) # 新值: 表注不写作者和文章名 # 原因: BUG-2129 - assert "Unified Nakshatra Dasa Approach" not in en + zh and "Narasimha Rao" not in en + zh + # 原值: 全文检查;新值: 附录「瑜伽条目」表之外检查;原因: 负责人 2026-11-24 出处只放附录数据章节,BUG-2377 在该表写书名 + body = without_appendix_yoga_sources(en) + without_appendix_yoga_sources(zh) + assert "Unified Nakshatra Dasa Approach" not in body and "Narasimha Rao" not in body # 原值: 「没有按宫头度数另划宫界」 / "not by house-cusp degrees" # 新值: 「没有按度数另划宫界」 / "not by degree-based house boundaries",并写明使用本报告参数、不是完整复现 # 原因: BUG-2159 占星师 2026-11-22 第 8.2 项 diff --git a/tests/test_report_fields_2065b.py b/tests/test_report_fields_2065b.py index ba3c3b847..d0c73fa31 100644 --- a/tests/test_report_fields_2065b.py +++ b/tests/test_report_fields_2065b.py @@ -108,8 +108,11 @@ def test_house_lord_table_counts_the_current_pd_lord_and_names_the_levels(editio # 原值: (en, "Dasha activation (MD/AD/PD)", {...}), (zh, "大运激活(大运/小运/细运)", {"当前运行", "当前大运层"}) # 新值: 表头问三级主星,单元格为 Yes / 是 # 原因: BUG-2110 占星师 2026-11-21:「是否为当前大运/小运/细运主星」 - (en, "Current MD / AD / PD lord?", {"Yes"}), - (zh, "是否为当前大运/小运/细运主星", {"是"}), + # 原值: {"Yes"} / {"是"} + # 新值: 另允许「仅为细运主星(按填写的出生时刻)」 + # 原因: BUG-2367 起 PD 主星只在出生时刻范围稳定时算作当前主星,否则单独写明(staging 上自 BUG-2367 起失败,BUG-2394 补) + (en, "Current MD / AD / PD lord?", {"Yes", "PD only, at the entered birth minute"}), + (zh, "是否为当前大运/小运/细运主星", {"是", "仅为细运主星(按填写的出生时刻)"}), ): tables = [table for table in _tables(markdown, "| ") if table[0][-1] == header] assert tables, header diff --git a/tests/test_report_formation_note_2394.py b/tests/test_report_formation_note_2394.py new file mode 100644 index 000000000..046b4f497 --- /dev/null +++ b/tests/test_report_formation_note_2394.py @@ -0,0 +1,59 @@ +"""BUG-2394: the engine's modifier note on a formed Raja row (BUG-2392) reaches the report. + +Public chart only (Barack Obama, AA) plus synthetic rows. +""" + +from __future__ import annotations + +from scripts import pl9_interpretation_packs as packs +from scripts.report_render import yoga_appendix_fields as fields +from tests.public_chart_reports import public_chart_reports + +ROW = {"rule_id": "raja_mutual_aspect", "name": "Raja Yoga (Mutual Aspect)", "name_cn": "王者格局(互视)", + "planets": ["Mercury", "Saturn"], "category": "raja", + "formation_assessment": {"status": "formed_under_source"}, + "formation_note_zh": "实际作用有利有弊:水星同时管第 6 宫。", + "formation_note_en": "Mixed in effect: Mercury also rules house 6."} + + +def test_appendix_formation_cell_carries_the_note() -> None: + assert fields.formation_text(ROW, "zh") == "按具名定义成立。实际作用有利有弊:水星同时管第 6 宫。" + assert fields.formation_text(ROW, "en") == "Formed under the named definition. Mixed in effect: Mercury also rules house 6." + plain = {k: v for k, v in ROW.items() if not k.startswith("formation_note")} + assert fields.formation_text(plain, "zh") == "按具名定义成立" + + +def test_yoga_page_formation_line_carries_the_note() -> None: + for language, expected in (("zh", "构型:按该格局的具名定义,条件满足。实际作用有利有弊:水星同时管第 6 宫。"), + ("en", "Configuration: met under the yoga's named definition. Mixed in effect: Mercury also rules house 6.")): + pages = packs.build_yoga_interpretation_pack({"detected_yogas": [ROW]}, {}, set(), language=language)["pages"] + assert pages[0]["sections"]["formation"] == expected + + +def test_public_report_shows_the_note_in_body_page_and_appendix() -> None: + _packet, chinese, english = public_chart_reports("barack_obama_1961_aa") + assert chinese.count("实际作用有利有弊:水星同时管第 6 宫。") == 3 + assert english.count("Mixed in effect: Mercury also rules house 6.") == 3 + # The body table's status column keeps the fixed status words (BUG-2104); the note follows the effect text. + assert "按所选规则的形成条件成立;强度和结果另评。实际作用有利有弊" not in chinese + assert "权力地位;影响力;实际作用有利有弊:水星同时管第 6 宫。" in chinese + + +def test_her_module_stays_verbatim_and_our_render_drops_the_source_line() -> None: + """BUG-2394: BUG-2366 / 2381 / 2382 live in expression_paths_wiring, her renderer is untouched.""" + from scripts.report_render.expression_paths_wiring import render_paths + from scripts.yoga_expression_paths import render_expression_paths + pack = {"rows": [{"kind": "x", "topic": "career", "title": {"en": "T", "zh": "T"}, "state": "full", + "meaning": {"en": "M", "zh": "M"}, "scope": {"en": "S", "zh": "S"}, "facts": [{"en": "F", "zh": "F"}], + "boundary": {"en": "B", "zh": "B"}, "source": "Book 11.7.3(1)"}]} + for language in ("en", "zh"): + assert "11.7.3(1)" in render_expression_paths(pack, language) + ours = render_paths(pack, language) + assert "11.7.3(1)" not in ours and "来源:" not in ours and "Source: " not in ours + assert "\n\n\n" not in ours + + +def test_rule_texts_name_no_book() -> None: + """BUG-2394: 「原书」 in her rule texts reads 「原规则」 in the report (BUG-2129).""" + from scripts.report_render.yoga_effect_gate import reader_text + assert reader_text("仅核对原书位置结构,不据此判断视力。", "zh") == "仅核对原规则位置结构,不据此判断视力。" diff --git a/tests/test_report_narayana_shadbala_20261111.py b/tests/test_report_narayana_shadbala_20261111.py index 1062e613c..c6c9fafca 100644 --- a/tests/test_report_narayana_shadbala_20261111.py +++ b/tests/test_report_narayana_shadbala_20261111.py @@ -269,12 +269,19 @@ def test_strength_audit_and_facts_use_same_per_planet_results_as_the_table(case_ # 原值: 按 "| Required | BPHS minimum |" 切 # 新值: 按 "| 所需(Rupa) | BPHS minimum |" 切 # 原因: BUG-2065 合计是 Virupa、所需是 Rupa,表头各写单位 - strength_table = [line for line in report.split("| 所需(Rupa) | BPHS minimum |", 1)[1].split("\n\n", 1)[0].splitlines() - if line.startswith("|") and "取决于未定" in line] + # 原值: 按 "| 所需(Rupa) | BPHS minimum |" 切 + # 新值: 按 "| 所需(Rupa) | 最低线 |" 切 + # 原因: BUG-2266 数据章节不写 BPHS,中文表头改为「最低线」(测试当时未跟上,BUG-2394 补) + strength_table = [line for line in report.split("| 所需(Rupa) | 最低线 |", 1)[1].split("\n\n", 1)[0].splitlines() + # 原值: 行内含「取决于未定」;新值: 行内含「其他取法结果不同」;原因: 参数敏感行改写为 + # 「按本报告所用方法达到/未达到最低线;其他取法结果不同」(测试未跟上,BUG-2394 补) + if line.startswith("|") and "其他取法结果不同" in line] sensitive = {planet_name(name, "zh") for name, row in planets.items() if row["minimum_check_status"] == PARAMETER_SENSITIVE} assert sensitive - assert set(summary.split(" 是否达到", 1)[0].split("、")) == sensitive + # 原值: 按「 是否达到」切;新值: 按代码同一来源的参数敏感说明切;原因: 说明改为「按本报告所用方法的结果见合计…」 + qualifier = row_check_text({"minimum_check_status": PARAMETER_SENSITIVE}, "zh").removeprefix(PARAMETER_SENSITIVE).strip().strip("()()") + assert set(summary.split(" " + qualifier, 1)[0].split("、")) == sensitive assert {line.split("|")[1].strip() for line in strength_table if line.startswith("|")} == sensitive facts = build_report_reading_facts(packet, {}, minute_confirmed=True, today=DAY) # 原值: 每星只有 minimum_check_status 与 meets_minimum @@ -302,7 +309,9 @@ def test_all_determinate_strength_audit_keeps_each_planets_verdict(): assert "取决于未定" not in note summary = note.split("Shadbala:", 1)[1].split(";", 1)[0] assert set(summary.split("、")) == { - f"{planet_name(name, 'zh')} {'达标' if row_check_text(row) == '达到 BPHS 最低要求' else '未达标'}" + # 原值: 按 row_check_text(row) == '达到 BPHS 最低要求' 判达标;新值: 按 row_fields(row)["meets_minimum"]; + # 原因: BUG-2266 检查文字不再写 BPHS,旧比较永远为假(测试未跟上,BUG-2394 补) + f"{planet_name(name, 'zh')} {'达标' if row_fields(row)['meets_minimum'] else '未达标'}" for name, row in planets.items() } diff --git a/tests/test_report_no_book_citations_2129.py b/tests/test_report_no_book_citations_2129.py index 26b5bc642..4fd38db0f 100644 --- a/tests/test_report_no_book_citations_2129.py +++ b/tests/test_report_no_book_citations_2129.py @@ -14,7 +14,7 @@ from scripts.narayana_legacy_label import RATH_LABEL_EN, RATH_LABEL_ZH, report_r from scripts.rashi_dasha_report import _method_line from scripts.report_render.book_refs import strip_book_refs from scripts.report_render.functional_layer_table import functional_layer_rows -from tests.public_chart_reports import PUBLIC_REPORT_CASES, public_chart_reports +from tests.public_chart_reports import PUBLIC_REPORT_CASES, public_chart_reports, without_appendix_yoga_sources BOOK_TITLES = ( "Predicting through Jaimini", "Vedic Astrology: An Integrated Approach", "Integrated Approach", @@ -30,7 +30,10 @@ CITATION = re.compile( @pytest.mark.parametrize("case_id", PUBLIC_REPORT_CASES) def test_public_reports_have_no_book_citations(case_id: str) -> None: _packet, zh, en = public_chart_reports(case_id) - for text in (zh, en): + # 原值: 全文不得出现书名 + # 新值: 附录「瑜伽条目」表之外不得出现书名 + # 原因: 负责人 2026-11-24 信息密度交接第 3 条:出处只放附录数据章节;BUG-2377 在该表加「条件出处 / 含义出处」 + for text in (without_appendix_yoga_sources(zh), without_appendix_yoga_sources(en)): hits = [title for title in BOOK_TITLES if title in text] assert hits == [], hits assert CITATION.findall(text) == [], sorted(set(CITATION.findall(text))) diff --git a/tests/test_yoga_expression_paths.py b/tests/test_yoga_expression_paths.py index fd9e87719..175110c13 100644 --- a/tests/test_yoga_expression_paths.py +++ b/tests/test_yoga_expression_paths.py @@ -178,12 +178,10 @@ 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']: + # 原值(BUG-2382):正文不印出处,从这里去掉 '11.7.3(1)';新值:恢复上游原样;原因:BUG-2394 把上游模块恢复为逐字一致, + # 「正文不印出处」改在本站 expression_paths_wiring.render_paths 里做,由 tests/test_report_formation_note_2394.py 核对。 + for token in ['2026-01-01','2029-01-01','11.7.3(1)']: 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']: