Commit graph

2 commits

Author SHA1 Message Date
d6cb0b6df8 context: split coverage into prose_coverage + chapter_coverage
The old parent_coverage was raw-prose / parent-words — a signal of
'how much actual prose opus is reading.' But the more actionable
signal is 'is every chapter represented somehow' which sits at 1.0
for any parent with summaries (or placeholders) for older chapters.

Add chapter_coverage = 1.0 when every chapter has either a summary
or full-recent-prose row in the context. Keep prose_coverage as
the precise raw-words metric for ops that care about token budget.

Deprecate parent_coverage with a one-release shim (renames to
prose_coverage).

show_context CLI prints both percentages.
2026-05-13 11:18:31 -07:00
5b418369c0 context: assemble DB→opus blob + skald show-context CLI
skald-core::context is the bridge between 'rows in postgres' and
'prompt-ready markdown blob.' ContinuationContext::assemble(pool,
parent_story_id, recent_n) pulls:

  - parent story meta (title, series, total word count)
  - characters split real / fictional
  - canon_facts grouped by category
  - chapter summaries for everything older than the recent window
  - FULL prose for the last recent_n chapters

render_markdown() formats it with the most-condensed data first
(characters, canon) and the richest detail last (recent chapter
prose). Opus reads it linearly so by the time it's writing the new
chapter, the previous chapter's prose is freshest in its context
window.

The 'continuation reads ≥85% of parent' rule lands here via
parent_coverage() which counts recent prose + summaries-as-proxy
(250 words / summary) against parent word_count. The web UI / CLI
can warn before firing a gen pass if coverage is below threshold.

New CLI subcommand:

  skald show-context --story <uuid> --recent <N>

Assembles + prints the blob to stdout (eprintln'd stats summary
goes to stderr). No LLM call — pre-flight inspection so we see
what would be sent before paying for it. Useful for prompt-eng
work in the next session.

Module structure now:

  skald-core/
    config.rs     ForgeConfig
    context.rs    ContinuationContext (new)
    db.rs         connect_and_migrate
    forge.rs      Forge — three-pass orchestration
    ingest.rs     markdown parser
    models.rs     row types
    lib.rs        MIGRATOR + module exports

  skald/
    main.rs       clap CLI
    serve.rs      axum + /health + migrations
    import.rs     skald import-markdown
    show_context.rs  skald show-context  (new)
2026-05-13 10:30:16 -07:00