Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7930697951 | ||
|
|
4c4ddddf33 | ||
|
|
ff00c96d2e |
@@ -1,5 +1,9 @@
|
||||
# BLOCKED
|
||||
|
||||
## #276 合盘出生时间误差验收
|
||||
|
||||
- Windows Docker Linux 引擎返回 500,容器数据库实测待补。已用同机 staging 测试对照、现有 RPC 契约和合成档案验证替代。预检已核对远端和外部适配器,碎片扫描与定向套件在本机超时。见 [#276 进度](docs/tasks/PROGRESS-synastry-precision-20261114.md)。
|
||||
|
||||
## #271 年运证据等级验收
|
||||
|
||||
- Windows Docker Linux 引擎不可用。开工预检的碎片扫描和定向套件超时。以同机 staging 对照、公开盘真实计算和桩写手回归提供替代证据。真实模型样例由独立验收方生成。见 [#271 进度](docs/tasks/PROGRESS-annual-grade-20261114.md)。
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# 印度占星 Skill 更新日志
|
||||
|
||||
## 2026-11-14 — 合盘按两个人各自的出生时间误差显示依据
|
||||
|
||||
- 计算附录显示甲乙各自的误差来源,以及本命上升、九分盘上升、月亮星宿与四分的核对结果。会受影响的技法标明参数敏感。占星 Skill 版本不变(BUG-1889)。
|
||||
|
||||
## 2026-11-14 — 年运逐段显示证据等级
|
||||
|
||||
- 报告正文和 Markdown 导出按段落、主题和时间点显示证据等级。缺少必需依据时说明哪一项受限。计算依据可查看各结论的等级上限。占星 Skill 版本不变(BUG-1887)。
|
||||
|
||||
@@ -25489,3 +25489,14 @@
|
||||
- 验收返工:时间表恢复原单元格内容,表外显示最严等级及补充理由。人物段和时间点只增加原定的等级行与补充理由。Markdown 沿用原时间表和窗口明细。回归覆盖多行时间表、正文展示与两种导出布局。
|
||||
- 关联记录:#224、#271、BUG-1650、BUG-1651、BUG-1855、BUG-1869。
|
||||
- 修复版本:`codex/annual-grade-20261114`,待独立验收。
|
||||
|
||||
## BUG-1889 | 合盘未核对两个人各自的出生时间误差
|
||||
|
||||
- 状态:fixed-pending-verify(待独立验收)。
|
||||
- 首次发现 / 最近更新:2026-11-14 / 2026-11-14。
|
||||
- 触发与现象:生成婚恋合盘时,档案的出生时间可能只有自报或纠正区间。计算依据仍然只写采用档案时间,受影响的单人证据和双盘比较未显示限制。
|
||||
- 根因:合盘请求只传单一时刻,未沿用个人报告的窗口逻辑。计算收据以该时刻的结果为依据,缺少误差对上升与月亮位置的逐人核对。
|
||||
- 修复:按两人已验证的档案来源分别传窗口,引擎核对 D1、D9 上升及月亮星宿与四分,将敏感状态写在有关的一侧和直接依赖的双盘比较。附录标注来源与变化,写作用一句话传达限制。
|
||||
- 验证与防复发:公开双盘使用默认窗口,合成用例分别覆盖甲方 D1、乙方 D9、月亮四分边界、两人稳定、自报误差、纠正记录复用及过时记录拒用。详见 [#276 进度](tasks/PROGRESS-synastry-precision-20261114.md)。
|
||||
- 关联记录:#224、#275、#276、BUG-1654、BUG-1679、BUG-1869。
|
||||
- 修复版本:`codex/synastry-precision-20261114`,待独立验收。
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# #276 合盘出生时间误差(2026-11-14)
|
||||
|
||||
根据 [任务书](TASK-synastry-precision-20261114.md) 从 `29ac0138` 开工。按 Claude 在 #276 的复验要求,交付基线改为 `ff00c96d2e9c32f31863012e280ecf367fcc8098`。执行者 Codex,BUG-1889,独立验收 Claude。
|
||||
|
||||
- 合盘发起、状态查询与生成共用个人报告的出生时间窗口。档案没有直接范围时,复用独立的所有者历史读取核对当前纠正记录及保存时刻。默认各向 30 分钟,计算缓存计入各自的窗口。公开交接不附个资。
|
||||
- 引擎分别核对甲乙的 D1 上升、D9 上升与月亮星宿和四分。上升用既有分盘边界,月亮用同口径星历。保留原中心计算;只在窗口越线时记录候选及相对偏移。
|
||||
- 暂行按产品运行合同 L.3,只标受影响的一侧和直接依赖的双盘比较。是否整层限制仍需拍板。Ashtakoota 的分数仍按档案时刻计算,附录标明需按条件观察的项目。各节写作材料在有变化时加一句话说明。
|
||||
- #275 的合盘审计表与本轮改动分别提交。待先合入的一单落地后,按任务书处理共用文件的衔接。
|
||||
|
||||
## 验证
|
||||
|
||||
- 公开盘以默认窗口核对三项。甲方只有 D9 越线;乙方 D1 与 D9 越线。测试还核对双盘大运比较降为参数敏感、原叙述就绪状态和四类事件口径维持原断言。
|
||||
- 合成覆盖两人都稳定、只变甲方 D1、只变乙方 D9、月亮跨四分、自报误差、纠正记录复用与相邻时刻旧记录拒用、写作材料哈希、附录中文与相关侧的计算标记。
|
||||
- TypeScript、ESLint 和生产构建通过,ESLint 为 0 错,首页保留静态产物。返基线后前端定向 53 项、Python 定向和隐私检查 76 项通过。全量前端 3751 项,3669 通过、45 项失败与 `ff00c96d` 的 3746 项基线逐项一致、37 跳过、0 取消。
|
||||
- 首页 HTML 引用的 JS gzip 从 507344 字节到 508645 字节(+0.26%),CSS gzip 保持 92393 字节。
|
||||
- 开工基线上的实现版 Python 快速门 1497 项通过、2 跳过、3 失败。三个 Kaala / PyJHora 失败在 `ff00c96d` 定向基线逐项复现。返基线后的 UTF-8 快速门另行重跑,完整结果交独立验收核对。Windows 默认编码引起的 CLI 测试失败在两个版本均复现,同一用例启用 UTF-8 后都通过。
|
||||
- 本机 Docker Linux 引擎返回 500,无法运行容器数据库验证;参见 [BLOCKED.md](../../BLOCKED.md)。远端与外部适配器预检通过,碎片扫描和预检定向套件超时。本轮按任务书未调用 DeepSeek。
|
||||
|
||||
## 既有断言变更
|
||||
|
||||
| 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- |
|
||||
| 公开盘的双人 Dasha/Narayana/Chara 比较是 `ready_for_comparison` | `parameter_sensitive`,且断言两人的默认窗口及具体三项状态 | 乙方 D1 在默认误差内更换上升,Narayana 起点受影响。就绪状态和事件断言仍维持原值。 |
|
||||
@@ -0,0 +1,83 @@
|
||||
# TASK:合盘第 2 批:两人各自的出生时间误差(2026-11-14)
|
||||
|
||||
- Gitea:#276
|
||||
- 分支:`codex/synastry-precision-20261114`,从 staging `29ac0138` 切出。
|
||||
- Bug 编号:BUG-1889。开工时核对 `docs/BUG_HISTORY.md` 末尾;已被占用就顺延,并在 PROGRESS 写明。
|
||||
- 负责验收:Claude(jyotisha-3f)。
|
||||
- 同时在做:#275(合盘第 1 批,BUG-1888),会改 `synastry-full-technical.ts` 和 `full_dossier.py`。两单各改各的函数,后合入的负责 rebase。
|
||||
|
||||
任务书没写到的取舍,不得写成"产品决定"或"裁定",一律标「需拍板」。不得修改或删除既有断言来让测试通过。确需修改的,在 PROGRESS 逐条写明原值、新值和原因。
|
||||
|
||||
## 背景
|
||||
|
||||
- 占星师合盘子 skill SKILL.md:28-30:出生时间不够精确时,依赖它的层要标 parameter_sensitive 或 blocked。
|
||||
- 产品负责人 2026-11-13(#224):出生时间误差用用户自报的范围,没填就按前后 30 分钟。个人报告和年运都已这样做。
|
||||
- 产品负责人 2026-11-13:分盘跨界在生时纠正里解决,报告只负责照实显示,不在报告里分支。
|
||||
- 现状:合盘完全没有处理误差。
|
||||
- `marriage-match-service.ts` 的 `engineBirth`(80-112 行)只传时、分,不传误差,引擎按「已确认」处理。
|
||||
- 附录只有一句「以各自档案里已经保存的时间为准」(`synastry-full-technical.ts:122`)。
|
||||
- 暂行规则见 `references/product_runtime_contract.md` 第 L 节第 3 条(本任务书同一提交)。只封一侧还是整层都封,等她裁定(合盘问题 6)。本单按「只封一侧」做,并在代码注释和 PROGRESS 写明是暂行。
|
||||
|
||||
## 要做的
|
||||
|
||||
### 1. 每人的误差窗口
|
||||
|
||||
- 前端:两人各自按个人报告的做法取窗口。复用 `personal-report-longform-birth.ts` 里 `buildLongformBirthPayload` 的窗口逻辑,不另写一套:
|
||||
- 有自报误差就用;
|
||||
- 采用过生时纠正的,用纠正后的区间;
|
||||
- 都没有就前后 30 分钟,`source: default_unknown_30`。
|
||||
- 把两人的窗口传给合盘引擎请求,后端用 `report_render.birth_precision_window.report_birth_window` 读取。
|
||||
|
||||
### 2. 每人扫描三项
|
||||
|
||||
- 只用已有的函数:
|
||||
- D1、D9 上升:`report_render.birth_precision_margins.ascendant_margins(birth, {1, 9}, window=...)`;
|
||||
- 月亮星宿和 pada:照同样的做法求窗口内月亮会不会跨星宿或 pada 边界。没有现成函数就在 `marriage_match_service` 下新写一个小函数,用引擎的星历取月亮经度,不改冻结文件。
|
||||
- 每人记录:每一项是 `stable` 还是 `varies`;`varies` 时写出候选值(星座或星宿中文名)和大约在误差内的哪一侧。
|
||||
|
||||
### 3. 标出受影响的层(只封一侧)
|
||||
|
||||
- 某人 D1 上升 `varies`:这个人一侧的上升、宫位、宫主、UL、A7、AL、Narayana 起点,以及用到这一侧宫位的两盘互落,都标参数敏感。
|
||||
- 某人 D9 上升 `varies`:这个人一侧的 D9 层,以及 D9 两盘对照,标参数敏感。
|
||||
- 某人月亮星宿或 pada `varies`:Ashtakoota 里依赖月亮星宿的各项、星宿关系,以及这个人的 Vimshottari 起点,标参数敏感。Ashtakoota 分数在附录照现在一样显示,加一句「这个人的月亮在出生时间误差内可能换星宿,以下几项会变」。
|
||||
- 另一人不受影响。
|
||||
- 做法:在 dossier 新增 `birth_precision` 块,按人记录扫描结果和受影响的层。她的 builder 输出不改,只在我方包装层叠加标记。
|
||||
- 已有的 `parameter_sensitive` 行保留,不能因为误差稳定就改成 executed。
|
||||
|
||||
### 4. 写作输入、附录、审计
|
||||
|
||||
- 写作输入:每一节加一句「哪个人的哪几层在出生时间误差内会变」(中文,用甲方、乙方的称呼)。提示词写明:这些层不能写成确定的结论,也不能说没有算出。
|
||||
- 附录「计算参数」:把「以各自档案里已经保存的时间为准」换成每人一行,写误差来源(自报、纠正区间或默认前后 30 分钟)和三项扫描结果。
|
||||
- 技法执行情况:受影响的行在「计算」一栏标参数敏感,理由写「出生时间误差内会变」。
|
||||
- 两人误差都稳定时,附录照实写「误差内稳定」,不加多余提示。
|
||||
|
||||
### 5. 不改的
|
||||
|
||||
- 不在合盘里给出分支结论,也不替用户选时间(11-13 业主规则)。
|
||||
- 冻结文件、她的 `skills/jyotish-full-synastry-reading/**` 只能调用。`references/**`(L 节已由本提交写好)、`consult-preset-prompts.ts` 不碰。
|
||||
- 不改四类事件、事件扫描、断言标签。
|
||||
- 不调用 DeepSeek。
|
||||
|
||||
## 要改的文件
|
||||
|
||||
- `frontend/src/lib/marriage-match-service.ts`、合盘发起和生成链路里传请求体的地方
|
||||
- `scripts/marriage_match_service/api.py`、`scripts/marriage_match_service/full_dossier.py`,必要时新增 `scripts/marriage_match_service/birth_precision.py`
|
||||
- `frontend/src/lib/synastry-full-technical.ts`、`frontend/src/lib/synastry-full-sections.ts`(只加写作输入那一句和提示词规则)
|
||||
- 测试:`tests/test_synastry_precision_20261114.py`、`frontend/tests/synastry-precision-20261114.test.tsx`。合成数据覆盖:
|
||||
- 两人都稳定;
|
||||
- 只有甲方 D1 上升会变:只有甲方一侧和用到甲方宫位的互落被标,乙方不变;
|
||||
- 只有乙方 D9 上升会变;
|
||||
- 月亮跨 pada:Ashtakoota 相关项被标;
|
||||
- 没填误差:按前后 30 分钟,附录写明默认;
|
||||
- 有自报误差:用自报值;
|
||||
- 写作输入里会变的层不出现「没有算出」;
|
||||
- 用户可见文字没有「·」、字段名或下划线。
|
||||
- `docs/BUG_HISTORY.md`,只在末尾追加
|
||||
- `docs/tasks/PROGRESS-synastry-precision-20261114.md`
|
||||
|
||||
## 验收标准
|
||||
|
||||
1. 公开名人盘一对(没填误差):附录每人一行误差来源和三项扫描结果;会变的层在技法表里标参数敏感,理由正确。
|
||||
2. 合成测试覆盖上面列出的每种情况。
|
||||
3. 写作输入只多了误差那一句;其余写作输入不变(同一请求、误差稳定时,evidence 哈希与改前一致)。
|
||||
4. tsc、eslint(0 错)、`npm test`(基线失败除外)、quick gate 全部通过。
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
代号与中文释义用括号,如「AK(自我)」「D9(婚姻)」。运期层级沿用「›」,Yogini 运名后的主星用括号。Saham 公式以「白天:」或「夜晚:」开头。
|
||||
|
||||
婚恋合盘技术依据的计算参数按甲乙各占一行,写出生时间误差来源和三项扫描结果。受误差影响时,技法执行情况沿用报告数据表的样式,按相关人物或双盘比较显示技法、计算状态和使用口径。
|
||||
|
||||
### Palette
|
||||
|
||||
| Role | Token | Value | Usage |
|
||||
|
||||
@@ -51,6 +51,8 @@ Jyotisha 的可见文案是产品的一部分。正确性红线(真实性、
|
||||
|
||||
## 婚恋合盘报告(2026-10-19)
|
||||
|
||||
计算附录分别称「甲方」「乙方」。无自报或纠正范围时写「没有误差信息,按前后各 30 分钟」。核对结果写「误差内稳定」或列出候选和大致偏早、偏晚的位置。会变化的技法写「出生时间误差内会变,只作观察」。正文把相应依据写成条件。
|
||||
|
||||
说「你们之间」,不说「你是什么人 / 他是什么人」。说倾向、需求和条件,不说注定、不合、适合结婚。不写某年结婚、领证或分开。页脚保留一句:合盘描述的是互动的质地,走不走、怎么走,仍然是你们两个人的选择。
|
||||
|
||||
「可以一起聊聊」用这四句,不再加第五句入口:
|
||||
|
||||
@@ -11,6 +11,7 @@ import { beginSynastrySectionChat } from "@/lib/synastry-report-chat-client";
|
||||
import { SECTION_TITLES, SYNASTRY_ASK_SECTION_IDS, SYNASTRY_FOOTNOTE, SYNASTRY_LEGACY_ORDER, SYNASTRY_LEGACY_TITLES, SYNASTRY_SECTION_IDS, SYNASTRY_STRUCTURE, TALK_TOGETHER, type SynastryAskSectionId, type SynastrySectionId } from "@/lib/synastry-full-sections";
|
||||
import { EVENT_OVERLAP_NOTE } from "@/lib/synastry-full-timeline";
|
||||
import type { TechnicalBlock } from "@/lib/synastry-full-technical";
|
||||
import { dragScroll } from "@/lib/drag-scroll";
|
||||
import { timelineHeading } from "@/lib/synastry-timeline-label";
|
||||
|
||||
type Reason = { plain?: string; basis?: string; evidence?: string; label?: string };
|
||||
@@ -274,6 +275,16 @@ 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}
|
||||
<ul>
|
||||
{block.lines.map((line) => <li key={line}>{line}</li>)}
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { asRecord } from "../guards.ts";
|
||||
import { reportAdoptedClock } from "../personal-report-longform-birth.ts";
|
||||
import { globalBirthProfileFromAccountRow } from "../server-owned-birth-profile.ts";
|
||||
|
||||
export async function readCurrentChartChoice(client: unknown, userId: string, subjectId: string, row: unknown) {
|
||||
const rpcClient = client as { rpc?: (name: string, args: Record<string, unknown>) =>
|
||||
PromiseLike<{ data: unknown; error: unknown }> };
|
||||
if (typeof rpcClient?.rpc !== "function") return null;
|
||||
try {
|
||||
const { data, error } = await rpcClient.rpc("chart_choice_records_v1", {
|
||||
p_user_id: userId,
|
||||
p_chart_profile_id: subjectId === "self" ? null : subjectId,
|
||||
});
|
||||
const history = asRecord(data);
|
||||
if (error || typeof history?.current_record_id !== "string" || !Array.isArray(history.records)) return null;
|
||||
const active = globalBirthProfileFromAccountRow(row);
|
||||
const activeClock = reportAdoptedClock(asRecord(row)?.active_birth_time ?? active.time);
|
||||
const currentId = history.current_record_id;
|
||||
const record = history.records.map(asRecord).find((entry) =>
|
||||
entry && entry.id === currentId && entry.reusable === true
|
||||
&& entry.saved_date === active.date && activeClock !== undefined && reportAdoptedClock(entry.saved_time) === activeClock);
|
||||
const detail = asRecord(record?.detail);
|
||||
const provenance = asRecord(detail?.provenance);
|
||||
if (provenance?.contract === "chart-choice-v2") return provenance.segment ? provenance : null;
|
||||
if (!record || !detail?.window) return null;
|
||||
const line = asRecord(detail.line);
|
||||
return {
|
||||
contract: "chart-choice-v1",
|
||||
window: detail.window,
|
||||
line_at: line?.at,
|
||||
line_charts: line?.charts,
|
||||
chosen_side: record.chosen_side,
|
||||
both_versions: asRecord(detail.decision)?.both_versions_domains,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,10 @@
|
||||
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import { readCurrentChartChoice } from "./chart-choice/current-provenance.ts";
|
||||
import { asRecord } from "./guards.ts";
|
||||
import { globalBirthProfileFromAccountRow } from "./server-owned-birth-profile.ts";
|
||||
import { buildLongformBirthPayload } from "./personal-report-longform-birth.ts";
|
||||
import {
|
||||
ConsultationSubjectError,
|
||||
loadSubjectBirth,
|
||||
@@ -71,8 +74,28 @@ type BirthBody = {
|
||||
ayanamsa: string;
|
||||
node_mode: "mean";
|
||||
today: string;
|
||||
birth_time_window?: unknown;
|
||||
reading_minute_confirmed?: boolean;
|
||||
};
|
||||
|
||||
export async function loadSynastrySubjectBirth(
|
||||
client: unknown,
|
||||
admin: unknown,
|
||||
userId: string,
|
||||
subjectId: string,
|
||||
): Promise<ResolvedSubjectBirth> {
|
||||
const subject = await loadSubjectBirth(client, userId, subjectId);
|
||||
const row = subject.row;
|
||||
if (row.birth_time_status !== "accepted" && row.birth_time_status !== "confirmed") return subject;
|
||||
const provenance = asRecord(row.active_birth_provenance);
|
||||
const hasChoiceRange = provenance?.contract === "chart-choice-v2" ? provenance.segment : provenance?.window;
|
||||
if (hasChoiceRange || (subject.role === "self" && !provenance)) return subject;
|
||||
|
||||
// The history RPC verifies the active choice for this owner, including reused choices.
|
||||
const choice = await readCurrentChartChoice(admin, userId, subject.subjectId, row);
|
||||
return choice ? { ...subject, row: { ...row, active_birth_provenance: choice } } : subject;
|
||||
}
|
||||
|
||||
export function marriageMatchBirthBody(row: Record<string, unknown>, today: string): BirthBody {
|
||||
return engineBirth(row, today);
|
||||
}
|
||||
@@ -95,19 +118,25 @@ function engineBirth(row: Record<string, unknown>, today: string): BirthBody {
|
||||
) {
|
||||
throw new MarriageMatchServiceError("subject_incomplete");
|
||||
}
|
||||
const precision = buildLongformBirthPayload(row, {
|
||||
today, targetYear: Number(today.slice(0, 4)), candidateRange: null,
|
||||
birthTimeAccuracy: "provisional", readingMinuteConfirmed: false,
|
||||
});
|
||||
return {
|
||||
year: Number(dateMatch[1]),
|
||||
month: Number(dateMatch[2]),
|
||||
day: Number(dateMatch[3]),
|
||||
hour: Number(timeMatch[1]),
|
||||
minute: Number(timeMatch[2]),
|
||||
second: 0,
|
||||
second: typeof precision?.second === "number" ? precision.second : 0,
|
||||
lat: latitude,
|
||||
lon: longitude,
|
||||
tz: timezoneOffset,
|
||||
ayanamsa,
|
||||
node_mode: "mean",
|
||||
today,
|
||||
...(precision?.birth_time_window ? { birth_time_window: precision.birth_time_window } : {}),
|
||||
...(precision && precision.reading_minute_confirmed === undefined ? { reading_minute_confirmed: true } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -125,6 +154,8 @@ export function marriageMatchFingerprint(row: Record<string, unknown>): string {
|
||||
tz: birth.tz,
|
||||
ayanamsa: birth.ayanamsa,
|
||||
node_mode: birth.node_mode,
|
||||
...(birth.birth_time_window ? { birth_time_window: birth.birth_time_window } : {}),
|
||||
...(birth.reading_minute_confirmed ? { reading_minute_confirmed: true } : {}),
|
||||
};
|
||||
return createHash("sha256").update(JSON.stringify(stable)).digest("hex");
|
||||
}
|
||||
@@ -221,8 +252,8 @@ export async function readOrComputeMarriageMatch(input: {
|
||||
if (personAId === personBId) throw new MarriageMatchServiceError("same_person");
|
||||
|
||||
const [personA, personB] = await Promise.all([
|
||||
loadSubjectBirth(input.supabase, input.userId, personAId),
|
||||
loadSubjectBirth(input.supabase, input.userId, personBId),
|
||||
loadSynastrySubjectBirth(input.supabase, input.supabase, input.userId, personAId),
|
||||
loadSynastrySubjectBirth(input.supabase, input.supabase, input.userId, personBId),
|
||||
]);
|
||||
return readResolvedPair({
|
||||
supabase: input.supabase,
|
||||
|
||||
@@ -1,47 +1,11 @@
|
||||
import { resolveMissingBirthTimezoneOffset } from "./birth-profile-timezone.ts";
|
||||
import { asRecord } from "./guards.ts";
|
||||
import { reportAdoptedClock } from "./personal-report-longform-birth.ts";
|
||||
import { readCurrentChartChoice } from "./chart-choice/current-provenance.ts";
|
||||
import { resolveReportBirthClock } from "./personal-report-route-core.ts";
|
||||
import { PersonalReportWorkerError } from "./personal-report-worker-core.ts";
|
||||
import { stampReportBirthFingerprint } from "./report-birth-binding.ts";
|
||||
import { globalBirthProfileFromAccountRow } from "./server-owned-birth-profile.ts";
|
||||
import { ConsultationSubjectError, loadSubjectBirth } from "./subject-birth.ts";
|
||||
|
||||
async function readCurrentChartChoice(client: unknown, userId: string, subjectId: string, row: unknown) {
|
||||
const rpcClient = client as { rpc?: (name: string, args: Record<string, unknown>) =>
|
||||
PromiseLike<{ data: unknown; error: unknown }> };
|
||||
if (typeof rpcClient.rpc !== "function") return null;
|
||||
try {
|
||||
const { data, error } = await rpcClient.rpc("chart_choice_records_v1", {
|
||||
p_user_id: userId,
|
||||
p_chart_profile_id: subjectId === "self" ? null : subjectId,
|
||||
});
|
||||
const history = asRecord(data);
|
||||
if (error || typeof history?.current_record_id !== "string" || !Array.isArray(history.records)) return null;
|
||||
const active = globalBirthProfileFromAccountRow(row);
|
||||
const activeClock = reportAdoptedClock(asRecord(row)?.active_birth_time ?? active.time);
|
||||
const currentId = history.current_record_id;
|
||||
const record = history.records.map(asRecord).find((entry) =>
|
||||
entry && entry.id === currentId && entry.reusable === true
|
||||
&& entry.saved_date === active.date && activeClock !== undefined && reportAdoptedClock(entry.saved_time) === activeClock);
|
||||
const detail = asRecord(record?.detail);
|
||||
const provenance = asRecord(detail?.provenance);
|
||||
if (provenance?.contract === "chart-choice-v2") return provenance.segment ? provenance : null;
|
||||
if (!record || !detail?.window) return null;
|
||||
const line = asRecord(detail.line);
|
||||
return {
|
||||
contract: "chart-choice-v1",
|
||||
window: detail.window,
|
||||
line_at: line?.at,
|
||||
line_charts: line?.charts,
|
||||
chosen_side: record.chosen_side,
|
||||
both_versions: asRecord(detail.decision)?.both_versions_domains,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadReportWorkerProfile(client: unknown, userId: string, subjectId: string): Promise<unknown> {
|
||||
try {
|
||||
const resolved = await loadSubjectBirth(client, userId, subjectId);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { authorizeUsage, releaseUsage } from "@/lib/consultation-billing";
|
||||
import type { DataQueryBuilder } from "@/lib/db/data-client";
|
||||
import { consultationSubjectFailureResponse } from "@/lib/consultation-subject-resolver";
|
||||
import { FeaturePricingError, resolveFeaturePricing } from "@/lib/feature-pricing";
|
||||
import { MARRIAGE_MATCH_RULES_VERSION, marriageMatchFingerprint } from "@/lib/marriage-match-service";
|
||||
import { loadSynastrySubjectBirth, MARRIAGE_MATCH_RULES_VERSION, marriageMatchFingerprint } from "@/lib/marriage-match-service";
|
||||
import { SYNASTRY_ORDER_SECTION } from "@/lib/synastry-display-order";
|
||||
import { loadLanguageModelCatalog } from "@/lib/model-catalog";
|
||||
import { REPORT_STABLE_CODES } from "@/lib/personal-report-codes";
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
type PersonalReportRecord,
|
||||
} from "@/lib/personal-report-service";
|
||||
import { isProductEnabled } from "@/lib/product-access";
|
||||
import { ConsultationSubjectError, isChartSubjectId, loadSubjectBirth } from "@/lib/subject-birth";
|
||||
import { ConsultationSubjectError, isChartSubjectId } from "@/lib/subject-birth";
|
||||
|
||||
const SKILL_SNAPSHOT_SHA256 = "5b12d7a51dfecfdfbc29c33263204f5069d79efd71a056c75fddb8151b78b329";
|
||||
|
||||
@@ -61,6 +61,7 @@ type OpenedPair = {
|
||||
async function openSynastryPair(input: Readonly<{
|
||||
userId: string | null;
|
||||
supabase: unknown;
|
||||
admin: unknown;
|
||||
subjectA: unknown;
|
||||
subjectB: unknown;
|
||||
}>): Promise<{ response: SynastryCreateResponse } | OpenedPair> {
|
||||
@@ -77,8 +78,8 @@ async function openSynastryPair(input: Readonly<{
|
||||
let rowB: Record<string, unknown>;
|
||||
try {
|
||||
const [personA, personB] = await Promise.all([
|
||||
loadSubjectBirth(input.supabase, input.userId, subjectA),
|
||||
loadSubjectBirth(input.supabase, input.userId, subjectB),
|
||||
loadSynastrySubjectBirth(input.supabase, input.admin, input.userId, subjectA),
|
||||
loadSynastrySubjectBirth(input.supabase, input.admin, input.userId, subjectB),
|
||||
]);
|
||||
if (!personA.chartable || !personB.chartable) {
|
||||
return { response: { status: 422, body: { error: "请先完善出生资料", code: REPORT_STABLE_CODES.profileIncomplete } } };
|
||||
@@ -142,6 +143,7 @@ export async function createSynastryFullReport(input: Readonly<{
|
||||
const opened = await openSynastryPair({
|
||||
userId: input.userId,
|
||||
supabase: input.supabase,
|
||||
admin: input.admin,
|
||||
subjectA: body.subjectA ?? "self",
|
||||
subjectB: body.subjectB ?? body.with,
|
||||
});
|
||||
|
||||
@@ -12,8 +12,7 @@ import {
|
||||
} from "@/lib/synastry-full-english";
|
||||
import { PersonalReportWorkerError } from "@/lib/personal-report-worker-core";
|
||||
import type { PersonalReportRecord } from "@/lib/personal-report-service-core";
|
||||
import { loadSubjectBirth } from "@/lib/subject-birth";
|
||||
import { marriageMatchBirthBody } from "@/lib/marriage-match-service";
|
||||
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 type { TimingPeriod } from "@/lib/synastry-full-timeline";
|
||||
@@ -182,8 +181,8 @@ export async function runSynastryFullReport(input: Readonly<{
|
||||
orderPayload,
|
||||
);
|
||||
const [personA, personB] = await Promise.all([
|
||||
loadSubjectBirth(input.admin, input.report.userId, firstId),
|
||||
loadSubjectBirth(input.admin, input.report.userId, secondId),
|
||||
loadSynastrySubjectBirth(input.admin, input.admin, input.report.userId, firstId),
|
||||
loadSynastrySubjectBirth(input.admin, input.admin, input.report.userId, secondId),
|
||||
]);
|
||||
const packet = asRecord(await postJson("/api/synastry_full_dossier", {
|
||||
person_a: marriageMatchBirthBody(personA.row, today),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { pairLinkLines, promiseLine } from "./synastry-full-technical.ts";
|
||||
import { pairLinkLines, precisionEvidence, promiseLine } from "./synastry-full-technical.ts";
|
||||
|
||||
/**
|
||||
* Nine sections, the evidence each one may see, and the prompts around that evidence.
|
||||
@@ -141,7 +141,7 @@ function scrub(value: unknown, key = ""): unknown {
|
||||
if (!row) return value;
|
||||
const next: Record<string, unknown> = {};
|
||||
for (const [name, item] of Object.entries(row)) {
|
||||
if (PRIVATE_KEY_NAMES.has(name)) continue;
|
||||
if (name === "birth_precision" || PRIVATE_KEY_NAMES.has(name)) continue;
|
||||
next[name] = scrub(item, name);
|
||||
}
|
||||
return next;
|
||||
@@ -258,16 +258,18 @@ export function sectionEvidence(
|
||||
): unknown {
|
||||
const packet = record(dossier) ?? {};
|
||||
const scope = readingScope(dossier);
|
||||
const precision = precisionEvidence(dossier, language);
|
||||
if (sectionId === "timeline" && language === "en") {
|
||||
// 原值:英文时间线只给 segments;新值:加四类事件、parallel_personal_timing 与 event_resonance_gate
|
||||
// 原因:产品 2026-11-07 占星师方案:合盘完整运行 skill
|
||||
return englishOnly(scrub({
|
||||
const evidence = record(englishOnly(scrub({
|
||||
segments: timeline ?? [],
|
||||
event_timeline: eventTimelineEvidence(dossier, "en"),
|
||||
parallel_personal_timing: packet.parallel_timing_context ?? null,
|
||||
event_resonance_gate: packet.event_resonance_gate ?? null,
|
||||
reading_scope: scope,
|
||||
}));
|
||||
}))) ?? {};
|
||||
return precision ? { ...evidence, birth_precision_note: precision } : evidence;
|
||||
}
|
||||
const wanted = new Set(SECTION_BRIEFS[sectionId]);
|
||||
const briefs = Array.isArray(packet.reader_section_brief) ? packet.reader_section_brief : [];
|
||||
@@ -316,6 +318,7 @@ export function sectionEvidence(
|
||||
if (packet.parallel_timing_context) picked.parallel_personal_timing = scrub(packet.parallel_timing_context);
|
||||
if (packet.event_resonance_gate) picked.event_resonance_gate = scrub(packet.event_resonance_gate);
|
||||
}
|
||||
if (precision) picked.birth_precision_note = precision;
|
||||
return picked;
|
||||
}
|
||||
|
||||
@@ -368,6 +371,7 @@ const ZH_SYSTEM = `你在写一份专业的婚恋合盘报告的一节,按占
|
||||
术语:可以用印度占星的术语(宫、宫主、上升、D9、UL、DK、A7、Dasha、Narayana 等),但每个术语在一节里第一次出现时要用括号或半句话解释它看什么,例如「UL(上升婚姻点,看婚姻能不能被日常托住)」。不要堆公式和度数。
|
||||
reading_scope:status 是 limited 时,不写全量结论,每个判断写成条件,不得用 multi_system_consensus;blocked 时只说明为什么无法判断。
|
||||
证据等级:parameter_sensitive、user_history_verification_required、blocked 照实保留,不要升级成确定的话。
|
||||
出生时间误差内会变的层只能写成条件性证据。它们已经算出,不写成缺少或没有算出。
|
||||
不要报分数。不要用「克 / 煞 / 凶」贴标签,也不用「吉」字下判语(「功能吉星」「功能凶星」作为术语可以用)。不要说「注定」「必然」「命中」「一定会」。不要把一方说成问题源。不要替当事人做决定。不要点名补充方法(西方占星、宿曜、问事盘),也不要写出生日期、时间、地点。不要写某年结婚、领证或分开。第一句不要写成「这段关系的核心不是……」,正文也不要以这一节的标题开头。两人运限日期同时落在一段时间里,只说明各自的背景,不等于共同的事件窗口。
|
||||
示例(别人的盘,只学写法):${ZH_EXAMPLE}
|
||||
每个判断给两到三条分析。盘面行必须逐字来自证据里的某个完整字段,不要改写。证据互相冲突时把 label 降为 parameter_sensitive 或 blocked,并写成条件,不要写成应期。
|
||||
@@ -378,6 +382,7 @@ Each paragraph builds at most one main conclusion, backed by at least two agreei
|
||||
Terms: Jyotish terms are allowed (house, lord, ascendant, D9, UL, DK, A7, dasha, Narayana), but explain each one the first time it appears in a section, e.g. "UL (the Upapada, the point that shows whether a marriage is carried by daily life)". No formulas or degree tables.
|
||||
reading_scope: when its status is limited, give no full conclusion, write every judgment as a condition and never use multi_system_consensus; when blocked, only say why no judgment is possible.
|
||||
Evidence labels: keep parameter_sensitive, user_history_verification_required and blocked as they are; never upgrade them into certainty.
|
||||
Layers that vary within a person's birth-time window are computed and conditional. Do not describe them as missing or certain.
|
||||
Do not quote a score. Do not use soulmate, destined, inevitable, guaranteed. Do not call one person the problem. Do not decide for them. Do not name supplementary methods (Western astrology, Shukuyo, horary), and do not include birth dates, times, or places. Do not predict a wedding or a breakup in a named year. Do not open with "The core of this relationship is not". Do not start the body with the section title. Two people's periods running at the same time only describe each person's background; they are not a shared event window.
|
||||
Example (someone else's chart, for the voice only): ${EN_EXAMPLE}
|
||||
Give two or three supports for each judgment. The chart line must copy one complete evidence field verbatim. When supports conflict, lower the label to parameter_sensitive or blocked and write a condition, not a dated event.
|
||||
|
||||
@@ -1,4 +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 { EVENT_OVERLAP_NOTE, eventClassRows } from "./synastry-full-timeline.ts";
|
||||
|
||||
/**
|
||||
@@ -9,6 +12,7 @@ export type TechnicalBlock = Readonly<{
|
||||
id: "parameters" | "structures" | "contacts" | "timing" | "traditional" | "execution";
|
||||
title: string;
|
||||
lines: readonly string[];
|
||||
precisionAudit?: readonly { method: string; calculation: string; usage: string }[];
|
||||
}>;
|
||||
|
||||
const STATUS_LABELS: Readonly<Record<string, string>> = {
|
||||
@@ -114,12 +118,83 @@ function profileValue(
|
||||
return `${names.a} ${a ? display(a) : "未标明"},${names.b} ${b ? display(b) : "未标明"}`;
|
||||
}
|
||||
|
||||
export function parameterLines(profile: Record<string, unknown>, names: Readonly<{ a: string; b: string }>): string[] {
|
||||
export function parameterLines(profile: Record<string, unknown>, names: Readonly<{ a: string; b: string }>, precision?: unknown): string[] {
|
||||
return [
|
||||
`岁差:${profileValue(profile, names, "ayanamsa", ayanamsaName)}`,
|
||||
`交点:${profileValue(profile, names, "node_mode", (value) => NODE_MODE[value] ?? value)}`,
|
||||
`宫制:${profileValue(profile, names, "house_system", (value) => HOUSE_SYSTEM[value] ?? value)}`,
|
||||
"出生时间精度:以各自档案里已经保存的时间为准,这里不显示日期和地点",
|
||||
...(record(precision) ? precisionLines(precision) : ["出生时间精度:以各自档案里已经保存的时间为准,这里不显示日期和地点"]),
|
||||
];
|
||||
}
|
||||
|
||||
const PRECISION_NAMES: Record<string, string> = { D1: "本命上升", D9: "九分盘上升", moon: "月亮星宿与四分" };
|
||||
const PRECISION_LAYERS: Record<string, string> = {
|
||||
ascendant: "上升", houses: "宫位及互落", house_lords: "宫主", UL: "UL", A7: "A7", AL: "AL",
|
||||
narayana: "Narayana 起点", D9: "九分盘及两盘对照", ashtakoota: "传统配对的星宿项目",
|
||||
nakshatra_relationship: "星宿关系", vimshottari: "Vimshottari 起点",
|
||||
};
|
||||
const PRECISION_LAYERS_EN: Record<string, string> = {
|
||||
ascendant: "rising sign", houses: "houses and overlays", house_lords: "house lords", UL: "UL", A7: "A7", AL: "AL",
|
||||
narayana: "Narayana starting point", D9: "Navamsa and its cross-chart comparison", ashtakoota: "nakshatra-based matching",
|
||||
nakshatra_relationship: "nakshatra relationship", vimshottari: "Vimshottari starting point",
|
||||
};
|
||||
|
||||
function precisionLines(precision: unknown): string[] {
|
||||
return ["person_a", "person_b"].flatMap((side, index) => {
|
||||
const person = record(record(precision)?.[side]);
|
||||
if (!person) return [];
|
||||
const axes = record(person.axes) ?? {};
|
||||
const summary = Object.entries(PRECISION_NAMES).map(([key, label]) => {
|
||||
const row = record(axes[key]);
|
||||
if (row?.status !== "varies") return `${label}${row?.status === "stable" ? "误差内稳定" : "暂无法核对"}`;
|
||||
const candidates = Array.isArray(row.candidates) ? row.candidates.flatMap((value) => {
|
||||
const item = record(value);
|
||||
if (!item) return [];
|
||||
const moon = record(item.value);
|
||||
const sign = text(item.value);
|
||||
const name = moon ? `${NAKSHATRA_ZH[text(moon.nakshatra)] ?? text(moon.nakshatra)}第 ${moon.pada} 四分`
|
||||
: sign ? `${signZh(sign)}座` : "";
|
||||
if (!name) return [];
|
||||
const direction = item.side === "before" ? "偏早" : item.side === "after" ? "偏晚" : "档案时刻";
|
||||
const minutes = typeof item.minutes === "number" && item.minutes > 0 ? `约 ${item.minutes} 分钟` : "";
|
||||
return [`${name}(${direction}${minutes})`];
|
||||
}) : [];
|
||||
return `${label}会变${candidates.length ? `,可能是${candidates.join("、")}` : ""}`;
|
||||
});
|
||||
return [`${index === 0 ? "甲方" : "乙方"}出生时间误差:${text(person.window_label)}。${summary.join(",")}。`];
|
||||
});
|
||||
}
|
||||
|
||||
export function precisionEvidence(dossier: unknown, language: "zh" | "en"): string {
|
||||
const precision = record(record(dossier)?.birth_precision);
|
||||
const affected = ["person_a", "person_b"].flatMap((side, index) => {
|
||||
const layers = record(precision?.[side])?.affected_layers;
|
||||
const labels = Array.isArray(layers) ? layers.filter((key): key is string => typeof key === "string" && Boolean(PRECISION_LAYERS[key])) : [];
|
||||
if (!labels.length) return [];
|
||||
if (language === "zh") return [`${index === 0 ? "甲方" : "乙方"}的${labels.map((key) => PRECISION_LAYERS[key]).join("、")}`];
|
||||
return [`${index === 0 ? "Person A" : "Person B"}: ${labels.map((key) => PRECISION_LAYERS_EN[key]).join(", ")}`];
|
||||
});
|
||||
if (!affected.length) return "";
|
||||
return language === "zh" ? `${affected.join(",以及")}在出生时间误差内会变。`
|
||||
: `${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 }] : [];
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -363,7 +438,7 @@ export function buildTechnicalBasis(input: Readonly<{
|
||||
const snapshots = record(dossier.chart_snapshots) ?? {};
|
||||
const structures = record(dossier.local_structures) ?? {};
|
||||
const match = record(dossier.marriage_match) ?? {};
|
||||
const parameters = parameterLines(profile, input.names);
|
||||
const parameters = parameterLines(profile, input.names, dossier.birth_precision);
|
||||
const promises = record(dossier.relationship_promise) ?? {};
|
||||
const structure = (["a", "b"] as const).flatMap((side) => {
|
||||
const key = side === "a" ? "person_a" : "person_b";
|
||||
@@ -374,6 +449,11 @@ export function buildTechnicalBasis(input: Readonly<{
|
||||
];
|
||||
}).concat(pairLinkLines(dossier.pair_promise_links, input.names));
|
||||
const traditional = traditionalLines(match, record(input.raman), input.names);
|
||||
const lunarNotes = [];
|
||||
for (const [side, label] of [["person_a", "甲方"], ["person_b", "乙方"]] as const) {
|
||||
const moon = record(record(record(record(dossier.birth_precision)?.[side])?.axes)?.moon);
|
||||
if (moon?.status === "varies") lunarNotes.push(`${label}的月亮在出生时间误差内可能换星宿或四分。星宿吉凶、本能性情、气质类型和体质脉络的结果只作观察。`);
|
||||
}
|
||||
// 产品 2026-11-07 占星师方案:合盘完整运行 skill — the pair's one ayanamsa, the reading scope and the four event classes.
|
||||
const alignment = record(dossier.ayanamsa_alignment);
|
||||
const used = record(alignment?.used);
|
||||
@@ -388,6 +468,7 @@ export function buildTechnicalBasis(input: Readonly<{
|
||||
// 原值:execution 末尾一行「外部资料与真实案例核对:未进行,本报告是计算层归纳」
|
||||
// 新值:删掉这一行;回执里的对应审计数据仍在后台
|
||||
// 原因:产品负责人 2026-11-08:用户可见文字不出现联网/外部核验字样,后台保留
|
||||
const precisionAudit = precisionAuditRows(receipt);
|
||||
const execution = [...executionBasisLines(receipt)];
|
||||
return [
|
||||
{ id: "parameters", title: "计算参数", lines: [...parameters, ...pairLines] },
|
||||
@@ -397,7 +478,7 @@ export function buildTechnicalBasis(input: Readonly<{
|
||||
...(input.timing.length > 0 ? input.timing : ["时间线没有可用的大运边界"]),
|
||||
...(eventLines.length > 0 ? [...eventLines, EVENT_OVERLAP_NOTE.zh] : []),
|
||||
] },
|
||||
{ id: "traditional", title: "传统配对参考", lines: traditional },
|
||||
{ id: "execution", title: "技法执行情况", lines: execution },
|
||||
{ id: "traditional", title: "传统配对参考", lines: [...lunarNotes, ...traditional] },
|
||||
{ id: "execution", title: "技法执行情况", lines: execution, ...(precisionAudit.length ? { precisionAudit } : {}) },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { createHash } from "node:crypto";
|
||||
import test from "node:test";
|
||||
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";
|
||||
|
||||
const stable = { D1: { status: "stable" }, D9: { status: "stable" }, moon: { status: "stable" } };
|
||||
const person = { window_label: "没有误差信息,按前后各 30 分钟", axes: stable, affected_layers: [] };
|
||||
const receipt = {
|
||||
individual_technique_audit: [{
|
||||
technique: "D1/Rashi", status: "parameter_sensitive",
|
||||
person_a: { status: "parameter_sensitive", reason: "birth_time_window_varies" }, person_b: { status: "executed" },
|
||||
}],
|
||||
};
|
||||
const changed = {
|
||||
execution_receipt: receipt,
|
||||
birth_precision: {
|
||||
person_a: { ...person, affected_layers: ["ascendant", "houses"], axes: { ...stable, D1: { status: "varies", candidates: [
|
||||
{ value: "Aquarius", side: "center", minutes: 0 }, { value: "Pisces", side: "after", minutes: 12 },
|
||||
] } } },
|
||||
person_b: person,
|
||||
},
|
||||
};
|
||||
const hash = (value: unknown) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
||||
|
||||
test("stable birth-time scans preserve every section's writing evidence", () => {
|
||||
const dossier = { profile_gate: "passed", reader_section_brief: [] };
|
||||
const precision = { person_a: person, person_b: person };
|
||||
for (const language of ["zh", "en"] as const) {
|
||||
for (const section of SYNASTRY_SECTION_IDS) {
|
||||
assert.equal(hash(sectionEvidence(dossier, section, [], language)),
|
||||
hash(sectionEvidence({ ...dossier, birth_precision: precision }, section, [], language)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("a varying layer adds only a conditional sentence in each writing section", () => {
|
||||
for (const section of SYNASTRY_SECTION_IDS) {
|
||||
const result = sectionEvidence(changed, section) as Record<string, unknown>;
|
||||
const { birth_precision_note, ...existing } = result;
|
||||
assert.deepEqual(existing, sectionEvidence({}, section));
|
||||
assert.equal(birth_precision_note, "甲方的上升、宫位及互落在出生时间误差内会变。");
|
||||
assert.doesNotMatch(JSON.stringify(result), /没有算出|乙方/);
|
||||
}
|
||||
assert.match(systemPrompt("zh"), /会变的层只能写成条件性证据/);
|
||||
assert.match(JSON.stringify(sectionEvidence(changed, "timeline", [], "en")), /Person A: rising sign, houses and overlays/);
|
||||
});
|
||||
|
||||
test("the appendix renders window sources, Chinese candidates and only the affected audit side", () => {
|
||||
const technical = buildTechnicalBasis({ dossier: changed, names: { a: "甲", b: "乙" }, contacts: [], timing: [] });
|
||||
const appendix = renderToStaticMarkup(<SynastryReportView reportId="fictional" snapshot={{ names: { a: "甲", b: "乙" }, technical }} />)
|
||||
.split('<details class="synastry-technical">')[1];
|
||||
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|[·_]/);
|
||||
});
|
||||
|
||||
test("the request reuses the reported and adopted windows", () => {
|
||||
const row = {
|
||||
birth_date: "1990-06-15", birth_time: "12:00", latitude: 39.9, longitude: 116.4, timezone_offset: 8,
|
||||
};
|
||||
assert.equal(marriageMatchBirthBody(row, "2026-11-14").birth_time_window, undefined);
|
||||
const reportedRow = { ...row, uncertainty_before_minutes: 5, uncertainty_after_minutes: 12 };
|
||||
const reported = marriageMatchBirthBody(reportedRow, "2026-11-14");
|
||||
assert.deepEqual(reported.birth_time_window, { before_minutes: 5, after_minutes: 12, source: "user_stated" });
|
||||
assert.notEqual(marriageMatchFingerprint(reportedRow), marriageMatchFingerprint(row));
|
||||
const adopted = marriageMatchBirthBody({
|
||||
...row, birth_time_status: "accepted", active_birth_time: "12:00:30",
|
||||
active_birth_provenance: { contract: "chart-choice-v2", segment: { start_at: "1990-06-15T11:58:00", end_at: "1990-06-15T12:04:00" } },
|
||||
}, "2026-11-14");
|
||||
assert.match(JSON.stringify(adopted.birth_time_window), /"before_minutes":2.5,"after_minutes":3.5,"source":"rectified_range"/);
|
||||
assert.equal(adopted.second, 30);
|
||||
});
|
||||
|
||||
test("the owner's reusable choice supplies the other person's current window", async () => {
|
||||
const userId = "fictional-owner";
|
||||
const subjectId = "11111111-1111-4111-8111-111111111111";
|
||||
const stored = {
|
||||
id: subjectId, user_id: userId, role: "other", name: "虚构乙", birth_date: "1990-06-15",
|
||||
reported_birth_time: "11:00:00", active_birth_time: "12:00:30", birth_time_status: "accepted",
|
||||
latitude: 39.9, longitude: 116.4, timezone_offset: 8,
|
||||
};
|
||||
const query = { eq: () => query, maybeSingle: async () => ({ data: stored, error: null }) };
|
||||
const subjectClient = { from: () => ({ select: () => query }) };
|
||||
const current = {
|
||||
id: "current", reusable: true, saved_date: "1990-06-15", saved_time: "12:00:30",
|
||||
detail: { provenance: { contract: "chart-choice-v2", segment: { start_at: "1990-06-15T11:58:00", end_at: "1990-06-15T12:04:00" } } },
|
||||
};
|
||||
const admin = { rpc: async (name: string, args: Record<string, unknown>) => {
|
||||
assert.equal(name, "chart_choice_records_v1");
|
||||
assert.deepEqual(args, { p_user_id: userId, p_chart_profile_id: subjectId });
|
||||
return { data: { current_record_id: current.id, records: [current] }, error: null };
|
||||
} };
|
||||
const subject = await loadSynastrySubjectBirth(subjectClient, admin, userId, subjectId);
|
||||
assert.equal(marriageMatchBirthBody(subject.row, "2026-11-14").second, 30);
|
||||
assert.match(JSON.stringify(marriageMatchBirthBody(subject.row, "2026-11-14").birth_time_window), /rectified_range/);
|
||||
current.saved_time = "12:01:30";
|
||||
const stale = await loadSynastrySubjectBirth(subjectClient, admin, userId, subjectId);
|
||||
assert.equal(marriageMatchBirthBody(stale.row, "2026-11-14").birth_time_window, undefined);
|
||||
});
|
||||
@@ -352,3 +352,11 @@ evidence_card.backstage records, for the backend only, that global web evidence
|
||||
- 出生时间误差按 #224:用户自报的误差,否则前后 30 分钟。
|
||||
- 研究方法(Yoga/Nakshatra Pravesha)只作观察,不进必需。
|
||||
- 本条不减少她要求执行的任何技法,也不把「需说明」项写成结论依据。
|
||||
|
||||
## L. 合盘的暂行做法(产品 2026-11-14,待占星师裁定)
|
||||
<!-- 产品对她合盘子 skill(skills/jyotish-full-synastry-reading,7a773d13)的暂行落地,不是她的方法。依据:2026-11-14 合盘差距盘点;产品负责人 2026-11-12「计算依据附录照实列网上资料核对、真实案例校准两行」、2026-11-13 出生时间误差规则(#224)。下列各条在她裁定前暂行,裁定后按她的改。 -->
|
||||
|
||||
- 技法执行情况分两栏:「计算」照她回执的状态写;`ready_for_comparison` 写「输入已齐」,不写「已执行」(她 SKILL.md:105-107)。「在本报告中」是产品的 v1 映射:executed、ready_for_comparison 写「供写作参考」,parameter_sensitive、partial 写「只作观察」,blocked、not_applicable 写「未使用」并附理由。
|
||||
- 附录照实列「网上资料核对:未完成」「真实案例校准:未完成」两行。正文不提。
|
||||
- 出生时间误差:每人用自报误差,没填按前后 30 分钟。某人的 D1 上升、D9 上升或月亮星宿在误差内会变时,只把这个人一侧依赖它的层,以及用到这一侧的两盘对照,标为参数敏感,并在附录写明;另一人不受影响。是只封一侧还是整层都封,待她裁定(合盘问题 6)。
|
||||
- 以下沿用现状,待她裁定,不算产品规则:附录显示的回执方法名(问题 1)、模型自选的 6 个断言标签(问题 2)、产品自写的逐类激活扫描和四类事件(问题 3–5)、Raman 默认并列显示(问题 8)。
|
||||
|
||||
@@ -11,6 +11,7 @@ import os
|
||||
from typing import Any
|
||||
|
||||
from marriage_match import build_marriage_match_dossier
|
||||
from marriage_match_service.birth_precision import normalized_birth_window
|
||||
from marriage_match_service.full_dossier import RULES_VERSION, build_synastry_full_dossier
|
||||
|
||||
try:
|
||||
@@ -71,6 +72,7 @@ def _birth_identity(body: dict[str, Any]) -> dict[str, Any]:
|
||||
"tz": body.get("tz"),
|
||||
"ayanamsa": body.get("ayanamsa", "lahiri"),
|
||||
"node_mode": node or "mean",
|
||||
"birth_precision_window": normalized_birth_window(body),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
"""Scan the two natal clocks without changing the upstream synastry builder."""
|
||||
|
||||
from datetime import datetime
|
||||
from math import ceil
|
||||
|
||||
from ashtakoot import get_nakshatra
|
||||
from ayanamsa_utils import swe, temporary_ayanamsa
|
||||
from domain_calculation_service import swiss_ephemeris_lock
|
||||
from jyotish_engine import SIGNS, _sidereal_calculation_profile
|
||||
from report_render.birth_precision_window import birth_window_label_zh, crosses_birth_window, report_birth_window
|
||||
from varga import calc_varga
|
||||
|
||||
|
||||
LAYERS = {
|
||||
"D1": ("ascendant", "houses", "house_lords", "UL", "A7", "AL", "narayana"),
|
||||
"D9": ("D9",),
|
||||
"moon": ("ashtakoota", "nakshatra_relationship", "vimshottari"),
|
||||
}
|
||||
MODULES = {
|
||||
"D1": {"chart", "functional_benefic_malefic", "bhava_chalit", "narayana_dasha", "jaimini", "special_lagnas", "argala", "bhava_bala"},
|
||||
"D9": {"varga_full.D9_Navamsa", "d9_navamsa_expanded"},
|
||||
"moon": {"dasha", "dasha_sandhi", "nakshatra_dasha", "nakshatra_advanced"},
|
||||
}
|
||||
MATCHING_TASK = "international Ashtakoota core, additional Kutas, Mars-only Kuja and separate Papasamya"
|
||||
D1_ARUDHA_TECHNIQUES = {"Upapada Lagna (UL)", "Arudha Lagna"}
|
||||
|
||||
|
||||
def normalized_birth_window(person):
|
||||
return report_birth_window(person.get("birth_time_window"), minute_confirmed=person.get("reading_minute_confirmed") is True)
|
||||
|
||||
|
||||
def _scan(margin, window, value_at):
|
||||
before = crosses_birth_window(margin["before_minutes"], None, window)
|
||||
after = crosses_birth_window(None, margin["after_minutes"], window)
|
||||
if not (before or after):
|
||||
return {"status": "stable"}
|
||||
candidates = [{"value": value_at(0), "side": "center", "minutes": 0}]
|
||||
for edge, sign, crossed in (("before", -1, before), ("after", 1, after)):
|
||||
if not crossed:
|
||||
continue
|
||||
offset = margin[f"{edge}_minutes"]
|
||||
end = int(window[f"{edge}_minutes"] * 60)
|
||||
start = round(offset * 60)
|
||||
samples = [start, *range(start, end, 30), end]
|
||||
for seconds in sorted(set(samples)):
|
||||
value = value_at(sign * seconds)
|
||||
if any(row["value"] == value and row["side"] in (edge, "center") for row in candidates):
|
||||
continue
|
||||
candidates.append({"value": value, "side": edge, "minutes": round(seconds / 60, 2)})
|
||||
return {"status": "varies", "candidates": candidates}
|
||||
|
||||
|
||||
def _moon_margin(value_at, direction, limit):
|
||||
natal = value_at(0)
|
||||
for far in range(60, ceil(limit * 60) + 61, 60):
|
||||
if value_at(direction * far) == natal:
|
||||
continue
|
||||
near = far - 60
|
||||
while far - near > 1:
|
||||
mid = (near + far) // 2
|
||||
if value_at(direction * mid) == natal:
|
||||
near = mid
|
||||
else:
|
||||
far = mid
|
||||
return far / 60
|
||||
return None
|
||||
|
||||
|
||||
def scan_birth_precision(person):
|
||||
window = normalized_birth_window(person)
|
||||
axes = {key: {"status": "blocked"} for key in LAYERS}
|
||||
result = {"window": {key: window[key] for key in ("before_minutes", "after_minutes", "source")},
|
||||
"window_label": birth_window_label_zh({key: window[key] for key in ("before_minutes", "after_minutes", "source")}),
|
||||
"axes": axes, "affected_layers": []}
|
||||
if swe is None:
|
||||
return result
|
||||
from report_render.birth_precision_margins import ascendant_margins
|
||||
|
||||
try:
|
||||
date = datetime(*(int(person[key]) for key in ("year", "month", "day", "hour", "minute")), int(person.get("second") or 0))
|
||||
tz, lat, lon = (float(person[key]) for key in ("tz", "lat", "lon"))
|
||||
ayanamsa = person.get("ayanamsa") or "lahiri"
|
||||
birth = {"date": date.date().isoformat(), "time": date.time().isoformat(), "tz": tz, "lat": lat, "lon": lon, "ayanamsa_name": ayanamsa}
|
||||
jd = swe.julday(date.year, date.month, date.day, date.hour + date.minute / 60 + date.second / 3600 - tz)
|
||||
margins = ascendant_margins(birth, {1, 9}, window=window)
|
||||
with swiss_ephemeris_lock(), temporary_ayanamsa(ayanamsa, swe):
|
||||
def ascendant(seconds, division):
|
||||
sample = jd + seconds / 86400
|
||||
_, _, offset = _sidereal_calculation_profile(sample, "legacy")
|
||||
cusps, _ = swe.houses(sample, lat, lon, b"A")
|
||||
longitude = (cusps[0] - offset) % 360
|
||||
index = int(longitude // 30) if division == 1 else calc_varga(longitude, division)["sign_idx"]
|
||||
return SIGNS[index]
|
||||
|
||||
def moon(seconds):
|
||||
sample = jd + seconds / 86400
|
||||
_, flags, offset = _sidereal_calculation_profile(sample, "legacy")
|
||||
position, _ = swe.calc_ut(sample, swe.MOON, flags)
|
||||
value = get_nakshatra((position[0] - offset) % 360)
|
||||
return {"nakshatra": value["name"], "pada": value["pada"]}
|
||||
|
||||
for division in (1, 9):
|
||||
key = f"D{division}"
|
||||
if key in margins:
|
||||
axes[key] = _scan(margins[key], window, lambda seconds: ascendant(seconds, division))
|
||||
moon_margin = {f"{side}_minutes": _moon_margin(moon, direction, window[f"{side}_minutes"])
|
||||
for side, direction in (("before", -1), ("after", 1))}
|
||||
axes["moon"] = _scan(moon_margin, window, moon)
|
||||
except (KeyError, TypeError, ValueError, swe.Error):
|
||||
pass
|
||||
result["affected_layers"] = [layer for key, axis in axes.items() if axis["status"] == "varies" for layer in LAYERS[key]]
|
||||
return result
|
||||
|
||||
|
||||
def add_pair_birth_precision(dossier, person_a, person_b):
|
||||
"""Temporary rule from L.3: mark the affected side and its comparisons only."""
|
||||
precision = {"person_a": scan_birth_precision(person_a), "person_b": scan_birth_precision(person_b)}
|
||||
dossier["birth_precision"] = precision
|
||||
affected = {side: {key for key, row in person["axes"].items() if row["status"] == "varies"}
|
||||
for side, person in precision.items()}
|
||||
if not any(affected.values()):
|
||||
return
|
||||
modules = {side: set().union(*(MODULES[key] for key in axes)) for side, axes in affected.items()}
|
||||
receipt = dossier.get("execution_receipt") or {}
|
||||
for row in receipt.get("individual_technique_audit", []):
|
||||
technique = row.get("technique")
|
||||
for side, paths in modules.items():
|
||||
item = row.get(side) or {}
|
||||
path = str(item.get("source_path", "")).removeprefix("modules.")
|
||||
varies = path in paths and technique != "Darakaraka (DK)"
|
||||
varies |= path == "yogas_doshas" and "D1" in affected[side] and technique in D1_ARUDHA_TECHNIQUES
|
||||
if varies and _mark(item):
|
||||
_mark(row)
|
||||
for row in receipt.get("pair_execution_tasks", []):
|
||||
for item in row.get("required_inputs", []):
|
||||
path = str(item.get("source_path", "")).removeprefix("modules.")
|
||||
for side, paths in modules.items():
|
||||
matching = row.get("task") == MATCHING_TASK
|
||||
varies = "moon" in affected[side] if matching else path in paths
|
||||
if varies and _mark(item, f"{side}_status", f"{side}_reason"):
|
||||
_mark(item)
|
||||
_mark(row)
|
||||
match = dossier.get("marriage_match") or {}
|
||||
koota = (match.get("ashtakoota_36") or {}).get("international_core") or {}
|
||||
moon_sides = [side for side, values in affected.items() if "moon" in values]
|
||||
if koota and moon_sides:
|
||||
koota["birth_precision"] = {
|
||||
"status": "parameter_sensitive", "sides": moon_sides,
|
||||
"affected_items": [name for name in ("Tara", "Yoni", "Gana", "Nadi") if name in (koota.get("scores") or {})],
|
||||
}
|
||||
for item in dossier.get("pair_promise_links", []):
|
||||
if (item.get("anchor") == "ascendant" and "D1" in affected.get(item.get("to"), set())
|
||||
or item.get("point") in {"seventh_lord", "upapada", "A7"} and "D1" in affected.get(item.get("from"), set())):
|
||||
_mark_overlay(item)
|
||||
interaction = dossier.get("pair_interaction_evidence") or {}
|
||||
for side, axis in affected.items():
|
||||
other = "person_b" if side == "person_a" else "person_a"
|
||||
overlay = f"{other}_to_{side}_overlays"
|
||||
for key, evidence in (("D1", interaction), ("D9", interaction.get("d9_interaction_evidence") or {})):
|
||||
if key not in axis:
|
||||
continue
|
||||
for item in evidence.get(overlay, []):
|
||||
_mark_overlay(item)
|
||||
for item in (evidence.get("recipient_experience_evidence") or {}).get(side, []):
|
||||
if "recipient_house" in item:
|
||||
_mark_overlay(item)
|
||||
|
||||
|
||||
def _mark_overlay(item):
|
||||
item["birth_precision"] = {"status": "parameter_sensitive", "reason": "birth_time_window_varies"}
|
||||
|
||||
|
||||
def _mark(item, field="status", reason="reason"):
|
||||
if item.get(field) in {"blocked", "not_applicable", "not_available"}:
|
||||
return False
|
||||
item[field] = "parameter_sensitive"
|
||||
item[reason] = "birth_time_window_varies"
|
||||
return True
|
||||
@@ -744,6 +744,9 @@ def build_synastry_full_dossier(
|
||||
"person_b": relationship_promise(reading_b if isinstance(reading_b, dict) else {}),
|
||||
}
|
||||
dossier["pair_promise_links"] = pair_promise_links(dossier["local_structures"], dossier["relationship_promise"])
|
||||
from marriage_match_service.birth_precision import add_pair_birth_precision
|
||||
|
||||
add_pair_birth_precision(dossier, person_a, person_b)
|
||||
today = str(person_a.get("today") or person_b.get("today") or "")
|
||||
if isinstance(dossier, dict):
|
||||
dossier["ayanamsa_alignment"] = ayanamsa_alignment
|
||||
|
||||
@@ -134,7 +134,15 @@ def test_public_pair_dossier_reading_scope_follows_upstream_readiness():
|
||||
dossier = packet["dossier"]
|
||||
assert dossier["profile_gate"] == "passed"
|
||||
tasks = {row["task"]: row["status"] for row in dossier["execution_receipt"]["pair_execution_tasks"]}
|
||||
assert tasks["two-person Dasha/Narayana/Chara context comparison"] == "ready_for_comparison"
|
||||
timing = "two-person Dasha/Narayana/Chara context comparison"
|
||||
precision = dossier["birth_precision"]
|
||||
assert {side: value["window"]["source"] for side, value in precision.items()} == {
|
||||
"person_a": "default_unknown_30", "person_b": "default_unknown_30",
|
||||
}
|
||||
assert {side: [axis["status"] for axis in value["axes"].values()] for side, value in precision.items()} == {
|
||||
"person_a": ["stable", "varies", "stable"], "person_b": ["varies", "varies", "stable"],
|
||||
}
|
||||
assert tasks[timing] == "parameter_sensitive"
|
||||
assert dossier["delivery_readiness"] == "ready_for_narrative"
|
||||
assert dossier["reading_scope"]["status"] == "full"
|
||||
assert dossier["ayanamsa_alignment"]["status"] == "same_profile"
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Precision changes are local to the person and the dependent comparison."""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
||||
|
||||
import pytest
|
||||
|
||||
from marriage_match_service import birth_precision as precision
|
||||
from marriage_match_service.api import _birth_identity
|
||||
|
||||
|
||||
@pytest.mark.parametrize("changes", [(), ("D1",), ("D9",), ("moon",)])
|
||||
def test_birth_precision_only_marks_dependent_layers(monkeypatch, changes):
|
||||
side = "person_b" if changes == ("D9",) else "person_a"
|
||||
monkeypatch.setattr(precision, "scan_birth_precision", lambda person: {
|
||||
"axes": {key: {"status": "varies" if key in person else "stable"} for key in precision.LAYERS},
|
||||
"affected_layers": [],
|
||||
})
|
||||
audit = [{"technique": name, "status": "executed",
|
||||
"person_a": {"status": "executed", "source_path": path},
|
||||
"person_b": {"status": "executed", "source_path": path}}
|
||||
for name, path in (("D1/Rashi", "modules.chart"), ("D9/Navamsa", "modules.varga_full.D9_Navamsa"),
|
||||
("Vimshottari", "modules.dasha"))]
|
||||
overlays = {"person_a_to_person_b_overlays": [{}], "person_b_to_person_a_overlays": [{}]}
|
||||
d9_overlays = {key: [{}] for key in overlays}
|
||||
overlays["d9_interaction_evidence"] = d9_overlays
|
||||
pairs = [{"task": "D1/D9 mutual overlays and relationship axes", "status": "ready_for_comparison",
|
||||
"required_inputs": [{"source_path": "modules.varga_full.D9_Navamsa", "status": "ready_for_comparison",
|
||||
"person_a_status": "executed", "person_b_status": "executed"}]}]
|
||||
core = {"scores": {"Tara": 1, "Nadi": 2, "Vashya": 1}}
|
||||
dossier = {"execution_receipt": {"individual_technique_audit": audit, "pair_execution_tasks": pairs},
|
||||
"pair_interaction_evidence": overlays, "marriage_match": {"ashtakoota_36": {"international_core": core}}}
|
||||
precision.add_pair_birth_precision(dossier, changes if side == "person_a" else (), changes if side == "person_b" else ())
|
||||
for key, item in zip(("D1", "D9", "moon"), audit, strict=True):
|
||||
for candidate in ("person_a", "person_b"):
|
||||
expected = "parameter_sensitive" if candidate == side and key in changes else "executed"
|
||||
assert item[candidate]["status"] == expected
|
||||
assert ("birth_precision" in overlays["person_b_to_person_a_overlays"][0]) == ("D1" in changes)
|
||||
assert "birth_precision" not in overlays["person_a_to_person_b_overlays"][0]
|
||||
assert ("birth_precision" in d9_overlays["person_a_to_person_b_overlays"][0]) == ("D9" in changes)
|
||||
assert "birth_precision" not in d9_overlays["person_b_to_person_a_overlays"][0]
|
||||
assert (pairs[0]["status"] == "parameter_sensitive") == ("D9" in changes)
|
||||
if "moon" in changes:
|
||||
assert core["birth_precision"]["affected_items"] == ["Tara", "Nadi"]
|
||||
assert core["scores"]["Nadi"] == 2
|
||||
else:
|
||||
assert "birth_precision" not in core
|
||||
|
||||
|
||||
def test_native_window_and_cache_identity_default_and_declared():
|
||||
person = dict(year=1990, month=6, day=15, hour=12, minute=0, lat=39.9, lon=116.4, tz=8, ayanamsa="raman")
|
||||
default = precision.scan_birth_precision(person)
|
||||
assert default["window"] == {"before_minutes": 30, "after_minutes": 30, "source": "default_unknown_30"}
|
||||
assert default["axes"]["D1"]["status"] == "varies"
|
||||
assert any(c["side"] == "after" for c in default["axes"]["D1"]["candidates"])
|
||||
declared = {**person, "birth_time_window": {"before_minutes": 1, "after_minutes": 1, "source": "user_stated"}}
|
||||
assert precision.scan_birth_precision(declared)["axes"]["D1"] == {"status": "stable"}
|
||||
assert _birth_identity(person) != _birth_identity(declared)
|
||||
|
||||
|
||||
def test_lunar_pada_boundary_is_detected_inside_the_window():
|
||||
def moon(second):
|
||||
return {"nakshatra": "Ashwini", "pada": 2 if second >= 35 else 1}
|
||||
after = precision._moon_margin(moon, 1, 1)
|
||||
scan = precision._scan({"before_minutes": None, "after_minutes": after},
|
||||
{"before_minutes": 0, "after_minutes": 1, "source": "user_stated"}, moon)
|
||||
assert scan["status"] == "varies"
|
||||
assert scan["candidates"][-1] == {"value": {"nakshatra": "Ashwini", "pada": 2}, "minutes": 0.58, "side": "after"}
|
||||
Reference in New Issue
Block a user