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): cover both on-demand engines + classify no-task outcome

[._.]/ Adam Eivy5ed95964a0ad
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index d0f9e7e728..521ccdab6e 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,7 +2,7 @@
## CoS Agents
-- **An explicit "Run" of a perpetual claim/reconcile task that finds no work now tells you so — instead of silently doing nothing.** Triggering an on-demand `claim-issue` (or any perpetual task) that had nothing actionable produced zero UI feedback: the task parked with a log line buried in pm2, so the user was left wondering why "40 open issues" didn't spawn an agent. The on-demand path now (1) resets any existing park **and the branch/issue-reconcile convergence signature** before re-running the detector, so a manual trigger always re-checks live state and never honors a stale/cached verdict — previously an explicit "Run" of `branch-reconcile`/`issue-reconcile` could re-park `no-progress` against an unchanged-since-last-run set even though the user asked to re-drive; and (2) when the fresh check still finds no work, emits a `cos:schedule:on-demand-empty` event that surfaces a toast — e.g. *"claim-issue: re-checked now — no claimable issues (0 of 40 claimable — 2 in-flight, 38 filtered). Next auto-recheck in 33 hours."* The GitHub/GitLab work-detector now returns a breakdown (`open`, `inFlight` held by open claim branches/PRs, `filtered` skipped by label/assignee/epic), plumbed through the park record and event, so the message explains WHY a non-empty queue yields zero claimable work — the common case being issues already shipped whose stale `claim/issue-N` branches still count as in-flight. A trigger that DIDN'T park (a transient `gh`/`glab` probe failure) is worded honestly as *"couldn't complete the check just now — try again"* rather than falsely claiming there's nothing to do. The event fires ONLY for user-initiated on-demand runs (never background parks), so there's no toast spam. (`server/services/cos.js`, `server/services/perpetualWork.js`, `server/services/taskSchedule.js`, `server/services/socket.js`, `client/src/hooks/useOnDemandTaskToast.js`)
+- **An explicit "Run" of a perpetual claim/reconcile task that finds no work now tells you so — instead of silently doing nothing.** Triggering an on-demand `claim-issue` (or any perpetual task) that had nothing actionable produced zero UI feedback: the task parked with a log line buried in pm2, so the user was left wondering why "40 open issues" didn't spawn an agent. The on-demand path now (1) resets any existing park **and the branch/issue-reconcile convergence signature** before re-running the detector, so a manual trigger always re-checks live state and never honors a stale/cached verdict — previously an explicit "Run" of `branch-reconcile`/`issue-reconcile` could re-park `no-progress` against an unchanged-since-last-run set even though the user asked to re-drive; and (2) when the fresh check still finds no work, emits a `cos:schedule:on-demand-empty` event that surfaces a toast — e.g. *"claim-issue: re-checked now — no claimable issues (0 of 40 claimable — 2 in-flight, 38 filtered). Next auto-recheck in 33 hours."* The GitHub/GitLab work-detector now returns a breakdown (`open`, `inFlight` held by open claim branches/PRs, `filtered` skipped by label/assignee/epic), plumbed through the park record and event, so the message explains WHY a non-empty queue yields zero claimable work — the common case being issues already shipped whose stale `claim/issue-N` branches still count as in-flight. The event carries an `outcome` so the message fits the case: `parked` (perpetual detector found no work), `transient` (a `gh`/`glab` probe failure — *"couldn't complete the check just now — try again"*, never a false "nothing to do"), or `idle` (a non-perpetual task like `pr-watcher` genuinely had nothing — a calm neutral note, not an error). Both on-demand drain engines — `cos.dequeueNextTask` and `cosTaskGenerator.spawnPriority0OnDemand` — share the reset-and-emit path (via `emitOnDemandEmpty`), so a user Run gets feedback no matter which engine picks it up. The event fires ONLY for user-initiated on-demand runs (never background parks), so there's no toast spam. (`server/services/cos.js`, `server/services/cosTaskGenerator.js`, `server/services/perpetualWork.js`, `server/services/taskSchedule.js`, `server/services/socket.js`, `client/src/hooks/useOnDemandTaskToast.js`)
- **The proactive voice agent now announces a task's topic, not the raw prompt block.** When a voice-dispatched CoS task became ready or finished, the spoken line read the first ~240 characters of the task's `description` — which for a scheduled swarm/claim run is the `# ⚡ SWARM MODE — claim and ship up to 3 independent issues in parallel. This run operates in slashdo /do:next --swarm=3 mode. …` prompt scaffolding, so the assistant recited the orchestration preamble instead of naming the work. Both the "new task is ready" and "task is done" lines now derive a short topical label via a shared `deriveTaskSpeechLabel` helper that prefers an explicit title or the post-run agent summary and otherwise strips the first meaningful description line down to its topic (leading markdown heading, emoji, `[Claim Issue: App]` tag, `**bold**` markers, and the `SWARM MODE —` label), clipped to one phrase — so the swarm task speaks "claim and ship up to 3 independent issues in parallel" and a plain claim task speaks "Claim and ship the next open GitHub issue". (`server/services/voice/proactiveTriggers.js`)
diff --git a/client/src/hooks/useOnDemandTaskToast.js b/client/src/hooks/useOnDemandTaskToast.js
index c7bfb74d25..af592a71ad 100644
--- a/client/src/hooks/useOnDemandTaskToast.js
+++ b/client/src/hooks/useOnDemandTaskToast.js
@@ -32,10 +32,10 @@ export function useOnDemandTaskToast() {
const task = data?.taskType || 'task';
const scope = data?.appName ? ` for ${data.appName}` : '';
- // No park record ⇒ the detector did NOT park this run — a transient probe
- // failure (gh/glab down) or a non-perpetual skip. Never claim "nothing to
- // do" here; the check didn't complete.
- if (!data?.parked) {
+ // A perpetual task that did NOT park ⇒ the detector couldn't complete (a
+ // transient gh/glab probe failure). Never claim "nothing to do" — the
+ // check didn't finish.
+ if (data?.outcome === 'transient') {
toast(`${task}${scope}: couldn't complete the check just now (a transient forge/network issue) — try again shortly.`, {
duration: 7000,
icon: '⚠️'
@@ -43,6 +43,16 @@ export function useOnDemandTaskToast() {
return;
}
+ // A non-perpetual task produced no task ⇒ genuinely nothing to do right
+ // now (not a failure, not a park). Keep it calm and neutral.
+ if (data?.outcome === 'idle') {
+ toast(`${task}${scope}: re-checked now — nothing to do right now.`, {
+ duration: 6000,
+ icon: '💤'
+ });
+ return;
+ }
+
const reasonLabel = PARK_REASON_LABELS[data?.parkReason] || data?.parkReason || 'nothing to do';
// Detector breakdown ({ open, inFlight, filtered }) explains WHY an
diff --git a/server/services/cos.js b/server/services/cos.js
index edc635ef4a..6420fa3297 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -86,6 +86,7 @@ import {
queueEligibleImprovementTasks,
generateSelfImprovementTaskForType,
generateManagedAppImprovementTaskForType,
+ emitOnDemandEmpty,
blockIfExceedsMaxSpawns,
selectDryRunAutoApproved,
isCooldownExemptTask,
@@ -802,30 +803,12 @@ async function dequeueNextTask() {
trackSpawn(task);
}
} else if (!task) {
- // The explicit user "Run" produced no task. Surface WHY so the trigger
- // isn't a silent no-op the user only discovers in the pm2 logs. This event
- // fires ONLY on the on-demand (user-initiated) path, so the client can
- // toast it without background-park noise.
- //
- // Because we reset the park BEFORE the fresh detection above, a park
- // record here unambiguously means "this check parked" (definitive no
- // work). Its ABSENCE means the detector did NOT park — a transient probe
- // failure (gh/glab down) or a non-perpetual skip — which the client must
- // word as "couldn't re-check", never "nothing to do".
- const parkInfo = await taskScheduleMod
- .getPerpetualParkInfo(request.taskType, targetApp?.id || null)
- .catch(() => null);
- cosEvents.emit('schedule:on-demand-empty', {
- requestId: request.id,
- taskType: request.taskType,
- appId: targetApp?.id || null,
- appName: targetApp?.name || null,
- parked: !!parkInfo,
- parkReason: parkInfo?.parkReason || null,
- parkedUntil: parkInfo?.parkedUntil || null,
- actionableCount: parkInfo?.parkActionableCount ?? null,
- counts: parkInfo?.parkCounts || null
- });
+ // Explicit user "Run" produced no task — surface WHY (parked / transient /
+ // idle) so the trigger isn't a silent no-op. Shared with the sibling
+ // spawnPriority0OnDemand engine so a request drained by either path gets
+ // the same feedback. Because we reset the park BEFORE the fresh detection
+ // above, the outcome classification reflects THIS check.
+ await emitOnDemandEmpty({ taskScheduleMod, request, targetApp, taskConfig: taskSchedule.tasks[request.taskType] });
}
}
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index 6a6279a43e..3366f47a11 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -574,6 +574,10 @@ async function spawnPriority0OnDemand(ctx) {
if (targetApp) {
emitLog('info', `Processing on-demand improvement: ${request.taskType} for ${targetApp.name}`, { requestId: request.id, appId: targetApp.id });
+ // A user-initiated "Run" must re-check live state — reset any park + the
+ // reconcile convergence signature so the detector below runs fresh (see
+ // cos.dequeueNextTask for the full rationale).
+ await taskSchedule.resetPerpetualForManualRun(request.taskType, targetApp.id);
// Advance the cooldown eagerly (deduped per app per cycle), but defer
// binding the active agent until a task is produced — a null result
// here must not strand `activeAgentId` (issue #978).
@@ -588,6 +592,7 @@ async function spawnPriority0OnDemand(ctx) {
}
} else {
emitLog('info', `Processing on-demand improvement: ${request.taskType}`, { requestId: request.id });
+ await taskSchedule.resetPerpetualForManualRun(request.taskType);
await taskSchedule.recordExecution(`task:${request.taskType}`);
await withStateLock(async () => {
const s = await loadState();
@@ -604,6 +609,10 @@ async function spawnPriority0OnDemand(ctx) {
tasksToSpawn.push(task);
trackSpawn(task);
}
+ } else if (!task) {
+ // Explicit user Run produced no task on THIS engine too — same feedback
+ // as cos.dequeueNextTask so a request drained here isn't a silent no-op.
+ await emitOnDemandEmpty({ taskScheduleMod: taskSchedule, request, targetApp, taskConfig: liveSchedule.tasks[request.taskType] });
}
}
}
@@ -1492,6 +1501,42 @@ async function generateManagedAppImprovementTask(app, state) {
* @param {Object} state - Current CoS state
* @returns {Object} Generated task
*/
+/**
+ * Surface WHY a user-initiated on-demand "Run" produced no task, so the trigger
+ * isn't a silent no-op the user only discovers in the pm2 logs. Emits
+ * `schedule:on-demand-empty` (which the client toasts) with an `outcome`:
+ * - 'parked' → a perpetual detector re-checked and found no actionable work;
+ * carries the reason + open/in-flight/filtered breakdown.
+ * - 'transient' → a perpetual task that did NOT park — a transient gh/glab
+ * probe failure — so the check didn't actually complete.
+ * - 'idle' → a non-perpetual task produced no task: a genuine "nothing to
+ * do", NOT a failure (e.g. pr-watcher with no new PRs).
+ *
+ * Called from BOTH on-demand drain engines (cos.dequeueNextTask and
+ * spawnPriority0OnDemand below) so a user Run gets feedback no matter which one
+ * drains the request. `taskConfig` is the already-loaded interval for the task,
+ * passed in to avoid re-reading the schedule. The event fires ONLY on the
+ * user-initiated on-demand path, so the client can toast it without
+ * background-park noise.
+ */
+export async function emitOnDemandEmpty({ taskScheduleMod, request, targetApp, taskConfig }) {
+ const appId = targetApp?.id || null;
+ const parkInfo = await taskScheduleMod.getPerpetualParkInfo(request.taskType, appId).catch(() => null);
+ const isPerpetual = taskConfig?.type === taskScheduleMod.INTERVAL_TYPES.PERPETUAL;
+ const outcome = parkInfo ? 'parked' : (isPerpetual ? 'transient' : 'idle');
+ cosEvents.emit('schedule:on-demand-empty', {
+ requestId: request.id,
+ taskType: request.taskType,
+ appId,
+ appName: targetApp?.name || null,
+ outcome,
+ parkReason: parkInfo?.parkReason || null,
+ parkedUntil: parkInfo?.parkedUntil || null,
+ actionableCount: parkInfo?.parkActionableCount ?? null,
+ counts: parkInfo?.parkCounts || null
+ });
+}
+
export async function generateManagedAppImprovementTaskForType(taskType, app, state, { skipPreconditions = false } = {}) {
const { updateAppActivity } = await import('./appActivity.js');
const taskSchedule = await import('./taskSchedule.js');