Round 28: the section failed its repair on fact_with_inference and fell back to a computed text that only said 「所需依据已算出」, so the planets, signs, houses and periods BUG-2143 moved there were lost. - writer rule (contract G-17): this section is fact paragraphs, no inference words; the repair note names the words; the last pass drops inferring clauses of a fact paragraph like reader wording (salvage reason fact_with_inference) - computed 依据与边界 lists the chart evidence per theme (sign, house, lord, dignity, D10/D2/D9, A10/AmK/UL/DK, health lords, Badhaka, current and next period to the month), only audit rows with content, birth-scenario limits only for an uncertain time (BUG-2141), packed into the stored 4 paragraphs - chat 判断依据: drop 「只是条件性窗口」「只作当年结构」 tails and 「本轮只解释到…」, 「本轮未交付」 → 「这次没有展开」; numbers kept (655 answers, 46 lines → 0) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
66 lines
4.9 KiB
TypeScript
66 lines
4.9 KiB
TypeScript
/**
|
|
* BUG-2134 (第二十六轮复测): the computed 「依据与边界」 read like a backstage checklist; a repair that
|
|
* lengthened the section failed as too_long; the admin log showed fact_with_inference as 「其它」; a chat
|
|
* failure told users 「Agent 未完成……」.
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
import { READING_REASON_LABELS, readingReasonLabel } from "../src/lib/admin/report-reading-log";
|
|
import { computeReadingSection } from "../src/lib/personal-report-reading-fallback";
|
|
import { basisAuditLine, disclosedWords, EVIDENCE_GRADE_CONTRACT } from "../src/lib/personal-report-reading-contract";
|
|
|
|
const src = (file: string) => readFileSync(path.join(import.meta.dirname, "..", "src", file), "utf8");
|
|
|
|
test("the computed 依据与边界 speaks to the reader, not as a to-do list", () => {
|
|
const claim = (extra: string[] = []) => ({ cap: "C", required: [], must_disclose: [...extra, "purpose_stability_not_evaluated"] });
|
|
// BUG-2145: the facts mark the time uncertain, so the shared other-scenario limit is still said (once).
|
|
const section = computeReadingSection({ id: "basis", title: "依据与边界" } as never, { birth_precision: { window: { source: "user_stated" } }, evidence_grades: { contract: EVIDENCE_GRADE_CONTRACT, claims: {
|
|
character_structure: claim(), career_promise: claim(["p:career:D10", "v:D10"]), health_pressure: claim(["p:health:D30"]),
|
|
} } } as never);
|
|
const text = section!.paragraphs.map((paragraph) => paragraph.text).join("\n");
|
|
assert.doesNotMatch(text, /需要说明|都要说明|未评估出生时间对这类判断的影响/);
|
|
assert.equal([...text.matchAll(/其他可能的出生时间尚未作比较/g)].length, 1, text);
|
|
// 原值: /事业倾向,所需依据已算出;还参考了事业分盘;…/、/健康压力,所需依据已算出;还参考了 D30 分盘/
|
|
// 新值: 「事业倾向方面,还参考了事业分盘;…」「健康压力方面,还参考了 D30 分盘」;原因:BUG-2145,复测第二十八轮计算稿只有「所需依据已算出」,BUG-2143 从正文移来的依据全部丢失;计算稿改为列出盘面依据,只保留有内容的说明行,出生时间的情景限制只在标为不确定时写
|
|
assert.match(text, /事业倾向方面,还参考了事业分盘;事业分盘的上升离星座边界很近/);
|
|
assert.match(text, /健康压力方面,还参考了 D30 分盘/);
|
|
assert.doesNotMatch(text, /所需依据已算出/);
|
|
assert.deepEqual(disclosedWords(["s:shadbala", "default_window_scenario"]), { methods: "六力", limits: "出生时间按前后 30 分钟试算" });
|
|
assert.equal(basisAuditLine({ claimType: "health_pressure", cap: "C", missingRequired: [], mustDisclose: ["v:D8"] }), "健康压力,所需依据已算出;D8 的上升离星座边界很近");
|
|
});
|
|
|
|
test("no section gets a birth-time line, so none can fail the section as too long", () => {
|
|
// 原值(BUG-2134):放不下的那句挪到同一节有空位的段落;新值:各节不再加这句;原因:BUG-2141
|
|
const reading = src("lib/personal-report-reading.ts");
|
|
assert.doesNotMatch(reading, /withBoundaryLine|const order = \[firstAffected/);
|
|
assert.doesNotMatch(reading, /if \(stored === null\) return withheld\("too_long"\);/);
|
|
});
|
|
|
|
test("every repair instruction except too_long carries the length limits", () => {
|
|
const reading = src("lib/personal-report-reading.ts");
|
|
assert.match(reading, /REPAIR_LENGTH_LIMIT = "改完每段不超过七百字,全节不超过六段,不要比原文更长。"/);
|
|
assert.match(reading, /return reason === "too_long" \? instruction : `\$\{instruction\}\$\{REPAIR_LENGTH_LIMIT\}`;/);
|
|
});
|
|
|
|
test("every reading rejection code has an admin label (none falls to 其它)", () => {
|
|
const union = /export type ReadingRejection =([\s\S]*?);/.exec(src("lib/personal-report-reading.ts"))![1]!;
|
|
const codes = [...union.matchAll(/"([a-z_]+)"/g)].map((match) => match[1]!);
|
|
assert.ok(codes.length >= 30, `${codes.length}`);
|
|
for (const code of codes) {
|
|
assert.ok(Object.hasOwn(READING_REASON_LABELS, code), code);
|
|
assert.notEqual(readingReasonLabel(code), "其它", code);
|
|
}
|
|
assert.equal(readingReasonLabel("fact_with_inference"), "事实段里夹了推断");
|
|
});
|
|
|
|
test("chat failure texts shown to users carry no Latin internal words", () => {
|
|
const files = ["lib/stream-agent-response.ts", "hooks/use-consultation-run.ts", "components/chat-message-actions.tsx"];
|
|
for (const file of files) {
|
|
const strings = [...src(file).matchAll(/"([^"\n]*[一-龥][^"\n]*)"/g)].map((match) => match[1]!);
|
|
for (const value of strings) assert.doesNotMatch(value, /\b(?:Agent|agent|Mastra|mastra|workflow|LLM|provider)\b/, `${file}: ${value}`);
|
|
}
|
|
assert.match(src("lib/stream-agent-response.ts"), /"这次没能完成必要的计算,没有扣点。请再问一次。"/);
|
|
});
|