From 778cb6389c7411e8da77f001bff8afe2d5b5cea2 Mon Sep 17 00:00:00 2001 From: jesse-ux Date: Wed, 7 Oct 2026 16:52:41 +0800 Subject: [PATCH] fix(tajika): store year-lord house separately from sign (BUG-1263, upstream 1918ffaf) --- docs/BUG_HISTORY.md | 19 ++++++++++++++++++- scripts/tajika.py | 13 ++++++++----- tests/test_tajika_panchadhikari_year_lord.py | 14 ++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 04d2e3f8..5846153a 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -16368,9 +16368,10 @@ - 修复:`0afcc2d9`。按上游原样移植函数、依赖与规则 JSON(blob `e8c15ac3` 一致)。本地差异两处:① 加关键字参数 `muntha_sign_idx`——上游的 Muntha 主候选用「年盘上升 + 年数」,本仓 Muntha 一律「本命上升 + 已满年数」(问 3 维持),生产调用方传入;不传时与上游行为相同。② 产品路径不把年盘 JD 交给 PyJHora(AGPL,API 镜像与 CI 都没有;本机有时会选出与生产不同的年主,且进程内调用不设岁差、同输入跨进程分数不同),Panchavargiya 一律 `native_proxy`,标注「Panchavargiya 为本地近似计算」;`JYOTISH_YEAR_LORD_PYJHORA_REFERENCE=1` 恢复上游查询,仅供研究。两个生产者共用 `select_annual_year_lord`,冲突门照常比较。输出 `candidates` / `candidate_list`(每个候选的分数、engine、吉凶相位)、`selection_basis`、一句话依据(中英)、`muntha_basis`。卡片 `varshesha_basis` 与报告「Selection basis」改为这句话,去掉 BUG-1212 的暂用标注。 - 验证:`tests/test_tajika_panchadhikari_year_lord.py`(四种选法分支、Muntha 参数、规则 JSON 与上游 blob 一致、两个生产者同盘同年主、研究开关)、`tests/test_year_lord_basis_label.py`、`tests/test_report_reader_main.py`(三条按三栏改写)。9 位公开名人 2026 年年盘:同输入下与上游函数逐项相同 9/9(native);生产结果与上游年主不同 2/9,原因都是 Muntha 起点(本命 vs 年盘)。上游 `tests/test_tajika.py` 没有 Panchadhikari 用例;上游 CLI 冒烟用例依赖私有本地盘,未移植。 - 防复发:同上测试。 -- 相关记录:BUG-1212、BUG-1037、BUG-1028。 +- 相关记录:BUG-1212、BUG-1037、BUG-1028、BUG-1263。 - 复发自:无 - 修复版本:待发布 +- 后续(2026-10-07):移植时 `planet_house` 存的是 0 起星座序号。相位和年主星座当时碰巧用了这个序号,选法没有因此改星;这个字段却不是相对年盘上升的第 1–12 宫。见 BUG-1263,不改写上面的修复记录。 ## BUG-1215 | 第二时间轴 Narayana 一律从上升起、一律顺行,各 profile 只改标签;Sanjay Rath 版起运宫未能复现原书样表 @@ -16965,3 +16966,19 @@ - 相关记录:BUG-1260 - 复发自:无 - 修复版本:本分支待发布 + +## BUG-1263 | 年主候选的 planet_house 存的是星座序号,不是相对年盘上升的宫 + +- 状态:resolved +- 首次发现:2026-10-07 +- 最近更新:2026-10-07 +- 影响面:`scripts/tajika.py` 的 `calc_panchadhikari_year_lord` +- 用户现象:年主候选的「宫」是 0 起的星座序号。年盘上升不是白羊时,这个数字不是该星在年盘里的第几宫 +- 触发条件:计算 Panchadhikari 年主 +- 根因:BUG-1214 从上游 `c7117f92` 移植时,`planet_house` 被写成黄经对应的星座序号。相位目标和 `planet_sign` 当时也读这个序号,所以选出来的年主没有偏;字段含义却错了。上游 `1918ffaf` 已把宫位改成相对年盘上升的 1–12,星座序号另存 +- 修复:`planet_sign_idx` 单独保存;`planet_house` 为 `(星座序号 - 年盘上升) % 12 + 1`;相位用星座序号;`year_lord_sign_idx` 取星座序号;新增 `year_lord_house` +- 验证:`tests/test_tajika_panchadhikari_year_lord.py` 白羊年盘上升、金牛座月亮:宫位 2、星座序号 1,二者不相等 +- 防复发:上述用例 +- 相关记录:BUG-1214 +- 复发自:BUG-1214 移植时带入的字段错位;选法结果未改,故不记为选法复发 +- 修复版本:本分支待发布 diff --git a/scripts/tajika.py b/scripts/tajika.py index e976d9ab..22edf300 100644 --- a/scripts/tajika.py +++ b/scripts/tajika.py @@ -225,7 +225,8 @@ def calc_panchadhikari_year_lord( if planet in seen or planet not in planet_lons: continue seen.add(planet) - planet_house = _sign_idx_from_lon(planet_lons[planet]) + planet_sign_idx = _sign_idx_from_lon(planet_lons[planet]) + planet_house = (planet_sign_idx - annual_asc_sign_idx) % 12 + 1 pvb = _resolve_year_lord_panchavargiya_score( planet, planet_lons[planet], @@ -244,9 +245,10 @@ def calc_panchadhikari_year_lord( 'source': source, 'planet': planet, 'planet_house': planet_house, - 'planet_sign': SIGNS[planet_house], - 'benefic_aspects_asc': annual_asc_sign_idx in _benefic_aspect_targets(planet_house), - 'malefic_aspects_asc': annual_asc_sign_idx in _malefic_aspect_targets(planet_house), + 'planet_sign_idx': planet_sign_idx, + 'planet_sign': SIGNS[planet_sign_idx], + 'benefic_aspects_asc': annual_asc_sign_idx in _benefic_aspect_targets(planet_sign_idx), + 'malefic_aspects_asc': annual_asc_sign_idx in _malefic_aspect_targets(planet_sign_idx), 'panchavargiya_score': pvb['score'], 'panchavargiya_raw_total': pvb.get('raw_total'), 'panchavargiya_engine': pvb['engine'], @@ -279,7 +281,8 @@ def calc_panchadhikari_year_lord( return { 'status': 'partial_verified', 'year_lord': winner['planet'], - 'year_lord_sign_idx': winner['planet_house'], + 'year_lord_sign_idx': winner['planet_sign_idx'], + 'year_lord_house': winner['planet_house'], 'year_lord_sign': winner['planet_sign'], 'selection_basis': selection_basis, 'annual_asc_sign_idx': annual_asc_sign_idx, diff --git a/tests/test_tajika_panchadhikari_year_lord.py b/tests/test_tajika_panchadhikari_year_lord.py index adbfd91a..1ffa05c6 100644 --- a/tests/test_tajika_panchadhikari_year_lord.py +++ b/tests/test_tajika_panchadhikari_year_lord.py @@ -56,6 +56,20 @@ def _select(planet_lons, **kwargs): return tajika.calc_panchadhikari_year_lord(planet_lons, **defaults) +def test_planet_house_is_relative_to_the_annual_ascendant_not_the_sign_index(monkeypatch) -> None: + """Taurus under an Aries annual ascendant is house 2. Sign index 1 must not be reused as the house.""" + _scores(monkeypatch, {"Moon": 50.0, "Mars": 1.0, "Venus": 1.0, "Mercury": 1.0, "Jupiter": 1.0, "Saturn": 1.0, "Sun": 1.0}) + result = _select(dict(BASE)) + assert result["year_lord"] == "Moon" + moon = next(row for row in result["candidates"] if row["planet"] == "Moon") + assert moon["planet_sign_idx"] == 1 + assert moon["planet_sign"] == "Taurus" + assert moon["planet_house"] == 2 + assert result["year_lord_sign_idx"] == 1 + assert result["year_lord_house"] == 2 + assert result["year_lord_sign"] == "Taurus" + + def test_benefic_shortlist_takes_the_strongest(monkeypatch) -> None: # Candidates: natal Lagna lord Moon (Cancer), Muntha lord Venus (Libra), # annual Lagna lord Mars, new-year lord and Tri-Rasi lord (day/night).