Selaa lähdekoodia

fix(v13): planner mustAvoid reads authoritative rules-reader [phase hotfix 5]

PlannerAgent.planChapter() called parseBookRules() on
seedMaterials.bookRulesRaw, which is the verbatim contents of
story/book_rules.md. For Phase 5 new-layout books that file is the compat
shim — parseBookRules previously parsed it as default-empty rules, silently
dropping prohibitions / protagonist / genreLock from intent.mustAvoid. The
authoritative loader (rules-reader.readBookRules) prefers
outline/story_frame.md frontmatter, falls back to legacy book_rules.md, and
now refuses shim files outright (Phase hotfix 1).

Fix:
- Replace parseBookRules(seedMaterials.bookRulesRaw) with
  readAuthoritativeBookRules(input.bookDir) in planner.ts.
- Drop the parseBookRules import.

planner-context.readBookRules (used to render the rules block into the
prompt) already routes through the authoritative loader, so this commit
only fixes the structured-fields path.
Ma 6 kuukautta sitten
vanhempi
commit
52eef97ebd
1 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 7 2
      packages/core/src/agents/planner.ts

+ 7 - 2
packages/core/src/agents/planner.ts

@@ -2,7 +2,7 @@ import { readFile, writeFile, mkdir } from "node:fs/promises";
 import { join } from "node:path";
 import { BaseAgent } from "./base.js";
 import type { BookConfig } from "../models/book.js";
-import { parseBookRules } from "../models/book-rules.js";
+import { readBookRules as readAuthoritativeBookRules } from "./rules-reader.js";
 import {
   ChapterIntentSchema,
   type ChapterIntent,
@@ -88,7 +88,12 @@ export class PlannerAgent extends BaseAgent {
       outlineNode,
       input.chapterNumber,
     );
-    const parsedRules = parseBookRules(seedMaterials.bookRulesRaw);
+    // Phase hotfix 5: read structured rules through the Phase 5 authoritative
+    // loader. It prefers outline/story_frame.md frontmatter, falls back to
+    // legacy book_rules.md, and refuses to silently zero out rules when the
+    // legacy file is just a compat shim. Reading raw bookRulesRaw via
+    // parseBookRules() bypassed all of that.
+    const parsedRules = await readAuthoritativeBookRules(input.bookDir);
     const prohibitions = parsedRules?.rules.prohibitions ?? [];
     const mustKeep = this.collectMustKeep(seedMaterials.currentState, seedMaterials.storyBible);
     const mustAvoid = this.collectMustAvoid(seedMaterials.currentFocus, prohibitions);