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

refactor([extract-mergeexpandintodraft-draft-result-from]): source canon cap from BIBLE_LIMITS

[._.]/ Adam Eivy08a43cf3dd80
diff --git a/client/src/lib/universeBuilderExpand.js b/client/src/lib/universeBuilderExpand.js
index 7e8c759464..664c6febce 100644
--- a/client/src/lib/universeBuilderExpand.js
+++ b/client/src/lib/universeBuilderExpand.js
@@ -27,13 +27,15 @@
// are preserved and merged ahead of LLM output.
// - Canon arrays merge by name/slugline/alias collision (existing wins).
import { mergeInfluencesWithLocks } from '../services/api';
+import { BIBLE_LIMITS } from './bibleLimits';
import { normalizeSlugline } from './scenePrompt';
-// Match server's BIBLE_LIMITS.ENTRIES_PER_BIBLE_MAX so the client doesn't
-// optimistically display + count entries the server will silently truncate
-// at sanitize time. Without this cap, the post-expand toast can claim
-// "+12 canon entries" while the server-saved record only kept some of them.
-export const CLIENT_CANON_MAX = 200;
+// Aliased so the call site in mergeCanonByName reads naturally. Sourced from
+// the BIBLE_LIMITS mirror so the client doesn't optimistically display +
+// count entries the server will silently truncate at sanitize time. Without
+// this cap, the post-expand toast can claim "+12 canon entries" while the
+// server-saved record only kept some of them.
+const CANON_ENTRIES_CAP = BIBLE_LIMITS.ENTRIES_PER_BIBLE_MAX;
// Merge two variation arrays under a single category bucket. Locked rows
// (already filtered upstream into `existing`) come first; LLM-supplied
@@ -112,7 +114,7 @@ export const mergeCanonByName = (existing, fresh, kind = 'character') => {
if (sluglineKey) seen.add(sluglineKey);
for (const k of aliasMatches) seen.add(k);
if (collides) continue;
- if (merged.length >= CLIENT_CANON_MAX) break;
+ if (merged.length >= CANON_ENTRIES_CAP) break;
merged.push(e);
}
return merged;
diff --git a/client/src/lib/universeBuilderExpand.test.js b/client/src/lib/universeBuilderExpand.test.js
index c12dbafd76..b4249e71f3 100644
--- a/client/src/lib/universeBuilderExpand.test.js
+++ b/client/src/lib/universeBuilderExpand.test.js
@@ -1,10 +1,10 @@
import { describe, it, expect } from 'vitest';
+import { BIBLE_LIMITS } from './bibleLimits.js';
import {
mergeVariations,
mergeCanonByName,
extractPreservedFromDraft,
mergeExpandIntoDraft,
- CLIENT_CANON_MAX,
} from './universeBuilderExpand.js';
// Identity helper used in several lock/clear tests below.
@@ -112,11 +112,12 @@ describe('mergeCanonByName', () => {
expect(out).toHaveLength(2);
});
- it('caps merged output at CLIENT_CANON_MAX (mirror of server BIBLE_LIMITS)', () => {
- const existing = Array.from({ length: CLIENT_CANON_MAX - 1 }, (_, i) => ({ name: `e${i}` }));
+ it('caps merged output at BIBLE_LIMITS.ENTRIES_PER_BIBLE_MAX', () => {
+ const cap = BIBLE_LIMITS.ENTRIES_PER_BIBLE_MAX;
+ const existing = Array.from({ length: cap - 1 }, (_, i) => ({ name: `e${i}` }));
const fresh = Array.from({ length: 5 }, (_, i) => ({ name: `f${i}` }));
const out = mergeCanonByName(existing, fresh, 'character');
- expect(out).toHaveLength(CLIENT_CANON_MAX);
+ expect(out).toHaveLength(cap);
});
});