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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: preserve readable world bible prose
[._.]/ Adam Eivy1cf0c9891b08
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex c1e43c7202..018a25c653 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -54,6 +54,8 @@- Make over-limit world-bible retries compress the rejected draft itself instead of rerunning the original generation prompt. Two progressively tighter headroom passes preserve the draft's names, causal mechanics, costs, jurisdictions, and site operations while removing repetition, so an otherwise strong repair can converge on the persisted contract without regenerating the same oversized answer.+- Raise the Universe Builder premise ceiling from 4,000 to 8,000 characters, matching production series. The former sanity cap forced legitimate multi-site world bibles into abbreviation-heavy ledgers; complete readable prose now persists directly, while the same fail-closed validator and draft-aware compression still contain genuinely runaway responses.+- **A successful agent run is no longer failed just because someone pulled `main` while it worked.** The branch-jack detector — which watches whether a worktree-isolated agent committed into the primary checkout instead of its own worktree — treated *any* movement of the primary as a branch-jack. So an ordinary `git pull` landing an already-merged PR flipped a run that had shipped its own PR into a failure, and told the user to consider `git reset --hard origin/main` over commits that already *were* `origin/main`. The guard now reports what a branch-jack actually leaves behind: commits the branch's upstream does not have, or the checkout parked on a different branch than it started on. A pure fast-forward onto upstream commits is logged as movement and nothing more. When damage is real, the recovery advice is sharper too — it quotes the number of *stranded* commits rather than how far HEAD travelled, and a checkout merely left on the wrong branch with nothing stranded is told to `git checkout` back instead of being pointed at a `--hard` reset that would discard nothing. A branch with no upstream to compare against still reports, since an unpushed commit is unreviewed by definition.- **Recovering an AI provider now affects the very next routed run.** PortOS accidentally kept two in-memory provider-status services over the same JSON file: the Providers UI updated one while the AI Toolkit's runner consulted the other. A manual “Recover now” therefore looked successful and persisted correctly, yet a run started moments later could still bypass the recovered primary and spend time on a fallback. All legacy callers and the PortOS status routes now delegate to the Toolkit-owned singleton, and provider status socket events have one broadcast path instead of being emitted twice.diff --git a/client/src/services/apiUniverseBuilder.js b/client/src/services/apiUniverseBuilder.jsindex 51b6e10c80..b5d6652405 100644--- a/client/src/services/apiUniverseBuilder.js+++ b/client/src/services/apiUniverseBuilder.js@@ -6,7 +6,7 @@ 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 = 4000;+export const WORLD_PREMISE_MAX = 8000;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 maxLengthdiff --git a/server/services/universeBuilder/sanitize.js b/server/services/universeBuilder/sanitize.jsindex e9536f2acf..b71984da23 100644--- a/server/services/universeBuilder/sanitize.js+++ b/server/services/universeBuilder/sanitize.js@@ -63,7 +63,11 @@ 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;-export const PREMISE_MAX = 4000;+// Match the production-series premise ceiling. A universe premise that must+// carry distinct economies, jurisdictions, travel rules, and several sites can+// legitimately need more than 4k; this remains a runaway-payload guard, not an+// instruction to crush readable bible prose into an abbreviation ledger.+export const PREMISE_MAX = 8000;export const STYLE_NOTES_MAX = 4000;export const VARIATIONS_PER_CATEGORY_MAX = 50;export const COMPOSITE_SHEETS_MAX = 50;diff --git a/server/services/universeBuilderExpand.effort.test.js b/server/services/universeBuilderExpand.effort.test.jsindex 4be7852715..caadbb8558 100644--- a/server/services/universeBuilderExpand.effort.test.js+++ b/server/services/universeBuilderExpand.effort.test.js@@ -79,7 +79,7 @@ describe('expandWorldTemplate reasoning effort', () => {.mockResolvedValueOnce({text: JSON.stringify({logline: 'A repaired world.',- premise: 'x'.repeat(4_001),+ premise: 'x'.repeat(8_001),styleNotes: 'Specific and tactile.',}),runId: 'run-oversized',@@ -103,9 +103,9 @@ describe('expandWorldTemplate reasoning effort', () => {});expect(runPromptThroughProviderMock).toHaveBeenCalledTimes(2);- expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise exceeds 4000 characters (got 4001)');+ expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise exceeds 8000 characters (got 8001)');expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain(`"premise": "${'x'.repeat(200)}`);- expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise: at most 3600 characters');+ expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise: at most 7200 characters');expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('Do not cut off a sentence');expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).not.toContain('# Starter idea');expect(result.premise).toBe('Trade, authority, and travel now end in a complete rule.');@@ -117,7 +117,7 @@ describe('expandWorldTemplate reasoning effort', () => {.mockResolvedValueOnce({text: JSON.stringify({logline: 'A repaired world.',- premise: 'a'.repeat(5_000),+ premise: 'a'.repeat(9_000),styleNotes: 'Specific and tactile.',}),runId: 'run-oversized',@@ -125,7 +125,7 @@ describe('expandWorldTemplate reasoning effort', () => {.mockResolvedValueOnce({text: JSON.stringify({logline: 'A repaired world.',- premise: 'b'.repeat(4_200),+ premise: 'b'.repeat(8_200),styleNotes: 'Specific and tactile.',}),runId: 'run-still-oversized',@@ -150,7 +150,7 @@ describe('expandWorldTemplate reasoning effort', () => {expect(runPromptThroughProviderMock).toHaveBeenCalledTimes(3);expect(runPromptThroughProviderMock.mock.calls[2][0].prompt).toContain(`"premise": "${'b'.repeat(200)}`);- expect(runPromptThroughProviderMock.mock.calls[2][0].prompt).toContain('premise: at most 3200 characters');+ expect(runPromptThroughProviderMock.mock.calls[2][0].prompt).toContain('premise: at most 6400 characters');expect(runPromptThroughProviderMock.mock.calls[2][0].prompt).not.toContain(`"premise": "${'a'.repeat(200)}`);expect(result.premise).toBe('A complete, compact operating rule.');});diff --git a/server/services/universeBuilderExpand.js b/server/services/universeBuilderExpand.jsindex bf408023fd..c3f6e4e8c2 100644--- a/server/services/universeBuilderExpand.js+++ b/server/services/universeBuilderExpand.js@@ -118,9 +118,9 @@ ${influencesSection}${currentStateSection}${foundationSection}# Output contractReturn one JSON object with exactly these top-level keys and no others:-- logline: string, one sentence (max 500 characters).-- premise: string, 1-3 concise paragraphs (max 4000 characters) defining the setting, conflict, stakes, and every operational rule needed to satisfy the repair directive.-- styleNotes: string (max 4000 characters) preserving the established tonal and sensory identity while making any worldbuilding guidance concrete enough for writers to apply.+- logline: string, one sentence (max ${LOGLINE_MAX} characters).+- premise: string, 1-3 concise paragraphs (max ${PREMISE_MAX} characters) defining the setting, conflict, stakes, and every operational rule needed to satisfy the repair directive.+- styleNotes: string (max ${STYLE_NOTES_MAX} characters) preserving the established tonal and sensory identity while making any worldbuilding guidance concrete enough for writers to apply.# Repair rules- Resolve the judge's exact contradiction or omission. Do not answer it with extra lore that leaves the named causal problem intact.@@ -165,9 +165,9 @@ ${influencesSection}${currentStateSection}${foundationSection}${preservedSection# Output contractReturn a SINGLE JSON object. NO markdown, NO commentary. The object MUST have these top-level keys:-- logline: string. ONE sentence (≤500 chars) capturing the universe's central tension/hook — protagonist-agnostic if no protagonist is implied. Example: "A foundry city goes silent — and the only survivor is a child."-- premise: string. 1-3 short paragraphs (≤4000 chars total) describing the setting, the central conflict or situation, the stakes, and the tone. Write it as the elevator pitch a showrunner would hand to a writers' room. No bullet points; prose only.-- styleNotes: string. A prose paragraph (≤4000 chars) describing the visual + tonal style for the story bible — references (artists, films, comics, games), mood, palette, pacing, narrative voice. This is read by writers + creative directors, not the image model, so use full sentences instead of comma-separated tokens.+- logline: string. ONE sentence (≤${LOGLINE_MAX} chars) capturing the universe's central tension/hook — protagonist-agnostic if no protagonist is implied. Example: "A foundry city goes silent — and the only survivor is a child."+- premise: string. 1-3 short paragraphs (≤${PREMISE_MAX} chars total) describing the setting, the central conflict or situation, the stakes, and the tone. Write it as the elevator pitch a showrunner would hand to a writers' room. No bullet points; prose only.+- styleNotes: string. A prose paragraph (≤${STYLE_NOTES_MAX} chars) describing the visual + tonal style for the story bible — references (artists, films, comics, games), mood, palette, pacing, narrative voice. This is read by writers + creative directors, not the image model, so use full sentences instead of comma-separated tokens.- influences: object { "embrace": [string], "avoid": [string] }. THIS IS THE UNIVERSE'S STYLE + NEGATIVE PROMPT. Each list is a set of short prompt tokens (max 120 chars each, max 30 per list). The "embrace" list is joined verbatim as the positive style prompt prepended to every render (palette, lighting, render quality, artist references — e.g. "moebius linework", "cel-shading", "dust palette"). The "avoid" list is joined verbatim as the negative prompt (e.g. "blurry", "lowres", "watermark", "extra fingers"). Use short token-style labels, NOT full sentences. When influence input is provided above, preserve those entries unless the starter idea explicitly contradicts them.- characters: array. Named cast members central to this universe. Each item has { "name": string (max 120 chars), "physicalDescription": string (max 1000 chars, what they look like — face, build, age range, distinguishing marks), "personality": string (max 600 chars), "background": string (max 800 chars, where they come from + role in the world), "prompt": string (max 400 chars, the render-prompt fragment used for reference images), "tags": [string] (1-3 short labels like "protagonist", "antagonist", "supporting") }. Generate 0-8 leads. Distinct from category "variations" (which are exploratory render prompts) — these are first-class entities that downstream pipeline stages address by name.- places: array. Named recurring places in this universe. Each item has { "name": string (max 120 chars, human label like "Foundry City"), "slugline": string (max 120 chars, screenplay-style location header like "EXT. FOUNDRY CITY — DAY"), "description": string (max 1000 chars), "palette": string (max 300 chars, dominant colors), "recurringDetails": string (max 600 chars, recognizable motifs that recur across scenes), "prompt": string (max 400 chars, render-prompt fragment), "tags": [string] }. Generate 0-8 key places.