refactor(persona): single source of truth — derive registry from card (P3) - #32
Merged
Conversation
…ona-card (P3)
index.json identity fields (self/user/language/label/description) were duplicated
in both index.json and each persona-card.json. This removes the dual source:
- index.json is now just an enable-list + default selector ({slug, default?}).
- loadPersonaRegistry derives label/description/self/user/language at runtime from
each persona-card.json via new loadPersonaCard helper — the card is the sole
authoritative source.
- Chose runtime derivation over build-time generation: no generated artifact, no
second copy to keep in sync.
Guards: two new tests — index.json must not carry voice/label/description fields,
and derived values must match the card exactly.
Pre-change audit confirmed index.json and cards were already fully consistent
(zero-risk derivation). npm test 380 passed (+3); verify:skills 25.
…display_name P3 made label derive from persona-card.json display_name; this stale assertion still expected the short '古怪精灵小师妹' instead of the full '古怪精灵小师妹 · 灵犀洞天'. Fixes the CI failure on PR #32. npm test 379 passed; verify:skills 25.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements P3 of
docs/persona-architecture-v2.md— the last structural debt in the persona system: single source of truth for persona identity fields.Before
self / user / language / label / descriptionlived in two places:config/personas/index.json(hand-maintained)config/personas/<slug>/persona-card.jsonvoice/display_name/descriptionDrift risk: edit one, forget the other.
After
index.jsonis now just an enable-list + default selector ({ slug, default? }).loadPersonaRegistryderiveslabel/description/self/user/languageat runtime from eachpersona-card.jsonvia a newloadPersonaCardhelper.Chose runtime derivation over build-time generation — no generated artifact, no second copy of the data, nothing to keep in sync.
Guards (new tests)
index.jsonmust NOT containvoice/label/descriptionfields (prevents re-introducing the dual source).persona-card.jsonexactly.Verification
loadPersonaRegistryis the sole consumer ofindex.json(no other readers).npm test: 380 passed (+3).npm run verify:skills: 25 skills. Rendering: voice macros inject correctly, zero leak.Remaining
P6 (lorebook-style on-demand 秘典 injection) — separate, addresses context-bloat issues #16/#13.