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: defer model import supervision and runtime checks until use

[._.]/ Adam Eivy3f08c50fafae
diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.js
index 5c72e25c04..2d73a602eb 100644
--- a/server/lib/importScoping.test.js
+++ b/server/lib/importScoping.test.js
@@ -284,6 +284,10 @@ describe('instance identity stays a leaf (#6836)', () => {
// [entry, target, why, specifier] — same first three columns as NARROWED above,
// plus the specifier the call site must still name in its `await import()`.
const DEFERRED = [
+ ['services/ollamaManager.js', 'services/ollamaSafetensorsImport.js',
+ 'loads staging and child supervision only for a curated Safetensors import', './ollamaSafetensorsImport.js'],
+ ['services/aiProvider.js', 'services/providerExecutionReadiness.js',
+ 'loads managed runtime readiness only for an actual inference call', './providerExecutionReadiness.js'],
['services/codeReview.js', 'services/lmStudioManager.js',
'reads the live endpoint only for a selected LM Studio review', './lmStudioManager.js'],
['services/codeReview.js', 'services/ollamaManager.js',
@@ -346,6 +350,8 @@ describe('deferred imports stay deferred (#6156)', () => {
// Positive control, mirroring the one above: these targets are real modules
// with real graphs, so a resolver gap can't be what makes the negatives pass.
it('still sees the deferred modules from their own entry points', () => {
+ expect(reaches('services/ollamaSafetensorsImport.js', 'lib/openFileHolders.js')).toBe(true);
+ expect(reaches('services/providerExecutionReadiness.js', 'services/ollamaManager.js')).toBe(true);
expect(reaches('services/persistentMindAdapter.js', 'services/cosToolRegistry.js')).toBe(true);
expect(reaches('services/tuiPromptRunner.js', 'services/shell.js')).toBe(true);
});
diff --git a/server/services/aiProvider.js b/server/services/aiProvider.js
index fdcc110cca..d2adc2dd7c 100644
--- a/server/services/aiProvider.js
+++ b/server/services/aiProvider.js
@@ -6,7 +6,6 @@
import { normalizeReviewFinishReason } from '../lib/reviewerHealth.js';
import { getAllProviders } from './providers.js';
import { startAIOp } from './aiStatusEvents.js';
-import { ensureManagedRuntimeReady } from './providerExecutionReadiness.js';
// localModelHealing is lazy-imported at its (rare, error-recovery) call site
// below — a static import here pulls its notifications/providers deps (which
// eagerly import fileUtils `PATHS`) into every aiProvider consumer's module
@@ -539,6 +538,8 @@ export async function callProviderAISimple(provider, model, prompt, options = {}
// bargain — the only place a simple call refreshes the idle clock, so a
// run that takes an hour still counts as use throughout, and the next call
// doesn't get a bare connection refusal.
+ // Provider selection and parsing need none of the managed daemon graph.
+ const { ensureManagedRuntimeReady } = await import('./providerExecutionReadiness.js');
const ready = await ensureManagedRuntimeReady(provider, {
onStarting: (label) => statusOp.update('provider:starting', `Starting ${label} if needed…`, { providerId: provider.id }),
});
diff --git a/server/services/ollamaManager.js b/server/services/ollamaManager.js
index 53738e8d7a..06e4ad92b2 100644
--- a/server/services/ollamaManager.js
+++ b/server/services/ollamaManager.js
@@ -41,10 +41,6 @@ import { compareSemver } from '../lib/versionUtils.js'
import { createSingleFlight } from '../lib/singleFlight.js'
import { isSafeHfRepoRelativePath } from '../lib/hfCache.js'
import { assessDownloadPreflight, diskInsufficientError, DOWNLOAD_VERDICTS } from '../lib/downloadPreflight.js'
-import {
- awaitStagingRelease, blobStoreSignature, createImportStaging, findImportStaging, removeImportStaging,
- runSupervisedOllamaCreate, stagedFilesComplete, sweepImportStaging, updateImportStaging
-} from './ollamaSafetensorsImport.js'
const execFileAsync = promisify(execFile)
const AVAILABILITY_CACHE_TTL_MS = 30_000
@@ -1637,6 +1633,11 @@ const heldImportResult = (modelId, error, reason) => ({
})
async function runSafetensorsImport({ modelId, repo, subdir, files, headers, onProgress }) {
+ // Ordinary daemon and model reads need none of the staged-import lifecycle.
+ const {
+ awaitStagingRelease, blobStoreSignature, createImportStaging, findImportStaging, removeImportStaging,
+ runSupervisedOllamaCreate, stagedFilesComplete, sweepImportStaging, updateImportStaging
+ } = await import('./ollamaSafetensorsImport.js')
let tempRoot = null
let reuse = false
// A staging directory from an earlier attempt (a stalled create, or a