diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 373e199be..ca50ad5de 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -28304,3 +28304,15 @@ - 待占星师确认:她 §6 P1「尊贵度照原词写」原本是为了能核对(防止把旺写成庙);改成说意思后,正文里的尊贵度不再能按原词核对。随这一轮内容审阅一起问她。 - 关联记录:BUG-2028、BUG-2034、BUG-2038、BUG-2043(解读的白话与分层)、BUG-2081、BUG-2091、BUG-2094(提问回答的同一套词表)、BUG-2095(数据章节里的代号,问答可读性窗口)。 - 修复版本:`claude/reading-plain-2098`。 + +## BUG-2099 | 报告内提问:从力量推出的生活判断没有数字时漏过检查 + +- 状态:fixed-pending-verify +- 现象:测试环境第二十二轮复测,个人报告提问「现在这几年」的回答写「盘中几颗关键星的力量都过了最低线,扛得住这几年」。前半句有存下的事实(「最低线 5,达到」),「扛得住这几年」是材料里没有的生活判断。 +- 触发条件:句子里有力量 / 六力 / 最低线一类的词,但没有数字,再从它推出扛得住、稳得住、吃得消这类结论。 +- 根因:BUG-2094 的强度判断检查只在力量词旁边有数字时才看,这句没有数字。 +- 修复:`frontend/src/lib/annual-question-check.ts` 的 `annualReplyStrengthVerdicts` 加一条不带数字的路径:句子里先出现力量词、后面跟生活判断或强弱用词(扛得住、稳得住、吃得消、起作用、偏弱……)就送进已有的改写轮;材料里同一个力量词的句子写了同样的判断时放行。单独的「过了最低线」「达到」仍按材料放行。改写提示补上「也没有从力量推出扛不扛得住、稳不稳」。个人报告提问的指令在力量那一行末尾补一句「也不从力量推出扛不扛得住、稳不稳」。年运和个人报告的提问共用这一检查。 +- 验证:`frontend/tests/report-answers-2099.test.ts`(第二十至二十二轮回答里所有带力量词的句子和几条中性句的对照表、材料放行、改写提示、指令);`report-answers-2094.test.ts` 改写提示的断言按原值 / 新值 / 原因更新。 +- 防复发:对照表钉住这次漏掉的句子和不应误报的句子。 +- 关联记录:BUG-2091、BUG-2094、BUG-2093、BUG-2085。 +- 修复版本:`claude/strength-check-2099`。 diff --git a/frontend/src/lib/annual-question-check.ts b/frontend/src/lib/annual-question-check.ts index 2be9fe6ed..c3830361a 100644 --- a/frontend/src/lib/annual-question-check.ts +++ b/frontend/src/lib/annual-question-check.ts @@ -177,10 +177,41 @@ function materialStrengthVerdict(source: string, terms: readonly string[]): bool return (source.match(SENTENCE) ?? []).some((sentence) => terms.some((term) => sentence.includes(term)) && strengthVerdict(sentence)); } +/** + * BUG-2099 (round twenty-two, personal answer 2): a life verdict drawn from strength with no number + * in the sentence — 「盘中几颗关键星的力量都过了最低线,扛得住这几年」. 「过了最低线」 is the stored + * fact (「最低线 5,达到」); 「扛得住这几年」 is not. A sentence counts when it names a strength term and, + * after it, a life verdict (扛得住、稳得住、吃得消…) or a strength quality (起作用、有力、偏弱…). The + * reach-the-line words themselves (达到、最低线、够) stay with the number path and STRENGTH_VERDICT, so a + * bare 「过了最低线」 is allowed when the material states 达到. Allowed when a sentence of the material + * with the same term carries the same verdict word. + */ +const LIFE_STRENGTH_TERM = /六力|八分力|五分力|分力|总分|强度|力量|最低线/u; +const LIFE_VERDICT = /扛得住|扛不住|撑得住|撑不住|稳得住|稳不住|顶得住|顶不住|有底气|没底气|不怕|没问题|吃得消|吃不消|够用|靠得住|靠不住|压得住|压不住|起作用|有力|无力|偏弱|偏强|很强|很弱|较强|较弱|不弱|不强|太弱|太强/gu; + +function lifeVerdictWords(sentence: string): string[] { + const term = sentence.search(LIFE_STRENGTH_TERM); + if (term < 0) return []; + return [...new Set(sentence.slice(term).match(LIFE_VERDICT) ?? [])]; +} + +function materialLifeVerdict(source: string, terms: readonly string[], words: readonly string[]): boolean { + return (source.match(SENTENCE) ?? []).some((sentence) => + terms.some((term) => sentence.includes(term)) && words.some((word) => sentence.includes(word))); +} + +function lifeStrengthTerms(sentence: string): string[] { + return [...new Set(sentence.match(new RegExp(LIFE_STRENGTH_TERM.source, "gu")) ?? [])]; +} + export function annualReplyStrengthVerdicts(answer: string, material: unknown): string[] { const source = materialText(material); return (answer.match(SENTENCE) ?? []) - .filter((sentence) => strengthVerdict(sentence) && !materialStrengthVerdict(source, strengthTerms(sentence))) + .filter((sentence) => { + if (strengthVerdict(sentence)) return !materialStrengthVerdict(source, strengthTerms(sentence)); + const words = lifeVerdictWords(sentence); + return words.length > 0 && !materialLifeVerdict(source, lifeStrengthTerms(sentence), words); + }) .map((sentence) => sentence.trim()); } @@ -196,7 +227,7 @@ export function annualReplyUnsupportedJudgments(answer: string, material: unknow out.push(`「${verdict}」:材料只给了强度的数字,没有说它达到或没达到最低线、够不够;照报告写数字,或者不写这一层`); } else { const drawn = annualReplyStrengthVerdicts(answer, material)[0]; - if (drawn) out.push(`「${drawn}」:材料只给了强度的数字,没有从数字推出轻重、虚实、够不够;照报告写数字,或者不写这一层`); + if (drawn) out.push(`「${drawn}」:材料只给了强度的数字,没有从数字推出轻重、虚实、够不够,也没有从力量推出扛不扛得住、稳不稳;照报告写数字,或者不写这一层`); } return out; } diff --git a/frontend/src/mastra/personal-report-chat.ts b/frontend/src/mastra/personal-report-chat.ts index c9be7666f..467b29c85 100644 --- a/frontend/src/mastra/personal-report-chat.ts +++ b/frontend/src/mastra/personal-report-chat.ts @@ -31,7 +31,7 @@ export const PERSONAL_CHAT_INSTRUCTIONS = [ `写给不懂占星的人:${PLAIN_TERMS}`, `${SYNASTRY_PLAIN_TIME_RULE}。`, `不推责:${SYNASTRY_NO_SHEDDING_RULE}。同一条限制全文只说一次,不写「只当方向参考」「仅供参考」这类话。`, - "限制和力量只照读到的材料说:出生时间差几分钟会改变哪一条,只在读到的材料写了时才写;六力只照材料里的数字和「达到 / 未达到」写,材料没写的强度不下结论。", + "限制和力量只照读到的材料说:出生时间差几分钟会改变哪一条,只在读到的材料写了时才写;六力只照材料里的数字和「达到 / 未达到」写,材料没写的强度不下结论,也不从力量推出扛不扛得住、稳不稳。", ].join("\n"); export const PERSONAL_TOOL_MISSING_MESSAGE = "这次没能读到报告材料,请再试一次。"; diff --git a/frontend/tests/report-answers-2094.test.ts b/frontend/tests/report-answers-2094.test.ts index 73783b40a..99ba75ae8 100644 --- a/frontend/tests/report-answers-2094.test.ts +++ b/frontend/tests/report-answers-2094.test.ts @@ -77,7 +77,10 @@ test("a verdict drawn from a strength number in other words is found; the number const judged = { sections: [{ ...work(), text: `${WORK_TEXT}\n- 土星本命八分力三、总分三十,所以力量偏弱。` }] }; assert.equal(annualReplyStrengthVerdicts(R21_ANSWER_3, judged).length, 0); // It is reported with what to do; BUG-2091's 「最低线」 note still comes first when that is the wording. - assert.ok(annualReplyUnsupportedJudgments(R21_ANSWER_3, material)[0]!.endsWith("没有从数字推出轻重、虚实、够不够;照报告写数字,或者不写这一层")); + // 原值:「…没有从数字推出轻重、虚实、够不够;照报告写数字,或者不写这一层」 + // 新值:「…没有从数字推出轻重、虚实、够不够,也没有从力量推出扛不扛得住、稳不稳;照报告写数字,或者不写这一层」 + // 原因:BUG-2099 把没有数字、从力量推出生活判断的句子也送进同一轮改写,提示写全两类。 + assert.ok(annualReplyUnsupportedJudgments(R21_ANSWER_3, material)[0]!.endsWith("没有从数字推出轻重、虚实、够不够,也没有从力量推出扛不扛得住、稳不稳;照报告写数字,或者不写这一层")); assert.ok(annualReplyUnsupportedJudgments(R20_ANSWER_12, material)[0]!.startsWith("「到了最低线」")); }); diff --git a/frontend/tests/report-answers-2099.test.ts b/frontend/tests/report-answers-2099.test.ts new file mode 100644 index 000000000..59ad8c671 --- /dev/null +++ b/frontend/tests/report-answers-2099.test.ts @@ -0,0 +1,56 @@ +/** + * BUG-2099 (staging retest round twenty-two, personal answer 2): 「盘中几颗关键星的力量都过了最低线, + * 扛得住这几年」 — the reach-the-line half is the stored fact, the life verdict is not. BUG-2094's + * check needed a number next to the strength term, so it slipped. The table below runs every + * strength sentence from the round-20/21/22 answers. + */ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { annualReplyStrengthVerdicts, annualReplyUnsupportedJudgments } from "@/lib/annual-question-check"; +import { PERSONAL_CHAT_INSTRUCTIONS } from "@/mastra/personal-report-chat"; + +// Material the personal answer read: the stored fact with 达到, and no life verdict. +const PERSONAL_MATERIAL = { + sections: [{ id: "now", text: "土星 落第 1 宫 摩羯座,六力 7.02(最低线 5,达到)。木星 落第 9 宫 处女座,六力 6.10(最低线 5,达到)。" }], +}; +// Material an annual answer read: five-fold strength as a number only. +const ANNUAL_MATERIAL = { sections: [{ id: "year", text: "年主木星落在年盘第 9 宫,五分力 12.51。土星本命八分力三、总分三十。" }] }; + +const TABLE: Array<[string, string, typeof PERSONAL_MATERIAL | typeof ANNUAL_MATERIAL, boolean]> = [ + // [label, sentence, material, flagged by annualReplyStrengthVerdicts] + ["r22 personal 2 (the slip)", "至于你自己这边,盘中几颗关键星的力量都过了最低线,扛得住这几年。", PERSONAL_MATERIAL, true], + ["bare 过了最低线, material says 达到", "盘中几颗关键星的力量都过了最低线。", PERSONAL_MATERIAL, false], + ["r22 personal 1", "依据是:你的第十宫在白羊座,宫主火星同时管第五宫,是这张盘里起正面作用的那颗星,落在第四宫天秤座,位置待得舒服,而且第十宫本身的宫位力量是全盘十二宫最高的,所以事业这件事整体是有承诺、有分量的。", PERSONAL_MATERIAL, false], + ["r21 annual 4", "依据在年盘上:年盘上升天蝎,年主木星落在年盘第 9 宫,也就是学习、远行、长辈那一块,五分力 12.51。", ANNUAL_MATERIAL, false], + ["r22 annual 7", "依据在年盘上:年盘上升天蝎,这一年主事的星是木星,落在年盘第 9 宫,也就是学习、远行、长辈那一块,五分力 12.51。", ANNUAL_MATERIAL, false], + ["r21 annual 3 (BUG-2094 path, unchanged)", "土星自己是本命八分力三、总分三十,所以这副担子加得是实的。", ANNUAL_MATERIAL, true], + ["life verdict, no number, annual", "木星的力量够大,这一年你吃得消。", ANNUAL_MATERIAL, true], + ["strength quality, no number", "这颗星力量偏弱,事情推起来慢。", ANNUAL_MATERIAL, true], + ["neutral: 力量排第三 copied", "这颗星力量排第三。", ANNUAL_MATERIAL, false], + ["neutral: 没问题 before any strength term", "这件事没问题,木星的力量排第二。", ANNUAL_MATERIAL, false], + ["neutral: no strength term", "这一年你扛得住压力,事情会慢慢理顺。", ANNUAL_MATERIAL, false], + ["neutral: 给你力量 without a verdict", "身边的长辈会给你力量和方向。", ANNUAL_MATERIAL, false], +]; + +test("strength sentences from rounds 20–22 and neutral ones are flagged only when a life verdict is drawn", () => { + for (const [label, sentence, material, flagged] of TABLE) { + assert.equal(annualReplyStrengthVerdicts(sentence, material).length > 0, flagged, label); + } +}); + +test("the same verdict in the material allows it", () => { + const material = { sections: [{ id: "now", text: "土星六力 7.02,达到最低线,这几年扛得住。" }] }; + assert.equal(annualReplyStrengthVerdicts("盘中几颗关键星的力量都过了最低线,扛得住这几年。", material).length, 0); +}); + +test("the slip goes to the reword round with the widened note", () => { + const out = annualReplyUnsupportedJudgments("至于你自己这边,盘中几颗关键星的力量都过了最低线,扛得住这几年。", PERSONAL_MATERIAL); + assert.equal(out.length, 1); + assert.ok(out[0]!.includes("扛得住这几年")); + assert.ok(out[0]!.endsWith("也没有从力量推出扛不扛得住、稳不稳;照报告写数字,或者不写这一层")); +}); + +test("the personal instructions say the same in one clause", () => { + assert.ok(PERSONAL_CHAT_INSTRUCTIONS.includes("材料没写的强度不下结论,也不从力量推出扛不扛得住、稳不稳。")); +});