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

address review (codex): keep object/place LoRAs out of character matches

[._.]/ Adam Eivy0e77c789ece4
diff --git a/server/services/characterLoraResolver.js b/server/services/characterLoraResolver.js
index 913848f2a9..a721db11db 100644
--- a/server/services/characterLoraResolver.js
+++ b/server/services/characterLoraResolver.js
@@ -5,16 +5,24 @@
* simply doesn't list it, so resolution degrades to "no LoRA" with no
* dangling links.
*
- * Matching: a trained sidecar carries `character: { entryId, ingredientId,
- * universeId, name }`. Canon entries are keyed by per-universe `entryId`
- * AND catalog `ingredientId` — match on either, since some surfaces (the
- * catalog detail page) only know the ingredient id.
+ * Matching: a trained sidecar carries `character: { entryId, entryKind,
+ * ingredientId, universeId, name }`. Canon entries are keyed by per-universe
+ * `entryId` AND catalog `ingredientId` — match on either, since some surfaces
+ * (the catalog detail page) only know the ingredient id.
+ *
+ * Both resolution paths here are CHARACTER lookups, so a non-character
+ * trained LoRA (object/place datasets now carry `entryKind: 'objects'|'places'`)
+ * must never match — otherwise, in the newly supported case where the same
+ * entry id exists in multiple bible kinds, an object/place LoRA would be
+ * auto-applied to a character render. A legacy sidecar with no `entryKind`
+ * predates the object/place feature and is therefore a character.
*/
import { listLoras } from './loras.js';
const matchesCharacter = (sidecarCharacter, { entryId = null, ingredientId = null }) => {
if (!sidecarCharacter) return false;
+ if ((sidecarCharacter.entryKind || 'characters') !== 'characters') return false;
if (entryId && sidecarCharacter.entryId === entryId) return true;
if (ingredientId && sidecarCharacter.ingredientId === ingredientId) return true;
return false;
diff --git a/server/services/characterLoraResolver.test.js b/server/services/characterLoraResolver.test.js
index 3bc4c3aa4c..a859b7cff8 100644
--- a/server/services/characterLoraResolver.test.js
+++ b/server/services/characterLoraResolver.test.js
@@ -72,6 +72,22 @@ describe('resolveCharacterLoras', () => {
expect(await resolveCharacterLoras([])).toEqual([]);
expect(listLoras).not.toHaveBeenCalled();
});
+
+ it('never matches a non-character LoRA sharing the entry id', async () => {
+ // Same entryId in two bible kinds: only the character LoRA may apply.
+ listLoras.mockResolvedValue([
+ trainedLora({
+ filename: 'obj.safetensors',
+ character: { entryId: 'char-1', entryKind: 'objects', name: 'Truthbreaker' },
+ }),
+ ]);
+ expect(await resolveCharacterLoras([{ id: 'char-1' }])).toHaveLength(0);
+ });
+
+ it('treats a legacy sidecar with no entryKind as a character', async () => {
+ listLoras.mockResolvedValue([trainedLora({ character: { entryId: 'char-1', name: 'Kessa' } })]);
+ expect(await resolveCharacterLoras([{ id: 'char-1' }])).toHaveLength(1);
+ });
});
describe('findLorasByCharacter', () => {
@@ -86,4 +102,11 @@ describe('findLorasByCharacter', () => {
expect(await findLorasByCharacter({})).toEqual([]);
expect(listLoras).not.toHaveBeenCalled();
});
+
+ it('excludes object/place LoRAs from a character lookup', async () => {
+ listLoras.mockResolvedValue([
+ trainedLora({ filename: 'place.safetensors', character: { entryId: 'char-1', entryKind: 'places', name: 'Shore' } }),
+ ]);
+ expect(await findLorasByCharacter({ entryId: 'char-1' })).toEqual([]);
+ });
});