diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 23febf5f5..01ff73e46 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -25099,6 +25099,20 @@ - 关联记录:#215、BUG-1851、BUG-1848。 - 修复版本:`codex/purpose-stability-20261112`。 +## BUG-1859 | 报告参与状态混用,Badhaka 宫位和宫主落点难以区分 + +- 状态:fixed-pending-verify(待独立验收)。 +- 首次发现 / 最近更新:2026-11-12 / 2026-11-12。 +- 影响面:个人报告事实包的领域参与行及共享技法,咨询和报告共用的 Badhaka 记录。 +- 现象:已算出的 Indu 等点只显示未路由;Badhaka 平铺字段容易把阻碍宫写成宫主星的落宫。 +- 触发条件:报告事实包包含领域不采用的已算结果,或健康参与层读取 Badhaka。 +- 根因:一个 `state` 同时表示执行与领域使用。BUG-1852 修了引用和描述,但没有分轴;BUG-1853 增加了计算,旧测试只验证平铺字段。 +- 修复:为每行加计算和解读两轴,保留旧状态并分别汇总缺口。Badhaka 按原来源输出阻碍宫、宫内行星和宫主落点,沿用产品计算待审状态。 +- 验证:十二上升合成盘、两张公开盘和精度阻塞回归均通过。任务及等级合同 42 项、消费者 10 项通过。详情见 `docs/tasks/PROGRESS-reading-status-axes-badhaka-20261112.md`。 +- 防复发:检查已算未用、缺真实结果、不适用理由及阻碍原因。断言宫主不在阻碍宫时不列入其宫内行星,落在该宫时列入。 +- 关联记录:#216、BUG-1848、BUG-1852、BUG-1853。 +- 修复版本:`codex/reading-status-axes-badhaka-20261112`。 + ## BUG-1861 | 个人报告提示仍含旧置信度口径,功能吉凶资料混用 - 状态:resolved(分支定向回归通过,待独立验收) diff --git a/docs/tasks/PROGRESS-reading-status-axes-badhaka-20261112.md b/docs/tasks/PROGRESS-reading-status-axes-badhaka-20261112.md new file mode 100644 index 000000000..fed9b7a72 --- /dev/null +++ b/docs/tasks/PROGRESS-reading-status-axes-badhaka-20261112.md @@ -0,0 +1,29 @@ +# 个人报告参与状态与 Badhaka · 2026-11-12 + +Gitea #216,BUG-1859。计划评论 42250,认领评论 42345。任务书基线 `1ba0364a`,验证基线为同步后的 staging `c55338f35916587ec9007d0786f370e5c29d0aa9`。 + +## 两轴与消费位置 + +- 参与行复用 `technique_status_axes.technique_audit_axes` 规范状态词,保留原有 `state`。参与本领域的计算默认是 `executed + primary`。Badhaka 是专项答复 §4 指定的健康补充层,记 `supporting`。KP 已有条件参考规则,存在实际宫头或行星结果时记 `conditional`,只有方法标签时记 `not_computed + not_used`。 +- 已算出的未路由值记 `executed + not_used`。缺结果且没有失败证据时记 `not_computed + not_used`,不附计算值。明确缺输入、调用失败和验证失败分别记录对应阻碍;精度保留层缺确认分钟,沿用原说明。显式不适用需带范围理由。汇总保留旧路由及精度分类,实际计算缺口分到各自状态。 +- 全仓检索核对:`consult_card_domain_facts._badhaka` 把产品记录传入咨询和阅读,从 D1 原有行星状态读取尊贵度,缺失或无效上升分别标明原因。 `reading_facts.STRUCTURED_VALUES` 放行两段新记录、来源与 profile。前端 `computedPointsOf` 读取参与 ID、旧 `state` 和 `computed`,上限模块也读旧 `state`。星盘页身份标签来自独立的 `chart_view_points.functional_roles`,没有读取本轮旧字段。 +- `badhaka_modality_v1` 沿用来源 §二及现有 `badhaka_house`。按落入目标星座记录 `badhaka_sthana.occupants`;`badhakesh` 记录宫主本身的落点和尊贵度。保留产品计算待审状态。 + +## 既有断言变更 + +| 位置 | 原值 | 新值 | 原因 | +| --- | --- | --- | --- | +| `test_badhaka_facts_20261112.py` 三种上升 | 比较顶层 `house/sign/lord` | 比较 `badhaka_sthana.house/sign` 与 `badhakesh.planet` | 迁移到任务书规定的宫位与宫主字段,预期值相同。 | +| 同测试宫主落点 | 比较 `lord_sign/lord_house` | 比较 `badhakesh.sign/house` | 保留对宫主落点的检查。 | +| 同测试宫内行星 | 比较顶层 `occupants` | 比较 `badhaka_sthana.occupants` | 保留对宫内行星的检查。 | +| `test_reading_facts_v3_20261112.py` 健康参与层宫位 | `value.house` 属于 7、9、11 | `value.badhaka_sthana.house` 属于 7、9、11 | 只更新读取位置。 | +| 同测试星座及宫主 | `value.sign` 和 `value.lord` 均有值 | `value.badhaka_sthana.sign` 和 `value.badhakesh.planet` 均有值 | 只更新读取位置。 | +| `test_report_reading_facts.py::test_withheld_varga_houses_stay_out_without_a_confirmed_minute` | D30 行精确等于四个旧字段 | 保留四个字段及精确相等,新增三个要求字段,值分别为 `blocked`、`not_used`、`missing_input` | 每条参与行都必须给两轴,缺确认分钟给具体阻碍。仍禁止附上计算值。 | +| `test_report_reading_facts.py::test_reading_facts_are_packet_leaves` | Python 默认带分隔空格的 JSON 长度小于 80,000 | 紧凑 JSON 长度小于 80,000 | 模型输入使用 `JSON.stringify(facts)`。测量实际的紧凑格式,保留阈值和内部字段禁入断言。 | + +## 验证 + +- 任务文件和等级合同共 42 项通过。两张公开盘实测分别为第 7 宫双鱼、木星落第 10 宫,以及第 11 宫天蝎、火星落第 9 宫。第一张的宫内行星含月亮。两张盘均按 D1 核对宫主尊贵度,四个未用点均为已算未用。 +- 报告与咨询消费者共 10 项通过。两条旧合同在 staging 原样通过。新事实用 Python 默认 JSON 计长为 80,710,实际模型使用的紧凑格式为 74,560,仍低于 80,000。 +- Python 快速门退出码 1,1,463 项通过、3 项失败、2 项跳过、29 项子测试通过。三项失败均在同一 staging 提交的上游技法定向测试重现。 +- 仓库隐私检查 62 项通过。 diff --git a/docs/tasks/TASK-reading-status-axes-badhaka-20261112.md b/docs/tasks/TASK-reading-status-axes-badhaka-20261112.md new file mode 100644 index 000000000..04dd10245 --- /dev/null +++ b/docs/tasks/TASK-reading-status-axes-badhaka-20261112.md @@ -0,0 +1,85 @@ +# TASK:事实包参与层改用两轴状态,Badhaka 区分宫与宫主并补十二上升测试(2026-11-12) + +- Gitea:#216 +- 分支:`codex/reading-status-axes-badhaka-20261112`,基于 staging `1ba0364a7a8c0f964c3e21c21cb304aaa1899375` +- Bug 编号:BUG-1859 +- 验收:Claude(jyotisha-e6) + +不得自行写「产品决定/裁定」。任务书没写到的取舍,一律选「需拍板」。 + +不得修改或删除既有断言来让测试通过。确需修改的,在 PROGRESS 里逐条写明原值、新值和原因。 + +占星师的引擎和资料(`scripts/jyotish_engine.py`、`scripts/yoga_engine.py`、`references/` 下她仓库已有的文件、`SKILL.md`)一律不改。产品差异只能放进单独的产品文件,并在 `references/product_runtime_contract.md` 公告(项目规则 2026-11-07)。 + +占星师回复原文:`docs/tasks/ref-astrologer-acceptance-reply-20261112.md`,由本分支第一个提交带入。下文的「她 §N」都指这份文件。 + +## 背景 + +### 两轴状态(她 §4「状态与可见审计」) + +`scripts/report_render/reading_facts.py` 给每个领域的参与层写一个单轴 `state`,取值有 `executed`、`not_routed`、`not_in_domain_route`、`not_computed`、`blocked` 等。 + +- 已经算出、只是本领域不用它下结论的层(Indu、Gulika 等),现在的状态是 `not_in_domain_route`,读起来像是没执行。 +- 她要求拆成两个轴:`execution_status`(`executed` / `blocked` / `not_applicable` / `not_computed`)和 `interpretation_usage`(`primary` / `supporting` / `conditional` / `not_used`)。 +- 已算出但没用的层,必须是 `execution_status=executed`、`interpretation_usage=not_used`。 +- `blocked` 必须写明具体阻碍:缺输入、调用失败或验证失败。 +- `not_applicable` 必须写明范围或适用条件的理由。 + +仓库里已经有词表 `scripts/report_render/technique_status_axes.py`(`CALCULATION_LABELS` / `INTERPRETATION_LABELS`),要复用它,不要另起一套。 + +### Badhaka(她 §3、§4) + +产品模块 `scripts/report_render/badhaka_facts.py` 返回的记录用 `house`、`sign`、`lord` 等字段,没有区分「阻碍宫(Badhaka sthana)」和「阻碍宫主(Badhakesh)」。样稿因此写成「阻碍星落在第七宫」。 + +她要求下一包附上:实现、profile、十二上升单测,以及星与宫区分的测试。 + +## 要改的文件 + +- `scripts/report_render/reading_facts.py`:只改参与层行的构造,以及汇总 `blocked_states` 的部分 +- `scripts/report_render/badhaka_facts.py` +- 新建 `tests/test_reading_status_axes_20261112.py` +- 新建 `tests/test_badhaka_twelve_ascendants_20261112.py` +- `tests/test_badhaka_facts_20261112.py`、`tests/test_reading_facts_v3_20261112.py`:只在字段改名处改,并逐条列进 PROGRESS +- `docs/BUG_HISTORY.md`:末尾追加一条 +- `docs/tasks/PROGRESS-reading-status-axes-badhaka-20261112.md` + +## 要做的 + +1. 参与层每一行加两个字段:`execution_status` 和 `interpretation_usage`。 + - 原有的 `state` 字段保留、取值不变。前端 `computedPointsOf` 和 `evidence_grade.py` 都读它。 + - 映射规则: + - `executed` 且本领域在用 → `executed` + `primary`(或按现有数据写 `supporting`,规则写进 PROGRESS) + - `not_in_domain_route` 且有值 → `executed` + `not_used` + - `not_routed` 且有值 → `executed` + `not_used`;没有值 → `not_computed` + `not_used` + - `not_computed` → `not_computed` + `not_used` + - `blocked` 类 → `blocked`,同时带 `blocked_reason`(`missing_input` / `call_failed` / `validation_failed` 之一,按实际原因写) + - 任何一行不得出现 `execution_status=not_computed` 却又附有计算值的情况。 +2. `badhaka_facts()` 的记录改用这些字段名: + - `badhaka_sthana`:`{house, sign, occupants}` + - `badhakesh`:`{planet, sign, house, dignity}` + - `ascendant_sign`、`ascendant_modality`、`source`、`status` 保留 + - 加 `profile: "badhaka_modality_v1"`,说明「动 → 11、固 → 9、双 → 7,按 badhaka-obstacle-planet-guide.md §二」 + - 旧字段名不再输出。`reading_facts.STRUCTURED_VALUES["Badhaka"]` 和 `consult_card_domain_facts.py` 里引用它的地方同步改。改之前先 grep 全仓,列进 PROGRESS。 +3. 十二上升测试:每个上升都用合成行星位置,断言 Badhaka 宫的宫位、星座、宫主。另外断言宫内行星只列落在该星座里的星,宫主自己不算进去(除非宫主恰好落在宫内)。 +4. 区分测试:造一个宫主不在 Badhaka 宫内的例子,断言 `badhakesh.house` 不等于 `badhaka_sthana.house`,而且 `badhaka_sthana.occupants` 里不含宫主。 + +## 不要碰 + +- `frontend/**` +- `references/**` +- `scripts/yoga_engine.py`、`scripts/jyotish_engine.py`(只能调用 `badhaka_house`) +- `scripts/report_render/evidence_grade.py` + +## 验收标准 + +1. 用 Jobs(1955-02-24 19:15,UTC−8,Raman 岁差,平均交点)和 Obama 两张公开盘生成事实包,健康领域 Badhaka 的结果是: + - Jobs:Badhaka 宫为第 7 宫双鱼,宫内有月亮;Badhakesh 为木星,在第 10 宫。 + - Obama:Badhaka 宫为第 11 宫天蝎;Badhakesh 为火星,在第 9 宫。 + 生成方法参考现有的 `tests/test_reading_facts_v3_20261112.py`。 +2. 两张盘的 Indu、Gulika、Mandi、Pranapada 行都是 `executed` + `not_used`。 +3. 新测试、改过的旧测试和 Python 快速质量门全部通过。 + +## 何时停下来选「需拍板」 + +- 某个领域的「在用 / 辅助」无法从现有数据判断。 +- 改字段名会影响 `frontend/` 下你不许改的代码。 diff --git a/scripts/consult_card_domain_facts.py b/scripts/consult_card_domain_facts.py index 94f26b4db..3a8fa60a3 100644 --- a/scripts/consult_card_domain_facts.py +++ b/scripts/consult_card_domain_facts.py @@ -175,7 +175,8 @@ def _planet_base(view: dict, name: str) -> str | None: def _badhaka(view: dict) -> dict[str, Any]: """BUG-1853: product computation from D1 positions (report_render/badhaka_facts.py). - Her engine has no natal Badhaka module; the record says it is pending her review. + The product record separates the obstructing house from its lord's placement + and keeps its pending-review status. """ from report_render.badhaka_facts import badhaka_facts @@ -184,10 +185,13 @@ def _badhaka(view: dict) -> dict[str, Any]: for name in PLANETS: base = _planet_base(view, name) if base: - planets[name] = dig(view, base) + placement = dig(view, base) + planets[name] = {"sign": placement.get("sign"), "house": placement.get("house"), + "dignity": placement.get("status") or placement.get("dignity")} record = badhaka_facts(asc, planets) if record is None: - return _gap("core_chart.houses.house_1.cusp_sign") + return {**_gap("core_chart.houses.house_1.cusp_sign"), + "blocked_reason": "validation_failed" if asc else "missing_input"} return {"status": "value", "path": "product:report_render.badhaka_facts", "value": record, "check": "product_computation"} diff --git a/scripts/report_render/badhaka_facts.py b/scripts/report_render/badhaka_facts.py index 6907b32d7..5cf902c73 100644 --- a/scripts/report_render/badhaka_facts.py +++ b/scripts/report_render/badhaka_facts.py @@ -15,6 +15,8 @@ from yoga_engine import badhaka_house SOURCE = "references/badhaka-obstacle-planet-guide.md §二" STATUS = "product_computation_pending_astrologer_review" +PROFILE = "badhaka_modality_v1" +PROFILE_RULE = "动 → 11、固 → 9、双 → 7,按 badhaka-obstacle-planet-guide.md §二" SIGNS = ("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces") LORDS = ("Mars", "Venus", "Mercury", "Moon", "Sun", "Mercury", "Venus", "Mars", @@ -23,7 +25,7 @@ MODALITY = {11: "movable", 9: "fixed", 7: "dual"} def badhaka_facts(asc_sign: Any, planets: dict[str, dict]) -> dict[str, Any] | None: - """Badhaka house, sign, lord and the lord's placement, plus occupants. + """Return the obstructing house and its lord's placement separately. ``planets`` maps a planet name to its D1 record (``sign``, ``house``, optional ``dignity``). Returns None when the ascendant sign is unknown. @@ -40,13 +42,15 @@ def badhaka_facts(asc_sign: Any, planets: dict[str, dict]) -> dict[str, Any] | N return { "ascendant_sign": asc_sign, "ascendant_modality": MODALITY[house], - "house": house, - "sign": sign, - "lord": lord, - "lord_sign": lord_data.get("sign"), - "lord_house": lord_data.get("house"), - "lord_dignity": lord_data.get("dignity"), - "occupants": occupants, + "badhaka_sthana": {"house": house, "sign": sign, "occupants": occupants}, + "badhakesh": { + "planet": lord, + "sign": lord_data.get("sign"), + "house": lord_data.get("house"), + "dignity": lord_data.get("dignity"), + }, "source": SOURCE, "status": STATUS, + "profile": PROFILE, + "profile_rule": PROFILE_RULE, } diff --git a/scripts/report_render/reading_facts.py b/scripts/report_render/reading_facts.py index 1f14c227a..17ec42729 100644 --- a/scripts/report_render/reading_facts.py +++ b/scripts/report_render/reading_facts.py @@ -24,6 +24,7 @@ from typing import Any from .birth_precision_margins import ascendant_margins from .evidence_grade import evidence_grades from .parity_chapters import _VIMSOPAKA_DIGNITY +from .technique_status_axes import technique_audit_axes try: from scripts.consult_card_domain_facts import ( @@ -115,7 +116,13 @@ PARTICIPATION_REASON_CODES = { ("general", "D2"): "not_routed", } STRUCTURED_VALUES = { - "Badhaka": ("ascendant_modality", "house", "sign", "lord", "lord_sign", "lord_house", "lord_dignity", "occupants", "status"), + "Badhaka": ("ascendant_sign", "ascendant_modality", "badhaka_sthana", "badhakesh", "source", "status", + "profile", "profile_rule"), +} +PARTICIPATION_BLOCKED_REASONS = { + "missing_input": "missing_input", "error": "call_failed", + "calculation_failed": "call_failed", "call_failed": "call_failed", + "validation_failed": "validation_failed", } UNUSED_POINT_PATHS = { "Indu": f"{LAGNAS}.Indu_Lagna.sign", @@ -408,6 +415,31 @@ def _unused_value(view: dict, item_id: str, minute_confirmed: bool) -> str | Non return None +def _participation_axes(row: dict[str, Any], item: dict[str, Any], view: dict) -> dict[str, Any]: + state, item_id = row["state"], row["id"] + if item_id == "kp" and item.get("check") == "label": + # The participation label describes the method, even when no KP results were supplied. + if not (dig(view, f"{KP}.planets") or dig(view, f"{KP}.houses")): + return {"execution_status": "not_computed", "interpretation_usage": "not_used"} + if state == "executed" or "value" in row: + usage = "not_used" + if state == "executed": + usage = {"Badhaka": "supporting", "kp": "conditional"}.get(item_id, "primary") + axes = technique_audit_axes({}, {"calculation_status": "executed", "interpretation_status": usage}) + return {"execution_status": axes["calculation_status"], "interpretation_usage": axes["interpretation_status"]} + if item.get("status") == "not_applicable" and isinstance(item.get("reason"), str) and item["reason"].strip(): + return {"execution_status": "not_applicable", "interpretation_usage": "not_used", "reason": item["reason"]} + raw_reason = item.get("blocked_reason") or item.get("reason_code") or item.get("status") + blocked_reason = ( + "missing_input" if state == "withheld" + else PARTICIPATION_BLOCKED_REASONS.get(raw_reason) + or PARTICIPATION_BLOCKED_REASONS.get(row.get("reason_code")) + ) + if blocked_reason: + return {"execution_status": "blocked", "interpretation_usage": "not_used", "blocked_reason": blocked_reason} + return {"execution_status": "not_computed", "interpretation_usage": "not_used"} + + def _participation(rows: list[dict[str, Any]], domain: str, view: dict, minute_confirmed: bool) -> list[dict[str, Any]]: """Each technique's state for the domain; small values ride along.""" out = [] @@ -418,7 +450,7 @@ def _participation(rows: list[dict[str, Any]], domain: str, view: dict, minute_c item_id = item["id"] reason = None if status == "blocked": - reason = PARTICIPATION_REASON_CODES[domain, item_id] + reason = PARTICIPATION_REASON_CODES.get((domain, item_id), "not_computed") elif status != "value" and status != "withheld": reason = "not_computed" # A packet leaf is absent. The card does not report an engine exception. state = {"value": "executed", "withheld": "withheld"}.get(status, "blocked") @@ -439,6 +471,9 @@ def _participation(rows: list[dict[str, Any]], domain: str, view: dict, minute_c row["reason"] = PRECISION_SENTENCE if isinstance(item.get("citation"), str): row["source"] = item["citation"] + row.update(_participation_axes(row, item, view)) + if row["execution_status"] == "not_computed": + row.pop("value", None) out.append(row) return out @@ -748,12 +783,15 @@ def _blocked_states( ) -> dict[str, Any]: labels: dict[str, list[str]] = { "blocked": [], "not_routed": [], "not_in_domain_route": [], - "parameter_sensitive": [], "not_applicable": [], "withheld": [], + "parameter_sensitive": [], "not_applicable": [], "withheld": [], "not_computed": [], } for name, row in domains.items(): for item in [*(row.get("participation") or []), *(shared if name == "general" else [])]: - if item["state"] in labels: - labels[item["state"]].append(f"{name}:{item['id']}") + identity = f"{name}:{item['id']}" + if item["state"] in UNUSED_REASONS or item["state"] == "withheld": + labels[item["state"]].append(identity) + if item["execution_status"] in ("blocked", "not_applicable", "not_computed"): + labels[item["execution_status"]].append(identity) for family in families: status = str(family.get("status") or "") if status in BLOCKED_STATES: diff --git a/tests/test_badhaka_facts_20261112.py b/tests/test_badhaka_facts_20261112.py index 6b6b9124f..788d0e7bc 100644 --- a/tests/test_badhaka_facts_20261112.py +++ b/tests/test_badhaka_facts_20261112.py @@ -9,9 +9,10 @@ def test_source_table_for_cancer_leo_gemini(): ("Gemini", 7, "Sagittarius", "Jupiter")): planets = {lord: {"sign": "Libra", "house": 2, "dignity": "Neutral"}, "Ketu": {"sign": sign, "house": house}} record = badhaka_facts(asc, planets) - assert (record["house"], record["sign"], record["lord"]) == (house, sign, lord) - assert (record["lord_sign"], record["lord_house"]) == ("Libra", 2) - assert record["occupants"] == ["Ketu"] + sthana, badhakesh = record["badhaka_sthana"], record["badhakesh"] + assert (sthana["house"], sthana["sign"], badhakesh["planet"]) == (house, sign, lord) + assert (badhakesh["sign"], badhakesh["house"]) == ("Libra", 2) + assert sthana["occupants"] == ["Ketu"] assert record["status"] == STATUS diff --git a/tests/test_badhaka_twelve_ascendants_20261112.py b/tests/test_badhaka_twelve_ascendants_20261112.py new file mode 100644 index 000000000..acf6a64cf --- /dev/null +++ b/tests/test_badhaka_twelve_ascendants_20261112.py @@ -0,0 +1,43 @@ +"""The source table's house and lord, with separate D1 placement facts.""" + +import pytest + +from scripts.report_render.badhaka_facts import badhaka_facts + + +@pytest.mark.parametrize(("ascendant", "house", "sign", "lord"), [ + ("Aries", 11, "Aquarius", "Saturn"), + ("Taurus", 9, "Capricorn", "Saturn"), + ("Gemini", 7, "Sagittarius", "Jupiter"), + ("Cancer", 11, "Taurus", "Venus"), + ("Leo", 9, "Aries", "Mars"), + ("Virgo", 7, "Pisces", "Jupiter"), + ("Libra", 11, "Leo", "Sun"), + ("Scorpio", 9, "Cancer", "Moon"), + ("Sagittarius", 7, "Gemini", "Mercury"), + ("Capricorn", 11, "Scorpio", "Mars"), + ("Aquarius", 9, "Libra", "Venus"), + ("Pisces", 7, "Virgo", "Mercury"), +]) +def test_badhaka_house_and_lord_from_source_table(ascendant, house, sign, lord): + assert ascendant != sign + planets = { + lord: {"sign": ascendant, "house": 1, "dignity": "Neutral"}, + "Ketu": {"sign": sign, "house": house}, + "Rahu": {"sign": ascendant, "house": house}, + } + record = badhaka_facts(ascendant, planets) + assert record["badhaka_sthana"] == {"house": house, "sign": sign, "occupants": ["Ketu"]} + assert record["badhakesh"] == {"planet": lord, "sign": ascendant, "house": 1, "dignity": "Neutral"} + assert record["badhakesh"]["house"] != record["badhaka_sthana"]["house"] + assert record["badhakesh"]["planet"] not in record["badhaka_sthana"]["occupants"] + assert record["profile"] == "badhaka_modality_v1" + assert record["source"].endswith("badhaka-obstacle-planet-guide.md §二") + assert record["status"] == "product_computation_pending_astrologer_review" + assert {"house", "sign", "lord", "lord_house", "occupants"}.isdisjoint(record) + + +def test_badhakesh_is_an_occupant_when_it_is_in_the_obstructing_sign(): + record = badhaka_facts("Gemini", {"Jupiter": {"sign": "Sagittarius", "house": 7}}) + assert record["badhaka_sthana"]["occupants"] == ["Jupiter"] + assert record["badhakesh"]["house"] == record["badhaka_sthana"]["house"] == 7 diff --git a/tests/test_reading_facts_v3_20261112.py b/tests/test_reading_facts_v3_20261112.py index c94dafad6..6757cae92 100644 --- a/tests/test_reading_facts_v3_20261112.py +++ b/tests/test_reading_facts_v3_20261112.py @@ -80,8 +80,8 @@ def test_public_report_v3_facts(public_report): # BUG-1853: Badhaka is computed from the ascendant and reaches the health facts with its positions. badhaka = next(row for row in facts["domains"]["health"]["participation"] if row["id"] == "Badhaka") assert badhaka["state"] == "executed" - assert badhaka["value"]["house"] in (7, 9, 11) - assert badhaka["value"]["sign"] and badhaka["value"]["lord"] + assert badhaka["value"]["badhaka_sthana"]["house"] in (7, 9, 11) + assert badhaka["value"]["badhaka_sthana"]["sign"] and badhaka["value"]["badhakesh"]["planet"] # Product computation, not her engine (owner rule 2026-11-07): the record says so. assert badhaka["value"]["status"] == "product_computation_pending_astrologer_review" assert dig(packet, "worksheets.advanced_systems.badhaka") is None diff --git a/tests/test_reading_status_axes_20261112.py b/tests/test_reading_status_axes_20261112.py new file mode 100644 index 000000000..59b981043 --- /dev/null +++ b/tests/test_reading_status_axes_20261112.py @@ -0,0 +1,118 @@ +"""Separate participation from computation in the report's facts.""" + +import pytest + +from scripts.consult_card_domain_facts import _badhaka +from scripts.report_render import reading_facts as rf +from scripts.report_render.technique_status_axes import CALCULATION_LABELS, INTERPRETATION_LABELS +from tests.test_reading_facts_v3_20261112 import _reading_facts, _reading_request, public_report + + +def test_unused_results_and_absent_results_keep_distinct_axes(): + card = [{"id": "Indu", "status": "blocked"}] + missing, = rf._participation(card, "wealth", {}, True) + assert (missing["state"], missing["execution_status"], missing["interpretation_usage"]) == ( + "not_in_domain_route", "not_computed", "not_used", + ) + assert "value" not in missing and "blocked_reason" not in missing + + view = {"worksheets": {"divisional_and_special_charts": { + "special_lagnas": {"Indu_Lagna": {"sign": "Leo"}}, + "varga_full": {"D10_Dasamsa": {"Ascendant": {"sign": "Leo"}}}, + }}} + unused, = rf._participation(card, "wealth", view, True) + not_routed, = rf._participation([{"id": "D10", "status": "blocked"}], "general", view, True) + assert unused["state"] == "not_in_domain_route" + assert not_routed["state"] == "not_routed" + for row in (unused, not_routed): + assert (row["execution_status"], row["interpretation_usage"]) == ("executed", "not_used") + assert row["value"] == "Leo" and row["computed"] is True + + +@pytest.mark.parametrize(("item", "execution", "reason"), [ + ({"status": "withheld"}, "blocked", "missing_input"), + ({"status": "error"}, "blocked", "call_failed"), + ({"status": "blocked", "blocked_reason": "validation_failed"}, "blocked", "validation_failed"), + ({"status": "gap"}, "not_computed", None), + ({"status": "not_applicable", "reason": "requires a relationship comparison"}, "not_applicable", None), +]) +def test_states_keep_explicit_blocking_and_applicability_reasons(item, execution, reason): + row, = rf._participation([{"id": "example", **item}], "general", {}, False) + assert (row["execution_status"], row["interpretation_usage"]) == (execution, "not_used") + assert row.get("blocked_reason") == reason + if execution == "not_applicable": + assert row["reason"] == item["reason"] + assert "value" not in row + + +def test_badhaka_missing_ascendant_is_blocked_for_missing_input(): + row, = rf._participation([{"id": "Badhaka", **_badhaka({})}], "health", {}, True) + assert (row["state"], row["execution_status"], row["blocked_reason"]) == ("blocked", "blocked", "missing_input") + + +def test_kp_method_label_is_not_a_calculation_result(): + item = {"id": "kp", "status": "value", "check": "label", "value": "conditional method"} + missing, = rf._participation([item], "general", {}, True) + assert missing["state"] == "executed" + assert (missing["execution_status"], missing["interpretation_usage"]) == ("not_computed", "not_used") + assert "value" not in missing + view = {"worksheets": {"advanced_systems": {"kp": {"planets": {"Moon": {"sub": "Mars"}}}}}} + computed, = rf._participation([item], "general", view, True) + assert (computed["execution_status"], computed["interpretation_usage"]) == ("executed", "conditional") + + +def test_summary_keeps_routing_separate_from_calculation_gaps(): + rows = rf._participation([ + {"id": "Gulika", "status": "blocked"}, + {"id": "D6", "status": "withheld"}, + {"id": "D8", "status": "gap"}, + ], "health", {"worksheets": {"divisional_and_special_charts": { + "upagrahas": {"raw": {"Gulika": {"sign_idx": 7}}}, + }}}, False) + transits = {"planets": {"Jupiter": {}}, "double_transit": {"checked_houses": [7]}} + result = rf._blocked_states({"health": {"participation": rows}}, [], [], {}, transits, {}) + assert result["not_in_domain_route"] == ["health:Gulika"] + assert result["withheld"] == ["health:D6"] + assert result["blocked"] == ["health:D6"] + assert result["not_computed"] == ["health:D8"] + + +def test_public_report_axes_and_badhaka_positions(public_report): + case, body, reading, packet = public_report + facts = _reading_facts(packet, reading, **_reading_request(body)) + participation = {name: {row["id"]: row for row in domain["participation"]} + for name, domain in facts["domains"].items()} + unused = [participation["wealth"]["Indu"]] + unused.extend(participation["health"][name] for name in ("Gulika", "Mandi", "Pranapada")) + for row in unused: + assert row["state"] == "not_in_domain_route" + assert (row["execution_status"], row["interpretation_usage"]) == ("executed", "not_used") + assert row["value"] and row["computed"] is True + + health = participation["health"]["Badhaka"] + assert (health["state"], health["execution_status"], health["interpretation_usage"]) == ( + "executed", "executed", "supporting", + ) + record = health["value"] + sthana, lord = record["badhaka_sthana"], record["badhakesh"] + expected = { + "steve_jobs_1955_aa": (7, "Pisces", "Jupiter", 10), + "barack_obama_1961_aa": (11, "Scorpio", "Mars", 9), + } + assert (sthana["house"], sthana["sign"], lord["planet"], lord["house"]) == expected[case] + assert lord["dignity"] and lord["dignity"] == facts["planets"][lord["planet"]]["d1_dignity"] + if case == "steve_jobs_1955_aa": + assert "Moon" in sthana["occupants"] + assert lord["planet"] not in sthana["occupants"] + assert record["profile"] == "badhaka_modality_v1" + assert record["status"] == "product_computation_pending_astrologer_review" + assert facts["evidence_grades"]["claims"]["health_obstruction"]["cap"] != "D" + + rows = [*facts["shared_techniques"], *(row for domain in participation.values() for row in domain.values())] + for row in rows: + assert row["execution_status"] in CALCULATION_LABELS.keys() | {"not_computed"} + assert row["interpretation_usage"] in INTERPRETATION_LABELS.keys() - {"blocked", "observation_only"} + if row["execution_status"] == "not_computed": + assert "value" not in row + if row["execution_status"] == "blocked": + assert row["blocked_reason"] in {"missing_input", "call_failed", "validation_failed"} diff --git a/tests/test_report_reading_facts.py b/tests/test_report_reading_facts.py index 100d7fb50..3ae53391f 100644 --- a/tests/test_report_reading_facts.py +++ b/tests/test_report_reading_facts.py @@ -54,9 +54,9 @@ def test_reading_facts_are_packet_leaves(chart) -> None: assert [row["lord"] for row in facts["timing"]["next_antardashas"]] == [row["lord"] for row in rows[index + 1:index + 3]] # 原值:'"status"'、'"citation"'、"references/" 一律不进模型输入,总长 < 20000 # 新值:内部 leaf 的 path / check / citation 键仍不进;技法状态(executed / blocked / withheld)、 - # 依据来源(references/ 条目)与证据路径进入契约;总长 < 80000 + # 依据来源(references/ 条目)与证据路径进入契约;写作输入的紧凑 JSON 总长 < 80000 # 原因:产品 2026-11-07 占星师方案 item 10:reading_facts 契约要带证据路径、方法差异和阻塞状态 - encoded = json.dumps(facts, ensure_ascii=False) + encoded = json.dumps(facts, ensure_ascii=False, separators=(",", ":")) for marker in ('"path"', '"check"', '"citation"'): assert marker not in encoded assert len(encoded) < 80_000 @@ -135,7 +135,10 @@ def test_withheld_varga_houses_stay_out_without_a_confirmed_minute(chart) -> Non health = facts["domains"]["health"] assert health["varga_charts"]["D30"] == "出生时间精度不够,不参与" d30 = next(row for row in health["participation"] if row["id"] == "D30") - assert d30 == {"id": "D30", "state": "withheld", "reason": "出生时间精度不够,不参与", "source": d30["source"]} + assert d30 == { + "id": "D30", "state": "withheld", "reason": "出生时间精度不够,不参与", "source": d30["source"], + "execution_status": "blocked", "interpretation_usage": "not_used", "blocked_reason": "missing_input", + } assert facts["special_points"]["Ghati_Lagna"] == "出生时间精度不够,不参与" assert "health:D30" in facts["blocked_states"]["withheld"]