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 (codex): canonicalize full 127.0.0.0/8 + bind-all as local
[._.]/ Adam Eivy57a735605a85
diff --git a/server/services/localModelHealing.js b/server/services/localModelHealing.jsindex 0043fdf57c..9c7ee48826 100644--- a/server/services/localModelHealing.js+++ b/server/services/localModelHealing.js@@ -99,16 +99,24 @@ function managerOrigin(backend) {return normalizeOrigin(base);}-// Loopback hosts that all name the same local instance — canonicalized to one-// token so a provider at `127.0.0.1:11434` matches a manager at `localhost:11434`.-const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);+// True when a hostname names the SAME local instance the backend manager runs+// on — any loopback (`127.0.0.0/8`, `::1`), `localhost`, or the unspecified /+// bind-all address (`0.0.0.0`, `::`, which a manager bound to all interfaces+// reports while a provider reaches it as localhost). These all canonicalize to+// one token so spelling differences don't block healing. Deliberately NOT+// link-local / LAN / Tailscale hosts — a peer on another box is a DIFFERENT+// instance whose installed models we must not heal against.+function isLocalInstanceHost(hostname) {+ const h = hostname.toLowerCase().replace(/^\[|\]$/g, ''); // strip IPv6 brackets+ return h === 'localhost' || h === '0.0.0.0' || h === '::' || h === '::1' ||+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);+}function normalizeOrigin(url) {const cleaned = String(url || '').replace(/\/v1\/?$/, '').replace(/\/+$/, '');try {const u = new URL(cleaned);- const hostname = u.hostname.toLowerCase();- const host = LOOPBACK_HOSTS.has(hostname) ? 'localhost' : hostname;+ const host = isLocalInstanceHost(u.hostname) ? 'localhost' : u.hostname.toLowerCase();const port = u.port || (u.protocol === 'https:' ? '443' : '80');return `${u.protocol}//${host}:${port}`;} catch { return ''; }diff --git a/server/services/localModelHealing.test.js b/server/services/localModelHealing.test.jsindex f3cf317c41..5c69302dcf 100644--- a/server/services/localModelHealing.test.js+++ b/server/services/localModelHealing.test.js@@ -169,11 +169,15 @@ describe('healMissingLocalModel', () => {expect(mocks.updateProvider).not.toHaveBeenCalled();});- it('treats loopback host spellings as the same instance (127.0.0.1 == localhost)', async () => {- // Manager lists from localhost:11434; a provider on 127.0.0.1:11434 is the- // SAME instance and must not be refused over a loopback spelling difference.+ it.each([+ ['127.0.0.1', 'http://127.0.0.1:11434/v1'],+ ['127.0.0.53', 'http://127.0.0.53:11434/v1'], // anywhere in 127.0.0.0/8+ ['0.0.0.0 bind-all', 'http://0.0.0.0:11434/v1'] // manager bound to all interfaces, reached as localhost+ ])('treats loopback/bind-all host %s as the same instance as localhost', async (_label, endpoint) => {+ // Manager lists from localhost:11434; these all name the SAME instance and+ // must not be refused over a host-spelling difference.mocks.ollamaInstalled.mockResolvedValue([{ id: 'llama3.1:8b' }]);- const provider = { id: 'ollama', endpoint: 'http://127.0.0.1:11434/v1', defaultModel: 'gone', models: [] };+ const provider = { id: 'ollama', endpoint, defaultModel: 'gone', models: [] };const result = await healMissingLocalModel({ provider, requestedModel: 'gone' });expect(result).toMatchObject({ healed: true, model: 'llama3.1:8b' });});