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
surface UI feedback when an on-demand CoS task run finds no work
[._.]/ Adam Eivyffbf6c636750
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d0da96bd36..d0f9e7e728 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## 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`)+- **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`)- **[issue-2259] `issue-reconcile` now heals JIRA zombie tickets as well as GitHub/GitLab issues.** Following the GitLab sibling (#2249), the zombie-scan is now JIRA-aware. JIRA has no `in-progress` label to release, so the zombie is STATUS-based: a ticket left **In Review** (the claim-issue-jira success end-state) whose MR/PR shipped with remaining scope and NO live `claim/<KEY>` branch anywhere. Detection flows through the PortOS JIRA API (`fetchMyCurrentSprintTickets` — a new non-swallowing variant of `getMyCurrentSprintTickets` so a transient API blip skips-without-parking instead of being misread as an empty sprint) + git-ref scan for `claim/<KEY>` / `cos/…/<KEY>/…` claim branches — no `gh`/`glab` equivalent. JIRA tickets normalize into the SAME common `{ number, title, url, status, hasMergedPr, hasLiveClaim, hasActiveAgent }` shape the forges use, so the pure classifier/signature stay shared: In-Review → ZOMBIE, plain In-Progress → STALLED, To Do / Done → excluded so the scan converges. Routing mirrors `resolveAppWorkTracker` — JIRA is NEVER auto-selected from the git host; it's chosen only when the app's resolved `workTracker` is `'jira'` with enabled `jira.instanceId`/`projectKey`. The coordinator prompt gains a JIRA arm (heal via ticket transitions + `POST /api/jira/instances/:id/tickets` rather than close+relabel), bumped to v3 with the v2 body preserved in `PREVIOUS_DEFAULT_PROMPTS`. (`server/services/issueReconcile.js`, `server/services/jira.js`, `server/services/cosTaskGenerator.js`, `server/services/taskPromptDefaults/`)diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex d206cd9209..ab310f240f 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -96,6 +96,7 @@ import Logo from './Logo';import { useErrorNotifications } from '../hooks/useErrorNotifications';import { useNotifications } from '../hooks/useNotifications';import { useAgentFeedbackToast } from '../hooks/useAgentFeedbackToast';+import { useOnDemandTaskToast } from '../hooks/useOnDemandTaskToast';import { useSharingNotifications } from '../hooks/useSharingNotifications';import { useUpdateChecker } from '../hooks/useUpdateChecker';import { useAIStatusNotifications } from '../hooks/useAIStatusNotifications';@@ -496,6 +497,9 @@ export default function Layout() {// Subscribe to agent completion feedback toastsuseAgentFeedbackToast();+ // Toast when a user-triggered on-demand task run found no actionable work+ useOnDemandTaskToast();+// Live AI operation status (model loads, "calling LM Studio…", etc.)useAIStatusNotifications();diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex 3692597f55..78410ba38b 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -23,6 +23,7 @@ grep -i "what you want to do" client/src/hooks/README.md| `useErrorNotifications` | Subscribes to server error events and shows toasts. | Wire once high in the tree to surface server errors. || `useAIStatusNotifications` | Subscribes to AI operation status events. | Wire once to surface AI run lifecycle as toasts. || `useAgentFeedbackToast` | Agent completion toast with thumbs-up/down UI. | Show actionable agent-run completion feedback. |+| `useOnDemandTaskToast` | Toasts when a user-triggered on-demand task run found no work (parked). | Wire once high in the tree so an explicit "Run" that parks isn't a silent no-op. || `useSharingNotifications` | Subscriber for share-bucket notifications. | Wire once to surface federation/sync events. |## Pipeline / Story Builder wiringdiff --git a/client/src/hooks/index.js b/client/src/hooks/index.jsindex 9f0224eda5..334c4d6f16 100644--- a/client/src/hooks/index.js+++ b/client/src/hooks/index.js@@ -59,6 +59,7 @@ export * from './useAIStatusNotifications.js';export * from './useAgentFeedbackToast.jsx';export * from './useErrorNotifications.js';export * from './useNotifications.js';+export * from './useOnDemandTaskToast.js';export * from './useSharingNotifications.js';// === Pipeline / Story Builder wiring ===diff --git a/client/src/hooks/useOnDemandTaskToast.js b/client/src/hooks/useOnDemandTaskToast.jsnew file mode 100644index 0000000000..c7bfb74d25--- /dev/null+++ b/client/src/hooks/useOnDemandTaskToast.js@@ -0,0 +1,80 @@+import { useEffect } from 'react';+import toast from '../components/ui/Toast';+import socket from '../services/socket';+import { timeUntil } from '../utils/formatters';++// Humanize a perpetual work-detector park reason for a user-facing toast. The+// raw reason strings are the same ones surfaced in the CoS → Schedule tab; here+// they get a plain-language gloss so an explicit "Run" that found nothing tells+// the user WHAT it checked rather than an opaque token.+const PARK_REASON_LABELS = {+ 'no-actionable-issues': 'no claimable issues',+ 'no-open-issues': 'no open issues',+ 'no-in-flight-branches': 'no branches in flight',+ 'no-zombie-issues': 'no stale issues to reconcile',+ 'no-actionable-plan-items': 'no unblocked PLAN items',+ 'no-progress': 'already up to date',+ 'no-detector': 'no work detector for this task'+};++/**+ * Global subscriber that toasts when a user-initiated on-demand task run+ * produced no work. The server emits `cos:schedule:on-demand-empty` ONLY for+ * explicit "Run" triggers (never background parks), so this fires exactly when+ * the user is waiting for feedback and otherwise gets a silent no-op. Mount once+ * high in the tree (Layout), alongside useErrorNotifications.+ */+export function useOnDemandTaskToast() {+ useEffect(() => {+ socket.emit('cos:subscribe');++ const handleEmpty = (data) => {+ 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) {+ toast(`${task}${scope}: couldn't complete the check just now (a transient forge/network issue) — try again shortly.`, {+ duration: 7000,+ icon: '⚠️'+ });+ return;+ }++ const reasonLabel = PARK_REASON_LABELS[data?.parkReason] || data?.parkReason || 'nothing to do';++ // Detector breakdown ({ open, inFlight, filtered }) explains WHY an+ // apparently-full queue is empty — the common case being issues already+ // shipped whose stale claim branches still count as in-flight. Only shown+ // when the detector reported a denominator (open > 0).+ const c = data?.counts;+ let countSuffix = '';+ if (c && typeof c.open === 'number' && c.open > 0) {+ const parts = [];+ if (c.inFlight) parts.push(`${c.inFlight} in-flight`);+ if (c.filtered) parts.push(`${c.filtered} filtered`);+ const detail = parts.length ? ` — ${parts.join(', ')}` : '';+ countSuffix = ` (0 of ${c.open} claimable${detail})`;+ }++ const recheckSuffix = data?.parkedUntil+ ? ` Next auto-recheck ${timeUntil(data.parkedUntil, 'soon')}.`+ : '';++ // Re-checked live on this trigger — say so, since the confusing case is a+ // "parked until <future>" line that reads like a cached refusal.+ toast(`${task}${scope}: re-checked now — ${reasonLabel}${countSuffix}.${recheckSuffix}`, {+ duration: 7000,+ icon: '💤'+ });+ };++ socket.on('cos:schedule:on-demand-empty', handleEmpty);+ return () => {+ socket.off('cos:schedule:on-demand-empty', handleEmpty);+ // Don't unsubscribe from cos — other components share the room.+ };+ }, []);+}diff --git a/server/services/cos.js b/server/services/cos.jsindex 2b3c1dd5b2..edc635ef4a 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -764,6 +764,11 @@ async function dequeueNextTask() {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, never honor a stale+ // park or convergence signature — resetting both up front guarantees the+ // detector/reconcile below runs fresh and dispatches on live state (and,+ // if still idle, re-stamps a park reflecting THIS check).+ await taskScheduleMod.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).@@ -778,6 +783,8 @@ async function dequeueNextTask() {}} else {emitLog('info', `Processing on-demand improvement: ${request.taskType}`, { requestId: request.id });+ // Same fresh-check guarantee as the app-scoped branch above.+ await taskScheduleMod.resetPerpetualForManualRun(request.taskType);await taskScheduleMod.recordExecution(`task:${request.taskType}`);await withStateLock(async () => {const s = await loadState();@@ -794,6 +801,31 @@ async function dequeueNextTask() {cosEvents.emit('task:ready', task);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+ });}}diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.jsindex 7cf6d5204e..6a6279a43e 100644--- a/server/services/cosTaskGenerator.js+++ b/server/services/cosTaskGenerator.js@@ -1600,7 +1600,12 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, stemitLog('debug', `Perpetual ${taskType} skip for ${app.name} (transient: ${detection.reason})`, { appId: app.id });return null;} else {- await taskSchedule.parkPerpetual(taskType, app.id, { reason: detection.reason, actionableCount: detection.count });+ // Carry the detector's open/in-flight/filtered breakdown into the park so+ // an explicit "Run" can explain WHY a non-empty queue yielded no work.+ const counts = detection.total != null+ ? { open: detection.total, inFlight: detection.inFlightCount ?? 0, filtered: detection.filteredCount ?? 0 }+ : null;+ await taskSchedule.parkPerpetual(taskType, app.id, { reason: detection.reason, actionableCount: detection.count, counts });emitLog('info', `Perpetual ${taskType} parked for ${app.name}: ${detection.reason}`, { appId: app.id });return null;}diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.jsindex 95ccd9cb5d..4f762e4c7d 100644--- a/server/services/perpetualWork.js+++ b/server/services/perpetualWork.js@@ -235,14 +235,25 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self' } =return { actionable: false, count: 0, reason: cfg.parseFail, transient: true };}if (!Array.isArray(raw)) return { actionable: false, count: 0, reason: cfg.parseFail, transient: true };- if (raw.length === 0) return { actionable: false, count: 0, reason: 'no-open-issues' };+ if (raw.length === 0) return { actionable: false, count: 0, total: 0, inFlightCount: 0, filteredCount: 0, reason: 'no-open-issues' };const inFlight = await inFlightIssueNumbers(repoPath, cfg.inFlightForge);const issues = cfg.normalize(raw);+ const total = issues.length;+ // How many of the OPEN issues were skipped only because a claim/PR is already+ // in flight for them (stale post-merge branches count here). Surfacing this+ // separately from the label/assignee/epic filter tells the user WHY an+ // apparently-non-empty queue yields zero claimable work — the exact confusion+ // behind "40 open issues but it parked."+ const inFlightCount = issues.filter((i) => typeof i.number === 'number' && inFlight.has(i.number)).length;const actionable = issues.filter((issue) => isActionableIssue(issue, inFlight));+ const filteredCount = Math.max(0, total - actionable.length - inFlightCount);return {actionable: actionable.length > 0,count: actionable.length,+ total,+ inFlightCount,+ filteredCount,reason: actionable.length > 0 ? 'actionable-issues' : 'no-actionable-issues',sample: actionable.slice(0, 5).map((i) => i.number)};diff --git a/server/services/perpetualWork.test.js b/server/services/perpetualWork.test.jsindex 0c73e3fa0a..3c027d74ef 100644--- a/server/services/perpetualWork.test.js+++ b/server/services/perpetualWork.test.js@@ -155,12 +155,34 @@ describe('perpetualWork', () => {expect(out.actionable).toBe(true);expect(out.count).toBe(2); // #1 and #5 (plan is claimable); #2 #3 #4 excludedexpect(out.sample).toEqual([1, 5]);+ // Breakdown surfaced for the UI: 5 open, 1 in-flight (#4), 2 filtered+ // (#2 needs-input, #3 assigned), 2 actionable.+ expect(out.total).toBe(5);+ expect(out.inFlightCount).toBe(1);+ expect(out.filteredCount).toBe(2);+ });++ it('reports the open/in-flight breakdown when nothing is claimable (the "40 open but parked" case)', async () => {+ routeSpawn({+ 'gh issue': { stdout: JSON.stringify([+ { number: 1, title: 'shipped, stale branch', assignees: [], labels: [] },+ { number: 2, title: 'shipped, stale branch', assignees: [], labels: [] },+ { number: 3, title: 'blocked', assignees: [], labels: [{ name: 'blocked' }] }+ ]) },+ 'git branch': { stdout: 'main\norigin/claim/issue-1\norigin/claim/issue-2\n' },+ 'gh pr': { stdout: '' }+ });+ const out = await detectGithubIssues(app, { issueAuthorFilter: 'any' });+ expect(out).toMatchObject({ actionable: false, count: 0, reason: 'no-actionable-issues' });+ expect(out.total).toBe(3);+ expect(out.inFlightCount).toBe(2); // #1 + #2 held by stale claim branches+ expect(out.filteredCount).toBe(1); // #3 blocked});it('parks (no-open-issues) on an empty list', async () => {routeSpawn({ 'gh issue': { stdout: '[]' } });const out = await detectGithubIssues(app, { issueAuthorFilter: 'any' });- expect(out).toMatchObject({ actionable: false, reason: 'no-open-issues' });+ expect(out).toMatchObject({ actionable: false, reason: 'no-open-issues', total: 0, inFlightCount: 0 });});it('reports a transient failure when gh exits non-zero', async () => {diff --git a/server/services/socket.js b/server/services/socket.jsindex 69c6103444..886ad49ef8 100644--- a/server/services/socket.js+++ b/server/services/socket.js@@ -728,6 +728,11 @@ function setupCosEventForwarding() {// Watcher eventscosEvents.on('watcher:started', (data) => broadcastToCos('cos:watcher:started', data));cosEvents.on('watcher:stopped', (data) => broadcastToCos('cos:watcher:stopped', data));++ // A user-initiated on-demand "Run" that produced no task — the client toasts+ // this so an explicit trigger that finds no actionable work (parked) isn't a+ // silent no-op.+ cosEvents.on('schedule:on-demand-empty', (data) => broadcastToCos('cos:schedule:on-demand-empty', data));}// Set up error event forwardingdiff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex 14a9ec8ef6..76f6ee83eb 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -743,7 +743,7 @@ export async function computePerpetualRecheckAt(interval, fromMs = Date.now()) {* skeleton if absent.*/function ensureExecutionRecord(schedule, taskType, appId) {- const key = taskType.startsWith('task:') ? taskType : `task:${taskType}`;+ const key = executionKey(taskType);if (!schedule.executions[key]) {schedule.executions[key] = { lastRun: null, count: 0, perApp: {} };}@@ -756,12 +756,33 @@ function ensureExecutionRecord(schedule, taskType, appId) {return top;}+/** Normalize a task type to its `task:`-prefixed executions map key. */+function executionKey(taskType) {+ return taskType.startsWith('task:') ? taskType : `task:${taskType}`;+}++/**+ * Resolve the EXISTING execution sub-record (global or per-app) without creating+ * it — the read-only counterpart to ensureExecutionRecord. Returns null when the+ * task (or that app) has no record yet.+ */+function resolveExecutionRecord(schedule, taskType, appId = null) {+ const top = schedule.executions[executionKey(taskType)];+ if (!top) return null;+ return (appId ? top.perApp?.[appId] : top) || null;+}++// Every field parkPerpetual stamps for a park. Kept as one list so the clear /+// reset paths can't drift from what park writes (adding a park field here is the+// single edit that keeps all three in sync).+const PARK_FIELDS = ['parkedUntil', 'parkReason', 'parkActionableCount', 'parkCounts', 'parkedAt'];+/*** Park a perpetual task: its work-detector reported nothing actionable, so stop* draining and wait until `parkedUntil` before re-probing. Stamps the park* fields on the (per-app or global) execution record.*/-export async function parkPerpetual(taskType, appId = null, { reason = null, actionableCount = 0, signature } = {}) {+export async function parkPerpetual(taskType, appId = null, { reason = null, actionableCount = 0, counts = null, signature } = {}) {const schedule = await loadSchedule();const interval = schedule.tasks[taskType] || {};const parkedUntil = await computePerpetualRecheckAt(interval);@@ -769,6 +790,12 @@ export async function parkPerpetual(taskType, appId = null, { reason = null, actrecord.parkedUntil = parkedUntil;record.parkReason = reason;record.parkActionableCount = actionableCount;+ // The detector's candidate breakdown ({ open, inFlight, filtered }). Lets the+ // UI explain WHY a non-empty queue yields zero claimable work — "0 of N, M+ // in-flight" — instead of a bare "no work". `null` = the detector reported no+ // breakdown (e.g. the reconcile scans), so the field is left off the record.+ if (counts != null) record.parkCounts = counts;+ else delete record.parkCounts;record.parkedAt = new Date().toISOString();// A drain that parks because a full cycle made NO progress (branch-reconcile's// 'no-progress' park) records the actionable signature it was stuck on, so the@@ -781,17 +808,33 @@ export async function parkPerpetual(taskType, appId = null, { reason = null, act}await saveSchedule(schedule);emitLog('info', `Perpetual ${taskType} parked until ${parkedUntil} (${reason || 'idle'})`, { taskType, appId, parkedUntil }, '📅 TaskSchedule');- cosEvents.emit('schedule:perpetual-parked', { taskType, appId, parkedUntil, reason });+ cosEvents.emit('schedule:perpetual-parked', { taskType, appId, parkedUntil, reason, actionableCount, counts });return record;}+/**+ * Read the current park record for a perpetual task (or null when not parked).+ * Used by the on-demand handler to explain to the user WHY an explicit "Run"+ * produced no task — the park fields are freshly stamped by the same dispatch,+ * so this reflects the just-completed detection, not stale cadence state.+ */+export async function getPerpetualParkInfo(taskType, appId = null) {+ const schedule = await loadSchedule();+ const record = resolveExecutionRecord(schedule, taskType, appId);+ if (!record || record.parkedUntil == null) return null;+ return {+ parkedUntil: record.parkedUntil,+ parkReason: record.parkReason ?? null,+ parkActionableCount: record.parkActionableCount ?? null,+ parkCounts: record.parkCounts ?? null,+ parkedAt: record.parkedAt ?? null+ };+}+/** Read the last actionable signature recorded for a perpetual drain (or null). */export async function getPerpetualSignature(taskType, appId = null) {const schedule = await loadSchedule();- const key = taskType.startsWith('task:') ? taskType : `task:${taskType}`;- const top = schedule.executions[key];- if (!top) return null;- const record = appId ? top.perApp?.[appId] : top;+ const record = resolveExecutionRecord(schedule, taskType, appId);return record?.lastActionableSignature ?? null;}@@ -815,19 +858,35 @@ export async function setPerpetualSignature(taskType, appId = null, signature) {*/export async function clearPerpetualPark(taskType, appId = null) {const schedule = await loadSchedule();- const key = taskType.startsWith('task:') ? taskType : `task:${taskType}`;- const top = schedule.executions[key];- if (!top) return false;- const record = appId ? top.perApp?.[appId] : top;+ const record = resolveExecutionRecord(schedule, taskType, appId);if (!record || record.parkedUntil == null) return false;- delete record.parkedUntil;- delete record.parkReason;- delete record.parkActionableCount;- delete record.parkedAt;+ for (const field of PARK_FIELDS) delete record[field];await saveSchedule(schedule);return true;}+/**+ * Reset a perpetual task's cached drain state for an explicit user-initiated+ * re-run. Drops any park AND the convergence `lastActionableSignature` in a+ * single write, so the next detection dispatches on LIVE state alone — never a+ * stale "no-progress" verdict or a cadence park. This is what makes a manual+ * "Run" honor the user's intent to re-check now: without clearing the signature,+ * branch-reconcile/issue-reconcile would re-park `no-progress` against an+ * unchanged-since-last-run set even though the user explicitly asked to re-drive.+ * Returns true when it cleared anything.+ */+export async function resetPerpetualForManualRun(taskType, appId = null) {+ const schedule = await loadSchedule();+ const record = resolveExecutionRecord(schedule, taskType, appId);+ if (!record) return false;+ let changed = false;+ for (const field of [...PARK_FIELDS, 'lastActionableSignature']) {+ if (record[field] !== undefined) { delete record[field]; changed = true; }+ }+ if (changed) await saveSchedule(schedule);+ return changed;+}+/*** Check if all runAfter dependencies have completed since this task's last run.* Returns { satisfied, pending } where pending lists unfinished dependency task types.diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex d1465763a8..17dd82d947 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -102,6 +102,8 @@ import {computePerpetualRecheckAt,parkPerpetual,clearPerpetualPark,+ resetPerpetualForManualRun,+ getPerpetualParkInfo,getPerpetualSignature,setPerpetualSignature,PROMPT_VERSIONS,@@ -1273,10 +1275,32 @@ describe('taskSchedule', () => {describe('parkPerpetual / clearPerpetualPark', () => {it('parkPerpetual stamps parkedUntil + reason on the per-app record', async () => {mockSchedule({ tasks: { 'claim-issue': { type: 'perpetual', enabled: true, recheckIntervalMs: 3600000 } } })- const record = await parkPerpetual('claim-issue', 'app-1', { reason: 'no-actionable-issues', actionableCount: 0 })+ const record = await parkPerpetual('claim-issue', 'app-1', { reason: 'no-actionable-issues', actionableCount: 0, counts: { open: 40, inFlight: 2, filtered: 38 } })expect(record.parkedUntil).toBeTruthy()expect(record.parkReason).toBe('no-actionable-issues')expect(record.parkActionableCount).toBe(0)+ expect(record.parkCounts).toEqual({ open: 40, inFlight: 2, filtered: 38 })+ })++ it('getPerpetualParkInfo reads back the park record (and null when not parked)', 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', parkActionableCount: 0, parkCounts: { open: 40, inFlight: 2, filtered: 38 } },+ 'app-2': { lastRun: null, count: 0 }+ } } }+ })+ const info = await getPerpetualParkInfo('claim-issue', 'app-1')+ expect(info).toMatchObject({ parkedUntil: future, parkReason: 'no-actionable-issues', parkActionableCount: 0, parkCounts: { open: 40, inFlight: 2, filtered: 38 } })+ expect(await getPerpetualParkInfo('claim-issue', 'app-2')).toBeNull()+ expect(await getPerpetualParkInfo('claim-issue', 'unknown-app')).toBeNull()+ })++ it('parkPerpetual omits parkCounts when no breakdown is provided', async () => {+ mockSchedule({ tasks: { 'branch-reconcile': { type: 'perpetual', enabled: true, recheckIntervalMs: 3600000 } } })+ const record = await parkPerpetual('branch-reconcile', 'app-1', { reason: 'no-in-flight-branches', actionableCount: 0, signature: null })+ expect(record.parkCounts).toBeUndefined()})it('clearPerpetualPark returns true when a park existed', async () => {@@ -1296,6 +1320,30 @@ describe('taskSchedule', () => {expect(await clearPerpetualPark('claim-issue', 'app-1')).toBe(false)})+ it('resetPerpetualForManualRun drops BOTH the park and the convergence signature', async () => {+ const future = new Date(Date.now() + 60 * 60 * 1000).toISOString()+ mockSchedule({+ tasks: { 'branch-reconcile': { type: 'perpetual', enabled: true } },+ executions: { 'task:branch-reconcile': { lastRun: null, count: 0, perApp: {+ 'app-1': { lastRun: null, count: 0, parkedUntil: future, parkReason: 'no-progress', lastActionableSignature: 'a:NEEDS_PR:none' }+ } } }+ })+ expect(await resetPerpetualForManualRun('branch-reconcile', 'app-1')).toBe(true)+ const saved = JSON.parse(writeFile.mock.calls.at(-1)[1])+ const rec = saved.executions['task:branch-reconcile'].perApp['app-1']+ expect(rec.parkedUntil).toBeUndefined()+ expect(rec.parkReason).toBeUndefined()+ expect(rec.lastActionableSignature).toBeUndefined()+ })++ it('resetPerpetualForManualRun is a no-op (false) when nothing is cached', async () => {+ mockSchedule({+ tasks: { 'claim-issue': { type: 'perpetual', enabled: true } },+ executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: { 'app-1': { lastRun: null, count: 0 } } } }+ })+ expect(await resetPerpetualForManualRun('claim-issue', 'app-1')).toBe(false)+ })+it('parkPerpetual stores an actionable signature and getPerpetualSignature reads it back', async () => {mockSchedule({ tasks: { 'branch-reconcile': { type: 'perpetual', enabled: true, recheckIntervalMs: 3600000 } } })await parkPerpetual('branch-reconcile', 'app-1', { reason: 'no-progress', actionableCount: 2, signature: 'a:NEEDS_PR:none|b:IN_REVIEW:5' })