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: keep foundation targets and bibles clear
[._.]/ Adam Eivycdf3d6c6b424
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 384f923ef9..b9c1ad572b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -54,7 +54,7 @@- 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 and production-series premise ceiling from 4,000 to 12,000 characters. The former sanity cap forced legitimate multi-site world bibles with operational route, communications, rescue, and resource rules 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.+- Raise the Universe Builder and production-series premise ceiling from 4,000 to 20,000 characters. The former sanity cap forced legitimate multi-site world bibles with operational route, communications, rescue, ecology, culture, and resource rules 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.@@ -141,6 +141,8 @@## Series Pipeline+- **Foundation results now call the next repair target what it is.** The gate deliberately chooses the largest weight-adjusted deficit, so a worldbuilding score of 8 can be the best next use of a repair round ahead of a structure score of 7. The Autopilot timeline and Series Review called that field the "weakest" dimension, which made the weighting look broken and obscured why a higher raw score ran first. They now say "next target," the options help names the largest weighted deficit, and server telemetry uses the same term; the persisted/API field remains backward-compatible.+- **Character-first planning now finishes the whole story cast instead of repeatedly polishing six people.** The foundation repair selector had a hard top-six cutoff, so a larger ensemble could spend every bounded repair round revisiting the same principals while later story-referenced characters remained blank. It now derives the series roster from authored arcs and issue synopses, processes every referenced character in sequential six-character work batches, and gives each batch the full ensemble map so voices, values and relationships stay differentiated. The foundation judge and its cache use that same series-scoped roster, so undeveloped characters belonging to other stories in a shared universe no longer make this series fail its character gate; before an arc exists, the small fallback remains and the architect may add only genuinely missing core roles.- **A paused Series Autopilot run now resumes with its visual and gap-filing choices intact.** Those two controls were run-local, but the pause marker remembered only the current step and error. Reloading the page or restarting PortOS therefore made the Options form look like a brand-new run: visuals returned to their default and "File CoS tasks" silently turned off, so a later unresolved gap could disappear instead of being tracked. Active and paused markers now carry only those two safe continuation choices, the resume form restores them, and a completed run or different series still gets clean defaults. The one-shot "Unlock everything" consent is deliberately not re-armed: its pass already leaves the records unlocked, and repeating a spent mutation is not part of resuming.diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxindex d1790c2266..bf57d47597 100644--- a/client/src/components/pipeline/AutopilotPanel.jsx+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -273,7 +273,7 @@ function frameLabel(f) {case 'resolve:rollback': return `${f.scope} auto-resolve went from ${f.before} to ${f.after} blocking finding(s) — `+ `${f.reverted ? 'reverted that round' : 'could not revert that round'}`;// #2176 — foundation-gate telemetry.- case 'foundation:round': return `Foundation round ${f.round} — weighted ${f.weightedScore}/${f.threshold}${f.weakest ? ` · weakest: ${f.weakest}` : ''}`;+ case 'foundation:round': return `Foundation round ${f.round} — weighted ${f.weightedScore}/${f.threshold}${f.weakest ? ` · next target: ${f.weakest}` : ''}`;case 'foundation:fix': return `${f.phase === 'pre-arc' ? 'Pre-arc foundation' : 'Foundation fix'} — ${f.dimension}${f.applied ? ' applied' : ` skipped${f.reason ? ` (${f.reason})` : ''}`}`;// #1578 — per-check telemetry forwarded from the editorial-checks runner.case 'check:start': return `Editorial check: ${f.label || f.checkId}…`;@@ -855,7 +855,7 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate/></div><p className="text-[11px] text-gray-500">- Weighted quality bar (0–10: worldbuilding 40%, character 30%, structure 20%, craft 10%) the foundation must clear before drafting; the run improves the weakest dimension up to the round limit, then pauses for review.+ Weighted quality bar (0–10: worldbuilding 40%, character 30%, structure 20%, craft 10%) the foundation must clear before drafting; the run repairs the largest weighted deficit up to the round limit, then pauses for review.</p></>) : null}diff --git a/client/src/components/pipeline/SeriesReviewPanel.jsx b/client/src/components/pipeline/SeriesReviewPanel.jsxindex f655d9d190..2d0d27e631 100644--- a/client/src/components/pipeline/SeriesReviewPanel.jsx+++ b/client/src/components/pipeline/SeriesReviewPanel.jsx@@ -384,7 +384,7 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpda<div className="flex flex-wrap gap-2 text-[11px]">{review.foundation && Number.isFinite(review.foundation.weightedScore) ? (<span className="px-2 py-0.5 rounded border border-port-border bg-port-bg text-gray-300" title={review.foundation.oneLineVerdict || ''}>- Foundation {review.foundation.weightedScore}/10{review.foundation.weakest ? ` · weakest: ${review.foundation.weakest}` : ''}+ Foundation {review.foundation.weightedScore}/10{review.foundation.weakest ? ` · next target: ${review.foundation.weakest}` : ''}</span>) : null}{review.health && Number.isFinite(review.health.score) ? (diff --git a/client/src/services/apiUniverseBuilder.js b/client/src/services/apiUniverseBuilder.jsindex 09fc6d2e24..560a019eba 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 = 12000;+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 maxLengthdiff --git a/server/services/pipeline/foundationJudge.js b/server/services/pipeline/foundationJudge.jsindex a6c2b168a6..3a1456cf6e 100644--- a/server/services/pipeline/foundationJudge.js+++ b/server/services/pipeline/foundationJudge.js@@ -15,7 +15,7 @@* returns a per-dimension `{ score, gap, fix }` and a weighted composite the* autopilot gate spends: proceed once the weighted score clears a configurable* threshold AND every dimension clears its floor; otherwise the bounded improve loop (in- * seriesAutopilot.js `runFoundationGate`) targets the weakest dimension, applies+ * seriesAutopilot.js `runFoundationGate`) targets the largest weighted deficit, applies* the fix through the OWNING service (never a raw write, `force:false`* everywhere), and re-judges.*@@ -664,7 +664,7 @@ export async function judgeFoundation(seriesId, { providerId, model, effort, for...judge,};await saveSnapshot(snapshot);- console.log(`🏛️ foundation judge — series=${seriesId.slice(0, 12)} weighted=${judge.weightedScore} weakest=${weak?.dimension || '—'}(${weak?.score ?? '—'}) via ${judgeProvider.id}/${judgeModel || '(default)'}`);+ console.log(`🏛️ foundation judge — series=${seriesId.slice(0, 12)} weighted=${judge.weightedScore} target=${weak?.dimension || '—'}(${weak?.score ?? '—'}) via ${judgeProvider.id}/${judgeModel || '(default)'}`);return snapshot;}diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.jsindex c9e3594dd6..1d739bee4d 100644--- a/server/services/pipeline/series.js+++ b/server/services/pipeline/series.js@@ -54,7 +54,7 @@ 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 = 12000;+export const PREMISE_MAX = 20000;export const STYLE_NOTES_MAX = 4000;// Author-supplied real-world fact reference (#1588) — the ground-truth facts the// opt-in `research.fact-accuracy` editorial check reconciles the prose againstdiff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.jsindex ed4f0b1201..239963a430 100644--- a/server/services/pipeline/seriesAutopilot/childRuns.js+++ b/server/services/pipeline/seriesAutopilot/childRuns.js@@ -263,7 +263,7 @@ export async function runCharacterFoundation(seriesId, record) {// Foundation-quality convergence loop (#2176). Mirrors runArcVerify but gates on// a WEIGHTED SCORE (not a blocking-findings count): judge the whole foundation,-// and while it's below the threshold, target the weakest dimension, apply the+// and while it's below the threshold, target the largest weighted deficit, apply the// fix through the owning service (universe refine / character expand / arc// resolve — force:false, never a raw write), then re-judge. The re-judge is// content-hash-cached, so an unchanged foundation short-circuits (no LLM) anddiff --git a/server/services/universeBuilder/sanitize.js b/server/services/universeBuilder/sanitize.jsindex 6302775863..96e60c3bd5 100644--- a/server/services/universeBuilder/sanitize.js+++ b/server/services/universeBuilder/sanitize.js@@ -65,10 +65,10 @@ export const VARIATION_LABEL_MAX = 120;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 more than 8k; this remains a+// 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 = 12000;+export const PREMISE_MAX = 20000;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 b59c0b3e19..d58705c8a1 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(12_001),+ premise: 'x'.repeat(20_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 12000 characters (got 12001)');+ expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise exceeds 20000 characters (got 20001)');expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain(`"premise": "${'x'.repeat(200)}`);- expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise: at most 10800 characters');+ expect(runPromptThroughProviderMock.mock.calls[1][0].prompt).toContain('premise: at most 18000 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(13_000),+ premise: 'a'.repeat(21_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(12_200),+ premise: 'b'.repeat(20_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 9600 characters');+ expect(runPromptThroughProviderMock.mock.calls[2][0].prompt).toContain('premise: at most 16000 characters');expect(runPromptThroughProviderMock.mock.calls[2][0].prompt).not.toContain(`"premise": "${'a'.repeat(200)}`);expect(result.premise).toBe('A complete, compact operating rule.');});