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: hoist universe bible field caps to server/lib/universeBibleLimits.js (#6818)

[._.]/ Adam Eivyad6b3d6965b0
diff --git a/client/src/services/apiUniverseBuilder.js b/client/src/services/apiUniverseBuilder.js
index 4e3e6f0924..1ddba1e70a 100644
--- a/client/src/services/apiUniverseBuilder.js
+++ b/client/src/services/apiUniverseBuilder.js
@@ -3,17 +3,18 @@ import { request } from './apiCore.js';
export const WORLD_CATEGORIES = ['landscapes', 'environments', 'structures', 'vehicles'];
export const WORLD_CATEGORY_KEY_MAX = 64;
export const COMPOSITE_PROMPT_MAX = 4000;
-// Mirror of the bible-field caps in server/services/universeBuilder.js — used by
-// the Universe Builder + Pipeline forms for maxLength enforcement on inputs.
-export const WORLD_LOGLINE_MAX = 500;
-export const WORLD_PREMISE_MAX = 20000;
-export const WORLD_STYLE_NOTES_MAX = 4000;
-// Mirror of INFLUENCE_ENTRY_MAX + INFLUENCES_PER_LIST_MAX in
-// server/services/universeBuilder.js — used by the chip editor for maxLength
-// enforcement and to bound paste-floods of refs.
-export const WORLD_INFLUENCE_ENTRY_MAX = 120;
-export const WORLD_INFLUENCES_PER_LIST_MAX = 30;
-export const WORLD_STYLE_REFERENCES_MAX = 20;
+// Universe bible field caps — used by the Universe Builder + Pipeline forms
+// for maxLength enforcement on inputs, and the chip editor to bound
+// paste-floods of influence refs. Re-exported from the shared leaf so this,
+// the sanitizer, and the pipeline series stage can't drift apart (#6818).
+export {
+ LOGLINE_MAX as WORLD_LOGLINE_MAX,
+ PREMISE_MAX as WORLD_PREMISE_MAX,
+ STYLE_NOTES_MAX as WORLD_STYLE_NOTES_MAX,
+ INFLUENCE_ENTRY_MAX as WORLD_INFLUENCE_ENTRY_MAX,
+ INFLUENCES_PER_LIST_MAX as WORLD_INFLUENCES_PER_LIST_MAX,
+ STYLE_REFERENCES_MAX as WORLD_STYLE_REFERENCES_MAX,
+} from '../../../server/lib/universeBibleLimits.js';
// Every request whose response completes a persisted universe write outside the
// general draft snapshot is tracked here, including LLM-backed mutations.
@@ -253,16 +254,9 @@ export const refineWorldPrompts = ({
}),
});
-// Mirror of LOCKABLE_FIELDS in server/services/universeBuilder.js — the lock UI
-// iterates this so a new lockable field only needs adding in two places.
-export const WORLD_LOCKABLE_FIELDS = [
- 'starterPrompt',
- 'logline',
- 'premise',
- 'styleNotes',
- 'influencesEmbrace',
- 'influencesAvoid',
-];
+// The lock UI iterates this so a new lockable field only needs adding in two
+// places. Re-exported from the shared leaf (#6818).
+export { LOCKABLE_FIELDS as WORLD_LOCKABLE_FIELDS } from '../../../server/lib/universeBibleLimits.js';
// Coerce whatever shape the server / draft / patch hands us into a strict
// `{ embrace: [], avoid: [] }` so consumers never have to guard undefined.
diff --git a/server/lib/universeBibleLimits.js b/server/lib/universeBibleLimits.js
new file mode 100644
index 0000000000..b7b448c4e4
--- /dev/null
+++ b/server/lib/universeBibleLimits.js
@@ -0,0 +1,23 @@
+/**
+ * Universe bible field size limits — shared between server (sanitizer,
+ * pipeline) and client (form inputs). A universe bible field that must
+ * carry distinct economies, jurisdictions, travel rules, route logistics,
+ * and several sites can legitimately need well beyond 8k; these remain
+ * runaway-payload guards, not instructions to crush readable prose.
+ */
+
+export const LOGLINE_MAX = 500;
+export const PREMISE_MAX = 20000;
+export const STYLE_NOTES_MAX = 4000;
+export const INFLUENCE_ENTRY_MAX = 120;
+export const INFLUENCES_PER_LIST_MAX = 30;
+export const STYLE_REFERENCES_MAX = 20;
+
+export const LOCKABLE_FIELDS = Object.freeze([
+ 'starterPrompt',
+ 'logline',
+ 'premise',
+ 'styleNotes',
+ 'influencesEmbrace',
+ 'influencesAvoid',
+]);
diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.js
index 2f8b82c506..e1288dc1ac 100644
--- a/server/services/pipeline/series.js
+++ b/server/services/pipeline/series.js
@@ -18,6 +18,7 @@ import { sanitizeArc, sanitizeSeasonList } from '../../lib/storyArc.js';
import { sanitizeCharacterArcList } from '../../lib/seriesCharacterArc.js';
import { sanitizeStyleGuide } from '../../lib/styleGuide.js';
import { sanitizeProseExportSettings } from '../../lib/proseExportSettings.js';
+import { LOGLINE_MAX, PREMISE_MAX, STYLE_NOTES_MAX } from '../../lib/universeBibleLimits.js';
import { sanitizeSeverityWeights, sanitizeBlockingSeverities } from '../../lib/editorial/severityConfig.js';
import { CHECK_SEVERITIES } from '../../lib/editorial/checkInfra/taxonomy.js';
import { sanitizeOrigin } from '../../lib/sharingOrigin.js';
@@ -53,11 +54,7 @@ const makeErr = (message, code) => Object.assign(new Error(message), { code });
const SERIES_ID_RE = /^ser-[A-Za-z0-9-]+$/;
export const NAME_MAX = 200;
-export const LOGLINE_MAX = 500;
-// Large enough for a multi-site production bible with concrete route and
-// resource rules; still bounded so the field cannot become an unbounded prompt.
-export const PREMISE_MAX = 20000;
-export const STYLE_NOTES_MAX = 4000;
+export { LOGLINE_MAX, PREMISE_MAX, STYLE_NOTES_MAX };
// Author-supplied real-world fact reference (#1588) — the ground-truth facts the
// opt-in `research.fact-accuracy` editorial check reconciles the prose against
// (e.g. "Paris is the capital of France"; physiological limits). Generous cap so
diff --git a/server/services/universeBuilder/sanitize.js b/server/services/universeBuilder/sanitize.js
index 5239204039..9d791d0424 100644
--- a/server/services/universeBuilder/sanitize.js
+++ b/server/services/universeBuilder/sanitize.js
@@ -18,6 +18,9 @@ import {
} from '../../lib/storyBible.js';
import { sanitizeOrigin } from '../../lib/sharingOrigin.js';
import { sanitizeSoftDeleteFields } from '../../lib/syncWire.js';
+import {
+ LOGLINE_MAX, PREMISE_MAX, STYLE_NOTES_MAX, INFLUENCE_ENTRY_MAX, INFLUENCES_PER_LIST_MAX, STYLE_REFERENCES_MAX, LOCKABLE_FIELDS,
+} from '../../lib/universeBibleLimits.js';
import { persistedRenderPinFields } from '../../lib/renderTargets.js';
// RECORD-shape schema version, stamped INSIDE each universe record. Distinct
@@ -62,14 +65,9 @@ export const COMPOSITE_PROMPT_MAX = 4000;
export const VARIATION_LABEL_MAX = 120;
// Narrative bible fields — surfaced into the Pipeline "new series" form so a
// universe's logline/premise/style notes can seed a production series in one click.
-export const LOGLINE_MAX = 500;
-// Match the production-series premise ceiling. A universe premise that must
-// carry distinct economies, jurisdictions, travel rules, route logistics, and
-// several sites can legitimately need well beyond 8k; this remains a
-// runaway-payload guard, not an instruction to crush readable bible prose into
-// an abbreviation ledger.
-export const PREMISE_MAX = 20000;
-export const STYLE_NOTES_MAX = 4000;
+// Shared limits and lockable-fields list now live in server/lib/universeBibleLimits.js
+// (imported above).
+export { LOGLINE_MAX, PREMISE_MAX, STYLE_NOTES_MAX, INFLUENCE_ENTRY_MAX, INFLUENCES_PER_LIST_MAX, STYLE_REFERENCES_MAX, LOCKABLE_FIELDS };
// Linked mood board pointer (`mb-<uuid>`, #4188) — generous cap for the id.
export const MOOD_BOARD_ID_MAX = 80;
export const VARIATIONS_PER_CATEGORY_MAX = 50;
@@ -96,24 +94,8 @@ export const ENTRY_REF_KIND = Object.freeze({
// prompts. Surfaced in the UI as "Style prompt" (embrace) and "Negative prompt"
// (avoid) and managed via the draggable-chip editor. Joined verbatim with the
// per-variation prompt at render-compile time.
-export const INFLUENCE_ENTRY_MAX = 120;
-export const INFLUENCES_PER_LIST_MAX = 30;
export const STYLE_REFERENCE_TITLE_MAX = 120;
export const STYLE_REFERENCE_PROMPT_MAX = 4000;
-export const STYLE_REFERENCES_MAX = 20;
-
-// Top-level fields the user can lock against AI-driven changes (refine /
-// expand). When a field is locked, both the refiner and the expansion-merge
-// must preserve the user's value verbatim. Categories + composite sheets are
-// not lockable yet — start with the bible/prompt scalars the user owns.
-export const LOCKABLE_FIELDS = Object.freeze([
- 'starterPrompt',
- 'logline',
- 'premise',
- 'styleNotes',
- 'influencesEmbrace',
- 'influencesAvoid',
-]);
// Human-readable labels for lockable fields. Single source of truth for the
// LLM prompt builders (refine emits "starter idea", expand emits "STARTER IDEA"