Skip to content

feat: established-name list and a per-chapter new-name budget - #294

Merged
andyhsu6 merged 1 commit into
mainfrom
feat/established-names-and-new-name-budget
Nov 13, 2026
Merged

andyhsu6 merged 1 commit into
mainfrom
feat/established-names-and-new-name-budget

Conversation

@andyhsu6

Copy link
Copy Markdown
Owner

Closes #293.

Problem

A generated chapter invented three place names absent from the preceding 58 chapters. Invented names are not wrong by themselves — the story has to leave the county — but they enter canon through analysis (chapter → facts → world settings → next prompt) and compound.

Balance: three tiers, not a ban

  1. Reuse established names. People, aliases, organisations, and the current outline's own names are injected as a short block near the end of the prompt.
  2. New stage names: allowed, anchored, budgeted. At most 2 per chapter, each carried by an anchor ("three days by water from X", "a branch of Y").
  3. One-off elements stay generic ("a neighbouring town"), because naming invites reuse and re-discovery by later chapters.

Implementation

  • app/services/prompt_names.py builds the block from characters (name/aliases/organisation flag) plus the chapter's outline (characters, scenes, title), with hard caps (12 people, 8 orgs, 8 outline names, 4 scenes, 2 aliases each) so the block stays ~300 characters.
  • Wired into the three chapter generation paths immediately before the writing-spec tail (so style still sits last).
  • Source guard asserts all three call sites; a behavioural test cannot catch a missing injection.

Verification (same chapter, before → after)

before after
invented place names 3 0
established names used partial county, inn, hall, existing cast
avg sentence 27.7 23.8
dialogue ratio 0.33 0.42

Naming stabilised. The style numbers moved in the worse direction on this single sample (the chapter is interrogation-heavy), so I am not tuning style from it — that needs a few samples to separate scene effect from drift.

.venv/bin/python -m pytest tests/test_prompt_names.py tests/test_chapter_output_budget.py -q → 15 passed
.venv/bin/python -m pytest tests/ -q -p no:cacheprovider                              → 1669 passed

Desensitized per repository policy: no source text, titles or character names are included.

A generated chapter invented three place names that never appear in the preceding
58 chapters. Invention is legitimate — the plot must be able to leave the county —
but invented proper nouns enter canon through the analysis pipeline and compound.

Three tiers instead of a ban:
- reuse established names (characters, aliases, organisations, the chapter outline's
  own names) — injected as a short block near the end of the prompt;
- allow at most 2 new proper nouns per chapter, each anchored to a known place or
  organisation;
- one-off places stay generic ("a neighbouring town") because naming invites reuse.

`prompt_names.build_established_names_block` builds it from characters + the
current outline with hard caps so the block stays small. Wired into all three
chapter generation paths right before the writing-spec tail; a source guard keeps
the wiring from being dropped silently.

Verified on the affected chapter: the three invented names are gone and the text
uses only established names.

Refs #293
@andyhsu6 andyhsu6 added the status:in-progress Work started, PR is open label Nov 13, 2026
@andyhsu6
andyhsu6 merged commit e210bf5 into main Nov 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:in-progress Work started, PR is open

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Establish a proper-noun list and a per-chapter new-name budget

1 participant