skald/skald-core
Kayos aece970b50 forge: skald owns chapter numbers, not the LLM
Caught on the 2026-05-13 Coast-Down 10-chapter Orson run: the LLM
labeled two chapters 'Chapter 1' instead of 9 and 10, and
ON CONFLICT (story_id, n) DO UPDATE silently overwrote them.
8 visible chapters from 10 successful gen+cleanup passes; 27k
words of work, ~6k buried. The audit caught the symptom but the
data damage was already done.

Fix:
- continue_story::run computes next_n from MAX(chapters.n) before
  the batch loop; each iteration's authoritative n is next_n,
  incremented after success.
- forge::generate + cleanup take chapter_n: Option<i32>. The gen
  prompt is now 'Write Chapter N. Begin with: ## Chapter N — ...'
  instead of the vague 'Write the next chapter.'
- We still parse_chapter() the LLM output but only to extract the
  title; if the LLM-returned n disagrees with ours, we log a warn
  and use the authoritative N at INSERT time.

The (story_id, n) unique constraint stays — it's now a defensive
catch for skald bugs, not the LLM's free-spirited numbering.
2026-05-13 18:29:22 -07:00
..
src forge: skald owns chapter numbers, not the LLM 2026-05-13 18:29:22 -07:00
Cargo.toml narrate: F5-TTS HTTP client + skald narrate CLI 2026-05-13 16:45:04 -07:00