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
fix: unpark in cos.js twin on-demand engine + preserve real error category on dual-failure (#2616)
Adam Eivye21650b92520
diff --git a/server/services/agentErrorAnalysis.js b/server/services/agentErrorAnalysis.jsindex 3dbe28126a..46e3ef58a3 100644--- a/server/services/agentErrorAnalysis.js+++ b/server/services/agentErrorAnalysis.js@@ -839,22 +839,18 @@ export function resolveFailedTaskDecision(task, errorAnalysis) {export function resolveTypeFailureSignal({ success, terminatedByUser = false, hookResult = null, errorCategory = null } = {}) {if (terminatedByUser) return { record: 'skip', category: null };- let failure = !success;- let category = errorCategory || 'unknown';+ // An already-failed run keeps its real exit-code category; the hook override+ // only UPGRADES an exit-0 (`success`) run to a failure (the exit-0-but-+ // unparseable / thrown-hook case). A hook that throws on top of a run that+ // already failed for e.g. `rate-limit` must not relabel the cause `hook-error`.+ if (!success) return { record: 'failure', category: errorCategory || 'unknown' };if (hookResult?.ran) {- if (hookResult.threw) {- failure = true;- category = 'hook-error';- } else if (hookResult.outcome?.reason === 'unparseable-response') {- failure = true;- category = 'unparseable-response';- }+ if (hookResult.threw) return { record: 'failure', category: 'hook-error' };+ if (hookResult.outcome?.reason === 'unparseable-response') return { record: 'failure', category: 'unparseable-response' };}- return failure- ? { record: 'failure', category }- : { record: 'success', category: null };+ return { record: 'success', category: null };}/**diff --git a/server/services/agentErrorAnalysis.test.js b/server/services/agentErrorAnalysis.test.jsindex 9da7b03375..6b780f6706 100644--- a/server/services/agentErrorAnalysis.test.js+++ b/server/services/agentErrorAnalysis.test.js@@ -255,6 +255,15 @@ describe('resolveTypeFailureSignal (#2616)', () => {expect(signal).toEqual({ record: 'failure', category: 'hook-error' });});+ it('a run that already failed keeps its real error category (hook throw does not relabel it)', () => {+ const signal = resolveTypeFailureSignal({+ success: false,+ errorCategory: 'rate-limit',+ hookResult: { ran: true, threw: true }+ });+ expect(signal).toEqual({ record: 'failure', category: 'rate-limit' });+ });+it('benign hook reasons (no-proposal/duplicate) leave the exit-code verdict intact', () => {for (const reason of ['no-proposal', 'duplicate', 'scope-suppressed', null]) {expect(resolveTypeFailureSignal({ success: true, hookResult: { ran: true, outcome: { reason } } }).record)diff --git a/server/services/cos.js b/server/services/cos.jsindex de825c79a1..cc00daa965 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -758,6 +758,11 @@ async function spawnDequeuePriority0OnDemand(ctx) {// 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);+ // A manual "Run" also unparks a failure-parked type (#2616) — clear this+ // app's consecutive-failure ledger. (Mirrors the sibling+ // spawnPriority0OnDemand engine in cosTaskGenerator.js; either engine may+ // drain a given on-demand request, so both must unpark.)+ await taskScheduleMod.clearTaskTypeFailurePark(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).@@ -774,6 +779,8 @@ async function spawnDequeuePriority0OnDemand(ctx) {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);+ // Manual re-run unparks a failure-parked type (global scope) — #2616.+ await taskScheduleMod.clearTaskTypeFailurePark(request.taskType);await taskScheduleMod.recordExecution(`task:${request.taskType}`);await withStateLock(async () => {const s = await loadState();