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

address review: migrate legacy improve flags in loadState; reject unknown task types; mirror task-enabled guard in evaluateTasks

[._.]/ Adam Eivy4a10d25a55e8
diff --git a/server/services/cos.js b/server/services/cos.js
index eedb898439..9c62169c57 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -650,6 +650,7 @@ export async function evaluateTasks() {
// Priority 0: On-demand task requests (highest priority - user explicitly requested these)
const taskSchedule = await import('./taskSchedule.js');
const onDemandRequests = await taskSchedule.getOnDemandRequests();
+ const liveSchedule = onDemandRequests.length > 0 ? await taskSchedule.loadSchedule() : null;
if (onDemandRequests.length > 0 && tasksToSpawn.length < availableSlots) {
for (const request of onDemandRequests) {
@@ -661,6 +662,13 @@ export async function evaluateTasks() {
continue;
}
+ // Skip if the task type was disabled or removed after queuing — parity with dequeueNextTask.
+ if (!liveSchedule.tasks[request.taskType]?.enabled) {
+ emitLog('info', `On-demand request skipped — task type '${request.taskType}' is disabled`, { requestId: request.id });
+ await taskSchedule.clearOnDemandRequest(request.id);
+ continue;
+ }
+
let task = null;
// Determine target app (if any)
const apps = await getActiveApps().catch(() => []);
diff --git a/server/services/cosState.js b/server/services/cosState.js
index 5b9e8b2800..d5b2fdd423 100644
--- a/server/services/cosState.js
+++ b/server/services/cosState.js
@@ -150,11 +150,19 @@ export async function loadState() {
return stateCache;
}
- // Merge with defaults to ensure all fields exist
+ // Migrate legacy split flags before merging defaults — DEFAULT_CONFIG.improvementEnabled = true
+ // would otherwise shadow a v1 file that only set selfImprovementEnabled/appImprovementEnabled.
+ const persistedConfig = state.config || {};
+ if (persistedConfig.improvementEnabled === undefined &&
+ (persistedConfig.selfImprovementEnabled !== undefined || persistedConfig.appImprovementEnabled !== undefined)) {
+ persistedConfig.improvementEnabled =
+ persistedConfig.selfImprovementEnabled || persistedConfig.appImprovementEnabled;
+ }
+
stateCache = {
...DEFAULT_STATE,
...state,
- config: { ...DEFAULT_CONFIG, ...state.config },
+ config: { ...DEFAULT_CONFIG, ...persistedConfig },
stats: { ...DEFAULT_STATE.stats, ...state.stats },
agents: state.agents ?? {}
};
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 73f59c8376..3b8e16332b 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -1894,8 +1894,11 @@ export async function triggerOnDemandTask(taskType, appId = null) {
const schedule = await loadSchedule();
// Cheap per-task-type check first; the master-flag check pays a state.json read.
- const interval = schedule.tasks[taskType];
- if (interval && !interval.enabled) {
+ const tasks = schedule.tasks || {};
+ if (!Object.prototype.hasOwnProperty.call(tasks, taskType)) {
+ return { error: `Unknown task type '${taskType}'` };
+ }
+ if (!tasks[taskType].enabled) {
return { error: `Task type '${taskType}' is disabled` };
}
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index 9cc2afaf86..f76976acd2 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -535,6 +535,17 @@ describe('taskSchedule', () => {
expect(loadState).not.toHaveBeenCalled()
})
+ it('should reject unknown task types instead of silently queuing them', async () => {
+ mockSchedule({
+ tasks: { 'feature-ideas': { type: 'weekly', enabled: true } }
+ })
+
+ const result = await triggerOnDemandTask('not-a-real-type', 'critical-mass')
+
+ expect(result.error).toMatch(/unknown task type 'not-a-real-type'/i)
+ expect(loadState).not.toHaveBeenCalled()
+ })
+
it('should fall back to legacy split flags when improvementEnabled is undefined', async () => {
mockSchedule({
tasks: { 'feature-ideas': { type: 'weekly', enabled: true } }