Merge remote-tracking branch 'origin/staging' into codex/reading-postcheck-facts-20261112
This commit is contained in:
@@ -25085,3 +25085,30 @@
|
||||
- 防复发:后端验证单来源不成窗、条件事件不能桥接窗口,前端验证同向不抬级和候选说明。
|
||||
- 关联记录:#209、#190、BUG-1601、BUG-1650、BUG-1732、BUG-1830、BUG-1842。
|
||||
- 修复版本:`codex/annual-narayana-conditional-20261112`。
|
||||
|
||||
## BUG-1858 | 报告用途稳定性由一分钟分盘边界检查推定
|
||||
|
||||
- 状态:fixed-pending-verify(待独立验收)。
|
||||
- 首次发现 / 最近更新:2026-11-12 / 2026-11-12。
|
||||
- 影响面:个人报告 `report_evidence_grade_v1` 每类结论的用途稳定性账本。
|
||||
- 现象和触发:事实包报用途未评估,但一分钟内无分盘边界时账本填稳定。应期窗口无分盘依赖也被填稳定。
|
||||
- 根因:`claim_grade` 从分盘边界检查推导用途稳定性。BUG-1851 的既有回归核对分级上限和分盘边界,还把边界值当作用途稳定性,未覆盖两者不一致。
|
||||
- 修复:分别记录用途评估和一分钟边界检查,增加未评估披露,保留必需分盘贴边时的 D 上限。
|
||||
- 验证:合成事实包复现原实现八项误报稳定。Claude 确认同步两条旧断言后,任务书三文件合跑 20 项通过。快速门有 3 项失败,均在 staging 定向复现。见 `docs/tasks/PROGRESS-purpose-stability-20261112.md`。
|
||||
- 防复发:新增回归覆盖未评估、应期窗口、必需分盘贴边及缺失边界。保留旧测试的 D6/D30 上限检查,分别核对 D6 的边界状态和 D30 的披露。
|
||||
- 关联记录:#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`。
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# 报告用途稳定性 · 2026-11-12
|
||||
|
||||
Gitea #215,BUG-1858。首次按评论 42245 认领。评论 42285 确认两条断言可同步更新,认领评论 42293。任务书基线为 `1ba0364a7a8c0f964c3e21c21cb304aaa1899375`。
|
||||
|
||||
## 已核实
|
||||
|
||||
- 用完整合成事实复现。所有分盘最近边界大于 60 分钟、事实包用途稳定性为 `not_evaluated` 时,旧账本将八类结论全标为 `stable`。八类上限仍为 C。
|
||||
- 账本从事实包读取用途稳定性,默认 `not_evaluated`。事实包给出 `stable` 时,应期窗口仍记为 `not_evaluated`。分盘边界独立列在 `ledger.boundary_check`,包含规则、状态和原数值。必需 D6 距边界 0.25 分钟时上限仍为 D。
|
||||
- 已检索 `frontend/src` 及后端消费者。前端等级判断读取 `evidence_grades.claims` 的 `cap`。未找到消费本单 `v:` 行的 `stable` 字面值的模块。
|
||||
- 四项新增回归在本地候选上通过。第一项在原实现失败,实际为八项 `stable`。
|
||||
- 拍板前合跑任务书指定的三个文件,19 项通过、1 项失败。原 staging 上两个既有文件 16 项均通过。候选失败是下表第一条。运行在第一条断言中止,第二条已用同一夹具独立核对。
|
||||
|
||||
## 既有断言变更
|
||||
|
||||
两条断言在 `tests/test_report_evidence_grade_20261112.py` 的同一个测试中。Claude 2026-11-12 答复确认可同步更新。
|
||||
|
||||
| 位置 | 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- | --- |
|
||||
| `test_missing_required_layer_or_boundary_varga_gives_d` 的必需 D6 | `ledger.purpose_stability == "boundary_sensitive"` | `ledger.purpose_stability == "not_evaluated"`,在 `boundary_check.rows` 验证 D6 为 `boundary_sensitive`,保留上限 D 断言 | 任务书 #215 第 1、5 条;Claude 2026-11-12 答复。 |
|
||||
| 同测试的仅核对 D30 | `must_disclose == ["v:D30"]` | `must_disclose` 同时包含 `v:D30` 与 `purpose_stability_not_evaluated`,保留上限 C 断言 | 任务书 #215 第 1、5 条;Claude 2026-11-12 答复。 |
|
||||
|
||||
## 最终验证
|
||||
|
||||
- 合入本分支的验证基线为 staging `2f374fff281622f342151a97fa6f6d758de74cc8`,保留了该分支上的 Bug 记录。
|
||||
- 更新既有断言后,任务书指定三文件合跑 20 项通过,四项新增回归均通过。
|
||||
- Python 快速门退出码 1,1,463 项通过、3 项失败、2 项跳过、29 项子测试通过。失败均在 `test_upstream_technique_layers.py`,在同一 staging 提交定向复跑重现。
|
||||
- 仓库隐私检查 62 项通过。
|
||||
@@ -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 项通过。
|
||||
@@ -0,0 +1,71 @@
|
||||
# TASK:上限账本的用途稳定性不再由一分钟规则冒充(2026-11-12)
|
||||
|
||||
- Gitea:#215
|
||||
- 分支:`codex/purpose-stability-20261112`,基于 staging `1ba0364a7a8c0f964c3e21c21cb304aaa1899375`
|
||||
- Bug 编号:BUG-1858
|
||||
- 验收: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」都指这份文件。
|
||||
|
||||
## 背景(她 §2 P0-1)
|
||||
|
||||
`scripts/report_render/evidence_grade.py` 为报告解读的每类结论算上限,账本里有一项 `purpose_stability`。问题在于两处结果对不上:
|
||||
|
||||
- 事实包里 `birth_precision.purpose_stability` 是 `not_evaluated`,因为按用途区间的合同还没接入。
|
||||
- 账本里却写 `stable`。
|
||||
|
||||
原因是 `claim_grade` 用 `_varga_stability` 的结果推出 `purpose_stability`:分盘上升最近的换宫距离大于 `CONFIRMED_TOLERANCE_MINUTES = 1.0`,就算 `stable`。Jobs 样例的 8 项全是 `stable`;Obama 样例 7 项 `stable`,1 项 `boundary_sensitive`。
|
||||
|
||||
她的裁定:这个一分钟比较只是在 `birth_record_minute_v1` 规则下检查附近有没有边界,不能证明结论在真实出生区间内稳定。`timing_window` 更不能在没有精度依赖的情况下标成稳定。
|
||||
|
||||
## 要改的文件
|
||||
|
||||
- `scripts/report_render/evidence_grade.py`
|
||||
- 新建 `tests/test_evidence_grade_purpose_stability_20261112.py`
|
||||
- `tests/test_report_evidence_grade_20261112.py`:只在断言写的是旧的 `stable` 时改,并在 PROGRESS 逐条列出
|
||||
- `docs/BUG_HISTORY.md`:只在末尾追加一条
|
||||
- `docs/tasks/PROGRESS-purpose-stability-20261112.md`
|
||||
|
||||
## 要做的
|
||||
|
||||
1. 账本里的 `purpose_stability` 改成直接取事实包的 `birth_precision.purpose_stability`,取不到就填 `not_evaluated`。不能再由分盘边界推出来。
|
||||
2. 分盘边界检查的结果单独记在账本新字段 `boundary_check` 里,形如 `{"policy": "birth_record_minute_v1", "rows": [...]}`。`rows` 保留现有的 `nearest_change_minutes`、`tolerance_minutes` 和状态(`clear` 表示一分钟内没有换宫,另有 `boundary_sensitive`、`not_evaluated`、`missing`)。
|
||||
- `required` / `checked` 里 `v:` 依赖行的 `state`:`stable` 改名为 `clear_at_tolerance`。
|
||||
- 其余状态不变。
|
||||
- 前端读不读这个字符串,你要用 grep 核对 `frontend/src`。如果有读取,只能在 PROGRESS 报告,不许改前端,选需拍板。
|
||||
3. 上限规则不变:
|
||||
- 必需分盘落在边界内(`boundary_sensitive`),照旧给 D;
|
||||
- `not_evaluated` 不会因此把结论降到 D(她:未评估不意味着整份报告一律 D)。
|
||||
4. `timing_window` 的账本里,`purpose_stability` 在任何情况下都不能是 `stable`。
|
||||
5. 新增一个 `must_disclose` 项 `purpose_stability_not_evaluated`:只要 `purpose_stability` 不是 `stable`,每类结论都带上这一项。
|
||||
|
||||
## 不要碰
|
||||
|
||||
- `frontend/**`、`references/**`、`scripts/report_render/reading_facts.py`、`scripts/report_render/birth_precision_margins.py`
|
||||
- 冻结文件
|
||||
|
||||
## 验收标准(写进新测试)
|
||||
|
||||
1. 用合成 facts 测:`minute_confirmed=True`,所有分盘边界都大于 60 分钟,`birth_precision.purpose_stability="not_evaluated"`。此时 8 类结论的账本 `purpose_stability` 全是 `not_evaluated`,上限仍是 C。
|
||||
2. 事实包里给出 `birth_precision.purpose_stability="stable"` 时,`timing_window` 仍不是 `stable`,其他类照抄 `stable`。
|
||||
3. `v:D8` 落在 0.25 分钟内、并且是必需依赖时(自己造一个把 D8 设为必需的场景;做不到就用 D6),该类上限是 D。`boundary_check.rows` 里能看到 0.25。
|
||||
4. 旧代码上,第 1 条必须失败。在 PROGRESS 里记下旧代码的结果。
|
||||
5. `tests/test_report_evidence_grade_20261112.py` 和 `tests/test_reading_facts_v3_20261112.py` 全部通过。
|
||||
|
||||
## 自测命令(仓库根目录)
|
||||
|
||||
```
|
||||
python3 -m pytest -q tests/test_evidence_grade_purpose_stability_20261112.py tests/test_report_evidence_grade_20261112.py tests/test_reading_facts_v3_20261112.py
|
||||
python3 scripts/run_quality_gate.py --profile quick --skip-frontend-runtime
|
||||
```
|
||||
|
||||
## 何时停下来选「需拍板」
|
||||
|
||||
- 前端或别的模块依赖 `stable` 这个字面值。
|
||||
- 只有改事实包结构才能完成。
|
||||
@@ -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/` 下你不许改的代码。
|
||||
@@ -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"}
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ GRADE_CONTRACT = "report_evidence_grade_v1"
|
||||
GRADE_ORDER = ("A", "B", "C", "D")
|
||||
# Product policy, versioned: how far the true birth instant may sit from the
|
||||
# recorded one. A minute-confirmed record is taken as +/- 1 minute; an
|
||||
# unconfirmed one has no stated tolerance, so varga stability is not evaluated.
|
||||
# unconfirmed one has no stated tolerance, so the local boundary is not checked.
|
||||
PRECISION_POLICY = "birth_record_minute_v1"
|
||||
CONFIRMED_TOLERANCE_MINUTES = 1.0
|
||||
|
||||
@@ -42,7 +42,7 @@ MISSING_STATES = {"blocked", "withheld", "missing", "calculation_failed", "missi
|
||||
# Dependency kinds:
|
||||
# ("p", domain, id) domain participation row
|
||||
# ("s", id) shared technique row
|
||||
# ("v", code) varga ascendant stable within the birth-time tolerance
|
||||
# ("v", code) varga ascendant boundary relative to the birth-time tolerance
|
||||
# ("t", key) timing / transit / annual block present
|
||||
# Each claim type: route (her router section), section ids it may appear in,
|
||||
# required deps (missing -> D) and checked deps (missing -> disclosed only).
|
||||
@@ -124,7 +124,7 @@ def _shared(facts: dict, item_id: str) -> str:
|
||||
return "missing"
|
||||
|
||||
|
||||
def _varga_stability(facts: dict, code: str) -> tuple[str, dict[str, Any]]:
|
||||
def _varga_boundary(facts: dict, code: str) -> tuple[str, dict[str, Any]]:
|
||||
precision = facts.get("birth_precision") or {}
|
||||
margin = (precision.get("ascendant_margins") or {}).get(code)
|
||||
if not facts.get("minute_confirmed"):
|
||||
@@ -134,7 +134,7 @@ def _varga_stability(facts: dict, code: str) -> tuple[str, dict[str, Any]]:
|
||||
nearest = min(float(margin.get("before_minutes", 0)), float(margin.get("after_minutes", 0)))
|
||||
detail = {"policy": PRECISION_POLICY, "nearest_change_minutes": nearest,
|
||||
"tolerance_minutes": CONFIRMED_TOLERANCE_MINUTES}
|
||||
return ("stable" if nearest > CONFIRMED_TOLERANCE_MINUTES else "boundary_sensitive"), detail
|
||||
return ("clear_at_tolerance" if nearest > CONFIRMED_TOLERANCE_MINUTES else "boundary_sensitive"), detail
|
||||
|
||||
|
||||
def _block_state(facts: dict, key: str) -> str:
|
||||
@@ -168,7 +168,7 @@ def _evaluate(facts: dict, dep: tuple, sensitive: set[str]) -> dict[str, Any]:
|
||||
if dep[1] in sensitive and state == "executed":
|
||||
state = "parameter_sensitive"
|
||||
elif kind == "v":
|
||||
state, detail = _varga_stability(facts, dep[1])
|
||||
state, detail = _varga_boundary(facts, dep[1])
|
||||
else:
|
||||
state = _block_state(facts, dep[1])
|
||||
return {"id": _dep_id(dep), "state": state, **({"detail": detail} if detail else {})}
|
||||
@@ -189,15 +189,20 @@ def claim_grade(facts: dict, claim_type: str) -> dict[str, Any]:
|
||||
required = [_evaluate(facts, dep, sensitive) for dep in spec["required"]]
|
||||
checked = [_evaluate(facts, dep, sensitive) for dep in spec["checked"]]
|
||||
missing_required = [row["id"] for row in required if _is_missing(row)]
|
||||
missing_checked = [row["id"] for row in checked if _is_missing(row)]
|
||||
must_disclose = [row["id"] for row in checked if _is_missing(row)]
|
||||
sensitive_rows = [row["id"] for row in required + checked if row["state"] == "parameter_sensitive"]
|
||||
stability = [row for row in required + checked if row["id"].startswith("v:")]
|
||||
if any(row["state"] == "boundary_sensitive" for row in stability):
|
||||
purpose = "boundary_sensitive"
|
||||
elif any(row["state"] == "not_evaluated" for row in stability):
|
||||
boundary_rows = []
|
||||
for row in required + checked:
|
||||
if row["id"].startswith("v:"):
|
||||
details = {key: value for key, value in row["detail"].items() if key != "policy"}
|
||||
state = "clear" if row["state"] == "clear_at_tolerance" else row["state"]
|
||||
boundary_rows.append({"id": row["id"], "state": state, **details})
|
||||
precision = facts.get("birth_precision") or {}
|
||||
purpose = precision.get("purpose_stability") or "not_evaluated"
|
||||
if claim_type == "timing_window" and purpose == "stable":
|
||||
purpose = "not_evaluated"
|
||||
else:
|
||||
purpose = "stable"
|
||||
if purpose != "stable":
|
||||
must_disclose.append("purpose_stability_not_evaluated")
|
||||
cap = "D" if missing_required else "C"
|
||||
reasons = (
|
||||
[f"required dependency unavailable: {item}" for item in missing_required]
|
||||
@@ -210,14 +215,15 @@ def claim_grade(facts: dict, claim_type: str) -> dict[str, Any]:
|
||||
"reasons": reasons,
|
||||
"required": required,
|
||||
"checked": checked,
|
||||
"must_disclose": missing_checked,
|
||||
"must_disclose": must_disclose,
|
||||
"parameter_sensitive": sensitive_rows,
|
||||
# Six axes (§5.2), raw enums; a missing value never defaults to good.
|
||||
# Six axes (§5.2) plus the local boundary check.
|
||||
"ledger": {
|
||||
"case_fit": "none",
|
||||
"method_maturity": "source_bounded" if not missing_required else "dependency_missing",
|
||||
"independent_agreement": "not_assessed",
|
||||
"purpose_stability": purpose,
|
||||
"boundary_check": {"policy": PRECISION_POLICY, "rows": boundary_rows},
|
||||
"external_calculation_check": "not_done",
|
||||
"contradiction": [f"{row.get('planet')}: natural {row.get('natural')} / functional {row.get('functional')}"
|
||||
for row in _contradictions(facts)],
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,70 @@
|
||||
"""Keep the product's minute boundary check separate from purpose stability."""
|
||||
|
||||
from scripts.report_render.evidence_grade import CLAIM_TYPES, claim_grade, evidence_grades
|
||||
from tests.test_report_evidence_grade_20261112 import _facts
|
||||
|
||||
|
||||
def _complete_facts(purpose_stability):
|
||||
facts = _facts()
|
||||
for row in facts["domains"]["health"]["participation"]:
|
||||
if row["id"] == "Badhaka":
|
||||
row["state"] = "executed"
|
||||
precision = facts["birth_precision"]
|
||||
precision["purpose_stability"] = purpose_stability
|
||||
for margin in precision["ascendant_margins"].values():
|
||||
margin.update(before_minutes=90.0, after_minutes=120.0)
|
||||
return facts
|
||||
|
||||
|
||||
def test_clear_minute_boundary_does_not_establish_purpose_stability():
|
||||
claims = evidence_grades(_complete_facts("not_evaluated"))["claims"]
|
||||
assert len(claims) == 8
|
||||
assert {name: claim["ledger"]["purpose_stability"] for name, claim in claims.items()} == {
|
||||
name: "not_evaluated" for name in CLAIM_TYPES
|
||||
}
|
||||
for claim in claims.values():
|
||||
assert claim["cap"] == "C"
|
||||
assert "purpose_stability_not_evaluated" in claim["must_disclose"]
|
||||
character = claims["character_structure"]
|
||||
assert character["required"][0]["state"] == "clear_at_tolerance"
|
||||
assert next(row for row in character["checked"] if row["id"] == "v:D9")["state"] == "clear_at_tolerance"
|
||||
assert character["ledger"]["boundary_check"]["policy"] == "birth_record_minute_v1"
|
||||
assert character["ledger"]["boundary_check"]["rows"][0] == {
|
||||
"id": "v:D1", "state": "clear", "nearest_change_minutes": 90.0, "tolerance_minutes": 1.0,
|
||||
}
|
||||
|
||||
|
||||
def test_explicit_stability_does_not_make_timing_stable():
|
||||
claims = evidence_grades(_complete_facts("stable"))["claims"]
|
||||
for name, claim in claims.items():
|
||||
purpose = "not_evaluated" if name == "timing_window" else "stable"
|
||||
assert claim["ledger"]["purpose_stability"] == purpose
|
||||
assert ("purpose_stability_not_evaluated" in claim["must_disclose"]) == (purpose != "stable")
|
||||
assert claims["timing_window"]["ledger"]["boundary_check"]["rows"] == []
|
||||
|
||||
|
||||
def test_required_boundary_still_caps_the_claim_at_d():
|
||||
facts = _complete_facts("not_evaluated")
|
||||
facts["birth_precision"]["ascendant_margins"]["D6"]["before_minutes"] = 0.25
|
||||
claim = claim_grade(facts, "health_pressure")
|
||||
assert claim["cap"] == "D"
|
||||
assert claim["ledger"]["purpose_stability"] == "not_evaluated"
|
||||
row = next(row for row in claim["ledger"]["boundary_check"]["rows"] if row["id"] == "v:D6")
|
||||
assert row == {
|
||||
"id": "v:D6", "state": "boundary_sensitive", "nearest_change_minutes": 0.25, "tolerance_minutes": 1.0,
|
||||
}
|
||||
|
||||
|
||||
def test_missing_purpose_defaults_to_unassessed_independently_of_boundary_status():
|
||||
facts = _complete_facts(None)
|
||||
del facts["birth_precision"]["ascendant_margins"]["D9"]
|
||||
claim = claim_grade(facts, "character_structure")
|
||||
assert claim["cap"] == "C"
|
||||
assert claim["ledger"]["purpose_stability"] == "not_evaluated"
|
||||
assert claim["must_disclose"] == ["v:D9", "purpose_stability_not_evaluated"]
|
||||
assert claim["ledger"]["boundary_check"]["rows"][-1]["state"] == "missing"
|
||||
|
||||
facts["minute_confirmed"] = False
|
||||
claim = claim_grade(facts, "character_structure")
|
||||
assert claim["cap"] == "C"
|
||||
assert {row["state"] for row in claim["ledger"]["boundary_check"]["rows"]} == {"not_evaluated"}
|
||||
@@ -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
|
||||
|
||||
@@ -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"}
|
||||
@@ -69,12 +69,14 @@ def test_missing_required_layer_or_boundary_varga_gives_d():
|
||||
boundary["birth_precision"]["ascendant_margins"]["D6"] = {"before_minutes": 0.4, "after_minutes": 9.0}
|
||||
health = claim_grade(boundary, "health_pressure")
|
||||
assert health["cap"] == "D"
|
||||
assert health["ledger"]["purpose_stability"] == "boundary_sensitive"
|
||||
assert health["ledger"]["purpose_stability"] == "not_evaluated"
|
||||
d6 = next(row for row in health["ledger"]["boundary_check"]["rows"] if row["id"] == "v:D6")
|
||||
assert d6["state"] == "boundary_sensitive"
|
||||
checked_only = _facts()
|
||||
checked_only["birth_precision"]["ascendant_margins"]["D30"] = {"before_minutes": 0.4, "after_minutes": 9.0}
|
||||
disclosed = claim_grade(checked_only, "health_pressure")
|
||||
assert disclosed["cap"] == "C"
|
||||
assert disclosed["must_disclose"] == ["v:D30"]
|
||||
assert {"v:D30", "purpose_stability_not_evaluated"} <= set(disclosed["must_disclose"])
|
||||
|
||||
|
||||
def test_unconfirmed_birth_time_is_not_evaluated_not_assumed_stable():
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user