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: keep a provider-config block paused instead of auto-completing it (#6193)
[._.]/ Adam Eivya4a62e9e373a
diff --git a/server/lib/README.md b/server/lib/README.mdindex 358c870690..84c8b923b7 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -359,7 +359,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `taskParser.js` | Parse `TASKS.md` format. || `cosTaskPrompt.js` | The CoS task prompt/note split (#4153) — `metadata.prompt` is the full agent-facing payload, `metadata.context` the one-line human note. `isPromptPayload(value)` is the single discriminator (a newline means it's a prompt, not a note), shared by the store's write path and the on-disk migration so they can't classify the same task differently. `getTaskPrompt(task)` prefers `metadata.prompt` and falls back to a legacy `metadata.context`; `getTaskContextNote(task)` returns the note only on an already-split task; `taskContextBlock(task)` renders both as one block so prompt templates (including customized ones) never see the split; `splitTaskPromptFields(metadata)` routes a multi-line `context` to `prompt` at CREATE time only. Pure, dependency-free. || `taskPauseHold.js` | The user-PAUSE hold — pure metadata helpers shared by the writer (`pauseAgent`), the reader (`resumeAgent`), and the clearer (`updateTask`). `AGENT_PAUSED_CATEGORY` is the `blockedCategory` a pause stamps; `PAUSE_METADATA_KEYS` names every key it writes; `pauseMetadata({agentId, pausedAt, workspacePath, runId})` arms it and `clearedPauseMetadata()` releases it (undefined-valued, so `updateTask` deletes rather than serializing `"null"`); `isAgentPausedTask(task)` / `isResumablePausedTask(task, agentId)` answer whether a pause is still live and whether it is THIS agent's. `updateTask` clears the whole set whenever the task leaves `blocked`, so a revive by any path (dedupe, cooldown expiry, manual unblock) can't leave a task running under a stale pause. Also carries the cycle-safe RELEASE adapter (#3730) `agentManagement.js` registers at load — `resolvePausedTaskResume(task)` hands `updateTask` the paused run's resume pointer before the write (so any un-block resumes on the preserved worktree, not just the Resume dialog) and `retirePausedAgent(agentId, taskId, branchName)` retires the paused record after it. |-| `taskBlockCategories.js` | The `blockedCategory` vocabulary — which blocks are the system's to clear and which are a person's, read by the pause logic, the failure reaper, and the investigation auto-retry so they can't drift into three literal sets. `PAUSED_BLOCKED_CATEGORIES` (paused until something outside the task changes — keeps the resume pointer), `USER_DECISION_BLOCKED_CATEGORIES` (user intent / open decision — the reaper's exemption), `NON_AUTO_RETRY_BLOCK_CATEGORIES` (their union — a completed investigation must never revive these), `TIMED_COOLDOWN_BLOCKED_CATEGORIES` (a timer clears these — the cooldown sweeper revives them, so block reporters stay quiet). Pure. |+| `taskBlockCategories.js` | The `blockedCategory` vocabulary — which blocks are the system's to clear and which are a person's, read by the pause logic, the failure reaper, and the investigation auto-retry so they can't drift into three literal sets. `PAUSED_BLOCKED_CATEGORIES` (paused until something outside the task changes — keeps the resume pointer), `USER_DECISION_BLOCKED_CATEGORIES` (user intent / open decision — the reaper's exemption), `NON_AUTO_RETRY_BLOCK_CATEGORIES` (their union — a completed investigation must never revive these), `TIMED_COOLDOWN_BLOCKED_CATEGORIES` (a timer clears these — the cooldown sweeper revives them, so block reporters stay quiet), `PROVIDER_CONFIG_BLOCKED_CATEGORY` (the shared literal the agent-spawn stamp site uses, so the stamp cannot drift from the two sets it belongs to). Pure. || `taskRequeue.js` | The REQUEUE stamp (#3376) — pure metadata helpers for the one BACKWARD lifecycle step (`in_progress → pending`, performed by the orphan sweep and the retry-hold release). `REQUEUED_AT_KEY` / `LAST_SPAWNED_AT_KEY` name the two stamps; `isPostSpawnRequeue(pendingTask, inProgressTask)` answers whether the requeue happened strictly AFTER that spawn, which is how the federated merge tells a real requeue apart from an ordinary edit landing on a peer's stale `pending` copy. Returns false when either stamp is missing, so callers fall back to the lifecycle rank. || `taskRetryHold.js` | The failed-task RETRY HOLD state (#3373) — pure metadata helpers shared by the failure verdict, the post-cleanup release, the spawn guard, and the orphan sweep. `retryHoldMetadata(agentId, now)` arms it (task stays `in_progress`, so no dequeue tier can claim the retry before its resume pointer is resolved); `clearedRetryHoldMetadata()` releases it in the same write that flips the task to `pending`; `isRetryHeld(metadata)` / `isRetryHoldOwner(metadata, agentId)` gate the spawn and the owner-scoped release; `isStaleRetryHold(metadata, now, graceMs)` + `RETRY_HOLD_GRACE_MS` let the orphan sweep finish a transition whose process died. || `taskTargetBranch.js` | Pure task-branch contract: `resolveTaskTargetBranch(metadata)` reads a retry's legacy `existingBranch` or a review-loop follow-up's canonical `reviewLoopPRBranch`; `shouldStripTaskTargetBranch(metadata)` identifies only retry-owned pointers for terminal cleanup. |diff --git a/server/lib/taskBlockCategories.js b/server/lib/taskBlockCategories.jsindex 64c90e8b5d..695584931c 100644--- a/server/lib/taskBlockCategories.js+++ b/server/lib/taskBlockCategories.js@@ -17,6 +17,16 @@import { AGENT_PAUSED_CATEGORY } from './taskPauseHold.js';+/**+ * A PERMANENT provider-config failure: the task's resolved provider cannot run+ * an agent at all (today, an `api`-type provider pinned to or resolved for an+ * agent task — it has no file-writing harness). Stamped by `runAgentSpawn`+ * (services/agentLifecycle.js) and read by both sets below, so it lives here+ * rather than as a third hand-written literal — exactly the drift this module+ * exists to prevent.+ */+export const PROVIDER_CONFIG_BLOCKED_CATEGORY = 'provider-config';+/*** Pauses a TIMER clears, not a person: the task carries a `cooldownUntil` and the* cooldown sweeper (`unblockExpiredCooldowns`, cosTaskGenerator.js) flips it back@@ -46,7 +56,14 @@ export const TIMED_COOLDOWN_BLOCKED_CATEGORIES = new Set([export const PAUSED_BLOCKED_CATEGORIES = new Set([...TIMED_COOLDOWN_BLOCKED_CATEGORIES,'app-unresolved', // the task's app has no usable Repository Path- 'workspace-invalid' // the resolved workspace isn't a usable directory+ 'workspace-invalid', // the resolved workspace isn't a usable directory+ // A CONFIG pause, NOT a timed one: nothing stamps a `cooldownUntil` for it and+ // no sweeper revives it — the user adds a CLI provider (or re-pins the task)+ // and unblocks it by hand. It therefore belongs here and in the user-decision+ // set, but never in TIMED_COOLDOWN_BLOCKED_CATEGORIES. Without this membership+ // the revived task restarts on a fresh branch and orphans the worktree its dead+ // agent left behind.+ PROVIDER_CONFIG_BLOCKED_CATEGORY]);/**@@ -54,18 +71,25 @@ export const PAUSED_BLOCKED_CATEGORIES = new Set([* artifact — the reaper leaves these alone. Everything else with a* `blockedCategory` is a failure-path block and therefore reapable.*- * The workspace blocks are an open user decision, not a stale failure: the task- * is waiting for the app's Repository Path to be fixed, and auto-completing it- * at 14 days would silently retire work nobody decided to drop. (The TIMED pause- * categories stay reapable — they revive themselves in minutes, so one still- * sitting there after 14 days IS stale.)+ * The CONFIG pauses are an open user decision, not a stale failure: the task is+ * waiting for the app's Repository Path to be fixed, or for a provider that can+ * actually run an agent, and auto-completing it at 14 days would silently retire+ * work nobody decided to drop. (The TIMED pause categories stay reapable — they+ * revive themselves in minutes, so one still sitting there after 14 days IS+ * stale.)*/export const USER_DECISION_BLOCKED_CATEGORIES = new Set(['user-terminated', // user explicitly stopped the agentAGENT_PAUSED_CATEGORY, // user paused; resumable on demand'challenge-escalation', // parked awaiting the user's arbitration'app-unresolved',- 'workspace-invalid'+ 'workspace-invalid',+ // Same shape: a config error only the user can clear. Exempt from the 14-day+ // `sweepResolvedFailureTasks` auto-expiry (cosTaskStore.js), which would+ // otherwise flip it to `completed` with `resolution: 'auto-expired'` and+ // federate that false `completed` to every peer — silently reporting work+ // nobody decided to drop as done.+ PROVIDER_CONFIG_BLOCKED_CATEGORY]);/**diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.jsindex 0abdd60282..926a859d8f 100644--- a/server/services/agentLifecycle.js+++ b/server/services/agentLifecycle.js@@ -45,6 +45,7 @@ import { spawnAgentViaRunner, getRunnerHealth, classifyRunnerSpawnFailure, RUNNEimport { MAX_TOTAL_SPAWNS, normalizeReviewers } from '../lib/validation.js';import { isInternalTaskId } from '../lib/taskParser.js';import { isRetryHeld } from '../lib/taskRetryHold.js';+import { PROVIDER_CONFIG_BLOCKED_CATEGORY } from '../lib/taskBlockCategories.js';import { ensureDir, PATHS, sleep, tryReadFile } from '../lib/fileUtils.js';import { createToolExecution, startExecution, completeExecution, errorExecution } from './toolStateMachine.js';import { determineLane, acquire, release } from './executionLanes.js';@@ -417,7 +418,7 @@ async function runAgentSpawn(task) {metadata: {...task.metadata,blockedReason: resolution.error,- blockedCategory: 'provider-config',+ blockedCategory: PROVIDER_CONFIG_BLOCKED_CATEGORY,blockedAt: new Date().toISOString()}}, task.taskType || 'user').catch(() => {});diff --git a/server/services/agentLifecycle.test.js b/server/services/agentLifecycle.test.jsindex d6c3b4f77e..af6ba7b32d 100644--- a/server/services/agentLifecycle.test.js+++ b/server/services/agentLifecycle.test.js@@ -32,6 +32,7 @@ import { dirname, join } from 'path';import { spawningTasks, runnerAgents } from './agentState.js';import { withSpawnDedupGuard, withMapEntryCleanup, withUpdateInProgressGuard, SPAWN_DEDUP_SKIP, SPAWN_UPDATE_SKIP } from './agentGuards.js';import { isInternalTaskId } from '../lib/taskParser.js';+import { PROVIDER_CONFIG_BLOCKED_CATEGORY, PAUSED_BLOCKED_CATEGORIES, USER_DECISION_BLOCKED_CATEGORIES } from '../lib/taskBlockCategories.js';const __dirname = dirname(fileURLToPath(import.meta.url));const AGENT_LIFECYCLE_SRC = readFileSync(join(__dirname, 'agentLifecycle.js'), 'utf-8');@@ -619,7 +620,22 @@ describe('runAgentSpawn source — permanent provider-config failure blocks theconst body = AGENT_LIFECYCLE_SRC.slice(idx, idx + 2000);expect(body, 'gates the block on resolution.permanent').toMatch(/if\s*\(resolution\.permanent\)/);expect(body, 'flips the task to blocked').toMatch(/status:\s*'blocked'/);- expect(body, 'tags the block category').toMatch(/blockedCategory:\s*'provider-config'/);+ // The category is the SHARED constant, not a hand-written literal: the pause+ // and reaper-exemption sets in lib/taskBlockCategories.js key on the same+ // value, and a stamp-site literal is exactly how those three drift apart.+ expect(body, 'tags the block category from the shared constant').toMatch(/blockedCategory:\s*PROVIDER_CONFIG_BLOCKED_CATEGORY,/);+ expect(body, 'does not re-hardcode the literal').not.toMatch(/blockedCategory:\s*'provider-config'/);+ expect(AGENT_LIFECYCLE_SRC, 'imports the shared constant').toMatch(/import \{[^}]*PROVIDER_CONFIG_BLOCKED_CATEGORY[^}]*\} from '\.\.\/lib\/taskBlockCategories\.js'/);+ });++ // The block only does its job if the vocabulary module agrees it is a config+ // PAUSE (keeps the resume pointer) and a user DECISION (exempt from the 14-day+ // auto-expiry). Pin both memberships here, at the stamp site, so removing one+ // fails beside the code that depends on it.+ it('the stamped category is a config pause the reaper leaves alone', () => {+ expect(PROVIDER_CONFIG_BLOCKED_CATEGORY).toBe('provider-config');+ expect(PAUSED_BLOCKED_CATEGORIES.has(PROVIDER_CONFIG_BLOCKED_CATEGORY), 'keeps its resume pointer').toBe(true);+ expect(USER_DECISION_BLOCKED_CATEGORIES.has(PROVIDER_CONFIG_BLOCKED_CATEGORY), 'never auto-expired to completed').toBe(true);});it('blocks BEFORE releasing the lease so a federated peer cannot be clobbered', () => {diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.jsindex 10b7e9324a..3f7a0a5a95 100644--- a/server/services/cosTaskStore.test.js+++ b/server/services/cosTaskStore.test.js@@ -1177,6 +1177,24 @@ describe('cosTaskStore.updateTask', () => {expect(blocked.metadata.resumeWorktreePath).toBe('/w/agent-x');});+ // Same for a permanent provider-config block (#6193): the resolved provider is+ // `api`-type and has no file-writing harness, so the task waits for the user to+ // add a CLI provider. Dropping the pointer means the revived task starts on a+ // fresh branch and orphans the worktree its dead agent left behind.+ it('keeps the resume pointer through a provider-config block', async () => {+ await addTask({ description: 'unrunnable provider', id: 'task-provider-config' }, 'user');+ await updateTask('task-provider-config', {+ metadata: { existingBranch: 'cos/b', resumedFromAgentId: 'agent-x', resumeWorktreePath: '/w/agent-x' }+ }, 'user');+ const blocked = await updateTask('task-provider-config', {+ status: 'blocked',+ metadata: { blockedCategory: 'provider-config' }+ }, 'user');+ expect(blocked.metadata.existingBranch).toBe('cos/b');+ expect(blocked.metadata.resumedFromAgentId).toBe('agent-x');+ expect(blocked.metadata.resumeWorktreePath).toBe('/w/agent-x');+ });+// An `existingBranch` with no `resumedFromAgentId` beside it was never written// by the resume mechanism — it is the task's OWN configuration. A merge// follow-up is the producer: it exists to land the PR on that branch. Stripping@@ -1626,7 +1644,10 @@ describe('cosTaskStore — stale failure-artifact reaper (#2619)', () => {// The workspace blocks are an open decision too: the task waits for the// user to fix the app's Repository Path, so auto-completing it at 14 days// would silently retire work nobody decided to drop.- for (const cat of ['user-terminated', 'agent-paused', 'challenge-escalation', 'app-unresolved', 'workspace-invalid']) {+ // `provider-config` is the same shape: an `api`-only provider can't run an+ // agent, and only the user can fix that — so a 14-day flip to `completed`+ // would report undropped work as done and federate that lie to every peer.+ for (const cat of ['user-terminated', 'agent-paused', 'challenge-escalation', 'app-unresolved', 'workspace-invalid', 'provider-config']) {expect(blockedFailureAgeMs(blocked(cat, daysAgo(30)), NOW)).toBeNull();expect(isReapableBlockedFailure(blocked(cat, daysAgo(30)), { now: NOW })).toBe(false);}@@ -1639,8 +1660,8 @@ describe('cosTaskStore — stale failure-artifact reaper (#2619)', () => {});it('falls back to lastFailureAt then updatedAt when blockedAt is absent', () => {- expect(blockedFailureAgeMs({ status: 'blocked', metadata: { blockedCategory: 'provider-config', lastFailureAt: daysAgo(20) } }, NOW)).toBe(20 * 24 * 60 * 60 * 1000);- expect(blockedFailureAgeMs({ status: 'blocked', metadata: { blockedCategory: 'provider-config', updatedAt: daysAgo(20) } }, NOW)).toBe(20 * 24 * 60 * 60 * 1000);+ expect(blockedFailureAgeMs({ status: 'blocked', metadata: { blockedCategory: 'max-spawns', lastFailureAt: daysAgo(20) } }, NOW)).toBe(20 * 24 * 60 * 60 * 1000);+ expect(blockedFailureAgeMs({ status: 'blocked', metadata: { blockedCategory: 'max-spawns', updatedAt: daysAgo(20) } }, NOW)).toBe(20 * 24 * 60 * 60 * 1000);});it('never reaps an undated block (cannot prove it is old)', () => {@@ -1713,6 +1734,23 @@ describe('cosTaskStore — stale failure-artifact reaper (#2619)', () => {expect(after.tasks.find(t => t.id === 'task-stop').status).toBe('blocked');});+ // A provider-config block never self-revives — it waits for the user to add a+ // CLI provider — so the reaper must leave it alone no matter how old it gets.+ // Flipping it to `completed` with `resolution: 'auto-expired'` would report+ // work nobody dropped as done, and federate that to every peer (#6193).+ it('never auto-expires a provider-config block, however stale', async () => {+ await addTask({ description: 'api-only provider pinned', id: 'task-pc-old', priority: 'HIGH' }, 'user', { now: NOW });+ await updateTask('task-pc-old', { status: 'blocked', metadata: { blockedCategory: 'provider-config', blockedAt: daysAgo(90) } }, 'user', { now: NOW });+ const res = await sweepResolvedFailureTasks({ now: NOW });+ expect(res.reaped).toBe(0);+ expect(res.staleBlocks).toBe(0);+ const task = (await getUserTasks()).tasks.find(t => t.id === 'task-pc-old');+ expect(task.status).toBe('blocked');+ expect(task.metadata.blockedCategory).toBe('provider-config');+ expect(task.metadata.resolution).toBeUndefined();+ expect(task.metadata.autoExpiredReason).toBeUndefined();+ });+it('flips an investigation whose originating task has completed', async () => {await addTask({ description: 'origin work', id: 'task-origin', priority: 'HIGH' }, 'user', { now: NOW });await updateTask('task-origin', { status: 'completed' }, 'user', { now: NOW });