name: chapter_review
description: >
  Independent chapter review. Agent reads the chapter and produces a structured
  critique with mandatory verbatim prose quotes, score-anchored verdict, and
  explicit character voice violation checks.
debug: true
rag_exclude: [business_plan, charter]
model: power
system: agent_prompt

agent_prompt:
  - system.md

sections:
  - project
  - rag
  - message
  - instructions

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

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

      Write a detailed editorial review. You MUST quote the actual text to support every
      claim you make. Vague commentary ("the pacing drags") without a quoted passage is
      not acceptable and will cause this review to fail adjudication.

      Structure your review using EXACTLY these seven labeled sections:

        1. PROSE EVIDENCE
           Quote 3-5 passages verbatim from this chapter (use quotation marks and indicate
           approximate position: "early", "mid", "late").
           For each quote, give one sentence of inline commentary: what it does well or
           what it fails to do. This section is MANDATORY -- do not summarize or paraphrase.
           A review with zero verbatim quotes will automatically score below 70.

        2. CHARACTER VOICE AUDIT
           {character_profiles}
           If the above block is non-empty: for EACH named character who speaks in this
           chapter, check their voice against their profile. Quote one line of their
           dialogue and state YES or NO for each constraint:
             - Does the character use their signature vocabulary / verbal tics?
             - Do they avoid any explicitly forbidden speech patterns?
             - Is their emotional register consistent with their arc position?
           If a violation is found, quote the offending line and state exactly what rule
           is broken (e.g. "Dorian uses contraction 'don't' -- profile forbids contractions
           unless in extreme pain or physical exhaustion. This scene does not qualify.").
           If the block is empty: check RAG context for "## Voice Signatures" and report
           what you find.

        3. STRENGTHS TO PRESERVE
           List 2-4 elements working well that must survive the editorial process unchanged.
           Each item must include a verbatim quote or specific scene reference.
           Generic praise ("the atmosphere is strong") without evidence is not allowed here.

        4. MUST-FIX -- CONTINUITY
           List factual errors, POV breaks, timeline inconsistencies, or world-rule violations.
           These are non-negotiable. For each item state:
           - ORIGINAL: quote the offending passage verbatim
           - PROBLEM: what rule or established fact it violates
           - FIX: the concrete correction (rewrite the sentence if necessary)

        5. 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:
           - ORIGINAL: quote the offending passage verbatim
           - PROBLEM: why it blocks comprehension
           - FIX: the concrete correction

        6. OPTIONAL SUGGESTIONS
           Craft improvements that would strengthen the chapter but are NOT required for it to
           pass. Label each suggestion clearly as optional. Include the relevant quote.
           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.

        7. 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.
           ALWAYS include: verbal tics, repeated phrases, and "imperfect" speech that is
           clearly a character signature, not an error.

        8. VERDICT
           One of: PASS / REVISE
           SCORE ANCHORS -- be honest, scores that cluster at 90-96 without strong evidence
           signal a rubber-stamp review and will be rejected by the adjudicator:
             95-100: Zero MUST-FIX items. PROSE EVIDENCE quotes show above-average craft.
                     Voice audit finds no violations.
             85-94:  1-2 minor MUST-FIX items. At least one PROSE EVIDENCE quote shows
                     a clear weakness with explanation.
             70-84:  Clear structural or voice problems. Every MUST-FIX item is quoted
                     verbatim with a rewrite suggestion.
             Below 70: Multiple serious violations. Every failing passage is quoted and
                        corrected. Automatic REVISE verdict.

           State your score and a one-sentence justification citing your evidence.
           Use PASS if only optional improvements remain.
           Use REVISE if any MUST-FIX items are present.

  - 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:
    prose_evidence:
      weight: 35
      description: "Review contains 3+ verbatim quoted passages with inline commentary. Zero quotes = automatic fail. Paraphrases do not count as quotes."
    specificity:
      weight: 30
      description: "Every MUST-FIX item includes the original passage quoted verbatim AND a concrete rewrite or correction. Generic commentary without quotes scores zero here."
    voice_audit:
      weight: 20
      description: "CHARACTER VOICE AUDIT section checks each speaking character against their profile constraints. Each violation is quoted and the broken rule named explicitly."
    coverage:
      weight: 15
      description: "All eight sections present and populated. STRENGTHS section includes evidence. FORBIDDEN section is not left empty."

