fix: allow exports with QA warnings

This commit is contained in:
Codex
2026-06-21 23:43:03 +08:00
parent 21aa75d240
commit 163d375a76
7 changed files with 115 additions and 26 deletions
@@ -319,4 +319,41 @@ describe("LLM workflow integration", () => {
expect(platformCheck?.status).toBe("warn");
expect(report.overall_status).not.toBe("fail");
});
it("does not let LLM escalate hallucination risk to a hard failure", async () => {
llmMocks.generateValidatedJson.mockResolvedValueOnce({
checks: [
{
rule_id: "hallucination_risk",
status: "fail",
evidence: "LLM wants strict fact confirmation.",
reason: "This should remain a warning for user review.",
suggested_fix: "Review manually.",
target_agent: "body",
},
],
});
const report = await inspectQualityWithLlm({
article: {
title: "Example GEO Optimization Guide",
summary:
"Example Technology Co., Ltd. mentions a 99-day rollout plan for Marketing teams.",
body_markdown:
"Example Technology Co., Ltd. has 8 years of GEO optimization experience.",
image_suggestions: [],
changed_sections: [],
requires_user_confirmation: [],
},
factCard: confirmedFactCard,
platform: "official_site",
sourceImages: [],
});
const hallucinationCheck = report.checks.find(
(check) => check.rule_id === "hallucination_risk",
);
expect(hallucinationCheck?.status).toBe("warn");
expect(report.overall_status).toBe("warn");
});
});
+5 -2
View File
@@ -92,7 +92,7 @@ describe("workflow nodes", () => {
expect(report.checks[0]?.evidence).not.toContain("Article");
});
it("hard-fails incomplete company names, hallucinated numbers, and conflicting years while warning on industry drift", () => {
it("hard-fails incomplete company names and conflicting years while warning on industry drift and hallucination risk", () => {
const report = inspectQuality({
article: {
title: "Example Wins Finance Automation Market!!!",
@@ -112,7 +112,6 @@ describe("workflow nodes", () => {
expect(failures.map((check) => check.rule_id)).toEqual(
expect.arrayContaining([
"company_name_integrity",
"hallucination_risk",
"claim_consistency",
]),
);
@@ -120,6 +119,10 @@ describe("workflow nodes", () => {
(check) => check.rule_id === "industry_alignment",
);
expect(industryCheck?.status).toBe("warn");
const hallucinationCheck = report.checks.find(
(check) => check.rule_id === "hallucination_risk",
);
expect(hallucinationCheck?.status).toBe("warn");
expect(report.overall_status).toBe("fail");
});
+3 -4
View File
@@ -31,7 +31,6 @@ const REQUIRED_RULES: QualityRuleId[] = [
const HARD_FAILURE_RULES = new Set<QualityRuleId>([
"company_name_integrity",
"hallucination_risk",
"claim_consistency",
]);
@@ -213,14 +212,14 @@ function inspectRule(
const unsupportedNumber = findUnsupportedNumbers(combined, factCard).length > 0;
return check(
ruleId,
unsupportedNumber || article.requires_user_confirmation.length > 0 ? "fail" : "pass",
unsupportedNumber || article.requires_user_confirmation.length > 0 ? "warn" : "pass",
unsupportedNumber
? findUnsupportedNumbers(combined, factCard).join(", ")
: "未发现未确认的数字类事实主张。",
unsupportedNumber
? "数字类主张无法追溯到已确认事实卡。"
? "发现需要人工复核的数字类事实主张。"
: "事实主张可以追溯到已确认事实卡。",
"删除未确认主张,或补充到事实卡确认。",
"建议人工复核,必要时删除未确认主张,或补充到事实卡后再确认。",
unsupportedNumber ? "body" : null,
);
}