Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c5cf04440 | ||
|
|
cf4d28727e | ||
|
|
72179255c5 | ||
|
|
5183afcc2b | ||
|
|
1ba0364a7a | ||
|
|
23e5e6c02e | ||
|
|
4c7abd7187 |
@@ -25015,3 +25015,45 @@
|
||||
- 防复发:检查实际 deadline 对象、正文已发出和查表次数。回归 CLI 缺少来源选项及跳过来源时禁止写清单。
|
||||
- 关联记录:#205、BUG-1051、BUG-1053、BUG-1142、BUG-1847。
|
||||
- 修复版本:`codex/flaky-tests-20261112`。
|
||||
|
||||
## BUG-1852 | 个人报告解读把已算出的 Indu、Gulika 等写成「参考资料里没有对应条目」
|
||||
|
||||
- 状态:fixed-pending-verify(staging 待真机)。
|
||||
- 首次发现 / 最近更新:2026-11-12(产品负责人真机导出 #192 报告后复查)/ 2026-11-12。
|
||||
- 影响面:新生成的中文个人报告「解读」的「依据与边界」节;聊天证据卡共用 `consult_card_domain_facts.py` 的引用,Vighati、Indu、第 64 个 Navamsa、D5 四行的引用文字在聊天里也随之改变(只改文字,状态不变)。
|
||||
- 现象:解读写「Vighati、Indu Lagna、第 64 个 Navamsa、Gulika、Mandi、Pranapada 在参考资料里没有对应条目,故不参与」,而同一份报告的特殊上升与副行星表已列出这些点的数值。占星师 2026-11-12(8aaf6099 §6 P1)已点名「Indu 写 references 未找到」是错的。
|
||||
- 触发条件:所有带解读的个人报告。
|
||||
- 根因:`scripts/consult_card_domain_facts.py` 的静态引用写「references/ 未找到 X 条目」(一次局部检索的结论),facts v3(#201)把它映射成状态 `no_reference_entry` 并原样作为 source 交给模型;产品规则块又让模型按「references 没有本领域条目」写原因。实际情况是:这些点已经算出,只是占星师路由文件该领域的必查模块没有列它们。BUG-1851 的复查只查等级、无阻塞、尊贵度与禁用词,没有查「已算出却说没有来源 / 没有计算」,所以她列的这条反例没被拦住。
|
||||
- 修复:引用改为指出具体路由(如「strict-workflow-router.md §5 必查模块与 event_judgment_wealth.md §3 未列 Indu Lagna;本领域不据此判断」);状态 `no_reference_entry` 改名 `not_in_domain_route`;report-reading 规则块写明带 computed 的层要写「已算出,本报告不用它下结论」;复查新增 `false_missing_layer`:某一分句点名已算出的点(Indu、Vighati、Ghati、Gulika、Mandi、Pranapada、第 64 个 Navamsa、Badhaka)又说没有条目、没有来源或没有计算时,只把那一节换成说明。
|
||||
- 验证:`frontend/tests/report-reading-20261027.test.tsx` 新用例(报告原句被拦、如实写法通过、未算出的点说没算通过);`tests/test_reading_facts_v3_20261112.py` 检查 Indu 引用不再含「未找到」。
|
||||
- 防复发:同上两个测试;状态名不再暗示检索结论。
|
||||
- 关联记录:#192、#201、BUG-1851、BUG-1848;占星师 8aaf6099 §6 P1。
|
||||
- 修复版本:`claude/report-reading-grade-20261112`。
|
||||
|
||||
## BUG-1853 | 健康领域列了 Badhaka,但引擎从未计算,解读只能写「关键依据缺失」
|
||||
|
||||
- 状态:fixed-pending-verify(staging 待真机)。
|
||||
- 首次发现 / 最近更新:2026-11-12(产品负责人真机导出 #192 报告后复查)/ 2026-11-12。
|
||||
- 影响面:个人报告解读健康节的「阻碍」结论(health_obstruction 恒为 D);聊天健康领域证据卡的 Badhaka 一行恒为缺口。
|
||||
- 现象:报告健康节写「本次所需的 Badhaka 计算没有完成,属关键依据缺失」,全报告搜不到 Badhaka 数据。
|
||||
- 触发条件:所有星盘。
|
||||
- 根因:健康参与层读取 `worksheets.advanced_systems.badhaka` / `worksheets.d1_rasi_bhava.badhaka`,但没有任何模块写这两个路径;`yoga_engine.badhaka_house` 只在瑜伽规则里用,没有进工作表。BUG-1851 评测把「Badhaka 段为 D」当作正确行为记录,没有追问为什么缺。
|
||||
- 修复:新增产品模块 `scripts/report_render/badhaka_facts.py`,按 references/badhaka-obstacle-planet-guide.md §二(与占星师 8aaf6099 同一文件)从已算好的 D1 位置给出 Badhaka 宫、星座、宫主及其落点与尊贵度、宫内行星,只给位置不下结论,记录带 `product_computation_pending_astrologer_review`;`consult_card_domain_facts` 的健康 Badhaka 一行改读它(聊天健康证据卡同时受益);已在 references/product_runtime_contract.md G 节公告为待她审核的产品计算。第一版(staging 23e5e6c0)把函数写进了她的 `yoga_engine.py` 并在 `jyotish_engine.py` 挂钩,违反产品负责人 2026-11-07「她的 skill 照原样跑、产品差异放单独公告的产品文件」规则,后续提交已移出,两文件与 6f1b9ac3 无差异;报告事实把这条小记录随 executed 一起交给模型;等级合同的路由说明改为「health-timing-strict §7 + badhaka-obstacle-planet-guide.md §二」(她的路由 §7 本身没有列 Badhaka)。
|
||||
- 验证:`tests/test_badhaka_facts_20261112.py`(巨蟹、狮子、双子三类上升对照来源表);`tests/test_reading_facts_v3_20261112.py` 两张公开盘 Badhaka 为 executed、宫位在 7/9/11、带待审核状态、引擎工作表里没有 badhaka、health_obstruction 上限不再是 D。公开盘 A(处女上升)得第 7 宫双鱼、宫主木星;B(摩羯上升)得第 11 宫天蝎、宫主火星,与来源表一致。
|
||||
- 防复发:同上。
|
||||
- 关联记录:#192、BUG-1851、BUG-1852。
|
||||
- 修复版本:`claude/report-reading-grade-20261112`。
|
||||
|
||||
## BUG-1854 | 个人报告解读缺少三项逐节复查
|
||||
|
||||
- 状态:fixed-pending-verify(待独立验收)。
|
||||
- 首次发现 / 最近更新:2026-11-12 / 2026-11-12。
|
||||
- 影响面:新生成的中文个人报告「解读」。
|
||||
- 现象:历史回放可能出现当前建议,双行运结果可能被用于未经检测的领域,瑜伽形成状态可能与现实结果核验混写。
|
||||
- 触发条件:模型草稿包含上述说法并进入 `acceptReportReadingDraft`。
|
||||
- 根因:这三项限制只在写作提示中声明,`checkSection` 缺少与事实包对照的复查。
|
||||
- 修复:逐段检查历史回放的建议词、双行运已检测宫位和瑜伽形成状态。对应原因记录在 `ReadingRejection`,不通过的节沿用现有退回显示。
|
||||
- 验证:新测试和任务书指定的既有测试共 35 项通过,核对每项触发只退回对应节。全量结果见本单进度。
|
||||
- 防复发:合成段落覆盖书名和普通引语、第 7 宫与空宫位、候选与形成、同句与分句,以及其他节继续显示。
|
||||
- 关联记录:#207、#192、BUG-1851、BUG-1852。
|
||||
- 修复版本:`codex/reading-postcheck-gaps-20261112`。
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# 个人报告解读复查 · 2026-11-12
|
||||
|
||||
Gitea #207,BUG-1854。按 Claude 评论 42178 认领,基线 `1ba0364a7a8c0f964c3e21c21cb304aaa1899375`。任务书在分支首提交 `5183afcc2`。
|
||||
|
||||
## 实施
|
||||
|
||||
- `current_advice_in_replay` 只在 `current_advice_allowed === false` 时扫描「几条建议」「健康」「现在这几年」的每段文字。词表包括「你」「您」「建议」「应当」「应该」「应依」「最好」「不妨」「可以考虑」「宜」「不宜」「就医」「多休息」「留意」「注意」。用中文分词识别单字「宜」,避免把「宜昌」「适宜」判成建议。书名号内或由书名、篇名、技法等语境明示名称的引文,仅豁免「宜」「不宜」「留意」「注意」。普通引用的「宜早作」和书名后的「最好」仍会触发。
|
||||
- `double_transit_scope` 识别 `Double Transit`、「双星过境」「双重行运」「双行运」。事业 10,财富 2、11,感情 7,健康 1、6、8、12,性格 1。总评、现在这几年、依据与边界免检。其余节须有一个本节宫位出现在 `transits.double_transit.checked_houses`,所以空或缺失时不能在这些节引用双行运。「几条建议」没有分配宫位。
|
||||
- `yoga_status_mismatch` 用「。」「;」「!」「?」划句。同句点名已形成的瑜伽又写「未形成」「没有形成」「不成立」「未成立」「尚未成立」时退回。名字使用中文名或去掉 `Yoga` 后的英文主体。另一条规则识别同句内的「等现实」「要等现实事件」「需现实验证」「经现实核验才」与「成立」「形成」。结果核验与形成分句时可以并存。
|
||||
|
||||
`reading_facts.py::_yogas` 通过 `yoga_status_words.py::yoga_status` 写出的 `state` 有 `candidate`、`computed`、`formed_under_source`、`conditions_not_met`、`blocked`。形成状态为 `formed_under_source`,兼容任务书验收样例中的 `formed`。候选和已计算的状态均不当作已形成。
|
||||
|
||||
## 验证
|
||||
|
||||
- 新测试用合成段落验证节级退回原因,其余节均为 `ok`。覆盖明确引用名称、普通引语、地名、历史和在世标志、第 7 宫和空宫位、句界,以及候选瑜伽的谨慎说法。词表按机械规则检查,普通引用的历史指令仍会命中。
|
||||
- 任务书指定的四个测试文件共 35 项通过。沿用既有断言。
|
||||
- 将新增测试接到未修复的 staging 实现,6 项拦截回归失败,2 项允许场景通过。接回任务分支后 8 项均通过。
|
||||
- `tsc --noEmit -p .` 通过,ESLint 为 0 错误、62 警告。
|
||||
- 用仓库的 Node/tsx 全量文件清单和 4 个测试进程比对。staging 共 3,653 项,3,623 通过、30 失败、0 取消。任务分支共 3,661 项,3,633 通过、28 失败、0 取消。顶层 TAP 名称新增 8 项、缺失 0 项。两边有 27 个同名失败,另有 4 个数据库测试在其中一边的并行运行中失败。
|
||||
- 分别串行复跑涉及两边差异的 4 个数据库测试文件。两边各 7 项通过,含任务分支并行时失败的并发档案修正迁移,以及 staging 并行时失败的管理员恢复和两项计费测试。
|
||||
- `npm run build` 通过,`/` 为静态页面。首页引用的 39 个资源逐文件 gzip -9 后,JS 为 515,860 字节,CSS 为 90,886 字节,两项均与 staging 相同。
|
||||
- 隐私检查通过。
|
||||
@@ -0,0 +1,107 @@
|
||||
# TASK:报告解读复查补三项机械检查(2026-11-12)
|
||||
|
||||
- Gitea:#207
|
||||
- 分支:`codex/reading-postcheck-gaps-20261112`(基于 staging `1ba0364a7a8c0f964c3e21c21cb304aaa1899375`)
|
||||
- Bug 编号:BUG-1854。开工时核对 `docs/BUG_HISTORY.md` 末尾;若已被占用,顺延,并在 PROGRESS 写明。
|
||||
- 负责验收:Claude(jyotisha-de)
|
||||
|
||||
不得自行写“产品决定/裁定”;任务书没写的取舍一律选需拍板。
|
||||
|
||||
不得修改或删除既有断言来让测试通过;确需修改必须写原值/新值/原因,并在 PROGRESS 里逐条列出。
|
||||
|
||||
## 背景
|
||||
|
||||
个人报告的「解读」由模型写,写完后由 `frontend/src/lib/personal-report-reading.ts::acceptReportReadingDraft` 逐节复查。
|
||||
|
||||
- 复查不通过的那一节,页面上显示「这一节没有通过数据核对,暂不显示。」,其他节照常显示。
|
||||
- 每一节由 `checkSection` 检查,退回原因记在 `ReadingRejection` 类型里。
|
||||
- 模型的输入是事实包 `report-reading-facts-v3`,由 `scripts/report_render/reading_facts.py` 生成。
|
||||
|
||||
占星师 2026-11-12 审核了一份样稿(她的仓库 `8aaf6099`,`handoff/2026-11-12/preset_q3/README.md` 第六、七节),列出了一批必须覆盖的反例。其中三条目前只在提示词里要求,复查不拦。#192 的验收材料把这三条标成了「部分(只靠提示)」:
|
||||
|
||||
1. **已故人物不给当前建议。** 事实包里 `report_mode = "historical_replay"`、`current_advice_allowed = false` 时,正文不应写对当事人现在的建议。一份样稿在健康节末尾写了「若有实际问题应依现实就医评估」。
|
||||
2. **Double Transit 不推到别的领域。** `transits.double_transit.checked_houses` 只列了被检测的宫位,例如 `[7]`。样稿曾把第 7 宫的检测结果写进健康和整体应期。
|
||||
3. **「形成」和「未验证」不混用。** 样稿曾写「Yoga 成立条件要等现实事件核验」,把“没有经过现实验证”写成了“没有形成”。
|
||||
|
||||
## 要改的文件
|
||||
|
||||
- `frontend/src/lib/personal-report-reading.ts`:只改复查部分,即 `checkSection`、`ReadingRejection`,以及新加的辅助函数。
|
||||
- 新建 `frontend/tests/report-reading-postcheck-gaps-20261112.test.ts`
|
||||
- `docs/BUG_HISTORY.md`:只在末尾追加一条。
|
||||
- `docs/tasks/PROGRESS-reading-postcheck-gaps-20261112.md`
|
||||
|
||||
## 要做的
|
||||
|
||||
每一条新检查不通过时,只退那一节,原因写进 `ReadingRejection`。
|
||||
|
||||
### 1. `current_advice_in_replay`
|
||||
|
||||
只在事实包 `current_advice_allowed === false` 时启用。
|
||||
|
||||
- 「几条建议」「健康」「现在这几年」三节里,任何一段命中下面任一条,就退回这一节:
|
||||
- 第二人称「你」「您」;
|
||||
- 建议性措辞:「建议」「应当」「应该」「应依」「最好」「不妨」「可以考虑」「宜」「不宜」「就医」「多休息」「留意」「注意」。
|
||||
- 例外:「宜」「不宜」「注意」「留意」出现在引号内的书名、技法名里时不算。如果没法可靠识别这种情况,就在 PROGRESS 列出误伤的例子,选需拍板。
|
||||
- `current_advice_allowed` 为 `true` 或缺失时,这条检查不运行。
|
||||
|
||||
### 2. `double_transit_scope`
|
||||
|
||||
- 先列出各节对应的宫位:
|
||||
- 事业:10;
|
||||
- 财富:2、11;
|
||||
- 感情:7;
|
||||
- 健康:1、6、8、12;
|
||||
- 性格:1。
|
||||
- 某一节的段落提到「Double Transit」「双星过境」「双重行运」「双行运」中任何一个,而这一节的宫位和 `checked_houses` 没有交集,就退回这一节。
|
||||
- 总评、现在这几年、依据与边界三节不在上面的列表里,不做这项检查。
|
||||
- `checked_houses` 为空或缺失时,凡是提到双行运又不在这三节的段落,一律退回。
|
||||
|
||||
### 3. `yoga_status_mismatch`
|
||||
|
||||
事实包 `yogas[]` 每一行有 `name`、`name_cn` 和 `state`。`state` 取 `candidate`、`formed` 等值,具体有哪些自己核对,列进 PROGRESS。
|
||||
|
||||
满足以下任一条件,就退回那一节:
|
||||
|
||||
1. 段落里出现某一行的 `name_cn`,或者 `name` 去掉 `Yoga` 后的主体词,同一句里又出现「未形成」「没有形成」「不成立」「未成立」「尚未成立」,而这一行的 `state` 是形成类的状态。
|
||||
2. 段落里出现「等现实」「要等现实事件」「需现实验证」「经现实核验才」中任何一个,同一句里又出现「成立」或「形成」。
|
||||
|
||||
「句」以「。」「;」「!」「?」分割。
|
||||
|
||||
## 不要碰
|
||||
|
||||
- `frontend/src/lib/personal-report-reading.ts` 里的现有检查和 `writeReportReading`,只新增代码。
|
||||
- `references/**`,包括 `references/product_runtime_contract.md`:提示词不改。
|
||||
- `scripts/**`、冻结文件和其他前端文件。
|
||||
|
||||
## 验收标准(写进新测试)
|
||||
|
||||
1. 三条检查各有一个能触发的合成段落和一个不触发的合成段落。
|
||||
- 第 1 条还要测:同一段文字在 `current_advice_allowed: true` 时不触发。
|
||||
- 第 2 条还要测:`checked_houses: [7]` 时,感情节可以提到双行运,健康节提到就退回。
|
||||
- 第 3 条还要测:`state` 为 `formed` 的瑜伽被写成「不成立」时退回;`candidate` 的瑜伽写成「候选、尚未确认」时不退回。
|
||||
2. 每条检查只退回所在的那一节,其他节保持 `status: "ok"`。
|
||||
3. 现有的 `frontend/tests/report-reading-20261027.test.tsx`、`report-md-export-reading-20261111.test.ts`、`report-no-web-wording-20261109.test.ts` 全部通过。
|
||||
4. 测试里的段落全部用合成文字,不使用真实模型的原文。
|
||||
|
||||
## 自测命令(在 frontend 目录)
|
||||
|
||||
```
|
||||
npx tsx --test tests/report-reading-postcheck-gaps-20261112.test.ts tests/report-reading-20261027.test.tsx tests/report-md-export-reading-20261111.test.ts tests/report-no-web-wording-20261109.test.ts
|
||||
npx tsc --noEmit -p .
|
||||
npx eslint .
|
||||
```
|
||||
|
||||
## 进度记录
|
||||
|
||||
写在 `docs/tasks/PROGRESS-reading-postcheck-gaps-20261112.md`,内容包括:
|
||||
|
||||
- 每条检查的规则和词表;
|
||||
- `yogas[].state` 实际有哪些取值;
|
||||
- 误伤风险,以及你测过的边界例子;
|
||||
- 测试结果。
|
||||
|
||||
## 何时停下来选“需拍板”
|
||||
|
||||
- 第 1 条的词表误伤正常的历史回放写法,而且不放宽就无法避免。
|
||||
- `yogas[].state` 里分不清哪些是形成类的状态。
|
||||
- 需要改提示词、事实包或冻结文件才能完成。
|
||||
@@ -48,6 +48,21 @@ const DISCLAIMER = /仅供参考|不构成|请咨询专业|不能替代/g;
|
||||
/** 「没有关键阻塞」 and the like: allowed only when the claim's required layers are all available (her §6 P0). */
|
||||
const NO_BLOCKER = /(没有|无|不存在)(任何)?(关键)?(层)?(的)?阻塞/;
|
||||
const PLANETS_ZH = ["太阳", "月亮", "火星", "水星", "木星", "金星", "土星", "罗睺", "计都"] as const;
|
||||
/**
|
||||
* Points the engine computes that a draft must not call unsourced or uncomputed
|
||||
* (her §6 P1: Indu written as "references 未找到" although special_lagnas has it; BUG-1852).
|
||||
*/
|
||||
const POINT_ALIASES: Readonly<Record<string, readonly string[]>> = {
|
||||
Indu: ["Indu"],
|
||||
Vighati: ["Vighati"],
|
||||
Ghati: ["Ghati"],
|
||||
Gulika: ["Gulika"],
|
||||
Mandi: ["Mandi", "Maandi"],
|
||||
Pranapada: ["Pranapada"],
|
||||
navamsa64: ["第64个 Navamsa", "第 64 个 Navamsa", "第64个Navamsa", "64th Navamsa"],
|
||||
Badhaka: ["Badhaka", "阻碍星"],
|
||||
};
|
||||
const MISSING_CLAIM = /没有.{0,6}条目|没有.{0,4}来源|无来源|参考资料.{0,8}没有|资料里没有|未计算|没有计算|没有算|计算没有完成|未完成计算|没有完成/;
|
||||
/** Dignity words a draft may not invent (her §6 P1: D2 Exalted written as own sign). */
|
||||
const CHECKED_DIGNITIES = ["入旺", "入庙", "落陷", "根本三分"] as const;
|
||||
|
||||
@@ -68,6 +83,10 @@ export type ReadingRejection =
|
||||
| "grade_above_cap"
|
||||
| "false_no_blocker"
|
||||
| "dignity_mismatch"
|
||||
| "false_missing_layer"
|
||||
| "current_advice_in_replay"
|
||||
| "double_transit_scope"
|
||||
| "yoga_status_mismatch"
|
||||
| "all_sections_withheld";
|
||||
|
||||
type Claims = Readonly<Record<string, { cap?: unknown; sections?: unknown; required?: unknown }>>;
|
||||
@@ -114,6 +133,92 @@ function dignitiesOf(facts: Record<string, unknown> | null): Map<string, Set<str
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Point ids the facts mark as computed, in any domain. */
|
||||
function computedPointsOf(facts: Record<string, unknown> | null): Set<string> {
|
||||
const out = new Set<string>();
|
||||
const domains = (facts?.domains ?? {}) as Record<string, { participation?: unknown }>;
|
||||
for (const domain of Object.values(domains)) {
|
||||
if (!Array.isArray(domain?.participation)) continue;
|
||||
for (const row of domain.participation as Record<string, unknown>[]) {
|
||||
if (typeof row?.id === "string" && (row.state === "executed" || row.computed === true)) out.add(row.id);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** A clause that names a computed point and says it has no source or was not computed. */
|
||||
function falseMissingLayer(text: string, computed: Set<string>): boolean {
|
||||
for (const clause of text.split(/[,。;;,!?\n]/)) {
|
||||
if (!MISSING_CLAIM.test(clause)) continue;
|
||||
for (const [id, aliases] of Object.entries(POINT_ALIASES)) {
|
||||
if (computed.has(id) && aliases.some((alias) => clause.includes(alias))) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const REPLAY_ADVICE_SECTIONS = new Set(["advice", "health", "now"]);
|
||||
const REPLAY_ADVICE = /你|您|建议|应当|应该|应依|最好|不妨|可以考虑|不宜|就医|多休息|留意|注意/;
|
||||
const TITLE_ADVICE_WORDS = /不宜|宜|注意|留意/g;
|
||||
const QUOTED_NAME = /《[^《》\n]+》|〈[^〈〉\n]+〉|「[^「」\n]+」|『[^『』\n]+』|“[^“”\n]+”|‘[^‘’\n]+’|"[^"\n]+"/g;
|
||||
const NAME_INTRO = /(?:书名|篇名|著作|技法(?:名|名称)?)[:: \t]*$/;
|
||||
const NAME_SUFFIX = /^[ \t]*(?:一书|这本书|(?:这[一项门])?技法)/;
|
||||
const CHINESE_WORDS = new Intl.Segmenter("zh", { granularity: "word" });
|
||||
|
||||
function currentAdviceInReplay(text: string, section: string, facts: Record<string, unknown> | null): boolean {
|
||||
if (facts?.current_advice_allowed !== false || !REPLAY_ADVICE_SECTIONS.has(section)) return false;
|
||||
const prose = text.replace(QUOTED_NAME, (quote: string, start: number) => {
|
||||
const title = quote.startsWith("《") || quote.startsWith("〈") ||
|
||||
NAME_INTRO.test(text.slice(0, start)) || NAME_SUFFIX.test(text.slice(start + quote.length));
|
||||
return title ? quote.replace(TITLE_ADVICE_WORDS, " ") : quote;
|
||||
});
|
||||
if (REPLAY_ADVICE.test(prose)) return true;
|
||||
// Match the word 宜 without treating 宜昌 or 适宜 as advice.
|
||||
if (prose.includes("宜")) {
|
||||
for (const { segment } of CHINESE_WORDS.segment(prose)) {
|
||||
if (segment === "宜") return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const DOUBLE_TRANSIT = /\bDouble\s+Transit\b|双星过境|双重行运|双行运/i;
|
||||
const TRANSIT_SCOPE_EXEMPT = new Set(["overview", "now", "basis"]);
|
||||
const SECTION_HOUSES: Readonly<Record<string, readonly number[]>> = {
|
||||
career: [10], wealth: [2, 11], love: [7], health: [1, 6, 8, 12], character: [1],
|
||||
};
|
||||
|
||||
function doubleTransitOutOfScope(text: string, section: string, facts: Record<string, unknown> | null): boolean {
|
||||
if (TRANSIT_SCOPE_EXEMPT.has(section) || !DOUBLE_TRANSIT.test(text)) return false;
|
||||
const transits = facts?.transits as { double_transit?: { checked_houses?: unknown } } | undefined;
|
||||
const checked = transits?.double_transit?.checked_houses;
|
||||
return !Array.isArray(checked) || !SECTION_HOUSES[section]?.some((house) => checked.includes(house));
|
||||
}
|
||||
|
||||
const YOGA_FORMATION_NEGATED = /未形成|没有形成|不成立|未成立|尚未成立/;
|
||||
const REAL_WORLD_FORMATION_CONDITION = /等现实|要等现实事件|需现实验证|经现实核验才/;
|
||||
const YOGA_FORMATION = /成立|形成/;
|
||||
|
||||
function mentionsYoga(sentence: string, yoga: { name?: unknown; name_cn?: unknown }): boolean {
|
||||
const chinese = typeof yoga.name_cn === "string" ? yoga.name_cn.trim() : "";
|
||||
if (chinese && sentence.includes(chinese)) return true;
|
||||
if (typeof yoga.name !== "string") return false;
|
||||
const english = yoga.name.replace(/\bYoga\b/gi, " ").trim().replace(/\s+/g, " ");
|
||||
if (!english) return false;
|
||||
const escaped = english.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const name = new RegExp(`(?<![\\p{Script=Latin}\\p{N}])${escaped}(?![\\p{Script=Latin}\\p{N}])`, "iu");
|
||||
return name.test(sentence.replace(/\s+/g, " "));
|
||||
}
|
||||
|
||||
function yogaStatusMismatch(text: string, facts: Record<string, unknown> | null): boolean {
|
||||
const yogas = facts?.yogas;
|
||||
return text.split(/[。;!?]/).some((sentence) => {
|
||||
if (REAL_WORLD_FORMATION_CONDITION.test(sentence) && YOGA_FORMATION.test(sentence)) return true;
|
||||
return YOGA_FORMATION_NEGATED.test(sentence) && Array.isArray(yogas) && yogas.some((yoga) =>
|
||||
(yoga?.state === "formed_under_source" || yoga?.state === "formed") && mentionsYoga(sentence, yoga));
|
||||
});
|
||||
}
|
||||
|
||||
/** A planet name followed closely by a dignity word the facts never give that planet. */
|
||||
function dignityMismatch(text: string, dignities: Map<string, Set<string>>): boolean {
|
||||
if (dignities.size === 0) return false;
|
||||
@@ -127,9 +232,13 @@ function dignityMismatch(text: string, dignities: Map<string, Set<string>>): boo
|
||||
return index === -1 ? window.length : index;
|
||||
}));
|
||||
const clause = window.slice(0, nextPlanet).split(/[,。;;,]/)[0] ?? "";
|
||||
// The clause ran up to the next planet without punctuation: a word at its end describes that planet.
|
||||
const nextFollows = nextPlanet < window.length && clause.length === nextPlanet;
|
||||
for (const word of CHECKED_DIGNITIES) {
|
||||
// 「落陷取消」 (cancelled debilitation) in the facts allows 「落陷」 in the text.
|
||||
const known = [...(dignities.get(planet) ?? [])];
|
||||
// 「木星、落陷金星」 (DeepSeek eval 2026-11-12, public chart A): 「落陷」 belongs to 金星.
|
||||
if (nextFollows && clause.endsWith(word)) continue;
|
||||
if (clause.includes(word) && !known.some((given) => given.includes(word))) return true;
|
||||
}
|
||||
}
|
||||
@@ -151,6 +260,8 @@ function checkSection(
|
||||
title: string,
|
||||
claims: Claims,
|
||||
dignities: Map<string, Set<string>>,
|
||||
computed: Set<string>,
|
||||
facts: Record<string, unknown> | null,
|
||||
): { section: CheckedSection; chars: number } {
|
||||
const withheld = (reason: ReadingRejection) => ({
|
||||
section: { id: section.id, title, status: "withheld" as const, reason },
|
||||
@@ -168,6 +279,10 @@ function checkSection(
|
||||
if (/[_={}<>#*|`]/.test(text)) return withheld("field_name");
|
||||
if (BANNED_PHRASES.some((phrase) => text.includes(phrase)) || CERTAINTY.test(text)) return withheld("banned_phrase");
|
||||
if (dignityMismatch(text, dignities)) return withheld("dignity_mismatch");
|
||||
if (falseMissingLayer(text, computed)) return withheld("false_missing_layer");
|
||||
if (currentAdviceInReplay(text, section.id, facts)) return withheld("current_advice_in_replay");
|
||||
if (doubleTransitOutOfScope(text, section.id, facts)) return withheld("double_transit_scope");
|
||||
if (yogaStatusMismatch(text, facts)) return withheld("yoga_status_mismatch");
|
||||
disclaimers += text.match(DISCLAIMER)?.length ?? 0;
|
||||
chars += text.length;
|
||||
if (!graded) {
|
||||
@@ -213,7 +328,9 @@ export function acceptReportReadingDraft(value: unknown, facts: Record<string, u
|
||||
}
|
||||
const claims = claimsOf(facts);
|
||||
const dignities = dignitiesOf(facts);
|
||||
const checked = sections.map((section, index) => checkSection(section, REPORT_READING_SECTIONS[index]!.title, claims, dignities));
|
||||
const computed = computedPointsOf(facts);
|
||||
const checked = sections.map((section, index) =>
|
||||
checkSection(section, REPORT_READING_SECTIONS[index]!.title, claims, dignities, computed, facts));
|
||||
const withheld = checked.filter(({ section }) => section.status === "withheld").length;
|
||||
if (withheld === checked.length) return { ok: false, reason: "all_sections_withheld" };
|
||||
const total = checked.reduce((sum, { chars }) => sum + chars, 0);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -181,12 +181,40 @@ test("grades above the backend ceiling, false no-blocker claims and invented dig
|
||||
assert.ok(own.ok && own.reading.sections.some((section) => "status" in section && section.status === "withheld" && section.reason === "dignity_mismatch"));
|
||||
const exalted = acceptReportReadingDraft(draft({ wealth: [`${PARAGRAPH}D2 木星在巨蟹入旺。`, PARAGRAPH] }), dignityFacts, SKILL);
|
||||
assert.ok(exalted.ok && exalted.withheld === 0);
|
||||
// A dignity word written right before the next planet is that planet's (DeepSeek eval 2026-11-12, chart A).
|
||||
const listFacts = { ...FACTS, planets: { Jupiter: { d1_dignity_zh: "中性" }, Venus: { d1_dignity_zh: "落陷" } } };
|
||||
const listed = acceptReportReadingDraft(draft({ health: [`${PARAGRAPH}第十二宫聚集木星、落陷金星与土星。`, PARAGRAPH] }), listFacts, SKILL);
|
||||
assert.ok(listed.ok && listed.withheld === 0, JSON.stringify(listed.ok && listed.reading.sections.find((s) => "status" in s)));
|
||||
const wrongOwner = acceptReportReadingDraft(draft({ health: [`${PARAGRAPH}木星落陷,金星也在这里。`, PARAGRAPH] }), listFacts, SKILL);
|
||||
assert.ok(wrongOwner.ok && wrongOwner.withheld === 1);
|
||||
// A cancelled debilitation in the facts (「落陷取消」) allows writing 「落陷」 (DeepSeek eval 2026-11-12, public chart B).
|
||||
const cancelledFacts = { ...FACTS, planets: { Jupiter: { d1_dignity_zh: "落陷取消" } } };
|
||||
const cancelled = acceptReportReadingDraft(draft({ overview: [`${PARAGRAPH}木星在第一宫摩羯落陷但成立落陷取消。`, PARAGRAPH] }), cancelledFacts, SKILL);
|
||||
assert.ok(cancelled.ok && cancelled.withheld === 0);
|
||||
});
|
||||
|
||||
// BUG-1852: her 8aaf6099 §6 P1 — Indu written as "references 未找到" although the engine computed it.
|
||||
test("calling a computed point unsourced or uncomputed withholds that section only", () => {
|
||||
const computedFacts = {
|
||||
...FACTS,
|
||||
domains: {
|
||||
wealth: { participation: [{ id: "Indu", state: "not_in_domain_route", computed: true, value: "Gemini" }] },
|
||||
health: { participation: [{ id: "Badhaka", state: "executed", value: { house: 11, lord: "Venus" } },
|
||||
{ id: "Gulika", state: "not_in_domain_route" }] },
|
||||
},
|
||||
};
|
||||
const verdict = (basis: string) => {
|
||||
const accepted = acceptReportReadingDraft(draft({ basis: [`${PARAGRAPH}${basis}`, PARAGRAPH] }), computedFacts, SKILL);
|
||||
assert.ok(accepted.ok, JSON.stringify(accepted));
|
||||
return accepted.reading.sections.flatMap((section) => "status" in section && section.status === "withheld" ? [`${section.id}:${section.reason}`] : []);
|
||||
};
|
||||
assert.deepEqual(verdict("Vighati、Indu Lagna、Gulika 在参考资料里没有对应条目,故不参与。"), ["basis:false_missing_layer"]);
|
||||
assert.deepEqual(verdict("本次所需的 Badhaka 计算没有完成。"), ["basis:false_missing_layer"]);
|
||||
// Stating it accurately passes; so does saying an uncomputed point was not computed.
|
||||
assert.deepEqual(verdict("Indu Lagna 已算出,在双子,本报告不用它下结论。"), []);
|
||||
assert.deepEqual(verdict("Gulika 没有计算。"), []);
|
||||
});
|
||||
|
||||
// #192 原值:REPORT_READING_SYSTEM(TypeScript 里的产品提示,九节 + 节尾「置信度:A/B/C」+「全篇最高 B」)
|
||||
// 新值:她的 SKILL.md 与路由 references 原文,加 references/product_runtime_contract.md 的 report-reading 块
|
||||
// 原因:产品负责人 2026-11-11 决定 2(报告按她的 skill 写);占星师 2026-11-12 §5、§7.3
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
acceptReportReadingDraft,
|
||||
REPORT_READING_SECTIONS,
|
||||
type ReadingRejection,
|
||||
type ReadingSkillMeta,
|
||||
} from "../src/lib/personal-report-reading";
|
||||
import { EVIDENCE_GRADE_CONTRACT } from "../src/lib/personal-report-reading-contract";
|
||||
|
||||
const SKILL: ReadingSkillMeta = {
|
||||
name: "jyotish-vedic-astrology", version: "test",
|
||||
loaded: [{ path: "SKILL.md", sha256: "0".repeat(64) }],
|
||||
};
|
||||
const NEUTRAL = "这里仅复述一个虚构场景中的既有记录。叙述把记载的顺序和可核对的线索分开,也说明当时的材料有些空白。相关细节均用于这个例子的文本核对。".repeat(2);
|
||||
const CLAIMS = {
|
||||
character: "character_structure", career: "career_promise", wealth: "wealth_earning",
|
||||
love: "relationship_structure", health: "health_pressure", now: "timing_window",
|
||||
} as const;
|
||||
const GRADES = {
|
||||
contract: EVIDENCE_GRADE_CONTRACT,
|
||||
claims: Object.fromEntries(Object.entries(CLAIMS).map(([section, claim]) => [claim, { cap: "C", sections: [section] }])),
|
||||
};
|
||||
type Section = (typeof REPORT_READING_SECTIONS)[number]["id"];
|
||||
|
||||
function expectPostcheck(
|
||||
facts: Record<string, unknown>,
|
||||
examples: Partial<Record<Section, string>>,
|
||||
rejected?: readonly [Section, ReadingRejection],
|
||||
): void {
|
||||
const draft = {
|
||||
sections: REPORT_READING_SECTIONS.map(({ id }) => {
|
||||
const claim = id in CLAIMS ? CLAIMS[id as keyof typeof CLAIMS] : null;
|
||||
return {
|
||||
id,
|
||||
paragraphs: [NEUTRAL, examples[id] ?? NEUTRAL].map((text) => ({
|
||||
text, claim_type: claim, grade: claim ? "C" : null,
|
||||
})),
|
||||
};
|
||||
}),
|
||||
};
|
||||
const verdict = acceptReportReadingDraft(draft, { ...facts, evidence_grades: GRADES }, SKILL);
|
||||
assert.ok(verdict.ok && verdict.reading.version === 3, JSON.stringify(verdict));
|
||||
assert.equal(verdict.withheld, rejected ? 1 : 0);
|
||||
for (const section of verdict.reading.sections) {
|
||||
if (section.id === rejected?.[0]) {
|
||||
assert.equal(section.status, "withheld", section.id);
|
||||
assert.equal(section.reason, rejected[1], section.id);
|
||||
} else {
|
||||
assert.equal(section.status, "ok", section.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test("the three historical replay sections withhold direct address or current advice", () => {
|
||||
const replay = { report_mode: "historical_replay", current_advice_allowed: false };
|
||||
for (const section of ["advice", "health", "now"] as const) {
|
||||
expectPostcheck(replay, { [section]: "这里建议先放慢节奏。" }, [section, "current_advice_in_replay"]);
|
||||
}
|
||||
for (const phrase of ["你", "您", "建议", "应当", "应该", "应依", "最好", "不妨", "可以考虑", "宜", "不宜", "就医", "多休息", "留意", "注意"]) {
|
||||
expectPostcheck(replay, { health: `本节使用该措辞:${phrase}。` }, ["health", "current_advice_in_replay"]);
|
||||
}
|
||||
expectPostcheck(replay, { career: "这里以第二人称转述这段记录:你核对了这一点。" });
|
||||
});
|
||||
|
||||
test("the same text passes when current advice is allowed or the flag is absent", () => {
|
||||
const example = { health: "这里建议先放慢节奏。" };
|
||||
expectPostcheck({ current_advice_allowed: true }, example);
|
||||
expectPostcheck({}, example);
|
||||
expectPostcheck({ current_advice_allowed: false }, { health: "当年途经宜昌,留下的文字只有一条纪事。" });
|
||||
});
|
||||
|
||||
test("title quoting exempts only the four title words and ordinary quotes still count", () => {
|
||||
const replay = { current_advice_allowed: false };
|
||||
expectPostcheck(replay, { health: "这里引用《宜忌》与〈注意〉,并抄录技法「不宜」和“留意”这项技法的名称。" });
|
||||
expectPostcheck(replay, { health: "记录按「注意」技法归类。" });
|
||||
expectPostcheck(replay, { health: "记录曾出现「宜早作」这句话。" }, ["health", "current_advice_in_replay"]);
|
||||
expectPostcheck(replay, { health: "历史笔记提到《建议录》。" }, ["health", "current_advice_in_replay"]);
|
||||
expectPostcheck(replay, { health: "文中引用《宜忌》。另外,最好先核对。" }, ["health", "current_advice_in_replay"]);
|
||||
});
|
||||
|
||||
test("a checked seventh house covers relationships and withholds Double Transit in health", () => {
|
||||
const facts = { transits: { double_transit: { checked_houses: [7] } } };
|
||||
expectPostcheck(facts, { love: "双行运仅讨论第七宫。", health: "健康这一段引用 Double Transit。" }, ["health", "double_transit_scope"]);
|
||||
});
|
||||
|
||||
test("Double Transit accepts an intersecting house for each mapped section", () => {
|
||||
for (const [section, house] of [["career", 10], ["wealth", 2], ["wealth", 11], ["character", 1], ["health", 1], ["health", 6], ["health", 8], ["health", 12]] as const) {
|
||||
expectPostcheck({ transits: { double_transit: { checked_houses: [house, 7] } } }, { [section]: "这里核对双星过境。" });
|
||||
}
|
||||
});
|
||||
|
||||
test("missing and empty checked houses withhold other sections and preserve the three exemptions", () => {
|
||||
const phrase = "这里提到双重行运。";
|
||||
for (const facts of [{}, { transits: { double_transit: { checked_houses: [] } } }]) {
|
||||
expectPostcheck(facts, { overview: phrase, now: phrase, basis: phrase, career: phrase }, ["career", "double_transit_scope"]);
|
||||
expectPostcheck(facts, { advice: phrase }, ["advice", "double_transit_scope"]);
|
||||
}
|
||||
});
|
||||
|
||||
test("a formed Yoga cannot be negated in the sentence that names it", () => {
|
||||
const row = { name: "Dhana Yoga", name_cn: "财富瑜伽" };
|
||||
for (const state of ["formed", "formed_under_source"]) {
|
||||
const facts = { yogas: [{ ...row, state }] };
|
||||
expectPostcheck(facts, { wealth: "财富瑜伽不成立。" }, ["wealth", "yoga_status_mismatch"]);
|
||||
expectPostcheck(facts, { wealth: "这里的 dhana 尚未成立。" }, ["wealth", "yoga_status_mismatch"]);
|
||||
expectPostcheck(facts, { wealth: "财富瑜伽成立。另一项组合未形成。" });
|
||||
expectPostcheck(facts, { wealth: "另一项称为 MahaDhana 的组合未形成。" });
|
||||
}
|
||||
expectPostcheck({ yogas: [{ ...row, state: "candidate" }] }, { wealth: "财富瑜伽是候选、尚未确认。" });
|
||||
});
|
||||
|
||||
test("reality checks can qualify outcomes but cannot be required for Yoga formation in the same sentence", () => {
|
||||
for (const condition of ["等现实", "要等现实事件", "需现实验证", "经现实核验才"]) {
|
||||
expectPostcheck({}, { basis: `瑜伽是否成立,${condition}核对。` }, ["basis", "yoga_status_mismatch"]);
|
||||
}
|
||||
for (const punctuation of ["。", ";", "!", "?"]) {
|
||||
expectPostcheck({}, { basis: `瑜伽按这组条件形成${punctuation}实际结果需现实验证。` });
|
||||
}
|
||||
});
|
||||
@@ -253,6 +253,8 @@ evidence_card.backstage records, for the backend only, that global web evidence
|
||||
|
||||
依据:占星师 2026-11-12 审核回复(她的仓库 `8aaf6099`,`handoff/2026-11-12/preset_q3/README.md` 第一、五、六、七节)。报告「解读」先绑定她的 SKILL.md 全文与相关 references(见 `frontend/src/mastra/report-reading-skill.ts`,实际加载清单与哈希存进每份解读),再附本块。本块是产品对报告体裁的规定,不是她的方法;与她历史文件里的分级说法冲突时,按她 11-12 交接合同 `report_evidence_grade_v1` 执行(她 §7.3)。原值:`frontend/src/lib/personal-report-reading.ts` 的 `REPORT_READING_SYSTEM`(2026-11-07 方案,九节 + 节尾 A/B/C + 「没有用户经历所以最高 B」)。
|
||||
|
||||
**产品计算,待占星师审核(BUG-1853,2026-11-12):Badhaka。** 她的引擎(`8aaf6099`)没有本命 Badhaka 模块,健康领域清单却列了它。产品在 `scripts/report_render/badhaka_facts.py` 里按 `references/badhaka-obstacle-planet-guide.md` §二(与她仓库同名文件逐字相同)从已算好的 D1 位置给出 Badhaka 宫、星座、宫主及其落点、宫内行星,只给位置、不下结论,记录里带 `status: product_computation_pending_astrologer_review`。它不改她的 `jyotish_engine.py`、`yoga_engine.py`(只调用后者的 `badhaka_house`)。报告解读和聊天健康证据卡都读这条记录。她的路由 §7 本身没有列 Badhaka;是否保留为健康必查项、用哪条规则,等她审核。
|
||||
|
||||
<!-- product-block:report-reading -->
|
||||
<!-- 产品规则,不是占星师的方法:R-01 输入边界。 -->
|
||||
你在给一份个人星盘报告写开头的「解读」。用户消息里的盘面事实(report-reading-facts-v3)是引擎已经算好的全部材料,只用这些,不编数据,不另起算法,不凭印象重算尊贵度、宫位或日期。事实里没有的层就当没有。
|
||||
@@ -266,7 +268,7 @@ evidence_card.backstage records, for the backend only, that global web evidence
|
||||
- 健康:只写有依据的传统条件和要多留意的时段,不从 6、8、12 宫直接推出免疫、睡眠这类具体身体事实,不写病名。D30 能不能用看 birth_precision 和 evidence_grades,不只看 minute_confirmed。
|
||||
- 现在这几年:写明实际覆盖哪几年。行运只是 observation_date 那一天的位置,不外推成几个月或几年的结论;时间粒度由证据决定。
|
||||
- 几条建议:两到四条,每条只能落在前面已经有依据的主题上。只是一般性的建议,就写明「一般建议」,不装成星盘算出来的结论;不从数值门槛推出具体作息时刻、贷款或资产安排。
|
||||
- 依据与边界:功能吉星、功能凶星及与自然吉凶的冲突;实际用到的技法;没有使用的层及原因(按 participation 的 state 写:未路由到本领域、references 没有本领域条目、没有计算);参数敏感的层;出生时间精度与 birth_precision 里接近边界的分盘;岁差、交点、宫制。
|
||||
- 依据与边界:功能吉星、功能凶星及与自然吉凶的冲突;实际用到的技法;没有使用的层及原因(按 participation 的 state 和 reason_code 写:not_routed 是路由把它分给了别的领域;not_in_domain_route 是占星师这一领域的必查模块没有列它,带 computed 的已经算出数值,要写「已算出,本报告不用它下结论」,不能说参考资料里没有、没有来源或没有计算;not_computed 才是没有计算);参数敏感的层;出生时间精度与 birth_precision 里接近边界的分盘;岁差、交点、宫制。
|
||||
<!-- 产品规则,不是占星师的方法:R-04 证据等级。她 §1.3–1.4、§5.2,合同 report_evidence_grade_v1。 -->
|
||||
证据等级按每条结论标,不按节标。事实里的 evidence_grades.claims 给出每一类结论(claim type)的等级上限(cap)、必需依据、需要说明的缺口(must_disclose)和参数敏感的层。性格、事业、财富、感情、健康、现在这几年六节的每一段都要选一个 claim type,并给一个不高于它 cap 的等级(A 最高,D 最低);总评、几条建议、依据与边界的段落 claim type 和 grade 都填 null。等级含义:C 是有星盘来源和可计算的依据、还没有经过案例校准;D 是这条结论需要的关键依据缺失或无法判别。D 的段落只写缺了什么、暂不能判断,不写结果。不要在正文里写「置信度:」或「证据等级:」,等级由页面显示。must_disclose 里的缺口和参数敏感的层要在相关段落里说出来。只有某类结论的必需依据全部可用时,才能说它「没有关键阻塞」。
|
||||
<!-- 产品规则,不是占星师的方法:R-05 不把不同体系的不同当冲突。她 §5.1、§6 P1。 -->
|
||||
|
||||
@@ -172,6 +172,25 @@ def _planet_base(view: dict, name: str) -> str | None:
|
||||
return 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.
|
||||
"""
|
||||
from report_render.badhaka_facts import badhaka_facts
|
||||
|
||||
asc = dig(view, "core_chart.houses.house_1.cusp_sign") or dig(view, "worksheets.d1_rasi_bhava.houses.house_1.cusp_sign")
|
||||
planets = {}
|
||||
for name in PLANETS:
|
||||
base = _planet_base(view, name)
|
||||
if base:
|
||||
planets[name] = dig(view, base)
|
||||
record = badhaka_facts(asc, planets)
|
||||
if record is None:
|
||||
return _gap("core_chart.houses.house_1.cusp_sign")
|
||||
return {"status": "value", "path": "product:report_render.badhaka_facts", "value": record, "check": "product_computation"}
|
||||
|
||||
|
||||
def _functional_role(view: dict, name: str) -> dict[str, Any]:
|
||||
base = "worksheets.strengths_and_scores.functional_benefic_malefic"
|
||||
if name in ("Rahu", "Ketu"):
|
||||
@@ -486,7 +505,7 @@ def domain_source_catalog() -> dict[str, list[dict[str, str]]]:
|
||||
("AK", "sourced", f"{CAREER} §2 Jaimini AmK / AK / Karakamsha"),
|
||||
("Karakamsha", "sourced", f"{CAREER} §2 Karakamsha"),
|
||||
("Ghati", "sourced", f"{DEEP} Ghati Lagna 权力指标"),
|
||||
("Vighati", "blocked", "references/ 未找到 Vighati 条目"),
|
||||
("Vighati", "blocked", f"{ROUTER} §3 必查模块未列 Vighati Lagna;本领域不据此判断"),
|
||||
("natural:Sun", "sourced", f"{CAREER} §2 Sun"),
|
||||
("natural:Saturn", "sourced", f"{CAREER} §2 Saturn"),
|
||||
("natural:Mercury", "sourced", f"{CAREER} §2 Mercury"),
|
||||
@@ -502,7 +521,7 @@ def domain_source_catalog() -> dict[str, list[dict[str, str]]]:
|
||||
("A11", "sourced", f"{WEALTH} §3 A2 / A11 / A10"),
|
||||
("A10", "sourced", f"{WEALTH} §3 A2 / A11 / A10"),
|
||||
("Hora", "sourced", f"{DEEP} Hora Lagna 财富指标"),
|
||||
("Indu", "blocked", "references/ 未找到 Indu Lagna 财富条目"),
|
||||
("Indu", "blocked", f"{ROUTER} §5 必查模块与 {WEALTH} §3 未列 Indu Lagna;本领域不据此判断"),
|
||||
("Sree", "sourced", "references/promise-assessment-templates.md Hora Lagna + Sree Lagna"),
|
||||
("AL2", "blocked", f"{WEALTH} §3 未列出从 AL 起第 2 宫"),
|
||||
("AL11", "blocked", f"{WEALTH} §3 未列出从 AL 起第 11 宫"),
|
||||
@@ -532,7 +551,7 @@ def domain_source_catalog() -> dict[str, list[dict[str, str]]]:
|
||||
("D8", "sourced", f"{ROUTER} §7 D8"),
|
||||
("D30", "sourced", f"{ROUTER} §7 D30"),
|
||||
("drekkana22", "sourced", f"{SHODASA} 第22Drekkana与寿限"),
|
||||
("navamsa64", "blocked", "references/ 未找到第 64 个 Navamsa 条目"),
|
||||
("navamsa64", "blocked", f"{ROUTER} §7 必查模块未列第 64 个 Navamsa;本领域不据此判断"),
|
||||
("Badhaka", "sourced", BADHAKA),
|
||||
("Gulika", "blocked", "references/prashna-complete-guide.md 只在问事章写 Gulika,未列入本命健康参与层"),
|
||||
("Mandi", "blocked", "references/prashna-complete-guide.md 只在问事章写 Mandi,未列入本命健康参与层"),
|
||||
@@ -563,7 +582,7 @@ def domain_source_catalog() -> dict[str, list[dict[str, str]]]:
|
||||
],
|
||||
"education": [
|
||||
("D24", "sourced", f"{ROUTER} §2 D24 for education"),
|
||||
("D5", "blocked", "references/ 未找到把 D5 标成学业分盘的段落"),
|
||||
("D5", "blocked", f"{ROUTER} §2 未把 D5 列为学业分盘;本领域不据此判断"),
|
||||
("natural:Mercury", "sourced", f"{MAPPING} 教育 水星"),
|
||||
("natural:Jupiter", "sourced", f"{MAPPING} 教育 木星"),
|
||||
("house:4", "sourced", f"{MAPPING} 教育(基础教育)4宫"),
|
||||
@@ -680,7 +699,7 @@ def _domain_participation(view: dict, domain: str, minute_ok: bool) -> list[dict
|
||||
_sourced("AK", f"{CAREER} §2 Jaimini AmK / AK / Karakamsha", _karaka(view, "7", "Atmakaraka")),
|
||||
_sourced("Karakamsha", f"{CAREER} §2 Karakamsha", _leaf(view, "worksheets.advanced_systems.jaimini.karakamsha")),
|
||||
_sourced("Ghati", f"{DEEP} Ghati Lagna 权力指标", _point(view, [f"{lagna}.Ghati_Lagna.sign"], precision=True, minute_ok=minute_ok)),
|
||||
_blocked("Vighati", "references/ 未找到 Vighati 条目"),
|
||||
_blocked("Vighati", f"{ROUTER} §3 必查模块未列 Vighati Lagna;本领域不据此判断"),
|
||||
_sourced("D1_D9_D10", f"{ROUTER} §2 D10 for career", _leaf(view, "worksheets.advanced_systems.inter_chart_linkage")),
|
||||
]
|
||||
if domain == "wealth":
|
||||
@@ -695,7 +714,7 @@ def _domain_participation(view: dict, domain: str, minute_ok: bool) -> list[dict
|
||||
f"{ARUDHA}.A10.sign",
|
||||
])),
|
||||
_sourced("Hora", f"{DEEP} Hora Lagna 财富指标", _leaf(view, f"{lagna}.Hora_Lagna.sign")),
|
||||
_blocked("Indu", "references/ 未找到 Indu Lagna 财富条目"),
|
||||
_blocked("Indu", f"{ROUTER} §5 必查模块与 {WEALTH} §3 未列 Indu Lagna;本领域不据此判断"),
|
||||
_sourced("Sree", "references/promise-assessment-templates.md Hora Lagna + Sree Lagna", _first(view, [
|
||||
f"{lagna}.Sree_Lagna.sign",
|
||||
f"{lagna}.Sri_Lagna.sign",
|
||||
@@ -725,11 +744,8 @@ def _domain_participation(view: dict, domain: str, minute_ok: bool) -> list[dict
|
||||
"worksheets.divisional_and_special_charts.sensitive_points.drekkana_22",
|
||||
"worksheets.divisional_and_special_charts.varga_full.D3_Drekkana",
|
||||
])),
|
||||
_blocked("navamsa64", "references/ 未找到第 64 个 Navamsa 条目"),
|
||||
_sourced("Badhaka", BADHAKA, _first(view, [
|
||||
"worksheets.advanced_systems.badhaka",
|
||||
"worksheets.d1_rasi_bhava.badhaka",
|
||||
])),
|
||||
_blocked("navamsa64", f"{ROUTER} §7 必查模块未列第 64 个 Navamsa;本领域不据此判断"),
|
||||
_sourced("Badhaka", BADHAKA, _badhaka(view)),
|
||||
_blocked("Gulika", "references/prashna-complete-guide.md 只在问事章写 Gulika,未列入本命健康参与层"),
|
||||
_blocked("Mandi", "references/prashna-complete-guide.md 只在问事章写 Mandi,未列入本命健康参与层"),
|
||||
_blocked("Pranapada", "references/prashna-complete-guide.md 的 Pranapada 是问事替代计算,未列入本命健康参与层"),
|
||||
@@ -748,7 +764,7 @@ def _domain_participation(view: dict, domain: str, minute_ok: bool) -> list[dict
|
||||
if domain == "education":
|
||||
return [
|
||||
_varga_item(view, "D24", f"{ROUTER} §2 D24 for education", "D24", minute_ok),
|
||||
_blocked("D5", "references/ 未找到把 D5 标成学业分盘的段落"),
|
||||
_blocked("D5", f"{ROUTER} §2 未把 D5 列为学业分盘;本领域不据此判断"),
|
||||
]
|
||||
if domain == "migration":
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
"""Badhaka raw facts for D1. PRODUCT computation, pending astrologer review (BUG-1853).
|
||||
|
||||
Her engine (yinduzhanxing 8aaf6099) has no natal Badhaka module, so this lives
|
||||
in a product file, announced in references/product_runtime_contract.md. It only
|
||||
reads positions the engine already computed and the Badhaka house rule from
|
||||
``yoga_engine.badhaka_house``; it follows references/badhaka-obstacle-planet-guide.md §二
|
||||
(identical to her copy) and gives positions, no interpretation.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from yoga_engine import badhaka_house
|
||||
|
||||
SOURCE = "references/badhaka-obstacle-planet-guide.md §二"
|
||||
STATUS = "product_computation_pending_astrologer_review"
|
||||
SIGNS = ("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio",
|
||||
"Sagittarius", "Capricorn", "Aquarius", "Pisces")
|
||||
LORDS = ("Mars", "Venus", "Mercury", "Moon", "Sun", "Mercury", "Venus", "Mars",
|
||||
"Jupiter", "Saturn", "Saturn", "Jupiter")
|
||||
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.
|
||||
|
||||
``planets`` maps a planet name to its D1 record (``sign``, ``house``, optional ``dignity``).
|
||||
Returns None when the ascendant sign is unknown.
|
||||
"""
|
||||
if asc_sign not in SIGNS:
|
||||
return None
|
||||
house = badhaka_house(asc_sign)
|
||||
if house is None:
|
||||
return None
|
||||
sign = SIGNS[(SIGNS.index(asc_sign) + house - 1) % 12]
|
||||
lord = LORDS[SIGNS.index(sign)]
|
||||
lord_data = planets.get(lord) if isinstance(planets.get(lord), dict) else {}
|
||||
occupants = sorted(name for name, row in planets.items() if isinstance(row, dict) and row.get("sign") == sign)
|
||||
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,
|
||||
"source": SOURCE,
|
||||
"status": STATUS,
|
||||
}
|
||||
@@ -89,7 +89,7 @@ CLAIM_TYPES: dict[str, dict[str, Any]] = {
|
||||
("p", "health", "drekkana22"), ("s", "shadbala")],
|
||||
},
|
||||
"health_obstruction": {
|
||||
"route": "health-timing-strict §7 (Badhaka)",
|
||||
"route": "health-timing-strict §7 + badhaka-obstacle-planet-guide.md §二",
|
||||
"sections": ("health",),
|
||||
"required": [("v", "D1"), ("p", "health", "Badhaka")],
|
||||
"checked": [],
|
||||
|
||||
@@ -96,24 +96,27 @@ NOTE_LIMIT = 280
|
||||
# Statuses that keep a technique out of the judgment (interpretation_status_contract.md).
|
||||
BLOCKED_STATES = {"blocked", "gap", "error", "missing"}
|
||||
CONDITIONAL_STATES = {"parameter_sensitive", "partial", "partial_verified", "conflict", "conditional"}
|
||||
UNUSED_REASONS = {"not_routed", "no_reference_entry"}
|
||||
UNUSED_REASONS = {"not_routed", "not_in_domain_route"}
|
||||
PARTICIPATION_REASON_CODES = {
|
||||
("career", "Vighati"): "no_reference_entry",
|
||||
("wealth", "Indu"): "no_reference_entry",
|
||||
("wealth", "AL2"): "no_reference_entry",
|
||||
("wealth", "AL11"): "no_reference_entry",
|
||||
("marriage", "UL2"): "no_reference_entry",
|
||||
("health", "navamsa64"): "no_reference_entry",
|
||||
("health", "Gulika"): "no_reference_entry",
|
||||
("health", "Mandi"): "no_reference_entry",
|
||||
("health", "Pranapada"): "no_reference_entry",
|
||||
("education", "D5"): "no_reference_entry",
|
||||
("career", "Vighati"): "not_in_domain_route",
|
||||
("wealth", "Indu"): "not_in_domain_route",
|
||||
("wealth", "AL2"): "not_in_domain_route",
|
||||
("wealth", "AL11"): "not_in_domain_route",
|
||||
("marriage", "UL2"): "not_in_domain_route",
|
||||
("health", "navamsa64"): "not_in_domain_route",
|
||||
("health", "Gulika"): "not_in_domain_route",
|
||||
("health", "Mandi"): "not_in_domain_route",
|
||||
("health", "Pranapada"): "not_in_domain_route",
|
||||
("education", "D5"): "not_in_domain_route",
|
||||
("migration", "D12"): "not_routed",
|
||||
("family", "D4"): "not_routed",
|
||||
("family", "D7"): "not_routed",
|
||||
("general", "D10"): "not_routed",
|
||||
("general", "D2"): "not_routed",
|
||||
}
|
||||
STRUCTURED_VALUES = {
|
||||
"Badhaka": ("ascendant_modality", "house", "sign", "lord", "lord_sign", "lord_house", "lord_dignity", "occupants", "status"),
|
||||
}
|
||||
UNUSED_POINT_PATHS = {
|
||||
"Indu": f"{LAGNAS}.Indu_Lagna.sign",
|
||||
"Vighati": f"{LAGNAS}.ViGhati_Lagna.sign",
|
||||
@@ -427,6 +430,9 @@ def _participation(rows: list[dict[str, Any]], domain: str, view: dict, minute_c
|
||||
value = item.get("value")
|
||||
if state == "executed" and isinstance(value, (str, int, float, bool)):
|
||||
row["value"] = value
|
||||
elif state == "executed" and item_id in STRUCTURED_VALUES and isinstance(value, dict):
|
||||
# BUG-1853: Badhaka is a small record; the reading needs its positions, not just "executed".
|
||||
row["value"] = {key: value[key] for key in STRUCTURED_VALUES[item_id] if value.get(key) not in (None, "", [])}
|
||||
if state in UNUSED_REASONS and (value := _unused_value(view, item_id, minute_confirmed)) is not None:
|
||||
row.update(computed=True, value=value)
|
||||
if state == "withheld":
|
||||
@@ -741,7 +747,7 @@ def _blocked_states(
|
||||
domains: dict, shared: list[dict], families: list[dict], evidence: dict, transits: dict, annual: dict,
|
||||
) -> dict[str, Any]:
|
||||
labels: dict[str, list[str]] = {
|
||||
"blocked": [], "not_routed": [], "no_reference_entry": [],
|
||||
"blocked": [], "not_routed": [], "not_in_domain_route": [],
|
||||
"parameter_sensitive": [], "not_applicable": [], "withheld": [],
|
||||
}
|
||||
for name, row in domains.items():
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"""BUG-1853: Badhaka raw facts (product computation) follow the source table per ascendant modality."""
|
||||
|
||||
from scripts.report_render.badhaka_facts import STATUS, badhaka_facts
|
||||
|
||||
|
||||
def test_source_table_for_cancer_leo_gemini():
|
||||
# references/badhaka-obstacle-planet-guide.md §二: Cancer → Taurus/Venus, Leo → Aries/Mars, Gemini → Sagittarius/Jupiter.
|
||||
for asc, house, sign, lord in (("Cancer", 11, "Taurus", "Venus"), ("Leo", 9, "Aries", "Mars"),
|
||||
("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"]
|
||||
assert record["status"] == STATUS
|
||||
|
||||
|
||||
def test_unknown_ascendant_gives_nothing():
|
||||
assert badhaka_facts("Unknown", {}) is None
|
||||
assert badhaka_facts(None, {}) is None
|
||||
@@ -50,7 +50,7 @@ def test_static_blocked_citations_have_reason_codes():
|
||||
})
|
||||
assert citations.keys() == rf.PARTICIPATION_REASON_CODES.keys()
|
||||
assert set(rf.PARTICIPATION_REASON_CODES.values()) <= {
|
||||
"not_routed", "no_reference_entry", "missing_input", "not_computed", "calculation_failed",
|
||||
"not_routed", "not_in_domain_route", "missing_input", "not_computed", "calculation_failed",
|
||||
}
|
||||
|
||||
|
||||
@@ -68,13 +68,24 @@ def test_public_report_v3_facts(public_report):
|
||||
blocked = facts["blocked_states"]
|
||||
assert "general:D10" in blocked["not_routed"]
|
||||
health_points = {f"health:{point}" for point in ("Gulika", "Mandi", "Pranapada")}
|
||||
assert health_points <= set(blocked["no_reference_entry"])
|
||||
assert health_points <= set(blocked["not_in_domain_route"])
|
||||
assert not (health_points | {"general:D10"}) & set(blocked["blocked"])
|
||||
wealth = facts["domains"]["wealth"]
|
||||
indu = next(row for row in wealth["participation"] if row["id"] == "Indu")
|
||||
assert indu["reason_code"] == indu["state"] == "no_reference_entry"
|
||||
assert indu["reason_code"] == indu["state"] == "not_in_domain_route"
|
||||
assert indu["computed"] is True
|
||||
assert indu["value"] == dig(packet, f"{rf.LAGNAS}.Indu_Lagna.sign")
|
||||
# BUG-1852: the citation names the route that leaves Indu out, not a failed search of references/.
|
||||
assert "未找到" not in indu["source"] and "Indu Lagna" in indu["source"]
|
||||
# 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"]
|
||||
# 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
|
||||
assert facts["evidence_grades"]["claims"]["health_obstruction"]["cap"] != "D"
|
||||
|
||||
general = facts["domains"]["general"]
|
||||
assert general["varga_charts"]["D10"]["routed_for_domain"] is False
|
||||
|
||||
@@ -23,7 +23,7 @@ def _facts(**overrides):
|
||||
"health": {"participation": [{"id": "D6", "state": "executed"}, {"id": "D8", "state": "executed"},
|
||||
{"id": "D30", "state": "executed"}, {"id": "drekkana22", "state": "executed"},
|
||||
{"id": "Badhaka", "state": "blocked", "reason_code": "not_computed"},
|
||||
{"id": "Gulika", "state": "no_reference_entry"}]},
|
||||
{"id": "Gulika", "state": "not_in_domain_route"}]},
|
||||
},
|
||||
"birth_precision": {"ascendant_margins": {code: {"before_minutes": 30.0, "after_minutes": 30.0}
|
||||
for code in ("D1", "D2", "D6", "D8", "D9", "D10", "D30")}},
|
||||
|
||||
Reference in New Issue
Block a user