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 (codex): per-app perpetual park status + recompute parks on cadence change

[._.]/ Adam Eivy1929c23e45d6
diff --git a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
index fab201acf5..aec54a35fd 100644
--- a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
+++ b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
@@ -218,14 +218,37 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
The check is programmatic (no LLM) — e.g. claim-issue counts open, claimable issues; an issue
the agent tags <code>needs-input</code> is excluded so the drain converges.
</p>
- {status.reason === 'perpetual-parked' && (
- <p className="text-xs text-port-warning mt-1">
- Parked{status.parkReason ? ` (${status.parkReason})` : ''}{status.nextRunAt ? ` — rechecks ${new Date(status.nextRunAt).toLocaleString()}` : ''}
- </p>
- )}
- {(status.reason === 'perpetual-drain' || status.reason === 'perpetual-recheck') && (
- <p className="text-xs text-port-success mt-1">Draining — actionable work available</p>
- )}
+ {(() => {
+ // claim-issue/claim-work park PER-APP, so prefer the per-app aggregate
+ // (config.perpetual) over the global status.reason — which always reads
+ // 'perpetual-drain' for app-scoped tasks even when every app is parked.
+ const p = config.perpetual;
+ if (p && (p.trackedAppCount > 0 || p.globalParked)) {
+ const allParked = p.globalParked || (p.trackedAppCount > 0 && p.parkedAppCount === p.trackedAppCount);
+ if (allParked) {
+ const scope = p.trackedAppCount > 0 ? `${p.trackedAppCount} app(s) parked` : 'Parked';
+ return (
+ <p className="text-xs text-port-warning mt-1">
+ {scope}{p.parkReason ? ` (${p.parkReason})` : ''}{p.nextRecheckAt ? ` — next recheck ${new Date(p.nextRecheckAt).toLocaleString()}` : ''}
+ </p>
+ );
+ }
+ const partial = p.parkedAppCount > 0 ? ` — ${p.parkedAppCount}/${p.trackedAppCount} app(s) parked` : '';
+ return <p className="text-xs text-port-success mt-1">Draining — actionable work available{partial}</p>;
+ }
+ // Global (non-app) perpetual task: the global status.reason is accurate.
+ if (status.reason === 'perpetual-parked') {
+ return (
+ <p className="text-xs text-port-warning mt-1">
+ Parked{status.parkReason ? ` (${status.parkReason})` : ''}{status.nextRunAt ? ` — rechecks ${new Date(status.nextRunAt).toLocaleString()}` : ''}
+ </p>
+ );
+ }
+ if (status.reason === 'perpetual-drain' || status.reason === 'perpetual-recheck') {
+ return <p className="text-xs text-port-success mt-1">Draining — actionable work available</p>;
+ }
+ return null;
+ })()}
</div>
)}
diff --git a/client/src/components/cos/tabs/schedule/scheduleConstants.js b/client/src/components/cos/tabs/schedule/scheduleConstants.js
index 76509de407..9d023195e1 100644
--- a/client/src/components/cos/tabs/schedule/scheduleConstants.js
+++ b/client/src/components/cos/tabs/schedule/scheduleConstants.js
@@ -105,8 +105,25 @@ export function describeNextRun(config) {
}
if (group === 'on-demand') return { text: 'Manual trigger only', tone: 'text-gray-400' };
if (config.type === 'perpetual') {
- const reason = config.status?.reason;
- if (reason === 'perpetual-parked') {
+ // Prefer the per-app park aggregate — claim-issue/claim-work park per-app, so
+ // the global status.reason reads 'perpetual-drain' even when all apps are parked.
+ const p = config.perpetual;
+ if (p && (p.trackedAppCount > 0 || p.globalParked)) {
+ // "Parked" only when there's nothing left draining: a global park, or every
+ // tracked app parked. A partial park (some apps still have work) is draining.
+ const allParked = p.globalParked || (p.trackedAppCount > 0 && p.parkedAppCount === p.trackedAppCount);
+ if (allParked) {
+ const scope = p.trackedAppCount > 0 ? `${p.trackedAppCount} app(s) parked` : 'parked';
+ return {
+ text: p.nextRecheckAt ? `${scope} · rechecks ${timeUntil(p.nextRecheckAt, 'soon')}` : `${scope} — no work`,
+ tone: 'text-gray-400',
+ title: p.parkReason ? `Parked: ${p.parkReason}` : undefined,
+ };
+ }
+ return { text: 'draining — runs back-to-back until done', tone: 'text-port-success' };
+ }
+ // Global (non-app) perpetual task: the global status.reason is accurate.
+ if (config.status?.reason === 'perpetual-parked') {
const next = config.status?.nextRunAt;
return {
text: next ? `parked · rechecks ${timeUntil(next, 'soon')}` : 'parked — no work',
diff --git a/client/src/components/cos/tabs/schedule/scheduleConstants.test.js b/client/src/components/cos/tabs/schedule/scheduleConstants.test.js
index b2fb7c9116..cc46acf6a7 100644
--- a/client/src/components/cos/tabs/schedule/scheduleConstants.test.js
+++ b/client/src/components/cos/tabs/schedule/scheduleConstants.test.js
@@ -115,6 +115,28 @@ describe('describeNextRun', () => {
expect(out.text).toMatch(/parked · rechecks/);
expect(out.title).toContain('no-actionable-issues');
});
+
+ it('prefers the per-app aggregate over the global drain status for app-scoped perpetual tasks', () => {
+ // Global status reads drain, but all tracked apps are parked — aggregate wins.
+ const out = describeNextRun({
+ enabled: true,
+ type: 'perpetual',
+ status: { reason: 'perpetual-drain' },
+ perpetual: { parkedAppCount: 2, trackedAppCount: 2, globalParked: false, nextRecheckAt: '2999-01-01T00:00:00Z', parkReason: 'no-actionable-issues' }
+ });
+ expect(out.text).toMatch(/2 app\(s\) parked · rechecks/);
+ expect(out.title).toContain('no-actionable-issues');
+ });
+
+ it('shows draining when some apps still have work in the aggregate', () => {
+ const out = describeNextRun({
+ enabled: true,
+ type: 'perpetual',
+ status: { reason: 'perpetual-drain' },
+ perpetual: { parkedAppCount: 1, trackedAppCount: 3, globalParked: false, nextRecheckAt: null, parkReason: null }
+ });
+ expect(out.text).toMatch(/draining/);
+ });
});
describe('coverageTone', () => {
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 3929d44c3f..44eda70939 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -599,6 +599,25 @@ export async function updateTaskInterval(taskType, settings) {
delete schedule.executions['task:pr-watcher'];
}
+ // When the recheck cadence of a perpetual task changes, re-derive the
+ // `parkedUntil` of any CURRENTLY-parked execution records (global + per-app)
+ // from the new cadence — otherwise an already-parked task keeps waiting out
+ // its old timestamp and the cadence control appears to do nothing until then.
+ // Only recompute existing parks (never create one), and compute from now so a
+ // shortened cadence takes effect on the next slot.
+ const merged = schedule.tasks[taskType];
+ if (merged.type === INTERVAL_TYPES.PERPETUAL && ('recheckCron' in settings || 'recheckIntervalMs' in settings)) {
+ const exec = schedule.executions[`task:${taskType}`];
+ if (exec) {
+ const records = [exec, ...Object.values(exec.perApp || {})];
+ for (const rec of records) {
+ if (rec?.parkedUntil) {
+ rec.parkedUntil = await computePerpetualRecheckAt(merged);
+ }
+ }
+ }
+ }
+
await saveSchedule(schedule);
// Globally disabling pr-watcher clears every app's high-water mark, mirroring
@@ -1257,6 +1276,30 @@ export async function getScheduleStatus() {
taskStatus.managedAgentOptions = MANAGED_AGENT_OPTIONS[taskType];
}
+ // Perpetual tasks park PER-APP (parkPerpetual is called with the appId), so
+ // the global `status` above (shouldRunTask with no appId) always reads
+ // 'perpetual-drain' for app-scoped tasks like claim-issue/claim-work even
+ // when every app is parked. Aggregate the per-app (and global) park records
+ // so the UI can show the true parked/draining state and the soonest recheck.
+ if (interval.type === INTERVAL_TYPES.PERPETUAL) {
+ const nowMs = Date.now();
+ const isParked = (r) => !!(r?.parkedUntil && new Date(r.parkedUntil).getTime() > nowMs);
+ const perAppEntries = Object.values(execution.perApp || {});
+ const parkedApps = perAppEntries.filter(isParked);
+ const globalParked = isParked(execution);
+ const nextRecheckAt = [
+ ...parkedApps.map((r) => r.parkedUntil),
+ ...(globalParked ? [execution.parkedUntil] : [])
+ ].filter(Boolean).sort()[0] || null;
+ taskStatus.perpetual = {
+ globalParked,
+ parkedAppCount: parkedApps.length,
+ trackedAppCount: perAppEntries.length,
+ nextRecheckAt,
+ parkReason: parkedApps[0]?.parkReason || (globalParked ? execution.parkReason : null) || null
+ };
+ }
+
status.tasks[taskType] = taskStatus;
if (learningInfo.adjusted) {
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index 6b20a5ddaf..c5f3637abc 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -114,6 +114,7 @@ import { DEFAULT_TASK_PROMPTS, PREVIOUS_DEFAULT_PROMPTS } from './taskPromptDefa
import { loadState } from './cosState.js'
import { readJSONFile } from '../lib/fileUtils.js'
+import { writeFile } from 'fs/promises'
import { isTaskTypeEnabledForApp, getAppTaskTypeInterval, clearAllPrWatcherState } from './apps.js'
import { getLocalParts } from '../lib/timezone.js'
import { getAdaptiveCooldownMultiplier } from './taskLearning.js'
@@ -1239,5 +1240,47 @@ describe('taskSchedule', () => {
expect(await clearPerpetualPark('claim-issue', 'app-1')).toBe(false)
})
})
+
+ describe('updateTaskInterval recompute-on-cadence-change', () => {
+ it('re-derives an existing park when the recheck cadence changes', async () => {
+ const farFuture = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString()
+ mockSchedule({
+ tasks: { 'claim-issue': { type: 'perpetual', enabled: true, recheckIntervalMs: 30 * 24 * 60 * 60 * 1000 } },
+ executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: { 'app-1': { lastRun: null, count: 0, parkedUntil: farFuture } } } }
+ })
+ await updateTaskInterval('claim-issue', { recheckIntervalMs: 1000 })
+ const saved = JSON.parse(writeFile.mock.calls.at(-1)[1])
+ const newParked = saved.executions['task:claim-issue'].perApp['app-1'].parkedUntil
+ // Recomputed from the shortened cadence (now + 1s), far earlier than the old 30-day park.
+ expect(new Date(newParked).getTime()).toBeLessThan(new Date(farFuture).getTime())
+ expect(new Date(newParked).getTime()).toBeLessThan(Date.now() + 60_000)
+ })
+
+ it('does not create a park when none exists', async () => {
+ mockSchedule({
+ tasks: { 'claim-issue': { type: 'perpetual', enabled: true } },
+ executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: { 'app-1': { lastRun: null, count: 0 } } } }
+ })
+ await updateTaskInterval('claim-issue', { recheckIntervalMs: 1000 })
+ const saved = JSON.parse(writeFile.mock.calls.at(-1)[1])
+ expect(saved.executions['task:claim-issue'].perApp['app-1'].parkedUntil).toBeUndefined()
+ })
+ })
+
+ describe('getScheduleStatus per-app park aggregate', () => {
+ it('aggregates per-app parks into taskStatus.perpetual', async () => {
+ const future = new Date(Date.now() + 60 * 60 * 1000).toISOString()
+ mockSchedule({
+ tasks: { 'claim-issue': { type: 'perpetual', enabled: true } },
+ executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: {
+ 'app-1': { lastRun: null, count: 0, parkedUntil: future, parkReason: 'no-actionable-issues' },
+ 'app-2': { lastRun: null, count: 0 }
+ } } }
+ })
+ const status = await getScheduleStatus()
+ const p = status.tasks['claim-issue'].perpetual
+ expect(p).toMatchObject({ parkedAppCount: 1, trackedAppCount: 2, globalParked: false, nextRecheckAt: future, parkReason: 'no-actionable-issues' })
+ })
+ })
})
})