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
address review (agy): state the listing sentinel accurately and make the fallback test prove it
Adam Eivy00e02e99966c
diff --git a/server/services/localLlm.js b/server/services/localLlm.jsindex a105462de7..76d7ca0b43 100644--- a/server/services/localLlm.js+++ b/server/services/localLlm.js@@ -648,13 +648,17 @@ export async function listModels(backend, forceRefresh = false) {* Both managers cache an EMPTY array on a failed read rather than throwing, so* `[]` alone is ambiguous — and collapsing an unreadable list into "this* backend has no models" is exactly the failure the sentinel rule in AGENTS.md- * forbids. Each manager's own error getter is the authoritative signal, so a- * caller that must not treat a transient daemon outage as an empty catalog- * reads `error` and falls back to whatever it had before.+ * forbids. **`error` is the authoritative signal, not `models`**: a failed read+ * comes back as `{ models: [], error: '<why>' }`, because that empty array is+ * genuinely what the manager is holding. A caller that must not treat a+ * transient daemon outage as an empty catalog checks `error` first and falls+ * back to whatever it had before.** @param {string} backend - 'ollama' | 'lmstudio'- * @returns {Promise<{ models: Array|null, error: string|null }>} `models: null`- * means the listing was not readable.+ * @returns {Promise<{ models: Array|null, error: string|null }>} A non-null+ * `error` means the listing was not readable, whatever `models` holds;+ * `models: null` additionally means there was no list to hold at all (the+ * call threw, or the backend name is unknown).*/export async function listManagedBackendModels(backend, forceRefresh = false) {if (!isBackend(backend)) return { models: null, error: `unknown backend '${backend}'` }diff --git a/server/services/localLlm.test.js b/server/services/localLlm.test.jsindex 6363dc959a..b05116a18a 100644--- a/server/services/localLlm.test.js+++ b/server/services/localLlm.test.js@@ -958,6 +958,9 @@ describe('listManagedBackendModels', () => {expect(await svc.listManagedBackendModels('ollama')).toEqual({ models: [], error: null });});+ // The failed read still surfaces the empty array the manager is holding — the+ // `error` is what separates it from the genuinely-empty case above, so a+ // caller keying on `models.length` alone would still get this wrong.it('separates an unreadable list from an empty one', async () => {mocks.lmstudio.getAvailableModels.mockResolvedValueOnce([]);mocks.lmstudio.getLastListError.mockReturnValueOnce('LM Studio is unavailable');diff --git a/server/services/persistentMindTaskCapability.test.js b/server/services/persistentMindTaskCapability.test.jsindex 154f846523..8a683e40b8 100644--- a/server/services/persistentMindTaskCapability.test.js+++ b/server/services/persistentMindTaskCapability.test.js@@ -187,6 +187,9 @@ describe('persistent mind CoS-task capability', () => {mocks.listManagedBackendModels.mockResolvedValue({ models: [], error: 'daemon not running' });const catalog = await readPersistentMindTaskCatalog();+ // Asserting the call as well as the result: without it this passes just as+ // green against a build that never consults the daemon at all.+ expect(mocks.listManagedBackendModels).toHaveBeenCalledWith('ollama');expect(catalog.providers[0].models.map((model) => model.id)).toEqual(['qwen3-coder:30b']);});