Просмотр исходного кода

fix: harden audit-revise loop quality gates

- Change auto-revise mode from rewrite to spot-fix (rewrite adds 6x more
  AI markers than spot-fix based on real testing)
- Add post-revise AI marker guard: discard revision if analyzeAITells
  detects more issues than the original text
- Set re-audit temperature to 0 for deterministic gating decisions
- Strengthen polish mode prompt: explicit prohibition against adding
  paragraphs, renaming entities, or changing causality
- Add optional temperature override to ContinuityAuditor.auditChapter()
majx_mac 8 месяцев назад
Родитель
Сommit
a91272b63c

+ 2 - 1
packages/core/src/agents/continuity.ts

@@ -171,6 +171,7 @@ export class ContinuityAuditor extends BaseAgent {
     chapterContent: string,
     chapterNumber: number,
     genre?: string,
+    options?: { temperature?: number },
   ): Promise<AuditResult> {
     const [currentState, ledger, hooks, styleGuideRaw, subplotBoard, emotionalArcs, characterMatrix, chapterSummaries, parentCanon] =
       await Promise.all([
@@ -271,7 +272,7 @@ ${chapterContent}`;
       { role: "system" as const, content: systemPrompt },
       { role: "user" as const, content: userPrompt },
     ];
-    const chatOptions = { temperature: 0.3, maxTokens: 4096 };
+    const chatOptions = { temperature: options?.temperature ?? 0.3, maxTokens: 4096 };
 
     // Use web search for fact verification when eraResearch is enabled
     const response = gp.eraResearch

+ 1 - 1
packages/core/src/agents/reviser.ts

@@ -18,7 +18,7 @@ export interface ReviseOutput {
 }
 
 const MODE_DESCRIPTIONS: Record<ReviseMode, string> = {
-  polish: "润色:只改表达、节奏、段落呼吸,不改事实与剧情结论",
+  polish: "润色:只改表达、节奏、段落呼吸,不改事实与剧情结论。禁止:增删段落、改变人名/地名/物品名、增加新情节或新对话、改变因果关系。只允许:替换用词、调整句序、修改标点节奏",
   rewrite: "改写:可改叙述顺序、画面、力度,但保留核心事实与人物动机",
   rework: "重写:可重构场景推进和冲突组织,但不改主设定和大事件结果",
   "anti-detect": `反检测改写:在保持剧情不变的前提下,降低AI生成可检测性。

+ 16 - 5
packages/core/src/pipeline/runner.ts

@@ -475,21 +475,32 @@ export class PipelineRunner {
           output.content,
           chapterNumber,
           auditResult.issues,
-          "rewrite",
+          "spot-fix",
           book.genre,
         );
 
         if (reviseOutput.revisedContent.length > 0) {
-          finalContent = reviseOutput.revisedContent;
-          finalWordCount = reviseOutput.wordCount;
-          revised = true;
+          // Guard: reject revision if AI markers increased
+          const preMarkers = analyzeAITells(output.content);
+          const postMarkers = analyzeAITells(reviseOutput.revisedContent);
+          const preCount = preMarkers.issues.length;
+          const postCount = postMarkers.issues.length;
+
+          if (postCount > preCount) {
+            // Revision made text MORE AI-like — discard it, keep original
+          } else {
+            finalContent = reviseOutput.revisedContent;
+            finalWordCount = reviseOutput.wordCount;
+            revised = true;
+          }
 
-          // Re-audit the revised content
+          // Re-audit the (possibly revised) content
           const reAudit = await auditor.auditChapter(
             bookDir,
             finalContent,
             chapterNumber,
             book.genre,
+            { temperature: 0 },
           );
           const reAITells = analyzeAITells(finalContent);
           const reSensitive = analyzeSensitiveWords(finalContent);