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): repoint persisted provider pins on rename
[._.]/ Adam Eivy4e1365d1e93b
diff --git a/scripts/migrations/146-claude-ollama-providers.js b/scripts/migrations/146-claude-ollama-providers.jsindex f886e307e4..f6d22fe859 100644--- a/scripts/migrations/146-claude-ollama-providers.js+++ b/scripts/migrations/146-claude-ollama-providers.js@@ -84,6 +84,57 @@ const CLAUDE_OLLAMA_TUI = {tuiIdleTimeoutMs: 180000,};+// Provider pins live OUTSIDE providers.json: scheduled tasks+// (data/task-schedule.json) and autonomous jobs (data/autonomous-jobs.json)+// persist the chosen provider as a `providerId` / `provider` field (including+// nested pipeline stages). Renaming the provider id above would orphan those+// pins — they'd resolve as "provider not found" and silently fall back to the+// active provider instead of the user's local model. So rewrite them too.+// Generic recursive walk keyed on field name + the EXACT old id (no other field+// legitimately holds the literal string "clawed-ollama", so false positives are+// impossible). Idempotent — a second run finds nothing left to rewrite.+const PIN_KEYS = new Set(['providerId', 'provider']);+const PIN_FILES = ['data/task-schedule.json', 'data/autonomous-jobs.json'];++function rewriteProviderPins(node) {+ let changed = false;+ if (Array.isArray(node)) {+ for (const item of node) {+ if (rewriteProviderPins(item)) changed = true;+ }+ } else if (node && typeof node === 'object') {+ for (const [key, value] of Object.entries(node)) {+ if (PIN_KEYS.has(key) && value === OLD_ID) {+ node[key] = NEW_ID;+ changed = true;+ } else if (value && typeof value === 'object') {+ if (rewriteProviderPins(value)) changed = true;+ }+ }+ }+ return changed;+}++async function rewritePinFile(rootDir, relPath) {+ const filePath = join(rootDir, relPath);+ const raw = await readFile(filePath, 'utf-8').catch((err) => {+ if (err.code === 'ENOENT') return null;+ throw err;+ });+ if (raw == null) return;+ let data;+ try {+ data = JSON.parse(raw);+ } catch (err) {+ console.log(`⚠️ ${relPath}: invalid JSON, skipping pin rewrite (${err.message})`);+ return;+ }+ if (rewriteProviderPins(data)) {+ await writeFile(filePath, `${JSON.stringify(data, null, 2)}\n`);+ console.log(`📝 ${relPath}: repointed ${OLD_ID} provider pins → ${NEW_ID}`);+ }+}+export default {async up({ rootDir }) {const providersPath = join(rootDir, PROVIDERS_REL_PATH);@@ -138,11 +189,17 @@ export default {}}- if (!changed) {+ if (changed) {+ await writeFile(providersPath, `${JSON.stringify(config, null, 2)}\n`);+ } else {console.log(`✅ ${PROVIDERS_REL_PATH}: Claude Ollama providers already present — no change`);- return;}- await writeFile(providersPath, `${JSON.stringify(config, null, 2)}\n`);+ // Repoint persisted provider pins (schedules / autonomous jobs) off the+ // retired id — runs regardless of whether providers.json changed this run,+ // since a pin can outlive the provider entry (e.g. already removed by hand).+ for (const relPath of PIN_FILES) {+ await rewritePinFile(rootDir, relPath);+ }},};diff --git a/scripts/migrations/146-claude-ollama-providers.test.js b/scripts/migrations/146-claude-ollama-providers.test.jsindex 3c08cf3d44..9d0f505fb5 100644--- a/scripts/migrations/146-claude-ollama-providers.test.js+++ b/scripts/migrations/146-claude-ollama-providers.test.js@@ -143,6 +143,48 @@ describe('migration 146 — Claude Ollama providers', () => {expect(readFileSync(providersPath, 'utf-8')).toBe(afterFirst);});+ it('repoints clawed-ollama provider pins in schedules and autonomous jobs', async () => {+ writeJson(providersPath, { providers: { 'clawed-ollama': clawed() } });+ const schedulePath = join(rootDir, 'data/task-schedule.json');+ const jobsPath = join(rootDir, 'data/autonomous-jobs.json');+ writeJson(schedulePath, {+ intervals: {+ security: { providerId: 'clawed-ollama', model: null },+ // nested pipeline stage pin must also be rewritten+ 'code-reviewer': {+ providerId: null,+ taskMetadata: { pipeline: { stages: [{ providerId: 'clawed-ollama' }, { providerId: 'claude-code' }] } },+ },+ other: { providerId: 'codex' }, // untouched+ },+ });+ writeJson(jobsPath, { jobs: [{ id: 'j1', providerId: 'clawed-ollama' }, { id: 'j2', provider: 'clawed-ollama' }, { id: 'j3', providerId: 'claude-code' }] });++ await migration.up({ rootDir });++ const sched = readJson(schedulePath);+ expect(sched.intervals.security.providerId).toBe('claude-ollama');+ expect(sched.intervals['code-reviewer'].taskMetadata.pipeline.stages[0].providerId).toBe('claude-ollama');+ expect(sched.intervals['code-reviewer'].taskMetadata.pipeline.stages[1].providerId).toBe('claude-code'); // untouched+ expect(sched.intervals.other.providerId).toBe('codex'); // untouched++ const jobs = readJson(jobsPath);+ expect(jobs.jobs[0].providerId).toBe('claude-ollama');+ expect(jobs.jobs[1].provider).toBe('claude-ollama');+ expect(jobs.jobs[2].providerId).toBe('claude-code'); // untouched+ });++ it('leaves pin files untouched when they have no clawed-ollama references', async () => {+ writeJson(providersPath, { providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } } });+ const schedulePath = join(rootDir, 'data/task-schedule.json');+ writeJson(schedulePath, { intervals: { security: { providerId: 'codex' } } });+ const before = readFileSync(schedulePath, 'utf-8');++ await migration.up({ rootDir });++ expect(readFileSync(schedulePath, 'utf-8')).toBe(before);+ });+it('is a no-op when data/providers.json does not exist (fresh install)', async () => {await migration.up({ rootDir });expect(existsSync(providersPath)).toBe(false);