diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 3fb7515f7..7b411bcdf 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -26836,3 +26836,30 @@ - 验证与防复发:`tests/test_synastry_parity_1994.py`(4 条,用被拒那次的三条依据原文)和 `frontend/tests/synastry-parity-1994.test.ts`(6 条,含按被拒那次第二轮关口结果重放整条生成流程)。旧代码下:三条依据 `_evidence_source` 返回空,`scrubEngineeringTerms` 原样留下字段名。同一对公开名人盘用 DeepSeek flash 实跑一次:13 次调用,关口第 3 轮通过并出报告;四条事实出现三条(缺 Sade Sati);对照 14 条结论为 9 相同、4 偏弱、1 缺失、0 相反(92.9%,原 78.6%)。只跑了一次。`test_synastry_b3_20261115.py` 两条失败(段落过长)在未改动的 staging 上同样失败,不属本条。 - 关联记录:BUG-1913、BUG-1915(程序改绑依据)、BUG-1903(照抄判定)、BUG-1681(婚恋点互落)、2026-11-13 规则(不向用户显示未通过核对)。 - 修复版本:`claude/synastry-parity-1994`,未推送。 + +## BUG-1993 | 个人报告解读:模型写了判断,九节全部因「结论没有绑定到依据」被拿掉,成品只剩事实句和「暂不能判断」 + +- 状态:fixed-pending-verify(离线回放和一次新生成已验证,待 staging 实测)。 +- 首次发现 / 最近更新:2026-11-18 / 2026-11-18。 +- 触发与现象:网站与上游本地跑法的对照里,一张公开测试盘的个人报告解读首轮九节全部被扣(`claim_binding_missing`),自动重绑修好 0 节,重写修好 1 节,最终 7 节改用计算回退,页面每节只有位置事实加「证据等级 D…暂不能判断」。模型原稿其实每段判断都写了结论类型、不超过上限的等级和允许范围内的依据编号。 +- 触发条件:模型在判断段上多写一个 `"kind":"judgement"`(照着事实段 `"kind":"fact"` 的样子补的),或在事实段上多带 `refs`。重写轮沿用同样的写法,所以重写也救不回来。 +- 根因(按保存的原稿离线回放逐层确认,共五处): + 1. `frontend/src/lib/personal-report-reading-contract.ts` 的段落结构是严格对象:判断段不允许有 `kind`,事实段不允许有 `refs`。`personal-report-reading.ts` 的 `checkSection` 解析失败就整节记 `claim_binding_missing`;`personal-report-reading-rebind.ts` 的 `rebindReadingSection` 遇到「解析失败但带了 kind 或 claims」的段落原样放过,所以自动重绑一段也不修。原稿 21 段判断全部带 `kind:"judgement"`,5 段事实带 `refs`(依据说明一节就是因此被扣),九节无一幸免。 + 2. 去掉上一层后露出:`TIMING_TEXT` 把四位小数的小数部分当成四位年份(事实包里的度数 15.0627、六力 5.1292),性格节和总评被判「时间未绑定」。 + 3. 性格和感情两节引用了事实包给出的八分法分值,但 `scripts/report_render/evidence_grade.py` 的 `CLAIM_TYPES` 只把八分法列在事业和财富三类的 checked 里,于是整节 `ref_outside_claims`。 + 4. 复述落陷取消条件的句子「土星在角宫、该星入旺星座的主星月亮在角宫」被 `dignityMismatch` 读成「土星入旺」。 + 5. 以上修完后回放还剩总评、建议两节是 `grade_above_cap`(事业节的时间段落在 D,总评的时间段写了 C)。这是等级规则本身在起作用,线上由重写轮处理,未改。 +- 修复: + - `rebindReadingSection` 在解析前先整理两种写法并记入 `auto_rebound`:判断段带齐 claims 时去掉非 fact 的 `kind`(规则名 `judgement_label_dropped`);纯事实段去掉多带的 `refs`(`fact_refs_dropped`)。之后照常走全部检查。标 fact 却带 claims 或 grade、只有标签没有 claims、有 claims 没有 grade 的段落不整理,仍按原样被扣。 + - `TIMING_TEXT` 的四位年份前面不能是小数点。 + - `CLAIM_TYPES`:性格、感情、健康压力、应期四类的 checked 加上八分法。依据是她 `strict-workflow-router.md` §2 共用基线把 Shadbala 和 Ashtakavarga 并列。它只是 checked:缺失时需要披露,不改变等级上限。这是产品对她清单的 v1 拆分,列入待她复核。 + - `dignityMismatch` 不把「入旺星座」「落陷星座」(指星座)算成这颗星的状态。 + - 没有放宽:超上限等级、本节不允许的结论类型、范围外引用、总评引用未成立结论、不稳定依据、禁用措辞,都照旧拦截,照旧先重写一次再用计算回退。 +- 验证: + - 离线回放保存的原稿(不调模型、不含重写轮):修复前 9 节被扣、0 节保留;修复后 7 节保留(性格 C×3、事业 D、财富 D×2、感情 C×4、健康 D 与 C、现在这几年 C×4、依据说明),总评和建议 2 节因 `grade_above_cap` 改用计算回退。 + - 同一张盘用 DeepSeek flash 新生成一次(含一轮重写):首轮 6 节被扣(没有一节是 `claim_binding_missing`),重绑修好 2 节,重写修好 4 节,最终 9 节全部保留、0 节回退。 + - 按事先定好的对照规则重评这份报告的 11 条上游结论:相同 2、偏弱 6、缺失 3、相反 0(72.7%,修复前 63.6%),仍未到 80%。剩下的差距不在绑定:事业、财富两类结论的上限是 D(D10、D2 上升离换座线 0.317 分钟,在 1 分钟容差内),上游在这两处给了判断;另外解读没有写「当前被点亮的是什么」。 + - 新增 `frontend/tests/report-reading-shape-labels-1993.test.ts`(6 条,修复前 5 条失败)和 `tests/test_report_grade_ashtakavarga_1993.py`(2 条,修复前 1 条失败)。 +- 防复发:旧测试只用规范写法造草稿,没有覆盖模型把两种段落形态混写的情况;验收工具的统计里 `claim_binding_missing` 同时代表「没有绑定」和「结构解析失败」,看不出是哪一种。新测试按原稿的真实写法造段落,并逐条断言其它检查没有被放宽。 +- 关联记录:BUG-1887(等级 v1)、11-13 产品规则(不因措辞或绑定检查扣节:自动重绑、重写一次、计算回退)。 +- 修复版本:`claude/report-claim-binding-1993`,未推送。 diff --git a/frontend/src/lib/personal-report-reading-rebind.ts b/frontend/src/lib/personal-report-reading-rebind.ts index 7677c63d9..9486bbe4f 100644 --- a/frontend/src/lib/personal-report-reading-rebind.ts +++ b/frontend/src/lib/personal-report-reading-rebind.ts @@ -12,7 +12,9 @@ export type Catalog = { }; export const FACT_INFERENCE = /意味着|显示出|适合|容易|有利|不利|倾向|说明你/; -export const TIMING_TEXT = /(?> = { character: "character_structure", career: "career_promise", wealth: "wealth_earning", @@ -33,6 +35,38 @@ function strictestGrade(grades: readonly EvidenceGrade[]): EvidenceGrade { return EVIDENCE_GRADES[Math.max(...grades.map((grade) => EVIDENCE_GRADES.indexOf(grade)))]!; } +type DraftParagraph = ReportReadingDraftSection["paragraphs"][number]; + +/** + * BUG-1993: two shapes the model writes that carry a complete, checkable paragraph but fail the + * strict schema, so the whole section used to be withheld as `claim_binding_missing` and neither + * rebind nor the repair round touched it (the repair reply repeats the shape): + * + * - a judgement paragraph with its claims and grade plus a label mirroring the fact shape + * (`"kind":"judgement"`). The label says nothing the claims do not; it is dropped. + * - a fact paragraph (`"kind":"fact"`, no claims, no grade) that also lists `refs`. A fact needs no + * refs; they are dropped. + * + * Nothing else changes: the paragraph still goes through every binding, section, cap, reference + * and wording check. A paragraph that says `fact` and also carries claims or a grade stays as + * written and fails as before. + */ +function reshapeParagraph(paragraph: DraftParagraph): { paragraph: DraftParagraph; rule?: string } { + const fields = paragraph as DraftParagraph & { kind?: unknown; claims?: unknown; grade?: unknown; refs?: unknown }; + const hasClaims = Array.isArray(fields.claims) && fields.claims.length > 0; + if (hasClaims && typeof fields.kind === "string" && fields.kind !== "fact") { + const { kind: _label, ...rest } = fields; + void _label; + return { paragraph: rest as DraftParagraph, rule: "judgement_label_dropped" }; + } + if (fields.kind === "fact" && !Object.hasOwn(fields, "claims") && !Object.hasOwn(fields, "grade") && Array.isArray(fields.refs)) { + const { refs: _refs, ...rest } = fields; + void _refs; + return { paragraph: rest as DraftParagraph, rule: "fact_refs_dropped" }; + } + return { paragraph }; +} + export function rebindReadingSection( section: ReportReadingDraftSection, claims: Claims, @@ -47,7 +81,13 @@ export function rebindReadingSection( const establishedTypes = REPORT_CLAIM_TYPES.filter((type) => established.has(type)); const dependencies = (types: readonly ReportClaimType[]) => claimDependencyIds(types.flatMap((type) => claims[type] ? [claims[type]] : [])); - const paragraphs: ReportReadingDraftSection["paragraphs"] = section.paragraphs.map((raw, index) => { + const paragraphs: ReportReadingDraftSection["paragraphs"] = section.paragraphs.map((original, index) => { + const reshaped = reshapeParagraph(original); + const raw = reshaped.paragraph; + if (reshaped.rule) { + const grade = EVIDENCE_GRADES.find((value) => value === raw.grade) ?? null; + changes.push({ section: section.id, paragraph: index + 1, rule: reshaped.rule, added_claims: [], grade_from: grade, grade_to: grade }); + } const parsed = reportReadingDraftParagraphSchema.safeParse(raw); const missing = !Object.hasOwn(raw, "kind") && !Object.hasOwn(raw, "claims"); if (!parsed.success && !missing) return raw; diff --git a/frontend/src/lib/personal-report-reading.ts b/frontend/src/lib/personal-report-reading.ts index 4674716f5..8c8db340d 100644 --- a/frontend/src/lib/personal-report-reading.ts +++ b/frontend/src/lib/personal-report-reading.ts @@ -265,7 +265,9 @@ function dignityMismatch(text: string, dignities: Map>): boo const known = [...(dignities.get(planet) ?? [])]; // 「木星、落陷金星」 (DeepSeek eval 2026-11-12, public chart A): 「落陷」 belongs to 金星. if (nextFollows && clause.endsWith(word)) continue; - if (clause.includes(word) && !known.some((given) => given.includes(word))) return true; + // BUG-1993: 「土星在角宫、该星入旺星座的主星月亮在角宫」 quotes the facts' cancellation + // condition; 「入旺星座」/「落陷星座」 names a sign, not this planet's dignity. + if (clause.replaceAll(`${word}星座`, "").includes(word) && !known.some((given) => given.includes(word))) return true; } } } diff --git a/frontend/tests/report-reading-shape-labels-1993.test.ts b/frontend/tests/report-reading-shape-labels-1993.test.ts new file mode 100644 index 000000000..4f995301e --- /dev/null +++ b/frontend/tests/report-reading-shape-labels-1993.test.ts @@ -0,0 +1,116 @@ +// BUG-1993: a saved report draft (公开测试盘, DeepSeek flash) lost all nine sections to +// `claim_binding_missing` although every judgement paragraph carried claims, a grade within its +// cap and allowed refs. These cases reproduce each cause found in that draft. +import assert from "node:assert/strict"; +import test from "node:test"; + +import { acceptReportReadingDraft } from "../src/lib/personal-report-reading"; +import { + EVIDENCE_GRADE_CONTRACT, REPORT_READING_SECTIONS, type ReportReadingSectionId, +} from "../src/lib/personal-report-reading-contract"; + +const SKILL = { name: "reading", version: "test", loaded: [{ path: "SKILL.md", sha256: "0".repeat(64) }] }; +const NEUTRAL = "本段复述虚构记录中的顺序、参与者位置以及需要核对的几条线索。读者可对照各行说明追溯原记录。".repeat(3); + +function claim(cap: string, sections: string[], required: string[], checked: string[] = []) { + return { cap, sections, required: required.map((id) => ({ id })), checked: checked.map((id) => ({ id })) }; +} + +const FACTS = { + planets: { Saturn: { d1_dignity_zh: "入友" }, Moon: { d1_dignity_zh: "极友" }, Jupiter: { d1_dignity_zh: "落陷取消" } }, + evidence_grades: { + contract: EVIDENCE_GRADE_CONTRACT, + claims: { + character_structure: claim("C", ["overview", "character"], ["v:D1", "s:functional"], ["s:shadbala", "s:ashtakavarga"]), + career_promise: claim("D", ["overview", "career"], ["v:D1", "v:D10"], ["s:shadbala"]), + timing_window: claim("C", ["overview", "career", "now"], ["s:vimshottari"]), + }, + dependency_catalog: { + "v:D1": { state: "clear_at_tolerance", aliases: ["D1", "本命盘"] }, + "v:D10": { state: "boundary_sensitive", aliases: ["D10"] }, + "s:functional": { state: "executed", aliases: ["功能吉凶"] }, + "s:shadbala": { state: "executed", aliases: ["Shadbala", "六力"] }, + "s:ashtakavarga": { state: "executed", aliases: ["Ashtakavarga", "八分法", "SAV"] }, + "s:vimshottari": { state: "executed", aliases: ["Vimshottari", "大运", "小运", "次小运"] }, + }, + }, +}; + +function run(overrides: Partial[]>>) { + const result = acceptReportReadingDraft({ sections: REPORT_READING_SECTIONS.map(({ id }) => ({ + id, + paragraphs: [{ text: NEUTRAL, kind: "fact" }, { text: NEUTRAL, kind: "fact" }, ...(overrides[id] ?? [])], + })) }, FACTS, SKILL); + assert.ok(result.ok, JSON.stringify(result)); + const withheld = result.reading.sections.flatMap((section) => section.status === "withheld" ? [[section.id, section.reason]] : []); + return { withheld, rebound: result.rebound, sections: result.reading.sections }; +} + +const JUDGEMENT = { + text: "本命盘上命主星落第三宫,表达欲强,要把感受说清楚才安心。", kind: "judgement", + claims: ["character_structure"], grade: "C", refs: ["v:D1", "s:functional"], +}; + +test("a judgement paragraph keeps its claims and grade when it also carries a kind label", () => { + const { withheld, rebound, sections } = run({ character: [JUDGEMENT] }); + assert.deepEqual(withheld, []); + assert.deepEqual(rebound, [{ + section: "character", paragraph: 3, rule: "judgement_label_dropped", added_claims: [], grade_from: "C", grade_to: "C", + }]); + const character = sections.find(({ id }) => id === "character"); + assert.ok(character?.status === "ok"); + const stored = character.paragraphs.at(-1)!; + assert.ok("claims" in stored); + assert.deepEqual([stored.claims, stored.grade], [["character_structure"], "C"]); +}); + +test("a fact paragraph that lists refs is kept as a fact", () => { + const { withheld, rebound, sections } = run({ career: [{ text: NEUTRAL, kind: "fact", refs: ["v:D10"] }] }); + assert.deepEqual(withheld, []); + assert.deepEqual(rebound.map(({ rule }) => rule), ["fact_refs_dropped"]); + const career = sections.find(({ id }) => id === "career"); + assert.ok(career?.status === "ok"); + assert.deepEqual(career.paragraphs.at(-1), { kind: "fact", text: NEUTRAL }); +}); + +test("dropping the label does not relax any other check", () => { + // A grade above the claim's cap is still rejected. + assert.deepEqual(run({ career: [{ ...JUDGEMENT, claims: ["career_promise"], grade: "C", refs: ["v:D1"] }] }).withheld, + [["career", "grade_above_cap"]]); + // A claim the section does not allow is still rejected. + assert.deepEqual(run({ now: [JUDGEMENT] }).withheld, [["now", "claim_type_section"]]); + // A ref outside the claim's dependencies is still rejected. + assert.deepEqual(run({ character: [{ ...JUDGEMENT, refs: ["v:D10"] }] }).withheld, [["character", "ref_outside_claims"]]); + // A label without claims, a fact that carries claims, and a judgement without a grade stay unbound. + for (const paragraph of [ + { text: JUDGEMENT.text, kind: "judgement" }, + { ...JUDGEMENT, kind: "fact" }, + { text: JUDGEMENT.text, kind: "judgement", claims: ["character_structure"] }, + { text: JUDGEMENT.text, kind: "judgement", claims: [], grade: "C" }, + ]) { + assert.deepEqual(run({ character: [paragraph] }).withheld, [["character", "claim_binding_missing"]], JSON.stringify(paragraph)); + } +}); + +test("four decimal digits of a degree or strength value are not a year", () => { + const strength = { ...JUDGEMENT, kind: undefined, text: "土星六力 5.1292 是七颗里最低,上升在 15.0627 度,起步偏慢。", refs: ["v:D1", "s:shadbala"] }; + delete strength.kind; + assert.deepEqual(run({ character: [strength] }).withheld, []); + assert.deepEqual(run({ character: [{ ...strength, text: "这一层到 2027 才松动。" }] }).withheld, [["character", "timing_unbound"]]); + assert.deepEqual(run({ character: [{ ...strength, text: "这一层到2027.5才松动。" }] }).withheld, [["character", "timing_unbound"]]); +}); + +test("a cancellation condition naming an exaltation sign is not a dignity claim about the planet before it", () => { + const condition = { + text: "木星的落陷取消写明了条件:落陷星座的主星土星在角宫、该星入旺星座的主星月亮在角宫。", + claims: ["character_structure"], grade: "C", refs: ["v:D1"], + }; + assert.deepEqual(run({ character: [condition] }).withheld, []); + assert.deepEqual(run({ character: [{ ...condition, text: "土星在第九宫入旺,底气足。" }] }).withheld, [["character", "dignity_mismatch"]]); + assert.deepEqual(run({ character: [{ ...condition, text: "土星落陷星座之外还落陷,底气弱。" }] }).withheld, [["character", "dignity_mismatch"]]); +}); + +test("a paragraph citing Ashtakavarga binds when the claim checks it", () => { + const sav = { text: "月亮自身八分法分值只有 3,情绪底气偏弱。", claims: ["character_structure"], grade: "C", refs: ["v:D1"] }; + assert.deepEqual(run({ character: [sav] }).withheld, []); +}); diff --git a/scripts/report_render/evidence_grade.py b/scripts/report_render/evidence_grade.py index 804847124..ece129f77 100644 --- a/scripts/report_render/evidence_grade.py +++ b/scripts/report_render/evidence_grade.py @@ -54,12 +54,20 @@ MISSING_STATES = {"blocked", "withheld", "missing", "calculation_failed", "missi # ("t", key) timing / transit / annual block present # Each claim type: route (her router section), section ids it may appear in, # required deps (missing -> D) and checked deps (missing -> disclosed only). +# +# BUG-1993: 原值: ("s", "ashtakavarga") 只在事业、财富三类的 checked 里; +# 新值: 性格、感情、健康压力、应期四类的 checked 也列它; +# 原因: 她的 strict-workflow-router.md §2 共用基线把 Shadbala 和 Ashtakavarga 并列("when a claim +# depends on planetary strength or transit strength"),事实包也给每个领域的宫位和行星带了八分法分值, +# 原表只把 Shadbala 列进了这几类。段落照事实包写出「第七宫八分法 30」就因引用不在允许范围整节被扣。 +# 它是 checked:缺失只需披露,不改变等级上限。 CLAIM_TYPES: dict[str, dict[str, Any]] = { "character_structure": { "route": "full-reading-strict §2", "sections": ("overview", "character"), "required": [("v", "D1"), ("s", "functional")], - "checked": [("s", "d9"), ("v", "D9"), ("s", "shadbala"), ("s", "avastha"), ("s", "dispositor_chain")], + "checked": [("s", "d9"), ("v", "D9"), ("s", "shadbala"), ("s", "ashtakavarga"), ("s", "avastha"), + ("s", "dispositor_chain")], }, "career_promise": { "route": "career-timing-strict §3", @@ -87,14 +95,14 @@ CLAIM_TYPES: dict[str, dict[str, Any]] = { "sections": ("overview", "love"), "required": [("v", "D1"), ("s", "functional"), ("p", "marriage", "D9_7"), ("v", "D9")], "checked": [("p", "marriage", "UL"), ("p", "marriage", "A7"), ("p", "marriage", "DK"), - ("p", "marriage", "Vivah"), ("s", "shadbala")], + ("p", "marriage", "Vivah"), ("s", "shadbala"), ("s", "ashtakavarga")], }, "health_pressure": { "route": "health-timing-strict §7", "sections": ("overview", "health"), "required": [("v", "D1"), ("s", "functional"), ("p", "health", "D6"), ("v", "D6")], "checked": [("p", "health", "D8"), ("v", "D8"), ("p", "health", "D30"), ("v", "D30"), - ("p", "health", "drekkana22"), ("s", "shadbala")], + ("p", "health", "drekkana22"), ("s", "shadbala"), ("s", "ashtakavarga")], }, "health_obstruction": { "route": "health-timing-strict §7 + badhaka-obstacle-planet-guide.md §二", @@ -106,7 +114,7 @@ CLAIM_TYPES: dict[str, dict[str, Any]] = { "route": "event-timing-strict §6", "sections": ("overview", "career", "wealth", "love", "health", "now"), "required": [("s", "vimshottari"), ("s", "narayana"), ("t", "transits")], - "checked": [("t", "annual"), ("t", "double_transit"), ("s", "yogini"), ("s", "kp")], + "checked": [("t", "annual"), ("t", "double_transit"), ("s", "yogini"), ("s", "kp"), ("s", "ashtakavarga")], }, } diff --git a/tests/test_report_grade_ashtakavarga_1993.py b/tests/test_report_grade_ashtakavarga_1993.py new file mode 100644 index 000000000..3e98378f3 --- /dev/null +++ b/tests/test_report_grade_ashtakavarga_1993.py @@ -0,0 +1,30 @@ +"""BUG-1993: Ashtakavarga is a checked layer of every claim whose facts carry its scores. + +Her strict-workflow-router.md §2 names Shadbala and Ashtakavarga together in the shared baseline. +The v1 table listed Ashtakavarga only for career and wealth, so a character or relationship +paragraph quoting the SAV score the facts supply was withheld as `ref_outside_claims`. +""" + +from scripts.report_render.evidence_grade import CLAIM_TYPES, claim_grade +from tests.test_report_evidence_grade_20261112 import _facts + +WITH_SAV = ("character_structure", "career_promise", "wealth_earning", "wealth_retention", + "relationship_structure", "health_pressure", "timing_window") + + +def test_ashtakavarga_is_checked_never_required(): + for claim_type in WITH_SAV: + assert ("s", "ashtakavarga") in CLAIM_TYPES[claim_type]["checked"], claim_type + assert ("s", "ashtakavarga") not in CLAIM_TYPES[claim_type]["required"], claim_type + # Badhaka obstruction has no strength layer in her guide. + assert CLAIM_TYPES["health_obstruction"]["checked"] == [] + + +def test_missing_ashtakavarga_is_disclosed_and_leaves_the_cap(): + facts = _facts() + facts["shared_techniques"] = [row for row in facts["shared_techniques"] if row["id"] != "ashtakavarga"] + for claim_type in ("character_structure", "relationship_structure", "timing_window"): + with_layer, without_layer = claim_grade(_facts(), claim_type), claim_grade(facts, claim_type) + assert without_layer["cap"] == with_layer["cap"] == "C", claim_type + assert "s:ashtakavarga" in without_layer["must_disclose"], claim_type + assert "s:ashtakavarga" not in with_layer["must_disclose"], claim_type