name: chapter_review
description: >
  Independent chapter review. Agent reads the chapter and produces a structured
  critique in their editorial domain with explicit must-fix vs optional categorization.
debug: true
model: power
system: agent_prompt

agent_prompt:
  - system.md

sections:
  - project
  - rag
  - message
  - instructions

steps:
  - type: think
    max_tokens: 4000
    hint: |
      TARGET AUDIENCE: {genre_audience}
      GENRE: {genre_name}
      CHAPTER: {chapter_ref}

      ---
      CHAPTER TEXT:
      {chapter_text}
      ---

      Write a detailed editorial review from your perspective.
      Be specific — cite line numbers or quote passages where relevant.
      Structure your review using EXACTLY these six labeled sections:

        1. STRENGTHS TO PRESERVE
           List elements that are working well and must survive the editorial process unchanged.
           Be specific: quote or paraphrase the passage. Vague praise ("the writing is good")
           is not useful here.
           ALSO CHECK VOICE SIGNATURES:
           CHARACTER VOICE PROFILES:
           {character_profiles}
           If the above block is non-empty: verify each named character in this chapter
           speaks to their profile. Can you identify each character's dialogue without
           speaker tags? Note YES or NO for each main character.
           If the block is empty: check RAG/project context for "## Voice Signatures"
           and note whether voice differentiation is present.

        2. MUST-FIX — CONTINUITY
           List factual errors, POV breaks, timeline inconsistencies, or world-rule violations.
           These are non-negotiable — they cannot be left as "optional." For each item, state:
           - What the error is
           - What the correction should be

        3. MUST-FIX — CLARITY
           List passages where meaning is genuinely obscured, transitions are dropped, or
           threads are left dangling in a way that blocks reader comprehension. For each item:
           - Quote or reference the passage
           - State the concrete fix

        4. OPTIONAL SUGGESTIONS
           Craft improvements that would strengthen the chapter but are NOT required for it to
           pass. Label each suggestion clearly as optional. Do not inflate this section — only
           include suggestions with a clear upside and low risk of voice damage.
           ⚠️ Do NOT suggest adding thematic contrast metaphors, making dialogue more elegant,
           or smoothing sentence variation — these are voice PRESERVATION issues, not fixes.

        5. FORBIDDEN CHANGES / NON-GOALS
           List things that might appear to be problems but should NOT be changed — intentional
           voice choices, genre conventions, structural decisions that are working. This section
           protects the draft from over-editing.
           ALWAYS list here: verbal tics, repeated phrases, and "imperfect" speech that is
           clearly a character signature, not an error.

        6. VERDICT
           One of: PASS / REVISE
           Use PASS if only optional improvements remain.
           Use REVISE if any MUST-FIX items are present.
           Reserve judgment on full rewrites — that decision belongs to the roundtable.

  - type: document
    filename: "Chapter_{chapter_number}_review_{review_letter}"

  - type: close
    rag_update: false

adjudication:
  enabled: true
  pass_threshold: 60
  deliverable_type: editorial_review
  criteria:
    specificity:
      weight: 40
      description: "Review cites specific passages, scenes, or structural elements in all sections — not vague general commentary"
    actionability:
      weight: 35
      description: "Each MUST-FIX item includes a concrete, implementable correction; OPTIONAL items are clearly labeled"
    coverage:
      weight: 25
      description: "All six sections are present; STRENGTHS and FORBIDDEN sections are populated, not left empty"
