fix(annual): the shared annual pack never runs the motion scan — the audit row also read the motion request, so every annual-service and chat pack scanned a whole year (BUG-2315)

The motion inputs are stripped at the pack's entry; only the solar-return
field's tajika_motion keeps them for the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp2U3BH1SxwAGyhhbe1
This commit is contained in:
2026-11-24 15:44:33 +08:00
co-authored by Claude Opus 5.5
parent 40b01b82e6
commit f22db59dfc
3 changed files with 28 additions and 5 deletions
+2 -1
View File
@@ -31294,7 +31294,8 @@
- 限时:同一份报告里未命中缓存的年份共用 `JYOTISH_ANNUAL_MOTION_BUDGET_SECONDS`(默认 30 秒)。估计放不下的年份不开始,记为 `execution_status: blocked`、`reason: time_budget_exceeded`,不写缓存,下一份报告再算。
- 存储无损压缩:上游每个精确接触都带「此前全部换座 / 停滞」的列表,一年约 5 MB;存储时去掉、可由事件列表按上游规则重建(`expand_prior_motion_changes`,测试核对与上游逐字相同),一年约 150 KB。
- 实测(开发机,乔布斯公开盘,三年):冷算 16.7 秒(5.6 + 5.4 + 5.7),缓存命中 0.01 秒;报告包增大约 0.8 MB(19.6 → 20.4 MB)。
- 验证:移植占星师测试 `test_annual_tajika_automatic_motion.py`(本站生产器没有 position_mode 参数,改为只测本站年盘实际口径)、`test_annual_motion_series_preservation.py`(上游那条依赖冻结引擎保留新字段,跳过并写明原因;另加本站接线的同等测试);新增 `test_annual_motion_cache_2315.py`(7 条:每年只扫一次且缓存 0600、键覆盖各项、最多三年与限时 blocked 不缓存、请求缺失 / blocked 照实记录、压缩与上游逐字可逆、聊天字段不变、过期清理)。
- 验证:移植占星师测试 `test_annual_tajika_automatic_motion.py`(本站生产器没有 position_mode 参数,改为只测本站年盘实际口径)、`test_annual_motion_series_preservation.py`(上游那条依赖冻结引擎保留新字段,跳过并写明原因;另加本站接线的同等测试);新增 `test_annual_motion_cache_2315.py`(8 条:每年只扫一次且缓存 0600、键覆盖各项、最多三年与限时 blocked 不缓存、请求缺失 / blocked 照实记录、压缩与上游逐字可逆、聊天字段不变、过期清理、共用年度包整体不跑扫描)。
- 验收中的回归(同日修):第一版只在聊天卡字段去掉了运动输入,`annual_tajika_pack._audit` 的「Tajika Yogas」一行仍用完整的太阳返照结果调用 `_tajika_yogas_field`,于是每次建年度包(年度服务、聊天)都跑一次整年扫描,`test_annual_audit_axes_20261112.py` 从 18 秒变成十分钟以上。改为在 `build_annual_tajika_pack` 入口就去掉运动输入,只有 `solar_return.tajika_motion` 拿到原件;新增测试把扫描函数换成直接报错,整包照常建成。
- 防复发:上述测试;聊天字段等值断言锁住「年运卡不跑扫描」。
- 边界(占星师原话的口径):时间线里的精确接触不是人生事件日期;没运行或被限时挡住的年份不写「无变化」。
- 关联记录:BUG-2223(三年年度系列)、BUG-2296(同一处报告接线做法)、BUG-1817(transit_search 缺失的旧记录)。
+6 -4
View File
@@ -45,16 +45,18 @@ def build_annual_tajika_pack(
args = _args_from_payload(payload)
solar_report = solar_return_report if solar_return_report is not None else _safe_solar_return(args)
# BUG-2315: the motion inputs only ride on the solar-return field (below). Nothing else in the shared
# annual pack sees the request, so no field here (chat card, audit) ever runs the motion scan.
motion_source = solar_report
solar_report = _without_motion_inputs(solar_report)
tajika_report = tajika_report if tajika_report is not None else _safe_tajika(args)
solar_return = _field_from_report(solar_report, "solar_return", "Solar Return")
_attach_motion_inputs(solar_return, solar_report)
_attach_motion_inputs(solar_return, motion_source)
annual_chart = _annual_chart_from_solar_report(solar_report)
muntha = _field_with_conflict_gate("muntha", solar_report, tajika_report)
year_lord = _field_with_conflict_gate("year_lord", solar_report, tajika_report)
# BUG-2315: the chat annual card's field stays the candidate list it was; the motion inputs
# added to the solar report are not read here (no motion scan in the shared annual pack).
tajika_yogas = _tajika_yogas_field(_without_motion_inputs(solar_report))
tajika_yogas = _tajika_yogas_field(solar_report)
sahams = _field_from_report(solar_report, "sahams", "Sahams")
mudda_dasha = _dasha_field("Mudda Dasha", solar_report, tajika_report, "mudda_dasha")
patyayini_dasha = _dasha_field("Patyayini Dasha", solar_report, tajika_report, "patyayini_dasha")
+20
View File
@@ -134,3 +134,23 @@ def test_retention_prunes_old_motion_files(monkeypatch, tmp_path):
stats = retention._prune_annual_motion(now)
assert stats['removed'] == 1 and not old.exists() and young.exists()
assert 'annual_motion_timeline' in retention.REGISTERED_DIR_NAMES
def test_shared_annual_pack_never_runs_the_scan(monkeypatch):
"""The chat card, the annual service and the audit rows all build this pack; only the report scans."""
import scripts.transit_search as transit_search
from scripts.annual_tajika_pack import build_annual_tajika_pack
def forbidden(*args, **kwargs):
raise AssertionError("the shared annual pack must not run the motion scan")
monkeypatch.setattr(transit_search, "build_tajika_motion_timeline", forbidden)
import transit_search as direct
monkeypatch.setattr(direct, "build_tajika_motion_timeline", forbidden)
pack = build_annual_tajika_pack({
"birth": {"date": "1990-01-01", "time": "12:00:00", "latitude": 20.0, "longitude": 75.0, "utc_offset": "+05:30"},
"settings": {"ayanamsa": "lahiri"}, "target_year": 2026})
motion = pack["solar_return"]["tajika_motion"]
assert motion["request_status"]["status"] == "ready" and motion["request"]["position_mode"] == "apparent"
assert "motion_timeline" not in (pack["tajika_yogas"].get("data") or {})
assert pack["tajika_named_yogas"]["data"]["motion_timeline"] == {"execution_status": "not_requested"}