From 0d0180667d6bc0aac86a32bb3584573bbdc04281 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 12:26:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(synastry):=20technical=20appendix=20shows?= =?UTF-8?q?=20parameters,=20the=20seven=20kutas,=20Kuja=20and=20Papasamya;?= =?UTF-8?q?=20blocked=20reads=20=E6=97=A0=E6=B3=95=E8=AE=A1=E7=AE=97=20(BU?= =?UTF-8?q?G-1679)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The appendix read keys the dossier does not have: the profile is per person (`calculation_profile.person_a/person_b`), kuta scores sit under `ashtakoota_36.international_core.scores`, and the Raman packet is the match object itself. Parameters were always 「未标明」 and the traditional block was one sentence. Now: per-person ayanamsa / node / house system, the seven-kuta total out of 35 with each item and its ceiling, Bhakoot / Nadi exception candidates (raw score unchanged), Kuja per reference frame with mitigations and the comparison, Papasamya per person, and the Raman Kuja variant. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DbBXp2su8Vzqv3jNvkCSqt --- docs/BUG_HISTORY.md | 14 ++ frontend/src/lib/synastry-full-technical.ts | 182 ++++++++++++++++++-- frontend/tests/synastry-full-report.test.ts | 68 +++++++- 3 files changed, 249 insertions(+), 15 deletions(-) diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 9a47086fd..91ded8629 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -22973,3 +22973,17 @@ - 防复发:表里年数与起止日期必须是同一段时间的口径;加列时同一处断言表头列数等于行列数。 - 关联记录:BUG-1674(同一次对比)、BUG-1556(第一大运从出生前起算) - 修复版本:分支 `codex/report-list-ui-20261106` + +## BUG-1679 | 合盘技术依据「计算参数」全是未标明,「传统配对参考」只剩一句话,无法计算的项露出英文 blocked + +- 状态:fixed-pending-verify(代码 + 回归测试;新生成的合盘待 staging 复核) +- 首次发现 / 最近更新:2026-11-07(对照 yinduzhanxing 合盘规范做缺口盘点时发现;产品负责人要求按缺口逐步修复,这是第 1 步) +- 影响面:`frontend/src/lib/synastry-full-technical.ts`(合盘报告技术依据第 ①、⑤、⑥ 块)。 +- 现象:第 ① 块岁差、交点、宫制在真实报告上恒为「未标明」;第 ⑤ 块只有「只作一层参考,不决定结论」、规则 id 和一行 Raman id,七项配对分、Bhakoot / Nadi 例外候选、火星凶位、Papasamya 一条都没有;第 ⑥ 块状态为 `blocked` 的技法显示英文原词。 +- 根因:证据包把计算口径按人放在 `calculation_profile.person_a / person_b`,附录读顶层;七项分数在 `ashtakoota_36.international_core.scores`,附录读不存在的 `ashtakoota_36.items`;Raman 包本身就是配对对象,附录读 `raman.marriage_match.items`。火星凶位和 Papasamya 从没接到附录。原测试只断六个块的 id 和最后一行,空块拦不住。 +- 修复:按人读口径,两人一致时写「(两人一致)」;传统配对块写七项合计(满分 35,不计种姓项)、逐项分 / 上限、例外候选(标明只是候选、原分不改)、Yoni 三档旧表说明、两人各自三个参照点的火星凶位与缓解因素、火星凶位对比、两人 Papasamya,以及 Raman 口径下的火星凶位;`blocked` / `not_available` 显示「无法计算」。 +- 验证:`frontend/tests/synastry-full-report.test.ts` 新增「BUG-1679: parameters and traditional matching read the dossier's real shape」(按 `build_synastry_full_dossier` 真实结构构造);公开名人证据包那条按真实收据核对「无法计算」;改 Raman 断言(原值 / 新值 / 原因写在测试里)。合盘测试 40/40(用带 swisseph 的 Python 跑了真实证据包)。 +- 防复发:附录每一块都要有一条用证据包真实结构的断言,不能只断块 id。 +- 已知限制:技术依据在生成时写进报告快照,本次修复只对之后新生成的合盘生效;英文版附录仍是中文,另行处理。 +- 关联记录:BUG-1395(同一附录的第 ② 块「各自的婚恋结构」曾全是未标明,当时只修了第 ② 块,第 ① 块同类问题没被测试覆盖) +- 修复版本:分支 `claude/synastry-appendix-1107` diff --git a/frontend/src/lib/synastry-full-technical.ts b/frontend/src/lib/synastry-full-technical.ts index 898c538eb..4ef97cd3a 100644 --- a/frontend/src/lib/synastry-full-technical.ts +++ b/frontend/src/lib/synastry-full-technical.ts @@ -1,3 +1,5 @@ +import { AYANAMSA_OPTIONS } from "@/lib/ayanamsa"; + /** * Technical appendix. Built only from the evidence packet, never from the model. */ @@ -22,6 +24,9 @@ const STATUS_LABELS: Readonly> = { not_applicable: "不适用", not_used: "不适用", not_used_for_date_intersection: "不适用", + // E5b: a layer that could not run says so in Chinese, not as a raw code (BUG-1679). + blocked: "无法计算", + not_available: "无法计算", }; function record(value: unknown): Record | null { @@ -81,6 +86,167 @@ function structureLine(name: string, snapshot: Record, local: R return `${name}:${slots.map(([label, value]) => `${label} ${value}`).join(";")}`; } +/* ── 计算参数 and 传统配对参考 (BUG-1679) ────────────────────────────── + The dossier keeps the profile per person (`calculation_profile.person_a`) + and the kuta scores under `ashtakoota_36.international_core.scores`; the + appendix read keys that do not exist, so these two blocks came out as + 「未标明」 and an empty list. */ + +const NODE_MODE: Readonly> = { mean: "平均交点", true: "真交点" }; +const HOUSE_SYSTEM: Readonly> = { whole_sign: "整宫制", placidus: "Placidus", equal: "等宫制", sripati: "Sripati" }; + +function ayanamsaName(value: string): string { + const option = AYANAMSA_OPTIONS.find((item) => item.value === value); + return option ? option.label.replace(/(默认)$/, "") : value; +} + +function profileValue( + profile: Record, + names: Readonly<{ a: string; b: string }>, + key: string, + display: (value: string) => string, +): string { + const a = text(record(profile.person_a)?.[key]) || text(profile[key]); + const b = text(record(profile.person_b)?.[key]) || text(profile[key]); + if (!a && !b) return "未标明"; + if (a === b) return `${display(a)}(两人一致)`; + return `${names.a} ${a ? display(a) : "未标明"},${names.b} ${b ? display(b) : "未标明"}`; +} + +export function parameterLines(profile: Record, names: Readonly<{ a: string; b: string }>): 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)}`, + "出生时间精度:以各自档案里已经保存的时间为准,这里不显示日期和地点", + ]; +} + +/** Seven kutas, each with its own ceiling; Varna (caste) is not scored. */ +const KUTAS: ReadonlyArray = [ + ["Vashya", "Vashya(相互牵引)", 2], + ["Tara", "Tara(星宿吉凶)", 3], + ["Yoni", "Yoni(本能性情)", 4], + ["GrahaMaitri", "Graha Maitri(月亮星座主星交情)", 5], + ["Gana", "Gana(气质类型)", 6], + ["Bhakoot", "Bhakoot(月亮星座相对位置)", 7], + ["Nadi", "Nadi(体质脉络)", 8], +]; + +const EXCEPTION_ZH: Readonly> = { + same_sign_lord: "两人月亮星座主星相同", + mutual_natural_friend_sign_lords: "两人月亮星座主星互为自然友星", + same_nakshatra_different_pada: "同一星宿、不同四分", + same_rashi_different_nakshatra: "同一星座、不同星宿", +}; + +const FRAME_ZH: Readonly> = { lagna: "上升", moon: "月亮", venus: "金星" }; +const PLANET_ZH: Readonly> = { Mars: "火星", Saturn: "土星", Sun: "太阳", Rahu: "罗睺", Ketu: "计都" }; +const MITIGATION_ZH: Readonly> = { + mars_own: "火星在本宫", + mars_exalted: "火星入旺", + jupiter_conjunction: "木星同宫", + moon_conjunction: "月亮同宫", + house_sign_exception: "宫位星座例外", + leo_aquarius_profile_exception: "狮子 / 水瓶例外", + leo_aquarius_exception_disputed: "狮子 / 水瓶例外有争议,未采用", +}; +const KUJA_OUTCOME_ZH: Readonly> = { + not_triggered: "两人都没有", + broadly_balanced: "两人轻重大致相当", + asymmetric: "两人轻重不一", + incomplete: "资料不全,无法比较", +}; + +function numberText(value: unknown): string | null { + return typeof value === "number" && Number.isFinite(value) ? String(Number(value.toFixed(1))) : null; +} + +export function ashtakootaLines(match: Record): string[] { + const ashtakoota = record(match.ashtakoota_36); + if (!ashtakoota) return ["七项配对:这份证据包里没有这一层"]; + if (text(ashtakoota.status) !== "executed") return ["七项配对:无法计算(缺两人的月亮经度)"]; + const core = record(ashtakoota.international_core) ?? {}; + const scores = record(core.scores) ?? {}; + const total = numberText(core.total_score); + const lines = [ + `七项配对合计:${total ?? "未标明"} / ${numberText(core.max_score) ?? "35"}(不计种姓一项;两人顺序互换后取平均)`, + `各项:${KUTAS.map(([key, label, max]) => `${label} ${numberText(scores[key]) ?? "—"}/${max}`).join(";")}`, + ]; + const review = record(ashtakoota.exception_review) ?? {}; + for (const key of ["bhakoot", "nadi"] as const) { + const row = record(review[key]); + const candidates = Array.isArray(row?.candidate_cancellations) ? row.candidate_cancellations.map(text).filter(Boolean) : []; + if (candidates.length === 0) continue; + const name = key === "bhakoot" ? "Bhakoot" : "Nadi"; + lines.push(`${name} 得 ${numberText(row?.raw_score) ?? "0"} 分,可能的例外:${candidates.map((item) => EXCEPTION_ZH[item] ?? item).join("、")}(只是候选,原分不改)`); + } + if (text(record(review.yoni)?.status) === "legacy_three_band_table") lines.push("Yoni 按 4 / 2 / 0 三档旧表计分"); + return lines; +} + +function kujaPersonLine(name: string, person: Record, prefix: string): string { + if (text(person.status) !== "executed") return `${prefix}${name} 火星凶位:无法计算`; + const frames = Array.isArray(person.frames) ? person.frames.map(record).filter((row): row is Record => row !== null) : []; + const parts = frames.map((frame) => { + const from = `${FRAME_ZH[text(frame.reference)] ?? text(frame.reference)}起第 ${numberText(frame.mars_house) ?? "?"} 宫`; + const mitigations = Array.isArray(frame.mitigations) ? frame.mitigations.map(text).filter(Boolean).map((item) => MITIGATION_ZH[item] ?? item) : []; + const status = text(frame.status); + const verdict = status === "active" ? "成立" : status === "cancelled_by_profile_exception" ? "按口径例外取消" : status === "not_available" ? "无法计算" : "不成立"; + return `${from}${verdict}${mitigations.length > 0 ? `(${mitigations.join("、")})` : ""}`; + }); + return `${prefix}${name} 火星凶位:${parts.join(";") || "未标明"}`; +} + +export function kujaLines(match: Record, names: Readonly<{ a: string; b: string }>, prefix = ""): string[] { + const kuja = record(match.kuja_mangal_dosha); + if (!kuja) return []; + const outcome = KUJA_OUTCOME_ZH[text(kuja.outcome)]; + return [ + kujaPersonLine(names.a, record(kuja.person_a) ?? {}, prefix), + kujaPersonLine(names.b, record(kuja.person_b) ?? {}, prefix), + ...(outcome ? [`${prefix}火星凶位对比:${outcome}(只看火星;不按性别区别对待,两人都有不等于自动抵消)`] : []), + ]; +} + +export function papasamyaLines(match: Record, names: Readonly<{ a: string; b: string }>): string[] { + const papasamya = record(match.papasamya); + if (!papasamya) return []; + return (["a", "b"] as const).map((side) => { + const person = record(papasamya[side === "a" ? "person_a" : "person_b"]) ?? {}; + const name = names[side]; + if (text(person.status) !== "executed") return `${name} 凶星压力(Papasamya):无法计算`; + const placements = Array.isArray(person.active_placements) ? person.active_placements.map(record).filter((row): row is Record => row !== null) : []; + if (placements.length === 0) return `${name} 凶星压力(Papasamya):没有落在压力宫位的凶星`; + const parts = placements.map((row) => `${PLANET_ZH[text(row.planet)] ?? text(row.planet)}(${FRAME_ZH[text(row.reference)] ?? text(row.reference)}起第 ${numberText(row.house) ?? "?"} 宫)`); + return `${name} 凶星压力(Papasamya):${parts.join("、")}`; + }); +} + +const PROFILE_ZH: Readonly> = { + practitioner_consensus_v1: "默认口径:从业者通行做法(火星看第 1、2、4、7、8、12 宫)", + raman_muhurtha_v1: "Raman 口径:不看第 1 宫,狮子 / 水瓶例外生效", +}; + +export function traditionalLines( + match: Record, + raman: Record | null, + names: Readonly<{ a: string; b: string }>, +): string[] { + const profileId = text(record(match.rule_profile)?.id); + // The Raman packet is the marriage-match object itself; older rows nested it. + const ramanMatch = raman ? (record(raman.marriage_match) ?? raman) : null; + const ramanId = ramanMatch ? text(record(ramanMatch.rule_profile)?.id) : ""; + return [ + "只作一层参考,不决定结论", + PROFILE_ZH[profileId] ?? (profileId || "传统配对"), + ...ashtakootaLines(match), + ...kujaLines(match, names), + ...papasamyaLines(match, names), + ...(ramanMatch ? [PROFILE_ZH[ramanId] ?? `Raman:${ramanId || "未标明"}`, ...kujaLines(ramanMatch, names, "Raman 口径 · ")] : []), + ]; +} + export function buildTechnicalBasis(input: Readonly<{ dossier: unknown; raman?: unknown; @@ -94,24 +260,12 @@ 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 = [ - `岁差:${text(profile.ayanamsa) || "未标明"}`, - `交点:${text(profile.node_mode) || text(profile.nodeMode) || "未标明"}`, - `宫制:${text(profile.house_system) || "未标明"}`, - "出生时间精度:以各自档案里已经保存的时间为准,这里不显示日期和地点", - ]; + const parameters = parameterLines(profile, input.names); const structure = (["a", "b"] as const).map((side) => { const key = side === "a" ? "person_a" : "person_b"; return structureLine(input.names[side], record(snapshots[key]) ?? {}, record(structures[key]) ?? {}); }); - const raman = record(input.raman); - const traditional = [ - "只作一层参考,不决定结论", - text(record(match.rule_profile)?.id) || "传统配对", - ...linesOf(record(match.ashtakoota_36)?.items ?? match.items), - ...(raman ? [`Raman:${text(record(raman.rule_profile)?.id) || "未标明"}`] : []), - ...linesOf(record(raman?.marriage_match)?.items ?? raman?.items), - ]; + const traditional = traditionalLines(match, record(input.raman), input.names); const execution = [ ...executionBasisLines(receipt), "外部资料与真实案例核对:未进行,本报告是计算层归纳", diff --git a/frontend/tests/synastry-full-report.test.ts b/frontend/tests/synastry-full-report.test.ts index 57c130ff6..0fb5834a2 100644 --- a/frontend/tests/synastry-full-report.test.ts +++ b/frontend/tests/synastry-full-report.test.ts @@ -494,10 +494,73 @@ test("technical execution lines follow the receipt and raman is named", () => { }); assert.deepEqual(blocks[5]?.lines.slice(0, 2), ["Niryaana Shoola:不适用", "DK cross-comparison:已执行"]); assert.match(blocks[1]?.lines[0] ?? "", /DK Venus/); - assert.match(blocks[4]?.lines.join("\n") ?? "", /raman_muhurtha_v1/); + // 2026-11-07 原值:/raman_muhurtha_v1/(原样显示规则 id)。新值:显示中文口径说明。 + // 原因:BUG-1679,传统配对块改成读真实字段并写成中文;Raman 仍然单独点名。 + assert.match(blocks[4]?.lines.join("\n") ?? "", /Raman 口径:不看第 1 宫/); assert.equal(JSON.stringify(blocks).includes("无法计算"), false); }); +/* BUG-1679: the parameters and traditional blocks read keys the dossier does + not have, so on a real report they were 「未标明」 and an empty list. The + shapes below are copied from `build_synastry_full_dossier` output. */ +test("BUG-1679: parameters and traditional matching read the dossier's real shape", () => { + const frames = (house: number, status: string, mitigations: string[] = []) => [ + { reference: "lagna", mars_house: house, status, mitigations }, + { reference: "moon", mars_house: 3, status: "not_triggered", mitigations: [] }, + { reference: "venus", mars_house: 11, status: "not_triggered", mitigations: [] }, + ]; + const marriage = (id: string) => ({ + rule_profile: { id }, + ashtakoota_36: { + status: "executed", + international_core: { + scores: { Vashya: 1, Tara: 3, Yoni: 2, GrahaMaitri: 5, Gana: 0, Bhakoot: 0, Nadi: 8 }, + total_score: 19, + max_score: 35, + }, + exception_review: { + bhakoot: { raw_score: 0, candidate_cancellations: ["mutual_natural_friend_sign_lords"] }, + nadi: { raw_score: 8, candidate_cancellations: [] }, + yoni: { status: "legacy_three_band_table" }, + }, + }, + kuja_mangal_dosha: { + outcome: "asymmetric", + person_a: { status: "executed", frames: frames(8, "active", ["mars_exalted"]) }, + person_b: { status: "executed", frames: frames(9, "not_triggered") }, + }, + papasamya: { + person_a: { status: "executed", active_placements: [{ planet: "Saturn", reference: "venus", house: 1 }] }, + person_b: { status: "executed", active_placements: [] }, + }, + }); + const profile = { ayanamsa: "lahiri", node_mode: "mean", house_system: "whole_sign" }; + const blocks = buildTechnicalBasis({ + dossier: { + calculation_profile: { person_a: profile, person_b: { ...profile, node_mode: "true" } }, + marriage_match: marriage("practitioner_consensus_v1"), + execution_receipt: { individual_technique_audit: [{ technique: "Vivah and other Sahams", status: "blocked" }] }, + }, + raman: marriage("raman_muhurtha_v1"), + names: { a: "甲", b: "乙" }, + contacts: [], + timing: [], + }); + assert.deepEqual(blocks[0]?.lines.slice(0, 3), ["岁差:Lahiri(两人一致)", "交点:甲 平均交点,乙 真交点", "宫制:整宫制(两人一致)"]); + const traditional = blocks[4]?.lines.join("\n") ?? ""; + assert.match(traditional, /七项配对合计:19 \/ 35/); + assert.match(traditional, /Bhakoot(月亮星座相对位置) 0\/7/); + assert.match(traditional, /Bhakoot 得 0 分,可能的例外:两人月亮星座主星互为自然友星(只是候选,原分不改)/); + assert.match(traditional, /甲 火星凶位:上升起第 8 宫成立(火星入旺)/); + assert.match(traditional, /火星凶位对比:两人轻重不一/); + assert.match(traditional, /甲 凶星压力(Papasamya):土星(金星起第 1 宫)/); + assert.match(traditional, /乙 凶星压力(Papasamya):没有落在压力宫位的凶星/); + 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:无法计算"]); +}); + function pythonBin(): string | null { const candidates = [process.env.PYTHON, "python3", "python"].filter((item): item is string => Boolean(item)); for (const candidate of candidates) { @@ -609,6 +672,9 @@ test("a public pair dossier fills every section without birth keys", { timeout: 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 ?? [];