feat: Improve revision pipeline quality — 6 targeted enhancements (v3.1)

1. editor.py — Fix rewrite_chapter_content to use model_writer (was model_logic).
   Chapter rewrites now use the creative writing model, not the cheaper analysis model.

2. editor.py — evaluate_chapter_quality now uses keep_head=True so the evaluator
   sees the chapter opening (engagement hook, sensory anchoring) as well as the
   ending; long chapters no longer scored on tail only.

3. editor.py — Consistency analysis sampling upgraded to head+middle+tail (was
   head+tail), giving the LLM a complete view of each chapter's events.

4. writer.py — max_attempts is now adaptive: climax/resolution chapters
   (position >= 0.75) receive 3 refinement attempts; others keep 2.

5. writer.py — Polish-skip threshold tightened from 0.012 to 0.008 (1 filter
   word per 125 words vs. 1 per 83 words), so more borderline drafts are cleaned.

6. style_persona.py — Persona validation sample increased from 200 to 400 words
   for more reliable voice quality assessment.

Version bumped: 3.0 → 3.1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 07:51:31 -05:00
parent dc39930da4
commit d2c65f010a
5 changed files with 35 additions and 11 deletions

View File

@@ -380,7 +380,7 @@ def write_chapter(chap, bp, folder, prev_sum, tracking=None, prev_content=None,
_draft_word_list = current_text.lower().split() if current_text else []
_fw_hit_count = sum(1 for w in _draft_word_list if w in _fw_set)
_fw_density = _fw_hit_count / max(len(_draft_word_list), 1)
_skip_polish = _fw_density < 0.012 # < ~1 filter word per 83 words → draft already clean
_skip_polish = _fw_density < 0.008 # < ~1 filter word per 125 words → draft already clean
if current_text and not _skip_polish:
utils.log("WRITER", f" -> Two-pass polish (Pro model, FW density {_fw_density:.3f})...")
@@ -427,8 +427,12 @@ def write_chapter(chap, bp, folder, prev_sum, tracking=None, prev_content=None,
elif current_text:
utils.log("WRITER", f" -> Draft clean (FW density {_fw_density:.3f}). Skipping polish pass.")
# Reduced from 3 → 2 attempts since polish pass already refines prose before evaluation
max_attempts = 2
# Adaptive attempts: climax/resolution chapters (position >= 0.75) get 3 passes;
# earlier chapters keep 2 (polish pass already refines prose before evaluation).
if chapter_position is not None and chapter_position >= 0.75:
max_attempts = 3
else:
max_attempts = 2
SCORE_AUTO_ACCEPT = 8
# Adaptive passing threshold: lenient for early setup chapters, strict for climax/resolution.
# chapter_position=0.0 → setup (SCORE_PASSING=6.5), chapter_position=1.0 → climax (7.5)