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(cos): attribute claim-issue park skips per cause so logs and toasts explain why nothing was claimable

Adam Eivy2bcd9321e5c7
diff --git a/client/src/components/apps/WorkItemPicker.jsx b/client/src/components/apps/WorkItemPicker.jsx
index 081e07c975..ede9b4858c 100644
--- a/client/src/components/apps/WorkItemPicker.jsx
+++ b/client/src/components/apps/WorkItemPicker.jsx
@@ -17,7 +17,7 @@ const EMPTY_REASONS = {
'no-actionable-plan-items': 'Every PLAN.md item is checked, blocked, or already claimed.',
'no-open-issues': 'The tracker has no open issues.',
'no-authored-issues': 'Open issues exist, but none match the author filter — widen it to see them.',
- 'no-actionable-issues': 'Every open issue is assigned, blocked, in flight, or an already-decomposed epic.',
+ 'no-actionable-issues': 'Every open issue is assigned, blocked, in flight, needs input, or an already-decomposed epic.',
'owner-is-org': 'The repo owner is an organization, which never authors issues — switch the filter to "Any author".',
'owner-is-group': 'The project namespace is a group, which never authors issues — switch the filter to "Any author".',
'jira-not-configured': 'JIRA is not configured for this app.',
diff --git a/client/src/hooks/useOnDemandTaskToast.js b/client/src/hooks/useOnDemandTaskToast.js
index 77bc51c5e2..6572aaf5b5 100644
--- a/client/src/hooks/useOnDemandTaskToast.js
+++ b/client/src/hooks/useOnDemandTaskToast.js
@@ -4,6 +4,7 @@ import toast from '../components/ui/Toast';
import socket from '../services/socket';
import { timeUntil } from '../utils/formatters';
import { formatLiReason } from '../utils/layeredIntelligenceReasons';
+import { formatSkipCauses } from '../lib/perpetualSkipCauses';
// 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
@@ -129,7 +130,12 @@ export function useOnDemandTaskToast() {
} else 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`);
+ // Per-cause attribution ("49 needs-input, 17 blocked") — the answer to
+ // "why is nothing claimable when 88 issues are open". Replaces the bare
+ // "N filtered" when present, since the causes ARE the filtered detail.
+ const causes = formatSkipCauses(data?.skipCauses);
+ if (causes) parts.push(causes);
+ else if (c.filtered) parts.push(`${c.filtered} filtered`);
const detail = parts.length ? ` — ${parts.join(', ')}` : '';
countSuffix = ` (0 of ${c.open} open${detail})`;
}
diff --git a/client/src/hooks/useOnDemandTaskToast.test.jsx b/client/src/hooks/useOnDemandTaskToast.test.jsx
index c146995e4e..b861b33667 100644
--- a/client/src/hooks/useOnDemandTaskToast.test.jsx
+++ b/client/src/hooks/useOnDemandTaskToast.test.jsx
@@ -117,6 +117,28 @@ describe('useOnDemandTaskToast — parked outcome', () => {
expect(msg).not.toMatch(/0 of/);
});
+ // The live failure mode behind this channel: 88 open issues, zero claimable,
+ // and a toast that said only "no claimable issues (0 of 88 open — 10
+ // in-flight, 78 filtered)" — which reads as the task being broken. The
+ // per-cause attribution names WHY each filtered issue was skipped, so the
+ // user sees their queue is 49 `needs-input` decisions deep, not stuck.
+ it('names the per-cause skip attribution instead of a bare "N filtered"', () => {
+ renderHook(() => useOnDemandTaskToast());
+ fire({
+ taskType: 'claim-issue', appName: 'App One', outcome: 'parked',
+ parkReason: 'no-actionable-issues',
+ counts: { open: 88, inFlight: 10, filtered: 78 },
+ skipCauses: { 'needs-input': 49, blocked: 17, 'decomposed-epic': 12 },
+ parkedUntil: new Date(Date.now() + 23 * 3600 * 1000).toISOString()
+ });
+ const [msg] = toastSpy.mock.calls[0];
+ expect(msg).toMatch(/no claimable issues/);
+ expect(msg).toMatch(/0 of 88 open/);
+ expect(msg).toMatch(/49 needs-input, 17 blocked, 12 decomposed-epic/);
+ // The causes replace the bare "78 filtered" — they ARE the filtered detail.
+ expect(msg).not.toMatch(/78 filtered/);
+ });
+
// branch-reconcile's park used to report 'no-in-flight-branches' while merged
// branches sat behind a protected worktree — "nothing to do" for a task the
// user could see had work queued, which reads as the task not running at all.
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index b14f780dff..3252615554 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -31,6 +31,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `eidoverseWorldReset.js` | Client reset-reconciliation maps for Eidoverse source kinds and district asset slots; parity-tested against the authoritative server world-design contracts. |
| `postQuickSession.js` | Pure Quick POST duration presets, local-observation estimator, deterministic budget composer, and preview metadata. |
| `postRotation.js` | Re-export of `server/lib/postRotation.js` — `orderByRecencyRotation` sorts POST practice candidates fresh-before-recently-practiced, then by priority, rotating equivalent ones by local day. |
+| `perpetualSkipCauses.js` | `formatSkipCauses(skipCauses, maxCauses)` — renders a perpetual work-detector's per-cause skip map (`{ 'needs-input': 49, blocked: 17 }`) as a compact largest-first string; client mirror of `formatSkipCauses` in `server/services/cosTaskGenerator.js`, used by the on-demand "Run" toast. |
---
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index 6ef7d00334..3bbe3894f0 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -185,6 +185,7 @@ export * from './pianoKeyboard.js';
export * from './pitchDetect.js';
export * from './postQuickSession.js';
export * from './postRotation.js';
+export * from './perpetualSkipCauses.js';
export * from './seriesReviewProgress.js';
export * from './powersBreakdown.js';
export * from './promptStageGroups.js';
diff --git a/client/src/lib/perpetualSkipCauses.js b/client/src/lib/perpetualSkipCauses.js
new file mode 100644
index 0000000000..acb153ec87
--- /dev/null
+++ b/client/src/lib/perpetualSkipCauses.js
@@ -0,0 +1,17 @@
+/**
+ * Render a perpetual work-detector skip-cause map
+ * ({ 'needs-input': 49, blocked: 17, … }) as a compact human string, largest
+ * cause first. Mirrors `formatSkipCauses` in server/services/cosTaskGenerator.js
+ * — the server renders it into park log lines, the client into the on-demand
+ * "Run" toast, and both must answer "why did N open issues yield zero work"
+ * with the same words. Returns '' for an empty/absent map.
+ */
+export function formatSkipCauses(skipCauses, maxCauses = 3) {
+ if (!skipCauses || typeof skipCauses !== 'object') return '';
+ return Object.entries(skipCauses)
+ .filter(([, n]) => Number.isFinite(n) && n > 0)
+ .sort((a, b) => b[1] - a[1])
+ .slice(0, maxCauses)
+ .map(([cause, n]) => `${n} ${cause}`)
+ .join(', ');
+}
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index 12a936b26a..61cd63b8ca 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -2115,6 +2115,22 @@ const transientVerdictKey = (taskType, appId) => `${taskType}:${appId || 'global
// escalating to `warn` — see recordPerpetualTransient's return value.
export const PERPETUAL_TRANSIENT_ESCALATION_THRESHOLD = 3;
+/**
+ * Render a detector skip-cause map ({ 'needs-input': 49, blocked: 17, … }) as a
+ * compact human string, largest cause first. Shared by the park log line and the
+ * on-demand toast so both answer "why did 88 open issues yield zero work" with
+ * the same words. Returns '' for an empty/absent map.
+ */
+export function formatSkipCauses(skipCauses, maxCauses = 3) {
+ if (!skipCauses || typeof skipCauses !== 'object') return '';
+ return Object.entries(skipCauses)
+ .filter(([, n]) => Number.isFinite(n) && n > 0)
+ .sort((a, b) => b[1] - a[1])
+ .slice(0, maxCauses)
+ .map(([cause, n]) => `${n} ${cause}`)
+ .join(', ');
+}
+
// Consecutive-transient-skip counters, keyed the same as transientVerdicts but
// deliberately tracked SEPARATELY from it: this streak must survive across
// evaluations more than 60s apart (it counts how many evaluations IN A ROW came
@@ -2360,7 +2376,8 @@ export async function emitOnDemandEmpty({ taskScheduleMod, request, targetApp, t
parkReason: parkInfo?.parkReason || null,
parkedUntil: parkInfo?.parkedUntil || null,
actionableCount: parkInfo?.parkActionableCount ?? null,
- counts: parkInfo?.parkCounts || null
+ counts: parkInfo?.parkCounts || null,
+ skipCauses: parkInfo?.parkSkipCauses || null
});
}
@@ -2588,10 +2605,16 @@ async function applyPerpetualWorkGate(app, taskType, promptTaskType, metadata, i
const counts = detection.total != null
? { open: detection.total, inFlight: detection.inFlightCount ?? 0, filtered: detection.filteredCount ?? 0 }
: null;
+ // Per-cause skip attribution for the same question at one level deeper: not
+ // just "78 filtered" but "49 needs-input, 17 blocked, …". Only the claim
+ // detectors report it; every other park shape keeps the field absent.
+ const skipCauses = detection.skipCauses && Object.keys(detection.skipCauses).length > 0
+ ? detection.skipCauses
+ : null;
// Terminal park — parkPerpetual zeroes the dispatch budget in the same write, so
// the next drain window starts fresh instead of capping early on this one's spend.
- await taskSchedule.parkPerpetual(taskType, app.id, { reason: detection.reason, actionableCount: detection.count, counts, signature: null });
- emitLog('info', `Perpetual ${taskType} parked for ${app.name}: ${detection.reason}`, { appId: app.id });
+ await taskSchedule.parkPerpetual(taskType, app.id, { reason: detection.reason, actionableCount: detection.count, counts, skipCauses, signature: null });
+ emitLog('info', `Perpetual ${taskType} parked for ${app.name}: ${detection.reason}${skipCauses ? ` (${formatSkipCauses(skipCauses)})` : ''}`, { appId: app.id });
return { skip: true };
}
diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.js
index 4736866ea2..0f47ea7b9d 100644
--- a/server/services/perpetualWork.js
+++ b/server/services/perpetualWork.js
@@ -257,25 +257,47 @@ const assigneeLogin = (assignee) => normalizeLogin(
* structural (in-progress/blocked/etc.), not user-configurable.
*/
export function isActionableIssue(issue, inFlight = new Set(), excludeLabels = null, currentLogin = null) {
- if (!issue || typeof issue.number !== 'number') return false;
- if (inFlight.has(issue.number)) return false;
+ return issueSkipCause(issue, inFlight, excludeLabels, currentLogin) === null;
+}
+
+/**
+ * Attribute WHY an issue is not claimable: the FIRST failing check from
+ * `isActionableIssue`'s predicate order, as a short cause string. The cause
+ * vocabulary is what the park breakdown (`skipCauses`) shows the user, so a
+ * queue that parks on "0 of 88 open" reads as "49 needs-input, 17 blocked, 13
+ * decomposed-epic" — the difference between "the task is broken" and "the work
+ * is waiting on you". Returns null for a claimable issue (the same contract
+ * `isActionableIssue` keys on), the structural label's own name for a
+ * label-skip (e.g. `needs-input`, `blocked`), the configured exclude label's
+ * name for a user-reserved skip, and `assigned` / `in-flight` /
+ * `decomposed-epic` / `malformed` for the structural checks. Not exported: the
+ * detector tests exercise it behaviorally through `skipCauses`, and the
+ * dead-exports guard keeps it honest about that.
+ */
+function issueSkipCause(issue, inFlight = new Set(), excludeLabels = null, currentLogin = null) {
+ if (!issue || typeof issue.number !== 'number') return 'malformed';
+ if (inFlight.has(issue.number)) return 'in-flight';
const assignees = Array.isArray(issue.assignees) ? issue.assignees : [];
const normalizedCurrentLogin = normalizeLogin(currentLogin);
const hasOtherAssignee = assignees.length > 0 && (
!normalizedCurrentLogin || !assignees.some((assignee) => assigneeLogin(assignee) === normalizedCurrentLogin)
);
- if (hasOtherAssignee) return false;
+ if (hasOtherAssignee) return 'assigned';
const labels = (Array.isArray(issue.labels) ? issue.labels : [])
.map((l) => (typeof l === 'string' ? l : l?.name) || '')
.map((s) => s.toLowerCase());
- if (labels.some((l) => NON_ACTIONABLE_ISSUE_LABELS.has(l))) return false;
- if (excludeLabels && labels.some((l) => excludeLabels.has(l))) return false;
+ const structural = labels.find((l) => NON_ACTIONABLE_ISSUE_LABELS.has(l));
+ if (structural) return structural;
+ if (excludeLabels) {
+ const excluded = labels.find((l) => excludeLabels.has(l));
+ if (excluded) return excluded;
+ }
// Marker first: the label scan is a 2–5 element array walk, while isEpicIssue
// lowercases and regex-tests the title. Only a decomposed issue needs the
// epic check, so this skips that work for essentially every issue in a
// 500-issue fetch.
- if (labels.includes(EPIC_DECOMPOSED_LABEL) && isEpicIssue(issue.title, labels)) return false;
- return true;
+ if (labels.includes(EPIC_DECOMPOSED_LABEL) && isEpicIssue(issue.title, labels)) return 'decomposed-epic';
+ return null;
}
/**
@@ -746,12 +768,25 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self', is
: null;
const actionable = issues.filter((issue) => isActionableIssue(issue, inFlight, excludeSet, currentLogin));
const filteredCount = Math.max(0, total - actionable.length - inFlightCount);
+ // Per-cause attribution of every skip, so a park on a non-empty queue can say
+ // WHY each issue was filtered ("49 needs-input, 17 blocked, …") instead of a
+ // bare "78 filtered". `inFlightCount` already accounts for the in-flight
+ // skips separately, so `in-flight` here is informational only — the counts
+ // sum to `total` only when the queue holds no malformed records.
+ const skipCauses = {};
+ if (actionable.length === 0 && total > 0) {
+ for (const issue of issues) {
+ const cause = issueSkipCause(issue, inFlight, excludeSet, currentLogin);
+ if (cause != null) skipCauses[cause] = (skipCauses[cause] || 0) + 1;
+ }
+ }
return {
actionable: actionable.length > 0,
count: actionable.length,
total,
inFlightCount,
filteredCount,
+ skipCauses,
reason: actionable.length > 0 ? 'actionable-issues' : 'no-actionable-issues',
sample: actionable.slice(0, 5).map((i) => i.number),
// The perpetual drain uses the complete candidate set to detect a
diff --git a/server/services/perpetualWork.test.js b/server/services/perpetualWork.test.js
index e7d4ede0b3..bf9615d69d 100644
--- a/server/services/perpetualWork.test.js
+++ b/server/services/perpetualWork.test.js
@@ -382,6 +382,45 @@ describe('perpetualWork', () => {
expect(out.total).toBe(7);
expect(out.inFlightCount).toBe(0);
expect(out.filteredCount).toBe(7); // the epic (#1) + 6 needs-input/blocked
+ // Per-cause attribution: the park breakdown must say WHY each of the 7 was
+ // filtered, not just how many — "0 of 7 open" alone reads as a broken task.
+ expect(out.skipCauses).toEqual({ 'needs-input': 5, blocked: 1, 'decomposed-epic': 1 });
+ });
+
+ it('attributes skips per cause (assigned / in-flight / excluded label) so a park names its reasons', async () => {
+ routeSpawn({
+ 'gh issue': { stdout: JSON.stringify([
+ { number: 1, title: 'plain', assignees: [], labels: [] },
+ { number: 2, title: 'taken', assignees: [{ login: 'x' }], labels: [] },
+ { number: 3, title: 'in flight', assignees: [], labels: [] },
+ { number: 4, title: 'reserved', assignees: [], labels: [{ name: 'good first issue' }] }
+ ]) },
+ 'git branch': { stdout: 'main\norigin/claim/issue-3\n' },
+ 'gh pr': { stdout: '' }
+ });
+ const out = await detectGithubIssues(app, { issueAuthorFilter: 'any', issueExcludeLabels: ['good first issue'] });
+ expect(out.actionable).toBe(true);
+ // Attribution is only computed for a park (0 actionable) — an actionable
+ // detection carries an empty map, not a partial one.
+ expect(out.skipCauses).toEqual({});
+ });
+
+ it('attributes every skip cause on a park, including in-flight and configured exclude labels', async () => {
+ routeSpawn({
+ 'gh issue': { stdout: JSON.stringify([
+ { number: 2, title: 'taken', assignees: [{ login: 'x' }], labels: [] },
+ { number: 3, title: 'in flight', assignees: [], labels: [] },
+ { number: 4, title: 'reserved', assignees: [], labels: [{ name: 'good first issue' }] },
+ { number: 5, title: 'waiting on you', assignees: [], labels: [{ name: 'needs-input' }] }
+ ]) },
+ 'git branch': { stdout: 'main\norigin/claim/issue-3\n' },
+ 'gh pr': { stdout: '' }
+ });
+ const out = await detectGithubIssues(app, { issueAuthorFilter: 'any', issueExcludeLabels: ['good first issue'] });
+ expect(out).toMatchObject({ actionable: false, count: 0, reason: 'no-actionable-issues' });
+ expect(out.inFlightCount).toBe(1);
+ expect(out.filteredCount).toBe(3);
+ expect(out.skipCauses).toEqual({ 'needs-input': 1, assigned: 1, 'in-flight': 1, 'good first issue': 1 });
});
it('keeps an issue assigned to the authenticated account claimable', async () => {
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index b91af5b65d..1bb8336a45 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -514,7 +514,7 @@ function resolveExecutionRecord(schedule, taskType, appId = 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', 'parkNotLaterThan', 'parkedAt'];
+const PARK_FIELDS = ['parkedUntil', 'parkReason', 'parkActionableCount', 'parkCounts', 'parkSkipCauses', 'parkNotLaterThan', 'parkedAt'];
/**
* Park a perpetual task: its work-detector reported nothing actionable, so stop
@@ -541,7 +541,7 @@ const PARK_FIELDS = ['parkedUntil', 'parkReason', 'parkActionableCount', 'parkCo
* zeroing the counter there would reset the budget before every dispatch, so the
* cap could never fire.
*/
-export async function parkPerpetual(taskType, appId = null, { reason = null, actionableCount = 0, counts = null, signature, dispatchCount = 0, notLaterThan = null } = {}) {
+export async function parkPerpetual(taskType, appId = null, { reason = null, actionableCount = 0, counts = null, skipCauses = null, signature, dispatchCount = 0, notLaterThan = null } = {}) {
const { record, parkedUntil } = await updateSchedule(async (schedule) => {
const interval = schedule.tasks[taskType] || {};
// Bound HERE, not at the assignment: `parkedUntil` is also what the log line and
@@ -558,6 +558,12 @@ export async function parkPerpetual(taskType, appId = null, { reason = null, act
// breakdown (e.g. the reconcile scans), so the field is left off the record.
if (counts != null) record.parkCounts = counts;
else delete record.parkCounts;
+ // Per-cause skip attribution ({ 'needs-input': 49, blocked: 17, … }) for the
+ // same purpose: "78 filtered" alone can't tell a user their work is waiting
+ // on `needs-input` decisions rather than the task being broken. Same null
+ // contract as parkCounts — absent when the detector reported no attribution.
+ if (skipCauses != null) record.parkSkipCauses = skipCauses;
+ else delete record.parkSkipCauses;
// The self-expiry has to OUTLIVE this call: updateTaskInterval restamps every
// un-elapsed park from the new cadence, and without a remembered bound it would
// stretch a correctly-shortened park back out — reintroducing the stacking this
@@ -594,8 +600,20 @@ export async function parkPerpetual(taskType, appId = null, { reason = null, act
return { result: { record, parkedUntil }, changed: true };
});
- emitLog('info', `Perpetual ${taskType} parked until ${parkedUntil} (${reason || 'idle'})`, { taskType, appId, parkedUntil }, '📅 TaskSchedule');
- cosEvents.emit('schedule:perpetual-parked', { taskType, appId, parkedUntil, reason, actionableCount, counts });
+ // A park on a non-empty queue needs its WHY in the log line itself — the
+ // operator reads PM2 output, where a bare `no-actionable-issues` next to "88
+ // open issues" reads as the task being broken. Render the top skip causes
+ // inline ("49 needs-input, 17 blocked") so the one line they see answers the
+ // question the toast exists for.
+ const causeSummary = skipCauses && Object.keys(skipCauses).length > 0
+ ? ` — ${Object.entries(skipCauses)
+ .sort((a, b) => b[1] - a[1])
+ .slice(0, 3)
+ .map(([cause, n]) => `${n} ${cause}`)
+ .join(', ')}`
+ : '';
+ emitLog('info', `Perpetual ${taskType} parked until ${parkedUntil} (${reason || 'idle'}${causeSummary})`, { taskType, appId, parkedUntil }, '📅 TaskSchedule');
+ cosEvents.emit('schedule:perpetual-parked', { taskType, appId, parkedUntil, reason, actionableCount, counts, skipCauses });
return record;
}
@@ -614,6 +632,7 @@ export async function getPerpetualParkInfo(taskType, appId = null) {
parkReason: record.parkReason ?? null,
parkActionableCount: record.parkActionableCount ?? null,
parkCounts: record.parkCounts ?? null,
+ parkSkipCauses: record.parkSkipCauses ?? null,
parkedAt: record.parkedAt ?? null,
signatureRepeatCount: Number.isFinite(record.signatureRepeatCount) ? record.signatureRepeatCount : null
};
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index c1d9735ee5..11fa2c2eea 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -167,7 +167,7 @@ import {
REFERENCE_WATCH_AUDITED_VERSION,
boundParkedUntil
} from './taskSchedule.js'
-import { cosEvents } from './cosEvents.js'
+import { cosEvents, emitLog } from './cosEvents.js'
import { recordUserAction } from './userActions.js'
// Prompt getters moved to taskPromptService.js (issue #744 split, #1083 cycle
@@ -2861,17 +2861,42 @@ describe('taskSchedule', () => {
expect(record.parkCounts).toEqual({ open: 40, inFlight: 2, filtered: 38 })
})
+ // A park on a non-empty queue must carry its WHY: the per-cause skip
+ // attribution ("49 needs-input, 17 blocked") is what tells the operator
+ // their work is waiting on decisions, not that the task is broken — the
+ // exact confusion behind reading a bare `no-actionable-issues` in PM2
+ // output next to 88 open issues.
+ it('parkPerpetual persists the per-cause skip attribution and names the top causes in its log line', async () => {
+ mockSchedule({ tasks: { 'claim-issue': { type: 'on-demand', perpetual: true, enabled: true, recheckIntervalMs: 3600000 } } })
+ const record = await parkPerpetual('claim-issue', 'app-1', {
+ reason: 'no-actionable-issues', actionableCount: 0,
+ counts: { open: 88, inFlight: 10, filtered: 78 },
+ skipCauses: { 'needs-input': 49, blocked: 17, 'decomposed-epic': 12, assigned: 2 }
+ })
+ expect(record.parkSkipCauses).toEqual({ 'needs-input': 49, blocked: 17, 'decomposed-epic': 12, assigned: 2 })
+ // The log line the operator reads in PM2 names the top 3 causes inline.
+ const logged = emitLog.mock.calls.at(-1);
+ expect(logged[1]).toMatch(/no-actionable-issues — 49 needs-input, 17 blocked, 12 decomposed-epic/);
+ expect(logged[1]).not.toMatch(/assigned: 2/);
+ })
+
+ it('parkPerpetual leaves parkSkipCauses absent when the detector reports no attribution', async () => {
+ mockSchedule({ tasks: { 'branch-reconcile': { type: 'on-demand', perpetual: true, enabled: true } } })
+ const record = await parkPerpetual('branch-reconcile', 'app-1', { reason: 'no-in-flight-branches', actionableCount: 0, counts: null, skipCauses: null })
+ expect(record.parkSkipCauses).toBeUndefined()
+ })
+
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: 'on-demand', perpetual: true, 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-1': { lastRun: null, count: 0, parkedUntil: future, parkReason: 'no-actionable-issues', parkActionableCount: 0, parkCounts: { open: 40, inFlight: 2, filtered: 38 }, parkSkipCauses: { 'needs-input': 30, blocked: 8 } },
'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(info).toMatchObject({ parkedUntil: future, parkReason: 'no-actionable-issues', parkActionableCount: 0, parkCounts: { open: 40, inFlight: 2, filtered: 38 }, parkSkipCauses: { 'needs-input': 30, blocked: 8 } })
expect(await getPerpetualParkInfo('claim-issue', 'app-2')).toBeNull()
expect(await getPerpetualParkInfo('claim-issue', 'unknown-app')).toBeNull()
})