fix(chapter_production): enforce sequential polished ordering, detect pipeline gaps

This commit is contained in:
2026-04-28 22:31:02 +00:00
parent ec0de51723
commit 4d501c5ad3

View File

@@ -28,30 +28,39 @@ steps:
Review the DELIVERABLES section above.
STEP 1 -- Count completed (polished) chapters:
Look for files matching the pattern: staging/polished/chapter-ch-XX.md
Count how many such files exist (ch-01, ch-02, etc.)
These are the chapters that have been fully written AND polished.
STEP 1 -- Count fully polished chapters (sequential):
Look for files matching: staging/polished/chapter-ch-XX.md
Walk the sequence from ch-01 upward. Count how many consecutive chapters
have a polished file. STOP counting at the first gap -- a missing polished
file breaks the sequence even if later chapters are polished.
Example: ch-01, ch-02, ch-03 exist but ch-04 missing -> sequential polished = 3
even if ch-05 polished file also exists.
STEP 2 -- Count in-progress (drafted) chapters:
Look for any staging files that suggest a chapter has been drafted but not polished.
Examples: review files, roundtable files, or draft files for a given chapter ref.
STEP 2 -- Identify the next chapter needed:
NEXT_CHAPTER = the first chapter in the sequence that does NOT have a polished file.
This is always sequential_polished_count + 1.
Example: ch-01 through ch-05 polished, ch-06 missing -> NEXT_CHAPTER = ch-06
Even if ch-07 is already polished, ch-06 must be completed first.
STEP 3 -- Determine next chapter:
The next chapter to write is the first chapter that has NO draft files at all.
- If polished: ch-01 through ch-04 and draft evidence for ch-05: next is ch-06
- If polished: ch-01 and draft evidence for ch-02: next is ch-03
- If nothing exists for any chapter: next is ch-01
STEP 3 -- Check if NEXT_CHAPTER is already in the pipeline:
Look in DELIVERABLES for any staging evidence for NEXT_CHAPTER:
- A draft file (e.g. Chapter_6_draft.md or Chapter_06_draft.md)
- Any review files (e.g. Chapter_6_review_a.md)
If staging evidence exists for NEXT_CHAPTER: it is ALREADY_IN_PIPELINE.
If no staging evidence at all: it is NEEDS_DRAFT.
Also check the BOOK OUTLINE if available above for chapter titles and total count.
If all chapters exist in some form up to the outline limit: the book is DONE.
STEP 4 -- Determine STATUS:
Check the BOOK OUTLINE for total chapter count (TOTAL_CHAPTERS).
If sequential_polished_count >= TOTAL_CHAPTERS: STATUS = COMPLETE
Otherwise: STATUS = NEEDS_CHAPTER
Output:
STATUS: NEEDS_CHAPTER or COMPLETE
NEXT_CHAPTER: ch-01 (or ch-02, etc., or N/A if COMPLETE)
CHAPTER_TITLE: <from outline if available, otherwise "Chapter N">
POLISHED_COUNT: <number of staging/polished/chapter-ch-*.md files found>
DRAFTED_COUNT: <number of chapters with any staging evidence>
NEXT_CHAPTER: ch-06 (or whichever, or N/A if COMPLETE)
CHAPTER_TITLE: <from outline if available>
SEQUENTIAL_POLISHED: <count of consecutive polished chapters from ch-01>
ALREADY_IN_PIPELINE: yes or no
PIPELINE_STAGE: draft-only / has-reviews / has-polish / none
- type: think
max_tokens: 100
@@ -70,8 +79,15 @@ steps:
If STATUS is COMPLETE: output exactly: none
If STATUS is NEEDS_CHAPTER, write a chapter dispatch message for Iris (lead author).
Include:
If STATUS is NEEDS_CHAPTER:
- If ALREADY_IN_PIPELINE is "yes": the chapter has a draft but is not polished.
Write a dispatch message instructing the author to pick up from the existing draft,
run the roundtable and polish sequence, and NOT re-draft from scratch.
Include: "Note: a draft already exists for this chapter in staging -- proceed directly
to chapter_roundtable using the existing draft. Do not re-write the draft."
- If ALREADY_IN_PIPELINE is "no": write a normal chapter dispatch message.
Always include:
- Book: {project.name} ({genre_name})
- Chapter to write: the NEXT_CHAPTER value from the decision
- Chapter title: the CHAPTER_TITLE value