Give the adventure a persona, so the protagonist has a name

The player had stats but no identity. `stat_schema.player` carried hp and
mana beside `npc.gwen.trust`, but where an NPC has a name and a
description the player had neither, so the block rendered as
`You: hp 100/100` and nothing in the prompt said who "you" was.

Three columns on `adventures`: name, pronouns, description. All
user-only, all optional, and an empty name means the app behaves exactly
as it did before — no backfill, no special case for an adventure that
predates the migration.

They are adventure columns rather than part of `stat_schema` for two
reasons. An adventure with no RPG layer still has a protagonist, and
that is the case this was added for. And `worldstate.schema._initials`
treats every dict inside a stat section as a stat definition, so a
persona placed there would be instantiated, rendered in the guide, and
handed an `initial` value as though it were one.

The paths do not change. `player.hp` stays `player.hp`; only the label
moves, to `Kaelen (player): hp 100/100`, the same way NPC lines already
print a display name beside the id. A path carrying the persona's name
would break the moment a player renamed their character, because
`_history_text` replays every past turn's stored delta into the prompt
and those blobs hold literal `player.hp` strings.

The section sits in the system block. Only the user can edit it, so it
never changes mid-story and stays inside the cached prefix. That is what
makes it free, and it is why the AI must not be able to move it — a
delta aimed at `persona.*` is already refused by `_resolve`, and there
is now a test holding that in place.

The modal that used to appear only for scenarios with `${Placeholder}`
tokens now always opens, and is where the character is named. Persona
and placeholders stay independent: a scenario asking for `${Name}` is
asking its own question. No scenario in the repo uses placeholders at
all, so the overlap is hypothetical.

Phase 2, which feeds the persona and the cast to the summarizer, is
written up in plan/18 and not started. That is where the memory-quality
problem actually gets fixed; this change is what gives it a name to use.

Not yet driven in a browser — plan/18 lists what to check by hand.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPyQN926gkZTAYfgugcaok
This commit is contained in:
Claude
2026-08-31 15:03:20 +05:30
committed by Parth
parent 9faf788bd5
commit 9ee052c51e
21 changed files with 1076 additions and 39 deletions
+13 -6
View File
@@ -4,7 +4,7 @@ import { api } from '../api'
import {
CardSkeleton,
extractPlaceholders,
PlaceholderModal,
BeginAdventureModal,
ScenarioArt,
useToast,
} from '../components'
@@ -61,9 +61,15 @@ export default function Home() {
const ongoing = useMemo(() => (adventures || []).slice(0, CONTINUE_LIMIT), [adventures])
const featured = useMemo(() => (scenarios || []).slice(0, SCENARIO_LIMIT), [scenarios])
const begin = async (scenarioId, placeholders = {}) => {
const begin = async (scenarioId, { persona = {}, placeholders = {} } = {}) => {
try {
const adv = await api.createAdventure({ scenario_id: scenarioId, placeholders })
const adv = await api.createAdventure({
scenario_id: scenarioId,
placeholders,
persona_name: persona.name || '',
persona_pronouns: persona.pronouns || '',
persona_desc: persona.desc || '',
})
navigate(`/play/${adv.id}`)
} catch (err) {
toast(err.message, 'error')
@@ -78,7 +84,8 @@ export default function Home() {
scenario.prompt, scenario.memory, scenario.authors_note, scenario.ai_instructions,
...scenario.story_cards.flatMap((c) => [c.keys, c.entry]),
)
if (names.length === 0) return begin(scenarioId)
// Always open the modal, even with no placeholders: it is where the
// player names their character.
setPending({ scenario, names })
} catch (err) {
toast(err.message, 'error')
@@ -218,11 +225,11 @@ export default function Home() {
</section>
{pending && (
<PlaceholderModal
<BeginAdventureModal
title={pending.scenario.title}
names={pending.names}
onCancel={() => setPending(null)}
onSubmit={(values) => { setPending(null); begin(pending.scenario.id, values) }}
onSubmit={(answers) => { setPending(null); begin(pending.scenario.id, answers) }}
/>
)}
</div>