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

fix: exclude non-visual framework fields from vision-expand + stable secret row ids (#2175)

Adam Eivy2d0262aa628c
diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsx
index 2254b23914..e121345ded 100644
--- a/client/src/components/universe/CharacterDetailEditor.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.jsx
@@ -248,9 +248,21 @@ function ListSectionEditor({ section, entry, onPatchList, disabled }) {
// 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;
+ // Stamp a CONTENT-derived stable id on each marshalled string-list row so
+ // ListRow's React key (and its `useRowDraft` buffer) survives a delete/reorder
+ // of an earlier row — a plain index key would shift a sibling's draft onto the
+ // wrong secret, the exact footgun the ListRow key comment warns about. The
+ // per-content occurrence counter disambiguates exact-duplicate strings.
+ const stringListRows = () => {
+ const seen = new Map();
+ return rawPersisted.map((s) => {
+ const text = typeof s === 'string' ? s : '';
+ const n = seen.get(text) || 0;
+ seen.set(text, n + 1);
+ return { id: `${section.key}-${n}-${text}`, [col0]: text };
+ });
+ };
+ const persisted = section.stringList ? stringListRows() : rawPersisted;
const emit = (next) => onPatchList(
section.field,
section.stringList
diff --git a/server/services/universeVisionExpand.js b/server/services/universeVisionExpand.js
index 8262bcaad7..ca769b164f 100644
--- a/server/services/universeVisionExpand.js
+++ b/server/services/universeVisionExpand.js
@@ -56,6 +56,16 @@ const LIST_FIELD_SHAPES = {
handGestures: '{ "name": "<gesture>", "description": "<the hand pose>" }',
};
+// Non-visual character-framework fields (CWQE Phase 10, #2175). They live in the
+// shared STRING_FIELDS / LIST_FIELDS lists (the text/vision expand flows share
+// one source of truth) but a vision model CANNOT infer a character's Ghost, Lie,
+// Want, Need, or secrets from an image — those are narrative, not renderable. So
+// the vision prompt excludes them (they'd only invite hallucinated backstory,
+// and `secrets` has no LIST_FIELD_SHAPES row shape to emit). arcType / sliders
+// are already absent from both shared lists (merged specially in the text flow),
+// so they never reach the vision prompt either.
+const NON_VISUAL_FRAMEWORK_FIELDS = new Set(['ghost', 'wound', 'lie', 'want', 'need', 'secrets']);
+
/**
* Build the vision prompt. The model is told to return ONE JSON object keyed by
* the structured character fields, populating only those it can infer from the
@@ -74,12 +84,16 @@ export function buildVisionExpandPrompt({ name, context, imageCount = 1, blankFi
// Narrow the ask to the fields that are still blank when we have that list;
// otherwise offer the full set. Populated fields are no-clobber server-side
// regardless, so this is purely to focus the model.
+ // Non-visual framework fields (ghost/lie/…/secrets) are never asked of a
+ // vision model — filter them out of both the full-set and blank-narrowed asks.
+ const visualStringFields = STRING_FIELDS.filter((f) => !NON_VISUAL_FRAMEWORK_FIELDS.has(f));
+ const visualListFields = LIST_FIELDS.filter((f) => !NON_VISUAL_FRAMEWORK_FIELDS.has(f));
const stringTargets = blankFields.length
- ? STRING_FIELDS.filter((f) => blankFields.includes(f))
- : STRING_FIELDS;
+ ? visualStringFields.filter((f) => blankFields.includes(f))
+ : visualStringFields;
const listTargets = blankFields.length
- ? LIST_FIELDS.filter((f) => blankFields.includes(f))
- : LIST_FIELDS;
+ ? visualListFields.filter((f) => blankFields.includes(f))
+ : visualListFields;
const stringLines = stringTargets.map((f) => ` "${f}": "<string>"`).join(',\n');
const listLines = listTargets
diff --git a/server/services/universeVisionExpand.test.js b/server/services/universeVisionExpand.test.js
index f6554d7678..c20daae1af 100644
--- a/server/services/universeVisionExpand.test.js
+++ b/server/services/universeVisionExpand.test.js
@@ -68,6 +68,23 @@ describe('buildVisionExpandPrompt', () => {
expect(p).toMatch(/"handGestures"/);
});
+ it('excludes non-visual character-framework fields from the vision prompt (#2175)', () => {
+ // A vision model cannot infer Ghost/Lie/Want/Need/secrets from an image, and
+ // `secrets` has no list row-shape — asking for them would invite hallucinated
+ // backstory / emit `[ undefined ]`. They must never reach the vision schema,
+ // in either the full-set or blank-narrowed ask.
+ const full = buildVisionExpandPrompt({ imageCount: 1 });
+ for (const f of ['ghost', 'wound', 'lie', 'want', 'need', 'secrets']) {
+ expect(full).not.toMatch(new RegExp(`"${f}"`));
+ }
+ // Even when a framework field is blank (and would otherwise be "targeted"),
+ // it is filtered out — while a real visual field in the same list still shows.
+ const narrowed = buildVisionExpandPrompt({ imageCount: 1, blankFields: ['lie', 'secrets', 'pronouns'] });
+ expect(narrowed).not.toMatch(/"lie"/);
+ expect(narrowed).not.toMatch(/"secrets"/);
+ expect(narrowed).toMatch(/"pronouns"/);
+ });
+
it('is re-exported on __testing', () => {
expect(__testing.buildVisionExpandPrompt).toBe(buildVisionExpandPrompt);
});