M5: genre-neutral authoritative narrative state, with review corrections
Replaces AI-DnD's RPG relative-delta world state with the genre-neutral typed
narrative state of ADR 010: explicit, absolute, allowlisted events proposed by
the model, validated by the application, applied to one authoritative document,
and snapshotted per position so restore stays a row read.
This commit includes the corrective pass that followed the independent review
in planning/reports/M5-IMPLEMENTATION-REPORT.md. The invariant it exists to
hold is:
visible active transcript position == stored head == authoritative state
Narrator editing (D10, STORY-BRANCH-SEMANTICS §§14-15)
A narrator edit no longer rewrites a row. It returns to the state before the
turn, takes the reader's exact text as the accepted narration, re-derives the
state that text implies, and becomes a new active continuation — while the
original narration keeps its words, its live flag and its whole future as
retained history. At the tip the correction is another take; with story below
it, it forks. No new history machinery: this is the existing fork/take/head
path with the reader's text in place of a generated reply. The §14A refusal
is therefore gone for narrator turns, and remains only for player input.
Pre-M5 positions
Migration 88 backfills the empty narrative document onto every action written
before M5, and a missing snapshot now restores the empty document instead of
leaving the previous position's state standing. Restoring to an old Save
Point no longer leaves a later position's entities and facts on screen.
Narrator context
Replayed history carries prose only; the machine-readable block is no longer
reconstructed into past turns, where it contradicted the authoritative state
in the same prompt. A fact withdrawn by a manual correction is now named as
no longer true, with the reader's reason, rather than silently dropped.
Also
- state_changes joins the action-list bulk read, removing one query per row.
- Extraction takes only the application's own protocol payload: an ordinary
```json or ```python block in a story survives, and a mangled proposal
still does not reach the reader.
Planning: ADR 013 records the authoritative document shape; §§14-15/14A, D10,
C04 and BUILD-MILESTONES are updated to describe what exists. Debt is recorded
against M8 (scenario editor UX) and M9 (export of the audit trail).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWU4gTfLYY6Qq9U7aa9Qw2
This commit is contained in:
co-authored by
Claude Opus 5
parent
62a997f364
commit
b7005e6fdd
@@ -165,11 +165,18 @@ def test_persona_does_not_move_between_turns(story):
|
||||
changed with the world state would re-price the whole history."""
|
||||
db, adventure, settings = story
|
||||
before, _, _ = builder.build_context(adventure, settings)
|
||||
adventure.world_state = {**adventure.world_state, "player": {"hp": 40}}
|
||||
# Move the live state. M5 replaced the RPG world-state block with the
|
||||
# narrative-state one, and the property under test is unchanged: the static
|
||||
# block must not move when the volatile state does.
|
||||
adventure.narrative_state = {
|
||||
"version": 1, "entities": {}, "possessions": {}, "threads": {},
|
||||
"relationships": [], "scene": {},
|
||||
"facts": [{"id": "f1", "predicate": "the lantern is lit", "status": "active"}],
|
||||
}
|
||||
db.commit()
|
||||
after, story_text, _ = builder.build_context(adventure, settings)
|
||||
assert before == after
|
||||
assert "Kaelen (player): hp 40/100" in story_text
|
||||
assert before == after, "the static block moved when the state did"
|
||||
assert "the lantern is lit" in story_text, "the new state did not reach the model"
|
||||
|
||||
|
||||
def test_persona_sits_above_the_plot_essentials(story):
|
||||
@@ -188,7 +195,9 @@ def test_no_persona_section_when_the_fields_are_blank(story):
|
||||
system_text, story_text, report = builder.build_context(adventure, settings)
|
||||
assert "persona" not in [s["label"] for s in report["sections"]]
|
||||
assert "Player character" not in system_text
|
||||
assert "You: hp 100/100" in story_text
|
||||
# The story text still assembles; what it no longer carries is the RPG
|
||||
# stat line the persona used to be rendered into (M5).
|
||||
assert story_text
|
||||
|
||||
|
||||
def test_persona_is_charged_to_the_token_budget(story):
|
||||
|
||||
Reference in New Issue
Block a user