');
+ assert.match(body, /这里是报告正文/);
+ assert.doesNotMatch(body, /网上资料核对|真实案例校准/);
+ assert.match(appendix, /| 方法<\/th> | 计算<\/th> | 在本报告中<\/th>/);
+ assert.match(appendix, / | 输入已齐<\/td> | 供写作参考<\/td>/);
+ assert.match(appendix, / | 阻塞<\/td> | 未使用。无法确定出生时刻所在的日出日落区间<\/td>/);
+ assert.match(appendix, /网上资料核对:未完成[\s\S]*真实案例校准:未完成/);
+ assert.doesNotMatch(appendix, /_|·|已执行/);
+});
+
+test("follow-up material includes at most twelve audit rows across both people and the comparison", () => {
+ const saved = buildTechnicalBasis({
+ dossier: { execution_receipt: {
+ individual_technique_audit: Array.from({ length: 14 }, (_, index) => ({
+ technique: `技法 ${index + 1}`,
+ person_a: { status: "parameter_sensitive", reason: "birth_time_window_varies" },
+ person_b: { status: "executed" },
+ })),
+ pair_execution_tasks: [{ task: "宫位对照", status: "ready_for_comparison" }],
+ } },
+ names: { a: "甲", b: "乙" }, contacts: [], timing: [],
+ });
+ const result = synastrySectionMaterial({ payload: { zh: { technical: saved } }, sectionId: "climate", includeTechnical: true });
+ const technical = result.technical as { id: string; lines: string[] }[];
+ const execution = technical.find(({ id }) => id === "execution")!;
+ assert.equal(execution.lines.length, 12);
+ assert.ok(execution.lines.includes("甲方 技法 1:计算 参数敏感,在本报告中 只作观察。出生时间误差内会变"));
+ assert.ok(execution.lines.includes("乙方 技法 1:计算 已执行,在本报告中 供写作参考"));
+ assert.ok(execution.lines.includes("两盘对照 宫位对照:计算 输入已齐,在本报告中 供写作参考"));
+ assert.doesNotMatch(JSON.stringify(result), /网上资料核对|真实案例校准/);
+ const old = synastrySectionMaterial({ payload: { zh: { technical: [{
+ id: "execution", title: "技法执行情况", lines: ["D1/Rashi:已执行", "网上资料核对:未完成", "真实案例校准:未完成"],
+ }] } }, sectionId: "climate", includeTechnical: true });
+ assert.deepEqual(old.technical, [{ id: "execution", title: "技法执行情况", lines: ["D1/Rashi:已执行"] }]);
+});
diff --git a/frontend/tests/synastry-chart-skip.test.ts b/frontend/tests/synastry-chart-skip.test.ts
deleted file mode 100644
index ffc03949b..000000000
--- a/frontend/tests/synastry-chart-skip.test.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-import assert from "node:assert/strict";
-import { spawnSync } from "node:child_process";
-import { fileURLToPath } from "node:url";
-import test from "node:test";
-
-const frontendRoot = fileURLToPath(new URL("../", import.meta.url));
-const partnerId = "11111111-1111-4111-8111-111111111111";
-
-function runRoute(script: string): { romance: Record; business: Record; maxChart: number; maxVarga: number; chartSkip: boolean } {
- const result = spawnSync(process.execPath, [
- "--experimental-test-module-mocks",
- "--import",
- "tsx",
- "--input-type=module",
- "--eval",
- script,
- ], { cwd: frontendRoot, encoding: "utf8", timeout: 20000 });
- assert.equal(result.status, 0, result.stderr || result.stdout);
- const line = result.stdout.trim().split("\n").at(-1) ?? "{}";
- return JSON.parse(line);
-}
-
-test("synastry charts send skip concurrently and keep the stubbed JSON", () => {
- const script = String.raw`
- import { mock } from "node:test";
- import { pathToFileURL } from "node:url";
- const moduleUrl = (path) => pathToFileURL(process.cwd() + "/" + path).href;
- mock.module("server-only", { namedExports: {} });
- mock.module("@/lib/account-deletion-server", { namedExports: { refuseWhenAccountDeletionPending: async () => null } });
- mock.module("@/lib/product-access", { namedExports: { isProductEnabled: async () => true } });
- mock.module("@/lib/request-rate-limit", { namedExports: { consumeUserRequestRateLimit: () => ({ ok: true, retryAfterSeconds: 1 }) } });
- mock.module("@/lib/supabase/server", { namedExports: { createServerSupabaseClient: async () => ({ auth: { getUser: async () => ({ data: { user: { id: "user-1" } }, error: null }) } }) } });
- mock.module("@/lib/subject-birth", { namedExports: {
- ConsultationSubjectError: class ConsultationSubjectError extends Error {},
- loadSubjectBirth: async () => ({ chartable: true, row: { name: "fixture" } }),
- } });
- mock.module("@/lib/server-owned-birth-profile", { namedExports: { globalBirthProfileFromAccountRow: (row) => row } });
- mock.module("@/lib/global-birth-payloads", { namedExports: {
- synastryBirthPayload: async () => ({ year: 1990, month: 1, day: 1, hour: 12, minute: 0, lat: 28.6139, lon: 77.209, tz: 5.5, ayanamsa: "lahiri" }),
- } });
- const chartBodies = [];
- const maxInflight = { chart: 0, varga: 0 };
- const inflight = { chart: 0, varga: 0 };
- const waiters = { chart: [], varga: [] };
- globalThis.fetch = async (inputUrl, init) => {
- const url = String(inputUrl);
- const body = JSON.parse(String(init.body));
- const kind = url.endsWith("/api/chart") ? "chart" : url.endsWith("/api/varga_full") ? "varga" : "other";
- if (kind === "chart") chartBodies.push(body);
- if (kind === "chart" || kind === "varga") {
- inflight[kind] += 1;
- maxInflight[kind] = Math.max(maxInflight[kind], inflight[kind]);
- await new Promise((resolve) => {
- waiters[kind].push(resolve);
- if (waiters[kind].length >= 2) {
- const pending = waiters[kind].splice(0, 2);
- pending.forEach((fn) => fn());
- }
- });
- inflight[kind] -= 1;
- }
- if (url.endsWith("/api/chart")) {
- return Response.json({
- planets: { Moon: { lon: 12.5, sign: "Aries", nakshatra: "Ashwini", nakshatra_pada: 1, nakshatra_lord: "Ketu" } },
- ascendant: { sign: "Leo" },
- });
- }
- if (url.endsWith("/api/varga_full")) {
- const divisions = body.divisions || [];
- if (divisions.includes("D9")) {
- return Response.json({ source: "engine", result: { D9_Navamsa: { ascendant: { sign: "Virgo" }, planets: { Moon: { sign: "Cancer" }, Venus: { sign: "Taurus" }, Mars: { sign: "Aries" } } } } });
- }
- return Response.json({ source: "engine", result: {
- D2_Hora: { planets: { Moon: { sign: "Taurus" } } },
- D10_Dasamsa: { ascendant: { sign: "Libra" } },
- D11_Rudramsa: { planets: { Sun: { sign: "Capricorn" } } },
- } });
- }
- if (url.endsWith("/api/synastry")) return Response.json({ total_score: 18, max_score: 36 });
- return Response.json({}, { status: 500 });
- };
- const { POST } = await import(moduleUrl("src/app/api/synastry/route.ts"));
- const romanceRes = await POST(new Request("https://example.test/api/synastry", { method: "POST", body: JSON.stringify({ partnerChartProfileId: "${partnerId}", relationshipType: "romance" }) }));
- const romance = await romanceRes.json();
- const businessRes = await POST(new Request("https://example.test/api/synastry", { method: "POST", body: JSON.stringify({ partnerChartProfileId: "${partnerId}", relationshipType: "business" }) }));
- const business = await businessRes.json();
- console.log(JSON.stringify({ romance, business, maxChart: maxInflight.chart, maxVarga: maxInflight.varga, chartSkip: chartBodies.every((body) => body.skip_vedastro_main_entry_overview === true) && chartBodies.length === 4 }));
- `;
- const got = runRoute(script);
- assert.equal(got.maxChart, 2);
- assert.equal(got.maxVarga, 2);
- assert.equal(got.chartSkip, true);
- assert.equal(got.romance.status, "ok");
- assert.equal(got.romance.method, "ashtakoot_plus_moon_nakshatra_d9");
- assert.deepEqual(got.romance.selfChart, {
- moon: { sign: "Aries", nakshatra: "Ashwini", pada: 1, lord: "Ketu", longitude: 12.5 },
- d9: { ascendant: { sign: "Virgo" }, moon: { sign: "Cancer" }, venus: { sign: "Taurus" }, mars: { sign: "Aries" }, source: "engine" },
- });
- assert.equal((got.romance.relationshipReport as { scoreBand?: string }).scoreBand, "mixed");
- assert.equal(got.business.status, "ok");
- assert.equal(got.business.method, "d2_d10_d11_business_screening_partial");
- assert.equal((got.business.relationshipReport as { scoreBand?: string }).scoreBand, "not_scored");
-});
diff --git a/frontend/tests/synastry-full-report.test.ts b/frontend/tests/synastry-full-report.test.ts
index ed79c0875..de9d63b14 100644
--- a/frontend/tests/synastry-full-report.test.ts
+++ b/frontend/tests/synastry-full-report.test.ts
@@ -156,10 +156,7 @@ test("technical appendix has six program blocks and the fixed closing line", ()
timing: ["甲:木星大运 2026-01 至 2028-01"],
});
assert.deepEqual(blocks.map((block) => block.id), ["parameters", "structures", "contacts", "timing", "traditional", "execution"]);
- // 原值:blocks[5].lines 末尾是「外部资料与真实案例核对:未进行,本报告是计算层归纳」
- // 新值:该行删除,执行情况只留回执里的技法依据
- // 原因:产品负责人 2026-11-08:用户可见文字不出现联网/外部核验字样,后台保留
- assert.equal(blocks[5]?.lines.some((line) => line.includes("外部资料")), false);
+ assert.deepEqual(blocks[5]?.lines, ["网上资料核对:未完成", "真实案例校准:未完成"]);
assert.equal(JSON.stringify(blocks).includes("1879"), false);
});
@@ -515,7 +512,9 @@ test("technical execution lines follow the receipt and raman is named", () => {
contacts: [],
timing: [],
});
- assert.deepEqual(blocks[5]?.lines.slice(0, 2), ["Niryaana Shoola:不适用", "DK cross-comparison:已执行"]);
+ assert.deepEqual(blocks[5]?.audit?.map(({ title }) => title), ["甲方", "乙方", "两盘对照"]);
+ assert.equal(blocks[5]?.audit?.[0].rows[0].calculation, "不适用");
+ assert.deepEqual(blocks[5]?.audit?.[2].rows[0], { method: "DK cross-comparison", calculation: "输入已齐", usage: "供写作参考" });
assert.match(blocks[1]?.lines[0] ?? "", /DK Venus/);
// 2026-11-07 原值:/raman_muhurtha_v1/(原样显示规则 id)。新值:显示中文口径说明。
// 原因:BUG-1679,传统配对块改成读真实字段并写成中文;Raman 仍然单独点名。
@@ -581,7 +580,9 @@ test("BUG-1679: parameters and traditional matching read the dossier's real shap
assert.match(traditional, /Raman 口径,甲 火星凶位/);
assert.doesNotMatch(traditional, /36|百分|%/);
assert.equal(JSON.stringify([blocks[0], blocks[4]]).includes("未标明"), false);
- assert.deepEqual(blocks[5]?.lines.slice(0, 1), ["Vivah and other Sahams:无法计算"]);
+ assert.deepEqual(blocks[5]?.audit?.[1].rows[0], {
+ method: "Vivah and other Sahams", calculation: "阻塞", usage: "未使用。回执没有可用的计算结果",
+ });
});
function pythonBin(): string | null {
@@ -684,40 +685,18 @@ test("a public pair dossier fills every section without birth keys", { timeout:
individual_technique_audit?: Array>;
pair_execution_tasks?: Array>;
};
- const statusText: Record = {
- executed: "已执行",
- ready_for_comparison: "已执行",
- present: "已执行",
- used: "已执行",
- available: "已执行",
- passed: "已执行",
- parameter_sensitive: "参数敏感",
- partial: "参数敏感",
- weak: "参数敏感",
- observation_only: "参数敏感",
- not_applicable: "不适用",
- not_used: "不适用",
- not_used_for_date_intersection: "不适用",
- // 2026-11-07 新增:blocked / not_available 显示「无法计算」,原来露出英文原词(BUG-1679)。
- blocked: "无法计算",
- not_available: "无法计算",
- };
- const receiptRows = [...(receipt.individual_technique_audit ?? []), ...(receipt.pair_execution_tasks ?? [])];
- const executionLines = blocks[5]?.lines ?? [];
- let namedRows = 0;
- for (const row of receiptRows) {
- const name = String(row.technique || row.task || row.label || row.lane || "").trim();
- const status = String(row.status || "").trim();
- if (!name || !status) continue;
- const shown = statusText[status.toLowerCase()] ?? status;
- assert.equal(executionLines.some((line) => line.includes(name) && line.includes(shown)), true, `${name} ${shown}`);
- namedRows += 1;
+ const execution = blocks[5];
+ const groups = execution?.audit ?? [];
+ assert.deepEqual(groups.map(({ title }) => title), ["甲方", "乙方", "两盘对照"]);
+ assert.equal(groups[0].rows.length, receipt.individual_technique_audit?.length);
+ assert.equal(groups[1].rows.length, receipt.individual_technique_audit?.length);
+ assert.equal(groups[2].rows.length, receipt.pair_execution_tasks?.length);
+ assert.deepEqual(execution?.lines, ["网上资料核对:未完成", "真实案例校准:未完成"]);
+ assert.ok(groups[2].rows.some((row) => row.calculation === "输入已齐" && row.usage === "供写作参考"));
+ for (const row of groups.flatMap(({ rows }) => [...rows])) {
+ assert.doesNotMatch(Object.values(row).join(" "), /[·_]|ready_for_comparison/);
+ if (["阻塞", "不适用"].includes(row.calculation)) assert.match(row.usage, /^未使用。.+/);
}
- assert.ok(namedRows > 0);
- // 原值:executionLines 末尾是「外部资料与真实案例核对:未进行,本报告是计算层归纳」
- // 新值:该行删除
- // 原因:产品负责人 2026-11-08:用户可见文字不出现联网/外部核验字样,后台保留
- assert.equal(executionLines.some((line) => line.includes("外部资料")), false);
const structures = dossier.local_structures as Record>;
for (const person of ["person_a", "person_b"]) {
const local = structures[person] ?? {};
diff --git a/frontend/tests/synastry-precision-20261114.test.tsx b/frontend/tests/synastry-precision-20261114.test.tsx
index 3eb4d5423..c8ae694b3 100644
--- a/frontend/tests/synastry-precision-20261114.test.tsx
+++ b/frontend/tests/synastry-precision-20261114.test.tsx
@@ -6,7 +6,7 @@ import { renderToStaticMarkup } from "react-dom/server";
import { SynastryReportView } from "../src/components/synastry/synastry-report-view";
import { loadSynastrySubjectBirth, marriageMatchBirthBody, marriageMatchFingerprint } from "../src/lib/marriage-match-service";
import { sectionEvidence, SYNASTRY_SECTION_IDS, systemPrompt } from "../src/lib/synastry-full-sections";
-import { buildTechnicalBasis } from "../src/lib/synastry-full-technical";
+import { buildTechnicalBasis, currentSynastryTechnicalBlocks } from "../src/lib/synastry-full-technical";
const stable = { D1: { status: "stable" }, D9: { status: "stable" }, moon: { status: "stable" } };
const person = { window_label: "没有误差信息,按前后各 30 分钟", axes: stable, affected_layers: [] };
@@ -15,6 +15,9 @@ const receipt = {
technique: "D1/Rashi", status: "parameter_sensitive",
person_a: { status: "parameter_sensitive", reason: "birth_time_window_varies" }, person_b: { status: "executed" },
}],
+ pair_execution_tasks: [{
+ task: "宫位对照", status: "parameter_sensitive", reason: "birth_time_window_varies",
+ }],
};
const changed = {
execution_receipt: receipt,
@@ -57,8 +60,22 @@ test("the appendix renders window sources, Chinese candidates and only the affec
assert.match(appendix, /甲方出生时间误差:没有误差信息,按前后各 30 分钟/);
assert.match(appendix, /水瓶座(档案时刻)、双鱼座(偏晚约 12 分钟)/);
assert.match(appendix, /乙方出生时间误差[^<]*本命上升误差内稳定/);
- assert.match(appendix, /| 甲方 D1\/Rashi<\/td> | 参数敏感<\/td> | 出生时间误差内会变/);
- assert.doesNotMatch(appendix, /乙方 D1|[·_]/);
+ assert.match(appendix, /甲方<\/h4>[\s\S]*?| D1\/Rashi<\/td> | 参数敏感<\/td> | 只作观察。出生时间误差内会变<\/td>/);
+ assert.match(appendix, /乙方<\/h4>[\s\S]*?| D1\/Rashi<\/td> | 已执行<\/td> | 供写作参考<\/td>/);
+ assert.match(appendix, /两盘对照<\/h4>[\s\S]*?| 宫位对照<\/td> | 参数敏感<\/td> | 只作观察。出生时间误差内会变<\/td>/);
+ assert.equal(appendix.match(/ {
+ const saved = {
+ id: "execution" as const, title: "技法执行情况", lines: ["D1/Rashi:参数敏感"], precisionAudit: [],
+ };
+ const execution = currentSynastryTechnicalBlocks([saved], changed)?.[0];
+ assert.deepEqual(execution?.audit, buildTechnicalBasis({
+ dossier: changed, names: { a: "甲", b: "乙" }, contacts: [], timing: [],
+ }).find(({ id }) => id === "execution")?.audit);
+ assert.ok(execution && !Object.hasOwn(execution, "precisionAudit"));
});
test("the request reuses the reported and adopted windows", () => {
diff --git a/scripts/consult_full_data_cache.py b/scripts/consult_full_data_cache.py
index 7439a3adf..65baa62ca 100644
--- a/scripts/consult_full_data_cache.py
+++ b/scripts/consult_full_data_cache.py
@@ -23,7 +23,9 @@ from typing import Any, Callable
ROOT = Path(__file__).resolve().parents[1]
# 原值 v2;新值 v3;原因:BUG-1601 Narayana 默认换成 Sanjay Rath,旧缓存里是旧算法默认(引擎版本号未变)
# 原值 v3;新值 v4;原因:BUG-1699 全读加了 Chesta 候选、AV score_fields 与 career_analysis,旧包里没有
-CACHE_SCHEMA = "consult-full-data-cache-v4"
+# v4: report reference identity without a shared schema marker for pair dossiers.
+# v5: the pair dossier uses this schema and includes both calculation dates.
+CACHE_SCHEMA = "consult-full-data-cache-v5"
SLOW_MISS_SECONDS = 20.0
KEEP_SECONDS = 2 * 24 * 60 * 60
diff --git a/scripts/marriage_match_service/api.py b/scripts/marriage_match_service/api.py
index 12857b20e..55db339e8 100644
--- a/scripts/marriage_match_service/api.py
+++ b/scripts/marriage_match_service/api.py
@@ -1,6 +1,6 @@
"""HTTP-facing marriage match and full synastry dossier.
-The dossier endpoint caches on the two birth payloads plus ``GITHUB_SHA``,
+The dossier endpoint caches on both births, calculation dates and ``GITHUB_SHA``,
the same scratch helper the report reference cache uses. A missing or
``unknown`` commit id skips the cache.
"""
@@ -73,6 +73,7 @@ def _birth_identity(body: dict[str, Any]) -> dict[str, Any]:
"ayanamsa": body.get("ayanamsa", "lahiri"),
"node_mode": node or "mean",
"birth_precision_window": normalized_birth_window(body),
+ "today": body.get("today"),
}
@@ -104,11 +105,19 @@ def _narayana_profile_config() -> dict[str, str]:
return dict(nr.DEFAULT_STEP_PROFILES)
+def _calculation_date(person: dict[str, Any], fallback: str) -> str:
+ day = person.get("today") or person.get("current_date")
+ return day.strip()[:10] if isinstance(day, str) and day.strip() else fallback
+
+
def compute_synastry_full_dossier(handler: Any, body: dict[str, Any]) -> dict[str, Any]:
if not isinstance(body, dict):
raise MarriageMatchInputError("request body must be an object")
person_a = _birth(body.get("person_a"), "person_a")
person_b = _birth(body.get("person_b"), "person_b")
+ pair_date = _calculation_date(person_a, "") or _calculation_date(person_b, "") or _cache.reference_date_from_body({})
+ person_a = {**person_a, "today": _calculation_date(person_a, pair_date)}
+ person_b = {**person_b, "today": _calculation_date(person_b, pair_date)}
sha = _commit_sha()
def build(_identity: dict[str, Any]) -> dict[str, Any]:
@@ -118,6 +127,7 @@ def compute_synastry_full_dossier(handler: Any, body: dict[str, Any]) -> dict[st
return build({})
cached = _cache.get_or_build(
{
+ "schema": _cache.CACHE_SCHEMA,
"person_a": _birth_identity(person_a),
"person_b": _birth_identity(person_b),
"github_sha": sha,
diff --git a/scripts/marriage_match_service/full_dossier.py b/scripts/marriage_match_service/full_dossier.py
index 173a1b53d..136376d65 100644
--- a/scripts/marriage_match_service/full_dossier.py
+++ b/scripts/marriage_match_service/full_dossier.py
@@ -718,6 +718,42 @@ def reading_scope(dossier: dict[str, Any]) -> dict[str, Any]:
"rule": "both chart profiles match and every primary pair lane is comparable"}
+def _saham_block_reason(reading: dict[str, Any]) -> str | None:
+ packet = _reading_packet(reading)
+ modules = packet.get("modules")
+ module = modules.get("sahams") if isinstance(modules, dict) else None
+ if isinstance(module, dict) and module.get("reason"):
+ return str(module["reason"])
+ for error in packet.get("errors") or []:
+ if isinstance(error, str) and error.startswith("tajika-yogas+sahams:"):
+ for reason in ("solar_day_window_unavailable", "sunrise_or_sunset_unavailable_for_location_date"):
+ if reason in error:
+ return reason
+ return "saham_calculation_failed"
+ if not module or (isinstance(module, dict) and module.get("warning")):
+ return "saham_inputs_unavailable"
+ return None
+
+
+def _add_saham_receipt_reasons(dossier: dict[str, Any], readings: dict[str, Any]) -> None:
+ receipt = dossier.get("execution_receipt") or {}
+ reasons = {side: _saham_block_reason(reading) for side, reading in readings.items() if isinstance(reading, dict)}
+ for row in receipt.get("individual_technique_audit", []):
+ if row.get("technique") != "Vivah and other Sahams":
+ continue
+ for side, reason in reasons.items():
+ person = row.get(side) or {}
+ if reason and person.get("status") == "blocked":
+ person["reason"] = reason
+ for row in receipt.get("pair_execution_tasks", []):
+ for item in row.get("required_inputs", []):
+ if item.get("source_path") != "modules.sahams":
+ continue
+ for side, reason in reasons.items():
+ if reason and item.get(f"{side}_status") == "blocked":
+ item[f"{side}_reason"] = reason
+
+
def build_synastry_full_dossier(
handler: Any,
person_a: dict[str, Any],
@@ -735,6 +771,7 @@ def build_synastry_full_dossier(
reading_b = future_b.result()
dossier = _dossier_builder()(reading_a, reading_b)
if isinstance(dossier, dict):
+ _add_saham_receipt_reasons(dossier, {"person_a": reading_a, "person_b": reading_b})
dossier["local_structures"] = {
"person_a": relationship_structure(reading_a if isinstance(reading_a, dict) else {}),
"person_b": relationship_structure(reading_b if isinstance(reading_b, dict) else {}),
diff --git a/tests/test_supabase_user_data_contract.py b/tests/test_supabase_user_data_contract.py
index 620fd217c..f4c6333a1 100644
--- a/tests/test_supabase_user_data_contract.py
+++ b/tests/test_supabase_user_data_contract.py
@@ -66,7 +66,6 @@ OPTIONAL_HOME_HOOKS = (
# 状态下沉把合盘从 page.tsx 搬进了自己的 hook(2026-09-16)。首页表面是这
# 些文件的并集,新 hook 不进这张白名单,下面的合盘断言就会在代码完全正确
# 的情况下变红。新增 Home 级 hook 时必须同步加进来。
- _FRONTEND_SRC / "hooks" / "use-synastry.ts",
_FRONTEND_SRC / "hooks" / "use-session-list.ts",
_FRONTEND_SRC / "hooks" / "use-home-shell-registration.ts",
_FRONTEND_SRC / "lib" / "session-list-context.tsx",
@@ -85,7 +84,6 @@ SESSION_ITEM_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" /
ACCOUNT_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "account" / "route.ts"
CHART_PROFILE_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "chart-profiles" / "route.ts"
CHART_PROFILE_DELETE_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "chart-profiles" / "[id]" / "route.ts"
-SYNASTRY_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "synastry" / "route.ts"
SYNASTRY_REPORT_ROUTE = Path(__file__).resolve().parents[1] / "frontend" / "src" / "app" / "api" / "synastry-reports" / "route.ts"
@@ -271,16 +269,10 @@ def test_chart_profile_library_has_cloud_table_api_and_local_fallback() -> None:
"fetchCloudChartLibrary",
"saveCloudChartProfile",
"deleteCloudChartProfile",
- "buildSynastryQuestion",
- "draftSynastryQuestionFromChart",
- "synastryReportCard",
- "synastryHistory",
"discardLegacyCloudMirrorKeys",
# 原值 / 新值 / 原因:退役面板样式 / 人物详情与带用量的删除 / 锁实际 /people 入口。
"people-archive-detail",
"pendingDelete",
- 'fetch("/api/synastry"',
- "Ashtakoot",
"jyotisha_chart_library",
"保存失败,请重试",
# 原值:首页相关源码必须出现「星盘库」。
@@ -304,35 +296,10 @@ def test_chart_profile_library_has_cloud_table_api_and_local_fallback() -> None:
assert "ayanam-sessions" not in page
-def test_synastry_route_orchestrates_python_chart_and_ashtakoot() -> None:
- route = SYNASTRY_ROUTE.read_text(encoding="utf-8")
- for token in (
- 'const apiBase = process.env.JYOTISH_API_BASE ?? "http://127.0.0.1:5200"',
- # 原值: postPython("/api/chart", selfPayload) 与 postPython("/api/chart", partnerPayload)
- # 新值: 两次调用都展开对应 payload,并带 skip_vedastro_main_entry_overview: true
- # 原因: 合盘改为同时排本人和对方两张盘,并关掉用不上的外部概览。断言仍锁住这两次 /api/chart,同时锁住这个开关,不放宽。
- 'postPython("/api/chart", { ...selfPayload, skip_vedastro_main_entry_overview: true })',
- 'postPython("/api/chart", { ...partnerPayload, skip_vedastro_main_entry_overview: true })',
- 'postPython("/api/varga_full"',
- 'postPython("/api/synastry"',
- "moonLongitude(selfChart)",
- "moonSummary(selfChart)",
- "d9Summary(selfD9)",
- "relationshipReport",
- "scoreBand",
- "nextEvidence",
- "ashtakoot_plus_moon_nakshatra_d9",
- 'evidenceLayers: ["ashtakoot", "moon_nakshatra", "d9_navamsa"]',
- 'status: "blocked"',
- "synastryBirthPayload",
- ):
- assert token in route
-
-
def test_synastry_reports_are_cloud_persisted_per_user() -> None:
sql = re.sub(r"\s+", " ", SYNASTRY_REPORT_MIGRATION.read_text(encoding="utf-8").lower()).strip()
route = SYNASTRY_REPORT_ROUTE.read_text(encoding="utf-8")
- page = _home_surface()
+ source = (_FRONTEND_SRC / "lib" / "home-cloud-sync.ts").read_text(encoding="utf-8")
for token in (
"create table if not exists public.synastry_reports",
@@ -362,14 +329,12 @@ def test_synastry_reports_are_cloud_persisted_per_user() -> None:
"fetchCloudSynastryHistory",
"saveCloudSynastryReport",
'fetch("/api/synastry-reports"',
- "未能存入历史",
"cloud_synastry_history_unavailable",
"cloud_synastry_report_save_failed",
):
- assert token in page
- # Former value: writeSynastryHistory(accountId, next) wrote a local
- # history copy when cloud save failed.
- assert "writeSynastryHistory(accountId, next)" not in page
+ assert token in source
+ # Legacy synastry records still persist on the guarded server route.
+ assert "writeSynastryHistory(accountId, next)" not in _home_surface()
def test_consultation_credit_lifecycle_is_idempotent_and_server_only() -> None:
diff --git a/tests/test_synastry_b1_20261114.py b/tests/test_synastry_b1_20261114.py
new file mode 100644
index 000000000..751633547
--- /dev/null
+++ b/tests/test_synastry_b1_20261114.py
@@ -0,0 +1,45 @@
+"""Synastry dossier date identity and the Saham reason in the upstream receipt."""
+
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
+
+from marriage_match_service import api, full_dossier
+
+
+def test_dossier_cache_changes_each_day_and_keeps_dates_used_by_native_calculation(monkeypatch):
+ birth = {"year": 1990, "month": 6, "day": 15, "hour": 12, "minute": 0, "lat": 40, "lon": 116, "tz": 8}
+ keys = []
+
+ def cache(identity, build, *, cache_name):
+ keys.append(identity)
+ return {"packet": build(identity)}
+
+ monkeypatch.setattr(api, "_commit_sha", lambda: "example-commit")
+ monkeypatch.setattr(api._cache, "get_or_build", cache)
+ monkeypatch.setattr(api, "build_synastry_full_dossier", lambda _, a, b: {"dates": [a["today"], b["today"]]})
+ for day in ("2026-11-14", "2026-11-15"):
+ result = api.compute_synastry_full_dossier(None, {"person_a": {**birth, "today": day}, "person_b": birth})
+ assert keys[-1]["schema"] == api._cache.CACHE_SCHEMA
+ assert [keys[-1][side]["today"] for side in ("person_a", "person_b")] == result["dates"] == [day, day]
+ assert keys[0] != keys[1]
+
+
+def test_native_saham_failure_stays_blocked_and_keeps_its_reason_on_the_affected_side():
+ # The upstream validator emits per-person and pair states but drops the calculation error.
+ receipt = {
+ "individual_technique_audit": [{
+ "technique": "Vivah and other Sahams", "person_a": {"status": "parameter_sensitive"}, "person_b": {"status": "blocked"},
+ }],
+ "pair_execution_tasks": [{"required_inputs": [{
+ "source_path": "modules.sahams", "status": "blocked", "person_a_status": "parameter_sensitive", "person_b_status": "blocked",
+ }]}],
+ }
+ a = {"modules": {"sahams": {"status": "partial", "vivah_saham": {"sign": "Aries"}}}}
+ b = {"modules": {}, "errors": ["tajika-yogas+sahams: solar_day_window_unavailable"]}
+ full_dossier._add_saham_receipt_reasons({"execution_receipt": receipt}, {"person_a": a, "person_b": b})
+ row = receipt["individual_technique_audit"][0]
+ assert row["person_a"] == {"status": "parameter_sensitive"}
+ assert row["person_b"] == {"status": "blocked", "reason": "solar_day_window_unavailable"}
+ assert receipt["pair_execution_tasks"][0]["required_inputs"][0]["person_b_reason"] == "solar_day_window_unavailable"
diff --git a/tests/test_synastry_full_dossier.py b/tests/test_synastry_full_dossier.py
index b7162a18e..7166c8e06 100644
--- a/tests/test_synastry_full_dossier.py
+++ b/tests/test_synastry_full_dossier.py
@@ -18,15 +18,16 @@ from marriage_match_service.full_dossier import build_synastry_full_dossier, rel
FIXTURE = ROOT / "frontend" / "tests" / "fixtures" / "synastry-full-dossier-truncated.json"
# Public Rodden-rated charts already used by tests/verify_jyotish_v6_1.py.
-# Times are the UT hours stored there, passed with tz 0.
+# The first time uses UT. For the second chart use the same instant in local
+# civil time so the native Saham sunrise function can bracket the local day.
EINSTEIN = {
"year": 1879, "month": 3, "day": 14, "hour": 10, "minute": 30, "second": 0,
"lat": 48.4, "lon": 10.0, "tz": 0, "ayanamsa": "lahiri", "node_mode": "mean",
"today": "2026-10-18",
}
JOBS = {
- "year": 1955, "month": 2, "day": 25, "hour": 3, "minute": 15, "second": 0,
- "lat": 37.77, "lon": -122.42, "tz": 0, "ayanamsa": "lahiri", "node_mode": "mean",
+ "year": 1955, "month": 2, "day": 24, "hour": 19, "minute": 15, "second": 0,
+ "lat": 37.77, "lon": -122.42, "tz": -8, "ayanamsa": "lahiri", "node_mode": "mean",
"today": "2026-10-18",
}
@@ -143,6 +144,12 @@ def test_public_pair_dossier_reading_scope_follows_upstream_readiness():
"person_a": ["stable", "varies", "stable"], "person_b": ["varies", "varies", "stable"],
}
assert tasks[timing] == "parameter_sensitive"
+
+ sahams = next(row for row in dossier["execution_receipt"]["individual_technique_audit"]
+ if row["technique"] == "Vivah and other Sahams")
+ for side in ("person_a", "person_b"):
+ assert sahams[side]["source_path"] == "modules.sahams"
+ assert sahams[side]["status"] == "parameter_sensitive"
assert dossier["delivery_readiness"] == "ready_for_narrative"
assert dossier["reading_scope"]["status"] == "full"
assert dossier["ayanamsa_alignment"]["status"] == "same_profile"
| | | | |