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

fix: make disabled maintenance runs actionable

[._.]/ Adam Eivye1dda61fdd63
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsx
index ca86a79d7a..1529498149 100644
--- a/client/src/components/cos/tabs/ScheduleTab.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.jsx
@@ -88,6 +88,7 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr
const data = await api.getCosSchedule().catch(() => null);
setSchedule(data);
setLoading(false);
+ return data;
}, []);
useEffect(() => {
@@ -192,7 +193,7 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr
<p className="text-xs mt-1">Resolve findings between audits, then document the resulting code. Quota Burn offers this sequence with perpetual claim-issue drains between steps.</p>
<details className="mt-2">
<summary className="cursor-pointer text-sm font-medium">Run maintenance now</summary>
- <MaintenanceRunForm schedule={{ ...schedule, tasks }} apps={apps} providers={providers} providersLoaded={providersLoaded} improvementDisabled={improvementDisabled} daemonRunning={daemonRunning} />
+ <MaintenanceRunForm schedule={{ ...schedule, tasks }} apps={apps} providers={providers} providersLoaded={providersLoaded} improvementDisabled={improvementDisabled} daemonRunning={daemonRunning} onRefresh={fetchSchedule} />
</details>
</Banner>
diff --git a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsx b/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsx
index ddeafd3f61..be2e05992b 100644
--- a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsx
+++ b/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsx
@@ -3,25 +3,57 @@ import { uuidv4 } from '../../../../lib/uuid';
import { Link } from 'react-router';
import ProviderModelSelector from '../../../ProviderModelSelector';
import * as api from '../../../../services/api';
-import { buildQuotaBurnTaskCatalog, maintenanceSequence } from '../../../../lib/quotaBurnTasks';
+import { buildQuotaBurnTaskCatalog, maintenancePrerequisites, maintenanceSequence, taskSourceHref } from '../../../../lib/quotaBurnTasks';
import { effortAwareModelOptions, isProcessProvider } from '../../../../utils/providers';
import { familyForProvider } from '../../../../../../server/lib/providerFamilies';
-export default function MaintenanceRunForm({ schedule, apps = [], providers = [], providersLoaded, improvementDisabled, daemonRunning }) {
+export default function MaintenanceRunForm({ schedule, apps = [], providers = [], providersLoaded, improvementDisabled, daemonRunning, onRefresh }) {
const [appId, setAppId] = useState('');
const [providerId, setProviderId] = useState('');
const [model, setModel] = useState('');
const [effort, setEffort] = useState('');
const [consent, setConsent] = useState(false);
const [busy, setBusy] = useState(false);
+ const [preparing, setPreparing] = useState(false);
const [message, setMessage] = useState('');
const availableProviders = providers.filter(provider => provider.enabled && isProcessProvider(provider) && familyForProvider(provider));
const provider = availableProviders.find(entry => entry.id === providerId);
const familyId = familyForProvider(provider);
const groups = buildQuotaBurnTaskCatalog({ schedule, apps });
const jobs = maintenanceSequence(groups, appId, 'preview');
+ const prerequisites = maintenancePrerequisites(groups, appId);
const blocked = improvementDisabled || daemonRunning === false;
+ const prepare = async () => {
+ if (busy || !onRefresh || !prerequisites.length || prerequisites.some(item => item.unavailable)) return;
+ setBusy(true);
+ setPreparing(true);
+ setMessage('Enabling required tasks…');
+ const save = async () => {
+ for (const { taskType, settings, enableApp } of prerequisites) {
+ if (Object.keys(settings).length) {
+ const result = await api.updateCosTaskInterval(taskType, settings, { silent: true });
+ if (!result?.success) throw new Error(`Could not update ${taskType}`);
+ }
+ if (enableApp) {
+ const result = await api.updateAppTaskTypeOverride(appId, taskType, { enabled: true }, { silent: true });
+ if (!result?.success) throw new Error(`Could not enable ${taskType} for this app`);
+ }
+ }
+ return true;
+ };
+ const saved = await save().catch(error => {
+ setMessage(`Setup incomplete: ${error.message}. Saved changes are kept; retry to finish.`);
+ return false;
+ });
+ // Refresh even after a partial save so retries use the persisted settings.
+ const refreshed = await onRefresh().catch(() => false);
+ if (!refreshed) setMessage('Could not refresh task settings. Refresh the schedule before running maintenance.');
+ else if (saved) setMessage('Required tasks enabled. You can now run maintenance.');
+ setPreparing(false);
+ setBusy(false);
+ };
+
const run = async () => {
if (busy || blocked || !jobs || !provider || !model || !consent) return;
setBusy(true);
@@ -89,7 +121,20 @@ export default function MaintenanceRunForm({ schedule, apps = [], providers = []
loading={!providersLoaded}
disabled={busy}
/>
- {appId && !jobs && <p role="status">Enable every maintenance task and claim-issue for this app, and set claim-issue to perpetual, before running the sequence.</p>}
+ {appId && !jobs && <div className="space-y-2">
+ <p role="status">Run now needs these saved task settings:</p>
+ <ul className="list-disc pl-5 space-y-1">
+ {prerequisites.map(item => <li key={item.taskType}>
+ <Link className="underline" to={taskSourceHref(item)}>{item.taskType}</Link>: {item.reason}
+ </li>)}
+ </ul>
+ {onRefresh && !prerequisites.some(item => item.unavailable) && <>
+ <p className="text-xs">Enable the listed tasks globally and for this app, and set claim-issue to perpetual. This also allows their existing schedules to run.</p>
+ <button type="button" onClick={prepare} disabled={busy} className="px-3 py-1.5 bg-port-accent text-white rounded disabled:opacity-50">
+ {preparing ? 'Enabling…' : 'Enable required tasks'}
+ </button>
+ </>}
+ </div>}
{blocked && <p role="status">Enable Improvement and start the CoS daemon before running maintenance.</p>}
<p className="text-xs">Runs the first step now, bypassing its reset window, reserve, and dispatch cap; later steps continue in order through Quota Burn, subject to its quota gates. Supports subscription CLI/TUI providers. Blank effort inherits each scheduled task’s saved effort.</p>
<label className="flex items-start gap-2" htmlFor="maintenance-run-consent">
@@ -98,7 +143,7 @@ export default function MaintenanceRunForm({ schedule, apps = [], providers = []
</label>
<div className="flex items-center gap-3 flex-wrap">
<button type="button" onClick={run} disabled={busy || blocked || !jobs || !provider || !model || !consent || !providersLoaded} className="px-3 py-1.5 bg-port-accent text-white rounded disabled:opacity-50">
- {busy ? 'Starting…' : 'Run now'}
+ {busy && !preparing ? 'Starting…' : 'Run now'}
</button>
<Link className="underline" to={familyId ? `/devtools/quota-burn/${familyId}` : '/devtools/quota-burn'}>Manage sequence in Quota Burn</Link>
</div>
diff --git a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsx b/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsx
index 7850184d7b..3ad6c2e8ff 100644
--- a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsx
+++ b/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsx
@@ -1,3 +1,4 @@
+import { useState } from 'react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
@@ -5,7 +6,7 @@ import { MemoryRouter } from 'react-router';
import { MAINTENANCE_TASK_ORDER } from '../../../../lib/quotaBurnTasks';
import MaintenanceRunForm from './MaintenanceRunForm';
-const api = vi.hoisted(() => ({ getQuotaBurn: vi.fn(), saveQuotaBurn: vi.fn(), runQuotaBurn: vi.fn() }));
+const api = vi.hoisted(() => ({ getQuotaBurn: vi.fn(), saveQuotaBurn: vi.fn(), runQuotaBurn: vi.fn(), updateCosTaskInterval: vi.fn(), updateAppTaskTypeOverride: vi.fn() }));
vi.mock('../../../../services/api', () => api);
const tasks = Object.fromEntries([...MAINTENANCE_TASK_ORDER, 'claim-issue'].map(taskType => [taskType, {
enabled: true, perpetual: taskType === 'claim-issue', appOverrides: { example: { enabled: true } },
@@ -25,6 +26,8 @@ const select = async user => {
};
beforeEach(() => {
vi.clearAllMocks();
+ api.updateCosTaskInterval.mockResolvedValue({ success: true });
+ api.updateAppTaskTypeOverride.mockResolvedValue({ success: true });
api.getQuotaBurn.mockResolvedValue({ config: { families: {} } });
api.saveQuotaBurn.mockResolvedValue({ config: {} });
api.runQuotaBurn.mockResolvedValue({ result: { dispatched: true } });
@@ -95,8 +98,59 @@ describe('maintenance launch', () => {
show({ schedule: { tasks: {} }, daemonRunning: false });
await select(user);
expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();
- expect(screen.getByText(/Enable every maintenance task/)).toBeInTheDocument();
+ expect(screen.getByText(/Run now needs these saved task settings/)).toBeInTheDocument();
expect(screen.getByText(/start the CoS daemon/)).toBeInTheDocument();
expect(api.saveQuotaBurn).not.toHaveBeenCalled();
});
});
+
+// Regression: a valid provider/model selection must have a path out of the
+// disabled launch state, and only persisted prerequisites may unlock launch.
+it('enables only missing prerequisites and waits for refreshed saved settings before launch', async () => {
+ const user = userEvent.setup();
+ const incomplete = { ...tasks,
+ simplify: { ...tasks.simplify, enabled: false, appOverrides: {} },
+ 'claim-issue': { ...tasks['claim-issue'], perpetual: false },
+ };
+ let finishRefresh;
+ const refreshed = new Promise(resolve => { finishRefresh = resolve; });
+ function Harness() {
+ const [schedule, setSchedule] = useState({ tasks: incomplete });
+ return <MaintenanceRunForm {...props} schedule={schedule} onRefresh={async () => {
+ await refreshed;
+ setSchedule({ tasks });
+ return { tasks };
+ }} />;
+ }
+ render(<MemoryRouter><Harness /></MemoryRouter>);
+ await select(user);
+ expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();
+ expect(screen.getByRole('link', { name: 'simplify' })).toHaveAttribute('href', '/cos/schedule?task=simplify');
+ expect(screen.getByText(/disabled globally; disabled for this app/)).toBeInTheDocument();
+ await user.click(screen.getByRole('button', { name: 'Enable required tasks' }));
+ await waitFor(() => expect(api.updateCosTaskInterval).toHaveBeenCalledTimes(2));
+ expect(api.updateCosTaskInterval).toHaveBeenCalledWith('simplify', { enabled: true }, { silent: true });
+ expect(api.updateCosTaskInterval).toHaveBeenCalledWith('claim-issue', { perpetual: true }, { silent: true });
+ expect(api.updateAppTaskTypeOverride).toHaveBeenCalledExactlyOnceWith('example', 'simplify', { enabled: true }, { silent: true });
+ expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();
+ expect(screen.getByRole('combobox', { name: 'App' })).toBeDisabled();
+ expect(api.runQuotaBurn).not.toHaveBeenCalled();
+ finishRefresh();
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Run now' })).toBeEnabled());
+ await user.click(screen.getByRole('button', { name: 'Run now' }));
+ expect(await screen.findByText(/Maintenance started/)).toBeInTheDocument();
+});
+
+it('refreshes partial setup after failure without saving a plan or starting work', async () => {
+ const user = userEvent.setup();
+ const onRefresh = vi.fn().mockResolvedValue({ tasks });
+ api.updateAppTaskTypeOverride.mockRejectedValueOnce(new Error('save unavailable'));
+ show({ schedule: { tasks: { ...tasks, simplify: { ...tasks.simplify, enabled: false, appOverrides: {} } } }, onRefresh });
+ await select(user);
+ await user.click(screen.getByRole('button', { name: 'Enable required tasks' }));
+ expect(await screen.findByText(/Setup incomplete: save unavailable/)).toBeInTheDocument();
+ expect(onRefresh).toHaveBeenCalledOnce();
+ expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();
+ expect(api.saveQuotaBurn).not.toHaveBeenCalled();
+ expect(api.runQuotaBurn).not.toHaveBeenCalled();
+});
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index af8b6f6c6c..adb8973b26 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -130,7 +130,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `clientErrorReporter.js` | `reportClientError({ type, error?, message?, ... })` — POSTs window.onerror + unhandledrejection events to `/api/client-errors` with throttle + dedup, dropping browser-extension errors (see `extensionErrors.js`) before either gate. Wired from `main.jsx`; never call directly from React components. |
| `clinicianReport.js` | Pure builders for the MeatSpace clinician-export view (`/meatspace/export`). `buildClinicianReport({ tests, config })` → structured report model (blood panels grouped by category with reference ranges + out-of-range flags, plus a lifestyle summary); `reportToMarkdown(report)` → copy-paste markdown. Reuses the Blood tab's `REFERENCE_RANGES` / `getBloodValueStatus` so printed flags match the UI. Also exports `buildBloodTestModel`, `buildLifestyleModel`, `getCategoryForKey`, `formatRange`. |
| `quotaBurnPatch.js` | `mergeQuotaBurnPatch(base, patch)` — mirrors the server's quota-burn config merge (top-level + per-family keys merge, a family's `jobs` array replaces) so the Quota Burn page can apply an edit optimistically and accumulate debounced edits into one PUT body. `quotaBurnJobIsSpent(job, ranAt)` — whether a `run once` step has had its one dispatch, gated on the optimistic config's own `runOnce` so a just-ticked checkbox reads as spent before the save round-trips (the client mirror of the server's `jobIsSpent`). `UNLIMITED_DISPATCHES` / `isUnlimitedDispatchCap(cap)` / `dispatchCapInput(value)` — the -1 "no dispatch cap" sentinel (the default), mirrored from the server. |
-| `quotaBurnTasks.js` | `MAINTENANCE_TASK_ORDER` / `MAINTENANCE_ORDER_GUIDANCE` document the default ladder; `maintenanceSequence` populates audit and claim-drain references. The Quota Burn page's view of the SHARED scheduled-task catalog. `buildQuotaBurnTaskCatalog({ schedule, jobs, apps })` groups PortOS built-in task types and app custom jobs into the picker's two groups (dropping what a burn may never invoke, and stamping a `blockedReason` on what is merely disabled or untargetable); `searchTaskCatalog` / `flattenTaskCatalog` / `findTaskEntry` query it. `taskRefKey` / `stepFromTaskEntry` / `taskEntryNeedsApp` build and address a step's `taskRef`. `effectiveQuotaBurnSettings(step, saved)` mirrors the server's `effectiveSettings` (overrides layered over the task's saved settings, params merged key-by-key). `quotaBurnStepPayload(job)` reduces a step to what the strict PUT schema accepts, dropping the top-level override mirrors that would otherwise outrank the `overrides` bag. `taskSourceHref(entry)` / `CREATE_TASK_HREF` link out to the source task. |
+| `quotaBurnTasks.js` | `MAINTENANCE_TASK_ORDER` / `MAINTENANCE_ORDER_GUIDANCE` document the default ladder; `maintenanceSequence` populates audit and claim-drain references; `maintenancePrerequisites` lists missing saved settings and scoped setup patches. The Quota Burn page's view of the SHARED scheduled-task catalog. `buildQuotaBurnTaskCatalog({ schedule, jobs, apps })` groups PortOS built-in task types and app custom jobs into the picker's two groups (dropping what a burn may never invoke, and stamping a `blockedReason` on what is merely disabled or untargetable); `searchTaskCatalog` / `flattenTaskCatalog` / `findTaskEntry` query it. `taskRefKey` / `stepFromTaskEntry` / `taskEntryNeedsApp` build and address a step's `taskRef`. `effectiveQuotaBurnSettings(step, saved)` mirrors the server's `effectiveSettings` (overrides layered over the task's saved settings, params merged key-by-key). `quotaBurnStepPayload(job)` reduces a step to what the strict PUT schema accepts, dropping the top-level override mirrors that would otherwise outrank the `overrides` bag. `taskSourceHref(entry)` / `CREATE_TASK_HREF` link out to the source task. |
| `clipboard.js` | `copyToClipboard`, `writeClipboardSilently`, `readClipboard` — safe across insecure-origin contexts. Use these instead of `navigator.clipboard.writeText` inline. |
| `effortCostEstimate.js` | `withEstimatedCosts(observations)` / `deriveEffortCostRatios(observations)` — fill the reasoning-effort rows Artificial Analysis publishes a quality score but no cost per task for, by scaling each model's own published cost anchor along the effort-cost curve measured across the models that do publish a full set. Estimated rows are flagged `costEstimated`; nothing is written back to the catalog. |
| `falVideoHandoff.js` | `buildFalH3MaxPrompt(prompt, negativePrompt)` composes the provider-neutral shot prompt fal's free MiniMax H3 Max tool is driven with; `FAL_H3_MAX_FREE_URL` and `FAL_H3_MAX_FREE_ALLOWANCE_NOTE` carry the tool URL and current vendor allowance copy. The free web allowance is deliberately a handoff, not the separately metered fal API. |
diff --git a/client/src/lib/quotaBurnTasks.js b/client/src/lib/quotaBurnTasks.js
index eac92ef664..98718a368a 100644
--- a/client/src/lib/quotaBurnTasks.js
+++ b/client/src/lib/quotaBurnTasks.js
@@ -259,14 +259,34 @@ export const MAINTENANCE_TASK_ORDER = Object.freeze([
]);
export const MAINTENANCE_ORDER_GUIDANCE = 'better-structural-drift → simplify → module-hygiene → better-complexity → performance + better-cognitive-load → documentation';
+/** Saved settings required by the maintenance ladder, including actionable patches. */
+export function maintenancePrerequisites(groups, appId) {
+ if (!appId) return [];
+ const entries = flattenTaskCatalog(groups);
+ return [...MAINTENANCE_TASK_ORDER, 'claim-issue'].flatMap(taskType => {
+ const entry = entries.find(candidate => candidate.taskType === taskType);
+ if (!entry) return [{ taskType, reason: 'unavailable in Scheduled Tasks', unavailable: true }];
+ const settings = {
+ ...(!entry.enabled ? { enabled: true } : {}),
+ ...(taskType === 'claim-issue' && entry.config.perpetual !== true ? { perpetual: true } : {}),
+ };
+ const enableApp = !entry.appIds.includes(appId);
+ const reasons = [
+ !entry.enabled && 'disabled globally',
+ enableApp && 'disabled for this app',
+ settings.perpetual && 'must use perpetual mode',
+ ].filter(Boolean);
+ return reasons.length ? [{ taskType, reason: reasons.join('; '), settings, enableApp }] : [];
+ });
+}
+
/** Populate references only; preserve the source tasks and their configured filters. */
export function maintenanceSequence(groups, appId, idPrefix) {
const entries = flattenTaskCatalog(groups);
const types = MAINTENANCE_TASK_ORDER.flatMap((type, index) =>
index ? ['claim-issue', type] : [type]);
const picked = types.map(type => entries.find(entry => entry.taskType === type));
- if (!appId || picked.some(entry => !entry || entry.blockedReason || !entry.appIds.includes(appId))) return null;
- if (picked.find(entry => entry.taskType === 'claim-issue').config.perpetual !== true) return null;
+ if (!appId || maintenancePrerequisites(groups, appId).length) return null;
return picked.map((entry, index) => ({
...stepFromTaskEntry(entry, { id: `${idPrefix}-${index}`, appId }),
runOnce: true,