Merge current staging for #218 repair verification
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
# 印度占星 Skill 更新日志
|
||||
|
||||
## 2026-11-13 — 个人报告按出生时间范围核对分盘边界
|
||||
|
||||
- 出生分钟未确认时,个人报告用填报的时间范围核对各分盘上升。误差未知时按前后各 30 分钟。必需分盘在范围内换座的结论暂不能判断。
|
||||
- 沿用当前 Skill 版本(BUG-1864)。
|
||||
|
||||
## 2026-11-12 — 个人报告补充事实核对与依据清单
|
||||
|
||||
- 逐节核对宫主与落宫、标准 SAV 总和、阻碍宫及具体健康风险,并拦截没有依据的数值准确率说法。
|
||||
|
||||
@@ -25143,3 +25143,17 @@
|
||||
- 相关记录:BUG-1854、BUG-1859、BUG-1848、#192。
|
||||
- 复发自:无。
|
||||
- 修复版本:`codex/reading-postcheck-facts-20261112`,待发布。
|
||||
|
||||
## BUG-1864 | 个人报告未确认出生分钟时漏查分盘边界
|
||||
|
||||
- 状态:fixed-pending-verify(待独立验收)。
|
||||
- 首次发现 / 最近更新:2026-11-13 / 2026-11-13。
|
||||
- 影响面:个人报告事实包、分盘上升边界与证据等级上限。
|
||||
- 现象:出生时间未确认到分钟时,必需分盘可能在填写范围内换座,依赖该分盘的判断仍可到 C。
|
||||
- 触发条件:报告依赖临近上升换座的分盘,档案使用报告时间、填报范围或未知误差。
|
||||
- 根因:未确认分钟时 `_varga_boundary` 直接返回 `not_evaluated`,不会限制上限。报告请求也没有区分单一计算时刻和确认到分钟。
|
||||
- 修复:报告事实包传入填报的两侧误差及来源,未知时用前后各 30 分钟。必需分盘跨边界时上限为 D。确认分钟继续按前后各 1 分钟,用途稳定性独立。
|
||||
- 验证:合成回归覆盖默认和填报范围、单侧误差、端点、时辰、请求缓存隔离,以及旧分钟规则。详见 `docs/tasks/PROGRESS-reading-birth-window-20261113.md`。
|
||||
- 防复发:分别核对边界行的状态、两侧误差及来源,并验证临界分盘只影响依赖它的结论。
|
||||
- 关联记录:#224、#144、BUG-1858、BUG-1848。
|
||||
- 修复版本:`codex/reading-birth-window-20261113`,待发布。
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# PROGRESS:未确认分钟的个人报告分盘边界(#224)
|
||||
|
||||
## 输入链与影响
|
||||
|
||||
- 从 #144 的 `birthTimePersistenceValues` 写入 `profiles` / `chart_profiles` 的 `uncertainty_before_minutes`、`uncertainty_after_minutes`、`birth_time_uncertainty_known`、`birth_time_source`、`birth_time_period`、`birth_time_shichen` 和 `declared_window_start/end` 开始核对。`loadSubjectBirth` 对本人及档案走各自的所有权查询,报告 worker 读取这一行。本人查询补选数据库已存在且已授权的 `birth_time_period`,与档案读取对齐。
|
||||
- `generatePersonalReportLongform` 经 `buildLongformBirthPayload` 传到 `/api/professional_report_reference`。原 `provenanceUncertaintyMinutes` 合计只用于来源信息。新增 `birth_time_window` 保留两侧与来源,优先使用围绕实际计算时刻的最早、最晚,其次用历史的两侧分钟数。明确未知、缺字段和历史 0/0 交由事实包默认。早晚与跨午夜沿用 `uncertaintyFromDeclaredRange`。时辰、时段用 `declared-birth-window.ts` 的产品定义。
|
||||
- 一个报告可用的计算时刻不能证明分钟已确认。`reading_minute_confirmed: false` 只作用于报告事实包,保留现有计算入口的 `birth_time_accuracy` 和校正候选范围。已有对称或不对称误差字段的 Python 调用也直接复用。`_reading_request` 正规化范围后写入缓存身份,再经 `_reading_facts` 到 `birth_precision.window`。
|
||||
- 有合法计算时刻的时辰或时段可使用各自起止作为边界。仅有时段且无可用计算时刻的档案仍走现有报告准入条件。
|
||||
- `birth_record_window_v1` 按各侧误差分别核对,边界刚好落在范围端点时也算跨边界。分盘边界扫描至少走到误差范围以外,避免把旧 240 分钟的搜索上限当作一次换座。分钟已确认时仍使用 `birth_record_minute_v1` 前后各 1 分钟,既有账本形状保留。`purpose_stability` 和 `PRECISION_VARGA` 参与门槛照旧。
|
||||
|
||||
## 既有断言
|
||||
|
||||
| 位置 | 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- | --- |
|
||||
| `test_report_evidence_grade_20261112.py` 未确认的事业上限 | D10 换座距离 30 分钟时为 C | 默认窗口端点包含换座,上限 D | #224 默认前后各 30 分钟,保留用途未评估断言。 |
|
||||
| `test_evidence_grade_purpose_stability_20261112.py` 未确认的边界行 | D1 与 D9 都是 `not_evaluated` | D1 `clear`,缺少距离的 D9 `missing` | 两行按窗口核对,性格上限仍为 C,用途仍未评估。 |
|
||||
| `server-owned-birth-profile.test.ts` 本人查询字段 | `birth_time_source` 后直接为 `country_code` | 中间加入 `birth_time_period` | 复用已有字段读取历史时段,其他列与顺序照旧。 |
|
||||
|
||||
## 聊天证据卡(需拍板)
|
||||
|
||||
聊天证据卡继续使用自己的参与门槛。若后续采用报告规则,部分依赖分盘的聊天判断会需要暂缓,计算还需要逐侧搜索边界。涉及的展示口径和响应时延需产品确认。
|
||||
|
||||
## 验证
|
||||
|
||||
- 开工基线 `b1bb5c53fd19307caf7e4f2fd519bd7809daffe6`。预检核实 Gitea 远端及引擎适配器,碎片扫描和预检定向组分别在本机 90 秒及 45 秒超时。
|
||||
- 前端报告、档案读取和来源字段定向 54 项通过。TypeScript、生产构建通过,Lint 0 错误、62 条既有警告。首页 `/` 保持 `○ Static`,首屏 39 个资源,JS gzip 515860 字节、CSS gzip 90886 字节,均与基线相同。
|
||||
- 请求与缓存隔离定向 6 项通过,包括时辰请求进报告事实包,以及同一计算时刻的不同误差范围分别缓存。
|
||||
- Python 定向 55 项通过,覆盖新增窗口、#215、#216 与既有报告事实包。
|
||||
- 前端按 `npm test` 同一文件清单和并发数对照。staging 3665 项中 3638 项通过,分支 3668 项中 3641 项通过。两边均为同名 27 项失败、0 项取消或跳过,退出码均为 1。原测试名全部保留,新增 3 项通过。
|
||||
- Python 快速门 1463 项通过、2 项跳过、29 个子测试通过,退出 1。失败的 3 项与开工基线完全相同,均在 `tests/test_upstream_technique_layers.py`(固定公开盘、大运注册表、Kaala 对照)。隐私守卫 62 项通过。
|
||||
@@ -0,0 +1,83 @@
|
||||
# TASK:出生时间没确认到分钟时,按用户填的误差范围(没填按 ±30 分钟)判断分盘边界(2026-11-13)
|
||||
|
||||
- Gitea:#224
|
||||
- 分支:`codex/reading-birth-window-20261113`,基于 staging `b1bb5c53fd19307caf7e4f2fd519bd7809daffe6`
|
||||
- Bug 编号:BUG-1864(开工时核对 `docs/BUG_HISTORY.md` 末尾;若已被占用就顺延,并在 PROGRESS 写明)
|
||||
- 验收:Claude(jyotisha-e6)
|
||||
|
||||
不得自行写「产品决定/裁定」。任务书没写到的取舍,一律选「需拍板」。
|
||||
|
||||
不得修改或删除既有断言来让测试通过。确需修改的,在 PROGRESS 里逐条写明原值、新值和原因。
|
||||
|
||||
占星师的引擎和资料(`scripts/jyotish_engine.py`、`scripts/yoga_engine.py`、`references/` 下她仓库已有的文件、`SKILL.md`)一律不改。产品差异只能放进单独的产品文件,并在 `references/product_runtime_contract.md` 公告(项目规则 2026-11-07)。
|
||||
|
||||
占星师回复原文:`docs/tasks/ref-astrologer-acceptance-reply-20261112.md`,由本分支第一个提交带入。下文的「她 §N」都指这份文件。
|
||||
|
||||
## 背景
|
||||
|
||||
产品负责人 2026-11-13 导出了一份报告。出生时间填的是 05:00,没有确认到分钟。D2、D6、D8、D10 的上升离换座只有约 0.3 分钟,D9 约 8 分钟,D1 约 73 分钟。可是事业、财富、健康的结论照样用了这几张分盘,而且都给到 C。
|
||||
|
||||
原因在 `scripts/report_render/evidence_grade.py::_varga_boundary`:
|
||||
|
||||
- `minute_confirmed` 为假时,直接返回 `not_evaluated`;
|
||||
- `not_evaluated` 不算缺失,所以上限仍是 C。
|
||||
|
||||
她 §2 P0-1 要求:会跨越边界的判断,必须分支,或者暂缓给确定结论。
|
||||
|
||||
**产品负责人 2026-11-13 的决定:**
|
||||
|
||||
- 出生时间没确认到分钟时,用用户在填写出生信息时给的范围(#144:最早、最晚)。
|
||||
- 用户没给范围(选了「不清楚误差」,或者只是大概记得),默认按 **±30 分钟**。
|
||||
- 只记得时辰、只知道时段的,用该时辰或时段本身的起止。
|
||||
- 必需分盘的上升在这个范围内会换座的,记为 `boundary_sensitive`,依赖它的结论上限降为 D。
|
||||
|
||||
## 要做的
|
||||
|
||||
1. **找出误差数据的来源。** 从资料表字段一路追到报告生成请求,再到 Python 端的报告事实包,写进 PROGRESS。相关字段:`uncertainty_before_minutes`、`uncertainty_after_minutes`、`birth_time_uncertainty_known`、`birth_time_source`、`birth_time_period`、`birth_time_shichen`、`declared_window_start/end`。`frontend/src/lib/personal-report-longform-birth.ts` 里已有 `provenanceUncertaintyMinutes`,先看它是怎么传的。
|
||||
- 现有请求已经带误差的,直接用。
|
||||
- 没带的,在报告生成请求里补传前后两个分钟数和它的来源。改动尽量小,在 PROGRESS 列出改了哪些文件。
|
||||
2. **报告事实包加字段。** `birth_precision` 新增 `window`,形如 `{"before_minutes": 前误差, "after_minutes": 后误差, "source": 来源}`。`source` 取以下之一:
|
||||
- `user_stated`:用户给了最早、最晚;
|
||||
- `default_unknown_30`:没给范围,按 ±30 分钟;
|
||||
- `shichen`:只记得时辰,取该时辰的起止;
|
||||
- `period`:只知道时段,取该时段的起止;
|
||||
- `confirmed_minute`:已确认到分钟。
|
||||
|
||||
时辰和时段的起止,取产品现有的定义(`birth-time-intake-model.ts` 或后端的对应常量),不要自己另定。
|
||||
3. **上限计算**(`evidence_grade.py::_varga_boundary`)
|
||||
- 已确认到分钟:行为不变,仍按 `birth_record_minute_v1` 的 ±1 分钟。
|
||||
- 没确认到分钟:用 `birth_precision.window` 检查,`policy` 为 `birth_record_window_v1`。
|
||||
- 前误差与 `before_minutes` 边界比,后误差与 `after_minutes` 边界比,只要有一侧边界落在误差之内,就记为 `boundary_sensitive`;两侧都在误差之外,记为 `clear_at_tolerance`。
|
||||
- `boundary_check.rows` 里记下前后两个误差值和来源。
|
||||
- 事实包里没有 `window` 时,按 `default_unknown_30` 处理,不能退回 `not_evaluated`。
|
||||
- `purpose_stability` 照旧取事实包的值,不受这一条影响(#215)。
|
||||
4. **D30 等精度分盘**:`PRECISION_VARGA` 按现有规则不参与,保持不变。
|
||||
|
||||
## 不要碰
|
||||
|
||||
- `frontend/src/lib/personal-report-reading.ts`(#218 在改)
|
||||
- `references/**`
|
||||
- 冻结文件
|
||||
- 聊天证据卡。聊天是否采用同一规则,在 PROGRESS 里列出影响,选需拍板,不要改。
|
||||
|
||||
## 验收标准(新测试)
|
||||
|
||||
1. 合成事实,未确认到分钟、没有 `window`:D1 边界 73 分钟记为 clear;D9 边界 8 分钟、D2/D6/D8/D10 边界 0.3 分钟都记为 `boundary_sensitive`。`wealth_*`、`health_pressure`、`career_promise`、`relationship_structure` 的上限都是 D;`character_structure`(必需依赖只有 D1)的上限是 C。
|
||||
2. 同一份事实,`window` 为 `{"before_minutes": 5, "after_minutes": 5, "source": "user_stated"}`:D9 记为 clear,上限 C;D2 仍是 `boundary_sensitive`,上限 D。
|
||||
3. 前后误差不对称(例如前 0、后 20)时,只检查对应那一侧。
|
||||
4. 已确认到分钟的旧测试全部通过,上限不变。
|
||||
5. 用一个只记得时辰的合成请求,确认 `window.source == "shichen"`,且前后误差与产品对该时辰的定义一致。
|
||||
6. #215 和 #216 的测试,以及报告事实包的测试,全部通过。
|
||||
|
||||
## 自测命令
|
||||
|
||||
```
|
||||
python3 -m pytest -q tests/test_report_evidence_grade_20261112.py tests/test_evidence_grade_purpose_stability_20261112.py tests/test_reading_facts_v3_20261112.py tests/test_report_reading_facts.py
|
||||
python3 scripts/run_quality_gate.py --profile quick --skip-frontend-runtime
|
||||
cd frontend && npx tsc --noEmit -p . && npx eslint . # 只有改了前端才跑;改了前端还要跑相关测试
|
||||
```
|
||||
|
||||
## 何时停下来选「需拍板」
|
||||
|
||||
- 报告生成请求里拿不到误差,而且补传必须改数据库结构。
|
||||
- 时辰或时段的起止,产品里有两套互相矛盾的定义。
|
||||
@@ -1,6 +1,8 @@
|
||||
import {
|
||||
globalBirthProfileFromAccountRow,
|
||||
} from "./server-owned-birth-profile";
|
||||
import { uncertaintyFromDeclaredRange } from "./birth-time-intake-model";
|
||||
import { declaredClockRangeFromProfile, isBirthClockText, isShichenId, SHICHEN_RANGES } from "./declared-birth-window";
|
||||
|
||||
export function utcToday(now = new Date()): string {
|
||||
return now.toISOString().slice(0, 10);
|
||||
@@ -46,6 +48,34 @@ export function provenanceUncertaintyMinutes(
|
||||
return Math.max(0, (hasBefore ? before : 0) + (hasAfter ? after : 0));
|
||||
}
|
||||
|
||||
function windowSide(value: unknown): number | null {
|
||||
if (typeof value !== "number" && (typeof value !== "string" || !value.trim())) return null;
|
||||
const minutes = Number(value);
|
||||
return Number.isInteger(minutes) && minutes >= 0 && minutes <= 720 ? minutes : null;
|
||||
}
|
||||
|
||||
/** The intake window around the actual calculation clock, separate from an inferred candidate range. */
|
||||
function readingBirthWindow(profile: Readonly<Record<string, unknown>>, clock: string) {
|
||||
const shichen = profile.birth_time_shichen;
|
||||
if (profile.birth_time_source === "period_only") {
|
||||
const range = isShichenId(shichen) ? SHICHEN_RANGES[shichen] : declaredClockRangeFromProfile(profile);
|
||||
const sides = range && uncertaintyFromDeclaredRange(clock, range.startTime, range.endTime);
|
||||
return sides ? { before_minutes: sides.before, after_minutes: sides.after, source: isShichenId(shichen) ? "shichen" : "period" } : undefined;
|
||||
}
|
||||
if (profile.birth_time_uncertainty_known === false) return undefined;
|
||||
const start = accountText(profile, "declared_window_start")?.slice(0, 5);
|
||||
const end = accountText(profile, "declared_window_end")?.slice(0, 5);
|
||||
if (isBirthClockText(start) && isBirthClockText(end)) {
|
||||
const sides = uncertaintyFromDeclaredRange(clock, start, end);
|
||||
return sides ? { before_minutes: sides.before, after_minutes: sides.after, source: "user_stated" } : undefined;
|
||||
}
|
||||
const before = windowSide(profile.uncertainty_before_minutes);
|
||||
const after = windowSide(profile.uncertainty_after_minutes);
|
||||
return before !== null && after !== null && (before > 0 || after > 0)
|
||||
? { before_minutes: before, after_minutes: after, source: "user_stated" }
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function buildLongformBirthPayload(
|
||||
row: unknown,
|
||||
extras: Readonly<{
|
||||
@@ -53,6 +83,7 @@ export function buildLongformBirthPayload(
|
||||
targetYear: number;
|
||||
candidateRange: { start_time: string; end_time: string; candidate_intervals?: readonly Readonly<{ start_at: string; end_at: string }>[] } | null;
|
||||
birthTimeAccuracy: "confirmed" | "provisional";
|
||||
readingMinuteConfirmed?: boolean;
|
||||
}>,
|
||||
): Record<string, unknown> | null {
|
||||
const profile = globalBirthProfileFromAccountRow(row);
|
||||
@@ -68,6 +99,10 @@ export function buildLongformBirthPayload(
|
||||
return null;
|
||||
}
|
||||
const year = Number.parseInt(dateMatch[1], 10);
|
||||
const readingMinuteConfirmed = extras.readingMinuteConfirmed ?? extras.birthTimeAccuracy === "confirmed";
|
||||
const birthWindow = !readingMinuteConfirmed && row && typeof row === "object"
|
||||
? readingBirthWindow(row as Record<string, unknown>, timeMatch[0])
|
||||
: undefined;
|
||||
return {
|
||||
year,
|
||||
month: Number.parseInt(dateMatch[2], 10),
|
||||
@@ -84,6 +119,8 @@ export function buildLongformBirthPayload(
|
||||
target_year: extras.targetYear,
|
||||
age: extras.targetYear - year,
|
||||
birth_time_accuracy: extras.birthTimeAccuracy,
|
||||
...(readingMinuteConfirmed ? {} : { reading_minute_confirmed: false }),
|
||||
...(birthWindow ? { birth_time_window: birthWindow } : {}),
|
||||
...(extras.candidateRange ? { candidate_range: extras.candidateRange } : {}),
|
||||
birthplace_label: accountText(row, "birth_place_label") ?? undefined,
|
||||
coordinate_source: "user_reported",
|
||||
|
||||
@@ -197,11 +197,15 @@ export async function generatePersonalReportLongform(
|
||||
const range = deps.candidateRange
|
||||
? { start_time: deps.candidateRange.startTime, end_time: deps.candidateRange.endTime, ...(deps.candidateRange.candidate_intervals ? { candidate_intervals: deps.candidateRange.candidate_intervals } : {}) }
|
||||
: null;
|
||||
const rangeProvisional = range && (range.candidate_intervals || range.start_time !== range.end_time);
|
||||
// A single calculation clock does not certify the birth minute for the reading.
|
||||
const readingMinuteConfirmed = !rangeProvisional && (deps.birthTimeStatus === "confirmed" || deps.birthTimeStatus === "accepted");
|
||||
const payload = buildLongformBirthPayload(deps.profile, {
|
||||
today,
|
||||
targetYear: Number(today.slice(0, 4)),
|
||||
candidateRange: range,
|
||||
birthTimeAccuracy: range && (range.candidate_intervals || range.start_time !== range.end_time) ? "provisional" : "confirmed",
|
||||
birthTimeAccuracy: rangeProvisional ? "provisional" : "confirmed",
|
||||
readingMinuteConfirmed,
|
||||
});
|
||||
if (!payload) {
|
||||
throw new LongformGenerateError("birth_time_not_usable", false);
|
||||
@@ -242,7 +246,7 @@ export async function generatePersonalReportLongform(
|
||||
const reading = deps.writeReading
|
||||
? await writeReportReading({
|
||||
facts: readingFacts,
|
||||
birthTimeConfirmed: deps.birthTimeStatus === "confirmed" || deps.birthTimeStatus === "accepted",
|
||||
birthTimeConfirmed: readingMinuteConfirmed,
|
||||
write: deps.writeReading,
|
||||
signal: deps.signal,
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ import { effectiveBirthDate } from "./effective-birth-date.ts";
|
||||
const usableActiveStatuses = new Set(["accepted", "confirmed"]);
|
||||
|
||||
export const ACCOUNT_BIRTH_SELECT =
|
||||
"name,birth_date,active_birth_date,active_birth_timezone_offset,active_birth_provenance,reported_birth_time,active_birth_time,birth_time,birth_time_status,birth_time_source,country_code,province_code,city_code,district_code,latitude,longitude,timezone_offset,timezone_id,ayanamsa,birth_place_label,uncertainty_before_minutes,uncertainty_after_minutes,birth_time_uncertainty_known,declared_window_start,declared_window_end,birth_time_clue,birth_time_shichen" as const;
|
||||
"name,birth_date,active_birth_date,active_birth_timezone_offset,active_birth_provenance,reported_birth_time,active_birth_time,birth_time,birth_time_status,birth_time_source,birth_time_period,country_code,province_code,city_code,district_code,latitude,longitude,timezone_offset,timezone_id,ayanamsa,birth_place_label,uncertainty_before_minutes,uncertainty_after_minutes,birth_time_uncertainty_known,declared_window_start,declared_window_end,birth_time_clue,birth_time_shichen" as const;
|
||||
|
||||
export type AccountBirthRow = Readonly<{
|
||||
name?: unknown;
|
||||
@@ -18,6 +18,7 @@ export type AccountBirthRow = Readonly<{
|
||||
birth_time?: unknown;
|
||||
birth_time_status?: unknown;
|
||||
birth_time_source?: unknown;
|
||||
birth_time_period?: unknown;
|
||||
birth_place_label?: unknown;
|
||||
uncertainty_before_minutes?: unknown;
|
||||
uncertainty_after_minutes?: unknown;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { buildLongformBirthPayload } from "../src/lib/personal-report-longform-birth";
|
||||
|
||||
const SYNTHETIC = {
|
||||
birth_date: "2000-01-01", reported_birth_time: "05:40", latitude: 0, longitude: 0, timezone_offset: 0,
|
||||
};
|
||||
const REQUEST = { today: "2026-11-13", targetYear: 2026, candidateRange: null, birthTimeAccuracy: "confirmed" } as const;
|
||||
|
||||
function request(row: Record<string, unknown>, readingMinuteConfirmed = false) {
|
||||
const result = buildLongformBirthPayload({ ...SYNTHETIC, ...row }, { ...REQUEST, readingMinuteConfirmed });
|
||||
assert.ok(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
test("longform request sends asymmetric intake bounds independently of engine accuracy", () => {
|
||||
const payload = request({
|
||||
birth_time_source: "approximate", birth_time_uncertainty_known: true,
|
||||
declared_window_start: "05:40:00", declared_window_end: "06:00:00",
|
||||
uncertainty_before_minutes: 0, uncertainty_after_minutes: 20,
|
||||
});
|
||||
assert.equal(payload.birth_time_accuracy, "confirmed");
|
||||
assert.equal(payload.reading_minute_confirmed, false);
|
||||
assert.deepEqual(payload.birth_time_window, { before_minutes: 0, after_minutes: 20, source: "user_stated" });
|
||||
assert.equal(payload.uncertainty_minutes, 20);
|
||||
assert.deepEqual(request({ uncertainty_before_minutes: "4", uncertainty_after_minutes: 7 }).birth_time_window,
|
||||
{ before_minutes: 4, after_minutes: 7, source: "user_stated" });
|
||||
});
|
||||
|
||||
test("missing, explicitly unknown and historically zero-width ranges defer to the report default", () => {
|
||||
for (const row of [{}, { uncertainty_before_minutes: 0, uncertainty_after_minutes: 0 },
|
||||
{ birth_time_uncertainty_known: false, uncertainty_before_minutes: 5, uncertainty_after_minutes: 5 }]) {
|
||||
const payload = request(row);
|
||||
assert.equal(payload.birth_time_window, undefined);
|
||||
assert.equal(payload.reading_minute_confirmed, false);
|
||||
}
|
||||
const confirmed = request({ uncertainty_before_minutes: 5, uncertainty_after_minutes: 5 }, true);
|
||||
assert.equal(confirmed.birth_time_window, undefined);
|
||||
assert.equal(confirmed.reading_minute_confirmed, undefined);
|
||||
});
|
||||
|
||||
test("a selected calculation clock inside a declared shichen or period uses the existing intake endpoints", () => {
|
||||
assert.deepEqual(request({ birth_time_source: "period_only", birth_time_shichen: "mao" }).birth_time_window,
|
||||
{ before_minutes: 40, after_minutes: 79, source: "shichen" });
|
||||
assert.deepEqual(request({ birth_time_source: "period_only", birth_time_shichen: "zi", reported_birth_time: "00:20" }).birth_time_window,
|
||||
{ before_minutes: 80, after_minutes: 39, source: "shichen" });
|
||||
assert.deepEqual(request({ birth_time_source: "period_only", birth_time_period: "afternoon", reported_birth_time: "16:00" }).birth_time_window,
|
||||
{ before_minutes: 240, after_minutes: 119, source: "period" });
|
||||
});
|
||||
@@ -89,7 +89,7 @@ test("daily and synastry routes share a literal account-birth select string", ()
|
||||
// 原因:issue #165 §5,只记得时辰的人对「出生日期确定吗」的回答存在 birth_time_clue,星盘页据此提示先核实
|
||||
assert.equal(
|
||||
ACCOUNT_BIRTH_SELECT,
|
||||
"name,birth_date,active_birth_date,active_birth_timezone_offset,active_birth_provenance,reported_birth_time,active_birth_time,birth_time,birth_time_status,birth_time_source,country_code,province_code,city_code,district_code,latitude,longitude,timezone_offset,timezone_id,ayanamsa,birth_place_label,uncertainty_before_minutes,uncertainty_after_minutes,birth_time_uncertainty_known,declared_window_start,declared_window_end,birth_time_clue,birth_time_shichen",
|
||||
"name,birth_date,active_birth_date,active_birth_timezone_offset,active_birth_provenance,reported_birth_time,active_birth_time,birth_time,birth_time_status,birth_time_source,birth_time_period,country_code,province_code,city_code,district_code,latitude,longitude,timezone_offset,timezone_id,ayanamsa,birth_place_label,uncertainty_before_minutes,uncertainty_after_minutes,birth_time_uncertainty_known,declared_window_start,declared_window_end,birth_time_clue,birth_time_shichen",
|
||||
);
|
||||
// 原值: the daily route selected ACCOUNT_BIRTH_SELECT inline.
|
||||
// 新值: subject-birth.ts selects it; the daily route calls loadSubjectBirth.
|
||||
|
||||
@@ -25,6 +25,7 @@ try:
|
||||
from scripts.reader_appendix_language import clean_reader_appendix_markdown
|
||||
from scripts.reader_dasha_applicability import render_dasha_applicability
|
||||
from scripts.report_density_packet import report_density_packet
|
||||
from scripts.report_render.birth_precision_window import report_birth_window
|
||||
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution path
|
||||
from pl9_full_data_export import (
|
||||
FULL_DATA_EDITION,
|
||||
@@ -34,6 +35,7 @@ except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution path
|
||||
from reader_appendix_language import clean_reader_appendix_markdown
|
||||
from reader_dasha_applicability import render_dasha_applicability
|
||||
from report_density_packet import report_density_packet
|
||||
from report_render.birth_precision_window import report_birth_window
|
||||
|
||||
try:
|
||||
from scripts.report_perf_flags import report_reference_cache_enabled
|
||||
@@ -316,8 +318,14 @@ def _reading_request(body: dict[str, Any]) -> dict[str, Any] | None:
|
||||
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution path
|
||||
from consult_card_domain_facts import minute_confirmed_from_body
|
||||
today = body.get("today")
|
||||
minute_confirmed = minute_confirmed_from_body(body) and body.get("reading_minute_confirmed") is not False
|
||||
window = body.get("birth_time_window")
|
||||
if window is None and body.get("birth_time_uncertainty_known") is not False:
|
||||
window = {"before_minutes": body.get("uncertainty_before_minutes"),
|
||||
"after_minutes": body.get("uncertainty_after_minutes"), "source": "user_stated"}
|
||||
return {
|
||||
"minute_confirmed": minute_confirmed_from_body(body),
|
||||
"minute_confirmed": minute_confirmed,
|
||||
"birth_time_window": report_birth_window(window, minute_confirmed=minute_confirmed),
|
||||
"today": today if isinstance(today, str) else None,
|
||||
**{key: body[key] for key in ("report_mode", "subject_life_status") if key in body},
|
||||
}
|
||||
|
||||
@@ -32,24 +32,24 @@ def _first_change(longitude_at, sign_at, natal_sign, part_width, near, far):
|
||||
return far
|
||||
|
||||
|
||||
def _margin(longitude_at, division, direction):
|
||||
def _margin(longitude_at, division, direction, cap_seconds):
|
||||
def sign_at(seconds):
|
||||
longitude = longitude_at(seconds)
|
||||
return int(longitude // 30) if division == 1 else calc_varga(longitude, division)["sign_idx"]
|
||||
|
||||
natal_sign = sign_at(0)
|
||||
for seconds in range(_STEP_SECONDS, _CAP_SECONDS + 1, _STEP_SECONDS):
|
||||
for seconds in range(_STEP_SECONDS, cap_seconds + 1, _STEP_SECONDS):
|
||||
change = _first_change(
|
||||
longitude_at, sign_at, natal_sign, 30 / division,
|
||||
direction * (seconds - _STEP_SECONDS), direction * seconds,
|
||||
)
|
||||
if change is not None:
|
||||
return round(abs(change) / 60, 3)
|
||||
return _CAP_SECONDS / 60
|
||||
return cap_seconds / 60
|
||||
|
||||
|
||||
def ascendant_margins(birth: dict, divisions: set[int]) -> dict:
|
||||
"""Return distances in minutes from the recorded instant, capped at 240."""
|
||||
def ascendant_margins(birth: dict, divisions: set[int], *, search_minutes: float = 0) -> dict:
|
||||
"""Return distances in minutes, searching strictly past the report window."""
|
||||
try:
|
||||
natal = datetime.fromisoformat(f"{birth['date']}T{birth['time']}")
|
||||
tz = float(str(birth["tz"]).removeprefix("UTC"))
|
||||
@@ -59,6 +59,8 @@ def ascendant_margins(birth: dict, divisions: set[int]) -> dict:
|
||||
return {}
|
||||
hour_ut = _birth_hour_decimal(natal.hour, natal.minute, natal.second) - tz
|
||||
natal_jd = swe.julday(natal.year, natal.month, natal.day, hour_ut)
|
||||
# A capped distance is outside the tolerance, including for windows of 240 minutes or more.
|
||||
cap_seconds = max(_CAP_SECONDS, (int(search_minutes * 60) // _STEP_SECONDS + 1) * _STEP_SECONDS)
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def longitude_at(seconds):
|
||||
@@ -71,8 +73,8 @@ def ascendant_margins(birth: dict, divisions: set[int]) -> dict:
|
||||
with swiss_ephemeris_lock(), temporary_ayanamsa(ayanamsa, swe):
|
||||
return {
|
||||
f"D{division}": {
|
||||
"before_minutes": _margin(longitude_at, division, -1),
|
||||
"after_minutes": _margin(longitude_at, division, 1),
|
||||
"before_minutes": _margin(longitude_at, division, -1, cap_seconds),
|
||||
"after_minutes": _margin(longitude_at, division, 1, cap_seconds),
|
||||
}
|
||||
for division in sorted(divisions)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"""Birth-time tolerance used by the personal report's evidence grading."""
|
||||
|
||||
from math import isfinite
|
||||
|
||||
|
||||
CONFIRMED_TOLERANCE_MINUTES = 1.0
|
||||
DEFAULT_TOLERANCE_MINUTES = 30.0
|
||||
WINDOW_POLICY = "birth_record_window_v1"
|
||||
_DECLARED_SOURCES = {"user_stated", "shichen", "period"}
|
||||
_MAX_SIDE_MINUTES = 720
|
||||
|
||||
|
||||
def _valid_side(value: object) -> bool:
|
||||
return type(value) in (float, int) and 0 <= value <= _MAX_SIDE_MINUTES and isfinite(value)
|
||||
|
||||
|
||||
def report_birth_window(value: object, *, minute_confirmed: bool) -> dict:
|
||||
if minute_confirmed:
|
||||
tolerance = CONFIRMED_TOLERANCE_MINUTES
|
||||
return {"before_minutes": tolerance, "after_minutes": tolerance, "source": "confirmed_minute"}
|
||||
if isinstance(value, dict):
|
||||
before, after, source = value.get("before_minutes"), value.get("after_minutes"), value.get("source")
|
||||
if isinstance(source, str) and source in _DECLARED_SOURCES and _valid_side(before) and _valid_side(after) and (before or after):
|
||||
return {"before_minutes": before, "after_minutes": after, "source": source}
|
||||
tolerance = DEFAULT_TOLERANCE_MINUTES
|
||||
return {"before_minutes": tolerance, "after_minutes": tolerance, "source": "default_unknown_30"}
|
||||
@@ -29,13 +29,17 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .birth_precision_window import CONFIRMED_TOLERANCE_MINUTES, WINDOW_POLICY, report_birth_window
|
||||
|
||||
try:
|
||||
from scripts.consult_card_domain_facts import PRECISION_VARGA
|
||||
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution path
|
||||
from consult_card_domain_facts import PRECISION_VARGA
|
||||
|
||||
GRADE_CONTRACT = "report_evidence_grade_v1"
|
||||
GRADE_ORDER = ("A", "B", "C", "D")
|
||||
# Product policy, versioned: how far the true birth instant may sit from the
|
||||
# recorded one. A minute-confirmed record is taken as +/- 1 minute; an
|
||||
# unconfirmed one has no stated tolerance, so the local boundary is not checked.
|
||||
# Keep the minute-confirmed policy and ledger shape for existing reports.
|
||||
PRECISION_POLICY = "birth_record_minute_v1"
|
||||
CONFIRMED_TOLERANCE_MINUTES = 1.0
|
||||
|
||||
MISSING_STATES = {"blocked", "withheld", "missing", "calculation_failed", "missing_input", "not_computed"}
|
||||
|
||||
@@ -128,7 +132,18 @@ def _varga_boundary(facts: dict, code: str) -> tuple[str, dict[str, Any]]:
|
||||
precision = facts.get("birth_precision") or {}
|
||||
margin = (precision.get("ascendant_margins") or {}).get(code)
|
||||
if not facts.get("minute_confirmed"):
|
||||
return "not_evaluated", {"policy": PRECISION_POLICY, "reason": "birth time not confirmed to the minute"}
|
||||
window = report_birth_window(precision.get("window"), minute_confirmed=False)
|
||||
detail = {"policy": WINDOW_POLICY, **window}
|
||||
if code in PRECISION_VARGA:
|
||||
return "not_evaluated", {**detail, "reason": "birth time not confirmed to the minute"}
|
||||
if not isinstance(margin, dict) or any(margin.get(side) is None for side in ("before_minutes", "after_minutes")):
|
||||
return "missing", {**detail, "reason": "no ascendant margin for this varga"}
|
||||
before = float(margin["before_minutes"])
|
||||
after = float(margin["after_minutes"])
|
||||
detail.update(before_change_minutes=before, after_change_minutes=after, nearest_change_minutes=min(before, after))
|
||||
crosses = (0 < window["before_minutes"] and before <= window["before_minutes"]
|
||||
or 0 < window["after_minutes"] and after <= window["after_minutes"])
|
||||
return ("boundary_sensitive" if crosses else "clear_at_tolerance"), detail
|
||||
if not isinstance(margin, dict):
|
||||
return "missing", {"policy": PRECISION_POLICY, "reason": "no ascendant margin for this varga"}
|
||||
nearest = min(float(margin.get("before_minutes", 0)), float(margin.get("after_minutes", 0)))
|
||||
@@ -223,7 +238,7 @@ def claim_grade(facts: dict, claim_type: str) -> dict[str, Any]:
|
||||
"method_maturity": "source_bounded" if not missing_required else "dependency_missing",
|
||||
"independent_agreement": "not_assessed",
|
||||
"purpose_stability": purpose,
|
||||
"boundary_check": {"policy": PRECISION_POLICY, "rows": boundary_rows},
|
||||
"boundary_check": {"policy": _precision_policy(facts), "rows": boundary_rows},
|
||||
"external_calculation_check": "not_done",
|
||||
"contradiction": [f"{row.get('planet')}: natural {row.get('natural')} / functional {row.get('functional')}"
|
||||
for row in _contradictions(facts)],
|
||||
@@ -231,11 +246,15 @@ def claim_grade(facts: dict, claim_type: str) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _precision_policy(facts: dict) -> str:
|
||||
return PRECISION_POLICY if facts.get("minute_confirmed") else WINDOW_POLICY
|
||||
|
||||
|
||||
def evidence_grades(facts: dict) -> dict[str, Any]:
|
||||
"""The per-claim ceilings the reading must respect."""
|
||||
return {
|
||||
"contract": GRADE_CONTRACT,
|
||||
"precision_policy": PRECISION_POLICY,
|
||||
"precision_policy": _precision_policy(facts),
|
||||
"grade_order": list(GRADE_ORDER),
|
||||
"graded_sections": list(GRADED_SECTIONS),
|
||||
"claims": {name: claim_grade(facts, name) for name in CLAIM_TYPES},
|
||||
|
||||
@@ -22,6 +22,7 @@ from datetime import date
|
||||
from typing import Any
|
||||
|
||||
from .birth_precision_margins import ascendant_margins
|
||||
from .birth_precision_window import report_birth_window
|
||||
from .evidence_grade import evidence_grades
|
||||
from .parity_chapters import _VIMSOPAKA_DIGNITY
|
||||
from .technique_status_axes import technique_audit_axes
|
||||
@@ -827,7 +828,7 @@ def _birth_parameters(packet: dict, minute_confirmed: bool) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _birth_precision(full_reading: dict, view: dict, domains: dict, minute_confirmed: bool) -> dict[str, Any]:
|
||||
def _birth_precision(full_reading: dict, view: dict, domains: dict, minute_confirmed: bool, window: object = None) -> dict[str, Any]:
|
||||
divisions = {1}
|
||||
for domain in domains.values():
|
||||
divisions.update(int(code[1:]) for code, chart in domain["varga_charts"].items() if isinstance(chart, dict))
|
||||
@@ -835,11 +836,13 @@ def _birth_precision(full_reading: dict, view: dict, domains: dict, minute_confi
|
||||
if minute_confirmed and _varga_chart(view, "D60")[1]:
|
||||
divisions.add(60)
|
||||
birth = dig(full_reading, "modules.chart.birth_info") or {}
|
||||
tolerance = report_birth_window(window, minute_confirmed=minute_confirmed)
|
||||
return {
|
||||
"minute_confirmed": minute_confirmed,
|
||||
"purpose_stability": "not_evaluated",
|
||||
"basis": "The purpose-specific interval contract (2026-11-09 interval_rectification handoff) is not integrated.",
|
||||
"ascendant_margins": ascendant_margins(birth, divisions),
|
||||
"window": tolerance,
|
||||
"ascendant_margins": ascendant_margins(birth, divisions, search_minutes=max(tolerance["before_minutes"], tolerance["after_minutes"])),
|
||||
}
|
||||
|
||||
|
||||
@@ -851,6 +854,7 @@ def build_report_reading_facts(
|
||||
today: str | None = None,
|
||||
report_mode: str = "living_consultation",
|
||||
subject_life_status: str = "unknown",
|
||||
birth_time_window: object = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Packet-sourced facts for the reading. Raises on any non-packet consult leaf."""
|
||||
if report_mode not in ("living_consultation", "historical_replay"):
|
||||
@@ -906,7 +910,7 @@ def build_report_reading_facts(
|
||||
"current_advice_allowed": report_mode == "living_consultation",
|
||||
"observation_date": today or reference_day,
|
||||
"birth_parameters": _birth_parameters(working, minute_confirmed),
|
||||
"birth_precision": _birth_precision(full_reading, view, domains, minute_confirmed),
|
||||
"birth_precision": _birth_precision(full_reading, view, domains, minute_confirmed, birth_time_window),
|
||||
"ascendant": _compact({
|
||||
key: {"status": "value", "check": "path", "value": ascendant.get(key)}
|
||||
for key in ("sign", "lord", "nakshatra", "degree_in_sign")
|
||||
|
||||
@@ -67,4 +67,7 @@ def test_missing_purpose_defaults_to_unassessed_independently_of_boundary_status
|
||||
facts["minute_confirmed"] = False
|
||||
claim = claim_grade(facts, "character_structure")
|
||||
assert claim["cap"] == "C"
|
||||
assert {row["state"] for row in claim["ledger"]["boundary_check"]["rows"]} == {"not_evaluated"}
|
||||
assert claim["ledger"]["purpose_stability"] == "not_evaluated"
|
||||
assert {row["id"]: row["state"] for row in claim["ledger"]["boundary_check"]["rows"]} == {
|
||||
"v:D1": "clear", "v:D9": "missing",
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""#224: grade report claims against the stated or default birth-time window."""
|
||||
|
||||
from scripts.professional_report_reference import _reading_request
|
||||
from scripts.report_render.evidence_grade import evidence_grades
|
||||
from scripts.report_render.reading_facts import _birth_precision
|
||||
from tests.test_report_evidence_grade_20261112 import _facts
|
||||
|
||||
|
||||
def _unconfirmed_facts(window=None):
|
||||
facts = _facts(minute_confirmed=False)
|
||||
facts["birth_precision"]["ascendant_margins"] = {
|
||||
code: {"before_minutes": value, "after_minutes": value}
|
||||
for code, value in {"D1": 73, "D2": 0.3, "D6": 0.3, "D8": 0.3, "D9": 8, "D10": 0.3, "D30": 0.3}.items()
|
||||
}
|
||||
if window is not None:
|
||||
facts["birth_precision"]["window"] = window
|
||||
return facts
|
||||
|
||||
|
||||
def _row(claims, name, varga):
|
||||
return next(row for row in claims[name]["ledger"]["boundary_check"]["rows"] if row["id"] == f"v:{varga}")
|
||||
|
||||
|
||||
def test_default_window_checks_required_and_optional_vargas():
|
||||
grades = evidence_grades(_unconfirmed_facts())
|
||||
claims = grades["claims"]
|
||||
assert grades["precision_policy"] == "birth_record_window_v1"
|
||||
assert claims["character_structure"]["cap"] == "C"
|
||||
for name, code in (("wealth_earning", "D2"), ("wealth_retention", "D2"), ("health_pressure", "D6"),
|
||||
("career_promise", "D10"), ("relationship_structure", "D9")):
|
||||
assert claims[name]["cap"] == "D"
|
||||
assert _row(claims, name, code)["state"] == "boundary_sensitive"
|
||||
row = _row(claims, "character_structure", "D1")
|
||||
assert row["state"] == "clear" and row["nearest_change_minutes"] == 73
|
||||
assert (row["before_minutes"], row["after_minutes"], row["source"]) == (30, 30, "default_unknown_30")
|
||||
assert _row(claims, "health_pressure", "D8")["state"] == "boundary_sensitive"
|
||||
assert _row(claims, "health_pressure", "D30")["state"] == "not_evaluated"
|
||||
|
||||
|
||||
def test_declared_window_uses_each_side_and_includes_the_endpoint():
|
||||
five = {"before_minutes": 5, "after_minutes": 5, "source": "user_stated"}
|
||||
claims = evidence_grades(_unconfirmed_facts(five))["claims"]
|
||||
assert claims["relationship_structure"]["cap"] == "C"
|
||||
assert _row(claims, "relationship_structure", "D9")["state"] == "clear"
|
||||
assert claims["wealth_earning"]["cap"] == "D"
|
||||
assert _row(claims, "wealth_earning", "D2")["source"] == "user_stated"
|
||||
|
||||
facts = _unconfirmed_facts({"before_minutes": 0, "after_minutes": 20, "source": "user_stated"})
|
||||
margin = facts["birth_precision"]["ascendant_margins"]["D2"]
|
||||
margin.update(before_minutes=0.3, after_minutes=21)
|
||||
assert evidence_grades(facts)["claims"]["wealth_earning"]["cap"] == "C"
|
||||
margin["after_minutes"] = 20
|
||||
assert evidence_grades(facts)["claims"]["wealth_earning"]["cap"] == "D"
|
||||
|
||||
|
||||
def test_shichen_request_reaches_facts_even_with_a_single_calculation_clock():
|
||||
# 卯时 05:00—06:59 at a synthetic calculation clock of 05:40.
|
||||
shichen = {"before_minutes": 40, "after_minutes": 79, "source": "shichen"}
|
||||
request = _reading_request({"hour": 5, "minute": 40, "include_reading_facts": True,
|
||||
"birth_time_accuracy": "confirmed", "reading_minute_confirmed": False,
|
||||
"birth_time_window": shichen})
|
||||
assert request["minute_confirmed"] is False
|
||||
precision = _birth_precision({}, {}, {}, request["minute_confirmed"], request["birth_time_window"])
|
||||
assert precision["window"] == shichen
|
||||
assert precision["purpose_stability"] == "not_evaluated"
|
||||
assert _birth_precision({}, {}, {}, True, shichen)["window"] == {
|
||||
"before_minutes": 1, "after_minutes": 1, "source": "confirmed_minute",
|
||||
}
|
||||
|
||||
|
||||
def test_invalid_window_falls_back_without_trusting_client_numbers():
|
||||
for window in ({"before_minutes": -2, "after_minutes": 5, "source": "user_stated"},
|
||||
{"before_minutes": True, "after_minutes": 5, "source": "user_stated"},
|
||||
{"before_minutes": 3, "after_minutes": 5, "source": []}):
|
||||
row = _row(evidence_grades(_unconfirmed_facts(window))["claims"], "character_structure", "D1")
|
||||
assert (row["before_minutes"], row["after_minutes"], row["source"]) == (30, 30, "default_unknown_30")
|
||||
|
||||
|
||||
def test_report_request_can_reuse_existing_asymmetric_minute_fields():
|
||||
body = {"include_reading_facts": True, "hour": 6, "minute": 10,
|
||||
"uncertainty_before_minutes": 0, "uncertainty_after_minutes": 20}
|
||||
assert _reading_request(body)["birth_time_window"] == {
|
||||
"before_minutes": 0, "after_minutes": 20, "source": "user_stated",
|
||||
}
|
||||
body["birth_time_uncertainty_known"] = False
|
||||
assert _reading_request(body)["birth_time_window"]["source"] == "default_unknown_30"
|
||||
@@ -79,11 +79,11 @@ def test_missing_required_layer_or_boundary_varga_gives_d():
|
||||
assert {"v:D30", "purpose_stability_not_evaluated"} <= set(disclosed["must_disclose"])
|
||||
|
||||
|
||||
def test_unconfirmed_birth_time_is_not_evaluated_not_assumed_stable():
|
||||
def test_unconfirmed_birth_time_at_default_boundary_is_not_assumed_stable():
|
||||
facts = _facts(minute_confirmed=False)
|
||||
claim = claim_grade(facts, "career_promise")
|
||||
assert claim["ledger"]["purpose_stability"] == "not_evaluated"
|
||||
assert claim["cap"] == "C"
|
||||
assert claim["cap"] == "D"
|
||||
|
||||
|
||||
def test_parameter_sensitive_timing_is_flagged_not_hidden():
|
||||
|
||||
@@ -250,3 +250,20 @@ def test_reading_flag_is_part_of_the_report_cache_key(stubbed, monkeypatch) -> N
|
||||
cached = build_professional_report_reference(handler, _body(include_reading_facts=True), engine=engine)
|
||||
assert handler.calls == 2
|
||||
assert "reading_facts" in cached
|
||||
|
||||
|
||||
def test_reading_birth_window_is_part_of_the_report_cache_key(stubbed, monkeypatch) -> None:
|
||||
handler, engine = stubbed
|
||||
monkeypatch.setenv("JYOTISH_REPORT_REFERENCE_CACHE", "1")
|
||||
monkeypatch.setenv("GITHUB_SHA", "reading-birth-window-cache-test")
|
||||
body = _body(include_reading_facts=True, birth_time_accuracy="confirmed", hour=5, minute=40,
|
||||
reading_minute_confirmed=False)
|
||||
windows = [{"before_minutes": 40, "after_minutes": 79, "source": "shichen"},
|
||||
{"before_minutes": 0, "after_minutes": 20, "source": "user_stated"}]
|
||||
for window in (*windows, windows[-1]):
|
||||
result = build_professional_report_reference(handler, {**body, "birth_time_window": window}, engine=engine)
|
||||
facts = result["reading_facts"]
|
||||
assert facts["minute_confirmed"] is False
|
||||
assert facts["birth_precision"]["window"] == window
|
||||
assert facts["evidence_grades"]["precision_policy"] == "birth_record_window_v1"
|
||||
assert handler.calls == 2
|
||||
|
||||
Reference in New Issue
Block a user