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

fix: preserve world repair reasoning effort

[._.]/ Adam Eivyf8f51951f7c1
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 90a1c5aaea..f50b549078 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -28,6 +28,8 @@
## Fixed
+- Preserve a Series Autopilot run's reasoning-effort override when the foundation gate delegates a worldbuilding repair to Universe Builder.
+
- **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/server/services/pipeline/foundationJudge.js b/server/services/pipeline/foundationJudge.js
index 567a6660b5..d89fd86ba3 100644
--- a/server/services/pipeline/foundationJudge.js
+++ b/server/services/pipeline/foundationJudge.js
@@ -1006,7 +1006,7 @@ async function repairCraft(series, issues, finding, options) {
// no-clobber) — then persist through updateUniverse (serialized write queue).
// Mirrors storyBuilder.js's `universeAesthetic` step. Returns false when there's
// no universe to refine.
-async function refineWorld(universeId, { providerId, model, finding = {} }) {
+async function refineWorld(universeId, { providerId, model, effort, finding = {} }) {
if (!universeId) return { applied: false, reason: 'no linked universe' };
const universe = await getUniverse(universeId).catch(() => null);
if (!universe) return { applied: false, reason: 'universe not found' };
@@ -1020,6 +1020,7 @@ async function refineWorld(universeId, { providerId, model, finding = {} }) {
foundationDirective: [finding.gap, finding.fix].filter(Boolean).join('\nRequested repair: '),
providerId,
model,
+ effort,
});
// Persist through the write-queue mutator against the FRESHEST record, and
// defensively DROP any field the user has locked — expandWorldTemplate is
diff --git a/server/services/pipeline/foundationJudge.test.js b/server/services/pipeline/foundationJudge.test.js
index 37fa9e459c..fa2f344ad2 100644
--- a/server/services/pipeline/foundationJudge.test.js
+++ b/server/services/pipeline/foundationJudge.test.js
@@ -567,10 +567,18 @@ describe('applyFoundationFix — dimension → owning-service routing table', ()
universeBuilder.getUniverse.mockResolvedValue(uni);
let writtenPatch = null;
universeBuilder.updateUniverse.mockImplementation(async (id, m) => { writtenPatch = typeof m === 'function' ? m(uni) : m; return { id, ...(writtenPatch || {}) }; });
- const r = await applyFoundationFix('ser-1', 'worldbuilding', { finding: { gap: 'costless magic', fix: 'make memory the price' } });
+ const r = await applyFoundationFix('ser-1', 'worldbuilding', {
+ finding: { gap: 'costless magic', fix: 'make memory the price' },
+ providerOverride: 'codex-tui',
+ modelOverride: 'gpt-5.6-sol',
+ effortOverride: 'ultra',
+ });
expect(universeBuilderExpand.expandWorldTemplate).toHaveBeenCalledWith(expect.objectContaining({
starterPrompt: 'U',
foundationDirective: expect.stringContaining('costless magic'),
+ providerId: 'codex-tui',
+ model: 'gpt-5.6-sol',
+ effort: 'ultra',
}));
expect(writtenPatch).toMatchObject({ logline: 'L2', premise: 'P2', styleNotes: 'S2' });
expect(r).toMatchObject({ dimension: 'worldbuilding', applied: true });
diff --git a/server/services/universeBuilderExpand.effort.test.js b/server/services/universeBuilderExpand.effort.test.js
new file mode 100644
index 0000000000..7131677e0d
--- /dev/null
+++ b/server/services/universeBuilderExpand.effort.test.js
@@ -0,0 +1,54 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const { resolveProviderAndModelMock, runPromptThroughProviderMock } = vi.hoisted(() => ({
+ resolveProviderAndModelMock: vi.fn(),
+ runPromptThroughProviderMock: vi.fn(),
+}));
+
+vi.mock('../lib/promptRunner.js', () => ({
+ assertProvider: vi.fn(),
+ resolveProviderAndModel: (...args) => resolveProviderAndModelMock(...args),
+ runPromptThroughProvider: (...args) => runPromptThroughProviderMock(...args),
+}));
+
+const { expandWorldTemplate } = await import('./universeBuilderExpand.js');
+
+const provider = { id: 'codex-tui', name: 'Codex TUI', type: 'tui' };
+
+beforeEach(() => {
+ resolveProviderAndModelMock.mockReset();
+ runPromptThroughProviderMock.mockReset();
+ resolveProviderAndModelMock.mockResolvedValue({ provider, selectedModel: 'gpt-5.6-sol' });
+ runPromptThroughProviderMock.mockResolvedValue({
+ text: JSON.stringify({
+ logline: 'A repaired world.',
+ premise: 'Costs and limits now drive the conflict.',
+ styleNotes: 'Specific and tactile.',
+ influences: { embrace: [], avoid: [] },
+ categories: {},
+ compositeSheets: [],
+ characters: [],
+ places: [],
+ objects: [],
+ }),
+ runId: 'run-world-repair',
+ });
+});
+
+describe('expandWorldTemplate reasoning effort', () => {
+ it('forwards a caller effort override to the provider runner', async () => {
+ await expandWorldTemplate({
+ starterPrompt: 'Example Universe',
+ providerId: 'codex-tui',
+ model: 'gpt-5.6-sol',
+ effort: 'ultra',
+ });
+
+ expect(runPromptThroughProviderMock).toHaveBeenCalledWith(expect.objectContaining({
+ provider,
+ model: 'gpt-5.6-sol',
+ effort: 'ultra',
+ source: 'universe-builder-expansion',
+ }));
+ });
+});
diff --git a/server/services/universeBuilderExpand.js b/server/services/universeBuilderExpand.js
index d6acb2dfed..527468ba42 100644
--- a/server/services/universeBuilderExpand.js
+++ b/server/services/universeBuilderExpand.js
@@ -337,6 +337,7 @@ const normalizeCanonArray = (raw, kind) => {
* @param {string} options.starterPrompt
* @param {string} [options.providerId] — optional override; falls back to active.
* @param {string} [options.model] — optional override; falls back to provider default.
+ * @param {string} [options.effort] — optional reasoning-effort override for capable providers.
*/
export async function expandWorldTemplate({
starterPrompt,
@@ -353,6 +354,7 @@ export async function expandWorldTemplate({
foundationDirective = '',
providerId,
model,
+ effort,
} = {}) {
if (!starterPrompt || !starterPrompt.trim()) {
throw new Error("starterPrompt is required");
@@ -394,6 +396,7 @@ export async function expandWorldTemplate({
const { text: raw, runId } = await runPromptThroughProvider({
provider,
model: selectedModel,
+ effort,
prompt: fullPrompt,
source: "universe-builder-expansion",
});