From 7fdaa1775a0bd0e0500fbc64bd3aedfe47b4628c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 16:55:17 +0800 Subject: [PATCH] fix: the Moon's always-true branch alone no longer cancels a debilitation (BUG-2027) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Astrologer 2026-11-19, answer to question 17. Two flags per condition: witness_is_reference (the Moon in the 1st from the Moon, true for every chart) and witness_is_debilitated_planet (Mercury as its own witness, a real position condition that still counts). A planet that hits only the always-true branch keeps the label 落陷, gets no row or cancel relation and is never the basis of a Raja Yoga candidate; the literal hit stays in backstage evidence (literal_only). This is the product policy neecha_bhanga_policy_v1; the raw rule version stays light_on_life_p295. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8 --- docs/BUG_HISTORY.md | 12 ++ ...sult-counterexamples-card-20261109.test.ts | 6 +- .../d_moon_self_reference.json | 101 ++++++++----- references/product_runtime_contract.md | 11 ++ scripts/main_yoga_detectors.py | 56 +++++++- ...apture_counterexample_fixtures_20261109.py | 46 +++++- scripts/yogas_doshas.py | 62 ++++++-- tests/test_counterexamples_engine_20261109.py | 28 ++-- tests/test_neecha_bhanga_conditions.py | 7 +- tests/test_neecha_bhanga_tautology_2027.py | 135 ++++++++++++++++++ tests/test_preset_evidence_library.py | 18 ++- tests/test_round6_self_reference.py | 81 ++++++++--- 12 files changed, 477 insertions(+), 86 deletions(-) create mode 100644 tests/test_neecha_bhanga_tautology_2027.py diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 4dd20f9ed..2b1780028 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -27308,3 +27308,15 @@ - 遗留:年运报告和合盘仍逐段显示证据等级;报告开头时间线里 Narayana 的「候选分支」「条件性窗口」和计算说明里的「本仓」「口径」没有改;等级算法仍是旧算法。 - 关联记录:BUG-2013、BUG-2015、BUG-2019、BUG-2021、BUG-2024、BUG-1997、BUG-1999。之前的测试钉的是这些文字本身,没有一条检查「读者文字里不出现等级字母和分盘用语」。 - 修复版本:`claude/report-user-layer-2028`。 + +## BUG-2027 | 落陷取消:月亮「在月亮起第 1 宫」这条恒成立的条件单独命中,也被当成取消成立 + +- 状态:fixed-pending-verify(待测试环境部署后复测)。 +- 首次发现 / 最近更新:2026-11-19 / 2026-11-19。 +- 触发与现象:BUG-2012 统一用 `light_on_life_p295` 之后,落陷的木星和火星只要盘上有月亮就判为落陷取消。这两颗星的一条见证是月亮,而「月亮在月亮起的角宫」对任何星盘都成立。81 张公开校准盘上 10 颗落陷木星、15 颗落陷火星全部成立,其中 3 颗火星只靠这一条成立。 +- 触发条件:木星落陷摩羯或火星落陷巨蟹,且没有其它取消条件成立。 +- 根因:照上游 `_eval_neecha_bhanga` 的写法,成立与否是 `bool(reasons)`;自我参照只记了标记,没有阻止它单独让规则成立。占星师 2026-11-19 确认「仅记录标志不充分」。 +- 修复:按她对第 17 问的答复,把两类自我参照分开记:见证星就是参照点本身(月亮对月亮,恒真)记 `witness_is_reference`;见证星就是落陷星自己(水星兼任自己入旺星座的主星)记 `witness_is_debilitated_planet`,后者是实际位置条件,照常计入。只有恒真条件命中时,默认标签仍是落陷,没有落陷取消行和取消关系,不作 Raja Yoga 候选的依据;字面命中留在后台证据(`literal_only`),不给用户看。恒真条件与有效条件并存时照列为原始证据,但行上的成立条件和条数只收有效条件。这是产品解释政策 `neecha_bhanga_policy_v1`,原始规则版本仍是 `light_on_life_p295`,产品合同 §AP 写明它不是原书的要求。本条只改判定,给读者和给模型的说法由问答侧另行统一。改动都在 `scripts/yogas_doshas.py`、`scripts/main_yoga_detectors.py`;标签函数读的是同一个字段,冻结文件没有改。 +- 验证与防复发:新增 `tests/test_neecha_bhanga_tautology_2027.py`(6 条:木星、火星只有恒真条件;恒真加有效条件;水星自己作见证在角宫与不在角宫;后台记录与不作 Raja 候选;合同)。上游第六轮移植的 `tests/test_round6_self_reference.py` 五条、`tests/test_counterexamples_engine_20261109.py` 的 (d)、`tests/test_neecha_bhanga_conditions.py` 一条、`tests/test_preset_evidence_library.py` 一条按原值、新值、原因更新;反例 (d) 的固定数据改为「没有行 + 后台记录 + 旧行」,前端卡片测试改用旧行(代表已保存的快照)。81 张公开校准盘:状态变化 3 颗(都是火星,落陷取消变回落陷);仍成立但少列一条恒真条件的 22 颗;标签与主检测器不一致的前后都是 0。 +- 关联记录:BUG-2012、BUG-1988、BUG-1205、BUG-2020、BUG-2024。BUG-2012 的测试只断言了「自我参照照列、不算独立佐证」(她第六轮的口径),没有断言它单独命中时不成立,所以没有拦住。 +- 修复版本:`claude/neecha-bhanga-tautology-2027`。 diff --git a/frontend/tests/consult-counterexamples-card-20261109.test.ts b/frontend/tests/consult-counterexamples-card-20261109.test.ts index 3f527db5c..1798d07e0 100644 --- a/frontend/tests/consult-counterexamples-card-20261109.test.ts +++ b/frontend/tests/consult-counterexamples-card-20261109.test.ts @@ -104,7 +104,11 @@ test("(d) Moon-only self-reference adds no support vote on the card", () => { const { card } = cardFor("d_moon_self_reference", (chart, data) => { // Replaces the last engine row with the injected one (the layer no longer caps rows, BUG-1967). const rows = chart.consultation_native_layers.yoga_conditions.rows as Json[]; - chart.consultation_native_layers.yoga_conditions.rows = [...rows.slice(0, rows.length - 1), data.row]; + // 原值:data.row(引擎当时给出的成立行)。新值:data.legacy_row。 + // 原因:BUG-2027,只命中恒真条件的落陷星不再有落陷取消行(data.rows 为空);这里注入的是 BUG-2027 + // 之前保存下来的那种行,卡片读到旧快照时仍然不能把它当成一票。 + assert.deepEqual(data.rows, []); + chart.consultation_native_layers.yoga_conditions.rows = [...rows.slice(0, rows.length - 1), data.legacy_row]; chart.consultation_native_layers.yoga_domains.rows = [...chart.consultation_native_layers.yoga_domains.rows, { name: "Neecha Bhanga", hit: true, domain: "career" }]; }); diff --git a/frontend/tests/fixtures/counterexamples-20261109/d_moon_self_reference.json b/frontend/tests/fixtures/counterexamples-20261109/d_moon_self_reference.json index 747e2157f..25463ff06 100644 --- a/frontend/tests/fixtures/counterexamples-20261109/d_moon_self_reference.json +++ b/frontend/tests/fixtures/counterexamples-20261109/d_moon_self_reference.json @@ -1,35 +1,66 @@ -{ - "ayanamsa": "raman", - "case": "d_moon_self_reference", - "engine": { - "row": { - "category": "neecha_bhanga", - "conditions_met": [ - "该星入旺星座的主星月亮在月亮起第1宫(角宫)" - ], - "formation_evidence": { - "cancellation_reasons": [ - { - "condition": "exaltation_sign_lord_kendra_from_moon", - "independent_confirmation_allowed": false, - "planet": "Moon", - "reference": "Moon", - "relative_house": 1, - "self_reference": true - } - ], - "independent_condition_count": 0, - "self_reference_only": true - }, - "name": "Neecha Bhanga", - "planets": { - "Jupiter": {} - }, - "running_dasha_levels": [], - "status": "computed" - }, - "yoga_conditions_status": "executed" - }, - "reference_date": "2026-11-09", - "source": "scripts/research/capture_counterexample_fixtures_20261109.py" -} +{ + "ayanamsa": "raman", + "case": "d_moon_self_reference", + "engine": { + "legacy_row": { + "category": "neecha_bhanga", + "conditions_met": [ + "该星入旺星座的主星月亮在月亮起第1宫(角宫)" + ], + "formation_evidence": { + "cancellation_reasons": [ + { + "condition": "exaltation_sign_lord_kendra_from_moon", + "independent_confirmation_allowed": false, + "planet": "Moon", + "reference": "Moon", + "relative_house": 1, + "self_reference": true + } + ], + "independent_condition_count": 0, + "self_reference_only": true + }, + "name": "Neecha Bhanga", + "planets": { + "Jupiter": {} + }, + "running_dasha_levels": [], + "status": "computed" + }, + "literal_only": [ + { + "debilitated_sign": "Capricorn", + "default_profile": "light_on_life_p295", + "default_rule_met": false, + "literal_conditions": [ + { + "condition": "exaltation_sign_lord_kendra_from_moon", + "independent_confirmation_allowed": false, + "planet": "Moon", + "reference": "Moon", + "relative_house": 1, + "self_reference": true + } + ], + "literal_conditions_en": [ + "lord of its exaltation sign, Moon, in house 1 from the Moon (kendra)" + ], + "literal_conditions_zh": [ + "该星入旺星座的主星月亮在月亮起第1宫(角宫)" + ], + "note": "仅命中字面自我参照条件(月亮在月亮起第 1 宫),取消未确认", + "note_en": "Only the literal self-reference condition (the Moon in the 1st from the Moon) is hit; the cancellation is not confirmed", + "planet": "Jupiter", + "policy": "neecha_bhanga_policy_v1", + "raw_rule_met": true, + "royal_yoga_candidate_allowed": false, + "tautology_only": true + } + ], + "rows": [], + "yoga_conditions_status": "executed" + }, + "reference_date": "2026-11-09", + "source": "scripts/research/capture_counterexample_fixtures_20261109.py" +} diff --git a/references/product_runtime_contract.md b/references/product_runtime_contract.md index 350fcf261..e035b0a73 100644 --- a/references/product_runtime_contract.md +++ b/references/product_runtime_contract.md @@ -731,3 +731,14 @@ evidence_card.backstage records, for the backend only, that global web evidence - 旧自选记录(BUG-1997 之前保存,没有逐条线的分盘清单)不回填:用到那些分盘的段落不带另一情景说明,在生时纠正里重新保存一次自选即写入清单(BUG-1997)。 - 候选瑜伽表里的组合说明不出现参考库的名字:「按 PyJHora 源码条件判定」写成「按来源规则判定」,「PyJHora aligned ……」去掉前缀。「独立年度方法参考」一章按原规定保留「来源:PyJHora」。 - 数据章节里保留不动的:状态格「参数敏感」、瑜伽的候选状态说明(文字只在 yoga-status-words.ts 一处;导出的审计标注,占星师 2026-11-07 方案)、功能吉凶层的字段名行、Narayana 候选分支编号与「暂不作为双体系确认」(她第五轮的候选句,只在数据章节)。大运附表里「各步 profile 计算」改为「各步口径计算」。 + +## AP. 落陷取消:两类「自我参照」分开处理(占星师 2026-11-19 对第 17 问的答复;BUG-2027) + +- 原始规则版本不变:`light_on_life_p295`(§AL)。另记产品解释政策版本 `neecha_bhanga_policy_v1`。下面「恒真条件单独命中不算成立」是本产品的解释政策,不是原书的要求:《Light on Life》该段没有写这个例外,不得对外说成原书明确要求排除。 +- 每条条件分别记两个标记,不采用「见证星必须是另一颗星」的统一排除: + - `witness_is_reference`(旧字段 `self_reference` 同义):见证星就是参照点本身,即「月亮在月亮起第 1 宫」。对任何星盘都成立,不区分星盘。落陷木星(入旺星座巨蟹的主星是月亮)、落陷火星(落陷星座巨蟹的主星是月亮)永远命中。 + - `witness_is_debilitated_planet`:见证星就是落陷星自己(水星是自己入旺星座处女的主星)。它相对上升或月亮是否在角宫不是恒成立,是实际位置条件,照常计入,只做标记(行上 `self_witness`)。 +- 只命中恒真条件的落陷星:`default_rule_met=false`、`raw_rule_met=true`、`tautology_only=true`。行星状态标签仍是「落陷」;没有落陷取消行,没有取消关系,不作任何 Raja Yoga 候选的依据(`royal_yoga_candidate_allowed=false`)。字面命中、来源和标记只留在后台证据里(检测结果 `literal_only`、`neecha_bhanga_literal_only_notes`,备注「仅命中字面自我参照条件,取消未确认」)。这条备注不给用户看:页面、问答卡、报告都不出现「取消未确认」,也不围绕它写风险。 +- 恒真条件与其它有效条件同时命中:成立。行上列出的成立条件和条数只收实际有效的条件;恒真条件完整留在 `formation_evidence.cancellation_reasons`,不增加强度、条数和独立佐证数。 +- 给读者和给模型的落陷取消说法不在本条范围内(由问答侧统一,见卡片标签与报告事实的同一句话);本条只管判定。 +- 81 张公开校准盘上 25 颗落陷木星、火星原先全部命中,只能说明这个逻辑现象,不能说明 25 个现实案例都产生了取消效果。 diff --git a/scripts/main_yoga_detectors.py b/scripts/main_yoga_detectors.py index 67f747408..5ab94b44c 100644 --- a/scripts/main_yoga_detectors.py +++ b/scripts/main_yoga_detectors.py @@ -139,8 +139,16 @@ WITNESS_KEYS = ('condition', 'planet', 'reference', 'relative_house', 'self_refe def _witness_row(cond: Dict[str, Any], *keys: str) -> Dict[str, Any]: - """One cancellation witness in her `formation_evidence.cancellation_reasons` shape.""" - return {key: cond[key] for key in WITNESS_KEYS + keys if key in cond} + """One cancellation witness in her `formation_evidence.cancellation_reasons` shape. + + BUG-2027: `self_reference` here is the engine's `witness_is_reference` (the witness is the + reference point itself). `witness_is_debilitated_planet` is written only when true (the + debilitated planet is its own witness, e.g. Mercury), so existing rows keep their shape. + """ + row = {key: cond[key] for key in WITNESS_KEYS + keys if key in cond} + if cond.get('witness_is_debilitated_planet'): + row['witness_is_debilitated_planet'] = True + return row def neecha_bhanga_rows(planets: Dict[str, Any]) -> List[Dict[str, Any]]: @@ -148,13 +156,20 @@ def neecha_bhanga_rows(planets: Dict[str, Any]) -> List[Dict[str, Any]]: BUG-2012: a row exists only when the default named rule `light_on_life_p295` holds. A planet for which only a variant condition holds gets no row (see `neecha_bhanga_variant_notes`), so - nothing states a cancellation the default rule does not give. + nothing states a cancellation the default rule does not give. BUG-2027: neither does a planet + that hits only the always-true branch (see `neecha_bhanga_literal_only_notes`). """ result = calc_nicha_bhanga_raj_yoga(with_navamsa(planets), {}) rows: List[Dict[str, Any]] = [] for item in result.get('yogas') or []: planet = item.get('planet') - texts = [_neecha_condition_text(cond, planet) for cond in item.get('cancellation_conditions') or []] + # BUG-2027:行上对读者列出的条件和条数只收实际有效的条件;恒真条件(月亮在月亮起第 1 宫) + # 不增加支持强度,仍完整留在 formation_evidence.cancellation_reasons 里。 + effective = item.get('effective_conditions') + if effective is None: + effective = [cond for cond in item.get('cancellation_conditions') or [] + if not cond.get('witness_is_reference')] + texts = [_neecha_condition_text(cond, planet) for cond in effective] if not texts: continue zh = [text[0] for text in texts] @@ -185,6 +200,9 @@ def neecha_bhanga_rows(planets: Dict[str, Any]) -> List[Dict[str, Any]]: 'self_reference_only': bool(item.get('self_reference_only')), 'independent_condition_count': item.get('independent_cancellation_count'), 'profile': 'light_on_life_p295', + # BUG-2027:产品解释政策版本,和原始规则版本分开记。有行就说明至少一条非恒真条件成立。 + 'policy': item.get('policy'), + 'self_witness': bool(item.get('self_witness')), 'default_rule_met': True, # 变体条件(互换、D9、来源待核的两条)只列出,不计入成立条件,也不算独立佐证。 'variant_reasons': [_witness_row(cond, 'profile') for cond in item.get('variant_conditions') or []], @@ -218,6 +236,36 @@ def neecha_bhanga_variant_notes(planets: Dict[str, Any]) -> List[Dict[str, Any]] return notes +def neecha_bhanga_literal_only_notes(planets: Dict[str, Any]) -> List[Dict[str, Any]]: + """Debilitated planets that hit only the always-true branch (the Moon in the 1st from the Moon). + + Backstage evidence only (BUG-2027, 占星师 2026-11-19 第 17 问): not yoga rows, no cancel relation, + never the basis of a Raja Yoga candidate, and nothing here is shown to the reader. The exclusion + is the product policy `neecha_bhanga_policy_v1`; the book passage does not state it. + """ + result = calc_nicha_bhanga_raj_yoga(with_navamsa(planets), {}) + notes: List[Dict[str, Any]] = [] + for item in result.get('literal_only') or []: + planet = item.get('planet') + texts = [_neecha_condition_text(cond, planet) for cond in item.get('literal_conditions') or []] + notes.append({ + 'planet': planet, + 'debilitated_sign': item.get('debilitated_sign'), + 'default_profile': 'light_on_life_p295', + 'policy': item.get('policy'), + 'default_rule_met': False, + 'raw_rule_met': True, + 'tautology_only': True, + 'royal_yoga_candidate_allowed': False, + 'literal_conditions': [_witness_row(cond) for cond in item.get('literal_conditions') or []], + 'literal_conditions_zh': [text[0] for text in texts], + 'literal_conditions_en': [text[1] for text in texts], + 'note': item.get('note'), + 'note_en': item.get('note_en'), + }) + return notes + + # Names as the rule registry and the card closed list spell them. MAHAPURUSHA_ROWS = { 'Mars': ('Ruchaka Yoga', '鲁查卡格局'), diff --git a/scripts/research/capture_counterexample_fixtures_20261109.py b/scripts/research/capture_counterexample_fixtures_20261109.py index 2e03b5f08..29e5f01ad 100644 --- a/scripts/research/capture_counterexample_fixtures_20261109.py +++ b/scripts/research/capture_counterexample_fixtures_20261109.py @@ -189,16 +189,54 @@ def case_ad_blocked_md_known() -> dict: # ── (d) 月亮自参照 ─────────────────────────────────────────────────────────── +# BUG-2027(占星师 2026-11-19 第 17 问):只命中恒真条件(月亮在月亮起第 1 宫)的落陷星不再有落陷取消行。 +# 下面这一行是 BUG-2027 之前引擎对这张合成盘给出的卡层行,逐字保留:已保存的问答卡和报告里还有这种行, +# 卡片仍然不能把它当成一票(frontend/tests/consult-counterexamples-card-20261109.test.ts (d))。 +LEGACY_MOON_SELF_REFERENCE_ROW = json.loads(r""" +{ + "category": "neecha_bhanga", + "conditions_met": [ + "该星入旺星座的主星月亮在月亮起第1宫(角宫)" + ], + "formation_evidence": { + "cancellation_reasons": [ + { + "condition": "exaltation_sign_lord_kendra_from_moon", + "independent_confirmation_allowed": false, + "planet": "Moon", + "reference": "Moon", + "relative_house": 1, + "self_reference": true + } + ], + "independent_condition_count": 0, + "self_reference_only": true + }, + "name": "Neecha Bhanga", + "planets": { + "Jupiter": {} + }, + "running_dasha_levels": [], + "status": "computed" +} +""") + + def case_moon_self_reference() -> dict: from scripts.consultation_native_layers import build_yoga_conditions from scripts.jyotish_api_server import _compact_yoga_entry + from scripts.main_yoga_detectors import neecha_bhanga_literal_only_notes planets = {"Jupiter": {"sign": "Capricorn", "house": 6}, "Moon": {"sign": "Aries", "house": 9}} - compact = _compact_yoga_entry(neecha_bhanga_rows(planets)[0]) - modules = {"raman_support": {"yogas": {"status": "executed", "hits": [], "ungoverned_detected": [compact]}}} + # 原值:neecha_bhanga_rows(planets)[0] 是一条 self_reference_only 的成立行。 + # 新值:没有行;只在后台留一条「仅命中字面自我参照条件」的记录。 + compact = [_compact_yoga_entry(row) for row in neecha_bhanga_rows(planets)] + modules = {"raman_support": {"yogas": {"status": "executed", "hits": [], "ungoverned_detected": compact}}} layer = build_yoga_conditions({"planets": planets}, modules, {}) - row = next(item for item in layer["rows"] if item["name"] == "Neecha Bhanga") - return {"row": row, "yoga_conditions_status": layer.get("status")} + rows = [item for item in layer["rows"] if item["name"] == "Neecha Bhanga"] + return {"rows": rows, "literal_only": neecha_bhanga_literal_only_notes(planets), + "legacy_row": LEGACY_MOON_SELF_REFERENCE_ROW, + "yoga_conditions_status": layer.get("status")} # ── (e) 出生余额 ──────────────────────────────────────────────────────────── diff --git a/scripts/yogas_doshas.py b/scripts/yogas_doshas.py index 7239cd475..166413abb 100644 --- a/scripts/yogas_doshas.py +++ b/scripts/yogas_doshas.py @@ -444,7 +444,23 @@ def calc_pancha_mahapurusha_yoga(planets_data: Dict) -> Dict: # 互换是单列的变体(exchange_variant);D9 入庙 / 入旺、落陷星座主星入旺、会在该星座入旺的行星 # 与落陷星同座,来源待核,记为 unverified_variant。变体只列出,不让默认规则成立。 # 原值:主检测器按 A–F(含互换、D9)任一成立即算成立;标签按另一套四条(含两条待核)独立判断。 +# BUG-2027(占星师 2026-11-19 对第 17 问的答复):两类「自我参照」分开记,不一律处理。 +# - witness_is_reference:见证星就是参照点本身,即「月亮在月亮起第 1 宫」。这一条对任何星盘都成立, +# 不区分星盘;落陷的木星(擢升星主是月亮)和火星(落陷星座主星是月亮)永远命中它。 +# - witness_is_debilitated_planet:见证星就是落陷星自己(水星是自己入旺星座处女的主星)。它相对上升 +# 或月亮是否在角宫并非恒成立,是实际的位置条件,照常计入,只做标记。 +# 产品解释政策 `neecha_bhanga_policy_v1`(不是《Light on Life》原文的要求,原书该段没有写这个例外; +# 原始规则版本仍是 light_on_life_p295):只有恒真条件命中时,默认标签仍是「落陷」,不出落陷取消行、 +# 不出取消关系、不升级为任何 Raja Yoga 候选;原始命中、来源和标记留在证据里(raw_rule_met、 +# tautology_only、literal_only)。恒真条件与其它有效条件同时命中时照列,但不增加支持强度和条数。 +# 原值:default_rule_met = bool(conditions),恒真条件单独命中也算成立(81 张公开盘 10 颗落陷木星、 +# 15 颗落陷火星全部成立)。 +# 新值:default_rule_met 只看非恒真条件;raw_rule_met 保留字面命中。 NEECHA_BHANGA_DEFAULT_PROFILE = 'light_on_life_p295' +NEECHA_BHANGA_POLICY = 'neecha_bhanga_policy_v1' +NEECHA_BHANGA_LITERAL_ONLY_NOTE_ZH = '仅命中字面自我参照条件(月亮在月亮起第 1 宫),取消未确认' +NEECHA_BHANGA_LITERAL_ONLY_NOTE_EN = ('Only the literal self-reference condition (the Moon in the 1st from the Moon) ' + 'is hit; the cancellation is not confirmed') NEECHA_BHANGA_EXCHANGE_PROFILE = 'exchange_variant' NEECHA_BHANGA_UNVERIFIED_PROFILE = 'unverified_variant' NEECHA_BHANGA_VARIANT_NOTE_ZH = '默认规则未满足;另一具名规则满足某项条件,存在方法差异' @@ -471,7 +487,9 @@ def neecha_bhanga_assessment(planet: str, sign: Optional[str], planets_data: Opt """ out = { 'planet': planet, 'debilitated_sign': sign, 'profile': NEECHA_BHANGA_DEFAULT_PROFILE, - 'default_rule_met': False, 'conditions': [], 'variant_conditions': [], 'status': 'executed', + 'policy': NEECHA_BHANGA_POLICY, + 'default_rule_met': False, 'raw_rule_met': False, 'tautology_only': False, + 'conditions': [], 'variant_conditions': [], 'status': 'executed', } if not isinstance(planets_data, dict) or not planets_data: out['status'] = 'blocked_missing_planets' @@ -500,10 +518,13 @@ def neecha_bhanga_assessment(planet: str, sign: Optional[str], planets_data: Opt def _kendra(code, role, name, frame, house): reference = 'Moon' if frame == 'moon' else 'Lagna' + # self_reference 是旧字段名,含义与 witness_is_reference 相同,保留给已有读者。 witness = {'code': code, 'condition': f'{role}_kendra_from_{frame}', 'planet': name, 'frame': frame, 'house': house, 'reference': reference, 'relative_house': house, - 'self_reference': name == reference, 'profile': NEECHA_BHANGA_DEFAULT_PROFILE} - if witness['self_reference']: + 'self_reference': name == reference, 'witness_is_reference': name == reference, + 'witness_is_debilitated_planet': name == planet, + 'profile': NEECHA_BHANGA_DEFAULT_PROFILE} + if witness['witness_is_reference']: witness['independent_confirmation_allowed'] = False return witness @@ -530,8 +551,11 @@ def neecha_bhanga_assessment(planet: str, sign: Optional[str], planets_data: Opt if distance in _NB_ASPECTS.get(dispositor, (7,)): conditions.append({'code': 'I', 'condition': 'dispositor_aspect', 'planet': dispositor, 'aspect_distance': distance, 'self_reference': False, + 'witness_is_reference': False, 'witness_is_debilitated_planet': False, 'profile': NEECHA_BHANGA_DEFAULT_PROFILE}) - out['default_rule_met'] = bool(conditions) + out['raw_rule_met'] = bool(conditions) + out['default_rule_met'] = any(not cond.get('witness_is_reference') for cond in conditions) + out['tautology_only'] = out['raw_rule_met'] and not out['default_rule_met'] variants = out['variant_conditions'] if dispositor and dispositor != planet and dispositor_sign is not None \ @@ -587,11 +611,14 @@ def calc_nicha_bhanga_raj_yoga(planets_data: Dict, houses: Dict) -> Dict: (条件见 `neecha_bhanga_assessment`);只有变体条件成立的落陷星另列在 `variant_only`, 写明「默认规则未满足;另一具名规则满足某项条件,存在方法差异」,不算成立。 + BUG-2027(占星师 2026-11-19 第 17 问):只命中恒真条件(月亮在月亮起第 1 宫)的落陷星不进 + `yogas`,另列在 `literal_only`,只作后台证据;`yogas` 里的条目 `self_reference_only` 恒为 False。 + 每条成立的条件同时写进 `cancellation_reasons`(中文)与 `cancellation_conditions`(结构化:code / planet / frame / house / sign), 供卡片与报告按同一份条件来源渲染。 """ - results = {'yogas': [], 'variant_only': [], 'summary': ''} + results = {'yogas': [], 'variant_only': [], 'literal_only': [], 'summary': ''} if not isinstance(planets_data, dict): results['summary'] = '落陷取消(Neecha Bhanga)条件检测:共0个' return results @@ -615,7 +642,9 @@ def calc_nicha_bhanga_raj_yoga(planets_data: Dict, houses: Dict) -> Dict: 'exaltation_sign': exalt_sign, 'exaltation_lord': SIGN_LORDS.get(exalt_sign, ''), 'profile': NEECHA_BHANGA_DEFAULT_PROFILE, + 'policy': NEECHA_BHANGA_POLICY, 'default_rule_met': verdict['default_rule_met'], + 'raw_rule_met': verdict['raw_rule_met'], 'variant_conditions': variant_conditions, 'variant_reasons': [_nb_reason_zh(cond, pname) for cond in variant_conditions], } @@ -624,7 +653,7 @@ def calc_nicha_bhanga_raj_yoga(planets_data: Dict, houses: Dict) -> Dict: # 原值:strength 按全部成立条件条数(含月亮自参照)分档。 # 新值:自参照分支照原文保留、仍算「成立」,但不计入强度档(independent_count)。 # 原因:占星师 2026-11-08 第六轮 R3:自参照不能多算一票,不能据此提升排序、强度或置信度。 - independent_count = sum(1 for c in cancel_conditions if not c.get('self_reference')) + independent_count = sum(1 for c in cancel_conditions if not c.get('witness_is_reference')) strength = 'very strong' if independent_count >= 3 else 'strong' if independent_count >= 2 else 'moderate' results['yogas'].append({ **base, @@ -632,9 +661,26 @@ def calc_nicha_bhanga_raj_yoga(planets_data: Dict, houses: Dict) -> Dict: 'cancellation_conditions': cancel_conditions, 'cancellation_count': len(cancel_reasons), 'independent_cancellation_count': independent_count, - 'self_reference_only': all(c.get('self_reference', False) for c in cancel_conditions), + # BUG-2027:只有恒真条件的落陷星不再进这里,所以这一项恒为 False;字段留给已有读者。 + 'self_reference_only': False, + 'self_witness': any(c.get('witness_is_debilitated_planet') for c in cancel_conditions), 'strength': strength, - 'interpretation': f'落陷取消(Neecha Bhanga)——{pname}在{deb_sign}落陷,成立条件:{"; ".join(cancel_reasons)}', + # BUG-2027:对读者列出的成立条件只收实际有效的;恒真条件留在 cancellation_conditions 里作原始证据。 + 'effective_conditions': [c for c in cancel_conditions if not c.get('witness_is_reference')], + 'interpretation': '落陷取消(Neecha Bhanga)——{}在{}落陷,成立条件:{}'.format( + pname, deb_sign, + '; '.join(_nb_reason_zh(c, pname) for c in cancel_conditions if not c.get('witness_is_reference'))), + }) + elif verdict['tautology_only']: + # 后台证据,不是成立的条目:没有行、没有取消关系,也不作任何 Raja Yoga 候选的依据。 + results['literal_only'].append({ + **base, + 'tautology_only': True, + 'literal_conditions': cancel_conditions, + 'literal_reasons': [_nb_reason_zh(cond, pname) for cond in cancel_conditions], + 'royal_yoga_candidate_allowed': False, + 'note': NEECHA_BHANGA_LITERAL_ONLY_NOTE_ZH, + 'note_en': NEECHA_BHANGA_LITERAL_ONLY_NOTE_EN, }) elif variant_conditions: results['variant_only'].append({ diff --git a/tests/test_counterexamples_engine_20261109.py b/tests/test_counterexamples_engine_20261109.py index 8b92437a8..c7ba5624e 100644 --- a/tests/test_counterexamples_engine_20261109.py +++ b/tests/test_counterexamples_engine_20261109.py @@ -138,17 +138,27 @@ def test_c_ad_undecided_keeps_the_md_and_names_the_reason() -> None: def test_d_moon_self_reference_is_never_independent_confirmation() -> None: - """(d) 月亮自参照:只标自参照,独立确认为 0,不当作独立一票。""" - row = engine("d_moon_self_reference")["row"] - assert row["name"] == "Neecha Bhanga" and row["status"] == "computed" - evidence = row["formation_evidence"] - assert evidence["self_reference_only"] is True - assert evidence["independent_condition_count"] == 0 - moon = next(item for item in evidence["cancellation_reasons"] if item.get("self_reference")) + """(d) 月亮自参照:只标自参照,独立确认为 0,不当作独立一票。 + + 原值:引擎给一条 Neecha Bhanga 成立行,formation_evidence.self_reference_only 为真。 + 新值:没有行;后台只留一条「仅命中字面自我参照条件」的记录。旧行逐字留在 legacy_row, + 代表已保存的卡和报告。 + 原因:BUG-2027,占星师 2026-11-19 第 17 问:只因「月亮在月亮起第 1 宫」命中时,默认标签是落陷, + 取消未确认,也不升级为 Raja Yoga 候选。 + """ + data = engine("d_moon_self_reference") + assert data["rows"] == [] + note = data["literal_only"][0] + assert (note["planet"], note["default_rule_met"], note["raw_rule_met"], note["tautology_only"]) == ( + "Jupiter", False, True, True) + assert note["royal_yoga_candidate_allowed"] is False + assert note["policy"] == "neecha_bhanga_policy_v1" and note["default_profile"] == "light_on_life_p295" + moon = note["literal_conditions"][0] assert (moon["reference"], moon["relative_house"], moon["self_reference"]) == ("Moon", 1, True) assert moon["independent_confirmation_allowed"] is False - non_self = [item for item in evidence["cancellation_reasons"] if not item.get("self_reference")] - assert len(non_self) == evidence["independent_condition_count"] == 0 + legacy = data["legacy_row"] + assert legacy["name"] == "Neecha Bhanga" and legacy["formation_evidence"]["self_reference_only"] is True + assert legacy["formation_evidence"]["independent_condition_count"] == 0 def test_e_birth_balance_keeps_the_full_parent_start_beside_the_visible_one() -> None: diff --git a/tests/test_neecha_bhanga_conditions.py b/tests/test_neecha_bhanga_conditions.py index 3c57fa09e..187ecf79c 100644 --- a/tests/test_neecha_bhanga_conditions.py +++ b/tests/test_neecha_bhanga_conditions.py @@ -60,7 +60,12 @@ def test_public_chart_lists_the_conditions_from_the_one_source() -> None: assert rows == neecha_bhanga_rows(planets) assert [row["planets"] for row in rows] == [[item["planet"]] for item in source] for row, item in zip(rows, source): - assert len(row["conditions"]) == len(item["cancellation_conditions"]) == len(item["cancellation_reasons"]) > 0 + # 原值:len(row["conditions"]) == len(item["cancellation_conditions"]) == len(item["cancellation_reasons"]) > 0 + # 新值:行上只列实际有效的条件;恒真条件(月亮在月亮起第 1 宫)仍在 cancellation_conditions 里。 + # 原因:BUG-2027,占星师 2026-11-19 第 17 问:恒真条件照列为原始证据,但不增加支持强度和条数。 + assert len(item["cancellation_conditions"]) == len(item["cancellation_reasons"]) > 0 + assert len(row["conditions"]) == len(item["effective_conditions"]) > 0 + assert len(item["effective_conditions"]) == item["independent_cancellation_count"] assert row["name"] == "Neecha Bhanga" and row["name_cn"] == "落陷取消" assert "成立条件:" in row["combination"] assert not RAJA.search(json.dumps(row, ensure_ascii=False)) diff --git a/tests/test_neecha_bhanga_tautology_2027.py b/tests/test_neecha_bhanga_tautology_2027.py new file mode 100644 index 000000000..c34caf63c --- /dev/null +++ b/tests/test_neecha_bhanga_tautology_2027.py @@ -0,0 +1,135 @@ +"""BUG-2027 (astrologer 2026-11-19, answer to question 17). + +Two kinds of "self-reference" are recorded separately. The Moon "in the 1st from the Moon" is true +for every chart: alone it no longer gives the default label, a row, a cancel relation or a Raja Yoga +candidate (product policy `neecha_bhanga_policy_v1`; the book passage does not state the exception). +A debilitated planet that is its own witness (Mercury) is a real position condition and still counts. +""" +from __future__ import annotations + +import json +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "scripts")) + +import jyotish_engine as engine # noqa: E402 +from main_yoga_detectors import ( # noqa: E402 + neecha_bhanga_literal_only_notes, + neecha_bhanga_rows, + neecha_bhanga_variant_notes, +) +from yoga_engine import YogaEngine # noqa: E402 +from yogas_doshas import ( # noqa: E402 + NEECHA_BHANGA_DEFAULT_PROFILE, + NEECHA_BHANGA_POLICY, + calc_nicha_bhanga_raj_yoga, + neecha_bhanga_assessment, +) + +SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", + "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"] + + +def chart(lagna: str, **places: str) -> dict: + start = SIGNS.index(lagna) + return {name: {"sign": sign, "house": (SIGNS.index(sign) - start) % 12 + 1} for name, sign in places.items()} + + +# Jupiter debilitated in a trikona (5th from Virgo). Its exaltation-sign lord is the Moon; Saturn +# (dispositor) and Mars (exalted in Capricorn) are outside every kendra and Saturn does not aspect it. +JUPITER_ONLY_MOON = ("Virgo", dict(Jupiter="Capricorn", Moon="Aries", Saturn="Leo", Mars="Taurus")) +# Mars debilitated in Cancer: dispositor Moon, outside the kendras from the Lagna, not aspecting Mars; +# Jupiter (exalted in Cancer) outside every kendra. +MARS_ONLY_MOON = ("Cancer", dict(Mars="Cancer", Moon="Taurus", Jupiter="Gemini")) + + +def test_moon_tautology_alone_keeps_the_label_debilitated_and_gives_no_row(): + for (lagna, places), planet in ((JUPITER_ONLY_MOON, "Jupiter"), (MARS_ONLY_MOON, "Mars")): + planets = chart(lagna, **places) + verdict = neecha_bhanga_assessment(planet, planets[planet]["sign"], planets) + assert verdict["raw_rule_met"] is True and verdict["default_rule_met"] is False + assert verdict["tautology_only"] is True + assert (verdict["profile"], verdict["policy"]) == (NEECHA_BHANGA_DEFAULT_PROFILE, NEECHA_BHANGA_POLICY) + assert [(c["planet"], c["frame"], c["house"]) for c in verdict["conditions"]] == [("Moon", "moon", 1)] + only = verdict["conditions"][0] + assert only["witness_is_reference"] is True and only["witness_is_debilitated_planet"] is False + # Label: the planet status stays 落陷; the raw hit is still on the evidence. + evidence = engine._neecha_bhanga_evidence(planet, planets[planet]["sign"], planets) + assert evidence["成立"] is False and len(evidence["reasons"]) == 1 + assert engine._check_neecha_bhanga(planet, planets[planet]["sign"], planets) is False + # Detector: no row, not a variant note, and the rule engine appends nothing for it. + assert neecha_bhanga_rows(planets) == [] and neecha_bhanga_variant_notes(planets) == [] + rows = YogaEngine(str(ROOT / "references/yoga_rules.json")).detect(planets, lagna) + assert not [row for row in rows if "eecha" in json.dumps(row, ensure_ascii=False)] + + +def test_tautology_only_is_kept_backstage_and_is_never_a_raja_candidate(): + lagna, places = JUPITER_ONLY_MOON + planets = chart(lagna, **places) + assert planets["Jupiter"]["house"] == 5 # a trikona: placement alone must not upgrade it + result = calc_nicha_bhanga_raj_yoga(planets, {}) + assert result["yogas"] == [] and result["variant_only"] == [] + kept = result["literal_only"][0] + assert kept["tautology_only"] is True and kept["royal_yoga_candidate_allowed"] is False + assert kept["raw_rule_met"] is True and kept["default_rule_met"] is False + note = neecha_bhanga_literal_only_notes(planets)[0] + assert note["planet"] == "Jupiter" and note["policy"] == NEECHA_BHANGA_POLICY + assert note["default_profile"] == NEECHA_BHANGA_DEFAULT_PROFILE + assert "取消未确认" in note["note"] and "not confirmed" in note["note_en"] + assert note["literal_conditions"][0]["self_reference"] is True + assert "共0个" in result["summary"] + + +def test_tautology_beside_a_real_condition_holds_but_adds_no_strength(): + lagna, places = JUPITER_ONLY_MOON + planets = chart(lagna, **{**places, "Saturn": "Virgo"}) # dispositor in the 1st from the Lagna + verdict = neecha_bhanga_assessment("Jupiter", "Capricorn", planets) + assert verdict["default_rule_met"] is True and verdict["tautology_only"] is False + item = calc_nicha_bhanga_raj_yoga(planets, {})["yogas"][0] + assert item["cancellation_count"] == 2 and item["independent_cancellation_count"] == 1 + assert item["strength"] == "moderate" and item["self_reference_only"] is False + assert [c["planet"] for c in item["effective_conditions"]] == ["Saturn"] + row = neecha_bhanga_rows(planets)[0] + # The reader-facing list and count carry the real condition only. + assert row["conditions"] == ["落陷星座主星土星在上升起第1宫(角宫)"] and row["strength"] == "成立条件 1 条" + assert "月亮在月亮起" not in row["combination"] and "Moon, in house 1 from the Moon" not in row["combination_en"] + # The raw evidence keeps both, the tautological one flagged. + witnesses = row["formation_evidence"]["cancellation_reasons"] + assert len(witnesses) == 2 + assert [w["planet"] for w in witnesses if w.get("self_reference")] == ["Moon"] + assert row["formation_evidence"]["independent_condition_count"] == 1 + assert row["formation_evidence"]["policy"] == NEECHA_BHANGA_POLICY + + +def test_mercury_as_its_own_witness_in_a_kendra_holds_and_is_flagged(): + # Mercury debilitated in Pisces is the lord of its own exaltation sign (Virgo). + planets = chart("Pisces", Mercury="Pisces", Moon="Aries", Jupiter="Leo", Venus="Capricorn") + verdict = neecha_bhanga_assessment("Mercury", "Pisces", planets) + assert verdict["default_rule_met"] is True and verdict["tautology_only"] is False + own = [c for c in verdict["conditions"] if c["planet"] == "Mercury"] + assert [(c["frame"], c["house"]) for c in own] == [("lagna", 1)] + assert own[0]["witness_is_debilitated_planet"] is True and own[0]["witness_is_reference"] is False + assert "independent_confirmation_allowed" not in own[0] + row = neecha_bhanga_rows(planets)[0] + assert row["formation_evidence"]["self_witness"] is True + flagged = [w for w in row["formation_evidence"]["cancellation_reasons"] if w.get("witness_is_debilitated_planet")] + assert [(w["planet"], w["relative_house"]) for w in flagged] == [("Mercury", 1)] + assert row["formation_evidence"]["independent_condition_count"] == len(row["conditions"]) >= 1 + assert engine._check_neecha_bhanga("Mercury", "Pisces", planets) is True + + +def test_mercury_outside_the_kendras_does_not_cancel_itself(): + planets = chart("Aries", Mercury="Pisces", Moon="Aries", Jupiter="Leo", Venus="Taurus") + verdict = neecha_bhanga_assessment("Mercury", "Pisces", planets) + assert verdict["conditions"] == [] and verdict["raw_rule_met"] is False + assert verdict["default_rule_met"] is False and verdict["tautology_only"] is False + assert neecha_bhanga_rows(planets) == [] and neecha_bhanga_literal_only_notes(planets) == [] + + +def test_contract_records_the_policy_as_a_product_interpretation(): + text = (ROOT / "references" / "product_runtime_contract.md").read_text(encoding="utf-8") + section = text[text.index("## AP. "):] + assert "neecha_bhanga_policy_v1" in section and "light_on_life_p295" in section + assert "产品解释政策" in section and "原书" in section diff --git a/tests/test_preset_evidence_library.py b/tests/test_preset_evidence_library.py index 852edb052..9f132f306 100644 --- a/tests/test_preset_evidence_library.py +++ b/tests/test_preset_evidence_library.py @@ -148,14 +148,24 @@ def test_neechabhanga_moon_frame_question_is_recorded_with_her_quote(): def test_neechabhanga_moon_frame_is_always_true_in_our_engine(): - """Documents the finding (BUG-1778); changes only after her ruling.""" + """Documents the finding (BUG-1778); changes only after her ruling. + + 原值:每张盘 `yogas` 里都有火星(B)和木星(D)的成立条目。 + 新值:字面命中仍然恒在,但只靠它时不进 `yogas`,留在 `literal_only`;两处合起来仍然每张盘都有 B 和 D。 + 原因:BUG-2027,占星师 2026-11-19 对第 17 问的答复:恒真条件单独命中不算取消成立。 + """ from scripts.yogas_doshas import calc_nicha_bhanga_raj_yoga for moon_sign in ("Aries", "Libra", "Pisces"): planets = {"Mars": {"sign": "Cancer", "house": 2}, "Jupiter": {"sign": "Capricorn", "house": 8}, "Moon": {"sign": moon_sign, "house": 11}} - rows = {y["planet"]: {c["code"] for c in y["cancellation_conditions"]} - for y in calc_nicha_bhanga_raj_yoga(planets, {})["yogas"]} - assert "B" in rows["Mars"] and "D" in rows["Jupiter"] + result = calc_nicha_bhanga_raj_yoga(planets, {}) + rows = {y["planet"]: {c["code"] for c in y["cancellation_conditions"]} for y in result["yogas"]} + literal = {y["planet"]: {c["code"] for c in y["literal_conditions"]} for y in result["literal_only"]} + assert "B" in rows.get("Mars", set()) | literal.get("Mars", set()) + assert "D" in rows.get("Jupiter", set()) | literal.get("Jupiter", set()) + # A planet listed only in `literal_only` holds nothing but the always-true branch. + assert all(codes <= {"B", "D"} for codes in literal.values()) + assert not set(rows) & set(literal) def test_library_is_not_wired_into_chat(): diff --git a/tests/test_round6_self_reference.py b/tests/test_round6_self_reference.py index 659db37f0..ceaa166bb 100644 --- a/tests/test_round6_self_reference.py +++ b/tests/test_round6_self_reference.py @@ -28,14 +28,43 @@ def evidence(planets): and r['formation_evidence']['planet'] == 'Jupiter') +# BUG-2027(占星师 2026-11-19 对第 17 问的答复)改了下面五条的期望: +# 原值:只命中「月亮在月亮起第 1 宫」时,落陷取消仍算成立(self_reference_only 为真、强度 moderate), +# 有一条主检测器行。 +# 新值:这种情况默认标签是落陷,没有行,也不作 Raja Yoga 候选的依据;字面命中和见证字段留在后台 +# (calc 结果的 literal_only / neecha_bhanga_literal_only_notes)。另有有效条件时照旧成立, +# 恒真条件照列但不计入条数和强度。 +# 原因:她确认上游 `bool(reasons)` 让恒真条件单独进入取消和王者格候选判断,「仅记录标志不充分」; +# 排除恒真分支是产品解释政策 neecha_bhanga_policy_v1,不是《Light on Life》原文的要求。 +def literal_note(planets, planet='Jupiter'): + from scripts.main_yoga_detectors import neecha_bhanga_literal_only_notes + + return next(note for note in neecha_bhanga_literal_only_notes(planets) if note['planet'] == planet) + + +def has_row(planets, planet='Jupiter'): + rows = YogaEngine(str(ROOT / 'references/yoga_rules.json')).detect(planets, 'Leo') + return any(r.get('rule_id') == 'main_detector:neecha_bhanga' + and r['formation_evidence']['planet'] == planet for r in rows) + + @pytest.mark.parametrize('moon_sign', SIGNS) def test_jupiter_moon_self_reference_is_visible_for_every_moon_sign(moon_sign): # Jupiter's exaltation sign is Cancer, ruled by Moon. Moon from itself # is always H1; moving Moon cannot create independent corroboration. - result = evidence({'Jupiter': {'sign': 'Capricorn', 'house': 6}, - 'Moon': {'sign': moon_sign, 'house': (SIGNS.index(moon_sign) - 4) % 12 + 1}}) - witness = next(r for r in result['cancellation_reasons'] - if r['condition'] == 'exaltation_sign_lord_kendra_from_moon') + planets = {'Jupiter': {'sign': 'Capricorn', 'house': 6}, + 'Moon': {'sign': moon_sign, 'house': (SIGNS.index(moon_sign) - 4) % 12 + 1}} + if has_row(planets): + # The Moon is also in a kendra from the Lagna here: a real position condition. + result = evidence(planets) + witnesses = result['cancellation_reasons'] + assert any(r['condition'] == 'exaltation_sign_lord_kendra_from_lagna' for r in witnesses) + assert result['independent_condition_count'] == 1 and result['self_reference_only'] is False + else: + note = literal_note(planets) + witnesses = note['literal_conditions'] + assert note['tautology_only'] is True and note['default_rule_met'] is False + witness = next(r for r in witnesses if r['condition'] == 'exaltation_sign_lord_kendra_from_moon') assert witness['self_reference'] is True assert witness['independent_confirmation_allowed'] is False assert witness['reference'] == 'Moon' @@ -43,13 +72,14 @@ def test_jupiter_moon_self_reference_is_visible_for_every_moon_sign(moon_sign): def test_self_reference_only_is_not_hidden_or_promoted_to_nonself_support(): - result = evidence({'Jupiter': {'sign': 'Capricorn', 'house': 6}, - 'Moon': {'sign': 'Aries', 'house': 9}}) - assert result['self_reference_only'] is True - # Her `royal_yoga_candidate` is False here (Jupiter in H6); this detector never - # names a Raja Yoga (BUG-1205), so the equivalent is: no independent condition. - assert result['independent_condition_count'] == 0 - assert result['profile'] == 'light_on_life_p295' + planets = {'Jupiter': {'sign': 'Capricorn', 'house': 6}, 'Moon': {'sign': 'Aries', 'house': 9}} + assert not has_row(planets) + note = literal_note(planets) + # Not hidden: the literal hit, its source and the flag stay in the backstage record. + assert note['raw_rule_met'] is True and note['tautology_only'] is True + assert note['default_profile'] == 'light_on_life_p295' and note['policy'] == 'neecha_bhanga_policy_v1' + # Not promoted: no formed row, and never the basis of a Raja Yoga candidate. + assert note['default_rule_met'] is False and note['royal_yoga_candidate_allowed'] is False def test_distinct_geometric_condition_survives_beside_self_reference(): @@ -62,12 +92,15 @@ def test_distinct_geometric_condition_survives_beside_self_reference(): assert any(r.get('self_reference') for r in result['cancellation_reasons']) -def test_literal_branch_stays_formed_but_self_reference_does_not_raise_strength(): - # The literal condition is not deleted: the yoga is still formed on it alone. - only = calc_nicha_bhanga_raj_yoga({'Jupiter': {'sign': 'Capricorn', 'house': 6}, - 'Moon': {'sign': 'Aries', 'house': 9}}, {})['yogas'][0] - assert only['cancellation_count'] == 1 and only['independent_cancellation_count'] == 0 - assert only['self_reference_only'] is True and only['strength'] == 'moderate' +def test_literal_branch_alone_is_not_formed_and_self_reference_does_not_raise_strength(): + # The literal hit is kept as evidence, but alone it no longer forms the cancellation. + result = calc_nicha_bhanga_raj_yoga({'Jupiter': {'sign': 'Capricorn', 'house': 6}, + 'Moon': {'sign': 'Aries', 'house': 9}}, {}) + assert result['yogas'] == [] + only = result['literal_only'][0] + assert only['planet'] == 'Jupiter' and only['tautology_only'] is True + assert only['default_rule_met'] is False and only['raw_rule_met'] is True + assert [c['condition'] for c in only['literal_conditions']] == ['exaltation_sign_lord_kendra_from_moon'] # Mars debilitated in Cancer: dispositor Moon from the Moon is the same tautology. mars = calc_nicha_bhanga_raj_yoga({'Mars': {'sign': 'Cancer', 'house': 12}, 'Moon': {'sign': 'Taurus', 'house': 10}}, {})['yogas'][0] @@ -76,15 +109,23 @@ def test_literal_branch_stays_formed_but_self_reference_does_not_raise_strength( lagna = next(c for c in mars['cancellation_conditions'] if c['condition'] == 'dispositor_kendra_from_lagna') assert lagna['self_reference'] is False and 'independent_confirmation_allowed' not in lagna assert mars['independent_cancellation_count'] == mars['cancellation_count'] - 1 + assert mars['self_reference_only'] is False and mars['strength'] == 'moderate' def test_card_layer_carries_the_witness_fields(): from scripts.main_yoga_detectors import neecha_bhanga_rows + # Tautology only: no row reaches the card layer. + assert neecha_bhanga_rows({'Jupiter': {'sign': 'Capricorn', 'house': 6}, + 'Moon': {'sign': 'Aries', 'house': 9}}) == [] + # Beside a real condition the tautological witness is still carried, flagged. row = neecha_bhanga_rows({'Jupiter': {'sign': 'Capricorn', 'house': 6}, - 'Moon': {'sign': 'Aries', 'house': 9}})[0] - assert row['formation_evidence']['self_reference_only'] is True - reason = row['formation_evidence']['cancellation_reasons'][0] + 'Moon': {'sign': 'Aries', 'house': 9}, + 'Saturn': {'sign': 'Leo', 'house': 1}})[0] + assert row['formation_evidence']['self_reference_only'] is False + assert row['formation_evidence']['independent_condition_count'] == 1 + assert len(row['conditions']) == 1 and '月亮在月亮起' not in row['combination'] + reason = next(r for r in row['formation_evidence']['cancellation_reasons'] if r.get('self_reference')) assert {k: reason[k] for k in ('reference', 'relative_house', 'self_reference', 'independent_confirmation_allowed')} == { 'reference': 'Moon', 'relative_house': 1, 'self_reference': True,