Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: generation-side character framework + structure doctrine (#2175)

Adam Eivy3aa0289cd0bc
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index fc2584bbe0..f6f813ffcd 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -119,3 +119,5 @@
- **`getSettings()` now serves from an in-memory cache instead of re-reading settings.json on every call.** `getSettings()` is invoked 100+ times across the codebase (several per request), each previously doing a fresh filesystem read + JSON.parse of app-wide, rarely-changing data. It now memoizes the parsed settings, populated lazily on first read and refreshed off the `settings:updated` event that every `save()`/`updateSettings()`/`updateSettingsWith()` already emits — so app-driven writes keep the cache coherent while write paths still read fresh off disk inside their write queue for the read-merge-write, preserving write-ordering guarantees. Mirrors the existing `settings:updated`-invalidated cache in `sharing/annotationIdentity.js`. Alongside it, a few independent per-file read loops are now parallelized (`digital-twin-analysis.validateCompleteness`, editorial series-health's series+settings load) and hot page derivations memoized (`Review` grouping/sorting, `Tribe` care-queue), cutting redundant work on socket-driven re-renders.
- **Branch & PR reconciliation now runs on any managed app as a Chief-of-Staff scheduled task — not just PortOS.** The branch reconciler (finish this machine's unfinished local git work: delete fully-merged orphaned branches + their worktrees, open PRs for pushed-but-unopened work, resolve merge conflicts, drive the review loop, and auto-merge when a PR is green) used to be a PortOS-only feature with its own daily cron, `/api/branch-reconcile` route, `settings.branchReconcile` toggle, and a dedicated Settings tab — hardwired to the PortOS checkout. It is now a first-class per-app CoS task type, **`branch-reconcile`**, configured like every other improvement task (per-app enable, provider/model, cadence, cooldown, budget) under Chief of Staff → task scheduling. It runs `perpetual` (drain-until-done): each dispatch runs the deterministic, peer-safe cleanup + classification against the *app's* repo, dispatches the coordinator agent only while actionable in-flight branches remain, then parks on a daily recheck — so no agent is burned on a no-op run. A progress-signature convergence guard ensures the drain only re-dispatches when the actionable set actually *changed* since the last run (a branch advanced NEEDS_PR→IN_REVIEW→merged, or a new/removed branch): a cycle that leaves the same branches in the same states (a branch judged "not ready", a PR blocked on human review or red CI) parks instead of re-spawning an identical coordinator back-to-back. The peer-safety guarantee is unchanged (only local `refs/heads/` are ever touched; a federated peer's branch exists here only as a remote-tracking ref and is structurally invisible), and the per-behavior toggles (`cleanupMerged` / `openPr` / `resolveConflicts` / `autoMerge`) are now per-app task-metadata overrides. Off by default; enabling it on an app is the user's explicit consent to let it drive PRs on a schedule. The old dedicated scheduler, route, settings key, and Settings tab are removed; a migration (`scripts/migrations/170-branch-reconcile-to-cos-task.js`) carries a previously-enabled `branchReconcile` opt-in into the new task (cron→recheckCron, actions→per-app metadata) scoped to the PortOS app, and drops the dead settings key — so an install that had it on keeps reconciling instead of silently stopping. (`server/services/branchReconcile.js`, `server/services/cosTaskGenerator.js`, `server/services/taskSchedule.js`, `server/services/taskPromptDefaults/prompts.js`)
+
+- **[issue-2175] Generation-side character framework + structure doctrine (CWQE Phase 10 remainder).** Following the worldbuilding-doctrine slice (#2219), the character-generation and structure-planning prompts now teach the craft up front. The character bible gains the Ghost → Wound → Lie → Want → Need chain (with interlock checks: state the Lie in one sentence; the Need/Truth is its direct opposite; the Ghost causally explains the Lie), a declared arc type (positive/negative/flat), the Three Sliders (proactivity/likability/competence 1–10, rule: HIGH on ≥2 or one-with-growth; all-low = boring, all-high = Mary Sue), and a secrets list — all OPTIONAL so pre-#2175 records round-trip unchanged (`server/lib/storyBible.js` sanitizer + Zod-shape parity via the existing `canonArrayField` sanitize-on-write, client mirror in `client/src/lib/bibleLimits.js`, character-sheet UI in `CharacterDetailEditor.jsx` with `htmlFor`/`id` pairing, and no-clobber merge in `universeCharacterExpand.js` for the AI-expand path). The `character.consistency` / `arc.*` editorial checks now receive the authored Lie/Want/Need/arc-type when present (via `canonCharacterTraitsSummary`) so they reconcile plan-vs-delivery instead of inferring both. Structure prompts gain lean doctrine: `pipeline-season-episodes.md` a try-fail mandate (60%+ of middle episodes end "Yes, but"/"No, and"), beat rules (Catalyst external; Break Into Two a protagonist choice; All Is Lost includes a death — literal or of a hope/relationship/identity) and an active-climax rule; `pipeline-arc-overview.md` MICE-style thread nesting (threads close in reverse order of opening; name the opening/closing thread per season). Shipped-template edits ship to existing installs via hash-keyed migrations 171/172/173 (with the drift-cross-sync of prior owners 003/005/019/027/166). Remaining Phase 10 items (Le Guin style doctrine into the style-guide flow) stay tracked on #2175.
diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsx
index 11c88fe3ef..2254b23914 100644
--- a/client/src/components/universe/CharacterDetailEditor.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.jsx
@@ -14,6 +14,7 @@ import { useState } from 'react';
import {
ChevronDown, ChevronRight, Plus, Trash2, WandSparkles, Loader2,
Palette, Hand, Smile, Package, BookOpen, Eye, Activity, Users, Swords,
+ Drama, KeyRound,
} from 'lucide-react';
import { BIBLE_LIMITS as L } from '../../lib/bibleLimits';
import useFieldDraft from '../../hooks/useFieldDraft';
@@ -44,6 +45,16 @@ const SECTIONS = Object.freeze([
{ name: 'skills', label: 'Skills', placeholder: 'concrete abilities, soft and hard', max: L.SKILLS_MAX, type: 'textarea' },
],
},
+ {
+ key: 'framework', label: 'Character framework', icon: Drama,
+ fields: [
+ { name: 'ghost', label: 'Ghost (backstory wound cause)', placeholder: 'the past event that wounded them — must causally explain the Lie', max: L.GHOST_MAX, type: 'textarea' },
+ { name: 'wound', label: 'Wound', placeholder: 'the lasting emotional damage the Ghost left', max: L.WOUND_MAX, type: 'textarea' },
+ { name: 'lie', label: 'Lie (false belief)', placeholder: 'state in one sentence — "I only matter if I win"', max: L.LIE_MAX, type: 'textarea' },
+ { name: 'need', label: 'Need (Truth — opposite of the Lie)', placeholder: 'the direct opposite of the Lie — "I matter whether I win or lose"', max: L.NEED_MAX, type: 'textarea' },
+ { name: 'want', label: 'Want (external goal)', placeholder: 'the concrete goal they pursue — usually conflicts with the Need', max: L.WANT_MAX, type: 'textarea' },
+ ],
+ },
{
key: 'visualIdentity', label: 'Visual identity', icon: Eye,
fields: [
@@ -66,6 +77,12 @@ const RELATIONSHIP_OPPOSITION_AXES = Object.freeze([
'winner/loser', 'smart/dumb', 'hunter/prey', 'predator/prey', 'custom',
]);
+// Mirrors `CHARACTER_ARC_TYPES` in server/lib/storyBible.js (#2175). The server
+// sanitizer coerces an unrecognized value to null, so an empty selection clears
+// the field. `''` = unset.
+const CHARACTER_ARC_TYPES = Object.freeze(['positive', 'negative', 'flat']);
+const SLIDER_AXES = Object.freeze(['proactivity', 'likability', 'competence']);
+
const LIST_SECTIONS = Object.freeze([
{
key: 'stats', label: 'Stats', icon: Activity, field: 'stats',
@@ -106,6 +123,19 @@ const LIST_SECTIONS = Object.freeze([
],
summary: (e) => `${e.name}${e.description ? ` — ${e.description}` : ''}`,
},
+ {
+ key: 'secrets', label: 'Secrets', icon: KeyRound, field: 'secrets',
+ addLabel: 'Add secret', singular: 'secret',
+ // `secrets` is a plain string[] on the server (cleanStringArray). The
+ // generic ListRow works on row objects keyed by column name, so this
+ // section stores each secret as `{ text }` and marshals to/from string[]
+ // via `toRows` / `fromRows` below (see ListSectionEditor).
+ stringList: true,
+ columns: [
+ { name: 'text', placeholder: 'something they hide from others or themselves', max: L.SECRET_MAX },
+ ],
+ summary: (s) => s.text,
+ },
{
key: 'handGestures', label: 'Hand gestures', icon: Hand, field: 'handGestures',
addLabel: 'Add gesture', singular: 'gesture',
@@ -212,14 +242,28 @@ function CollapsibleSection({ icon: Icon, label, summary, defaultOpen = false, c
// `<kind>-<uuid>` under its own convention — see usePendingListRows.js for
// the trade-off this strip implies for sibling drafts.
function ListSectionEditor({ section, entry, onPatchList, disabled }) {
- const persisted = Array.isArray(entry[section.field]) ? entry[section.field] : [];
+ const rawPersisted = Array.isArray(entry[section.field]) ? entry[section.field] : [];
+ // A `stringList` section (e.g. `secrets`) persists a plain string[] on the
+ // server, but the generic row editor works on objects keyed by the single
+ // column name. Marshal string → { [col]: string } on the way in and back to
+ // string on the way out so the section stays server-shape-correct.
+ const col0 = section.columns[0].name;
+ const persisted = section.stringList
+ ? rawPersisted.map((s) => ({ [col0]: typeof s === 'string' ? s : '' }))
+ : rawPersisted;
+ const emit = (next) => onPatchList(
+ section.field,
+ section.stringList
+ ? next.map((r) => (r?.[col0] || '').trim()).filter(Boolean)
+ : next,
+ );
const { merged, addRow, updateRow, removeRow } = usePendingListRows({
persisted,
- requiredColumn: section.columns[0].name,
+ requiredColumn: col0,
idPrefix: `pending-${section.key}-`,
stripIdOnPromote: true,
blankRow: () => Object.fromEntries(section.columns.map((c) => [c.name, ''])),
- onChange: (next) => onPatchList(section.field, next),
+ onChange: emit,
});
const summary = merged.length === 0
? 'empty'
@@ -456,6 +500,82 @@ function RelationshipsSection({ entry, characters, onPatch, disabled }) {
);
}
+// Declared arc type + Three Sliders (CWQE Phase 10, #2175). Arc type is a plain
+// enum <select> ('' clears); each slider is an integer 1–10 range input with an
+// explicit "unset" state (null) so an un-rated axis stays absent rather than
+// snapping to a default. Patches commit immediately (no draft buffer needed —
+// these are discrete controls, not free text). `idPrefix` scopes the field ids
+// so two open cards don't collide.
+function ArcFrameworkControls({ entry, onPatch, disabled, idPrefix }) {
+ const sliders = (entry.sliders && typeof entry.sliders === 'object') ? entry.sliders : {};
+ const arcId = `chr-arc-${idPrefix || 'unknown'}`;
+ const patchSlider = (axis, value) => onPatch?.({ sliders: { ...sliders, [axis]: value } });
+ const setCount = SLIDER_AXES.reduce((n, a) => n + (typeof entry[a] === 'string' ? 0 : (sliders[a] != null ? 1 : 0)), 0);
+ const summary = `${entry.arcType || 'no arc'}${setCount ? ` · ${setCount}/3 sliders` : ''}`;
+ return (
+ <CollapsibleSection icon={Drama} label="Arc type & sliders" summary={summary}>
+ <div className="space-y-0.5">
+ <label htmlFor={arcId} className="block text-[10px] uppercase tracking-wider text-gray-500">
+ Arc type
+ </label>
+ <select
+ id={arcId}
+ value={entry.arcType || ''}
+ onChange={(e) => onPatch?.({ arcType: e.target.value })}
+ disabled={disabled}
+ className="w-full px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-white disabled:opacity-50"
+ >
+ <option value="">— unset —</option>
+ {CHARACTER_ARC_TYPES.map((t) => <option key={t} value={t}>{t}</option>)}
+ </select>
+ </div>
+ <p className="text-[10px] text-gray-500 leading-snug">
+ Rule: HIGH (≥7) on at least two sliders, or high on one with room to grow. All-low = boring; all-high = Mary Sue.
+ </p>
+ {SLIDER_AXES.map((axis) => {
+ const id = `chr-slider-${idPrefix || 'unknown'}-${axis}`;
+ const val = sliders[axis];
+ const set = val != null;
+ return (
+ <div key={axis} className="space-y-0.5">
+ <div className="flex items-center justify-between">
+ <label htmlFor={id} className="text-[10px] uppercase tracking-wider text-gray-500 capitalize">
+ {axis}
+ </label>
+ <div className="flex items-center gap-1.5">
+ <span className="text-[10px] text-gray-400 tabular-nums w-6 text-right">{set ? val : '—'}</span>
+ {set ? (
+ <button
+ type="button"
+ onClick={() => patchSlider(axis, null)}
+ disabled={disabled}
+ title={`Clear ${axis}`}
+ className="text-gray-500 hover:text-port-error disabled:opacity-30"
+ >
+ <Trash2 size={11} />
+ </button>
+ ) : null}
+ </div>
+ </div>
+ <input
+ id={id}
+ type="range"
+ min={L.SLIDER_MIN}
+ max={L.SLIDER_MAX}
+ step={1}
+ value={set ? val : L.SLIDER_MIN}
+ onChange={(e) => patchSlider(axis, Number(e.target.value))}
+ disabled={disabled}
+ className="w-full disabled:opacity-50"
+ aria-label={`${axis} rating 1 to 10`}
+ />
+ </div>
+ );
+ })}
+ </CollapsibleSection>
+ );
+}
+
export default function CharacterDetailEditor({ entry, onPatch, onExpand, expanding = false, disabled = false, characters = [] }) {
if (!entry) return null;
@@ -512,6 +632,13 @@ export default function CharacterDetailEditor({ entry, onPatch, onExpand, expand
</CollapsibleSection>
))}
+ <ArcFrameworkControls
+ entry={entry}
+ onPatch={onPatch}
+ disabled={disabled}
+ idPrefix={entry.id}
+ />
+
<RelationshipsSection
entry={entry}
characters={characters}
diff --git a/client/src/components/universe/CharacterDetailEditor.test.jsx b/client/src/components/universe/CharacterDetailEditor.test.jsx
index 2c5a97cc16..7ea80691d1 100644
--- a/client/src/components/universe/CharacterDetailEditor.test.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.test.jsx
@@ -112,3 +112,54 @@ describe('CharacterDetailEditor — Relationships (#1287)', () => {
expect(screen.getByText(/2 links · 1 opposing/i)).toBeInTheDocument();
});
});
+
+describe('CharacterDetailEditor — character framework (#2175)', () => {
+ const openArc = () => fireEvent.click(screen.getByRole('button', { name: /Arc type & sliders/i }));
+
+ it('renders the arc-type select seeded from the entry and patches on change', () => {
+ const onPatch = vi.fn();
+ render(<CharacterDetailEditor entry={{ ...ARIA, arcType: 'positive' }} characters={[ARIA]} onPatch={onPatch} />);
+ openArc();
+ const select = screen.getByLabelText(/Arc type/i);
+ expect(select).toHaveValue('positive');
+ fireEvent.change(select, { target: { value: 'negative' } });
+ expect(onPatch).toHaveBeenCalledWith({ arcType: 'negative' });
+ });
+
+ it('patches a slider value, merging with existing sliders', () => {
+ const onPatch = vi.fn();
+ const entry = { ...ARIA, sliders: { proactivity: 8, likability: null, competence: null } };
+ render(<CharacterDetailEditor entry={entry} characters={[ARIA]} onPatch={onPatch} />);
+ openArc();
+ fireEvent.change(screen.getByLabelText(/likability rating 1 to 10/i), { target: { value: '6' } });
+ expect(onPatch).toHaveBeenCalledWith({ sliders: { proactivity: 8, likability: 6, competence: null } });
+ });
+
+ it('clears a set slider back to unset (null)', () => {
+ const onPatch = vi.fn();
+ const entry = { ...ARIA, sliders: { proactivity: 9, likability: null, competence: null } };
+ render(<CharacterDetailEditor entry={entry} characters={[ARIA]} onPatch={onPatch} />);
+ openArc();
+ fireEvent.click(screen.getByRole('button', { name: /Clear proactivity/i }));
+ expect(onPatch).toHaveBeenCalledWith({ sliders: { proactivity: null, likability: null, competence: null } });
+ });
+
+ it('marshals the secrets string list to/from row objects', () => {
+ const onPatch = vi.fn();
+ const entry = { ...ARIA, secrets: ['forged the charter'] };
+ render(<CharacterDetailEditor entry={entry} characters={[ARIA]} onPatch={onPatch} />);
+ fireEvent.click(screen.getByRole('button', { name: /Secrets/i }));
+ // Existing secret is rendered in its row input.
+ const input = screen.getByDisplayValue('forged the charter');
+ fireEvent.change(input, { target: { value: 'forged the charter and the seal' } });
+ fireEvent.blur(input);
+ // Commits back as a plain string[] (not row objects).
+ expect(onPatch).toHaveBeenCalledWith({ secrets: ['forged the charter and the seal'] });
+ });
+
+ it('exposes the Ghost→Wound→Lie→Want→Need prose fields', () => {
+ render(<CharacterDetailEditor entry={{ ...ARIA, lie: 'I only matter if I win' }} characters={[ARIA]} onPatch={() => {}} />);
+ fireEvent.click(screen.getByRole('button', { name: /Character framework/i }));
+ expect(screen.getByDisplayValue('I only matter if I win')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/lib/bibleLimits.js b/client/src/lib/bibleLimits.js
index 88a92c48e7..7ef9c5b953 100644
--- a/client/src/lib/bibleLimits.js
+++ b/client/src/lib/bibleLimits.js
@@ -23,6 +23,16 @@ export const BIBLE_LIMITS = Object.freeze({
SPECIAL_TRAITS_MAX: 2000,
VISUAL_IDENTITY_MAX: 1000,
MOTIVATIONS_MAX: 2000,
+ // Character framework (CWQE Phase 10, #2175).
+ GHOST_MAX: 1000,
+ WOUND_MAX: 1000,
+ LIE_MAX: 600,
+ WANT_MAX: 600,
+ NEED_MAX: 600,
+ SECRET_MAX: 600,
+ SECRETS_PER_CHARACTER_MAX: 12,
+ SLIDER_MIN: 1,
+ SLIDER_MAX: 10,
LIKES_MAX: 1500,
DISLIKES_MAX: 1500,
MANNERISMS_MAX: 1500,
diff --git a/data.reference/prompts/stages/pipeline-arc-overview.md b/data.reference/prompts/stages/pipeline-arc-overview.md
index 6dcfba4204..896d94c4c3 100644
--- a/data.reference/prompts/stages/pipeline-arc-overview.md
+++ b/data.reference/prompts/stages/pipeline-arc-overview.md
@@ -60,7 +60,8 @@ The series is grounded in this World Builder world: **{{worldName}}**. When you
- **`logline`** — one sentence; what changes in this season.
- **`endingHook`** — the image or line that pulls the audience into season N+1. Skippable for the final season (leave empty).
- **`episodeCountTarget`** — integer. Divide `issueCountTarget` across the seasons roughly proportionally to season weight. Sum of all `episodeCountTarget`s should approximately equal `issueCountTarget`.
-6. **Foreshadowing ledger (2–6 seeds).** Plan the major setups the series plants early and pays off later — a Chekhov's gun, a prophecy, an unexplained scar, a withheld secret. For each seed record:
+6. **Thread nesting (MICE).** Treat each season as opening and closing narrative threads (a Milieu / Inquiry / Character / Event question). Threads must close in the REVERSE order they open — the last thread opened is the first resolved, like nested brackets. In each season's `logline` (or the `summary`), name the thread this season OPENS and the thread it CLOSES, so the nesting is legible: a season that opens a thread it never closes leaves a dangling question; one that closes a thread out of order breaks the nesting.
+7. **Foreshadowing ledger (2–6 seeds).** Plan the major setups the series plants early and pays off later — a Chekhov's gun, a prophecy, an unexplained scar, a withheld secret. For each seed record:
- **`label`** — a short name for the seed (e.g. *The locked room*, *Mara's limp*, *The recurring bell*).
- **`plantIssue`** — the 1-indexed issue number where it's first planted (subtly introduced, not explained).
- **`reinforceIssues`** — 0 or more issue numbers between plant and payoff where the seed is quietly reinforced so the reader doesn't forget it. Keep it a light touch — a glimpse, not a recap.
diff --git a/data.reference/prompts/stages/pipeline-season-episodes.md b/data.reference/prompts/stages/pipeline-season-episodes.md
index b946b100c5..aec0c951ff 100644
--- a/data.reference/prompts/stages/pipeline-season-episodes.md
+++ b/data.reference/prompts/stages/pipeline-season-episodes.md
@@ -63,6 +63,15 @@ Plan an arc *within* the season that bends from "pickup state" (the natural star
- **8-episode arc** — pilot, complication, complication, midpoint, complication, complication, all-is-lost, finale.
- **12+** — add B-plot episodes between the structural beats; don't waste the count on filler.
+### Structure rules (enforce while beating out the season)
+
+- **Try-fail mandate.** 60%+ of the middle episodes (everything between pilot and finale) must end in complication, not clean success — "Yes, but…" (they get what they wanted, but it costs or backfires) or "No, and…" (they fail, and it gets worse). A run of clean wins stalls momentum.
+- **Beat rules.**
+ - Catalyst / pilot inciting event is EXTERNAL — it happens TO the protagonist; they don't choose it.
+ - The pivot into the season's main conflict (Break Into Two) is a protagonist CHOICE — they decide to engage.
+ - The all-is-lost beat includes a DEATH — literal, or the death of a hope, a relationship, or an identity.
+- **Finale = the protagonist's hardest ACTIVE choice** between what they WANT (external goal) and what they NEED (the truth). They drive the climax; it does not resolve itself around them.
+
For each episode write:
- **`number`** — 1-indexed within this season (NOT cumulative across the whole series). Sequential.
diff --git a/data.reference/prompts/stages/universe-character-expand.md b/data.reference/prompts/stages/universe-character-expand.md
index d306a7b359..e2fe1a02d1 100644
--- a/data.reference/prompts/stages/universe-character-expand.md
+++ b/data.reference/prompts/stages/universe-character-expand.md
@@ -41,6 +41,15 @@ For every BLANK field in the character JSON above, propose a value that:
- `specialTraits` — non-redundant standout details ("quick hands; chipped nail polish; scar on right eyebrow; restless energy; observant").
- `visualIdentity` — design language axes ("knobs + sights; urban utilitarian; analog tech feel; small signals of story; hard to pin down").
- `motivations` — primary drives in 2–3 sentences. What does the character WANT, and what does the character fear losing?
+- **Character framework (Ghost → Wound → Lie → Want → Need).** Only propose these for a lead/antagonist the universe clearly centers; leave blank for a bit-player. They must interlock — pass these checks before writing them:
+ - `ghost` — the past event that wounded the character (1–2 sentences). Must causally explain the Lie.
+ - `wound` — the lasting emotional damage the Ghost left (1 sentence).
+ - `lie` — the false belief the character holds because of the Wound. State it in ONE sentence ("I only matter if I win").
+ - `need` — the Truth that is the DIRECT OPPOSITE of the Lie ("I matter whether I win or lose").
+ - `want` — the concrete external goal the character pursues, which usually conflicts with the Need.
+- `arcType` — one of `positive` (overcomes the Lie, embraces the Truth), `negative` (consumed by the Lie), or `flat` (already knows the Truth; changes the world instead). Omit if unclear.
+- `sliders` — rate `proactivity`, `likability`, `competence` each 1–10. Rule: HIGH (≥7) on at least TWO, OR high on one with clear room to grow. All-low reads boring; all-high-from-the-start reads as a Mary Sue. Omit for a bit-player.
+- `secrets` — 2+ things this character hides (from others or themselves). Short prose items.
- `likes` — short prose list, separated by commas or semicolons.
- `dislikes` — same shape as likes.
- `mannerisms` — habitual physical / verbal tics ("touches the back of the neck when lying; trails off mid-sentence when thinking; whistles tunelessly while working").
@@ -69,6 +78,14 @@ Return ONLY valid JSON, no markdown fence, no commentary. Include ONLY the keys
"specialTraits": "string",
"visualIdentity": "string",
"motivations": "string",
+ "ghost": "string",
+ "wound": "string",
+ "lie": "string",
+ "want": "string",
+ "need": "string",
+ "arcType": "positive | negative | flat",
+ "sliders": {"proactivity": 1, "likability": 1, "competence": 1},
+ "secrets": ["string"],
"likes": "string",
"dislikes": "string",
"mannerisms": "string",
diff --git a/scripts/migrations/003-update-pipeline-stage-prompts.js b/scripts/migrations/003-update-pipeline-stage-prompts.js
index 5e39f400e9..7ab5157d3d 100644
--- a/scripts/migrations/003-update-pipeline-stage-prompts.js
+++ b/scripts/migrations/003-update-pipeline-stage-prompts.js
@@ -49,6 +49,7 @@ export const ACCEPTED_OLD_MD5 = {
'pipeline-season-episodes.md': [
'6e349ad26bed8a0ccb042571f03f03eb', // pre-003 (original)
'c4928e2a5f833358116b29d2d669888d', // post-003 / pre-005 — the hash this migration originally produced
+ '50c68a29c3ebc275db3095d06bd87100', // post-005 / pre-172 (structure rules)
],
};
@@ -57,7 +58,7 @@ export const NEW_SHIPPED_MD5 = {
'pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54', // post-169 (cross-issue continuity)
'pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87', // post-127 (scene markers)
'pipeline-tv-script.md': '376f779f4687b598f1c92ca4e770fd5a', // retired upstream (no data.reference)
- 'pipeline-season-episodes.md': '50c68a29c3ebc275db3095d06bd87100', // post-005
+ 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b', // post-172 (structure rules)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/005-shape-aware-arc-prompts.js b/scripts/migrations/005-shape-aware-arc-prompts.js
index 2946c88b17..db9593f792 100644
--- a/scripts/migrations/005-shape-aware-arc-prompts.js
+++ b/scripts/migrations/005-shape-aware-arc-prompts.js
@@ -25,6 +25,7 @@ export const ACCEPTED_OLD_MD5 = {
'6a3ecab43d1f46b7ef9aab6c69ea0326', // pre-005 (original)
'd34d72b8e49ba303d38607845dd87f1c', // post-005 / pre-019 — the hash this migration originally produced
'0a1f6ffa6908522e3690c5e9e53a6ee0', // post-019 / pre-165 (foreshadowing ledger)
+ '612f8b04950e2ff26dd350dd76a062fe', // post-166 / pre-173 (MICE thread nesting)
],
'pipeline-arc-verify.md': [
'52e31abc93e3105176236fcaa5d1575a', // pre-005 (original)
@@ -34,7 +35,10 @@ export const ACCEPTED_OLD_MD5 = {
'c6ea28e972ad6e229bafb2d602b4dda3', // pre-005 (original)
'03f3c874cb80e1c98abcf03168fa7a92', // post-005 / pre-019 — the hash this migration originally produced
],
- 'pipeline-season-episodes.md': ['c4928e2a5f833358116b29d2d669888d'], // pre-005 (original); post-005 hash IS the live sample
+ 'pipeline-season-episodes.md': [
+ 'c4928e2a5f833358116b29d2d669888d', // pre-005 (original)
+ '50c68a29c3ebc275db3095d06bd87100', // post-005 / pre-172 (structure rules)
+ ],
'pipeline-arc-resolve.md': [
'87bc5c01f1a8a97b681727a38b05edc6', // pre-005 (original)
'a8677bbe1eb38f871fb152a5b0fec7c6', // post-005 / pre-019 — the hash this migration originally produced
@@ -44,10 +48,10 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-arc-overview.md': '612f8b04950e2ff26dd350dd76a062fe', // post-166 (foreshadowing ledger)
+ 'pipeline-arc-overview.md': '74d6c26548660d85fc345b2099c63b6c', // post-173 (MICE thread nesting)
'pipeline-arc-verify.md': '36aa70cdfc25d7549573a4d556e7702c', // post-019
'pipeline-volume-verify.md': '49458d36700cb94e34806d536ffe2940', // post-019
- 'pipeline-season-episodes.md': '50c68a29c3ebc275db3095d06bd87100', // post-005 (live sample)
+ 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b', // post-172 (structure rules)
'pipeline-arc-resolve.md': 'cc27b4da1d1a13c35e35d1c2d6183815', // post-123 (episodes[] correction channel)
};
diff --git a/scripts/migrations/019-arc-volume-prompts-canon-context.js b/scripts/migrations/019-arc-volume-prompts-canon-context.js
index 64a0c1c119..e43aaeb3b0 100644
--- a/scripts/migrations/019-arc-volume-prompts-canon-context.js
+++ b/scripts/migrations/019-arc-volume-prompts-canon-context.js
@@ -40,6 +40,7 @@ export const ACCEPTED_OLD_MD5 = {
'd34d72b8e49ba303d38607845dd87f1c', // current (pre-Phase B) shipped
'6a3ecab43d1f46b7ef9aab6c69ea0326', // pre-005 (shape-aware), still in setup-data.js OLD list
'0a1f6ffa6908522e3690c5e9e53a6ee0', // post-019 / pre-165 (foreshadowing ledger)
+ '612f8b04950e2ff26dd350dd76a062fe', // post-166 / pre-173 (MICE thread nesting)
],
'pipeline-arc-verify.md': [
'ff56d8387162017e08d5d0491060ddd6', // current (pre-Phase B) shipped
@@ -58,7 +59,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-arc-overview.md': '612f8b04950e2ff26dd350dd76a062fe', // post-166 (foreshadowing ledger)
+ 'pipeline-arc-overview.md': '74d6c26548660d85fc345b2099c63b6c', // post-173 (MICE thread nesting)
'pipeline-arc-verify.md': '36aa70cdfc25d7549573a4d556e7702c', // post-019
'pipeline-arc-resolve.md': 'cc27b4da1d1a13c35e35d1c2d6183815', // post-123 (episodes[] correction channel)
'pipeline-volume-verify.md': '49458d36700cb94e34806d536ffe2940', // post-019
diff --git a/scripts/migrations/027-text-stage-prompts-entities-summary.js b/scripts/migrations/027-text-stage-prompts-entities-summary.js
index e5f3befd2e..a723de610c 100644
--- a/scripts/migrations/027-text-stage-prompts-entities-summary.js
+++ b/scripts/migrations/027-text-stage-prompts-entities-summary.js
@@ -64,6 +64,7 @@ export const ACCEPTED_OLD_MD5 = {
],
'universe-character-expand.md': [
'ef109eb8e12ddb664c11c790271b5139', // pre-027 shipped
+ '67b6e73ed47f318451a730088b4cff14', // post-027 / pre-171 (character framework)
],
};
@@ -71,7 +72,7 @@ export const NEW_SHIPPED_MD5 = {
'pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54', // post-169 (cross-issue continuity)
'pipeline-teleplay.md': '2ea9974ac3803658b2314db1f5818b77', // post-128 (canonical scene list)
'pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87', // post-127 (scene markers)
- 'universe-character-expand.md': '67b6e73ed47f318451a730088b4cff14',
+ 'universe-character-expand.md': '177b6e4e8bdf445308cf8ac423cd5ad8', // post-171 (character framework)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/166-craft-knowledge-prompt-upgrades.js b/scripts/migrations/166-craft-knowledge-prompt-upgrades.js
index 5d62cf37f5..30e129380b 100644
--- a/scripts/migrations/166-craft-knowledge-prompt-upgrades.js
+++ b/scripts/migrations/166-craft-knowledge-prompt-upgrades.js
@@ -39,7 +39,10 @@ import { makePromptReplaceMigration } from './_lib.js';
export const ACCEPTED_OLD_MD5 = {
'pipeline-prose.md': ['25e3d58c2741bd98acd5d08ba70d8a5e', '430d38ed2da59e0d4212e65edc499a74'],
'writers-room-continue.md': ['93bfe80543ceca39842201a78b8393fa'],
- 'pipeline-arc-overview.md': ['0a1f6ffa6908522e3690c5e9e53a6ee0'],
+ 'pipeline-arc-overview.md': [
+ '0a1f6ffa6908522e3690c5e9e53a6ee0',
+ '612f8b04950e2ff26dd350dd76a062fe', // post-166 / pre-173 (MICE thread nesting)
+ ],
};
// Post-change shipped hashes (partial injected / foreshadowing ledger added).
@@ -48,7 +51,7 @@ export const ACCEPTED_OLD_MD5 = {
export const NEW_SHIPPED_MD5 = {
'pipeline-prose.md': '4cb3ef48309f3673570cf80e4d544b54',
'writers-room-continue.md': '67663696c97ebaeb23de25f7410cfdd4',
- 'pipeline-arc-overview.md': '612f8b04950e2ff26dd350dd76a062fe',
+ 'pipeline-arc-overview.md': '74d6c26548660d85fc345b2099c63b6c', // post-173 (MICE thread nesting)
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/171-character-framework-prompt.js b/scripts/migrations/171-character-framework-prompt.js
new file mode 100644
index 0000000000..4eebc9d58e
--- /dev/null
+++ b/scripts/migrations/171-character-framework-prompt.js
@@ -0,0 +1,57 @@
+/**
+ * CWQE Phase 10 (remainder) — character framework generation doctrine (#2175).
+ *
+ * `universe-character-expand.md` gained the Ghost → Wound → Lie → Want → Need
+ * chain (with interlock checks), the declared arc type, the Three Sliders
+ * (proactivity/likability/competence 1–10), and a secrets list — so the
+ * character-generation LLM elicits these authored fields up front, which the
+ * `arc.*` / `character.consistency` editorial checks then reconcile against
+ * (plan vs delivery) instead of inferring both.
+ *
+ * `scripts/setup-data.js` only copies *missing* prompt files, so existing
+ * installs keep their old template until this migration rewrites it. This is a
+ * NEW migration slot that OWNS the current shipped hash going forward; migration
+ * 027 (the prior owner of universe-character-expand.md) is resynced in this same
+ * change per the drift-cross-sync convention: its previous current hash moved
+ * into `ACCEPTED_OLD_MD5` and its `NEW_SHIPPED_MD5` was bumped to the post-171
+ * hash so its drift-catch test stays in lock-step with the live sample. The
+ * drift baseline in `setup-data-drift.test.js` was updated to match.
+ *
+ * Customization-safe: only installs whose copy still hashes to the prior shipped
+ * version are auto-updated; customized prompts are left intact and warned about.
+ *
+ * Strategy: hash-driven prompt-replace via `./_lib.js`. Idempotent.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+// Pre-change shipped hash (the current shipped body before #2175 remainder).
+export const ACCEPTED_OLD_MD5 = {
+ 'universe-character-expand.md': ['67b6e73ed47f318451a730088b4cff14'], // post-027
+};
+
+// Post-change shipped hash (character framework fields added).
+export const NEW_SHIPPED_MD5 = {
+ 'universe-character-expand.md': '177b6e4e8bdf445308cf8ac423cd5ad8',
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ label: 'character framework doctrine',
+ customizedHint: (filename) =>
+ ` To add the Ghost→Wound→Lie→Want→Need chain + arc type + Three Sliders +\n` +
+ ` secrets manually, diff:\n` +
+ ` data.reference/prompts/stages/${filename}\n` +
+ ` against your current:\n` +
+ ` data/prompts/stages/${filename}\n` +
+ ` and merge the "Character framework" guidance + output-contract keys.`,
+ skipFooter: (count) =>
+ `⚠️ ${count} prompt(s) could not be auto-updated because they were customized.\n` +
+ ` Character generation still works, but the character-framework fields\n` +
+ ` (ghost/wound/lie/want/need, arcType, sliders, secrets) will not be\n` +
+ ` elicited until you merge them from data.reference/prompts/stages/.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/171-character-framework-prompt.test.js b/scripts/migrations/171-character-framework-prompt.test.js
new file mode 100644
index 0000000000..33b76472d1
--- /dev/null
+++ b/scripts/migrations/171-character-framework-prompt.test.js
@@ -0,0 +1,22 @@
+/**
+ * Test for migration 171 — universe-character-expand.md gains the character
+ * framework doctrine (Ghost→Wound→Lie→Want→Need, arc type, Three Sliders,
+ * secrets).
+ *
+ * Picked up via the vitest include glob in server/vitest.config.js
+ * (`../scripts/migrations/**\/*.test.js`).
+ */
+import { describe } from 'vitest';
+
+import { runPromptMigrationTests } from './_testHelpers.js';
+import migration, { applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5 } from './171-character-framework-prompt.js';
+
+describe('migration 171 — character framework generation doctrine', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-171-',
+ });
+});
diff --git a/scripts/migrations/172-structure-rules-season-episodes.js b/scripts/migrations/172-structure-rules-season-episodes.js
new file mode 100644
index 0000000000..95c4cafc32
--- /dev/null
+++ b/scripts/migrations/172-structure-rules-season-episodes.js
@@ -0,0 +1,56 @@
+/**
+ * CWQE Phase 10 (remainder) — structure rules at generation, season beats (#2175).
+ *
+ * `pipeline-season-episodes.md` gained a lean "Structure rules" block:
+ * - try-fail mandate (60%+ of middle episodes end "Yes, but" / "No, and")
+ * - beat rules (Catalyst external; Break Into Two is a protagonist choice;
+ * All Is Lost includes a death — literal or of a hope/relationship/identity)
+ * - climax = the protagonist's hardest ACTIVE choice between Want and Need
+ *
+ * `scripts/setup-data.js` only copies *missing* prompt files, so existing
+ * installs keep their old template until this migration rewrites it. This is a
+ * NEW migration slot that OWNS the current shipped hash going forward; migration
+ * 003 (the prior owner of pipeline-season-episodes.md) is resynced in this same
+ * change per the drift-cross-sync convention: its previous current hash moved
+ * into `ACCEPTED_OLD_MD5` and its `NEW_SHIPPED_MD5` was bumped to the post-172
+ * hash so its drift-catch test stays in lock-step with the live sample. The
+ * drift baseline in `setup-data-drift.test.js` was updated to match.
+ *
+ * Customization-safe: only installs whose copy still hashes to the prior shipped
+ * version are auto-updated; customized prompts are left intact and warned about.
+ *
+ * Strategy: hash-driven prompt-replace via `./_lib.js`. Idempotent.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+// Pre-change shipped hash (the current shipped body before #2175 remainder).
+export const ACCEPTED_OLD_MD5 = {
+ 'pipeline-season-episodes.md': ['50c68a29c3ebc275db3095d06bd87100'], // post-005 (via 003)
+};
+
+// Post-change shipped hash (structure rules block added).
+export const NEW_SHIPPED_MD5 = {
+ 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b',
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ label: 'season-episode structure rules',
+ customizedHint: (filename) =>
+ ` To add the try-fail mandate + beat rules + active-climax guidance\n` +
+ ` manually, diff:\n` +
+ ` data.reference/prompts/stages/${filename}\n` +
+ ` against your current:\n` +
+ ` data/prompts/stages/${filename}\n` +
+ ` and merge the "Structure rules" block under "How to shape the season".`,
+ skipFooter: (count) =>
+ `⚠️ ${count} prompt(s) could not be auto-updated because they were customized.\n` +
+ ` Season planning still works, but the try-fail mandate + beat rules will\n` +
+ ` not be enforced at generation until you merge them from\n` +
+ ` data.reference/prompts/stages/.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/172-structure-rules-season-episodes.test.js b/scripts/migrations/172-structure-rules-season-episodes.test.js
new file mode 100644
index 0000000000..da4128269b
--- /dev/null
+++ b/scripts/migrations/172-structure-rules-season-episodes.test.js
@@ -0,0 +1,21 @@
+/**
+ * Test for migration 172 — pipeline-season-episodes.md gains the structure-rules
+ * block (try-fail mandate, beat rules, active climax).
+ *
+ * Picked up via the vitest include glob in server/vitest.config.js
+ * (`../scripts/migrations/**\/*.test.js`).
+ */
+import { describe } from 'vitest';
+
+import { runPromptMigrationTests } from './_testHelpers.js';
+import migration, { applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5 } from './172-structure-rules-season-episodes.js';
+
+describe('migration 172 — season-episode structure rules', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-172-',
+ });
+});
diff --git a/scripts/migrations/173-mice-thread-nesting-arc-overview.js b/scripts/migrations/173-mice-thread-nesting-arc-overview.js
new file mode 100644
index 0000000000..bf7f2743b6
--- /dev/null
+++ b/scripts/migrations/173-mice-thread-nesting-arc-overview.js
@@ -0,0 +1,55 @@
+/**
+ * CWQE Phase 10 (remainder) — MICE thread nesting in the arc overview (#2175).
+ *
+ * `pipeline-arc-overview.md` gained a lean "Thread nesting (MICE)" instruction:
+ * treat each season as opening/closing a narrative thread (Milieu / Inquiry /
+ * Character / Event question); threads close in the REVERSE order they open
+ * (nested brackets), and each season names the thread it opens and the thread
+ * it closes so the nesting is legible to later structure checks.
+ *
+ * `scripts/setup-data.js` only copies *missing* prompt files, so existing
+ * installs keep their old template until this migration rewrites it. This is a
+ * NEW migration slot that OWNS the current shipped hash going forward; migration
+ * 166 (the prior owner of pipeline-arc-overview.md) is resynced in this same
+ * change per the drift-cross-sync convention: its previous current hash moved
+ * into `ACCEPTED_OLD_MD5` and its `NEW_SHIPPED_MD5` was bumped to the post-173
+ * hash so its drift-catch test stays in lock-step with the live sample. The
+ * drift baseline in `setup-data-drift.test.js` was updated to match.
+ *
+ * Customization-safe: only installs whose copy still hashes to the prior shipped
+ * version are auto-updated; customized prompts are left intact and warned about.
+ *
+ * Strategy: hash-driven prompt-replace via `./_lib.js`. Idempotent.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+// Pre-change shipped hash (the current shipped body before #2175 remainder).
+export const ACCEPTED_OLD_MD5 = {
+ 'pipeline-arc-overview.md': ['612f8b04950e2ff26dd350dd76a062fe'], // post-166 (foreshadowing ledger)
+};
+
+// Post-change shipped hash (MICE thread-nesting instruction added).
+export const NEW_SHIPPED_MD5 = {
+ 'pipeline-arc-overview.md': '74d6c26548660d85fc345b2099c63b6c',
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ label: 'MICE thread nesting',
+ customizedHint: (filename) =>
+ ` To add the MICE thread-nesting instruction manually, diff:\n` +
+ ` data.reference/prompts/stages/${filename}\n` +
+ ` against your current:\n` +
+ ` data/prompts/stages/${filename}\n` +
+ ` and merge the "Thread nesting (MICE)" step into "How to shape the arc".`,
+ skipFooter: (count) =>
+ `⚠️ ${count} prompt(s) could not be auto-updated because they were customized.\n` +
+ ` Arc planning still works, but the MICE thread-nesting doctrine will not\n` +
+ ` be applied at generation until you merge it from\n` +
+ ` data.reference/prompts/stages/.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/173-mice-thread-nesting-arc-overview.test.js b/scripts/migrations/173-mice-thread-nesting-arc-overview.test.js
new file mode 100644
index 0000000000..228f310e29
--- /dev/null
+++ b/scripts/migrations/173-mice-thread-nesting-arc-overview.test.js
@@ -0,0 +1,21 @@
+/**
+ * Test for migration 173 — pipeline-arc-overview.md gains the MICE thread-nesting
+ * instruction.
+ *
+ * Picked up via the vitest include glob in server/vitest.config.js
+ * (`../scripts/migrations/**\/*.test.js`).
+ */
+import { describe } from 'vitest';
+
+import { runPromptMigrationTests } from './_testHelpers.js';
+import migration, { applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5 } from './173-mice-thread-nesting-arc-overview.js';
+
+describe('migration 173 — MICE thread nesting (arc overview)', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-173-',
+ });
+});
diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.js
index 2c2d69b423..c5501e7820 100644
--- a/scripts/setup-data-drift.test.js
+++ b/scripts/setup-data-drift.test.js
@@ -29,15 +29,15 @@ const EXPECTED_STAGE_OLD = {
'writers-room-continue.md': ['93bfe80543ceca39842201a78b8393fa'],
'pipeline-comic-script.md': ['133d200d069c2e8173b7c129eea58f53', '1e0af305c27d0c80c4b482d2ebcb4a0d', '40e5fdc1a1e68a7419b7dad936366c1a', '7c05ecde539f04c9fa91e87543057204', 'a4303016c34b65e4b0e641fe71252de3', 'beab031951859ca13579cdb9c4dbe769', 'dea7d497d1cb38e7574f236f4ff8e644', 'e530fc76b89cedaef848ad7ec99c934c', 'e9ee70bf18888492edada6633cd9928a'],
'pipeline-teleplay.md': ['1280ef6b1ad68fa44070ca7478ec2a5f', '2568e14beaa574d43f8018a5def51d04', '376f779f4687b598f1c92ca4e770fd5a', '3f6fecc25573ed054b47db392250034a', 'afa4215330bf856429d70d7e2f856605'],
- 'pipeline-season-episodes.md': ['6e349ad26bed8a0ccb042571f03f03eb', 'c4928e2a5f833358116b29d2d669888d'],
- 'pipeline-arc-overview.md': ['6a3ecab43d1f46b7ef9aab6c69ea0326', 'd34d72b8e49ba303d38607845dd87f1c', '0a1f6ffa6908522e3690c5e9e53a6ee0'],
+ 'pipeline-season-episodes.md': ['6e349ad26bed8a0ccb042571f03f03eb', 'c4928e2a5f833358116b29d2d669888d', '50c68a29c3ebc275db3095d06bd87100'],
+ 'pipeline-arc-overview.md': ['6a3ecab43d1f46b7ef9aab6c69ea0326', 'd34d72b8e49ba303d38607845dd87f1c', '0a1f6ffa6908522e3690c5e9e53a6ee0', '612f8b04950e2ff26dd350dd76a062fe'],
'pipeline-arc-verify.md': ['52e31abc93e3105176236fcaa5d1575a', 'ff56d8387162017e08d5d0491060ddd6'],
'pipeline-volume-verify.md': ['03f3c874cb80e1c98abcf03168fa7a92', 'c6ea28e972ad6e229bafb2d602b4dda3'],
'pipeline-arc-resolve.md': ['5b340885c6e8f8afc63424d6b5bc7eb7', '87bc5c01f1a8a97b681727a38b05edc6', '8e348f3d1894382889f9f0ee7d5c6792', 'a8677bbe1eb38f871fb152a5b0fec7c6'],
'pipeline-script-verify.md': ['ed6c8101644cfe56a100eb6bfe3587f3'],
'pipeline-extract-scenes.md': ['59fa5ee305ce53d91eb15224d8b546d3', 'c51fb208568d0d903eb43b437478b0ba'],
'writers-room-places.md': ['24a33628cc94d80fa5ca60831d973daf', '7f1f80eb63d67a21161994cde115045e'],
- 'universe-character-expand.md': ['ef109eb8e12ddb664c11c790271b5139'],
+ 'universe-character-expand.md': ['ef109eb8e12ddb664c11c790271b5139', '67b6e73ed47f318451a730088b4cff14'],
'story-builder-idea-expand.md': ['778c86e2caa120856c36e4d5a4da3355', 'a23939626a226f7420cebfb45d47950c'],
'pipeline-editorial-analysis.md': ['14d9879697c66d51830cc798040d5369'],
'pipeline-manuscript-completeness.md': ['4f2b95778aed85f5fc461d71eb461b79', 'e6858c74ab2cead752d388e3f428406c', '1ee5ac936fbf1d365e0eaea99bcf1e77', 'cec8faeb75dfff74e41b8221145c2e92'],
@@ -55,8 +55,8 @@ const EXPECTED_STAGE_NEW = {
'writers-room-continue.md': '67663696c97ebaeb23de25f7410cfdd4',
'pipeline-comic-script.md': '49af30c05f008b20f6998a0f113f7d87',
'pipeline-teleplay.md': '2ea9974ac3803658b2314db1f5818b77',
- 'pipeline-season-episodes.md': '50c68a29c3ebc275db3095d06bd87100',
- 'pipeline-arc-overview.md': '612f8b04950e2ff26dd350dd76a062fe',
+ 'pipeline-season-episodes.md': 'a88e8e78a949b7aaf500d03314e2ea0b',
+ 'pipeline-arc-overview.md': '74d6c26548660d85fc345b2099c63b6c',
'pipeline-arc-verify.md': '36aa70cdfc25d7549573a4d556e7702c',
'pipeline-volume-verify.md': '49458d36700cb94e34806d536ffe2940',
'pipeline-arc-resolve.md': 'cc27b4da1d1a13c35e35d1c2d6183815',
@@ -64,7 +64,7 @@ const EXPECTED_STAGE_NEW = {
'pipeline-extract-scenes.md': '9f404b0c4721b23932a6d2dcfc1fba43',
'writers-room-places.md': 'a7f68e51dd6b4421d20f5bd9d855d9b4',
'cos-agent-briefing.md': 'dccb392a43cbd3dac900fee12c31619a',
- 'universe-character-expand.md': '67b6e73ed47f318451a730088b4cff14',
+ 'universe-character-expand.md': '177b6e4e8bdf445308cf8ac423cd5ad8',
'story-builder-idea-expand.md': 'c12d76fefaaded2838023065bfc94bb0',
'pipeline-editorial-analysis.md': 'daeb02bd54b0c099b21af659c6298cfe',
'pipeline-manuscript-completeness.md': 'fd26f928c33803c12878a1bfb8561ece',
diff --git a/server/lib/editorial/checkInfra.js b/server/lib/editorial/checkInfra.js
index b0d9be4db6..83c58ee623 100644
--- a/server/lib/editorial/checkInfra.js
+++ b/server/lib/editorial/checkInfra.js
@@ -713,6 +713,20 @@ export function canonCharacterTraitsSummary(canon) {
if (dislikes) facts.push(`dislikes: ${dislikes}`);
const speechPattern = cleanStr(c.speechPattern);
if (speechPattern) facts.push(`speech: ${speechPattern}`);
+ // Authored character-framework fields (CWQE Phase 10, #2175) — the Lie the
+ // character believes, the Want (external goal), the Need (the Truth), and
+ // the declared arc type. Surfacing these lets the consistency / arc checks
+ // reconcile the prose against the PLAN (does the character overcome the Lie,
+ // pursue the Want, arrive at the Need per the declared arc?) instead of
+ // inferring the intended arc from the prose alone.
+ const lie = cleanStr(c.lie).slice(0, CANON_TRAIT_FACT_CHARS);
+ if (lie) facts.push(`believes (Lie): ${lie}`);
+ const want = cleanStr(c.want).slice(0, CANON_TRAIT_FACT_CHARS);
+ if (want) facts.push(`wants: ${want}`);
+ const need = cleanStr(c.need).slice(0, CANON_TRAIT_FACT_CHARS);
+ if (need) facts.push(`needs (Truth): ${need}`);
+ const arcType = cleanStr(c.arcType);
+ if (arcType) facts.push(`declared arc: ${arcType}`);
if (!facts.length) continue;
const who = aliases.length ? `${name} (also: ${aliases.join(', ')})` : name;
rows.push(`- ${who} — ${facts.join('; ')}`);
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index d5c85de2ff..b2ca97ea1a 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -1467,6 +1467,25 @@ describe('canonCharacterTraitsSummary (#1582)', () => {
// personality is a non-string and mannerisms is a non-array object → no traits → C drops out.
expect(canonCharacterTraitsSummary({ characters: [{ name: 'C', personality: 5, mannerisms: {} }] })).toBe('');
});
+
+ it('surfaces authored character-framework fields for arc reconciliation (#2175)', () => {
+ const out = canonCharacterTraitsSummary({ characters: [
+ { name: 'Vale', lie: 'I only matter if I win', want: 'seize command', need: 'I matter regardless', arcType: 'positive' },
+ ] });
+ expect(out).toContain('believes (Lie): I only matter if I win');
+ expect(out).toContain('wants: seize command');
+ expect(out).toContain('needs (Truth): I matter regardless');
+ expect(out).toContain('declared arc: positive');
+ });
+
+ it('omits framework fields that are absent (pre-#2175 records)', () => {
+ const out = canonCharacterTraitsSummary({ characters: [
+ { name: 'Legacy', personality: 'stoic' },
+ ] });
+ expect(out).toContain('personality: stoic');
+ expect(out).not.toContain('believes (Lie)');
+ expect(out).not.toContain('declared arc');
+ });
});
describe('theme.coherence — LLM check (#1317)', () => {
diff --git a/server/lib/storyBible.js b/server/lib/storyBible.js
index be731f7fb4..b503d086db 100644
--- a/server/lib/storyBible.js
+++ b/server/lib/storyBible.js
@@ -46,6 +46,27 @@ export const BIBLE_LIMITS = Object.freeze({
SPECIAL_TRAITS_MAX: 2000,
VISUAL_IDENTITY_MAX: 1000,
MOTIVATIONS_MAX: 2000,
+ // Character framework (CWQE Phase 10, #2175). The Ghost → Wound → Lie →
+ // Want → Need chain + Three Sliders + declared arc type. All OPTIONAL so
+ // every pre-existing character round-trips unchanged (absent vs empty rule).
+ // The checkable-test discipline (state the Lie in one sentence; Truth is its
+ // direct opposite; Ghost causally explains the Lie) lives in the prompt, not
+ // the sanitizer — these caps just bound each field's length.
+ GHOST_MAX: 1000,
+ WOUND_MAX: 1000,
+ LIE_MAX: 600,
+ WANT_MAX: 600,
+ NEED_MAX: 600,
+ // Secrets the character keeps (≥2 encouraged in the prompt). Short prose
+ // items, capped per-item and per-character like other string lists.
+ SECRET_MAX: 600,
+ SECRETS_PER_CHARACTER_MAX: 12,
+ // Three Sliders — proactivity / likability / competence on a 1–10 scale.
+ // Stored as integers; a value outside the range (or a non-integer) collapses
+ // to null (unset). Rule (prompt-enforced, not sanitizer-enforced): HIGH on ≥2,
+ // or HIGH on one with clear growth; all-low = boring, all-high = Mary Sue.
+ SLIDER_MIN: 1,
+ SLIDER_MAX: 10,
LIKES_MAX: 1500,
DISLIKES_MAX: 1500,
MANNERISMS_MAX: 1500,
@@ -194,6 +215,13 @@ export const PLACE_TIME_OF_DAY = Object.freeze(['dawn', 'day', 'dusk', 'night'])
const PLACE_INT_EXT_SET = new Set(PLACE_INT_EXT);
const PLACE_TIME_OF_DAY_SET = new Set(PLACE_TIME_OF_DAY);
+// Declared character arc type (CWQE Phase 10, #2175). A positive arc overcomes
+// the Lie and embraces the Truth; a negative arc is consumed by the Lie; a flat
+// arc holds a truth the character already knows and changes the world around
+// them instead. Unset (null) keeps the field absent for every pre-#2175 record.
+export const CHARACTER_ARC_TYPES = Object.freeze(['positive', 'negative', 'flat']);
+const CHARACTER_ARC_TYPE_SET = new Set(CHARACTER_ARC_TYPES);
+
const trimEnum = (raw, allowed) => {
if (typeof raw !== 'string') return null;
const trimmed = raw.trim();
@@ -226,7 +254,7 @@ export const BIBLE_KINDS = Object.freeze(Object.values(BIBLE_KIND));
// `existing<X>Json` prompt variable (bibleExtractor) and into the script
// stage's bibles context (evaluator). Excludes ids/timestamps/source/notes.
export const PROMPT_FIELDS = Object.freeze({
- [BIBLE_KIND.CHARACTER]: ['name', 'aliases', 'role', 'pronouns', 'age', 'coreTheme', 'speechAccent', 'speechPattern', 'visualNotes', 'physicalDescription', 'personality', 'background', 'silhouetteNotes', 'postureNotes', 'specialTraits', 'visualIdentity', 'motivations', 'likes', 'dislikes', 'mannerisms', 'relationships', 'skills', 'stats', 'colorPalette', 'props', 'expressions', 'handGestures', 'voiceId', 'wardrobes', 'prompt', 'tags'],
+ [BIBLE_KIND.CHARACTER]: ['name', 'aliases', 'role', 'pronouns', 'age', 'coreTheme', 'speechAccent', 'speechPattern', 'visualNotes', 'physicalDescription', 'personality', 'background', 'silhouetteNotes', 'postureNotes', 'specialTraits', 'visualIdentity', 'motivations', 'ghost', 'wound', 'lie', 'want', 'need', 'arcType', 'sliders', 'secrets', 'likes', 'dislikes', 'mannerisms', 'relationships', 'skills', 'stats', 'colorPalette', 'props', 'expressions', 'handGestures', 'voiceId', 'wardrobes', 'prompt', 'tags'],
[BIBLE_KIND.PLACE]: ['name', 'slugline', 'description', 'palette', 'era', 'weather', 'intExt', 'timeOfDay', 'recurringDetails', 'prompt', 'tags'],
[BIBLE_KIND.OBJECT]: ['name', 'aliases', 'description', 'significance', 'prompt', 'tags'],
});
@@ -762,6 +790,30 @@ function ensureRevealIssue(raw) {
return n;
}
+// Normalize a Three-Sliders value (proactivity/likability/competence) to an
+// integer in [SLIDER_MIN, SLIDER_MAX] or null (unset). Accepts a finite number
+// or numeric string (LLM/JSON both occur); out-of-range / non-integer collapses
+// to null so an absent or hallucinated value doesn't masquerade as a real rating
+// (CWQE Phase 10, #2175). Null = the slider was never authored — distinct from a
+// deliberate low rating.
+function ensureSlider(raw) {
+ const n = typeof raw === 'number' ? raw : (isStr(raw) && raw.trim() !== '' ? Number(raw) : NaN);
+ if (!Number.isInteger(n) || n < BIBLE_LIMITS.SLIDER_MIN || n > BIBLE_LIMITS.SLIDER_MAX) return null;
+ return n;
+}
+
+// Build the Three-Sliders object from a raw payload. Returns an object with the
+// three keys always present (each null when unset) so the shape is stable and a
+// round-trip never strips it — mirrors the reveal-gating always-present pattern.
+function sanitizeCharacterSliders(raw) {
+ const src = raw && typeof raw === 'object' ? raw : {};
+ return {
+ proactivity: ensureSlider(src.proactivity),
+ likability: ensureSlider(src.likability),
+ competence: ensureSlider(src.competence),
+ };
+}
+
// Shared canon extras applied to every kind. Persists explicit `locked: true`
// AND `locked: false` so a Universe-Builder caller can flip the bit and have
// the change survive round-trips. Missing `locked` still collapses to absent
@@ -839,6 +891,26 @@ export function sanitizeCharacter(raw, { idPrefix = DEFAULT_ID_PREFIX.character,
visualIdentity: trimTo(raw.visualIdentity, BIBLE_LIMITS.VISUAL_IDENTITY_MAX),
// Narrative depth — drives dialogue + arc planning.
motivations: trimTo(raw.motivations, BIBLE_LIMITS.MOTIVATIONS_MAX),
+ // Character framework (CWQE Phase 10, #2175). Ghost → Wound → Lie → Want →
+ // Need chain + declared arc type + Three Sliders + secrets. All optional —
+ // a blank string / null / empty array keeps the legacy shape so every
+ // pre-#2175 character round-trips unchanged (absent vs empty rule). The
+ // arc.*/character.consistency editorial checks read the authored Lie/Want/
+ // Need/arc-type when present so they compare plan-vs-delivery instead of
+ // inferring both.
+ ghost: trimTo(raw.ghost, BIBLE_LIMITS.GHOST_MAX),
+ wound: trimTo(raw.wound, BIBLE_LIMITS.WOUND_MAX),
+ lie: trimTo(raw.lie, BIBLE_LIMITS.LIE_MAX),
+ want: trimTo(raw.want, BIBLE_LIMITS.WANT_MAX),
+ need: trimTo(raw.need, BIBLE_LIMITS.NEED_MAX),
+ // Declared arc type — null (unset) unless it's one of the three known
+ // values, so a legacy record with no arc type stays absent.
+ arcType: trimEnum(raw.arcType, CHARACTER_ARC_TYPE_SET),
+ // Three Sliders — always-present object, each axis null when unset.
+ sliders: sanitizeCharacterSliders(raw.sliders),
+ // Secrets the character keeps (≥2 encouraged). Plain string list; empty
+ // array is the legacy shape.
+ secrets: cleanStringArray(raw.secrets, BIBLE_LIMITS.SECRET_MAX, BIBLE_LIMITS.SECRETS_PER_CHARACTER_MAX),
likes: trimTo(raw.likes, BIBLE_LIMITS.LIKES_MAX),
dislikes: trimTo(raw.dislikes, BIBLE_LIMITS.DISLIKES_MAX),
mannerisms: trimTo(raw.mannerisms, BIBLE_LIMITS.MANNERISMS_MAX),
@@ -1174,6 +1246,8 @@ const MERGE_CONFIG = Object.freeze({
'silhouetteNotes', 'postureNotes', 'specialTraits', 'visualIdentity',
'motivations', 'likes', 'dislikes', 'mannerisms', 'relationships', 'skills',
'stats', 'colorPalette', 'props', 'expressions', 'handGestures',
+ // Character framework (CWQE Phase 10, #2175) — fill only when blank.
+ 'ghost', 'wound', 'lie', 'want', 'need', 'arcType', 'secrets',
],
keyFields: [
{ field: 'name', normalize: normalizeBibleName },
diff --git a/server/lib/storyBible.test.js b/server/lib/storyBible.test.js
index 8c5aa3cbd9..10ff4fdf73 100644
--- a/server/lib/storyBible.test.js
+++ b/server/lib/storyBible.test.js
@@ -99,6 +99,76 @@ describe('storyBible — sanitizeCharacter', () => {
expect(preserved.id).toBe('wr-char-existing');
});
+ // Character framework (CWQE Phase 10, #2175). All fields optional — a
+ // pre-#2175 record has no framework keys, so the sanitizer must produce the
+ // empty/legacy shape (absent vs empty rule) and a populated record must round
+ // trip verbatim.
+ describe('character framework (Ghost→Wound→Lie→Want→Need + arc type + sliders + secrets)', () => {
+ it('produces the empty/legacy shape when the fields are absent', () => {
+ const out = sanitizeCharacter({ name: 'Legacy' });
+ expect(out.ghost).toBe('');
+ expect(out.wound).toBe('');
+ expect(out.lie).toBe('');
+ expect(out.want).toBe('');
+ expect(out.need).toBe('');
+ expect(out.arcType).toBeNull();
+ expect(out.sliders).toEqual({ proactivity: null, likability: null, competence: null });
+ expect(out.secrets).toEqual([]);
+ });
+
+ it('round-trips a fully-authored framework', () => {
+ const authored = {
+ name: 'Vale',
+ ghost: 'Watched her mentor die for a cause she now doubts.',
+ wound: 'She cannot trust a cause bigger than herself.',
+ lie: 'I only matter if I stay in control.',
+ need: 'I matter whether or not I am in control.',
+ want: 'To seize command of the resistance.',
+ arcType: 'positive',
+ sliders: { proactivity: 9, likability: 4, competence: 8 },
+ secrets: ['She forged the founding charter.', 'She still writes to the dead mentor.'],
+ };
+ const out = sanitizeCharacter(authored);
+ expect(out.ghost).toBe(authored.ghost);
+ expect(out.wound).toBe(authored.wound);
+ expect(out.lie).toBe(authored.lie);
+ expect(out.need).toBe(authored.need);
+ expect(out.want).toBe(authored.want);
+ expect(out.arcType).toBe('positive');
+ expect(out.sliders).toEqual({ proactivity: 9, likability: 4, competence: 8 });
+ expect(out.secrets).toEqual(authored.secrets);
+ // Re-sanitizing the output is stable (no drift on the second pass).
+ expect(sanitizeCharacter(out)).toMatchObject({
+ ghost: authored.ghost, lie: authored.lie, arcType: 'positive',
+ sliders: { proactivity: 9, likability: 4, competence: 8 },
+ });
+ });
+
+ it('collapses an unknown arc type and out-of-range / non-integer sliders to unset', () => {
+ const out = sanitizeCharacter({
+ name: 'X',
+ arcType: 'redemption', // not one of positive/negative/flat
+ sliders: { proactivity: 11, likability: 0, competence: 5.5 },
+ });
+ expect(out.arcType).toBeNull();
+ // 11 > max, 0 < min, 5.5 non-integer — all collapse to null (unset).
+ expect(out.sliders).toEqual({ proactivity: null, likability: null, competence: null });
+ });
+
+ it('accepts a numeric-string slider and normalizes it to an integer', () => {
+ const out = sanitizeCharacter({ name: 'X', sliders: { proactivity: '7', likability: '', competence: 'nope' } });
+ expect(out.sliders).toEqual({ proactivity: 7, likability: null, competence: null });
+ });
+
+ it('caps framework prose fields and the secrets list', () => {
+ const long = 'g'.repeat(BIBLE_LIMITS.LIE_MAX + 100);
+ const tooMany = Array.from({ length: BIBLE_LIMITS.SECRETS_PER_CHARACTER_MAX + 5 }, (_, i) => `secret ${i}`);
+ const out = sanitizeCharacter({ name: 'X', lie: long, secrets: tooMany });
+ expect(out.lie.length).toBe(BIBLE_LIMITS.LIE_MAX);
+ expect(out.secrets.length).toBe(BIBLE_LIMITS.SECRETS_PER_CHARACTER_MAX);
+ });
+ });
+
it('coerces invalid source to `user`', () => {
expect(sanitizeCharacter({ name: 'A', source: 'evil' }).source).toBe('user');
});
diff --git a/server/services/universeCharacterExpand.js b/server/services/universeCharacterExpand.js
index b34b415d65..dfe105a77f 100644
--- a/server/services/universeCharacterExpand.js
+++ b/server/services/universeCharacterExpand.js
@@ -26,9 +26,15 @@ export const STRING_FIELDS = Object.freeze([
'pronouns', 'age', 'coreTheme', 'speechAccent', 'speechPattern', 'visualNotes',
'silhouetteNotes', 'postureNotes', 'specialTraits', 'visualIdentity',
'motivations', 'likes', 'dislikes', 'mannerisms', 'relationships', 'skills',
+ // Character framework (CWQE Phase 10, #2175) — the Ghost → Wound → Lie →
+ // Want → Need chain. Plain prose fields; `arcType` (enum) and `sliders`
+ // (structured) are handled separately below.
+ 'ghost', 'wound', 'lie', 'want', 'need',
]);
export const LIST_FIELDS = Object.freeze([
'stats', 'colorPalette', 'props', 'expressions', 'handGestures',
+ // Character framework — secrets are a plain string list (#2175).
+ 'secrets',
]);
// `relationshipLinks` (#1287) is INTENTIONALLY excluded from both lists: each
// link points at a sibling character by `targetCharacterId`, an id the LLM
@@ -95,6 +101,36 @@ export function applyExpansion(target, content) {
merged[field] = cleaned;
updatedFields.push(field);
}
+ // arcType — a bare enum string, filled only when the target has no arc type.
+ // Run through sanitizeCharacter so an unrecognized value (folded to null by
+ // trimEnum) never records a spurious update.
+ if ('arcType' in content && !isBlankString(content.arcType) && isBlankString(target.arcType)) {
+ const sanitized = sanitizeCharacter({ name: target.name, arcType: content.arcType }, { preserveTimestamps: false });
+ if (sanitized?.arcType) {
+ merged.arcType = sanitized.arcType;
+ updatedFields.push('arcType');
+ }
+ }
+ // sliders — a { proactivity, likability, competence } object. Fill each axis
+ // ONLY when the target's axis is unset (null), preserving any the user already
+ // rated. Sanitize the proposal so an out-of-range value collapses to null and
+ // never records a bogus update.
+ if (content.sliders && typeof content.sliders === 'object') {
+ const proposed = sanitizeCharacter({ name: target.name, sliders: content.sliders }, { preserveTimestamps: false })?.sliders || {};
+ const existing = (target.sliders && typeof target.sliders === 'object') ? target.sliders : {};
+ const nextSliders = { ...existing };
+ let changed = false;
+ for (const axis of ['proactivity', 'likability', 'competence']) {
+ if (existing[axis] == null && proposed[axis] != null) {
+ nextSliders[axis] = proposed[axis];
+ changed = true;
+ }
+ }
+ if (changed) {
+ merged.sliders = nextSliders;
+ updatedFields.push('sliders');
+ }
+ }
return { merged, updatedFields };
}
diff --git a/server/services/universeCharacterExpand.test.js b/server/services/universeCharacterExpand.test.js
index c5bc86b5b3..d5735a1027 100644
--- a/server/services/universeCharacterExpand.test.js
+++ b/server/services/universeCharacterExpand.test.js
@@ -5,10 +5,13 @@ describe('universeCharacterExpand — exported field lists', () => {
// These are the single source of truth for both the text expand and the
// vision-driven expand (universeVisionExpand.js). A drift here means one of
// the two flows silently stops filling a field.
- it('exports the 16 string fields + 5 list fields', () => {
- expect(STRING_FIELDS).toHaveLength(16);
- expect(LIST_FIELDS).toHaveLength(5);
- expect(LIST_FIELDS).toEqual(['stats', 'colorPalette', 'props', 'expressions', 'handGestures']);
+ it('exports the 21 string fields + 6 list fields', () => {
+ // 16 original + 5 framework prose fields (ghost/wound/lie/want/need, #2175).
+ expect(STRING_FIELDS).toHaveLength(21);
+ expect(STRING_FIELDS).toEqual(expect.arrayContaining(['ghost', 'wound', 'lie', 'want', 'need']));
+ // 5 original + `secrets` (#2175).
+ expect(LIST_FIELDS).toHaveLength(6);
+ expect(LIST_FIELDS).toEqual(['stats', 'colorPalette', 'props', 'expressions', 'handGestures', 'secrets']);
});
});
@@ -103,22 +106,78 @@ describe('universeCharacterExpand — applyExpansion (no-clobber merge semantics
name: 'Vale', pronouns: '', age: '', coreTheme: '', speechAccent: '', speechPattern: '', visualNotes: '',
silhouetteNotes: '', postureNotes: '', specialTraits: '', visualIdentity: '',
motivations: '', likes: '', dislikes: '', mannerisms: '', relationships: '', skills: '',
- stats: [], colorPalette: [], props: [], expressions: [], handGestures: [],
+ ghost: '', wound: '', lie: '', want: '', need: '',
+ stats: [], colorPalette: [], props: [], expressions: [], handGestures: [], secrets: [],
};
const content = {
pronouns: 'she/her', age: '27', coreTheme: 't', speechAccent: 'a', speechPattern: 'sp', visualNotes: 'v',
silhouetteNotes: 's', postureNotes: 'p', specialTraits: 'st', visualIdentity: 'vi',
motivations: 'm', likes: 'l', dislikes: 'd', mannerisms: 'mn', relationships: 'r', skills: 'sk',
+ ghost: 'g', wound: 'w', lie: 'li', want: 'wa', need: 'ne',
stats: [{ label: 'L', value: 'V' }],
colorPalette: [{ name: 'n' }],
props: [{ name: 'n' }],
expressions: [{ name: 'n' }],
handGestures: [{ name: 'n' }],
+ secrets: ['a hidden thing'],
};
const { updatedFields } = applyExpansion(target, content);
- // 16 strings + 5 lists = 21 fields total in the expand contract.
- expect(updatedFields).toHaveLength(21);
+ // 21 strings + 6 lists = 27 fields total in the expand contract.
+ expect(updatedFields).toHaveLength(27);
expect(updatedFields).toContain('speechPattern');
+ expect(updatedFields).toContain('lie');
+ expect(updatedFields).toContain('secrets');
+ });
+
+ // Character framework — arcType (enum) + sliders (structured) are merged
+ // outside the STRING/LIST loops (#2175).
+ describe('character framework — arcType + sliders no-clobber merge', () => {
+ it('fills a blank arcType from a valid enum proposal, ignores an unknown one', () => {
+ expect(applyExpansion({ name: 'V', arcType: '' }, { arcType: 'positive' }))
+ .toMatchObject({ merged: { arcType: 'positive' }, updatedFields: ['arcType'] });
+ // unknown enum → sanitizer folds to null → no update
+ expect(applyExpansion({ name: 'V', arcType: '' }, { arcType: 'redemption' }).updatedFields)
+ .toEqual([]);
+ });
+
+ it('does NOT clobber a populated arcType', () => {
+ const { merged, updatedFields } = applyExpansion({ name: 'V', arcType: 'negative' }, { arcType: 'positive' });
+ expect(merged.arcType).toBe('negative');
+ expect(updatedFields).toEqual([]);
+ });
+
+ it('fills only the unset slider axes, preserving user-rated ones', () => {
+ const target = { name: 'V', sliders: { proactivity: 9, likability: null, competence: null } };
+ const content = { sliders: { proactivity: 3, likability: 4, competence: 8 } };
+ const { merged, updatedFields } = applyExpansion(target, content);
+ // proactivity stays user's 9; the two null axes fill from the proposal.
+ expect(merged.sliders).toEqual({ proactivity: 9, likability: 4, competence: 8 });
+ expect(updatedFields).toEqual(['sliders']);
+ });
+
+ it('no-ops sliders when every axis is already set or every proposal is invalid', () => {
+ const bothSet = applyExpansion(
+ { name: 'V', sliders: { proactivity: 5, likability: 5, competence: 5 } },
+ { sliders: { proactivity: 9, likability: 9, competence: 9 } },
+ );
+ expect(bothSet.updatedFields).toEqual([]);
+ const allInvalid = applyExpansion(
+ { name: 'V', sliders: { proactivity: null, likability: null, competence: null } },
+ { sliders: { proactivity: 99, likability: 0, competence: 'x' } },
+ );
+ expect(allInvalid.updatedFields).toEqual([]);
+ });
+
+ it('fills the framework prose chain + secrets like any string/list field', () => {
+ const target = { name: 'V', ghost: '', lie: '', need: '', secrets: [] };
+ const content = { ghost: 'a wound', lie: 'I must win', need: 'I am enough', secrets: ['hidden'] };
+ const { merged, updatedFields } = applyExpansion(target, content);
+ expect(merged.ghost).toBe('a wound');
+ expect(merged.lie).toBe('I must win');
+ expect(merged.need).toBe('I am enough');
+ expect(merged.secrets).toEqual(['hidden']);
+ expect(updatedFields).toEqual(expect.arrayContaining(['ghost', 'lie', 'need', 'secrets']));
+ });
});
it('REGRESSION: list proposals whose rows all fail bible sanitization are NOT marked as updated', () => {