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
feat: move local LLM refresh to PortOS automation
[._.]/ Adam Eivy425171a3f43f
diff --git a/scripts/migrations/298-refresh-local-llm-catalog-custom-task.js b/scripts/migrations/298-refresh-local-llm-catalog-custom-task.jsnew file mode 100644index 0000000000..989864af6f--- /dev/null+++ b/scripts/migrations/298-refresh-local-llm-catalog-custom-task.js@@ -0,0 +1,158 @@+/**+ * Move the PortOS-only `refresh-local-llm-catalog` scheduled task into the+ * PortOS app's Custom Tasks list.+ *+ * The old task type appeared for every managed app even though its prompt could+ * only edit PortOS. The destination is an app-scoped autonomous job, which keeps+ * provider/model/effort, prompt, cadence, git-workflow options, and PortOS run+ * history while removing the dead schedule entry and per-app overrides.+ *+ * Writes are ordered destination first, source tombstone last. If a partial run+ * is retried, an existing destination job wins so user edits are never replaced.+ */++import { readFile } from 'fs/promises'+import { join } from 'path'+import { atomicWrite } from '../../server/lib/fileUtils.js'+import { PORTOS_APP_ID } from '../../server/lib/appIdentity.js'+import {+ PORTOS_CATALOG_REFRESH_JOB_ID,+ PORTOS_CATALOG_REFRESH_TASK_TYPE,+ buildMigratedCatalogRefreshJob+} from '../../server/services/autonomousJobs/portosCatalogRefresh.js'++const CURRENT_SCHEDULE_REL = join('data', 'cos', 'task-schedule.json')+const LEGACY_SCHEDULE_REL = join('data', 'task-schedule.json')+const JOBS_REL = join('data', 'cos', 'autonomous-jobs.json')+const APPS_REL = join('data', 'apps.json')+const EXECUTION_KEY = `task:${PORTOS_CATALOG_REFRESH_TASK_TYPE}`++const isObject = (value) => value && typeof value === 'object' && !Array.isArray(value)++async function readOptionalJsonStrict(path, label) {+ const raw = await readFile(path, 'utf8').catch((err) => {+ if (err.code === 'ENOENT') return null+ throw err+ })+ if (raw == null) return null+ try {+ return JSON.parse(raw)+ } catch (err) {+ throw new Error(`${label} is unreadable; repair it before retrying migration 298: ${err.message}`)+ }+}++function removeLegacyScheduleState(schedule) {+ if (!isObject(schedule)) return false+ let changed = false+ if (isObject(schedule.tasks) && Object.hasOwn(schedule.tasks, PORTOS_CATALOG_REFRESH_TASK_TYPE)) {+ delete schedule.tasks[PORTOS_CATALOG_REFRESH_TASK_TYPE]+ changed = true+ }+ if (isObject(schedule.executions) && Object.hasOwn(schedule.executions, EXECUTION_KEY)) {+ delete schedule.executions[EXECUTION_KEY]+ changed = true+ }+ if (Array.isArray(schedule.onDemandRequests)) {+ const kept = schedule.onDemandRequests.filter((request) => request?.taskType !== PORTOS_CATALOG_REFRESH_TASK_TYPE)+ if (kept.length !== schedule.onDemandRequests.length) {+ schedule.onDemandRequests = kept+ changed = true+ }+ }+ return changed+}++export default {+ async up({ rootDir }) {+ const currentSchedulePath = join(rootDir, CURRENT_SCHEDULE_REL)+ const legacySchedulePath = join(rootDir, LEGACY_SCHEDULE_REL)+ const jobsPath = join(rootDir, JOBS_REL)+ const appsPath = join(rootDir, APPS_REL)++ const [currentSchedule, legacySchedule, appsData] = await Promise.all([+ readOptionalJsonStrict(currentSchedulePath, CURRENT_SCHEDULE_REL),+ readOptionalJsonStrict(legacySchedulePath, LEGACY_SCHEDULE_REL),+ readOptionalJsonStrict(appsPath, APPS_REL)+ ])++ for (const [label, schedule] of [[CURRENT_SCHEDULE_REL, currentSchedule], [LEGACY_SCHEDULE_REL, legacySchedule]]) {+ if (schedule != null && (!isObject(schedule) || !isObject(schedule.tasks))) {+ throw new Error(`${label} has an invalid tasks collection; repair it before retrying migration 298`)+ }+ }+ if (appsData != null && (!isObject(appsData) || !isObject(appsData.apps))) {+ throw new Error(`${APPS_REL} has an invalid apps collection; repair it before retrying migration 298`)+ }++ const schedules = [+ { path: currentSchedulePath, data: currentSchedule },+ { path: legacySchedulePath, data: legacySchedule }+ ]+ const sourceSchedule = schedules.find(({ data }) => isObject(data?.tasks?.[PORTOS_CATALOG_REFRESH_TASK_TYPE]))?.data+ const task = sourceSchedule?.tasks?.[PORTOS_CATALOG_REFRESH_TASK_TYPE] || null+ const execution = sourceSchedule?.executions?.[EXECUTION_KEY] || {}+ const portosApp = isObject(appsData?.apps?.[PORTOS_APP_ID]) ? appsData.apps[PORTOS_APP_ID] : null+ const appOverride = isObject(portosApp?.taskTypeOverrides?.[PORTOS_CATALOG_REFRESH_TASK_TYPE])+ ? portosApp.taskTypeOverrides[PORTOS_CATALOG_REFRESH_TASK_TYPE]+ : null+ const hasAnyAppOverride = isObject(appsData?.apps) && Object.values(appsData.apps).some(+ (app) => isObject(app?.taskTypeOverrides?.[PORTOS_CATALOG_REFRESH_TASK_TYPE])+ )++ // Fresh installs have neither persisted source. DEFAULT_JOBS seeds the new+ // disabled PortOS custom task during autonomous-job initialization.+ if (!task && !hasAnyAppOverride) {+ return { updated: 0, jobCreated: false, schedulesCleaned: 0, appOverridesRemoved: 0 }+ }++ const jobsData = await readOptionalJsonStrict(jobsPath, JOBS_REL) || {+ version: 1,+ lastUpdated: null,+ jobs: []+ }+ if (!isObject(jobsData) || !Array.isArray(jobsData.jobs)) {+ throw new Error(`${JOBS_REL} has an invalid jobs collection; repair it before retrying migration 298`)+ }++ let jobCreated = false+ if (!jobsData.jobs.some((job) => isObject(job) && job.id === PORTOS_CATALOG_REFRESH_JOB_ID)) {+ const sourceTask = task || { type: 'weekly', enabled: false }+ jobsData.jobs.push(buildMigratedCatalogRefreshJob({+ task: sourceTask,+ appOverride: appOverride || {},+ execution+ }))+ jobsData.lastUpdated = new Date().toISOString()+ await atomicWrite(jobsPath, jobsData)+ jobCreated = true+ console.log('📝 refresh-local-llm-catalog: created the PortOS app custom task')+ }++ let appOverridesRemoved = 0+ if (isObject(appsData?.apps)) {+ for (const app of Object.values(appsData.apps)) {+ if (!isObject(app?.taskTypeOverrides) || !Object.hasOwn(app.taskTypeOverrides, PORTOS_CATALOG_REFRESH_TASK_TYPE)) continue+ delete app.taskTypeOverrides[PORTOS_CATALOG_REFRESH_TASK_TYPE]+ appOverridesRemoved += 1+ }+ if (appOverridesRemoved > 0) await atomicWrite(appsPath, appsData)+ }++ let schedulesCleaned = 0+ for (const schedule of schedules) {+ if (removeLegacyScheduleState(schedule.data)) {+ await atomicWrite(schedule.path, schedule.data)+ schedulesCleaned += 1+ }+ }++ console.log(`✅ refresh-local-llm-catalog: moved to PortOS Custom Tasks and removed ${appOverridesRemoved} obsolete app override(s)`)+ return {+ updated: (jobCreated ? 1 : 0) + schedulesCleaned + appOverridesRemoved,+ jobCreated,+ schedulesCleaned,+ appOverridesRemoved+ }+ }+}diff --git a/scripts/migrations/298-refresh-local-llm-catalog-custom-task.test.js b/scripts/migrations/298-refresh-local-llm-catalog-custom-task.test.jsnew file mode 100644index 0000000000..ce6c1f9a38--- /dev/null+++ b/scripts/migrations/298-refresh-local-llm-catalog-custom-task.test.js@@ -0,0 +1,187 @@+import { afterEach, beforeEach, describe, expect, it } from 'vitest'+import { mkdtempSync, readFileSync, rmSync, writeFileSync, mkdirSync } from 'fs'+import { tmpdir } from 'os'+import { dirname, join } from 'path'+import { PORTOS_APP_ID } from '../../server/lib/appIdentity.js'+import { PORTOS_CATALOG_REFRESH_JOB_ID } from '../../server/services/autonomousJobs/portosCatalogRefresh.js'+import migration from './298-refresh-local-llm-catalog-custom-task.js'++const writeJson = (path, value) => {+ mkdirSync(dirname(path), { recursive: true })+ writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`)+}+const readJson = (path) => JSON.parse(readFileSync(path, 'utf8'))++describe('migration 298 — local-LLM catalog refresh → PortOS custom task', () => {+ let rootDir+ let schedulePath+ let legacySchedulePath+ let jobsPath+ let appsPath++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-298-'))+ schedulePath = join(rootDir, 'data', 'cos', 'task-schedule.json')+ legacySchedulePath = join(rootDir, 'data', 'task-schedule.json')+ jobsPath = join(rootDir, 'data', 'cos', 'autonomous-jobs.json')+ appsPath = join(rootDir, 'data', 'apps.json')+ })++ afterEach(() => rmSync(rootDir, { recursive: true, force: true }))++ it('no-ops on a fresh install so DEFAULT_JOBS can seed the task', async () => {+ await expect(migration.up({ rootDir })).resolves.toEqual({+ updated: 0,+ jobCreated: false,+ schedulesCleaned: 0,+ appOverridesRemoved: 0+ })+ })++ it('moves effective PortOS settings and history, then removes every old schedule surface', async () => {+ writeJson(schedulePath, {+ version: 2,+ tasks: {+ security: { enabled: true },+ 'refresh-local-llm-catalog': {+ enabled: true,+ type: 'weekly',+ providerId: 'global-provider',+ model: 'global-model',+ effort: 'xhigh',+ prompt: 'Refresh {appName} from {repoPath} on {defaultBranch}.',+ taskMetadata: { useWorktree: true, openPR: true, simplify: true }+ }+ },+ executions: {+ 'task:security': { count: 1 },+ 'task:refresh-local-llm-catalog': {+ count: 8,+ perApp: { [PORTOS_APP_ID]: { count: 3, lastRun: '2026-08-20T00:00:00.000Z' } }+ }+ },+ onDemandRequests: [+ { id: 'keep', taskType: 'security' },+ { id: 'remove', taskType: 'refresh-local-llm-catalog' }+ ]+ })+ writeJson(jobsPath, { version: 1, jobs: [{ id: 'job-existing', name: 'Existing' }] })+ writeJson(appsPath, {+ apps: {+ [PORTOS_APP_ID]: {+ name: 'PortOS',+ taskTypeOverrides: {+ security: { enabled: true },+ 'refresh-local-llm-catalog': {+ enabled: true,+ interval: 'custom',+ intervalMs: 12_345,+ providerId: 'app-provider',+ model: 'app-model',+ taskMetadata: { simplify: false }+ }+ }+ },+ 'example-app': {+ taskTypeOverrides: { 'refresh-local-llm-catalog': { enabled: false } }+ }+ }+ })++ const result = await migration.up({ rootDir })+ expect(result).toMatchObject({ jobCreated: true, schedulesCleaned: 1, appOverridesRemoved: 2 })++ const jobs = readJson(jobsPath).jobs+ expect(jobs.map((job) => job.id)).toEqual(['job-existing', PORTOS_CATALOG_REFRESH_JOB_ID])+ expect(jobs[1]).toMatchObject({+ appId: PORTOS_APP_ID,+ enabled: true,+ interval: 'custom',+ intervalMs: 12_345,+ providerId: 'app-provider',+ model: 'app-model',+ effort: 'xhigh',+ promptTemplate: 'Refresh PortOS from . on the repository default branch.',+ taskMetadata: { useWorktree: true, openPR: true, simplify: false },+ runCount: 3,+ lastRun: '2026-08-20T00:00:00.000Z'+ })++ const schedule = readJson(schedulePath)+ expect(schedule.tasks).toEqual({ security: { enabled: true } })+ expect(schedule.executions).toEqual({ 'task:security': { count: 1 } })+ expect(schedule.onDemandRequests).toEqual([{ id: 'keep', taskType: 'security' }])+ const apps = readJson(appsPath).apps+ expect(apps[PORTOS_APP_ID].taskTypeOverrides).toEqual({ security: { enabled: true } })+ expect(apps['example-app'].taskTypeOverrides).toEqual({})+ })++ it('migrates the legacy schedule path and preserves the global pause', async () => {+ writeJson(legacySchedulePath, {+ tasks: { 'refresh-local-llm-catalog': { enabled: false, type: 'daily' } },+ executions: {}+ })+ writeJson(appsPath, {+ apps: { [PORTOS_APP_ID]: { taskTypeOverrides: { 'refresh-local-llm-catalog': { enabled: true } } } }+ })++ await migration.up({ rootDir })+ const job = readJson(jobsPath).jobs.find((candidate) => candidate.id === PORTOS_CATALOG_REFRESH_JOB_ID)+ expect(job).toMatchObject({ enabled: false, interval: 'daily' })+ expect(readJson(legacySchedulePath).tasks).toEqual({})+ })++ it('preserves an existing destination job while completing a partial migration cleanup', async () => {+ writeJson(schedulePath, {+ tasks: { 'refresh-local-llm-catalog': { enabled: true, type: 'weekly' } },+ executions: {}+ })+ writeJson(jobsPath, {+ version: 1,+ jobs: [{ id: PORTOS_CATALOG_REFRESH_JOB_ID, name: 'My customized destination', enabled: false }]+ })+ writeJson(appsPath, {+ apps: { [PORTOS_APP_ID]: { taskTypeOverrides: { 'refresh-local-llm-catalog': { enabled: true } } } }+ })++ const result = await migration.up({ rootDir })+ expect(result.jobCreated).toBe(false)+ expect(readJson(jobsPath).jobs[0].name).toBe('My customized destination')+ expect(readJson(schedulePath).tasks).toEqual({})+ expect(readJson(appsPath).apps[PORTOS_APP_ID].taskTypeOverrides).toEqual({})+ })++ it('fails closed on corrupt persisted state instead of overwriting it', async () => {+ mkdirSync(join(rootDir, 'data', 'cos'), { recursive: true })+ writeFileSync(schedulePath, '{not json')++ await expect(migration.up({ rootDir })).rejects.toThrow('task-schedule.json is unreadable')+ expect(readFileSync(schedulePath, 'utf8')).toBe('{not json')+ })++ it('fails closed on a malformed jobs collection before removing the source', async () => {+ writeJson(schedulePath, {+ tasks: { 'refresh-local-llm-catalog': { enabled: true, type: 'weekly' } },+ executions: {}+ })+ writeJson(jobsPath, { version: 1, jobs: null })+ writeJson(appsPath, {+ apps: { [PORTOS_APP_ID]: { taskTypeOverrides: { 'refresh-local-llm-catalog': { enabled: true } } } }+ })++ await expect(migration.up({ rootDir })).rejects.toThrow('invalid jobs collection')+ expect(readJson(schedulePath).tasks).toHaveProperty('refresh-local-llm-catalog')+ expect(readJson(appsPath).apps[PORTOS_APP_ID].taskTypeOverrides).toHaveProperty('refresh-local-llm-catalog')+ })++ it('fails closed on a malformed apps collection before removing the source', async () => {+ writeJson(schedulePath, {+ tasks: { 'refresh-local-llm-catalog': { enabled: true, type: 'weekly' } },+ executions: {}+ })+ writeJson(appsPath, { apps: null })++ await expect(migration.up({ rootDir })).rejects.toThrow('invalid apps collection')+ expect(readJson(schedulePath).tasks).toHaveProperty('refresh-local-llm-catalog')+ })+})diff --git a/server/services/autonomousJobs/constants.js b/server/services/autonomousJobs/constants.jsindex 0dea6b1bf7..41ea85d345 100644--- a/server/services/autonomousJobs/constants.js+++ b/server/services/autonomousJobs/constants.js@@ -59,7 +59,7 @@ export const INTERVAL_OPTIONS = [// Fields that are code contracts — always overwrite on restart so runtime// stays consistent with the shipped implementation.-export const JOB_STRUCTURAL_FIELDS = ['type', 'scriptHandler']+export const JOB_STRUCTURAL_FIELDS = ['type', 'scriptHandler', 'appId']// Fields that ship with a default but are user-editable via PUT /api/cos/jobs/:id.// Only written when the field is absent on the stored job (first-time population).diff --git a/server/services/autonomousJobs/defaults.js b/server/services/autonomousJobs/defaults.jsindex 1e9ac77a31..896b93ca66 100644--- a/server/services/autonomousJobs/defaults.js+++ b/server/services/autonomousJobs/defaults.js@@ -10,6 +10,7 @@*/import { DAY, WEEK, JOB_STRUCTURAL_FIELDS, JOB_ADDITIVE_FIELDS } from './constants.js'+import { PORTOS_CATALOG_REFRESH_JOB } from './portosCatalogRefresh.js'/*** Default job definitions@@ -289,6 +290,7 @@ Phase 4 — Report:createdAt: null,updatedAt: null},+ PORTOS_CATALOG_REFRESH_JOB,// 'job-layered-intelligence' removed (#2322): Layered Intelligence is now a// per-app HANDLER-BACKED scheduled task (CoS → Schedule) rather than a global// autonomous-job sweep. Migration 184 tombstones the persisted job record anddiff --git a/server/services/autonomousJobs/portosCatalogRefresh.js b/server/services/autonomousJobs/portosCatalogRefresh.jsnew file mode 100644index 0000000000..ec7177418f--- /dev/null+++ b/server/services/autonomousJobs/portosCatalogRefresh.js@@ -0,0 +1,116 @@+/**+ * PortOS-owned custom job for maintaining the bundled local-LLM catalog.+ *+ * This is an autonomous job rather than a task-schedule type because its prompt+ * edits PortOS-specific files. Scoping it to the baseline PortOS app keeps it in+ * that app's Automation tab and out of every other managed app's task catalog.+ */++import { PORTOS_APP_ID } from '../../lib/appIdentity.js'+import { DEFAULT_TASK_PROMPTS, PREVIOUS_DEFAULT_PROMPTS } from '../taskPromptDefaults.js'+import { DAY, WEEK } from './constants.js'++export const PORTOS_CATALOG_REFRESH_JOB_ID = 'job-refresh-local-llm-catalog'+export const PORTOS_CATALOG_REFRESH_TASK_TYPE = 'refresh-local-llm-catalog'++/**+ * Scheduled-task prompts used app-template placeholders. Autonomous jobs run in+ * the app's prepared workspace, so repo-relative `.` is both portable and (when+ * worktree isolation is enabled) points at the branch the agent should edit.+ */+export function catalogRefreshPromptForCustomJob(prompt = DEFAULT_TASK_PROMPTS[PORTOS_CATALOG_REFRESH_TASK_TYPE]) {+ return String(prompt || '')+ .replaceAll('{appName}', 'PortOS')+ .replaceAll('{repoPath}', '.')+ .replaceAll('{defaultBranch}', 'the repository default branch')+}++export const PORTOS_CATALOG_REFRESH_JOB = Object.freeze({+ id: PORTOS_CATALOG_REFRESH_JOB_ID,+ name: 'Refresh Local LLM Catalog',+ description: "Research current local models and refresh PortOS's bundled catalog and editorial ranking.",+ category: 'portos-maintenance',+ appId: PORTOS_APP_ID,+ interval: 'weekly',+ intervalMs: WEEK,+ enabled: false,+ priority: 'MEDIUM',+ autonomyLevel: 'manager',+ type: 'agent',+ promptTemplate: catalogRefreshPromptForCustomJob(),+ taskMetadata: { useWorktree: true, openPR: true, simplify: true },+ providerId: null,+ model: null,+ effort: null,+ lastRun: null,+ runCount: 0,+ createdAt: null,+ updatedAt: null+})++const isObject = (value) => value && typeof value === 'object' && !Array.isArray(value)++/** Map the task scheduler's cadence vocabulary to autonomous-job fields. */+export function catalogRefreshJobScheduleFields(task = {}, appOverride = {}) {+ const overrideInterval = typeof appOverride.interval === 'string' ? appOverride.interval.trim() : ''+ const type = overrideInterval || task.type || 'weekly'+ const cronExpression = type.includes(' ')+ ? type+ : (type === 'cron' && typeof task.cronExpression === 'string' ? task.cronExpression.trim() : '')++ if (cronExpression.split(/\s+/).length === 5) {+ return { interval: 'daily', intervalMs: DAY, cronExpression }+ }+ if (type === 'daily') return { interval: 'daily', intervalMs: DAY }+ if (type === 'weekly') return { interval: 'weekly', intervalMs: WEEK }+ if (type === 'custom') {+ const overrideMs = Number(appOverride.intervalMs)+ const globalMs = Number(task.intervalMs)+ const intervalMs = overrideMs > 0 ? overrideMs : (globalMs > 0 ? globalMs : DAY)+ return { interval: 'custom', intervalMs }+ }++ // Rotation/once/on-demand/perpetual do not have faithful autonomous-job+ // equivalents. The migration disables these below and leaves a weekly cadence+ // visible for manual runs rather than silently turning one-shot work recurring.+ return { interval: 'weekly', intervalMs: WEEK, unsupportedScheduleType: type }+}++/**+ * Build the destination job from the effective PortOS schedule configuration.+ * Exported so migration tests can pin every preserved field without disk I/O.+ */+export function buildMigratedCatalogRefreshJob({ task = {}, appOverride = {}, execution = {}, now = new Date().toISOString() } = {}) {+ const scheduleFields = catalogRefreshJobScheduleFields(task, appOverride)+ const { unsupportedScheduleType, ...persistedScheduleFields } = scheduleFields+ const effectiveExecution = isObject(execution.perApp?.[PORTOS_APP_ID])+ ? execution.perApp[PORTOS_APP_ID]+ : execution+ const globalMetadata = isObject(task.taskMetadata) ? task.taskMetadata : {}+ const appMetadata = isObject(appOverride.taskMetadata) ? appOverride.taskMetadata : {}+ const storedPrompt = task.prompt || DEFAULT_TASK_PROMPTS[PORTOS_CATALOG_REFRESH_TASK_TYPE]+ const promptWasShipped = storedPrompt === DEFAULT_TASK_PROMPTS[PORTOS_CATALOG_REFRESH_TASK_TYPE]+ || (PREVIOUS_DEFAULT_PROMPTS[PORTOS_CATALOG_REFRESH_TASK_TYPE] || []).includes(storedPrompt)+ const prompt = promptWasShipped ? DEFAULT_TASK_PROMPTS[PORTOS_CATALOG_REFRESH_TASK_TYPE] : storedPrompt++ return {+ ...PORTOS_CATALOG_REFRESH_JOB,+ ...persistedScheduleFields,+ enabled: unsupportedScheduleType+ ? false+ : task.enabled === true && appOverride.enabled === true,+ promptTemplate: catalogRefreshPromptForCustomJob(prompt),+ taskMetadata: {+ ...PORTOS_CATALOG_REFRESH_JOB.taskMetadata,+ ...globalMetadata,+ ...appMetadata+ },+ providerId: appOverride.providerId || task.providerId || null,+ model: appOverride.model || task.model || null,+ effort: task.effort || null,+ lastRun: effectiveExecution.lastRun || null,+ runCount: Number.isFinite(effectiveExecution.count) ? effectiveExecution.count : 0,+ createdAt: task.createdAt || now,+ updatedAt: now+ }+}diff --git a/server/services/autonomousJobs/portosCatalogRefresh.test.js b/server/services/autonomousJobs/portosCatalogRefresh.test.jsnew file mode 100644index 0000000000..433ce374a4--- /dev/null+++ b/server/services/autonomousJobs/portosCatalogRefresh.test.js@@ -0,0 +1,128 @@+import { describe, expect, it } from 'vitest'+import { PORTOS_APP_ID } from '../../lib/appIdentity.js'+import { DEFAULT_TASK_PROMPTS, PREVIOUS_DEFAULT_PROMPTS } from '../taskPromptDefaults.js'+import { SELF_IMPROVEMENT_TASK_TYPES, DEFAULT_TASK_INTERVALS } from '../taskScheduleRegistry.js'+import { DEFAULT_JOBS, mergeWithDefaults } from './defaults.js'+import {+ PORTOS_CATALOG_REFRESH_JOB_ID,+ PORTOS_CATALOG_REFRESH_JOB,+ buildMigratedCatalogRefreshJob,+ catalogRefreshJobScheduleFields,+ catalogRefreshPromptForCustomJob+} from './portosCatalogRefresh.js'++describe('PortOS local-LLM catalog refresh custom task', () => {+ it('ships as a disabled weekly custom task scoped to PortOS, not a global task type', () => {+ const job = DEFAULT_JOBS.find((candidate) => candidate.id === PORTOS_CATALOG_REFRESH_JOB_ID)+ expect(job).toBe(PORTOS_CATALOG_REFRESH_JOB)+ expect(job).toMatchObject({+ appId: PORTOS_APP_ID,+ type: 'agent',+ interval: 'weekly',+ enabled: false,+ taskMetadata: { useWorktree: true, openPR: true, simplify: true }+ })+ expect(SELF_IMPROVEMENT_TASK_TYPES).not.toContain('refresh-local-llm-catalog')+ expect(DEFAULT_TASK_INTERVALS['refresh-local-llm-catalog']).toBeUndefined()+ })++ it('adapts scheduled-task placeholders to the prepared custom-task workspace', () => {+ const prompt = catalogRefreshPromptForCustomJob('For {appName}, inspect {repoPath}/x on {defaultBranch}.')+ expect(prompt).toBe('For PortOS, inspect ./x on the repository default branch.')+ expect(PORTOS_CATALOG_REFRESH_JOB.promptTemplate).toContain('LOCAL_LLM_CATALOG')+ expect(PORTOS_CATALOG_REFRESH_JOB.promptTemplate).toContain('Do NOT create or edit a changelog file or fragment')+ expect(PORTOS_CATALOG_REFRESH_JOB.promptTemplate).not.toContain('changelog:add')+ expect(PORTOS_CATALOG_REFRESH_JOB.promptTemplate).not.toMatch(/\{(?:appName|repoPath|defaultBranch)\}/)+ })++ it('reasserts PortOS scope if persisted shipped state drifts', () => {+ const stored = {+ version: 1,+ jobs: [{ ...PORTOS_CATALOG_REFRESH_JOB, appId: 'example-app' }]+ }+ const { data, dirty } = mergeWithDefaults(stored)++ expect(dirty).toBe(true)+ expect(data.jobs.find((job) => job.id === PORTOS_CATALOG_REFRESH_JOB_ID)?.appId).toBe(PORTOS_APP_ID)+ })++ it('maps supported fixed, custom, and cron cadences', () => {+ expect(catalogRefreshJobScheduleFields({ type: 'daily' })).toMatchObject({ interval: 'daily' })+ expect(catalogRefreshJobScheduleFields({ type: 'custom', intervalMs: 1234 })).toEqual({ interval: 'custom', intervalMs: 1234 })+ expect(catalogRefreshJobScheduleFields({ type: 'weekly' }, { interval: '0 6 * * 1' }))+ .toEqual({ interval: 'daily', intervalMs: 86_400_000, cronExpression: '0 6 * * 1' })+ })++ it('preserves effective pins, metadata, prompt, and PortOS execution history', () => {+ const job = buildMigratedCatalogRefreshJob({+ task: {+ enabled: true,+ type: 'weekly',+ providerId: 'global-provider',+ model: 'global-model',+ effort: 'high',+ prompt: 'Work in {repoPath} for {appName}.',+ taskMetadata: { useWorktree: true, openPR: true, simplify: true }+ },+ appOverride: {+ enabled: true,+ interval: 'custom',+ intervalMs: 7_200_000,+ providerId: 'app-provider',+ model: 'app-model',+ taskMetadata: { simplify: false }+ },+ execution: {+ count: 99,+ perApp: { [PORTOS_APP_ID]: { count: 4, lastRun: '2026-08-01T00:00:00.000Z' } }+ },+ now: '2026-08-26T00:00:00.000Z'+ })++ expect(job).toMatchObject({+ enabled: true,+ interval: 'custom',+ intervalMs: 7_200_000,+ providerId: 'app-provider',+ model: 'app-model',+ effort: 'high',+ promptTemplate: 'Work in . for PortOS.',+ taskMetadata: { useWorktree: true, openPR: true, simplify: false },+ lastRun: '2026-08-01T00:00:00.000Z',+ runCount: 4+ })+ })++ it('upgrades a stored shipped prompt while preserving a genuinely customized prompt', () => {+ const previous = PREVIOUS_DEFAULT_PROMPTS['refresh-local-llm-catalog'].at(-1)+ const migrated = buildMigratedCatalogRefreshJob({+ task: { enabled: true, type: 'weekly', prompt: previous },+ appOverride: { enabled: true }+ })++ expect(migrated.promptTemplate).toContain('Do NOT create or edit a changelog file or fragment')+ expect(migrated.promptTemplate).not.toContain('changelog:add')+ expect(migrated.promptTemplate).toBe(catalogRefreshPromptForCustomJob(+ DEFAULT_TASK_PROMPTS['refresh-local-llm-catalog']+ ))++ const customized = buildMigratedCatalogRefreshJob({+ task: { enabled: true, type: 'weekly', prompt: 'Keep my {appName} instructions.' },+ appOverride: { enabled: true }+ })+ expect(customized.promptTemplate).toBe('Keep my PortOS instructions.')+ })++ it('keeps the job disabled when the global pause is on or the cadence is unsupported', () => {+ expect(buildMigratedCatalogRefreshJob({+ task: { enabled: false, type: 'weekly' },+ appOverride: { enabled: true }+ }).enabled).toBe(false)+ const once = buildMigratedCatalogRefreshJob({+ task: { enabled: true, type: 'once' },+ appOverride: { enabled: true }+ })+ expect(once).toMatchObject({ enabled: false, interval: 'weekly' })+ expect(once).not.toHaveProperty('unsupportedScheduleType')+ })+})diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.jsindex 63e98cfb7f..dbf7416f24 100644--- a/server/services/taskPromptDefaults.test.js+++ b/server/services/taskPromptDefaults.test.js@@ -552,19 +552,20 @@ describe('taskPromptDefaults integrity snapshot', () => {expect(v10).not.toBe(current);});- // refresh-local-llm-catalog is the one PortOS-ONLY prompt in this set (it- // edits PortOS's own bundled catalog), so it may — and should — name the- // fragment helper directly instead of describing the convention.- it('refresh-local-llm-catalog uses the changelog:add fragment helper, preserving the outgoing default', () => {+ // The PortOS custom catalog-refresh job still sources this versioned prompt:+ // keeping its history here lets migration recognize old shipped copies while+ // autonomous-job shipped-default snapshots handle future custom-job updates.+ it('refresh-local-llm-catalog follows the no-per-branch-changelog contract and preserves v3', () => {const current = DEFAULT_TASK_PROMPTS['refresh-local-llm-catalog'];- expect(current).toContain('npm run changelog:add -- changed');- // Line-wrap-insensitive — the prompt body is hard-wrapped.- expect(current).toMatch(/Do NOT\s+append to `\.changelog\/NEXT\.md` by hand/);+ expect(PROMPT_VERSIONS['refresh-local-llm-catalog']).toBe(4);+ expect(current).toContain('Do NOT create or edit a changelog file or fragment');+ expect(current).not.toContain('npm run changelog:add');+ expect(current).not.toContain('.changelog/NEXT.md');const previous = PREVIOUS_DEFAULT_PROMPTS['refresh-local-llm-catalog'];const outgoing = previous[previous.length - 1];- expect(outgoing).not.toContain('changelog:add');- expect(outgoing).toContain('Add a one-line entry to `{repoPath}/.changelog/NEXT.md`');+ expect(outgoing).toContain('npm run changelog:add -- changed');+ expect(outgoing).toMatch(/Do NOT\s+append to `\.changelog\/NEXT\.md` by hand/);expect(outgoing).not.toBe(current);});diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.jsonindex 336d76d1cc..e000746269 100644--- a/server/services/taskPromptDefaults/integrity.snapshot.json+++ b/server/services/taskPromptDefaults/integrity.snapshot.json@@ -37,7 +37,7 @@"pr-reviewer-review": "ec67b91468cead9c16cfcffff06f8993","reference-watch": "e0e20754700fb08d5159b8437d9c260b","pr-watcher": "53ead8e26d396849bfa78f28550bd691",- "refresh-local-llm-catalog": "ca7324a0f2251a66b46ea534940c9da8"+ "refresh-local-llm-catalog": "9741ca6a8419fcdea2743e3b64781a8b"},"PROMPT_VERSIONS": {"do-replan": 2,@@ -53,7 +53,7 @@"pr-watcher": 1,"branch-reconcile": 3,"issue-reconcile": 4,- "refresh-local-llm-catalog": 3,+ "refresh-local-llm-catalog": 4,"plan-feature": 2,"security": 2,"code-quality": 2,@@ -227,7 +227,8 @@],"refresh-local-llm-catalog": ["525bd0077672bf2f8beec9c0124740c8",- "a9dce67bb9f0837ba904f3412b03637f"+ "a9dce67bb9f0837ba904f3412b03637f",+ "ca7324a0f2251a66b46ea534940c9da8"],"plan-feature": ["3df6f0a46f2a524af1dc4f83dfdf0647"diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.jsindex 7a257a8fff..dd4a52bb6d 100644--- a/server/services/taskPromptDefaults/previousDefaults.js+++ b/server/services/taskPromptDefaults/previousDefaults.js@@ -10879,6 +10879,85 @@ Default branch: {defaultBranch}## Output+- If the catalog is already current and accurate, make NO changes — do not open+ an empty PR. Finish with a summary saying it was already up to date.+- Otherwise commit your changes with a clear message (a PR will be opened for+ the branch). Finish with a 2–4 sentence summary listing exactly which models+ were added, updated, or removed and the sources you verified them against.`,+ // v3 default prompt — outgoing scheduled-task body before PortOS adopted+ // commit-derived release notes and moved this automation to a custom job.+ `[Improvement: {appName}] Refresh the bundled local-LLM suggested-models catalog++You maintain PortOS's curated catalog of suggested local models so the in-app+install picker and the editorial-model recommendation keep pace with what's+actually current. Models move fast (new Qwen / Llama / Gemma / Mistral releases,+deprecations), and this catalog is shipped in the app — so it goes stale unless+refreshed.++Repository: {repoPath}+Default branch: {defaultBranch}++## Guard — PortOS only++1. Check that \`{repoPath}/server/lib/localLlmCatalog.js\` exists. If it does NOT,+ this repository is not PortOS — make NO changes, open NO PR, and finish with a+ one-line summary saying the catalog file was not found so there was nothing to do.++## What to do (only when the catalog file exists)++2. Read the current catalog at \`server/lib/localLlmCatalog.js\` (the+ \`LOCAL_LLM_CATALOG\` array; each entry is+ \`{ key, name, category, recommendedFor?, featured?, params, size, family, description, capabilities, ollama?, lmstudio? }\`)+ and the editorial ranking \`EDITORIAL_FAMILY_RANK\` in+ \`server/lib/localModelHeuristics.js\`.++3. Research the current best-in-class local models for EACH category in+ \`LOCAL_LLM_CATEGORIES\` (general-purpose, coding/agents,+ reasoning/analysis, vision/image-analysis, chat/voice,+ lightweight/small-&-fast, multilingual, embedding). Prefer models that are:+ - Pullable on Ollama (use the canonical \`ollama pull\` id) and/or available+ as a well-known GGUF build on LM Studio / Hugging Face (use the canonical+ repo id, e.g. \`lmstudio-community/<Model>-GGUF\`).+ - Genuinely current and widely used — not every brand-new release. Verify the+ pull id actually exists before adding it (cite your source in the PR body).+ Use web search / fetch if the tools are available; otherwise rely on your+ most current knowledge and clearly mark any entry you could not verify.++4. Update \`LOCAL_LLM_CATALOG\`:+ - Add newly-prominent models, refresh \`params\`/\`size\`/\`description\` on+ existing entries, and remove models that are clearly deprecated/superseded.+ - Treat \`category\` as the model's ONE primary recommendation lane. Use+ \`recommendedFor\` only for additional user-facing filters where a genuinely+ general model is a good choice; it must include the primary category. Keep+ modality and tool facts in \`capabilities\`, not in arbitrary categories.+ Reserve \`featured\` for a deliberate first-choice recommendation with a+ concise user-facing reason — never set it merely because a model is newest.+ - Keep the module's shape EXACTLY: do not change the exports+ (\`BACKENDS\`, \`isBackend\`, \`LOCAL_LLM_CATEGORIES\`, \`LOCAL_LLM_CATALOG\`),+ and keep \`category\` and every \`recommendedFor\` value within+ \`LOCAL_LLM_CATEGORIES\` ids. A missing \`ollama\`/\`lmstudio\` id is fine+ when no well-known build exists for that backend.++5. Review \`EDITORIAL_FAMILY_RANK\` in \`server/lib/localModelHeuristics.js\` (used+ to recommend a model for editorial review/editing — it favors tight+ instruction-following over chatty/RAG-tuned families). Only adjust it if a new+ family clearly belongs or an existing one should move; keep the+ longest-match-first ordering (\`command-r-plus\` before \`command-r\` before+ \`command\`). Do not change the function signatures or other exports.++6. Run the affected tests and make sure they pass:+ \`cd {repoPath}/server && npx vitest run lib/localLlmCatalog lib/localModelHeuristics lib/index.test.js\`.+ Update catalog/picker tests when you intentionally add recommendation+ metadata; do not change existing cross-backend install-id mapping semantics.++7. Log the refresh in the changelog with+ \`cd {repoPath} && npm run changelog:add -- changed "<one line summarizing the catalog refresh>"\`.+ That writes a per-branch fragment under \`.changelog/next/\`, which is what keeps+ parallel agents from conflicting on the shared \`.changelog/NEXT.md\`. Do NOT+ append to \`.changelog/NEXT.md\` by hand.++## Output+- If the catalog is already current and accurate, make NO changes — do not openan empty PR. Finish with a summary saying it was already up to date.- Otherwise commit your changes with a clear message (a PR will be opened fordiff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.jsindex 214b0aad0d..0ac41d16d6 100644--- a/server/services/taskPromptDefaults/prompts.js+++ b/server/services/taskPromptDefaults/prompts.js@@ -2166,11 +2166,9 @@ Default branch: {defaultBranch}Update catalog/picker tests when you intentionally add recommendationmetadata; do not change existing cross-backend install-id mapping semantics.-7. Log the refresh in the changelog with- \`cd {repoPath} && npm run changelog:add -- changed "<one line summarizing the catalog refresh>"\`.- That writes a per-branch fragment under \`.changelog/next/\`, which is what keeps- parallel agents from conflicting on the shared \`.changelog/NEXT.md\`. Do NOT- append to \`.changelog/NEXT.md\` by hand.+7. Do NOT create or edit a changelog file or fragment. PortOS release notes are+ synthesized from the commit log, so write a clear conventional commit subject+ that names the catalog change and its user-visible effect.## Outputdiff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.jsindex 96e33d5533..447a67e287 100644--- a/server/services/taskPromptDefaults/versions.js+++ b/server/services/taskPromptDefaults/versions.js@@ -22,7 +22,7 @@ export const PROMPT_VERSIONS = {'pr-watcher': 1, // v1: review-and-comment default for newly-opened PRs on the app's default branch'branch-reconcile': 3, // v3: SUPERSEDED is a first-class outcome — a branch whose problem the default branch already solved a different way is reported and left untouched, never merged (merging it undoes shipped work). A resolvable conflict is explicitly NOT evidence the work is still wanted, and every branch is rebased + test-verified before it reaches a PR. v2: a branch whose "Do:" line ends in a merge isn't finished until it IS merged — the sub-agent waits CI out in-session instead of handing back a green-but-open PR, and the old blanket "never merge unreviewed work" rule (which vetoed the per-branch merge instruction) is replaced by the explicit CI-green + MERGEABLE + review gate. v1: per-app coordinator that finishes in-flight LOCAL branches (open PR / resolve conflicts / drive review / auto-merge) after the deterministic merged-branch cleanup pass. Peer-safe (local refs only). Replaced the PortOS-only branchReconcileScheduler.'issue-reconcile': 4, // v4: follow-up recipes apply independent slashdo dispatch hints and contributor labels (`good first issue`/`help wanted`, Jira hyphenated equivalents) instead of only `plan`. v3: adds a JIRA arm — status-based zombies (a ticket left In Review with remaining scope + no live claim; JIRA has no `in-progress` label) detected via the PortOS JIRA API and healed through ticket transitions + `POST tickets`, routed in via the app's resolved workTracker ('jira') rather than the git host. v2: forge-aware — the scan + coordinator now cover GitLab (`glab` issues + MRs) as well as GitHub, resolved from the app's origin host; every heal command is shown as gh/glab and the injected header names the forge. v1: per-app coordinator that heals ZOMBIE issues (open + in-progress but their PR merged with no live claim) after the deterministic gh/git scan. Applies the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the claim so the queue re-picks it.- 'refresh-local-llm-catalog': 3, // v3: catalog maintenance now preserves the primary-lane + cross-lane recommendation taxonomy and reserves featured treatment for a deliberate first choice. v2: PortOS-only task, so it names the fragment command directly: `npm run changelog:add -- changed "…"` instead of hand-appending to `.changelog/NEXT.md`. v1: research current local models, refresh LOCAL_LLM_CATALOG + EDITORIAL_FAMILY_RANK, PR (PortOS repo only)+ 'refresh-local-llm-catalog': 4, // v4: follows the current no-per-branch-changelog contract and relies on a release-note-quality commit subject. v3: catalog maintenance now preserves the primary-lane + cross-lane recommendation taxonomy and reserves featured treatment for a deliberate first choice. v2: PortOS-only task, so it names the retired fragment command directly. v1: research current local models, refresh LOCAL_LLM_CATALOG + EDITORIAL_FAMILY_RANK, PR (PortOS repo only)'plan-feature': 2, // v2: PRD.md is the primary product/evaluation source, GOALS.md supplements or falls back, and repository documentation is the best-effort fallback when neither exists; removes obsolete roadmap/rejection-ledger research dependencies while retaining the resolved work-tracker filing flow. v1: net-new planning-only sibling of feature-ideas.// Basic self-improvement tasks — versioned so installs created before thediff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex f8b8f06c37..53a3d7da2a 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -1321,33 +1321,6 @@ describe('taskSchedule', () => {})})- describe('refresh-local-llm-catalog defaults', () => {- it('is registered as a self-improvement task type', () => {- expect(SELF_IMPROVEMENT_TASK_TYPES).toContain('refresh-local-llm-catalog')- })-- it('defaults to weekly, disabled, with CoS-managed worktree + PR', () => {- const cfg = DEFAULT_TASK_INTERVALS['refresh-local-llm-catalog']- expect(cfg.type).toBe(INTERVAL_TYPES.WEEKLY)- expect(cfg.enabled).toBe(false)- // CoS manages the worktree + PR (like feature-ideas), so these are NOT- // in MANAGED_AGENT_OPTIONS (the user could turn them off if they wanted).- expect(cfg.taskMetadata.useWorktree).toBe(true)- expect(cfg.taskMetadata.openPR).toBe(true)- expect(MANAGED_AGENT_OPTIONS['refresh-local-llm-catalog']).toBeUndefined()- })-- it('prompt guards on the PortOS catalog file and targets the catalog + ranking', async () => {- const prompt = await getTaskPrompt('refresh-local-llm-catalog')- // No-ops on any repo lacking the catalog file (so enabling on a non-PortOS app is safe).- expect(prompt).toContain('server/lib/localLlmCatalog.js')- expect(prompt).toContain('LOCAL_LLM_CATALOG')- expect(prompt).toContain('EDITORIAL_FAMILY_RANK')- // Must not open an empty PR when nothing changed (phrase may be line-wrapped).- expect(prompt).toContain('empty PR')- })- })-describe('ux defaults (#3273)', () => {it('is registered as a self-improvement task type with a description', () => {expect(SELF_IMPROVEMENT_TASK_TYPES).toContain('ux')diff --git a/server/services/taskScheduleRegistry.js b/server/services/taskScheduleRegistry.jsindex 8599a77bb7..7a22f76463 100644--- a/server/services/taskScheduleRegistry.js+++ b/server/services/taskScheduleRegistry.js@@ -61,12 +61,6 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [// On-demand only, and GLOBAL: 'Run Now' with no app sweeps the whole install,// which is the shape the task exists for. Non-committing coordinator posture.'repo-sync',- // PortOS-only: researches the current best local LLMs per category and- // refreshes the bundled suggested-models catalog (server/lib/localLlmCatalog.js)- // + the editorial family ranking (server/lib/localModelHeuristics.js), opening a- // PR. No-ops on any repo lacking that catalog file, so enabling it on a- // non-PortOS app does nothing. See DEFAULT_TASK_PROMPTS['refresh-local-llm-catalog'].- 'refresh-local-llm-catalog',// The planning-only sibling of `feature-ideas`: runs the same brainstorm// research (PRD.md/GOALS.md or repository docs, changelog/git log, and// closed-unmerged PRs)@@ -342,12 +336,6 @@ export const DEFAULT_TASK_INTERVALS = {// customized prompt can make changes if the operator wants — the shipped// default prompt only reviews + comments.'pr-watcher': { type: INTERVAL_TYPES.CUSTOM, intervalMs: 1800000, enabled: false, providerId: null, model: null, prompt: null, taskMetadata: { prAuthorFilter: 'any', readOnly: false } },- // refresh-local-llm-catalog maintains PortOS's own bundled suggested-models- // catalog. CoS manages the worktree + PR (like feature-ideas/do-replan) — the- // agent only edits the catalog file. Weekly is generous; the prompt only opens- // a PR when the catalog is actually stale, so most runs are no-ops. Off by- // default; the user enables it on the PortOS app.- 'refresh-local-llm-catalog': { type: INTERVAL_TYPES.WEEKLY, enabled: false, providerId: null, model: null, prompt: null, taskMetadata: { useWorktree: true, openPR: true, simplify: true } },// plan-feature files a plan, not code — tracker-filing posture mirrors// reference-watch: writable (a file-based tracker commits checklist items), no// managed worktree, no PR. Weekly (not daily like feature-ideas) so an@@ -494,7 +482,6 @@ export const TASK_TYPE_DESCRIPTIONS = {'simplify': 'Dead-code/duplication audit — file issues (default) or implement removals','stash-cleanup': 'Triage git stash list — drop entries superseded by or stale relative to main, leave real unlanded work in place','repo-sync': 'Sync every managed app with origin — back on the default branch, pushed and pulled, merged branches/worktrees and redundant stashes cleared',- 'refresh-local-llm-catalog': "Refresh PortOS's bundled suggested local-model catalog + editorial ranking (PortOS repo only)",'plan-feature': "Brainstorm one feature and file its decision-complete plan to the app's work tracker (no code)",'layered-intelligence': "Read this app's goals + telemetry, ask a reasoning model for one improvement, and file one deduplicated tracker issue — no code, no agent"};diff --git a/server/services/workflow.js b/server/services/workflow.jsindex 4cf054342b..23cde20bf4 100644--- a/server/services/workflow.js+++ b/server/services/workflow.js@@ -76,10 +76,9 @@ export const WORKFLOW_STAGES = ['typing','ui-bugs','mobile-responsive',- 'ux',- 'refresh-local-llm-catalog'+ 'ux'],- jobIds: ['job-wiki-maintenance']+ jobIds: ['job-wiki-maintenance', 'job-refresh-local-llm-catalog']},{id: 'build',diff --git a/server/services/workflow.test.js b/server/services/workflow.test.jsindex ecf6ee7e37..7826bf6c16 100644--- a/server/services/workflow.test.js+++ b/server/services/workflow.test.js@@ -46,6 +46,12 @@ describe('WORKFLOW_STAGES contract', () => {expect(review.taskTypes).toContain('pr-reviewer');});+ it('places the PortOS catalog refresh custom task in the audit stage', () => {+ const audit = WORKFLOW_STAGES.find(s => s.id === 'audit');+ expect(audit.taskTypes).not.toContain('refresh-local-llm-catalog');+ expect(audit.jobIds).toContain('job-refresh-local-llm-catalog');+ });+it('does not place the same task type in two stages', () => {const seen = new Set();for (const stage of WORKFLOW_STAGES) {