Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f29e1d601 | ||
|
|
a6611180e8 | ||
|
|
9131288630 | ||
|
|
405876ad2e | ||
|
|
3371a5da34 | ||
|
|
6a08164194 | ||
|
|
399d5495df | ||
|
|
c78f5c7cfe | ||
|
|
436385703a |
+13
@@ -4,9 +4,14 @@
|
||||
|
||||
- Windows Docker Linux 引擎返回 500,容器数据库实测待补。已用同机 staging 测试对照、现有 RPC 契约和合成档案验证替代。预检已核对远端和外部适配器,碎片扫描与定向套件在本机超时。见 [#276 进度](docs/tasks/PROGRESS-synastry-precision-20261114.md)。
|
||||
|
||||
## #275 合盘第 1 批验收环境
|
||||
|
||||
- Windows Docker Linux 引擎不可用,前端全量用同机无 Docker 基线对照。Windows 的缓存文件权限位断言在基线同样失败。碎片扫描和定向预检超时。详见 [#275 进度](docs/tasks/PROGRESS-synastry-b1-20261114.md)。
|
||||
|
||||
## #271 年运证据等级验收
|
||||
|
||||
- Windows Docker Linux 引擎不可用。开工预检的碎片扫描和定向套件超时。以同机 staging 对照、公开盘真实计算和桩写手回归提供替代证据。真实模型样例由独立验收方生成。见 [#271 进度](docs/tasks/PROGRESS-annual-grade-20261114.md)。
|
||||
- 更新基线后,Docker Linux 引擎仍返回 500。无 Docker 的数据库套件失败清单与新基线逐项一致,真实 PostgreSQL 实测留待复验。
|
||||
|
||||
## #264 年运 KP 验收环境
|
||||
|
||||
@@ -843,3 +848,11 @@
|
||||
- ~~现行采纳函数和历史表约束拒绝非零秒,采纳函数也不接受 v2 provenance。需明确迁移归属,并确认短区间的保护距离。~~
|
||||
- ~~已复现短区间返回段外整分钟。Docker Desktop 返回 HTTP 500,当前证据为迁移原文和引擎复现。见 [执行进度](docs/tasks/PROGRESS-chart-choice-rounds-engine-20261113.md)。~~
|
||||
- 已解除。按修订任务书完成秒级采纳并用隔离 PostgreSQL 读回。Docker Desktop 的完整数据库套件仍受 HTTP 500 影响,见进度。
|
||||
|
||||
## #279 · 旧窄范围停用标记和来源
|
||||
|
||||
- 历史表仅有既有采用、复用和查询 RPC,缺少附加永久审计标记的授权接口。需批准数据库侧方案,或允许本轮派生停用标记、另立持久化审计单。
|
||||
- 部分已复用 v1 的档案规则不足以区分手选与按事件采纳。替代证据是原历史记录的规则与证据来源。需确认无法追溯的记录与早期 `segment-v1` 的处理口径。
|
||||
- 实际默认试算为 ±15 分钟,任务书 §六描述 ±30 且限定组件改动。需确认是否同步更新服务端默认,或按实际范围显示试算文案。
|
||||
- 快照数量需受控的 staging 数据源。隔离数据库可验证行为和原记录保留,不能据此推断真实受影响数量。
|
||||
- 详见 [#279 进度](docs/tasks/PROGRESS-rect-p0-20261115.md)。
|
||||
|
||||
+5
-1
@@ -4,9 +4,13 @@
|
||||
|
||||
- 计算附录显示甲乙各自的误差来源,以及本命上升、九分盘上升、月亮星宿与四分的核对结果。会受影响的技法标明参数敏感。占星 Skill 版本不变(BUG-1889)。
|
||||
|
||||
## 2026-11-14 — 合盘分列计算状态和报告用途
|
||||
|
||||
- 附录按甲方、乙方和两盘对照分组,列出核验状态。合盘计算缓存按日期区分,旧合盘链接继续打开当前选人页。占星 Skill 版本不变(BUG-1888)。
|
||||
|
||||
## 2026-11-14 — 年运逐段显示证据等级
|
||||
|
||||
- 报告正文和 Markdown 导出按段落、主题和时间点显示证据等级。缺少必需依据时说明哪一项受限。计算依据可查看各结论的等级上限。占星 Skill 版本不变(BUG-1887)。
|
||||
- 报告正文和 Markdown 导出按段落、主题和时间点显示证据等级。等级受限时说明缺少哪项依据,或哪项结果会随出生时间变化,并列出已算出的候选星座。计算依据可查看各结论的等级上限。占星 Skill 版本不变(BUG-1887)。
|
||||
|
||||
## 2026-11-14 — 生时纠正结果只按填写时间保存
|
||||
|
||||
|
||||
@@ -25487,9 +25487,22 @@
|
||||
- 修复:后端在现有计算上按结论类型和窗口给出 C 或 D。写手逐段声明结论和等级,超上限或缺理由先重写一次,再由程序降低等级或补理由。新快照存哈希和调整记录。页面与导出沿用个人报告等级行。
|
||||
- 验证与防复发:定向覆盖逐主题与窗口降级、缺项披露、写作重试和兜底、旧快照回读和 Markdown。详见 [#271 进度](tasks/PROGRESS-annual-grade-20261114.md)。
|
||||
- 验收返工:时间表恢复原单元格内容,表外显示最严等级及补充理由。人物段和时间点只增加原定的等级行与补充理由。Markdown 沿用原时间表和窗口明细。回归覆盖多行时间表、正文展示与两种导出布局。
|
||||
- 第二次验收返工:必需依据的降级清单原先只传名称,导致写作、兜底和附录把出生时间误差内会换星座的结果写成未计算。现保留状态及候选,分别说明变动和缺项,合并理由时逐项去重。真实引擎夹具覆盖事业分盘水瓶座、双鱼座两个候选,回放错误模型草稿检查重写与兜底,核对附录、页面和 Markdown。
|
||||
- 关联记录:#224、#271、BUG-1650、BUG-1651、BUG-1855、BUG-1869。
|
||||
- 修复版本:`codex/annual-grade-20261114`,待独立验收。
|
||||
|
||||
## BUG-1888 | 合盘把两盘输入齐全标成已执行,日切后可能复用旧计算
|
||||
|
||||
- 状态:fixed-pending-verify(待独立验收)。
|
||||
- 首次发现 / 最近更新:2026-11-14 / 2026-11-14。
|
||||
- 现象与触发:打开新合盘的技术依据摘要,无法区分输入齐全、计算成功和在报告中使用。缺少两项核验状态。隔天重复请求时,缓存可返回上一日的数据。离线测试用 UTC 日期表示第二人的出生时刻,Saham 缺失。
|
||||
- 根因:附录把回执压成单一状态。缓存键没带计算日期。第二人已和第一人共用本命引擎,UTC 日期无法为该地点构造 Saham 所需的当地日出区间。
|
||||
- 修复:按甲方、乙方、两盘对照分组,分列计算状态和用途,附上核验状态。缓存按两人的计算日期区分。原生 Saham 失败原因透传到对应一侧的回执,公开样本按同一时刻的当地时间重放。旧首页打分回调和网页接口退役,旧链接继续跳转到选人页。
|
||||
- 验证与防复发:覆盖跨日缓存、Saham 本地计算和阻塞原因、回执表格、旧快照与旧链接。测试详见 [#275 进度](tasks/PROGRESS-synastry-b1-20261114.md)。
|
||||
- 首次验收返工:追问按原先的附录文字读取技法,审计改表后只拿到两条核验文案,遗漏技法状态。追问改为从审计行提取计算状态和用途,各组合计最多 12 行。误差敏感项并入同一组表格,旧快照可从已保存的回执恢复误差标记。回归核对三个分组、旧文字及核验文案过滤。
|
||||
- 关联记录:#275、BUG-1595、BUG-1679、BUG-1680、BUG-1794。
|
||||
- 修复版本:`codex/synastry-b1-20261114`。
|
||||
|
||||
## BUG-1889 | 合盘未核对两个人各自的出生时间误差
|
||||
|
||||
- 状态:fixed-pending-verify(待独立验收)。
|
||||
@@ -25500,3 +25513,14 @@
|
||||
- 验证与防复发:公开双盘使用默认窗口,合成用例分别覆盖甲方 D1、乙方 D9、月亮四分边界、两人稳定、自报误差、纠正记录复用及过时记录拒用。详见 [#276 进度](tasks/PROGRESS-synastry-precision-20261114.md)。
|
||||
- 关联记录:#224、#275、#276、BUG-1654、BUG-1679、BUG-1869。
|
||||
- 修复版本:`codex/synastry-precision-20261114`,待独立验收。
|
||||
|
||||
## BUG-1890 | 旧答题窄范围仍可进入读盘
|
||||
|
||||
- 状态:blocked(旧记录停用范围和审计写入方式待拍板)。
|
||||
- 首次发现 / 最近更新:2026-11-15 / 2026-11-15。
|
||||
- 现象与触发:FIX-7 撤下比较按钮后,兼容接口仍可接收采用答题范围的请求。已有旧窄范围的档案仍可供读盘。
|
||||
- 根因:采用 API 接收 `useAnswerWindow`。持久化旧记录的 `rectified_range` 是读时投影,不能单凭名称区分手动选边和证据推断。历史表未提供停用标记写入接口。
|
||||
- 修复进度:本地关闭应用层答题窄范围写入,保留旧记录及历史读取。停用标记与下游回退待拍板。
|
||||
- 验证与防复发:定向测试覆盖旧采用开关发出时不调用引擎、保存默认原范围、在隔离数据库读取原有记录。详见 [#279 进度](tasks/PROGRESS-rect-p0-20261115.md)。
|
||||
- 关联记录:#279、#260、#272、#229、BUG-1886。
|
||||
- 修复版本:任务分支 `codex/rect-p0-20261115` 本地草稿。
|
||||
|
||||
@@ -681,3 +681,8 @@ Prevention: 不要把 `lagna_seventh_strength` 或 `niryaana_shoola_strength`
|
||||
多个会话在同一台机器上各开整份工作树(每份带 `frontend/.next` 构建产物),根分区 inode 到 100%(剩约 5,700),新工作树建不出来,`next build` 中途还会再吃掉几千个。`df -h` 看着有空间,`df -i` 才看得到。清理已推送、工作区干净的临时工作树(`git worktree remove`,分支保留)和 `.next` 后回到 65%。
|
||||
|
||||
Prevention: 开工作树前先看 `df -i /`;工作树用完、内容已推送就删掉;构建验证后删 `.next`(含 `standalone`);`node_modules` 一律软链到已有工作树,不在新工作树里装依赖。关联本地前端构建验证步骤(next build --webpack + next start)。
|
||||
|
||||
## 2026-11-15 · #279 Windows 预检
|
||||
|
||||
- Python 3.11、Gitea 远端和引擎适配器诊断通过。定向预检的 `test_preflight_fragment_scan_reports_authority_layers_and_risk_buckets` 依赖工作区里的 `.workbuddy` 镜像,独立工作树不满足该断言。
|
||||
- 复验包按冻结提交建立干净工作树,锁定 Python 依赖。原归档校验与 smoke 行对比通过。见 [#279 进度](../tasks/PROGRESS-rect-p0-20261115.md)。
|
||||
|
||||
@@ -86,3 +86,28 @@
|
||||
- active_rectification_selector.py 只接受 A/B/C/D 才计作已答和领域频次,并透传模板来源及未验证时段状态。网站使用实际题目允许的 choice、独立验证冲突;本轮回放仅提交网站接受的原生答案。
|
||||
|
||||
下一轮:重新按人物划分开发、验证、最终留出,最终留出另收新人物;按原始记录分辨率保留标签区间;固定 profile、代码哈希和只读事实的模拟器;偏差配对之外增加整点舍入和时辰不明;交完整轨迹,固定消融次序,报告覆盖—宽度和伤害,另测用途稳定性。这些是下一轮方案,本次未使用新人物或做用途稳定性试验。
|
||||
|
||||
## #279 引擎复跑补包
|
||||
|
||||
取源提交为 `845854ff79ac72c931daa4e34f97f7084e8f35d4`。从 `results/SHA256SUMS` 筛选 `scripts/` 下的 60 个 Python 模块。用上述提交的 Git blob 提取,逐项核对 SHA256,并保留路径。另核对清单里的 3 个 `.se1` 文件。提交中的相同星历路径为 `references/open_source_sources/vedic-astro-skills/antigravity/skills/vedic-calculator/scripts/ephe/`。当前 staging 在年运、咨询和合盘模块上已有其他提交,复验不得把这些版本混入。
|
||||
|
||||
在干净检出根目录解压源码补包和原 #272 归档,保留 `scripts/`、`references/real_case_calibration/` 和星历原目录。用 Python 3.11。需要显式设置 `PYTHONPATH` 时加入检出根和 `scripts/`,Windows 用分号,POSIX 用冒号。先执行:
|
||||
|
||||
python references/real_case_calibration/rect_repro_20261114/reproduce.py --output rect-smoke --workers 1 --smoke
|
||||
|
||||
烟测通过后重跑全量:
|
||||
|
||||
python references/real_case_calibration/rect_repro_20261114/reproduce.py --output rect-full --workers 8
|
||||
|
||||
核对原归档及其散列:
|
||||
|
||||
python references/real_case_calibration/rect_repro_20261114/verify.py references/real_case_calibration/rect_repro_20261114/results
|
||||
|
||||
烟测的每个解压 JSONL 与相应归档开头 8 行比较。验收证据:Windows 干净工作树上 32 行全匹配,原归档 2464 行全部通过校验。
|
||||
|
||||
| 依赖 | 许可证与获取位置 |
|
||||
| --- | --- |
|
||||
| Jyotisha 复跑模块 | MIT。源码补包保留源提交的 LICENSE |
|
||||
| `pyswisseph==2.10.3.2` | AGPL-3.0。见 [PyPI 版本](https://pypi.org/project/pyswisseph/2.10.3.2/) 和 [作者仓库](https://github.com/astrorigin/pyswisseph) |
|
||||
| `tzdata==2026.2` | Python 包 Apache-2.0。见 [Python tzdata 许可证](https://github.com/python/tzdata/blob/master/LICENSE) |
|
||||
| `seas_18.se1`、`semo_18.se1`、`sepl_18.se1` | Astrodienst 的 AGPL 或专业许可。补包提供原路径与散列。按 [Swiss Ephemeris 官方下载及许可说明](https://www.astro.com/swisseph/swephinfo_e.htm) 获取并核对冻结散列 |
|
||||
|
||||
@@ -37,3 +37,33 @@
|
||||
| 既有断言原值 | 新值 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| 独立时间表与时间轴各时间段逐行显示等级,二者等级行总数相同 | 时间轴仍按各段显示等级,独立多行表在表下汇总一次 | 验收要求复用 staging 的表格布局和原列宽 |
|
||||
|
||||
## 第二次验收返工
|
||||
|
||||
- Claude 在评论 `44397` 退回 `29ac0138`,评论 `44413` 确认可继续沿用 PR #273。原降级清单把变动的分盘压成名称,导致写作和附录将已算出的依据写成缺项。
|
||||
- 清单保留原状态及候选。事业分盘的真实引擎夹具覆盖水瓶座、双鱼座。人物、感情、家宅、学习使用同一个状态和候选格式。窗口月份变动单独说明。若候选只涉及上升主星落宫,文案只说明落宫变动。
|
||||
- 写作材料分别给出「会变」和「缺少」,提示词要求准确披露候选。错误草稿先重写,兜底纠正缺失表述并补上按事实合并的理由。页面、附录和 Markdown 共用依据文案,时间表继续汇总一条最严等级。
|
||||
- 旧事实中的字符串清单从已保存的必需依据补读状态,既有报告继续读取原快照。等级上限及版式未调整。真实模型样例留给独立验收,本轮使用真实引擎夹具和桩写手。
|
||||
|
||||
| 既有断言原值 | 新值 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| 已计算的 Narayana 不出现在字符串缺项中 | 上限仍为 C,降级清单为空 | 已计算的必需依据均满足,避免用字符串比较结构化清单 |
|
||||
| `vimshottari`、`window_precision` 与 `D24` 只验证 ID | 分别验证原 ID 及 `missing`、`varies`、`unknown` | 状态现在是降级清单的公开契约 |
|
||||
| Narayana 同向时关系上限 D,缺项为字符串 D9 | 上限仍为 D,旧清单补读到 D9 `varies` 和三个候选 | 九分盘已有计算,保留方向断言并校验旧事实兼容 |
|
||||
| 页面和 Markdown 的兜底断言写「缺少事业分盘上升」 | 断言写「会换星座」及水瓶座、双鱼座,并拒绝两种缺项表述 | 真实引擎已算出候选,上限仍为 D |
|
||||
|
||||
### 本轮验证
|
||||
|
||||
- 前端定向 23 项通过。Python 年运及仓库隐私合计 80 项通过。另以既有公开盘事实核对五项因出生时间变化降至 D 的结论,写作材料与附录逐项一致。
|
||||
- 前端全量 3744 项(3661 通过、46 失败、37 跳过、0 取消),同机无 Docker 基线 3743 项(3660 通过、46 失败、37 跳过、0 取消)。逐条比较失败清单一致,既有测试均保留。
|
||||
- Python 快速门 1497 项通过、3 项失败、2 项跳过,另有 29 个子测试通过。与同机 `29ac0138` 基线逐条同为三项 Kaala / PyJHora 失败。完整快速门待独立环境复核。
|
||||
- TypeScript 和生产构建通过。ESLint 0 错误、63 条既有警告。首页仍为静态路由。按同一方法计算 HTML 引用的首屏 gzip JS 和 CSS,分别为 517063 与 93168 字节,与本单返工前同机、同提交的构建产物一致。
|
||||
- 预检确认 Python、远端仓库和引擎适配器可用,Windows 碎片扫描与定向预检仍分别在 90 秒和 45 秒超时。
|
||||
|
||||
## 更新验收基线
|
||||
|
||||
- 按 Claude 在 #271 的评论 `44442`、`44451`,把 PR #273 的修改移到 `ff00c96d2e9c32f31863012e280ecf367fcc8098`(含 #265 和 #274)。原交付提交是 `3df218782b9c8ddef51f9da574e4fc6396d81bc7`。
|
||||
- 逐项比较返基线前后的补丁,年运实现和既有回归测试一致。独立验收可在同一 PR 按新提交核对真实模型样例。
|
||||
- 前端定向 33 项、Python 年运及隐私检查 66 项通过。TypeScript、ESLint(0 错)和生产构建通过。首页为静态路由,JS 和 CSS 的 gzip 体积与同机新基线一致,分别为 507344 和 92393 字节。
|
||||
- 前端全量 3747 项,3665 通过、45 项失败与新基线逐项一致、37 项跳过、0 项取消。既有测试名称均保留。
|
||||
- Docker Linux 引擎返回 500。无 Docker 的数据库套件与同机新基线逐项一致(8 通过、28 失败、36 跳过),真实 PostgreSQL 验证待补。预检已核对远端和引擎适配器,碎片扫描和定向套件仍超时。
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# #279 · 生时纠正 P0(2026-11-15)
|
||||
|
||||
- 执行者:Codex。任务书由 Claude 在评论 44523 确认。
|
||||
- 代码基线:`origin/staging` 的 `405876ad2e5a6312145d9061e5c738bd5dc506ac`。从该提交建立独立工作树,再快进到任务分支的任务书提交 `a6611180e863db1cf9a27e4ba90818dc3e50cb25`。
|
||||
- 关联 BUG-1886:FIX-7 已撤下页面比较按钮。复核发现采用 API 和历史复用 RPC 仍能写入旧窄范围,报告仅降级把握,仍读取候选段。
|
||||
- 上线范围按 Git 引用核对。下表日期为代码进入所核对的 staging 历史的日期,实际部署时间待负责人核对;生产控制分支 `7b620c7a2` 无这些 11 月提交,未据此推断线上实际镜像。
|
||||
|
||||
| 来源 | 可验证的写入与版本 | 下游与快照 |
|
||||
| --- | --- | --- |
|
||||
| 问卷答题段 `user_choice_from_answers` | 11-14,`chart_choice_adopt_v4` 写原始历史与档案采纳来源。页面 FIX-7 撤掉入口,直接请求仍可写。 | 长报告和合盘从档案取采纳段。年运或聊天若读取采纳时刻和状态也会受影响;账户、星盘和生时纠正首页会取采纳时间。已有长报告、年运正文和导出使用已保存的报告数据。 |
|
||||
| 11-06 旧选盘采纳 | `chart-choice-v1` 共用 `source=user_choice`;11 月事件证据链可留下 `rule=evidence`,但只在完整历史决策中有 `decided_by`;证据也可能来自外貌或补充问答。复用 v1 记录会重写档案副本的 `rule=reused_record`,原历史记录保留原值。11-13 报告读取才把采纳范围转换为 `rectified_range`。 | 生时纠正首页与账户使用采纳时间;长报告用 `active_birth_provenance` 及选边重建区间。这些新输出可以回退,已生成快照和导出须保持原样。 |
|
||||
| #229 的显式分盘选边 | 11-13 多轮数据为 `chart-choice-v2`、`rounds` 与 `segment`。部分被续问的老记录仍是 v1;原规则 `user_override` 可证明显式反选。 | 继续作为历史和当前分盘依据。不得仅凭 `rectified_range`、`user_choice` 或本地日期整批停用。 |
|
||||
| 早期事件校正段 | 旧流程另有 `segment-v1` 与 `read_report_candidate_range`。前者存校正采纳,后者可读候选区间,不能仅凭候选区间认定已采纳。 | 旧咨询从独立 RPC 取候选范围。需先决定是否纳入本次回退,避免改变明确采纳或数据不足的旧记录。 |
|
||||
| 原始填报 / 范围中点 | `reported_time_default`、`window_midpoint_default` 与原始声明。 | 是回退目标。未填范围的试算窗口单独说明,不能作为用户已确认的误差。 |
|
||||
|
||||
仍需负责人确认的范围和存储方案见下方记录。已有快照受影响数量 blocked:本轮只使用隔离测试环境,没有获准查询含用户记录的数据库。
|
||||
|
||||
## 待拍板
|
||||
|
||||
- **停用标记的持久化。** `chart_choice_records` 已撤回应用角色的表权限。现有 RPC 只允许老记录复用、新记录采用和只读查询,没有附加标记的入口。自己的档案和代管人物权限不同,不能使用应用代码绕过历史记录表权限。建议由数据库负责人确认走独立审计记录,或批准在原历史 JSON 新增只写一次的标记及受控回填。若本单必须保持零迁移,可先按读取规则派生「已停用」及原因,同时将持久化审计另立单。
|
||||
- **已复用的旧 v1。** 档案的规则被复用覆盖时,可以在对应历史还在可读窗口内时找回原规则。历史缺失或规则无法区分手选与证据时,建议保留明示手选和来源不明的记录,先只停用有明确证据的旧窄范围。待确认早期 `segment-v1` 是否属于本轮。
|
||||
- **生时纠正实际默认值。** 任务书 §六以 ±30 为默认,并限定只改组件。现有 `DEFAULT_RANGE_MINUTES` 是 ±15,服务端也复用该值。建议允许同步改服务端默认;若只改本页文案,按实际区间说明试算,用户手填范围保持原意。
|
||||
|
||||
## 已做与验证
|
||||
|
||||
- 本地改动拦截 `POST /api/chart-choice/adopt` 的 `useAnswerWindow`,内部保存也拒绝旧开关,避免新的问卷采用写入窄范围。历史枚举、表和 RPC 未改。
|
||||
- 定向选盘页面/服务 7 项通过。隔离 PostgreSQL 的历史记录测试 2 项通过。
|
||||
- 预检的 Python、Gitea 远端、碎片扫描和引擎适配器通过。定向预检一项未过,独立工作树缺少扫描测试期望的 `.workbuddy` 镜像目录。
|
||||
- 在干净工作树按冻结提交 `845854ff79ac72c931daa4e34f97f7084e8f35d4` 安装锁定依赖。归档 `verify.py` 核对 2464 行通过。四组 smoke 各 8 行解压后与归档逐行一致。
|
||||
- 本地源码补包已核对 60 个 Python 模块和 3 份星历的冻结散列。包提供 Python 源码和星历原路径、散列及授权获取说明。复跑说明见 `docs/research/rect-repro-20261114.md`。
|
||||
|
||||
| 既有测试原值 | 新值 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| `useAnswerWindow=true` 通过应用服务写入旧窄范围 | 服务在调用引擎前拒绝,保留之前已写入的原始范围 | 产品要求关闭新写入 |
|
||||
| 通过应用服务构造数据库中的旧记录 | 用现有旧版本 RPC 模拟数据库中已存在的旧记录,保留其来源、秒级窗口和复用断言 | 继续验证原记录的读取与兼容性 |
|
||||
|
||||
待处理:旧档案的完整回退及审计标记、各下游合同与快照统计、四条模拟器反例、页面试算文案与 390 像素验收。当前进度不作为完整修复验收。
|
||||
@@ -0,0 +1,43 @@
|
||||
# #275 合盘第 1 批
|
||||
|
||||
- 从 `origin/staging` 开独立工作树,快进到可信规划评论中的任务书提交 `8dbaf2d3`。按随任务书提交的产品契约 L 节实现。
|
||||
- 「技术依据摘要」按甲方、乙方、两盘对照分组。表内分开「计算」和「在本报告中」。两盘输入齐全写「输入已齐」,阻塞或不适用写原因。网上资料核对和真实案例校准两行只在附录。旧报告继续从快照读原有的文字列表。
|
||||
- 两人走同一个本命引擎。旧公开复现的第二人以 UTC 表达同一出生时刻,Swiss 日出流程报 `solar_day_window_unavailable`。用该地点当地时间与正确时区表达同一 UTC 时刻,原生模块返回 `partial`,有 Vivah Saham 数据。保留真实失败状态并在个人回执和两人对照中解释原因。这个部分结果继续按参数敏感展示,不抬高就绪状态。
|
||||
- 缓存对每人保存计算实际使用的日期,共用缓存版本从 v4 升至 v5。每日重新区分身份键。
|
||||
- 用户入口只打开当前合盘选人页。旧 `/?synastry=` 链接也只做重定向,传入的旧打分回调从未被调用。删除 `use-synastry.ts`、Next `/api/synastry` 和首页的旧卡片、历史绑定。保留现用的完整合盘入口、已存报告和 Python 接口。
|
||||
|
||||
## 断言调整
|
||||
|
||||
| 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| 对照就绪等于「已执行」,阻塞只有「无法计算」,核验行隐藏 | 验证「输入已齐」、分组和用途列,阻塞说明原因,附录有两项「未完成」 | 产品契约 L 节按计算与引用分别显示 |
|
||||
| 公开盘第二人用同一时刻的 UTC 日历表示 | 用相同 UTC 时刻的当地日历表示,核对两份 Saham 原生回执为参数敏感 | 日出区间依赖当地日历,出生物理时刻不变,保留原配对结果断言 |
|
||||
| 针对旧接口的并发请求、域分流、旧卡和旧历史状态断言 | 移除 `synastry-chart-skip` 和 `chart-library-other-profile` 的三条旧链测试,以及 Python 旧路线编排断言。改查旧链接重定向和当前配对入口 | 任务书明确退役没有用户入口的打分路径 |
|
||||
| 账户保护、属主取资料、产品开关和 Python 到达测试含旧路线 | 保留账户保护和报告路由断言,合盘检查改指向其现用创建或生成逻辑 | 被删除的路线已不承载用户操作 |
|
||||
| 旧档案详情断言首页新建自绑定对话、旧报告卡带有人物 ID | 核对档案按钮带所选人物进入当前合盘选人页 | 重定向不新建对话,人物 ID 仍随入口传递 |
|
||||
| 附录全部文字禁用核验措辞 | 对两条固定文案逐字断言,其余技法、状态、用途和个人及年运报告继续检查禁用词 | 契约 L 节仅为合盘附录开放两行 |
|
||||
|
||||
## 验证
|
||||
|
||||
- 合盘完整报告与追问定向 29 项通过,新增的四项前端回归通过。Python 定向 83 项通过,Windows 缓存文件权限位检查一项失败。同机基线得到同样的权限位和失败。
|
||||
- TypeScript 与生产构建通过,ESLint 0 错误、63 条既有警告。首页为静态路由,首屏 gzip JS 从 517063 降至 514367 字节,CSS 同为 93168 字节。
|
||||
- Python、Gitea 远端可见性与引擎适配器预检通过。碎片扫描和定向预检分别在 90 秒、45 秒超时。
|
||||
- 同机无 Docker 前端全量均为 3743 项,修复分支 3662 通过、44 失败,基线 3661 通过、45 失败,均为 37 跳过、0 取消。四条退役测试和四条新增测试按名称比对,无新增失败。仅基线有一项答复计时失败。
|
||||
- Python 快速门为 1495 项通过、4 项失败、2 项跳过,另有 29 个子测试通过。三项 Kaala / PyJHora 失败与同机同提交基线相同。另有一项咨询 VedAstro 原始结果可用性断言,修复分支与同机基线定向重跑都复现相同差异。完整门禁待独立环境复核。
|
||||
|
||||
## 首次验收返工
|
||||
|
||||
- Claude 的退回评论 `44494` 针对 PR #277 的 `62f643425e77befc485d5f94449bab3ae9a6af75`。现以已纳入 #276 的 staging 提交 `79306979513c5da9a5f92a44f1426e968bea91d7` 为基线。
|
||||
- 追问材料从甲方、乙方及两盘对照三组提取技法状态和用途,依次从各组取行,最多 12 行。旧报告仍读取历史技法文字,附录核验文案留在附录。
|
||||
- 出生时间误差在相关人物或两盘对照的技法行标「参数敏感」「只作观察。出生时间误差内会变」。#276 已保存的快照通过原回执渲染分组。
|
||||
|
||||
| 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| #276 断言单独误差表含「甲方 D1/Rashi」,并排除乙方行 | 断言甲方组的对应行及两盘对照标为参数敏感,乙方同技法继续显示原状态,每组仅一张表 | 按验收要求合并审计及误差展示 |
|
||||
| #275 的公开双盘断言主大运对照输入已齐 | 沿用 #276 的参数敏感及双盘扫描断言,同时保留双方 Saham 有计算结果的断言 | 乙方 D1 在误差内换座,Narayana 起点受影响 |
|
||||
| 服务端属主契约要求合盘生成器直接调用 `loadSubjectBirth` | 断言生成器把所有者和对象传给 `loadSynastrySubjectBirth`,后者再调用 `loadSubjectBirth`,保留公共列清单断言 | #276 已将纠正窗口接到共同的属主读取链路 |
|
||||
|
||||
- 前端定向 49 项、Python 定向及隐私 78 项通过。附加契约检查 11 项通过,Windows 缓存文件权限位的 1 项失败在新基线复现。
|
||||
- 全量前端 3753 项,3671 通过、45 项失败与新基线逐项一致、37 跳过、0 取消。退役路径少 4 项旧测试,本单新增 6 项测试。
|
||||
- 生产构建通过,首页仍静态。首屏 JS gzip 由 508645 减为 505948 字节,CSS 保持 92393 字节。ESLint 0 错。
|
||||
- Docker Linux 引擎返回 500。无 Docker 的数据库套件 28 项失败与新基线逐项一致,真实 PostgreSQL 验证待补。预检的碎片扫描和定向套件仍超时。
|
||||
@@ -0,0 +1,113 @@
|
||||
# 生时纠正 P0:旧窄范围退出报告、弃权语义、模拟器隔离、引擎复跑包(2026-11-15,Claude)
|
||||
|
||||
Bug 编号:BUG-1890。
|
||||
|
||||
## 背景
|
||||
|
||||
占星师 11-15 复核了 #272 的复验包,主要统计独立复算一致。她排了下一包的验收顺序:
|
||||
|
||||
1. **P0:**
|
||||
- 证明「应用」已禁用;
|
||||
- 旧的窄范围已撤回;
|
||||
- 弃权语义正确;
|
||||
- 原始记录保留。
|
||||
2. 补齐源码依赖,让她能复跑引擎;做模拟器隔离的反例测试。
|
||||
3. 日期区间和用途稳定性。**本任务不做。**
|
||||
|
||||
产品负责人 11-15 定了两件事:
|
||||
|
||||
- **旧窄范围:** 报告一律改用原范围。旧记录留在库里备查,但报告、聊天、导出和首页都按用户填的时间和原范围读,相当于自动改回,并留下审计痕迹。
|
||||
- **源码:** 给占星师的复跑包只放复跑需要的 Python 模块、星历和目录重建说明。不放前端、部署配置或密钥。
|
||||
|
||||
## 一、盘点(先做,结果写进 PROGRESS)
|
||||
|
||||
列出所有会让「读盘窗口」比用户原始范围窄的路径,每条写清楚以下几项:
|
||||
|
||||
- 来源字段,例如 `user_choice_from_answers`、11-06 按事件采纳的 `rectified_range`、#229 分盘换座线两侧的选边,以及其他来源;
|
||||
- 是在 staging 还是生产上线,什么时候上线的;
|
||||
- 会进哪些下游:长报告、年运、聊天、星盘页、导出、首页;
|
||||
- 已生成的报告快照会不会继续沿用旧窗口。
|
||||
|
||||
只盘点,不顺手改。
|
||||
|
||||
## 二、旧窄范围退出下游
|
||||
|
||||
1. **适用范围:** 来源属于下面两类的记录。
|
||||
- 答题或事件得出的范围:`user_choice_from_answers`、11-06 按事件采纳的 `rectified_range`,以及盘点中发现的同类来源。
|
||||
- 处理方式:下游一律按用户原始填写时间加原始范围读。没有填时间的,按原范围中点读。
|
||||
2. **#229 的分盘选边**(用户按「哪种更像你」选了换座线某一侧)**这次不改。** 在盘点里单独列出,交产品负责人和占星师另定。
|
||||
3. **记录不删不改:**
|
||||
- 原记录保留原值和来源;
|
||||
- 新增一个停用标记,写明原因,例如「BUG-1890:答题缩窄未验证」;
|
||||
- 读取层看到这个标记,就退回原范围。
|
||||
- 首页显示填写的时间;历史里能查到旧记录,标「已停用」。
|
||||
4. **已生成的报告快照:**
|
||||
- 不自动重写;
|
||||
- 用户下次重新生成时按原范围;
|
||||
- 在 PROGRESS 里统计受影响的快照数(staging 本地库能统计就统计,统计不了写 blocked)。
|
||||
5. **前端和 API 不能再新写窄范围:**
|
||||
- `/api/chart-choice/adopt` 收到 `useAnswerWindow` 时直接拒绝(4xx,带明确说明);
|
||||
- 迁移不改,旧枚举值保留,旧记录还要能读。
|
||||
|
||||
## 三、弃权语义
|
||||
|
||||
占星师指出:555 次「弃权」(停在「没有可以再区分的题」)里,有 52 次在停下之前已经把真实时间排除了。
|
||||
|
||||
1. **回放轨迹拆成四个字段:**
|
||||
- `stop_reason`;
|
||||
- `set_changed`:候选集合是否比原窗口小;
|
||||
- `reverted_to_original`:最终是否退回原集合;
|
||||
- `apply_allowed`:是否允许应用(现在恒为 false)。
|
||||
2. **网站行为:** 任何停止原因下(包括弃权),保存的都是填写时间加原窗口,不能悄悄用受损的区间。
|
||||
- 写一个反例测试:先缩窄、把参照时间排除在外,再停在「没有可以再区分的题」,断言保存的仍是 `reported_time_default` 和原窗口。
|
||||
|
||||
## 四、模拟器隔离反例(`references/real_case_calibration/rect_repro_20261114/` 的测试)
|
||||
|
||||
1. 把评分用的真实时间换成另一个值,事件答案不能变。
|
||||
2. 题目选项重新排序后,选中的事实语义不能变。
|
||||
3. 胎记题传空数组时,记作「未知」,不能当成「确定没有」。
|
||||
4. 同一条人生事件衍生出的毕业、就业、搬迁,记录共同的事实链 ID,汇总时不算三条独立经历。只加标注和统计,不改评分。
|
||||
|
||||
## 五、给占星师的引擎复跑包
|
||||
|
||||
1. 按 `results/SHA256SUMS` 里列出、但 ZIP 里没有的 63 项打包:
|
||||
- `scripts/`、`scripts/chart_choice`、`scripts/chart_dasha`、`scripts/rectification`、`scripts/report_render` 中回放实际加载的模块;
|
||||
- 3 份星历文件。
|
||||
2. **原目录重建说明:**
|
||||
- 解压到哪里、`PYTHONPATH` 怎么设;
|
||||
- 一条命令跑 `--smoke`,再跑全量。
|
||||
3. **许可清单:** 每个依赖和星历文件的许可证名称;不允许再分发的写明,改为给下载地址。
|
||||
4. **版本:**
|
||||
- 以 845854ff 为准;
|
||||
- 如果复跑用的 scripts 和当前 staging 不同,写明差异;
|
||||
- 不能拿资料仓里的同名文件顶替。
|
||||
5. **在干净目录里自测一次:** `--smoke` 逐行一致,`verify.py` 通过,并写清楚需要 Python 3.11。
|
||||
|
||||
## 验收
|
||||
|
||||
- **测试:**
|
||||
- 旧 `user_choice_from_answers` 和 11-06 `rectified_range` 记录:长报告、年运、聊天、导出、首页都按原范围读,不出现 `minute_confirmed`;
|
||||
- 停用标记写入、可审计;
|
||||
- `useAnswerWindow` 被拒绝;
|
||||
- 弃权反例;
|
||||
- 四个模拟器反例。
|
||||
- **证据:**
|
||||
- 新用户和历史用户各一组,覆盖 API 响应、存储前后、页面截图(390 宽)和导出文件;
|
||||
- 本地能做到的先做,staging 部署后补;
|
||||
- 用合成账号和资料,不碰真实用户。
|
||||
- **门禁:** Python quick gate、chart-choice 和报告相关前端测试、`tsc`、`npx eslint .` 0 errors。
|
||||
- **文档:**
|
||||
- BUG_HISTORY 新增 BUG-1890,只在文件末尾追加这一节;
|
||||
- 写 PROGRESS;
|
||||
- 复跑包说明写进 `docs/research/rect-repro-20261114.md` 的新一节。
|
||||
|
||||
## 六、补充(11-15):默认 ±30 窗口的说法
|
||||
|
||||
产品负责人 11-15 定了一条规则:用户没填范围时,默认的 ±30 分钟只算「研究情景」,个人报告、年运、合盘、生时纠正都适用。报告侧由另一个会话改(BUG-1891 起)。生时纠正页面的文案在本任务里改:
|
||||
|
||||
1. **用户没填范围、用的是默认 ±30 时:**
|
||||
- 星盘行不写「已定」,改写「前后 30 分钟试算里没有变化」;
|
||||
- 不写「真实时间在这段里任何一处,下面六张盘都一样」;
|
||||
- 不出现「稳定」。
|
||||
2. **用户自己填了范围时:** 「已定」仍然只表示「在你填的范围里没有换座」。文案要把这层意思说出来,不暗示出生时间已确认。具体写法在 PROGRESS 里给出,等我验收时确认。
|
||||
3. **只改 `frontend/src/components/chart-choice/` 和对应测试。** 不碰 `scripts/report_render/birth_precision_window.py`,也不碰 `birth_window_label_zh`,那两处归另一个会话的任务。
|
||||
@@ -0,0 +1,81 @@
|
||||
# TASK:合盘第 1 批:技法审计两栏、附录核验两行、第二人 Saham、缓存日期、旧打分接口(2026-11-14)
|
||||
|
||||
- Gitea:#275
|
||||
- 分支:`codex/synastry-b1-20261114`,从 staging `29ac0138` 切出。
|
||||
- Bug 编号:BUG-1888。开工时核对 `docs/BUG_HISTORY.md` 末尾;已被占用就顺延,并在 PROGRESS 写明。
|
||||
- 负责验收:Claude(jyotisha-3f)。
|
||||
- 同时在做:#276(合盘出生时间误差,BUG-1889),会改 `full_dossier.py` 和 `synastry-full-technical.ts`。两单各改各的函数,后合入的负责 rebase。
|
||||
|
||||
任务书没写到的取舍,不得写成"产品决定"或"裁定",一律标「需拍板」。不得修改或删除既有断言来让测试通过。确需修改的,在 PROGRESS 逐条写明原值、新值和原因。
|
||||
|
||||
## 背景
|
||||
|
||||
2026-11-14 合盘差距盘点(`/workspace/eval-upstream-1107/synastry-audit-1114/SYNASTRY_GAP_AUDIT.md`)对照的是占星师的合盘子 skill `skills/jyotish-full-synastry-reading`(她 7a773d13,与本仓同名目录逐字节一致)。本单只做不需要等她裁定的确定性和展示问题。
|
||||
|
||||
暂行规则已写进 `references/product_runtime_contract.md` 第 L 节(本任务书同一提交),照该节执行。
|
||||
|
||||
## 要做的
|
||||
|
||||
### 1. 技法执行情况改两栏(`frontend/src/lib/synastry-full-technical.ts`)
|
||||
|
||||
- 现状:`STATUS_LABELS` 把 `ready_for_comparison` 映射成「已执行」(第 16 行)。她在 SKILL.md:105-107 写明这只代表两人的输入齐了。
|
||||
- 改成和年运附录一样的两栏表:方法、计算、在本报告中。复用 `consultation-technique-audit.ts` 的标签和年运 `annualAudit` 的表格版式,不新做组件。
|
||||
- 映射照契约 L 节第 1 条。blocked、not_applicable 必须附回执里的理由(中文,不出现字段名或下划线)。
|
||||
- 个人技法(`individual_technique_audit`)按人分组,标明甲方、乙方;两盘任务(`pair_execution_tasks`)单独一组。
|
||||
- 已经生成的旧报告照常显示,不报错。
|
||||
|
||||
### 2. 附录加两行核验
|
||||
|
||||
- 照契约 L 节第 2 条,在「技法执行情况」末尾加「网上资料核对:未完成」「真实案例校准:未完成」,写法同个人报告和年运的附录。
|
||||
- 删掉 11-08 那条「原值、新值、原因」注释所说的删除,改成新注释写明 11-12 的业主决定。
|
||||
- 正文和合盘追问对话里不提这两项(BUG-1794 照旧)。
|
||||
|
||||
### 3. 第二人的 Saham 缺失
|
||||
|
||||
- 现象:用一对公开名人盘离线跑 `build_synastry_full_dossier`,第二人 `modules.sahams` 缺失。结果是「Vivah and other Sahams」blocked,两盘年度对照(shared transit, Tajika, Saham and annual-window comparison)blocked,`legal_marriage` 也 blocked。复现脚本:`/workspace/eval-upstream-1107/synastry-audit-1114/syn_probe.py`。
|
||||
- 先查根因:是我方给她 builder 准备第二人模块时漏了,还是引擎对这个人真的算不出。
|
||||
- 漏了:补上,第二人和第一人走同一条路径。
|
||||
- 引擎真的算不出:保持 blocked,理由写清楚,记进 BLOCKED,标需拍板。
|
||||
- 她的 builder 和冻结文件只能调用,不能改。
|
||||
|
||||
### 4. 缓存键加日期
|
||||
|
||||
- `consult_full_data_cache.py` 的缓存最多保留 2 天,合盘的缓存键(`marriage_match_service/api.py` `_birth_identity`)不含 `today`。她 SKILL.md:47-50 要求与日期有关的层按当天重算。
|
||||
- 把 `today` 加进合盘缓存键,`CACHE_SCHEMA` 版本号加一,并照现有格式写原值、新值、原因。
|
||||
|
||||
### 5. 旧的合盘打分接口
|
||||
|
||||
- `/api/synastry`(`frontend/src/app/api/synastry/route.ts`)按 36 分加档位标题给结论,按性别取月亮,违反她 SKILL.md:202-204、243-247。
|
||||
- 首页 `frontend/src/app/(app)/page.tsx:404` 还在用 `useSynastry`(`hooks/use-synastry.ts:64` 调这个接口)。先确认首页上有没有用户能点到、会触发这个接口的入口:
|
||||
- 没有入口:删掉接口、hook 和首页里的引用,相关测试一起移除,在 PROGRESS 列出删了什么。
|
||||
- 有入口:不改,停下来写进 BLOCKED,标需拍板,把入口位置和截图路径写清楚。
|
||||
|
||||
## 不要碰
|
||||
|
||||
- 她的 `skills/jyotish-full-synastry-reading/**`、冻结文件(`jyotish_engine.py`、`jyotish_api_server.py` 等)只能调用。
|
||||
- `references/**`(L 节已由本提交写好)、`consult-preset-prompts.ts`。
|
||||
- 不改四类事件、事件扫描、写作提示词、断言标签。这些等她裁定。
|
||||
- 不调用 DeepSeek。
|
||||
|
||||
## 要改的文件
|
||||
|
||||
- `frontend/src/lib/synastry-full-technical.ts`、合盘报告页附录部分
|
||||
- `scripts/marriage_match_service/api.py`、`scripts/marriage_match_service/full_dossier.py`(只限第 3 节)、`scripts/consult_full_data_cache.py`
|
||||
- 第 5 节确认没有入口时:`frontend/src/app/api/synastry/route.ts`、`frontend/src/hooks/use-synastry.ts`、`frontend/src/app/(app)/page.tsx`
|
||||
- 测试:`tests/test_synastry_b1_20261114.py`、`frontend/tests/synastry-b1-20261114.test.tsx`,覆盖:
|
||||
- `ready_for_comparison` 显示「输入已齐」,不显示「已执行」;
|
||||
- blocked 行带理由;
|
||||
- 两行核验在附录里,正文里没有;
|
||||
- 第二人 Saham 存在(或 blocked 带真实理由);
|
||||
- 缓存键随 `today` 变化;
|
||||
- 旧报告照常显示;
|
||||
- 用户可见文字没有「·」、字段名或下划线。
|
||||
- `docs/BUG_HISTORY.md`,只在末尾追加
|
||||
- `docs/tasks/PROGRESS-synastry-b1-20261114.md`
|
||||
|
||||
## 验收标准
|
||||
|
||||
1. 公开名人盘一对:附录技法表是两栏,没有一行把 `ready_for_comparison` 写成「已执行」。
|
||||
2. 第二人 Saham 的根因写进 PROGRESS,结果符合第 3 节。
|
||||
3. 第 5 节结果符合两种情况之一,并写进 PROGRESS。
|
||||
4. tsc、eslint(0 错)、`npm test`(基线失败除外)、quick gate 全部通过。
|
||||
+4
-2
@@ -15,7 +15,7 @@
|
||||
|
||||
代号与中文释义用括号,如「AK(自我)」「D9(婚姻)」。运期层级沿用「›」,Yogini 运名后的主星用括号。Saham 公式以「白天:」或「夜晚:」开头。
|
||||
|
||||
婚恋合盘技术依据的计算参数按甲乙各占一行,写出生时间误差来源和三项扫描结果。受误差影响时,技法执行情况沿用报告数据表的样式,按相关人物或双盘比较显示技法、计算状态和使用口径。
|
||||
婚恋合盘技术依据的计算参数按甲乙各占一行,写出生时间误差来源和三项扫描结果。误差影响在甲方、乙方及两盘对照各组的原技法行内显示。计算列写「参数敏感」,用途列写「只作观察。出生时间误差内会变」。
|
||||
|
||||
### Palette
|
||||
|
||||
@@ -1402,11 +1402,13 @@ Yogini 还在取时,右栏用和 Chara 相同的轨道等待(`OrbitWaiting`
|
||||
|
||||
## 婚恋合盘报告(2026-10-19)
|
||||
|
||||
- **技法执行情况(#275,BUG-1888):** 「技术依据摘要」内沿用年运的横向可拖动表格,分列方法、计算和在本报告中。按甲方、乙方、两盘对照分组,表后列网上资料核对和真实案例校准。旧报告仍可打开原附录。
|
||||
|
||||
选人页不重复标题和副标题,页名在顶栏(2026-10-25)。两个人的选择框左右并排,中间一个叉;窄屏改成上下排,叉仍在正中。各自是下拉,最多二十人。资料不全的人不能选;已经在另一边的人不能再选。下面是「新增星盘」,点开一张卡片:称呼、性别(男 / 女)、出生日期、出生时间、出生地,右下角「取消」和「保存并选中」。满二十人时这一行换成去星盘档案删人。「开始合盘」在桌面和手机上都居中,按钮上不写价格。点了先问「会用掉 N 点,余额 M 点。」,按钮是「取消 / 开始」。余额不够时说「需要 N 点,余额只有 M 点。」,主按钮换成「去补点数」。N 从计价表读,M 从账户读。计价读不到时不弹确认,只说「计费配置不可用」。进页面不等开关请求(2026-11-03,BUG-1529):开 / 关来自外壳读到的账户,账户没到时按产品注册表默认值(开)直接画出选人区;账户的 `compatibility` 为 false 才写「合盘服务暂未开放」、不画选人区,账户读失败写「合盘服务暂时连不上,请稍后再试」。人物来自外壳的人物列表,余额来自外壳的账户,页面自己不再读这两样。价格和之前的合盘在页面挂上时同一轮去读,各自到了各自填上;价格没到之前「开始合盘」不可点。这两人已经有写好的合盘、且没有一份正在生成时,按钮下面再写已经合过几次、再生成会另扣多少点。之前的合盘只列人名和日期。生成中是轨道和四步(算两张完整命盘、整理两人之间的证据、写报告、检查报告),句子是「正在写 甲 × 乙 的合盘报告…」。报告页回到「婚恋合盘」,标题下是日期和「已保存,再次打开不扣点」,语言是「中文 / English」。选中的那一个边框是 `--color-action-strong`、文字是 `--color-action`,背景仍是画布色,认 `[data-active]` 或 `[aria-selected="true"]`,不铺 `--color-action-soft`。第一次打开时两个头像仍从两侧靠拢;减少动态效果时只淡入。九节编号,分析逻辑默认收起。英文报告同样收起分析逻辑(Analysis,依据行是 Chart 和 So),时间线每段标题写出起止年月;第一段从本月起时,起点写「现在」或 Now。英文准备时同一套轨道,写「正在写英文版…」,揭幕后整份替换。报告末尾「对哪一段想再问清楚?」,下面是八枚胶囊(`.synastry-report-ask`),不含共同练习。点一枚只新建对话并预填问题,不自动发送。对话里人物选择器锁住,显示「甲 × 乙」。合盘删除后输入框占位是「这份合盘已删除」,发送停用。报告在整宽的外层滚动,两侧空白也能滚;中间一栏只负责居中排版。合盘报告单独走 `/synastry/报告`。开始合盘、之前的合盘和报告中心的合盘卡片都进这个地址,侧栏仍亮「婚恋合盘」。旧的 `/reports/报告` 会换成新地址,并保留语言。
|
||||
|
||||
## 年运报告与开始遮罩(2026-11-01,issue #153 / #154)
|
||||
|
||||
- **年运证据等级(#271,BUG-1887):** 新报告沿用个人报告的灰字等级行。时间表下方显示表内最严的等级,补充理由在等级前。总览和主题保留「依据」段。计算依据增设「证据等级上限」,首条展开,其余可按组展开。Markdown 保留原来的时间表,时间点等级附在各自明细下。
|
||||
- **年运证据等级(#271,BUG-1887):** 新报告沿用个人报告的灰字等级行。时间表下方显示表内最严的等级,补充理由在等级前,每个依据只列一次。总览和主题保留「依据」段。计算依据增设「证据等级上限」,首条展开,其余可按组展开。上限理由分别写出缺项和随出生时间变化的计算结果,候选星座用中文。Markdown 共用理由文案,保留原来的时间表,时间点等级附在各自明细下。
|
||||
- **方案 B(#212,BUG-1868):** 报告标题后以浅灰块列返照起止和名义年末,跨年盘分别列。时间轴之后、计算依据之前用细边框块显示月相回归,现居地优先并标注出生地参考。计算依据沿用折叠。审计用不换行可横向拖动的表格,列为「方法」「计算」「在本报告中」。本命瑜伽先显示第一条,其余在原生折叠里展开。页面不渲染把握等级。
|
||||
- **年运导出(#233,BUG-1869):** 写完后顶栏右侧显示共用的描边「导出」按钮。桌面从右侧打开面板,手机从底部打开。可以导出整篇或自选正文,计算依据可整组选取。手机顶栏保留「年运」标题。
|
||||
- **年运 Tajika 附录(#256,BUG-1879):** 相位联系在格局之前,首行显示双星、角度、运动、残差及容许度,其余沿用原生折叠。格局按名称和参与行星列形成状态及未检查的必要条件。
|
||||
|
||||
@@ -51,7 +51,9 @@ Jyotisha 的可见文案是产品的一部分。正确性红线(真实性、
|
||||
|
||||
## 婚恋合盘报告(2026-10-19)
|
||||
|
||||
计算附录分别称「甲方」「乙方」。无自报或纠正范围时写「没有误差信息,按前后各 30 分钟」。核对结果写「误差内稳定」或列出候选和大致偏早、偏晚的位置。会变化的技法写「出生时间误差内会变,只作观察」。正文把相应依据写成条件。
|
||||
计算附录分别称「甲方」「乙方」。无自报或纠正范围时写「没有误差信息,按前后各 30 分钟」。核对结果写「误差内稳定」或列出候选和大致偏早、偏晚的位置。会变化的技法在用途栏写「只作观察。出生时间误差内会变」。正文把相应依据写成条件。
|
||||
|
||||
- 附录把两盘对照的就绪状态写成「输入已齐」。未使用的技法说明原因。附录末尾写「网上资料核对:未完成」「真实案例校准:未完成」。正文和追问沿用原口径。
|
||||
|
||||
说「你们之间」,不说「你是什么人 / 他是什么人」。说倾向、需求和条件,不说注定、不合、适合结婚。不写某年结婚、领证或分开。页脚保留一句:合盘描述的是互动的质地,走不走、怎么走,仍然是你们两个人的选择。
|
||||
|
||||
@@ -66,7 +68,7 @@ Jyotisha 的可见文案是产品的一部分。正确性红线(真实性、
|
||||
|
||||
## 年运报告(2026-11-01,issue #153 / #154)
|
||||
|
||||
- 新报告沿用个人报告的证据等级行。「证据等级 C:有星盘依据,还没有对得上的案例」「证据等级 D:关键依据缺失,暂不能判断」。缺项用名称说明,例如「暂不能判断:缺少事业分盘上升。」计算依据里的分组标题是「证据等级上限」。
|
||||
- 新报告沿用个人报告的证据等级行。「证据等级 C:有星盘依据,还没有对得上的案例」「证据等级 D:关键依据缺失,暂不能判断」。实际缺项用名称说明。结果随出生时间误差变化时,说明哪里会变并写出已算出的候选,例如「事业分盘上升在出生时间误差内会换星座(可能是水瓶座或双鱼座)」。计算依据里的分组标题是「证据等级上限」。
|
||||
|
||||
遮罩上只有这些句子:范围「YYYY-MM-DD 到 YYYY-MM-DD」,标题「{名字}的这一年」,三条注意事项:
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ import { useConsultationRun } from "@/hooks/use-consultation-run";
|
||||
import { useConversationScrollAnchor } from "@/hooks/use-conversation-scroll-anchor";
|
||||
import { useBirthSkyReveal } from "@/hooks/use-birth-sky-reveal";
|
||||
import { useProfileOnboarding } from "@/hooks/use-profile-onboarding";
|
||||
import { useSynastry } from "@/hooks/use-synastry";
|
||||
import { useSessionManagement } from "@/hooks/use-session-management";
|
||||
import { showChatNotice as setComposerNotice } from "@/lib/chat-notice";
|
||||
import { chatReplyAnnouncement, type ChatReplyPhase } from "@/lib/chat-reply-announcement";
|
||||
@@ -137,7 +136,6 @@ import {
|
||||
ConsultationResponseError,
|
||||
discardLegacyCloudMirrorKeys,
|
||||
fetchCloudChartLibrary,
|
||||
fetchCloudSynastryHistory,
|
||||
payloadCode,
|
||||
payloadMessage,
|
||||
waitForUndoWindow,
|
||||
@@ -401,10 +399,6 @@ export default function Home() {
|
||||
setSessions, uiPreview,
|
||||
});
|
||||
|
||||
const { synastryPanel, clearSynastryHistory, applyCloudSynastryHistory } = useSynastry({
|
||||
accountId, profile, chooseSuggestedQuestion, closeAccountDialog, startNewChat,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
activeSessionIdRef.current = activeSessionId;
|
||||
}, [activeSessionId]);
|
||||
@@ -486,10 +480,7 @@ export default function Home() {
|
||||
const branch = chartLibrarySessionBranch(accountId, chartLibraryLoadedAccount.current);
|
||||
if (branch === "clear" || !accountId) {
|
||||
chartLibraryLoadedAccount.current = "";
|
||||
queueMicrotask(() => {
|
||||
setChartLibrary([]);
|
||||
clearSynastryHistory();
|
||||
});
|
||||
queueMicrotask(() => setChartLibrary([]));
|
||||
return;
|
||||
}
|
||||
const profileForLibrary: Profile = account ? readProfile(account.profile) : profile;
|
||||
@@ -497,7 +488,6 @@ export default function Home() {
|
||||
chartLibraryLoadedAccount.current = accountId;
|
||||
discardLegacyCloudMirrorKeys(accountId);
|
||||
setChartLibrary(chartLibraryOnCloudFailure(profileForLibrary, upsertSelfChart));
|
||||
clearSynastryHistory();
|
||||
void fetchCloudChartLibrary()
|
||||
.then((cloudLibrary) => {
|
||||
if (chartLibraryLoadedAccount.current !== accountId) return;
|
||||
@@ -510,27 +500,9 @@ export default function Home() {
|
||||
if (chartLibraryLoadedAccount.current !== accountId) return;
|
||||
markChatProfilesDegraded(accountId);
|
||||
});
|
||||
void fetchCloudSynastryHistory()
|
||||
.then((cloudHistory) => {
|
||||
applyCloudSynastryHistory(cloudHistory);
|
||||
})
|
||||
.catch(() => {
|
||||
setComposerNotice("合盘历史暂时无法读取,请重试。", {
|
||||
label: "重试",
|
||||
onClick: () => {
|
||||
void fetchCloudSynastryHistory()
|
||||
.then((cloudHistory) => {
|
||||
applyCloudSynastryHistory(cloudHistory);
|
||||
})
|
||||
.catch(() => {
|
||||
setComposerNotice("合盘历史暂时无法读取,请重试。");
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
setChartLibrary((current) => upsertSelfChart(current, profileForLibrary));
|
||||
}, [account, accountId, applyCloudSynastryHistory, beginChatProfileReload, clearSynastryHistory, markChatProfilesDegraded, markChatProfilesReady, profile]);
|
||||
}, [account, accountId, beginChatProfileReload, markChatProfilesDegraded, markChatProfilesReady, profile]);
|
||||
|
||||
// An empty stand-in is not a known empty list. Until the people list arrives,
|
||||
// do not treat a name-only holder as unfinished (that flashes 「看谁的盘」).
|
||||
@@ -1120,7 +1092,7 @@ export default function Home() {
|
||||
dialogOpen={activeAccountDialog !== null || onboardingPaywallOpen || sessionDeletionOpen}
|
||||
profile={profile}
|
||||
/>
|
||||
<SynastryDeepLink profile={profile} draft={synastryPanel.draftSynastryQuestionFromChart} />
|
||||
<SynastryDeepLink />
|
||||
<AccountDialogDeepLink ready={hydrated && Boolean(account)} open={openAccountDialog} />
|
||||
<span className="sr-only" role="status" aria-live="polite" aria-atomic="true">{replyAnnouncement}</span>
|
||||
<header className="chat-header">
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { refuseWhenAccountDeletionPending } from "@/lib/account-deletion-server";
|
||||
import { z } from "zod";
|
||||
import { isProductEnabled } from "@/lib/product-access";
|
||||
import { consumeUserRequestRateLimit } from "@/lib/request-rate-limit";
|
||||
import { globalBirthProfileFromAccountRow } from "@/lib/server-owned-birth-profile";
|
||||
import { ConsultationSubjectError, loadSubjectBirth } from "@/lib/subject-birth";
|
||||
import { createServerSupabaseClient } from "@/lib/supabase/server";
|
||||
import { synastryBirthPayload } from "@/lib/global-birth-payloads";
|
||||
|
||||
const apiBase = process.env.JYOTISH_API_BASE ?? "http://127.0.0.1:5200";
|
||||
const synastryRequestSchema = z.object({
|
||||
partnerChartProfileId: z.string().uuid(),
|
||||
relationshipType: z.enum(["romance", "business", "family", "general"]).optional(),
|
||||
}).strict();
|
||||
|
||||
function moonLongitude(chart: Record<string, unknown>) {
|
||||
const planets = chart.planets && typeof chart.planets === "object" ? chart.planets as Record<string, unknown> : {};
|
||||
const moon = planets.Moon && typeof planets.Moon === "object" ? planets.Moon as Record<string, unknown> : {};
|
||||
const value = moon.lon ?? moon.longitude ?? moon.degree;
|
||||
const numeric = Number(value);
|
||||
if (!Number.isFinite(numeric)) throw new Error("moon_longitude_missing");
|
||||
return numeric;
|
||||
}
|
||||
|
||||
function moonSummary(chart: Record<string, unknown>) {
|
||||
const planets = chart.planets && typeof chart.planets === "object" ? chart.planets as Record<string, unknown> : {};
|
||||
const moon = planets.Moon && typeof planets.Moon === "object" ? planets.Moon as Record<string, unknown> : {};
|
||||
return {
|
||||
sign: moon.sign,
|
||||
nakshatra: moon.nakshatra,
|
||||
pada: moon.nakshatra_pada,
|
||||
lord: moon.nakshatra_lord,
|
||||
longitude: moonLongitude(chart),
|
||||
};
|
||||
}
|
||||
|
||||
function d9Summary(varga: Record<string, unknown>) {
|
||||
const result = varga.result && typeof varga.result === "object" ? varga.result as Record<string, unknown> : {};
|
||||
const d9 = result.D9_Navamsa && typeof result.D9_Navamsa === "object" ? result.D9_Navamsa as Record<string, unknown> : {};
|
||||
const ascendant = d9.ascendant && typeof d9.ascendant === "object" ? d9.ascendant as Record<string, unknown> : {};
|
||||
const planets = d9.planets && typeof d9.planets === "object" ? d9.planets as Record<string, unknown> : {};
|
||||
return {
|
||||
ascendant,
|
||||
moon: planets.Moon,
|
||||
venus: planets.Venus,
|
||||
mars: planets.Mars,
|
||||
source: varga.source,
|
||||
};
|
||||
}
|
||||
|
||||
function planetSign(point: unknown) {
|
||||
return point && typeof point === "object" && "sign" in point
|
||||
? String((point as Record<string, unknown>).sign || "unknown")
|
||||
: "unknown";
|
||||
}
|
||||
|
||||
function relationshipReport(synastry: Record<string, unknown>, selfD9: Record<string, unknown>, partnerD9: Record<string, unknown>) {
|
||||
const total = Number(synastry.total_score ?? 0);
|
||||
const max = Number(synastry.max_score ?? 36);
|
||||
const ratio = max > 0 ? total / max : 0;
|
||||
const band = ratio >= 0.72 ? "supportive" : ratio >= 0.5 ? "mixed" : "challenging";
|
||||
const self = d9Summary(selfD9);
|
||||
const partner = d9Summary(partnerD9);
|
||||
return {
|
||||
status: "evidence_summary",
|
||||
scoreBand: band,
|
||||
headline: band === "supportive"
|
||||
? "基础匹配度偏支持,但仍需结合现实互动与长期运势。"
|
||||
: band === "mixed"
|
||||
? "基础匹配度中等,适合重点观察沟通节奏、价值观与关系承诺。"
|
||||
: "基础匹配度偏谨慎,需要先处理冲突模式与现实条件。",
|
||||
strengths: [
|
||||
`Ashtakoot ${total}/${max}`,
|
||||
`本人 D9 Moon:${planetSign(self.moon)}`,
|
||||
`对方 D9 Moon:${planetSign(partner.moon)}`,
|
||||
],
|
||||
risks: [
|
||||
"这不是完整婚恋结论;尚未纳入双方 Dasha、UL/DK 与长期时机。",
|
||||
`D9 Venus/Mars 需要继续解释:本人 ${planetSign(self.venus)}/${planetSign(self.mars)},对方 ${planetSign(partner.venus)}/${planetSign(partner.mars)}。`,
|
||||
],
|
||||
nextEvidence: ["双方 Dasha", "UL/DK", "D9 7宫/7主", "现实关系时间线"],
|
||||
};
|
||||
}
|
||||
|
||||
function vargaPlanetSign(varga: Record<string, unknown>, division: string, planet: string) {
|
||||
const result = varga.result && typeof varga.result === "object" ? varga.result as Record<string, unknown> : {};
|
||||
const chart = result[division] && typeof result[division] === "object" ? result[division] as Record<string, unknown> : {};
|
||||
const planets = chart.planets && typeof chart.planets === "object" ? chart.planets as Record<string, unknown> : {};
|
||||
return planetSign(planet === "Ascendant" ? chart.ascendant : planets[planet]);
|
||||
}
|
||||
|
||||
function businessReport(selfVargas: Record<string, unknown>, partnerVargas: Record<string, unknown>) {
|
||||
return {
|
||||
status: "partial_evidence",
|
||||
scoreBand: "not_scored",
|
||||
headline: "已完成基础合作结构筛查;这不是合作成败、收益或契约保证。",
|
||||
strengths: [
|
||||
`D10 事业轴:本人 ${vargaPlanetSign(selfVargas, "D10_Dasamsa", "Ascendant")} / 对方 ${vargaPlanetSign(partnerVargas, "D10_Dasamsa", "Ascendant")}`,
|
||||
`D2 财富轴:本人 Moon ${vargaPlanetSign(selfVargas, "D2_Hora", "Moon")} / 对方 Moon ${vargaPlanetSign(partnerVargas, "D2_Hora", "Moon")}`,
|
||||
`D11 收益轴:本人 Sun ${vargaPlanetSign(selfVargas, "D11_Rudramsa", "Sun")} / 对方 Sun ${vargaPlanetSign(partnerVargas, "D11_Rudramsa", "Sun")}`,
|
||||
],
|
||||
risks: [
|
||||
"尚未完成 A10、功能吉凶、双方 Vimshottari + Narayana、Shadbala/AV 与外部数值一致性,不得据此断言合作结果或精确时点。",
|
||||
],
|
||||
nextEvidence: ["A10", "功能吉凶", "双方 Vimshottari + Narayana", "D10/D2/D11 原始度数与外部校验"],
|
||||
};
|
||||
}
|
||||
|
||||
async function postPython(path: string, body: unknown) {
|
||||
const response = await fetch(`${apiBase}${path}`, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(45_000),
|
||||
});
|
||||
const data = await response.json().catch(() => null);
|
||||
if (!response.ok || !data || typeof data !== "object") {
|
||||
throw new Error(`jyotish_api_${response.status}`);
|
||||
}
|
||||
return data as Record<string, unknown>;
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient();
|
||||
const { data: { user }, error: authError } = await supabase.auth.getUser();
|
||||
if (authError || !user) {
|
||||
return NextResponse.json({ error: "请先登录" }, { status: 401 });
|
||||
}
|
||||
const frozen = await refuseWhenAccountDeletionPending(user.id);
|
||||
if (frozen) return frozen;
|
||||
if (!await isProductEnabled("compatibility")) {
|
||||
return NextResponse.json(
|
||||
{ error: "合盘服务暂未开放", code: "compatibility_product_disabled" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
const limited = consumeUserRequestRateLimit("synastry", user.id);
|
||||
if (!limited.ok) {
|
||||
return NextResponse.json({
|
||||
error: "请求过于频繁",
|
||||
code: "rate_limited",
|
||||
retryAfterSeconds: limited.retryAfterSeconds,
|
||||
}, { status: 429, headers: { "Retry-After": String(limited.retryAfterSeconds) } });
|
||||
}
|
||||
|
||||
const parsed = synastryRequestSchema.safeParse(await request.json().catch(() => null));
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "请选择已保存的对方星盘" }, { status: 400 });
|
||||
}
|
||||
|
||||
let selfResolved;
|
||||
try {
|
||||
selfResolved = await loadSubjectBirth(supabase, user.id, "self");
|
||||
} catch (error) {
|
||||
if (error instanceof ConsultationSubjectError) {
|
||||
return NextResponse.json({ error: "请先完成本人出生资料" }, { status: 409 });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (!selfResolved.chartable) {
|
||||
return NextResponse.json({ error: "请先完成本人出生资料" }, { status: 409 });
|
||||
}
|
||||
let partnerResolved;
|
||||
try {
|
||||
partnerResolved = await loadSubjectBirth(supabase, user.id, parsed.data.partnerChartProfileId);
|
||||
} catch (error) {
|
||||
if (error instanceof ConsultationSubjectError && error.code === "subject_unavailable") {
|
||||
return NextResponse.json({ error: "暂时无法读取对方星盘" }, { status: 503 });
|
||||
}
|
||||
if (error instanceof ConsultationSubjectError) {
|
||||
return NextResponse.json({ error: "请先把对方星盘保存到云端星盘库" }, { status: 404 });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (!partnerResolved.chartable) {
|
||||
return NextResponse.json({ error: "请先把对方星盘保存到云端星盘库" }, { status: 404 });
|
||||
}
|
||||
|
||||
const [selfPayload, partnerPayload] = await Promise.all([
|
||||
synastryBirthPayload(globalBirthProfileFromAccountRow(selfResolved.row)),
|
||||
synastryBirthPayload(globalBirthProfileFromAccountRow(partnerResolved.row)),
|
||||
]);
|
||||
const [selfChart, partnerChart] = await Promise.all([
|
||||
postPython("/api/chart", { ...selfPayload, skip_vedastro_main_entry_overview: true }),
|
||||
postPython("/api/chart", { ...partnerPayload, skip_vedastro_main_entry_overview: true }),
|
||||
]);
|
||||
const relationshipType = parsed.data.relationshipType === "business" || parsed.data.relationshipType === "family" || parsed.data.relationshipType === "general"
|
||||
? parsed.data.relationshipType
|
||||
: "romance";
|
||||
if (relationshipType === "business") {
|
||||
const [selfVargas, partnerVargas] = await Promise.all([
|
||||
postPython("/api/varga_full", { ...selfPayload, planets: selfChart.planets, ascendant: selfChart.ascendant, divisions: ["D2", "D10", "D11"] }),
|
||||
postPython("/api/varga_full", { ...partnerPayload, planets: partnerChart.planets, ascendant: partnerChart.ascendant, divisions: ["D2", "D10", "D11"] }),
|
||||
]);
|
||||
return NextResponse.json({
|
||||
status: "ok",
|
||||
relationshipType,
|
||||
claimStatus: "partial",
|
||||
method: "d2_d10_d11_business_screening_partial",
|
||||
evidenceLayers: ["d2_hora", "d10_dashamsa", "d11_ekadashamsa"],
|
||||
blockedLayers: ["A10", "functional_benefic_malefic", "vimshottari_narayana", "shadbala_ashtakavarga", "external_engine_parity"],
|
||||
relationshipReport: businessReport(selfVargas, partnerVargas),
|
||||
});
|
||||
}
|
||||
if (relationshipType !== "romance") {
|
||||
return NextResponse.json({
|
||||
status: "blocked",
|
||||
relationshipType,
|
||||
message: "该关系类型尚无可验证的专用合盘计算合同;已保留问题草稿。",
|
||||
});
|
||||
}
|
||||
const [selfD9, partnerD9] = await Promise.all([
|
||||
postPython("/api/varga_full", {
|
||||
...selfPayload,
|
||||
planets: selfChart.planets,
|
||||
ascendant: selfChart.ascendant,
|
||||
divisions: ["D9"],
|
||||
}),
|
||||
postPython("/api/varga_full", {
|
||||
...partnerPayload,
|
||||
planets: partnerChart.planets,
|
||||
ascendant: partnerChart.ascendant,
|
||||
divisions: ["D9"],
|
||||
}),
|
||||
]);
|
||||
const synastry = await postPython("/api/synastry", {
|
||||
male_moon: moonLongitude(selfChart),
|
||||
female_moon: moonLongitude(partnerChart),
|
||||
});
|
||||
return NextResponse.json({
|
||||
status: "ok",
|
||||
method: "ashtakoot_plus_moon_nakshatra_d9",
|
||||
evidenceLayers: ["ashtakoot", "moon_nakshatra", "d9_navamsa"],
|
||||
selfChart: { moon: moonSummary(selfChart), d9: d9Summary(selfD9) },
|
||||
partnerChart: { moon: moonSummary(partnerChart), d9: d9Summary(partnerD9) },
|
||||
synastry,
|
||||
relationshipReport: relationshipReport(synastry, selfD9, partnerD9),
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json({
|
||||
status: "blocked",
|
||||
error: error instanceof Error ? error.message : "synastry_unavailable",
|
||||
message: "合盘计算暂时不可用;可先保留合盘问题草稿。",
|
||||
}, { status: 503 });
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
parseAccountDialogIntent,
|
||||
type AccountDialogIntent,
|
||||
} from "@/lib/account-dialog-intent";
|
||||
import type { ChartLibraryRecord, OpenAccountDialogOptions, Profile, SynastryRelationshipType } from "@/lib/home-types";
|
||||
import type { OpenAccountDialogOptions } from "@/lib/home-types";
|
||||
|
||||
function stripQuery(key: string) {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
@@ -17,10 +17,7 @@ function stripQuery(key: string) {
|
||||
window.history.replaceState(null, "", `${window.location.pathname}${query ? `?${query}` : ""}${window.location.hash}`);
|
||||
}
|
||||
|
||||
export function SynastryDeepLink(props: {
|
||||
profile: Profile;
|
||||
draft: (record: ChartLibraryRecord, relationshipType: SynastryRelationshipType) => Promise<void>;
|
||||
}) {
|
||||
export function SynastryDeepLink() {
|
||||
const started = useRef(false);
|
||||
useEffect(() => {
|
||||
if (started.current) return;
|
||||
@@ -29,7 +26,6 @@ export function SynastryDeepLink(props: {
|
||||
started.current = true;
|
||||
window.location.replace(`/synastry?with=${encodeURIComponent(id)}`);
|
||||
}, []);
|
||||
void props;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,16 +275,19 @@ export function SynastryReportView(props: {
|
||||
{(snapshot.technical ?? []).map((block) => (
|
||||
<section key={block.id}>
|
||||
<h3>{block.title}</h3>
|
||||
{block.precisionAudit?.length ? (
|
||||
<div className="annual-table-box" onPointerDown={dragScroll}>
|
||||
<table className="annual-table">
|
||||
<thead><tr><th scope="col">方法</th><th scope="col">计算</th><th scope="col">在本报告中</th></tr></thead>
|
||||
<tbody>{block.precisionAudit.map((row) => <tr key={row.method}>
|
||||
<td>{row.method}</td><td>{row.calculation}</td><td>{row.usage}</td>
|
||||
</tr>)}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
) : null}
|
||||
{block.audit?.map(({ title, rows }) => (
|
||||
<section key={title}>
|
||||
<h4>{title}</h4>
|
||||
<div className="annual-table-box" onPointerDown={dragScroll}>
|
||||
<table className="annual-table">
|
||||
<thead><tr><th scope="col">方法</th><th scope="col">计算</th><th scope="col">在本报告中</th></tr></thead>
|
||||
<tbody>{rows.map((row) => <tr key={row.method}>
|
||||
<td>{row.method}</td><td>{row.calculation}</td><td>{row.usage}</td>
|
||||
</tr>)}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
<ul>
|
||||
{block.lines.map((line) => <li key={line}>{line}</li>)}
|
||||
</ul>
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState, type Dispatch, type SetStateAction } from "react";
|
||||
|
||||
import { showChatNotice as setComposerNotice } from "@/lib/chat-notice";
|
||||
import { saveCloudSynastryReport } from "@/lib/home-cloud-sync";
|
||||
import { buildSynastryQuestion } from "@/lib/home-profile";
|
||||
import {
|
||||
timestamp,
|
||||
type ChartLibraryRecord,
|
||||
type Profile,
|
||||
type SynastryRelationshipType,
|
||||
type SynastryReportCard,
|
||||
type Theme,
|
||||
} from "@/lib/home-types";
|
||||
|
||||
export type SynastryParams = {
|
||||
accountId: string | undefined;
|
||||
profile: Profile;
|
||||
chooseSuggestedQuestion: (question: string, theme: Theme) => void;
|
||||
closeAccountDialog: () => void;
|
||||
startNewChat: (options: { subjectId: "self" }) => Promise<unknown>;
|
||||
};
|
||||
|
||||
export type SynastryPanel = {
|
||||
synastryRelationshipType: SynastryRelationshipType;
|
||||
setSynastryRelationshipType: Dispatch<SetStateAction<SynastryRelationshipType>>;
|
||||
synastryPendingId: string | null;
|
||||
synastryReportCard: SynastryReportCard | null;
|
||||
setSynastryReportCard: Dispatch<SetStateAction<SynastryReportCard | null>>;
|
||||
synastryHistory: SynastryReportCard[];
|
||||
draftSynastryQuestionFromChart: (record: ChartLibraryRecord, relationshipType: SynastryRelationshipType) => Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Owns the four synastry states that used to sit in Home(). Home keeps only the
|
||||
* two stable history hooks the chart-library effect calls; everything else the
|
||||
* chart-library dialog needs travels as one `synastryPanel` object.
|
||||
*/
|
||||
export function useSynastry(params: SynastryParams) {
|
||||
const { accountId, profile, chooseSuggestedQuestion, closeAccountDialog } = params;
|
||||
const [synastryRelationshipType, setSynastryRelationshipType] = useState<SynastryRelationshipType>("romance");
|
||||
const [synastryPendingId, setSynastryPendingId] = useState<string | null>(null);
|
||||
const [synastryReportCard, setSynastryReportCard] = useState<SynastryReportCard | null>(null);
|
||||
const [synastryHistory, setSynastryHistory] = useState<SynastryReportCard[]>([]);
|
||||
|
||||
// Stable across renders so Home's chart-library effect can list them in its
|
||||
// dependency array without gaining a re-run.
|
||||
const clearSynastryHistory = useCallback(() => {
|
||||
setSynastryHistory([]);
|
||||
}, []);
|
||||
const applyCloudSynastryHistory = useCallback((cloudHistory: SynastryReportCard[]) => {
|
||||
setSynastryHistory([...cloudHistory].sort((a, b) => b.createdAt - a.createdAt).slice(0, 10));
|
||||
}, []);
|
||||
|
||||
async function draftSynastryQuestionFromChart(record: ChartLibraryRecord, relationshipType: SynastryRelationshipType) {
|
||||
if (record.role !== "other") return;
|
||||
if (synastryPendingId) return;
|
||||
if (!await params.startNewChat({ subjectId: "self" })) return;
|
||||
const baseQuestion = buildSynastryQuestion(profile, record.profile, relationshipType);
|
||||
setSynastryPendingId(record.id);
|
||||
setComposerNotice("正在计算基础合盘证据,请稍候。");
|
||||
try {
|
||||
const response = await fetch("/api/synastry", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ partnerChartProfileId: record.id, relationshipType }),
|
||||
});
|
||||
const payload = await response.json().catch(() => null) as { status?: string; claimStatus?: string; blockedLayers?: string[]; evidenceLayers?: string[]; synastry?: { total_score?: number; max_score?: number; assessment?: string }; relationshipReport?: { headline?: string; scoreBand?: string; strengths?: string[]; risks?: string[]; nextEvidence?: string[] } } | null;
|
||||
if (response.ok && payload?.status === "ok") {
|
||||
const score = payload.synastry?.total_score;
|
||||
const max = payload.synastry?.max_score;
|
||||
const assessment = payload.synastry?.assessment;
|
||||
const layers = (payload.evidenceLayers || []).join(" / ") || "Ashtakoot / Moon / D9";
|
||||
const evidenceSummary = relationshipType === "business"
|
||||
? `已完成基础商业合作证据筛查:${layers};声明状态:${payload.claimStatus || "partial"};未用层:${(payload.blockedLayers || []).join(" / ") || "A10 / 双方 Dasha-Narayana / 功能吉凶"}。请勿将其表述为合作保证或精确时点。`
|
||||
: `已计算基础合盘证据:${layers};Ashtakoot ${score ?? "?"}/${max ?? "?"},初步评级:${assessment || "待解释"}。请基于这个证据包继续分析。`;
|
||||
const reportCard: SynastryReportCard = {
|
||||
id: `${record.id}-${timestamp()}`,
|
||||
partnerName: record.profile.name || "对方",
|
||||
partnerChartId: record.id,
|
||||
score,
|
||||
maxScore: max,
|
||||
assessment,
|
||||
headline: payload.relationshipReport?.headline,
|
||||
scoreBand: payload.relationshipReport?.scoreBand,
|
||||
strengths: payload.relationshipReport?.strengths,
|
||||
risks: payload.relationshipReport?.risks,
|
||||
nextEvidence: payload.relationshipReport?.nextEvidence,
|
||||
createdAt: timestamp(),
|
||||
};
|
||||
let savedReportCard = reportCard;
|
||||
let historyPersisted = !accountId;
|
||||
if (accountId) {
|
||||
try {
|
||||
savedReportCard = await saveCloudSynastryReport(reportCard);
|
||||
historyPersisted = true;
|
||||
} catch {
|
||||
historyPersisted = false;
|
||||
}
|
||||
}
|
||||
setSynastryReportCard(savedReportCard);
|
||||
if (accountId && historyPersisted) {
|
||||
setSynastryHistory((current) => (
|
||||
[savedReportCard, ...current.filter((item) => item.id !== savedReportCard.id)].slice(0, 10)
|
||||
));
|
||||
}
|
||||
chooseSuggestedQuestion([
|
||||
baseQuestion,
|
||||
"",
|
||||
evidenceSummary,
|
||||
payload.relationshipReport?.headline ? `结构化摘要:${payload.relationshipReport.headline}` : "",
|
||||
].join("\n"), relationshipType === "business" ? "career" : "marriage");
|
||||
if (accountId && !historyPersisted) {
|
||||
setComposerNotice("未能存入历史");
|
||||
}
|
||||
} else {
|
||||
chooseSuggestedQuestion(baseQuestion, relationshipType === "business" ? "career" : "marriage");
|
||||
setComposerNotice(response.status === 404
|
||||
? "请先把对方星盘保存到云端,再用于合盘。"
|
||||
: response.status === 429
|
||||
? "合盘请求过于频繁,请稍后再试。"
|
||||
: payload?.status === "blocked" ? "合盘计算暂时不可用,已先生成问题草稿。" : "已生成合盘问题草稿。");
|
||||
}
|
||||
} catch {
|
||||
chooseSuggestedQuestion(baseQuestion, relationshipType === "business" ? "career" : "marriage");
|
||||
setComposerNotice("合盘计算暂时不可用,已先生成问题草稿。");
|
||||
} finally {
|
||||
setSynastryPendingId(null);
|
||||
}
|
||||
closeAccountDialog();
|
||||
}
|
||||
|
||||
const synastryPanel: SynastryPanel = {
|
||||
synastryRelationshipType,
|
||||
setSynastryRelationshipType,
|
||||
synastryPendingId,
|
||||
synastryReportCard,
|
||||
setSynastryReportCard,
|
||||
synastryHistory,
|
||||
draftSynastryQuestionFromChart,
|
||||
};
|
||||
|
||||
return { synastryPanel, clearSynastryHistory, applyCloudSynastryHistory };
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { AYANAMSA_OPTIONS } from "./ayanamsa.ts";
|
||||
import { ANNUAL_CLAIMS, ANNUAL_CLAIM_LABELS, annualCap, annualGradeBlock, dependencyLabels } from "./annual-report-grade.ts";
|
||||
import { ANNUAL_CLAIMS, ANNUAL_CLAIM_LABELS, annualCap, annualDependencyReasons, annualGradeBlock, dependencyLabels } from "./annual-report-grade.ts";
|
||||
import { planetZh, signZh } from "./chart-view-labels.ts";
|
||||
import { displayTechniqueAuditLabel, techniqueAuditAxes, techniqueAuditStatusText, techniqueCalculationStatusLabel, techniqueInterpretationStatusLabel } from "./consultation-technique-audit.ts";
|
||||
import {
|
||||
@@ -792,7 +792,7 @@ function gradeAppendix(facts: unknown): AnnualAppendixBlock[] {
|
||||
const cap = annualCap(facts, claim, windowId);
|
||||
return [
|
||||
`${label}:${cap.cap}`,
|
||||
cap.missing_required.length ? `缺少${dependencyLabels(cap.missing_required).join("、")}` : "必需依据齐全",
|
||||
annualDependencyReasons(cap).join(",") || "必需依据齐全",
|
||||
cap.must_disclose.length ? `需说明${dependencyLabels(cap.must_disclose).join("、")}` : "",
|
||||
].filter(Boolean).join(",");
|
||||
};
|
||||
@@ -1023,7 +1023,7 @@ export async function writeAnnualReport(input: Readonly<{
|
||||
}
|
||||
// BUG-1640: wording slips (a 顺/紧 verdict, a dasha word, talk about the material)
|
||||
// no longer stop the whole report after the one rewrite; hard rules still do.
|
||||
const repairable = ["grade_above_cap", "d_without_reason"];
|
||||
const repairable = ["grade_above_cap", "d_without_reason", "incorrect_variation"];
|
||||
if (failures.some((code) => ![...SOFT_GATE_CODES, ...repairable].some((soft) => code.startsWith(`${soft}:`)))) {
|
||||
throw new AnnualGateError(entry.id, failures);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import { isSignName, signZh } from "./chart-view-labels.ts";
|
||||
import { EVIDENCE_GRADES, evidenceGradeTag } from "./personal-report-reading-contract.ts";
|
||||
|
||||
export const ANNUAL_CLAIMS = [
|
||||
@@ -27,13 +28,28 @@ const DEPENDENCY_LABELS: Record<string, string> = {
|
||||
evidence_grades: "证据等级所需的计算依据",
|
||||
};
|
||||
|
||||
const dependencySchema = z.object({
|
||||
id: z.string(),
|
||||
state: z.string(),
|
||||
candidates: z.array(z.union([z.string(), z.object({ lagna_sign: z.string() })])).optional(),
|
||||
});
|
||||
const capSchema = z.object({
|
||||
cap: z.enum(["C", "D"]),
|
||||
missing_required: z.array(z.string()),
|
||||
required: z.array(dependencySchema).optional(),
|
||||
missing_required: z.array(z.union([z.string(), dependencySchema])),
|
||||
must_disclose: z.array(z.string()),
|
||||
}).transform(({ cap, required, missing_required, must_disclose }) => {
|
||||
const byId = new Map(required?.map((dependency) => [dependency.id, dependency]));
|
||||
return {
|
||||
cap,
|
||||
missing_required: missing_required.map((dependency) => typeof dependency === "string"
|
||||
? byId.get(dependency) ?? { id: dependency, state: "missing" }
|
||||
: dependency),
|
||||
must_disclose,
|
||||
};
|
||||
});
|
||||
export type AnnualCap = z.infer<typeof capSchema>;
|
||||
const unknownCap: AnnualCap = { cap: "D", missing_required: ["evidence_grades"], must_disclose: [] };
|
||||
const unknownCap: AnnualCap = { cap: "D", missing_required: [{ id: "evidence_grades", state: "missing" }], must_disclose: [] };
|
||||
|
||||
export function annualGradeBlock(facts: unknown): Row {
|
||||
return record(record(record(facts).cards).evidence_grades);
|
||||
@@ -53,7 +69,7 @@ export function weakestCap(caps: readonly AnnualCap[], fallback: AnnualCap): Ann
|
||||
if (!caps.length) return fallback;
|
||||
return {
|
||||
cap: caps.some(({ cap }) => cap === "D") ? "D" : "C",
|
||||
missing_required: [...new Set(caps.flatMap(({ missing_required }) => missing_required))],
|
||||
missing_required: caps.flatMap(({ missing_required }) => missing_required),
|
||||
must_disclose: [...new Set(caps.flatMap(({ must_disclose }) => must_disclose))],
|
||||
};
|
||||
}
|
||||
@@ -62,8 +78,59 @@ export function dependencyLabels(ids: readonly string[]): string[] {
|
||||
return ids.map((id) => DEPENDENCY_LABELS[id] ?? "计算依据");
|
||||
}
|
||||
|
||||
export function gradeEvidence(cap: AnnualCap): Row {
|
||||
return { 上限: cap.cap, 缺少: dependencyLabels(cap.missing_required), 需说明: dependencyLabels(cap.must_disclose) };
|
||||
export function varyingAnnualReasons(cap: AnnualCap): { label: string; reason: string }[] {
|
||||
const varies = new Map<string, Set<string>>();
|
||||
for (const dependency of cap.missing_required) {
|
||||
if (dependency.state !== "varies") continue;
|
||||
const signs = varies.get(dependency.id) ?? new Set<string>();
|
||||
for (const candidate of dependency.candidates ?? []) {
|
||||
const sign = typeof candidate === "string" ? candidate : candidate.lagna_sign;
|
||||
if (isSignName(sign)) signs.add(`${signZh(sign)}座`);
|
||||
}
|
||||
varies.set(dependency.id, signs);
|
||||
}
|
||||
return [...varies].map(([id, signs]) => {
|
||||
const [label] = dependencyLabels([id]);
|
||||
if (id === "window_precision") return { label, reason: `${label}会变` };
|
||||
const candidates = [...signs];
|
||||
if (candidates.length < 2) {
|
||||
const detail = candidates.length === 1 ? `(${candidates[0]}上升的主星落宫会变)` : "";
|
||||
return { label, reason: `${label}在出生时间误差内有变化${detail}` };
|
||||
}
|
||||
const names = `${candidates.slice(0, -1).join("、")}或${candidates.at(-1)}`;
|
||||
return { label, reason: `${label}在出生时间误差内会换星座(可能是${names})` };
|
||||
});
|
||||
}
|
||||
|
||||
export function gradeEvidence(cap: AnnualCap) {
|
||||
return {
|
||||
上限: cap.cap,
|
||||
会变: varyingAnnualReasons(cap).map(({ reason }) => reason),
|
||||
缺少: [...new Set(dependencyLabels(cap.missing_required.filter(({ state }) => state !== "varies").map(({ id }) => id)))],
|
||||
需说明: dependencyLabels(cap.must_disclose),
|
||||
};
|
||||
}
|
||||
|
||||
export function annualDependencyReasons(cap: AnnualCap): string[] {
|
||||
const evidence = gradeEvidence(cap);
|
||||
return [...evidence.会变, ...evidence.缺少.map((label) => `缺少${label}`)];
|
||||
}
|
||||
|
||||
function uniqueAnnualReasons(reasons: readonly string[]): string {
|
||||
const prefix = "暂不能判断:";
|
||||
const joined = new Set<string>();
|
||||
const other = new Set<string>();
|
||||
for (const reason of reasons) {
|
||||
if (reason.startsWith(prefix)) {
|
||||
for (const fact of reason.slice(prefix.length).replace(/。$/, "").split(",")) {
|
||||
if (fact) joined.add(fact);
|
||||
}
|
||||
} else {
|
||||
other.add(reason);
|
||||
}
|
||||
}
|
||||
if (joined.size) other.add(`${prefix}${[...joined].join(",")}。`);
|
||||
return [...other].join("\n");
|
||||
}
|
||||
|
||||
export const annualRating = {
|
||||
@@ -89,6 +156,6 @@ export function remainingTableGrade(rows: readonly (Row | undefined)[]): Row {
|
||||
const reasons = rated.flatMap(({ gradeReason }) => typeof gradeReason === "string" && gradeReason ? [gradeReason] : []);
|
||||
return {
|
||||
grade: rated.some(({ grade }) => grade === "D") ? "D" : rated[0]?.grade,
|
||||
gradeReason: [...new Set(reasons)].join("\n"),
|
||||
gradeReason: uniqueAnnualReasons(reasons),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { ANNUAL_CLAIMS, ANNUAL_CLAIM_LABELS, annualCap, annualParagraph, annualRating, dependencyLabels, gradeEvidence, weakestCap,
|
||||
import { ANNUAL_CLAIMS, ANNUAL_CLAIM_LABELS, annualCap, annualParagraph, annualRating, gradeEvidence, varyingAnnualReasons, weakestCap,
|
||||
type AnnualCap, type AnnualClaim } from "./annual-report-grade.ts";
|
||||
|
||||
import {
|
||||
@@ -690,7 +690,7 @@ const WRITING_RULES = [
|
||||
"- 术语可以用,但第一次出现时用半句话解释,例如「Muntha(每年顺移一宫的年度敏感点)落在年盘第 10 宫」「Mudda(年内按月亮星宿分的计时)」。不要把术语堆成清单。",
|
||||
"- 应期双轨:本命计时看 Vimshottari 和 Narayana 两套,各自判断后再对照。两套方向一致就说一致;不一致就把两边都写出来,不挑一边。年内再用 Mudda / Patyayini 与年盘解释,它们不改写本命两轨的判断。",
|
||||
"- 状态照实保留:材料里标 parameter_sensitive(参数敏感,如 Saham、Varsha Narayana、Vedha)的,写明是参数敏感的参考;标 blocked 或「没有算出」的,写明这一层没有算出,不用它下结论,也不要假装用过。",
|
||||
"- 按每段或每条给 claims 和 grade。等级取 C 或 D,不能高于计算依据给的上限。上限 D 的结论暂不能判断,在 evidence 中写清楚缺少的依据,沿用材料中的中文名称。需说明的项也照实写。把上限和类型留在 JSON 字段中,正文不复述等级。",
|
||||
"- 按每段或每条给 claims 和 grade。等级取 C 或 D,不能高于计算依据给的上限。上限 D 的结论暂不能判断。在 evidence 中逐项写清「缺少」的依据,并原样引用「会变」中的说明和候选。「会变」的依据已经算出,任何段落都不能把它写成缺少或没有算出。需说明的项也照实写。把上限和类型留在 JSON 字段中,正文不复述等级。",
|
||||
"- Tajika 相位和九种结构只说明两颗星之间有联系,不作为判断因素,不写成「因此会成」。五分力和年盘 Shadbala 说一颗星能不能起作用,不说好坏。",
|
||||
"- 不给时间段打顺或紧的总评,不写偏顺、偏紧、有顺有紧、先紧后松、平稳;「基调」只决定建议的方向,写成具体该推什么、该守什么。",
|
||||
"- 可以写月份,例如「5 月下旬」,不写具体哪一天。材料里的日期是天象或运限换段的日子,不等于事情发生的那天;写成「这前后」「从这时起」。",
|
||||
@@ -877,7 +877,22 @@ export type AnnualGradeCorrection = Readonly<{
|
||||
|
||||
function missingReasons(item: Row, cap: AnnualCap): string[] {
|
||||
if (cap.cap !== "D") return [];
|
||||
return dependencyLabels(cap.missing_required).filter((label) => !str(item.evidence).includes(label));
|
||||
const evidence = str(item.evidence);
|
||||
const { 会变, 缺少 } = gradeEvidence(cap);
|
||||
return [
|
||||
...会变.filter((reason) => !evidence.includes(reason)),
|
||||
...缺少.filter((label) => !evidence.includes(label)).map((label) => `缺少${label}`),
|
||||
];
|
||||
}
|
||||
|
||||
const UNAVAILABLE_WORDS = "缺少|缺失|没有算出|没算出|未算出|没有计算|未计算|无法计算";
|
||||
|
||||
function correctedVariation(text: string, cap: AnnualCap): string {
|
||||
return varyingAnnualReasons(cap).reduce((result, { label, reason }) => {
|
||||
const escapedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const wrong = new RegExp(`(?<!不是|并非)(?:${UNAVAILABLE_WORDS})\\s*${escapedLabel}|${escapedLabel}\\s*(?:尚|仍|还)?(?:${UNAVAILABLE_WORDS})`, "g");
|
||||
return result.replace(wrong, reason.split("(", 1)[0]);
|
||||
}, text);
|
||||
}
|
||||
|
||||
/** Apply the deterministic fallback only after the section's rewrite. */
|
||||
@@ -894,11 +909,13 @@ export function repairAnnualGrades(entry: AnnualPlanEntry, value: unknown): { bo
|
||||
}
|
||||
const absent = missingReasons(item, cap);
|
||||
if (absent.length) {
|
||||
const reason = `暂不能判断:缺少${absent.join("、")}。`;
|
||||
for (const part of selected.filter((part) => missingReasons(item, part.cap).length)) {
|
||||
corrections.push({ action: "reason_appended", section: entry.id, item: id, claim: part.claim, reason });
|
||||
}
|
||||
const affected = selected.find((part) => missingReasons(item, part.cap).length)?.claim ?? claim;
|
||||
const reason = `暂不能判断:${absent.join(",")}。`;
|
||||
item.gradeReason = reason;
|
||||
corrections.push({ action: "reason_appended", section: entry.id, item: id, claim: affected, reason });
|
||||
}
|
||||
for (const [field, content] of Object.entries(item)) {
|
||||
if (typeof content === "string") item[field] = correctedVariation(content, cap);
|
||||
}
|
||||
}
|
||||
return { body, corrections };
|
||||
@@ -936,12 +953,15 @@ export function gateSection(entry: AnnualPlanEntry, body: unknown, allowedWindow
|
||||
const ids = rows(value.rows).map((item) => str(item.row_id));
|
||||
if (ids.join("|") !== (entry.rowIds ?? []).join("|")) failures.push("rows_mismatch");
|
||||
}
|
||||
for (const { item, claim, claims, limits, selected } of ratedParts(entry, value)) {
|
||||
for (const { item, id, claim, claims, limits, selected, cap } of ratedParts(entry, value)) {
|
||||
if (!claims.includes(claim) || claims.some((other) => !limits[other])) failures.push(`claim_mismatch:${claim}`);
|
||||
for (const part of selected) {
|
||||
if (str(item.grade) < part.cap.cap) failures.push(`grade_above_cap:${part.claim}`);
|
||||
if (missingReasons(item, part.cap).length) failures.push(`d_without_reason:${part.claim}`);
|
||||
}
|
||||
if (Object.values(item).some((content) => typeof content === "string" && correctedVariation(content, cap) !== content)) {
|
||||
failures.push(`incorrect_variation:${id}`);
|
||||
}
|
||||
}
|
||||
if (entry.kind === "windows" && rows(value.items).some((item) => !allowedWindowIds.includes(str(item.window_id)))) failures.push("unknown_window");
|
||||
return [...new Set(failures)];
|
||||
|
||||
@@ -15,6 +15,7 @@ import type { PersonalReportRecord } from "@/lib/personal-report-service-core";
|
||||
import { loadSynastrySubjectBirth, marriageMatchBirthBody } from "@/lib/marriage-match-service";
|
||||
import { SYNASTRY_ORDER_SECTION, synastryDisplaySubjectIds } from "@/lib/synastry-display-order";
|
||||
import { timelineForPair, writeSynastryLanguage, type SynastrySnapshot } from "@/lib/synastry-full-generate";
|
||||
import { currentSynastryTechnicalBlocks } from "@/lib/synastry-full-technical";
|
||||
import type { TimingPeriod } from "@/lib/synastry-full-timeline";
|
||||
|
||||
const API_BASE = process.env.JYOTISH_API_BASE ?? "http://127.0.0.1:5200";
|
||||
@@ -122,7 +123,7 @@ export function publicSynastryView(payload: unknown): SynastrySnapshot | null {
|
||||
sections: zh.sections as SynastrySnapshot["sections"],
|
||||
timeline: zh.timeline as SynastrySnapshot["timeline"],
|
||||
practices: zh.practices as SynastrySnapshot["practices"],
|
||||
technical: zh.technical as SynastrySnapshot["technical"],
|
||||
technical: currentSynastryTechnicalBlocks(zh.technical as SynastrySnapshot["technical"], row.dossier) ?? [],
|
||||
gate: { ok: true, language: "zh" },
|
||||
// 产品 2026-11-07 占星师方案:skill order marker, reading scope and the four event classes.
|
||||
...(zh.structure ? { structure: zh.structure as SynastrySnapshot["structure"] } : {}),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AYANAMSA_OPTIONS } from "@/lib/ayanamsa";
|
||||
import { signZh } from "./chart-view-labels.ts";
|
||||
import { NAKSHATRA_ZH } from "./panchanga-names-zh.ts";
|
||||
import { displayTechniqueAuditLabel } from "./consultation-technique-audit.ts";
|
||||
import { displayTechniqueAuditLabel, displayTechniqueAuditNote, techniqueCalculationStatusLabel } from "./consultation-technique-audit.ts";
|
||||
import { EVENT_OVERLAP_NOTE, eventClassRows } from "./synastry-full-timeline.ts";
|
||||
|
||||
/**
|
||||
@@ -12,26 +12,26 @@ export type TechnicalBlock = Readonly<{
|
||||
id: "parameters" | "structures" | "contacts" | "timing" | "traditional" | "execution";
|
||||
title: string;
|
||||
lines: readonly string[];
|
||||
precisionAudit?: readonly { method: string; calculation: string; usage: string }[];
|
||||
audit?: readonly Readonly<{ title: string; rows: readonly AuditRow[] }>[];
|
||||
}>;
|
||||
|
||||
const STATUS_LABELS: Readonly<Record<string, string>> = {
|
||||
executed: "已执行",
|
||||
ready_for_comparison: "已执行",
|
||||
present: "已执行",
|
||||
used: "已执行",
|
||||
available: "已执行",
|
||||
passed: "已执行",
|
||||
parameter_sensitive: "参数敏感",
|
||||
partial: "参数敏感",
|
||||
weak: "参数敏感",
|
||||
observation_only: "参数敏感",
|
||||
not_applicable: "不适用",
|
||||
not_used: "不适用",
|
||||
not_used_for_date_intersection: "不适用",
|
||||
// E5b: a layer that could not run says so in Chinese, not as a raw code (BUG-1679).
|
||||
blocked: "无法计算",
|
||||
not_available: "无法计算",
|
||||
type AuditRow = Readonly<{ method: string; calculation: string; usage: string }>;
|
||||
const VERIFICATION_LINES = ["网上资料核对:未完成", "真实案例校准:未完成"];
|
||||
|
||||
const AUDIT_REASONS: Readonly<Record<string, string>> = {
|
||||
birth_time_window_varies: "出生时间误差内会变",
|
||||
solar_day_window_unavailable: "无法确定出生时刻所在的日出日落区间",
|
||||
sunrise_or_sunset_unavailable_for_location_date: "出生地当日没有可用的日出或日落计算",
|
||||
saham_daynight_requires_wgs84_location_and_timezone: "缺少计算日出日落所需的地点或时区",
|
||||
saham_inputs_unavailable: "缺少 Saham 所需的盘面输入",
|
||||
saham_calculation_failed: "Saham 计算未完成",
|
||||
};
|
||||
|
||||
const NOT_APPLICABLE: Readonly<Record<string, string>> = {
|
||||
"Niryaana Shoola Dasha": "此技法用于寿元,不用于关系应期",
|
||||
"optional 27-nakshatra Shukuyo narrative layer": "宿曜属于单独的文化解读",
|
||||
"optional Western synastry/composite/Davison layer": "本命西洋盘不能替代两人的西洋合盘",
|
||||
"Prashna context when a real question chart was supplied": "本报告没有用于问卦的提问时刻盘",
|
||||
};
|
||||
|
||||
function record(value: unknown): Record<string, unknown> | null {
|
||||
@@ -42,12 +42,6 @@ function text(value: unknown): string {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
|
||||
function statusLabel(value: unknown): string {
|
||||
const raw = text(value);
|
||||
if (!raw) return "未标明";
|
||||
return STATUS_LABELS[raw.toLowerCase()] ?? raw;
|
||||
}
|
||||
|
||||
function named(value: unknown): string {
|
||||
if (typeof value === "string") return value.trim();
|
||||
const row = record(value);
|
||||
@@ -55,22 +49,69 @@ function named(value: unknown): string {
|
||||
return text(row.planet) || text(row.sign) || text(row.name) || text(row.lord);
|
||||
}
|
||||
|
||||
export function executionBasisLines(receipt: unknown): string[] {
|
||||
const row = record(receipt) ?? {};
|
||||
return [
|
||||
...linesOf(row.individual_technique_audit),
|
||||
...linesOf(row.pair_execution_tasks),
|
||||
];
|
||||
function reasonText(value: unknown): string {
|
||||
const raw = text(value);
|
||||
const label = AUDIT_REASONS[raw] ?? displayTechniqueAuditNote(raw);
|
||||
return /\p{Script=Han}/u.test(label) ? label.replace(/\s*·\s*/g, ",") : "";
|
||||
}
|
||||
|
||||
function linesOf(value: unknown): string[] {
|
||||
function auditRow(method: string, item: Record<string, unknown>): AuditRow {
|
||||
const display = displayTechniqueAuditLabel(method).replaceAll("_", " ").replace(/\s*·\s*/g, ",");
|
||||
const status = text(item.status).toLowerCase();
|
||||
const reasonLabel = reasonText(item.reason || item.note);
|
||||
const reasons = [reasonLabel];
|
||||
if (item.reason === "birth_time_window_varies") {
|
||||
return { method: display, calculation: "参数敏感", usage: `只作观察。${reasonLabel}` };
|
||||
}
|
||||
if (status === "ready_for_comparison") return { method: display, calculation: "输入已齐", usage: "供写作参考" };
|
||||
if (["executed", "present", "used", "available", "passed"].includes(status)) {
|
||||
return { method: display, calculation: techniqueCalculationStatusLabel("executed"), usage: "供写作参考" };
|
||||
}
|
||||
if (["parameter_sensitive", "partial", "weak", "observation_only"].includes(status)) {
|
||||
return { method: display, calculation: status === "partial" ? techniqueCalculationStatusLabel("partial") : "参数敏感", usage: "只作观察" };
|
||||
}
|
||||
if (["not_applicable", "not_used", "not_used_for_date_intersection"].includes(status)) {
|
||||
reasons.push(NOT_APPLICABLE[method] || "该技法不在本次对照范围");
|
||||
return { method: display, calculation: techniqueCalculationStatusLabel("not_applicable"), usage: `未使用。${reasons.find(Boolean)}` };
|
||||
}
|
||||
if (Array.isArray(item.required_inputs)) {
|
||||
for (const raw of item.required_inputs) {
|
||||
const input = record(raw);
|
||||
if (input?.status !== "blocked") continue;
|
||||
if (input.person_a_status === "blocked") reasons.push(`甲方${reasonText(input.person_a_reason) || "缺少所需的计算结果"}`);
|
||||
if (input.person_b_status === "blocked") reasons.push(`乙方${reasonText(input.person_b_reason) || "缺少所需的计算结果"}`);
|
||||
}
|
||||
}
|
||||
const reason = [...new Set(reasons.filter(Boolean))].join(",") || "回执没有可用的计算结果";
|
||||
const calculation = status ? techniqueCalculationStatusLabel("blocked") : "未标明";
|
||||
return { method: display, calculation, usage: `未使用。${reason}` };
|
||||
}
|
||||
|
||||
function receiptRows(value: unknown, side?: "person_a" | "person_b"): AuditRow[] {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value.flatMap((row) => {
|
||||
const item = record(row);
|
||||
if (!item) return [];
|
||||
const label = text(item.technique) || text(item.task) || text(item.label) || text(item.lane);
|
||||
if (!label) return [];
|
||||
return [`${label}:${statusLabel(item.status)}`];
|
||||
const method = text(item?.technique || item?.task || item?.label || item?.lane);
|
||||
return item && method ? [auditRow(method, (side && record(item[side])) || item)] : [];
|
||||
});
|
||||
}
|
||||
|
||||
export function synastryExecutionAudit(receipt: unknown): NonNullable<TechnicalBlock["audit"]> {
|
||||
const source = record(receipt);
|
||||
return [
|
||||
{ title: "甲方", rows: receiptRows(source?.individual_technique_audit, "person_a") },
|
||||
{ title: "乙方", rows: receiptRows(source?.individual_technique_audit, "person_b") },
|
||||
{ title: "两盘对照", rows: receiptRows(source?.pair_execution_tasks) },
|
||||
].filter(({ rows }) => rows.length);
|
||||
}
|
||||
|
||||
export function currentSynastryTechnicalBlocks(blocks: readonly TechnicalBlock[] | undefined, dossier: unknown) {
|
||||
const packet = record(dossier);
|
||||
if (!record(packet?.birth_precision)) return blocks;
|
||||
return blocks?.map((block) => {
|
||||
if (block.id !== "execution" || block.audit) return block;
|
||||
const audit = synastryExecutionAudit(packet?.execution_receipt);
|
||||
return audit.length ? { id: block.id, title: block.title, lines: VERIFICATION_LINES, audit } : block;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,25 +220,6 @@ export function precisionEvidence(dossier: unknown, language: "zh" | "en"): stri
|
||||
: `${affected.join(" / ")}. These layers vary within the birth-time window.`;
|
||||
}
|
||||
|
||||
function precisionAuditRows(receipt: Record<string, unknown>) {
|
||||
const usage = "出生时间误差内会变,只作观察";
|
||||
const individual = Array.isArray(receipt.individual_technique_audit) ? receipt.individual_technique_audit : [];
|
||||
const pairs = Array.isArray(receipt.pair_execution_tasks) ? receipt.pair_execution_tasks : [];
|
||||
return [
|
||||
...individual.flatMap((value) => {
|
||||
const item = record(value);
|
||||
const method = displayTechniqueAuditLabel(text(item?.technique));
|
||||
return [["person_a", "甲方"], ["person_b", "乙方"]].flatMap(([side, label]) =>
|
||||
record(item?.[side])?.reason === "birth_time_window_varies"
|
||||
? [{ method: `${label} ${method}`, calculation: "参数敏感", usage }] : []);
|
||||
}),
|
||||
...pairs.flatMap((value) => {
|
||||
const item = record(value);
|
||||
return item?.reason === "birth_time_window_varies" ? [{ method: text(item.task), calculation: "参数敏感", usage }] : [];
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
/** Seven kutas, each with its own ceiling; Varna (caste) is not scored. */
|
||||
const KUTAS: ReadonlyArray<readonly [key: string, label: string, max: number]> = [
|
||||
["Vashya", "Vashya(相互牵引)", 2],
|
||||
@@ -462,14 +484,12 @@ export function buildTechnicalBasis(input: Readonly<{
|
||||
...(alignment ? [text(alignment.status) === "same_profile"
|
||||
? "两盘口径:两人用同一岁差与交点"
|
||||
: `两盘口径:两人档案的岁差或交点不同,合盘统一用 ${text(used?.ayanamsa) || "lahiri"} / ${text(used?.node_mode) || "mean"}`] : []),
|
||||
...(scope ? [`结论范围:${text(scope.status) === "full" ? "可以写完整结论" : text(scope.status) === "limited" ? `主链对照有未闭合项,只写条件性结论(${text(scope.reason)})` : "两盘口径不一致,不出结论"}`] : []),
|
||||
...(scope ? [`结论范围:${text(scope.status) === "full" ? "可以写完整结论" : text(scope.status) === "limited" ? "主链对照有未闭合项,只写条件性结论" : "两盘口径不一致,不出结论"}`] : []),
|
||||
];
|
||||
const eventLines = eventClassRows(dossier, input.names).map((row) => `${row.title}:${row.status}${row.windows.length ? `;候选 ${row.windows.join("、")}` : ""};${row.people.join(";")}`);
|
||||
// 原值:execution 末尾一行「外部资料与真实案例核对:未进行,本报告是计算层归纳」
|
||||
// 新值:删掉这一行;回执里的对应审计数据仍在后台
|
||||
// 原因:产品负责人 2026-11-08:用户可见文字不出现联网/外部核验字样,后台保留
|
||||
const precisionAudit = precisionAuditRows(receipt);
|
||||
const execution = [...executionBasisLines(receipt)];
|
||||
// 原值:没有公开核验行。新值:在计算依据附录中分列两项未完成。
|
||||
// 原因:产品负责人 2026-11-12 决定附录照实列出,正文和追问仍沿用 BUG-1794。
|
||||
const audit = synastryExecutionAudit(receipt);
|
||||
return [
|
||||
{ id: "parameters", title: "计算参数", lines: [...parameters, ...pairLines] },
|
||||
{ id: "structures", title: "各自的婚恋结构", lines: structure },
|
||||
@@ -479,6 +499,6 @@ export function buildTechnicalBasis(input: Readonly<{
|
||||
...(eventLines.length > 0 ? [...eventLines, EVENT_OVERLAP_NOTE.zh] : []),
|
||||
] },
|
||||
{ id: "traditional", title: "传统配对参考", lines: [...lunarNotes, ...traditional] },
|
||||
{ id: "execution", title: "技法执行情况", lines: execution, ...(precisionAudit.length ? { precisionAudit } : {}) },
|
||||
{ id: "execution", title: "技法执行情况", lines: VERIFICATION_LINES, audit },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
type SynastryAskSectionId,
|
||||
type SynastrySectionId,
|
||||
} from "@/lib/synastry-full-sections";
|
||||
import { currentSynastryTechnicalBlocks, type TechnicalBlock } from "@/lib/synastry-full-technical";
|
||||
|
||||
export const SYNASTRY_CHAT_CHAR_BUDGET = 20_000;
|
||||
|
||||
@@ -12,7 +13,7 @@ type LanguageBody = {
|
||||
sections?: Array<{ id?: string; title?: string; text?: string; reasons?: Array<{ plain?: string; basis?: string }> }>;
|
||||
timeline?: Array<{ id?: string; phase?: string; text?: string; basis?: string }>;
|
||||
practices?: Array<{ text?: string }>;
|
||||
technical?: Array<{ id?: string; title?: string; lines?: string[] }>;
|
||||
technical?: TechnicalBlock[];
|
||||
events?: Array<Record<string, unknown>>;
|
||||
};
|
||||
|
||||
@@ -58,6 +59,22 @@ function timingLines(payload: Record<string, unknown>): unknown {
|
||||
return Object.keys(picked).length > 0 ? picked : null;
|
||||
}
|
||||
|
||||
function technicalLines(block: TechnicalBlock): string[] {
|
||||
if (block.id === "execution" && block.audit?.length) {
|
||||
const lines: string[] = [];
|
||||
const rowCount = Math.max(...block.audit.map(({ rows }) => rows.length));
|
||||
for (let index = 0; index < rowCount && lines.length < 12; index += 1) {
|
||||
for (const { title, rows } of block.audit) {
|
||||
const row = rows[index];
|
||||
if (row) lines.push(`${title} ${row.method}:计算 ${row.calculation},在本报告中 ${row.usage}`);
|
||||
if (lines.length === 12) return lines;
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
return (block.lines ?? []).filter((line) => !/网上资料核对|真实案例校准/.test(line)).slice(0, 12);
|
||||
}
|
||||
|
||||
export function synastrySectionMaterial(input: {
|
||||
payload: unknown;
|
||||
sectionId: SynastrySectionId;
|
||||
@@ -100,10 +117,11 @@ export function synastrySectionMaterial(input: {
|
||||
}
|
||||
if (input.includeTechnical) {
|
||||
const blocks = (record(payload.zh)?.technical ?? body?.technical) as LanguageBody["technical"];
|
||||
material.technical = (blocks ?? []).map((block) => ({
|
||||
const current = currentSynastryTechnicalBlocks(blocks, payload.dossier);
|
||||
material.technical = (current ?? []).map((block) => ({
|
||||
id: block.id ?? "",
|
||||
title: block.title ?? "",
|
||||
lines: (block.lines ?? []).slice(0, 12),
|
||||
lines: technicalLines(block),
|
||||
}));
|
||||
}
|
||||
return fitSynastryMaterial(material, 16_000);
|
||||
|
||||
@@ -118,7 +118,6 @@ test("every paid route refuses a frozen account before doing work", () => {
|
||||
for (const path of [
|
||||
"../src/app/api/consult/route.ts",
|
||||
"../src/app/api/reports/route.ts",
|
||||
"../src/app/api/synastry/route.ts",
|
||||
]) {
|
||||
const source = read(path);
|
||||
assert.match(source, /refuseWhenAccountDeletionPending\(/, path);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { AnnualReportView } from "../src/components/annual/annual-report-page";
|
||||
import { buildAnnualExportBlocks } from "../src/lib/annual-report-export";
|
||||
import { annualCap, dependencyLabels, type AnnualClaim } from "../src/lib/annual-report-grade";
|
||||
import { annualCap, annualDependencyReasons, remainingTableGrade, type AnnualClaim } from "../src/lib/annual-report-grade";
|
||||
import { AnnualGateError, writeAnnualReport, type AnnualSnapshot } from "../src/lib/annual-report-generate";
|
||||
import { buildAnnualPlan, gateSection } from "../src/lib/annual-report-sections";
|
||||
import { EMPTY_ANNUAL_SITUATION } from "../src/lib/annual-report-shared";
|
||||
@@ -15,7 +15,9 @@ import { evidenceGradeTag } from "../src/lib/personal-report-reading-contract";
|
||||
const fixture = (name: string) => JSON.parse(readFileSync(new URL(`./fixtures/${name}.json`, import.meta.url), "utf8"));
|
||||
const facts = fixture("annual-report-facts").facts;
|
||||
const grades = fixture("annual-report-grade-20261114");
|
||||
grades.annual_domain_career = fixture("annual-report-d10-variation").career;
|
||||
facts.cards.evidence_grades = grades;
|
||||
const careerVariation = "事业分盘上升在出生时间误差内会换星座(可能是水瓶座或双鱼座)";
|
||||
const situation = EMPTY_ANNUAL_SITUATION;
|
||||
const plan = buildAnnualPlan(facts, situation);
|
||||
const input = {
|
||||
@@ -30,8 +32,8 @@ function writeBody(sectionId: string, overrate = false) {
|
||||
const rating = (rowId?: string): { claims: AnnualClaim[]; grade: string; evidence: string } => {
|
||||
const { claim, cap, rows } = entry.grade!;
|
||||
const limit = (rowId && rows?.[rowId]) || cap;
|
||||
const missing = dependencyLabels(limit.missing_required);
|
||||
return { claims: [claim], grade: limit.cap, evidence: missing.length ? `缺少${missing.join("、")}。` : "参考本命运限。" };
|
||||
const reasons = annualDependencyReasons(limit);
|
||||
return { claims: [claim], grade: limit.cap, evidence: reasons.length ? `${reasons.join(",")}。` : "参考本命运限。" };
|
||||
};
|
||||
if (entry.kind === "close") return { line: "可以先做好手上的事。" };
|
||||
if (entry.kind === "windows") return { items: entry.windowIds!.map((id) => ({
|
||||
@@ -52,7 +54,10 @@ test("annual writing retries once, then clamps and adds the missing reason to th
|
||||
const { snapshot } = await writeAnnualReport({ ...input, write: async (request) => {
|
||||
requests.push(request);
|
||||
const body = writeBody(request.sectionId, request.sectionId === "overview");
|
||||
if (request.sectionId === "career" && "evidence" in body) body.evidence = "有本命运限的记录。";
|
||||
if (request.sectionId === "career" && "evidence" in body) {
|
||||
body.evidence = "有本命运限的记录。缺少事业分盘上升。";
|
||||
body.text = "事业分盘上升没有算出。";
|
||||
}
|
||||
return { body, inputTokens: 0, outputTokens: 0 };
|
||||
} });
|
||||
assert.equal(snapshot.version, 2);
|
||||
@@ -67,11 +72,17 @@ test("annual writing retries once, then clamps and adds the missing reason to th
|
||||
assert.equal(career.length, 2);
|
||||
assert.match(overview[1].user, /grade_above_cap:annual_overview/);
|
||||
assert.match(career[1].user, /d_without_reason:annual_domain_career/);
|
||||
assert.match(career[1].user, /incorrect_variation:1/);
|
||||
assert.ok(career[0].user.includes(`"会变":["${careerVariation}"],"缺少":[]`));
|
||||
assert.doesNotMatch(career[0].user, /缺少事业分盘上升|事业分盘上升没有算出/);
|
||||
assert.match(career[0].system, /「会变」的依据已经算出,任何段落都不能把它写成缺少或没有算出/);
|
||||
assert.ok(snapshot.gradeCorrections.some((entry) => entry.action === "grade_clamped"
|
||||
&& entry.claim === "annual_overview" && entry.from === "B" && entry.to === "C"));
|
||||
assert.ok(snapshot.gradeCorrections.some((entry) => entry.action === "reason_appended"
|
||||
&& entry.claim === "annual_domain_career" && entry.reason.includes("事业分盘上升")));
|
||||
&& entry.claim === "annual_domain_career" && entry.reason === `暂不能判断:${careerVariation}。`));
|
||||
assert.equal((snapshot.sections.overview as { paragraphs: { grade: string }[] }).paragraphs[0].grade, "C");
|
||||
const appendix = snapshot.appendix.find(({ id }) => id === "evidence-grades");
|
||||
assert.ok(appendix?.lines.includes(`工作:D,${careerVariation}`));
|
||||
|
||||
const html = renderToStaticMarkup(<AnnualReportView snapshot={snapshot} generating={false} />);
|
||||
const markdown = buildAnnualExportBlocks(snapshot).map((block) => block.text).join("\n");
|
||||
@@ -82,7 +93,8 @@ test("annual writing retries once, then clamps and adds the missing reason to th
|
||||
assert.match(rendered, /证据等级上限/);
|
||||
assert.ok(rendered.includes(evidenceGradeTag("C")));
|
||||
assert.ok(rendered.includes(evidenceGradeTag("D")));
|
||||
assert.match(rendered, /暂不能判断:缺少事业分盘上升/);
|
||||
assert.ok(rendered.includes(`暂不能判断:${careerVariation}`));
|
||||
assert.doesNotMatch(rendered, /缺少事业分盘上升|事业分盘上升没有算出/);
|
||||
assert.doesNotMatch(rendered, /_|把握等级|·/);
|
||||
assert.equal([...rendered.matchAll(/证据等级 [CD]/g)].length, expectedLineCount);
|
||||
}
|
||||
@@ -147,7 +159,7 @@ test("the table layout keeps the weakest remaining grade below the rows and omit
|
||||
|
||||
test("mixed claims use the most restrictive cap and certainty checks still apply at D", async () => {
|
||||
const entry = plan.find(({ id }) => id === "overview")!;
|
||||
const value = { paragraphs: [{ text: "还有待核对的地方。", evidence: "缺少事业分盘上升。",
|
||||
const value = { paragraphs: [{ text: "还有待核对的地方。", evidence: careerVariation,
|
||||
claims: ["annual_overview", "annual_domain_career"], grade: "C" }] };
|
||||
assert.deepEqual(gateSection(entry, value, []), ["grade_above_cap:annual_domain_career"]);
|
||||
assert.deepEqual(gateSection(entry, { paragraphs: [{ text: "运限 · dates_wide。", evidence: "grade。",
|
||||
@@ -163,6 +175,27 @@ test("mixed claims use the most restrictive cap and certainty checks still apply
|
||||
}) }), (error: unknown) => error instanceof AnnualGateError && error.failures.includes("certainty_word:text"));
|
||||
});
|
||||
|
||||
test("combining claims and table rows lists each limiting fact once", async () => {
|
||||
const { snapshot } = await writeAnnualReport({ ...input, write: async ({ sectionId }) => {
|
||||
const body = writeBody(sectionId);
|
||||
if (sectionId === "overview" && "paragraphs" in body && body.paragraphs) {
|
||||
body.paragraphs[0].claims = ["annual_overview", "annual_domain_career", "annual_domain_relationship"];
|
||||
}
|
||||
return { body, inputTokens: 0, outputTokens: 0 };
|
||||
} });
|
||||
assert.equal(snapshot.version, 2);
|
||||
if (snapshot.version !== 2) throw new Error("expected a rated snapshot");
|
||||
const [correction] = snapshot.gradeCorrections.filter(({ section, action }) => section === "overview" && action === "reason_appended");
|
||||
assert.equal(snapshot.gradeCorrections.filter(({ section }) => section === "overview").length, 2);
|
||||
assert.ok(correction.action === "reason_appended" && correction.reason.includes(careerVariation) && correction.reason.includes("九分盘上升"));
|
||||
const reason = correction.reason;
|
||||
const combined = remainingTableGrade([
|
||||
{ grade: "D", gradeReason: reason },
|
||||
{ grade: "D", gradeReason: `暂不能判断:${careerVariation},缺少年盘。` },
|
||||
]);
|
||||
assert.deepEqual(combined, { grade: "D", gradeReason: reason.replace(/。$/, ",缺少年盘。") });
|
||||
});
|
||||
|
||||
test("version one reports still render their original paragraphs and omit grades in Markdown", () => {
|
||||
const snapshot: AnnualSnapshot = {
|
||||
kind: "annual_report_snapshot", version: 1, status: "ready", subject: input.subject,
|
||||
|
||||
@@ -16,7 +16,9 @@ test("the annual window cannot raise confidence for matching Vimshottari and Nar
|
||||
return tracks.vimshottari === "support" && tracks.narayana === "support";
|
||||
}));
|
||||
assert.equal(annualCap(captured, "annual_domain_relationship").cap, "D");
|
||||
assert.deepEqual(annualCap(captured, "annual_domain_relationship").missing_required, ["D9"]);
|
||||
assert.deepEqual(annualCap(captured, "annual_domain_relationship").missing_required, [{
|
||||
id: "D9", state: "varies", candidates: [{ lagna_sign: "Scorpio" }, { lagna_sign: "Sagittarius" }, { lagna_sign: "Capricorn" }],
|
||||
}]);
|
||||
});
|
||||
|
||||
test("the annual appendix describes candidate branches separately as conditional references", () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "../src/components/annual/annual-report-page.tsx";
|
||||
import { reportRowTitle } from "../src/components/personal-report/personal-report-center.tsx";
|
||||
import { AnnualGateError, writeAnnualReport, type AnnualSectionWriter } from "../src/lib/annual-report-generate.ts";
|
||||
import { dependencyLabels } from "../src/lib/annual-report-grade.ts";
|
||||
import { annualDependencyReasons } from "../src/lib/annual-report-grade.ts";
|
||||
import {
|
||||
buildAnnualPlan,
|
||||
gateSection,
|
||||
@@ -48,8 +48,8 @@ const read = (path: string) => readFileSync(new URL(path, root), "utf8");
|
||||
function rated(entry: AnnualPlanEntry, evidence: string, id?: string) {
|
||||
const plan = entry.grade!;
|
||||
const cap = (id ? plan.rows?.[id] : undefined) ?? plan.cap;
|
||||
const missing = dependencyLabels(cap.missing_required);
|
||||
return { evidence: missing.length ? `${evidence} 缺少${missing.join("、")}。` : evidence, claims: [plan.claim], grade: cap.cap };
|
||||
const reasons = annualDependencyReasons(cap);
|
||||
return { evidence: [evidence, ...reasons.map((reason) => `${reason}。`)].join(" "), claims: [plan.claim], grade: cap.cap };
|
||||
}
|
||||
|
||||
function prose(entry: AnnualPlanEntry, text: string, evidence = "木星落在第四宫。") {
|
||||
|
||||
@@ -66,52 +66,6 @@ test("cloud save failures preserve the server error message", () => {
|
||||
assert.match(source, /throw new Error\(payload\?\.error \|\| "cloud_chart_profile_save_failed"\);/);
|
||||
});
|
||||
|
||||
test("synastry selection exposes a pending state while the evidence packet is computed", () => {
|
||||
assert.match(source, /const \[synastryPendingId, setSynastryPendingId\] = useState<string \| null>\(null\);/);
|
||||
assert.match(source, /setSynastryPendingId\(record\.id\);/);
|
||||
assert.match(source, /finally \{\s*setSynastryPendingId\(null\);\s*\}/);
|
||||
// 原值 / 新值 / 原因:死面板 disabled/按钮 spinner / hook 重入门与既有通知 / 锁实际合盘请求入口。
|
||||
assert.match(source, /if \(synastryPendingId\) return;/);
|
||||
assert.match(source, /正在计算基础合盘证据,请稍候。/);
|
||||
});
|
||||
|
||||
test("relationship intent selects domain-specific evidence instead of treating every pairing as romance", () => {
|
||||
const route = readFileSync(new URL("../src/app/api/synastry/route.ts", import.meta.url), "utf8");
|
||||
assert.match(source, /商业合作/);
|
||||
assert.match(source, /亲友\/家庭/);
|
||||
assert.match(source, /其他关系/);
|
||||
assert.match(source, /relationshipType: SynastryRelationshipType/);
|
||||
assert.match(source, /body: JSON\.stringify\(\{ partnerChartProfileId: record\.id, relationshipType \}\)/);
|
||||
assert.doesNotMatch(source, /selfProfile: profile, partnerProfile: record\.profile/);
|
||||
assert.match(route, /partnerChartProfileId/);
|
||||
// 原值: the route selected profiles and the chart_profiles jsonb itself.
|
||||
// 新值: both people are read by loadSubjectBirth.
|
||||
// 原因: D13. The other person's birth is the typed columns. "我" stays the household profile.
|
||||
assert.match(route, /loadSubjectBirth/);
|
||||
assert.doesNotMatch(route, /globalBirthProfileFromStoredChart/);
|
||||
assert.match(route, /consumeUserRequestRateLimit\("synastry"/);
|
||||
assert.match(route, /relationshipType === "business"/);
|
||||
assert.match(route, /divisions: \["D2", "D10", "D11"\]/);
|
||||
assert.match(route, /"D10_Dasamsa"/);
|
||||
assert.match(route, /"D11_Rudramsa"/);
|
||||
assert.match(route, /blockedLayers:/);
|
||||
assert.match(route, /"A10"/);
|
||||
assert.match(route, /"functional_benefic_malefic"/);
|
||||
assert.match(route, /"vimshottari_narayana"/);
|
||||
assert.match(source, /基础商业合作证据筛查/);
|
||||
assert.match(source, /relationshipType === "business"/);
|
||||
});
|
||||
|
||||
|
||||
test("synastry history is replaced by the cloud list and save failures stay in page memory", () => {
|
||||
// Former value: `new Map([...current, ...cloudHistory])` unioned local+cloud
|
||||
// and `writeSynastryHistory(accountId, next)` on cloud save failure.
|
||||
assert.doesNotMatch(source, /new Map\(\[\.\.\.current, \.\.\.cloudHistory\]/);
|
||||
assert.match(source, /未能存入历史/);
|
||||
assert.doesNotMatch(source, /writeSynastryHistory\(/);
|
||||
assert.match(source, /discardLegacyCloudMirrorKeys\(/);
|
||||
});
|
||||
|
||||
test("current chart selection is local and does not overwrite the owner's profile", () => {
|
||||
// 原值: activeChartStorageKey and the "set as current" copy lived in the home surface.
|
||||
// 新值: those symbols are gone from frontend/src. The page profile is not replaced from the archive.
|
||||
@@ -145,7 +99,6 @@ test("other chart details own actions and self details cannot delete", () => {
|
||||
// 原因: D11 removes "set as default".
|
||||
assert.doesNotMatch(charts, /设为默认/);
|
||||
assert.match(charts, /和我合盘/);
|
||||
assert.match(source, /startNewChat\(\{ subjectId: "self" \}\)/);
|
||||
assert.match(charts, /\/synastry\?with=\$\{selected\.id\}/);
|
||||
assert.match(charts, /pendingDelete\?\.id === selected\.id && selected\.role === "other"/);
|
||||
assert.match(source, /partnerChartId: record\.id/);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,6 @@ const chatOwnerSource = [
|
||||
"../src/hooks/use-session-management.ts",
|
||||
"../src/hooks/use-consultation-run.ts",
|
||||
"../src/hooks/use-profile-onboarding.ts",
|
||||
"../src/hooks/use-synastry.ts",
|
||||
].map((path) => readFileSync(new URL(path, import.meta.url), "utf8")).join("\n");
|
||||
|
||||
function sourceBetween(source: string, startMarker: string, endMarker: string) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"sourceCommand": "POST /api/annual/report_facts using the fictional annual-report-facts.json golden with 11:17 and birth_window -4/+8; career cap only.",
|
||||
"career": {
|
||||
"cap": "D",
|
||||
"required": [
|
||||
{
|
||||
"id": "functional",
|
||||
"state": "computed"
|
||||
},
|
||||
{
|
||||
"id": "annual_chart",
|
||||
"state": "computed"
|
||||
},
|
||||
{
|
||||
"id": "vimshottari",
|
||||
"state": "computed"
|
||||
},
|
||||
{
|
||||
"id": "D10",
|
||||
"state": "varies",
|
||||
"candidates": [
|
||||
{
|
||||
"lagna_sign": "Aquarius",
|
||||
"lord_house": 8
|
||||
},
|
||||
{
|
||||
"lagna_sign": "Pisces",
|
||||
"lord_house": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"missing_required": [
|
||||
{
|
||||
"id": "D10",
|
||||
"state": "varies",
|
||||
"candidates": [
|
||||
{
|
||||
"lagna_sign": "Aquarius",
|
||||
"lord_house": 8
|
||||
},
|
||||
{
|
||||
"lagna_sign": "Pisces",
|
||||
"lord_house": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"must_disclose": []
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ const optionalHomeHookFiles = [
|
||||
"../src/hooks/use-session-management.ts",
|
||||
"../src/hooks/use-consultation-run.ts",
|
||||
"../src/hooks/use-profile-onboarding.ts",
|
||||
"../src/hooks/use-synastry.ts",
|
||||
"../src/hooks/use-session-list.ts",
|
||||
"../src/hooks/use-home-shell-registration.ts",
|
||||
// issue #116:会话行的重命名、删除、收藏、转发、排序和删除确认框搬进共用外壳。
|
||||
|
||||
@@ -7,7 +7,7 @@ const readRoot = (path: string) => readFileSync(new URL(path, root), "utf8");
|
||||
const consultationWorkflow = readRoot("frontend/src/mastra/consultation-workflow.ts");
|
||||
// 原值: 读 birth-time-journey-engine-model.ts,断言 /api/active_rectification_* 新值: 读 chart-choice/server.ts,断言 /api/chart_choice/* 原因: 2026-11-06 生时纠正改为选盘页
|
||||
const chartChoice = readRoot("frontend/src/lib/chart-choice/server.ts");
|
||||
const synastry = readRoot("frontend/src/app/api/synastry/route.ts");
|
||||
const synastry = readRoot("frontend/src/lib/synastry-full-run.ts");
|
||||
const apiServer = readRoot("scripts/jyotish_api_server.py");
|
||||
|
||||
test("commercial Jyotish paths resolve to a registered Python handler", () => {
|
||||
@@ -15,14 +15,14 @@ test("commercial Jyotish paths resolve to a registered Python handler", () => {
|
||||
"/api/consultation_workflow",
|
||||
"/api/chart_choice/packet",
|
||||
"/api/chart_choice/decide",
|
||||
"/api/varga_full",
|
||||
"/api/synastry",
|
||||
"/api/synastry_full_dossier",
|
||||
"/api/synastry_full_reader_gate",
|
||||
]) {
|
||||
assert.match(apiServer, new RegExp(`['\"]${path.replaceAll("/", "\\/")}['\"]`));
|
||||
}
|
||||
assert.match(consultationWorkflow, /\/api\/consultation_workflow/);
|
||||
assert.match(chartChoice, /\/api\/chart_choice\/packet/);
|
||||
assert.match(chartChoice, /\/api\/chart_choice\/decide/);
|
||||
assert.match(synastry, /\/api\/varga_full/);
|
||||
assert.match(synastry, /\/api\/synastry/);
|
||||
assert.match(synastry, /"\/api\/synastry_full_dossier"/);
|
||||
assert.match(synastry, /"\/api\/synastry_full_reader_gate"/);
|
||||
});
|
||||
|
||||
@@ -86,7 +86,8 @@ test("people delete requires known usage and synastry never switches the global
|
||||
// 原因: BUG-1081——本人在星盘档案可编辑(TASK-self-edit-avatar-menu-20260928 S1)
|
||||
assert.match(people, /title=\{editingSelf \? "编辑我的资料" : selectedId \? "编辑人物" : "添加一个人"\}/);
|
||||
assert.doesNotMatch(people, /openPerson\(selected\.id,.*synastry/);
|
||||
assert.match(source("hooks/use-synastry.ts"), /startNewChat\(\{ subjectId: "self" \}\)/);
|
||||
assert.match(people, /\/synastry\?with=/);
|
||||
assert.match(source("components/people-home-links.tsx"), /location\.replace\(`\/synastry\?with=/);
|
||||
});
|
||||
|
||||
test("daily card computes eligibility, calendar and fingerprint from selected profile", () => {
|
||||
|
||||
@@ -51,7 +51,7 @@ test("write and compute APIs enforce their independent product gates", async ()
|
||||
["src/app/api/chart-choice/route.ts", "await chartChoiceCaller("],
|
||||
["src/app/api/chart-choice/packet/route.ts", "await chartChoiceCaller("],
|
||||
["src/app/api/chart-choice/adopt/route.ts", "await chartChoiceCaller("],
|
||||
["src/app/api/synastry/route.ts", 'isProductEnabled("compatibility")'],
|
||||
["src/lib/synastry-full-create.ts", 'isProductEnabled("compatibility")'],
|
||||
["src/app/api/synastry-reports/route.ts", 'isProductEnabled("compatibility")'],
|
||||
["src/app/api/reports/route.ts", 'isProductEnabled("report_center")'],
|
||||
];
|
||||
|
||||
@@ -73,8 +73,15 @@ test("synastry technical basis never shows web-verification wording", () => {
|
||||
contacts: [],
|
||||
timing: [],
|
||||
});
|
||||
assertNoWebWording(blocks.flatMap((block) => [block.title, ...block.lines]).join("\n"), "合盘技法依据");
|
||||
// 回执数据原样保留,只是不再渲染。
|
||||
// #275:11-12 允许在合盘附录列两行固定状态,其余文案仍用原契约。
|
||||
const verification = ["网上资料核对:未完成", "真实案例校准:未完成"];
|
||||
assert.deepEqual(blocks.find(({ id }) => id === "execution")?.lines, verification);
|
||||
assertNoWebWording(blocks.flatMap((block) => [
|
||||
block.title,
|
||||
...block.lines.filter((line) => block.id !== "execution" || !verification.includes(line)),
|
||||
...(block.audit ?? []).flatMap(({ rows }) => rows.flatMap(({ method, calculation, usage }) => [method, calculation, usage])),
|
||||
]).join("\n"), "合盘技法依据的其他文字");
|
||||
// 后台原始核验条目照旧保留。
|
||||
assert.match(JSON.stringify(dossier.execution_receipt), /MEVG/);
|
||||
assert.match(JSON.stringify(dossier.execution_receipt), /Real Case/);
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ test("a stored chart without a clock cannot be used for synastry", () => {
|
||||
|
||||
test("daily and synastry routes share a literal account-birth select string", () => {
|
||||
const daily = readFileSync(new URL("../src/app/api/daily-starlanguage/route.ts", import.meta.url), "utf8");
|
||||
const synastry = readFileSync(new URL("../src/app/api/synastry/route.ts", import.meta.url), "utf8");
|
||||
const synastry = readFileSync(new URL("../src/lib/synastry-full-run.ts", import.meta.url), "utf8");
|
||||
// 原值:…,uncertainty_after_minutes,declared_window_start,declared_window_end
|
||||
// 新值:uncertainty_after_minutes 后多一列 birth_time_uncertainty_known,其余列与顺序不变
|
||||
// 原因:issue #144 T4,选了「不清楚误差」的本人,星盘页上升预检只按所填时间算一次,需要读这一列
|
||||
@@ -100,7 +100,9 @@ test("daily and synastry routes share a literal account-birth select string", ()
|
||||
const subjectBirth = readFileSync(new URL("../src/lib/subject-birth.ts", import.meta.url), "utf8");
|
||||
assert.match(subjectBirth, /select\(ACCOUNT_BIRTH_SELECT\)/);
|
||||
assert.match(daily, /loadSubjectBirth/);
|
||||
assert.match(synastry, /loadSubjectBirth/);
|
||||
const matchService = readFileSync(new URL("../src/lib/marriage-match-service.ts", import.meta.url), "utf8");
|
||||
assert.match(synastry, /loadSynastrySubjectBirth\(input\.admin, input\.admin, input\.report\.userId,/);
|
||||
assert.match(matchService, /function loadSynastrySubjectBirth\([\s\S]*?await loadSubjectBirth\(client, userId, subjectId\)/);
|
||||
assert.doesNotMatch(daily, /accountBirthColumns/);
|
||||
assert.doesNotMatch(synastry, /accountBirthColumns/);
|
||||
assert.doesNotMatch(daily, /\.join\(",\"\)/);
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { SynastryReportView } from "../src/components/synastry/synastry-report-view";
|
||||
import { buildTechnicalBasis } from "../src/lib/synastry-full-technical";
|
||||
import { synastrySectionMaterial } from "../src/lib/synastry-report-material";
|
||||
|
||||
const oldLink = new URL("../src/components/people-home-links.tsx", import.meta.url);
|
||||
const retiredRoute = new URL("../src/app/api/synastry/route.ts", import.meta.url);
|
||||
|
||||
test("old links still reach the current pair picker after the scoring route is retired", () => {
|
||||
assert.match(readFileSync(oldLink, "utf8"), /location\.replace\(`\/synastry\?with=/);
|
||||
assert.throws(() => readFileSync(retiredRoute), { code: "ENOENT" });
|
||||
});
|
||||
|
||||
test("legacy report snapshots still render the saved appendix", () => {
|
||||
const html = renderToStaticMarkup(<SynastryReportView reportId="legacy" snapshot={{
|
||||
names: { a: "甲", b: "乙" },
|
||||
sections: [{ id: "communication", title: "旧版节名", text: "旧报告正文" }],
|
||||
technical: [{ id: "execution", title: "技法执行情况", lines: ["旧版技法回执"] }],
|
||||
}} />);
|
||||
assert.match(html, /旧报告正文/);
|
||||
assert.match(html, /<li>旧版技法回执<\/li>/);
|
||||
assert.doesNotMatch(html, /<table/);
|
||||
});
|
||||
|
||||
test("pair audit identifies the blocked side and keeps partial calculations observational", () => {
|
||||
const execution = buildTechnicalBasis({
|
||||
dossier: { execution_receipt: {
|
||||
individual_technique_audit: [{ technique: "Tajika Yogas", person_a: { status: "partial" }, person_b: { status: "executed" } }],
|
||||
pair_execution_tasks: [{
|
||||
task: "年度对照", status: "blocked",
|
||||
required_inputs: [{ status: "blocked", person_a_status: "executed", person_b_status: "blocked", person_b_reason: "solar_day_window_unavailable" }],
|
||||
}],
|
||||
} },
|
||||
names: { a: "甲", b: "乙" }, contacts: [], timing: [],
|
||||
}).find(({ id }) => id === "execution");
|
||||
assert.equal(execution?.audit?.[0].rows[0].usage, "只作观察");
|
||||
assert.equal(execution?.audit?.[1].rows[0].usage, "供写作参考");
|
||||
assert.equal(execution?.audit?.[2].rows[0].usage, "未使用。乙方无法确定出生时刻所在的日出日落区间");
|
||||
});
|
||||
|
||||
test("the audit tables distinguish comparison readiness and render verification only in the appendix", () => {
|
||||
const basis = buildTechnicalBasis({
|
||||
dossier: { execution_receipt: {
|
||||
individual_technique_audit: [{
|
||||
technique: "Vivah and other Sahams",
|
||||
person_a: { status: "parameter_sensitive" },
|
||||
person_b: { status: "blocked", reason: "solar_day_window_unavailable" },
|
||||
}],
|
||||
pair_execution_tasks: [{ task: "DK cross-comparison", status: "ready_for_comparison" }],
|
||||
} },
|
||||
names: { a: "甲", b: "乙" }, contacts: [], timing: [],
|
||||
});
|
||||
const execution = basis.find(({ id }) => id === "execution")!;
|
||||
const html = renderToStaticMarkup(<SynastryReportView reportId="old-report" snapshot={{
|
||||
names: { a: "甲", b: "乙" },
|
||||
sections: [{ id: "communication", title: "命局承诺", text: "这里是报告正文。" }],
|
||||
technical: [execution],
|
||||
}} />);
|
||||
const [body, appendix] = html.split('<details class="synastry-technical">');
|
||||
assert.match(body, /这里是报告正文/);
|
||||
assert.doesNotMatch(body, /网上资料核对|真实案例校准/);
|
||||
assert.match(appendix, /<th scope="col">方法<\/th><th scope="col">计算<\/th><th scope="col">在本报告中<\/th>/);
|
||||
assert.match(appendix, /<td>输入已齐<\/td><td>供写作参考<\/td>/);
|
||||
assert.match(appendix, /<td>阻塞<\/td><td>未使用。无法确定出生时刻所在的日出日落区间<\/td>/);
|
||||
assert.match(appendix, /网上资料核对:未完成[\s\S]*真实案例校准:未完成/);
|
||||
assert.doesNotMatch(appendix, /_|·|已执行/);
|
||||
});
|
||||
|
||||
test("follow-up material includes at most twelve audit rows across both people and the comparison", () => {
|
||||
const saved = buildTechnicalBasis({
|
||||
dossier: { execution_receipt: {
|
||||
individual_technique_audit: Array.from({ length: 14 }, (_, index) => ({
|
||||
technique: `技法 ${index + 1}`,
|
||||
person_a: { status: "parameter_sensitive", reason: "birth_time_window_varies" },
|
||||
person_b: { status: "executed" },
|
||||
})),
|
||||
pair_execution_tasks: [{ task: "宫位对照", status: "ready_for_comparison" }],
|
||||
} },
|
||||
names: { a: "甲", b: "乙" }, contacts: [], timing: [],
|
||||
});
|
||||
const result = synastrySectionMaterial({ payload: { zh: { technical: saved } }, sectionId: "climate", includeTechnical: true });
|
||||
const technical = result.technical as { id: string; lines: string[] }[];
|
||||
const execution = technical.find(({ id }) => id === "execution")!;
|
||||
assert.equal(execution.lines.length, 12);
|
||||
assert.ok(execution.lines.includes("甲方 技法 1:计算 参数敏感,在本报告中 只作观察。出生时间误差内会变"));
|
||||
assert.ok(execution.lines.includes("乙方 技法 1:计算 已执行,在本报告中 供写作参考"));
|
||||
assert.ok(execution.lines.includes("两盘对照 宫位对照:计算 输入已齐,在本报告中 供写作参考"));
|
||||
assert.doesNotMatch(JSON.stringify(result), /网上资料核对|真实案例校准/);
|
||||
const old = synastrySectionMaterial({ payload: { zh: { technical: [{
|
||||
id: "execution", title: "技法执行情况", lines: ["D1/Rashi:已执行", "网上资料核对:未完成", "真实案例校准:未完成"],
|
||||
}] } }, sectionId: "climate", includeTechnical: true });
|
||||
assert.deepEqual(old.technical, [{ id: "execution", title: "技法执行情况", lines: ["D1/Rashi:已执行"] }]);
|
||||
});
|
||||
@@ -1,103 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import test from "node:test";
|
||||
|
||||
const frontendRoot = fileURLToPath(new URL("../", import.meta.url));
|
||||
const partnerId = "11111111-1111-4111-8111-111111111111";
|
||||
|
||||
function runRoute(script: string): { romance: Record<string, unknown>; business: Record<string, unknown>; maxChart: number; maxVarga: number; chartSkip: boolean } {
|
||||
const result = spawnSync(process.execPath, [
|
||||
"--experimental-test-module-mocks",
|
||||
"--import",
|
||||
"tsx",
|
||||
"--input-type=module",
|
||||
"--eval",
|
||||
script,
|
||||
], { cwd: frontendRoot, encoding: "utf8", timeout: 20000 });
|
||||
assert.equal(result.status, 0, result.stderr || result.stdout);
|
||||
const line = result.stdout.trim().split("\n").at(-1) ?? "{}";
|
||||
return JSON.parse(line);
|
||||
}
|
||||
|
||||
test("synastry charts send skip concurrently and keep the stubbed JSON", () => {
|
||||
const script = String.raw`
|
||||
import { mock } from "node:test";
|
||||
import { pathToFileURL } from "node:url";
|
||||
const moduleUrl = (path) => pathToFileURL(process.cwd() + "/" + path).href;
|
||||
mock.module("server-only", { namedExports: {} });
|
||||
mock.module("@/lib/account-deletion-server", { namedExports: { refuseWhenAccountDeletionPending: async () => null } });
|
||||
mock.module("@/lib/product-access", { namedExports: { isProductEnabled: async () => true } });
|
||||
mock.module("@/lib/request-rate-limit", { namedExports: { consumeUserRequestRateLimit: () => ({ ok: true, retryAfterSeconds: 1 }) } });
|
||||
mock.module("@/lib/supabase/server", { namedExports: { createServerSupabaseClient: async () => ({ auth: { getUser: async () => ({ data: { user: { id: "user-1" } }, error: null }) } }) } });
|
||||
mock.module("@/lib/subject-birth", { namedExports: {
|
||||
ConsultationSubjectError: class ConsultationSubjectError extends Error {},
|
||||
loadSubjectBirth: async () => ({ chartable: true, row: { name: "fixture" } }),
|
||||
} });
|
||||
mock.module("@/lib/server-owned-birth-profile", { namedExports: { globalBirthProfileFromAccountRow: (row) => row } });
|
||||
mock.module("@/lib/global-birth-payloads", { namedExports: {
|
||||
synastryBirthPayload: async () => ({ year: 1990, month: 1, day: 1, hour: 12, minute: 0, lat: 28.6139, lon: 77.209, tz: 5.5, ayanamsa: "lahiri" }),
|
||||
} });
|
||||
const chartBodies = [];
|
||||
const maxInflight = { chart: 0, varga: 0 };
|
||||
const inflight = { chart: 0, varga: 0 };
|
||||
const waiters = { chart: [], varga: [] };
|
||||
globalThis.fetch = async (inputUrl, init) => {
|
||||
const url = String(inputUrl);
|
||||
const body = JSON.parse(String(init.body));
|
||||
const kind = url.endsWith("/api/chart") ? "chart" : url.endsWith("/api/varga_full") ? "varga" : "other";
|
||||
if (kind === "chart") chartBodies.push(body);
|
||||
if (kind === "chart" || kind === "varga") {
|
||||
inflight[kind] += 1;
|
||||
maxInflight[kind] = Math.max(maxInflight[kind], inflight[kind]);
|
||||
await new Promise((resolve) => {
|
||||
waiters[kind].push(resolve);
|
||||
if (waiters[kind].length >= 2) {
|
||||
const pending = waiters[kind].splice(0, 2);
|
||||
pending.forEach((fn) => fn());
|
||||
}
|
||||
});
|
||||
inflight[kind] -= 1;
|
||||
}
|
||||
if (url.endsWith("/api/chart")) {
|
||||
return Response.json({
|
||||
planets: { Moon: { lon: 12.5, sign: "Aries", nakshatra: "Ashwini", nakshatra_pada: 1, nakshatra_lord: "Ketu" } },
|
||||
ascendant: { sign: "Leo" },
|
||||
});
|
||||
}
|
||||
if (url.endsWith("/api/varga_full")) {
|
||||
const divisions = body.divisions || [];
|
||||
if (divisions.includes("D9")) {
|
||||
return Response.json({ source: "engine", result: { D9_Navamsa: { ascendant: { sign: "Virgo" }, planets: { Moon: { sign: "Cancer" }, Venus: { sign: "Taurus" }, Mars: { sign: "Aries" } } } } });
|
||||
}
|
||||
return Response.json({ source: "engine", result: {
|
||||
D2_Hora: { planets: { Moon: { sign: "Taurus" } } },
|
||||
D10_Dasamsa: { ascendant: { sign: "Libra" } },
|
||||
D11_Rudramsa: { planets: { Sun: { sign: "Capricorn" } } },
|
||||
} });
|
||||
}
|
||||
if (url.endsWith("/api/synastry")) return Response.json({ total_score: 18, max_score: 36 });
|
||||
return Response.json({}, { status: 500 });
|
||||
};
|
||||
const { POST } = await import(moduleUrl("src/app/api/synastry/route.ts"));
|
||||
const romanceRes = await POST(new Request("https://example.test/api/synastry", { method: "POST", body: JSON.stringify({ partnerChartProfileId: "${partnerId}", relationshipType: "romance" }) }));
|
||||
const romance = await romanceRes.json();
|
||||
const businessRes = await POST(new Request("https://example.test/api/synastry", { method: "POST", body: JSON.stringify({ partnerChartProfileId: "${partnerId}", relationshipType: "business" }) }));
|
||||
const business = await businessRes.json();
|
||||
console.log(JSON.stringify({ romance, business, maxChart: maxInflight.chart, maxVarga: maxInflight.varga, chartSkip: chartBodies.every((body) => body.skip_vedastro_main_entry_overview === true) && chartBodies.length === 4 }));
|
||||
`;
|
||||
const got = runRoute(script);
|
||||
assert.equal(got.maxChart, 2);
|
||||
assert.equal(got.maxVarga, 2);
|
||||
assert.equal(got.chartSkip, true);
|
||||
assert.equal(got.romance.status, "ok");
|
||||
assert.equal(got.romance.method, "ashtakoot_plus_moon_nakshatra_d9");
|
||||
assert.deepEqual(got.romance.selfChart, {
|
||||
moon: { sign: "Aries", nakshatra: "Ashwini", pada: 1, lord: "Ketu", longitude: 12.5 },
|
||||
d9: { ascendant: { sign: "Virgo" }, moon: { sign: "Cancer" }, venus: { sign: "Taurus" }, mars: { sign: "Aries" }, source: "engine" },
|
||||
});
|
||||
assert.equal((got.romance.relationshipReport as { scoreBand?: string }).scoreBand, "mixed");
|
||||
assert.equal(got.business.status, "ok");
|
||||
assert.equal(got.business.method, "d2_d10_d11_business_screening_partial");
|
||||
assert.equal((got.business.relationshipReport as { scoreBand?: string }).scoreBand, "not_scored");
|
||||
});
|
||||
@@ -156,10 +156,7 @@ test("technical appendix has six program blocks and the fixed closing line", ()
|
||||
timing: ["甲:木星大运 2026-01 至 2028-01"],
|
||||
});
|
||||
assert.deepEqual(blocks.map((block) => block.id), ["parameters", "structures", "contacts", "timing", "traditional", "execution"]);
|
||||
// 原值:blocks[5].lines 末尾是「外部资料与真实案例核对:未进行,本报告是计算层归纳」
|
||||
// 新值:该行删除,执行情况只留回执里的技法依据
|
||||
// 原因:产品负责人 2026-11-08:用户可见文字不出现联网/外部核验字样,后台保留
|
||||
assert.equal(blocks[5]?.lines.some((line) => line.includes("外部资料")), false);
|
||||
assert.deepEqual(blocks[5]?.lines, ["网上资料核对:未完成", "真实案例校准:未完成"]);
|
||||
assert.equal(JSON.stringify(blocks).includes("1879"), false);
|
||||
});
|
||||
|
||||
@@ -515,7 +512,9 @@ test("technical execution lines follow the receipt and raman is named", () => {
|
||||
contacts: [],
|
||||
timing: [],
|
||||
});
|
||||
assert.deepEqual(blocks[5]?.lines.slice(0, 2), ["Niryaana Shoola:不适用", "DK cross-comparison:已执行"]);
|
||||
assert.deepEqual(blocks[5]?.audit?.map(({ title }) => title), ["甲方", "乙方", "两盘对照"]);
|
||||
assert.equal(blocks[5]?.audit?.[0].rows[0].calculation, "不适用");
|
||||
assert.deepEqual(blocks[5]?.audit?.[2].rows[0], { method: "DK cross-comparison", calculation: "输入已齐", usage: "供写作参考" });
|
||||
assert.match(blocks[1]?.lines[0] ?? "", /DK Venus/);
|
||||
// 2026-11-07 原值:/raman_muhurtha_v1/(原样显示规则 id)。新值:显示中文口径说明。
|
||||
// 原因:BUG-1679,传统配对块改成读真实字段并写成中文;Raman 仍然单独点名。
|
||||
@@ -581,7 +580,9 @@ test("BUG-1679: parameters and traditional matching read the dossier's real shap
|
||||
assert.match(traditional, /Raman 口径,甲 火星凶位/);
|
||||
assert.doesNotMatch(traditional, /36|百分|%/);
|
||||
assert.equal(JSON.stringify([blocks[0], blocks[4]]).includes("未标明"), false);
|
||||
assert.deepEqual(blocks[5]?.lines.slice(0, 1), ["Vivah and other Sahams:无法计算"]);
|
||||
assert.deepEqual(blocks[5]?.audit?.[1].rows[0], {
|
||||
method: "Vivah and other Sahams", calculation: "阻塞", usage: "未使用。回执没有可用的计算结果",
|
||||
});
|
||||
});
|
||||
|
||||
function pythonBin(): string | null {
|
||||
@@ -684,40 +685,18 @@ test("a public pair dossier fills every section without birth keys", { timeout:
|
||||
individual_technique_audit?: Array<Record<string, unknown>>;
|
||||
pair_execution_tasks?: Array<Record<string, unknown>>;
|
||||
};
|
||||
const statusText: Record<string, string> = {
|
||||
executed: "已执行",
|
||||
ready_for_comparison: "已执行",
|
||||
present: "已执行",
|
||||
used: "已执行",
|
||||
available: "已执行",
|
||||
passed: "已执行",
|
||||
parameter_sensitive: "参数敏感",
|
||||
partial: "参数敏感",
|
||||
weak: "参数敏感",
|
||||
observation_only: "参数敏感",
|
||||
not_applicable: "不适用",
|
||||
not_used: "不适用",
|
||||
not_used_for_date_intersection: "不适用",
|
||||
// 2026-11-07 新增:blocked / not_available 显示「无法计算」,原来露出英文原词(BUG-1679)。
|
||||
blocked: "无法计算",
|
||||
not_available: "无法计算",
|
||||
};
|
||||
const receiptRows = [...(receipt.individual_technique_audit ?? []), ...(receipt.pair_execution_tasks ?? [])];
|
||||
const executionLines = blocks[5]?.lines ?? [];
|
||||
let namedRows = 0;
|
||||
for (const row of receiptRows) {
|
||||
const name = String(row.technique || row.task || row.label || row.lane || "").trim();
|
||||
const status = String(row.status || "").trim();
|
||||
if (!name || !status) continue;
|
||||
const shown = statusText[status.toLowerCase()] ?? status;
|
||||
assert.equal(executionLines.some((line) => line.includes(name) && line.includes(shown)), true, `${name} ${shown}`);
|
||||
namedRows += 1;
|
||||
const execution = blocks[5];
|
||||
const groups = execution?.audit ?? [];
|
||||
assert.deepEqual(groups.map(({ title }) => title), ["甲方", "乙方", "两盘对照"]);
|
||||
assert.equal(groups[0].rows.length, receipt.individual_technique_audit?.length);
|
||||
assert.equal(groups[1].rows.length, receipt.individual_technique_audit?.length);
|
||||
assert.equal(groups[2].rows.length, receipt.pair_execution_tasks?.length);
|
||||
assert.deepEqual(execution?.lines, ["网上资料核对:未完成", "真实案例校准:未完成"]);
|
||||
assert.ok(groups[2].rows.some((row) => row.calculation === "输入已齐" && row.usage === "供写作参考"));
|
||||
for (const row of groups.flatMap(({ rows }) => [...rows])) {
|
||||
assert.doesNotMatch(Object.values(row).join(" "), /[·_]|ready_for_comparison/);
|
||||
if (["阻塞", "不适用"].includes(row.calculation)) assert.match(row.usage, /^未使用。.+/);
|
||||
}
|
||||
assert.ok(namedRows > 0);
|
||||
// 原值:executionLines 末尾是「外部资料与真实案例核对:未进行,本报告是计算层归纳」
|
||||
// 新值:该行删除
|
||||
// 原因:产品负责人 2026-11-08:用户可见文字不出现联网/外部核验字样,后台保留
|
||||
assert.equal(executionLines.some((line) => line.includes("外部资料")), false);
|
||||
const structures = dossier.local_structures as Record<string, Record<string, unknown>>;
|
||||
for (const person of ["person_a", "person_b"]) {
|
||||
const local = structures[person] ?? {};
|
||||
|
||||
@@ -6,7 +6,7 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { SynastryReportView } from "../src/components/synastry/synastry-report-view";
|
||||
import { loadSynastrySubjectBirth, marriageMatchBirthBody, marriageMatchFingerprint } from "../src/lib/marriage-match-service";
|
||||
import { sectionEvidence, SYNASTRY_SECTION_IDS, systemPrompt } from "../src/lib/synastry-full-sections";
|
||||
import { buildTechnicalBasis } from "../src/lib/synastry-full-technical";
|
||||
import { buildTechnicalBasis, currentSynastryTechnicalBlocks } from "../src/lib/synastry-full-technical";
|
||||
|
||||
const stable = { D1: { status: "stable" }, D9: { status: "stable" }, moon: { status: "stable" } };
|
||||
const person = { window_label: "没有误差信息,按前后各 30 分钟", axes: stable, affected_layers: [] };
|
||||
@@ -15,6 +15,9 @@ const receipt = {
|
||||
technique: "D1/Rashi", status: "parameter_sensitive",
|
||||
person_a: { status: "parameter_sensitive", reason: "birth_time_window_varies" }, person_b: { status: "executed" },
|
||||
}],
|
||||
pair_execution_tasks: [{
|
||||
task: "宫位对照", status: "parameter_sensitive", reason: "birth_time_window_varies",
|
||||
}],
|
||||
};
|
||||
const changed = {
|
||||
execution_receipt: receipt,
|
||||
@@ -57,8 +60,22 @@ test("the appendix renders window sources, Chinese candidates and only the affec
|
||||
assert.match(appendix, /甲方出生时间误差:没有误差信息,按前后各 30 分钟/);
|
||||
assert.match(appendix, /水瓶座(档案时刻)、双鱼座(偏晚约 12 分钟)/);
|
||||
assert.match(appendix, /乙方出生时间误差[^<]*本命上升误差内稳定/);
|
||||
assert.match(appendix, /<td>甲方 D1\/Rashi<\/td><td>参数敏感<\/td><td>出生时间误差内会变/);
|
||||
assert.doesNotMatch(appendix, /乙方 D1|[·_]/);
|
||||
assert.match(appendix, /<h4>甲方<\/h4>[\s\S]*?<td>D1\/Rashi<\/td><td>参数敏感<\/td><td>只作观察。出生时间误差内会变<\/td>/);
|
||||
assert.match(appendix, /<h4>乙方<\/h4>[\s\S]*?<td>D1\/Rashi<\/td><td>已执行<\/td><td>供写作参考<\/td>/);
|
||||
assert.match(appendix, /<h4>两盘对照<\/h4>[\s\S]*?<td>宫位对照<\/td><td>参数敏感<\/td><td>只作观察。出生时间误差内会变<\/td>/);
|
||||
assert.equal(appendix.match(/<table/g)?.length, 3);
|
||||
assert.doesNotMatch(appendix, /[·_]/);
|
||||
});
|
||||
|
||||
test("a saved precision appendix uses current audit groups from the stored receipt", () => {
|
||||
const saved = {
|
||||
id: "execution" as const, title: "技法执行情况", lines: ["D1/Rashi:参数敏感"], precisionAudit: [],
|
||||
};
|
||||
const execution = currentSynastryTechnicalBlocks([saved], changed)?.[0];
|
||||
assert.deepEqual(execution?.audit, buildTechnicalBasis({
|
||||
dossier: changed, names: { a: "甲", b: "乙" }, contacts: [], timing: [],
|
||||
}).find(({ id }) => id === "execution")?.audit);
|
||||
assert.ok(execution && !Object.hasOwn(execution, "precisionAudit"));
|
||||
});
|
||||
|
||||
test("the request reuses the reported and adopted windows", () => {
|
||||
|
||||
@@ -49,7 +49,7 @@ def _grade(required, checked, states, candidates=None, disclosures=()):
|
||||
for row in needed:
|
||||
if candidates and row["id"] in candidates and row["state"] == "varies":
|
||||
row["candidates"] = candidates[row["id"]]
|
||||
missing = [row["id"] for row in needed if row["state"] not in AVAILABLE]
|
||||
missing = [row for row in needed if row["state"] not in AVAILABLE]
|
||||
disclose = [row["id"] for row in needed if row["state"] in ("samples_consistent", "branch_unresolved")]
|
||||
disclose.extend(key for key in checked if states.get(key, "missing") in (
|
||||
MISSING_STATES | {"partial", "parameter_sensitive", "varies", "unknown", "samples_consistent", "branch_unresolved"}
|
||||
|
||||
@@ -23,7 +23,9 @@ from typing import Any, Callable
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
# 原值 v2;新值 v3;原因:BUG-1601 Narayana 默认换成 Sanjay Rath,旧缓存里是旧算法默认(引擎版本号未变)
|
||||
# 原值 v3;新值 v4;原因:BUG-1699 全读加了 Chesta 候选、AV score_fields 与 career_analysis,旧包里没有
|
||||
CACHE_SCHEMA = "consult-full-data-cache-v4"
|
||||
# v4: report reference identity without a shared schema marker for pair dossiers.
|
||||
# v5: the pair dossier uses this schema and includes both calculation dates.
|
||||
CACHE_SCHEMA = "consult-full-data-cache-v5"
|
||||
SLOW_MISS_SECONDS = 20.0
|
||||
KEEP_SECONDS = 2 * 24 * 60 * 60
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""HTTP-facing marriage match and full synastry dossier.
|
||||
|
||||
The dossier endpoint caches on the two birth payloads plus ``GITHUB_SHA``,
|
||||
The dossier endpoint caches on both births, calculation dates and ``GITHUB_SHA``,
|
||||
the same scratch helper the report reference cache uses. A missing or
|
||||
``unknown`` commit id skips the cache.
|
||||
"""
|
||||
@@ -73,6 +73,7 @@ def _birth_identity(body: dict[str, Any]) -> dict[str, Any]:
|
||||
"ayanamsa": body.get("ayanamsa", "lahiri"),
|
||||
"node_mode": node or "mean",
|
||||
"birth_precision_window": normalized_birth_window(body),
|
||||
"today": body.get("today"),
|
||||
}
|
||||
|
||||
|
||||
@@ -104,11 +105,19 @@ def _narayana_profile_config() -> dict[str, str]:
|
||||
return dict(nr.DEFAULT_STEP_PROFILES)
|
||||
|
||||
|
||||
def _calculation_date(person: dict[str, Any], fallback: str) -> str:
|
||||
day = person.get("today") or person.get("current_date")
|
||||
return day.strip()[:10] if isinstance(day, str) and day.strip() else fallback
|
||||
|
||||
|
||||
def compute_synastry_full_dossier(handler: Any, body: dict[str, Any]) -> dict[str, Any]:
|
||||
if not isinstance(body, dict):
|
||||
raise MarriageMatchInputError("request body must be an object")
|
||||
person_a = _birth(body.get("person_a"), "person_a")
|
||||
person_b = _birth(body.get("person_b"), "person_b")
|
||||
pair_date = _calculation_date(person_a, "") or _calculation_date(person_b, "") or _cache.reference_date_from_body({})
|
||||
person_a = {**person_a, "today": _calculation_date(person_a, pair_date)}
|
||||
person_b = {**person_b, "today": _calculation_date(person_b, pair_date)}
|
||||
sha = _commit_sha()
|
||||
|
||||
def build(_identity: dict[str, Any]) -> dict[str, Any]:
|
||||
@@ -118,6 +127,7 @@ def compute_synastry_full_dossier(handler: Any, body: dict[str, Any]) -> dict[st
|
||||
return build({})
|
||||
cached = _cache.get_or_build(
|
||||
{
|
||||
"schema": _cache.CACHE_SCHEMA,
|
||||
"person_a": _birth_identity(person_a),
|
||||
"person_b": _birth_identity(person_b),
|
||||
"github_sha": sha,
|
||||
|
||||
@@ -718,6 +718,42 @@ def reading_scope(dossier: dict[str, Any]) -> dict[str, Any]:
|
||||
"rule": "both chart profiles match and every primary pair lane is comparable"}
|
||||
|
||||
|
||||
def _saham_block_reason(reading: dict[str, Any]) -> str | None:
|
||||
packet = _reading_packet(reading)
|
||||
modules = packet.get("modules")
|
||||
module = modules.get("sahams") if isinstance(modules, dict) else None
|
||||
if isinstance(module, dict) and module.get("reason"):
|
||||
return str(module["reason"])
|
||||
for error in packet.get("errors") or []:
|
||||
if isinstance(error, str) and error.startswith("tajika-yogas+sahams:"):
|
||||
for reason in ("solar_day_window_unavailable", "sunrise_or_sunset_unavailable_for_location_date"):
|
||||
if reason in error:
|
||||
return reason
|
||||
return "saham_calculation_failed"
|
||||
if not module or (isinstance(module, dict) and module.get("warning")):
|
||||
return "saham_inputs_unavailable"
|
||||
return None
|
||||
|
||||
|
||||
def _add_saham_receipt_reasons(dossier: dict[str, Any], readings: dict[str, Any]) -> None:
|
||||
receipt = dossier.get("execution_receipt") or {}
|
||||
reasons = {side: _saham_block_reason(reading) for side, reading in readings.items() if isinstance(reading, dict)}
|
||||
for row in receipt.get("individual_technique_audit", []):
|
||||
if row.get("technique") != "Vivah and other Sahams":
|
||||
continue
|
||||
for side, reason in reasons.items():
|
||||
person = row.get(side) or {}
|
||||
if reason and person.get("status") == "blocked":
|
||||
person["reason"] = reason
|
||||
for row in receipt.get("pair_execution_tasks", []):
|
||||
for item in row.get("required_inputs", []):
|
||||
if item.get("source_path") != "modules.sahams":
|
||||
continue
|
||||
for side, reason in reasons.items():
|
||||
if reason and item.get(f"{side}_status") == "blocked":
|
||||
item[f"{side}_reason"] = reason
|
||||
|
||||
|
||||
def build_synastry_full_dossier(
|
||||
handler: Any,
|
||||
person_a: dict[str, Any],
|
||||
@@ -735,6 +771,7 @@ def build_synastry_full_dossier(
|
||||
reading_b = future_b.result()
|
||||
dossier = _dossier_builder()(reading_a, reading_b)
|
||||
if isinstance(dossier, dict):
|
||||
_add_saham_receipt_reasons(dossier, {"person_a": reading_a, "person_b": reading_b})
|
||||
dossier["local_structures"] = {
|
||||
"person_a": relationship_structure(reading_a if isinstance(reading_a, dict) else {}),
|
||||
"person_b": relationship_structure(reading_b if isinstance(reading_b, dict) else {}),
|
||||
|
||||
@@ -42,7 +42,7 @@ def test_complete_required_layers_and_conditional_narayana_cap_at_c():
|
||||
package, natal, cards = _inputs()
|
||||
package["natal_periods"]["narayana"]["rath"] = {"status": "computed", "rows": []}
|
||||
overview = evidence_grades(package, natal, cards, window)["annual_overview"]
|
||||
assert overview["cap"] == "C" and "narayana" not in overview["missing_required"]
|
||||
assert overview["cap"] == "C" and overview["missing_required"] == []
|
||||
|
||||
|
||||
def test_primary_chart_change_is_local_to_its_theme_and_preserves_candidates():
|
||||
@@ -54,6 +54,7 @@ def test_primary_chart_change_is_local_to_its_theme_and_preserves_candidates():
|
||||
assert grades["annual_domain_career"]["required"][-1] == {
|
||||
"id": "D10", "state": "varies", "candidates": ["Leo", "Virgo"],
|
||||
}
|
||||
assert grades["annual_domain_career"]["missing_required"] == [grades["annual_domain_career"]["required"][-1]]
|
||||
assert all(row["cap"] == "C" for key, row in grades.items() if key.startswith("annual_domain_") and not key.endswith("career"))
|
||||
assert "D2" in grades["annual_domain_wealth"]["must_disclose"]
|
||||
|
||||
@@ -66,10 +67,11 @@ def test_missing_vimshottari_and_wide_window_do_not_poison_unrelated_claims():
|
||||
assert grades["windows"]["b"]["cap"] == "C"
|
||||
package["natal_periods"]["vimshottari"]["rows"] = []
|
||||
grades = evidence_grades(package, natal, cards, {})
|
||||
missing_vimshottari = {"id": "vimshottari", "state": "missing"}
|
||||
for key, row in grades.items():
|
||||
if key.startswith("annual_") and key != "annual_person":
|
||||
assert row["cap"] == "D" and "vimshottari" in row["missing_required"]
|
||||
assert all(row["cap"] == "D" and "vimshottari" in row["missing_required"] for row in grades["windows"].values())
|
||||
assert row["cap"] == "D" and missing_vimshottari in row["missing_required"]
|
||||
assert all(row["cap"] == "D" and missing_vimshottari in row["missing_required"] for row in grades["windows"].values())
|
||||
assert grades["annual_person"]["cap"] == "C"
|
||||
|
||||
|
||||
@@ -80,6 +82,6 @@ def test_expansion_across_the_original_month_and_an_unknown_primary_fall_to_d():
|
||||
second.update(start={"local": "2026-11-01"}, computed_at_used_birth_time={"start": {"local": "2026-11-02"}})
|
||||
natal["domains"]["learning"]["vargas"][0]["stability"] = "unknown"
|
||||
grades = evidence_grades(package, natal, cards, {})
|
||||
assert grades["windows"]["a"]["missing_required"] == ["window_precision"]
|
||||
assert grades["windows"]["a"]["missing_required"] == [{"id": "window_precision", "state": "varies"}]
|
||||
assert grades["windows"]["b"]["cap"] == "C"
|
||||
assert grades["annual_domain_learning"]["missing_required"] == ["D24"]
|
||||
assert grades["annual_domain_learning"]["missing_required"] == [{"id": "D24", "state": "unknown"}]
|
||||
|
||||
@@ -66,7 +66,6 @@ OPTIONAL_HOME_HOOKS = (
|
||||
# 状态下沉把合盘从 page.tsx 搬进了自己的 hook(2026-09-16)。首页表面是这
|
||||
# 些文件的并集,新 hook 不进这张白名单,下面的合盘断言就会在代码完全正确
|
||||
# 的情况下变红。新增 Home 级 hook 时必须同步加进来。
|
||||
_FRONTEND_SRC / "hooks" / "use-synastry.ts",
|
||||
_FRONTEND_SRC / "hooks" / "use-session-list.ts",
|
||||
_FRONTEND_SRC / "hooks" / "use-home-shell-registration.ts",
|
||||
_FRONTEND_SRC / "lib" / "session-list-context.tsx",
|
||||
@@ -85,7 +84,6 @@ SESSION_ITEM_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" /
|
||||
ACCOUNT_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "account" / "route.ts"
|
||||
CHART_PROFILE_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "chart-profiles" / "route.ts"
|
||||
CHART_PROFILE_DELETE_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "chart-profiles" / "[id]" / "route.ts"
|
||||
SYNASTRY_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "synastry" / "route.ts"
|
||||
SYNASTRY_REPORT_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "synastry-reports" / "route.ts"
|
||||
|
||||
|
||||
@@ -271,16 +269,10 @@ def test_chart_profile_library_has_cloud_table_api_and_local_fallback() -> None:
|
||||
"fetchCloudChartLibrary",
|
||||
"saveCloudChartProfile",
|
||||
"deleteCloudChartProfile",
|
||||
"buildSynastryQuestion",
|
||||
"draftSynastryQuestionFromChart",
|
||||
"synastryReportCard",
|
||||
"synastryHistory",
|
||||
"discardLegacyCloudMirrorKeys",
|
||||
# 原值 / 新值 / 原因:退役面板样式 / 人物详情与带用量的删除 / 锁实际 /people 入口。
|
||||
"people-archive-detail",
|
||||
"pendingDelete",
|
||||
'fetch("/api/synastry"',
|
||||
"Ashtakoot",
|
||||
"jyotisha_chart_library",
|
||||
"保存失败,请重试",
|
||||
# 原值:首页相关源码必须出现「星盘库」。
|
||||
@@ -304,35 +296,10 @@ def test_chart_profile_library_has_cloud_table_api_and_local_fallback() -> None:
|
||||
assert "ayanam-sessions" not in page
|
||||
|
||||
|
||||
def test_synastry_route_orchestrates_python_chart_and_ashtakoot() -> None:
|
||||
route = SYNASTRY_ROUTE.read_text(encoding="utf-8")
|
||||
for token in (
|
||||
'const apiBase = process.env.JYOTISH_API_BASE ?? "http://127.0.0.1:5200"',
|
||||
# 原值: postPython("/api/chart", selfPayload) 与 postPython("/api/chart", partnerPayload)
|
||||
# 新值: 两次调用都展开对应 payload,并带 skip_vedastro_main_entry_overview: true
|
||||
# 原因: 合盘改为同时排本人和对方两张盘,并关掉用不上的外部概览。断言仍锁住这两次 /api/chart,同时锁住这个开关,不放宽。
|
||||
'postPython("/api/chart", { ...selfPayload, skip_vedastro_main_entry_overview: true })',
|
||||
'postPython("/api/chart", { ...partnerPayload, skip_vedastro_main_entry_overview: true })',
|
||||
'postPython("/api/varga_full"',
|
||||
'postPython("/api/synastry"',
|
||||
"moonLongitude(selfChart)",
|
||||
"moonSummary(selfChart)",
|
||||
"d9Summary(selfD9)",
|
||||
"relationshipReport",
|
||||
"scoreBand",
|
||||
"nextEvidence",
|
||||
"ashtakoot_plus_moon_nakshatra_d9",
|
||||
'evidenceLayers: ["ashtakoot", "moon_nakshatra", "d9_navamsa"]',
|
||||
'status: "blocked"',
|
||||
"synastryBirthPayload",
|
||||
):
|
||||
assert token in route
|
||||
|
||||
|
||||
def test_synastry_reports_are_cloud_persisted_per_user() -> None:
|
||||
sql = re.sub(r"\s+", " ", SYNASTRY_REPORT_MIGRATION.read_text(encoding="utf-8").lower()).strip()
|
||||
route = SYNASTRY_REPORT_ROUTE.read_text(encoding="utf-8")
|
||||
page = _home_surface()
|
||||
source = (_FRONTEND_SRC / "lib" / "home-cloud-sync.ts").read_text(encoding="utf-8")
|
||||
|
||||
for token in (
|
||||
"create table if not exists public.synastry_reports",
|
||||
@@ -362,14 +329,12 @@ def test_synastry_reports_are_cloud_persisted_per_user() -> None:
|
||||
"fetchCloudSynastryHistory",
|
||||
"saveCloudSynastryReport",
|
||||
'fetch("/api/synastry-reports"',
|
||||
"未能存入历史",
|
||||
"cloud_synastry_history_unavailable",
|
||||
"cloud_synastry_report_save_failed",
|
||||
):
|
||||
assert token in page
|
||||
# Former value: writeSynastryHistory(accountId, next) wrote a local
|
||||
# history copy when cloud save failed.
|
||||
assert "writeSynastryHistory(accountId, next)" not in page
|
||||
assert token in source
|
||||
# Legacy synastry records still persist on the guarded server route.
|
||||
assert "writeSynastryHistory(accountId, next)" not in _home_surface()
|
||||
|
||||
|
||||
def test_consultation_credit_lifecycle_is_idempotent_and_server_only() -> None:
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
"""Synastry dossier date identity and the Saham reason in the upstream receipt."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
|
||||
from marriage_match_service import api, full_dossier
|
||||
|
||||
|
||||
def test_dossier_cache_changes_each_day_and_keeps_dates_used_by_native_calculation(monkeypatch):
|
||||
birth = {"year": 1990, "month": 6, "day": 15, "hour": 12, "minute": 0, "lat": 40, "lon": 116, "tz": 8}
|
||||
keys = []
|
||||
|
||||
def cache(identity, build, *, cache_name):
|
||||
keys.append(identity)
|
||||
return {"packet": build(identity)}
|
||||
|
||||
monkeypatch.setattr(api, "_commit_sha", lambda: "example-commit")
|
||||
monkeypatch.setattr(api._cache, "get_or_build", cache)
|
||||
monkeypatch.setattr(api, "build_synastry_full_dossier", lambda _, a, b: {"dates": [a["today"], b["today"]]})
|
||||
for day in ("2026-11-14", "2026-11-15"):
|
||||
result = api.compute_synastry_full_dossier(None, {"person_a": {**birth, "today": day}, "person_b": birth})
|
||||
assert keys[-1]["schema"] == api._cache.CACHE_SCHEMA
|
||||
assert [keys[-1][side]["today"] for side in ("person_a", "person_b")] == result["dates"] == [day, day]
|
||||
assert keys[0] != keys[1]
|
||||
|
||||
|
||||
def test_native_saham_failure_stays_blocked_and_keeps_its_reason_on_the_affected_side():
|
||||
# The upstream validator emits per-person and pair states but drops the calculation error.
|
||||
receipt = {
|
||||
"individual_technique_audit": [{
|
||||
"technique": "Vivah and other Sahams", "person_a": {"status": "parameter_sensitive"}, "person_b": {"status": "blocked"},
|
||||
}],
|
||||
"pair_execution_tasks": [{"required_inputs": [{
|
||||
"source_path": "modules.sahams", "status": "blocked", "person_a_status": "parameter_sensitive", "person_b_status": "blocked",
|
||||
}]}],
|
||||
}
|
||||
a = {"modules": {"sahams": {"status": "partial", "vivah_saham": {"sign": "Aries"}}}}
|
||||
b = {"modules": {}, "errors": ["tajika-yogas+sahams: solar_day_window_unavailable"]}
|
||||
full_dossier._add_saham_receipt_reasons({"execution_receipt": receipt}, {"person_a": a, "person_b": b})
|
||||
row = receipt["individual_technique_audit"][0]
|
||||
assert row["person_a"] == {"status": "parameter_sensitive"}
|
||||
assert row["person_b"] == {"status": "blocked", "reason": "solar_day_window_unavailable"}
|
||||
assert receipt["pair_execution_tasks"][0]["required_inputs"][0]["person_b_reason"] == "solar_day_window_unavailable"
|
||||
@@ -18,15 +18,16 @@ from marriage_match_service.full_dossier import build_synastry_full_dossier, rel
|
||||
FIXTURE = ROOT / "frontend" / "tests" / "fixtures" / "synastry-full-dossier-truncated.json"
|
||||
|
||||
# Public Rodden-rated charts already used by tests/verify_jyotish_v6_1.py.
|
||||
# Times are the UT hours stored there, passed with tz 0.
|
||||
# The first time uses UT. For the second chart use the same instant in local
|
||||
# civil time so the native Saham sunrise function can bracket the local day.
|
||||
EINSTEIN = {
|
||||
"year": 1879, "month": 3, "day": 14, "hour": 10, "minute": 30, "second": 0,
|
||||
"lat": 48.4, "lon": 10.0, "tz": 0, "ayanamsa": "lahiri", "node_mode": "mean",
|
||||
"today": "2026-10-18",
|
||||
}
|
||||
JOBS = {
|
||||
"year": 1955, "month": 2, "day": 25, "hour": 3, "minute": 15, "second": 0,
|
||||
"lat": 37.77, "lon": -122.42, "tz": 0, "ayanamsa": "lahiri", "node_mode": "mean",
|
||||
"year": 1955, "month": 2, "day": 24, "hour": 19, "minute": 15, "second": 0,
|
||||
"lat": 37.77, "lon": -122.42, "tz": -8, "ayanamsa": "lahiri", "node_mode": "mean",
|
||||
"today": "2026-10-18",
|
||||
}
|
||||
|
||||
@@ -143,6 +144,12 @@ def test_public_pair_dossier_reading_scope_follows_upstream_readiness():
|
||||
"person_a": ["stable", "varies", "stable"], "person_b": ["varies", "varies", "stable"],
|
||||
}
|
||||
assert tasks[timing] == "parameter_sensitive"
|
||||
|
||||
sahams = next(row for row in dossier["execution_receipt"]["individual_technique_audit"]
|
||||
if row["technique"] == "Vivah and other Sahams")
|
||||
for side in ("person_a", "person_b"):
|
||||
assert sahams[side]["source_path"] == "modules.sahams"
|
||||
assert sahams[side]["status"] == "parameter_sensitive"
|
||||
assert dossier["delivery_readiness"] == "ready_for_narrative"
|
||||
assert dossier["reading_scope"]["status"] == "full"
|
||||
assert dossier["ayanamsa_alignment"]["status"] == "same_profile"
|
||||
|
||||
Reference in New Issue
Block a user