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
address review (claude): keep a refused lane's resume pointer, and refuse a lane with nothing to inherit
Adam Eivyd2580ef35237
diff --git a/server/lib/taskBlockCategories.js b/server/lib/taskBlockCategories.jsindex bd1c1e9a5e..4f21ab158b 100644--- a/server/lib/taskBlockCategories.js+++ b/server/lib/taskBlockCategories.js@@ -17,6 +17,14 @@import { AGENT_PAUSED_CATEGORY } from './taskPauseHold.js';+/**+ * A fail-closed orchestration lane refused to substitute providers (#5993). Its+ * own exported name because three places key on it — `agentLifecycle.js` stamps+ * it, and BOTH sets below list it — which is exactly the literal drift this+ * module exists to prevent.+ */+export const ORCHESTRATION_LANE_BLOCKED_CATEGORY = 'orchestration-lane-unavailable';+/*** Pauses a TIMER clears, not a person: the task carries a `cooldownUntil` and the* cooldown sweeper (`unblockExpiredCooldowns`, cosTaskGenerator.js) flips it back@@ -46,7 +54,16 @@ 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 fail-closed lane is a CONFIG pause of the same shape: the user authenticates+ // the provider (or gives the role a fallbackProvider) and revives the task. It+ // is not TIMED, so no cooldown sweeper picks it up. Listing it here is what+ // keeps the resume pointer — without it a lane that blocked on a merely+ // rate-limited provider would strip `existingBranch` / `resumeWorktreePath`,+ // and the revived task would restart clean and orphan its predecessor's+ // worktree. Before fail-closed that case stayed `pending` with its pointer+ // intact, so omitting it here would be a NEW way to abandon work.+ ORCHESTRATION_LANE_BLOCKED_CATEGORY]);/**@@ -60,24 +77,17 @@ export const PAUSED_BLOCKED_CATEGORIES = new Set([* categories stay reapable — they revive themselves in minutes, so one still* sitting there after 14 days IS stale.)*/-/**- * A fail-closed orchestration lane refused to substitute providers (#5993). Its- * own exported name because `agentLifecycle.js` stamps it and the sweep below- * exempts it — two string literals that must never drift apart.- */-export const ORCHESTRATION_LANE_BLOCKED_CATEGORY = 'orchestration-lane-unavailable';-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',- // Waiting on the same kind of fix as the two above: authenticate the lane's- // provider, pick another model for the role, or give it a fallbackProvider.- // Without the exemption the failure sweep retires it to `completed` with an- // `auto-expired` marker after 14 days — turning the loud, deliberate stop into- // exactly the silent success the fail-closed lane exists to prevent.+ // Waiting on the same kind of fix as the workspace blocks above: authenticate+ // the lane's provider, pick another model for the role, or give it a+ // fallbackProvider. Without the exemption the failure sweep retires it to+ // `completed` with an `auto-expired` marker after 14 days — turning the loud,+ // deliberate stop into exactly the silent success the lane exists to prevent.ORCHESTRATION_LANE_BLOCKED_CATEGORY]);diff --git a/server/services/agentProviderResolution.js b/server/services/agentProviderResolution.jsindex 9818e5a590..483d8a04e2 100644--- a/server/services/agentProviderResolution.js+++ b/server/services/agentProviderResolution.js@@ -196,17 +196,26 @@ async function resolveOrdinaryProviderAndModel(task) {}}if (!provider) provider = await getActiveProvider();- // A lane that pins only a MODEL inherits the active provider — so when there- // is no active provider it is the LANE that has nowhere to run, and it says so- // in the lane's own shape. Falling through to the generic- // "No active AI provider configured" below would lose the role, leaving the- // client with nothing to name.- if (lane && !provider) {+ // A lane that pins only a MODEL inherits whatever provider the task resolves+ // to — so both ways that inheritance can fail are the LANE failing, and both+ // say so in the lane's own shape rather than falling through.+ //+ // `userProviderMissing` is the one that bites: the `else` above continues on+ // the active provider, which makes `providerSwapped` true below, which drops+ // the lane's pinned model to that provider's default. That is the silent+ // model-axis substitution the `no-model` refusal and the alternate's+ // pass-through exemption exist to close, arriving on a path with no block, no+ // `orchestrationLane`, and nothing naming the role. The other is simpler: no+ // active provider at all, where the generic "No active AI provider configured"+ // below would lose the role and leave the client nothing to name.+ if (lane && (!provider || userProviderMissing)) {return laneUnavailable({role: laneRole,- requestedProvider: null,+ requestedProvider: userProviderMissing ? userProviderId : null,requestedModel: lane.model || null,- reason: 'no active AI provider is configured for it to inherit',+ reason: userProviderMissing+ ? 'the provider pinned for this task is not configured on this install'+ : 'no active AI provider is configured for it to inherit',});}diff --git a/server/services/agentProviderResolution.test.js b/server/services/agentProviderResolution.test.jsindex 78a6312c41..4846b6d656 100644--- a/server/services/agentProviderResolution.test.js+++ b/server/services/agentProviderResolution.test.js@@ -815,3 +815,51 @@ describe('resolveAgentProviderAndModel — orchestration accounting coverage', (});});});++/**+ * Both ways a model-only lane's provider inheritance can fail. The+ * missing-task-pin case is the sharp one: it used to continue on the active+ * provider, which counts as a provider swap and drops the lane's model to that+ * provider's default — a silent substitution with no block and nothing naming+ * the role.+ */+describe('resolveAgentProviderAndModel — a model-only lane with nothing to inherit', () => {+ const modelOnly = {+ id: 'task-model-only',+ metadata: {+ provider: 'p-gone',+ orchestrationMode: 'orchestrated',+ orchestrationProfile: { architect: { model: 'm-cheap' } },+ },+ };++ it('refuses when the task-level provider pin names a missing record', async () => {+ getProviderById.mockResolvedValue(null);+ getActiveProvider.mockResolvedValue({ id: 'p-active', type: 'cli', models: ['m-active'], defaultModel: 'm-active' });+ selectModelForTask.mockResolvedValue({ model: 'm-cheap', tier: 'user-specified', reason: 'orchestration-role-architect' });++ const r = await resolveAgentProviderAndModel(modelOnly);++ expect(r.ok).toBe(false);+ expect(r.permanent).toBe(true);+ expect(r.orchestrationLane).toEqual({+ role: 'architect',+ requestedProvider: 'p-gone',+ requestedModel: 'm-cheap',+ reason: 'the provider pinned for this task is not configured on this install',+ });+ });++ it('still refuses when there is no active provider to inherit at all', async () => {+ getActiveProvider.mockResolvedValue(null);++ const r = await resolveAgentProviderAndModel({+ ...modelOnly,+ metadata: { ...modelOnly.metadata, provider: undefined },+ });++ expect(r.ok).toBe(false);+ expect(r.orchestrationLane.requestedProvider).toBeNull();+ expect(r.orchestrationLane.reason).toContain('no active AI provider');+ });+});diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.jsindex 2c8c9a37f4..0ee2166dda 100644--- a/server/services/cosTaskStore.test.js+++ b/server/services/cosTaskStore.test.js@@ -1195,6 +1195,25 @@ describe('cosTaskStore.updateTask', () => {expect(blocked.metadata.resumeWorktreePath).toBe('/w/agent-x');});+ // Same CONFIG-pause shape (#5993): the user authenticates the lane's provider+ // and revives the task. Stripping the pointer here would restart the revived+ // task clean and orphan its predecessor's worktree — and before this block+ // category existed, that same condition left the task pending with its pointer+ // intact, so losing it would be a NEW way to abandon work.+ it('keeps the resume pointer through a refused orchestration lane', async () => {+ await addTask({ description: 'lane', id: 'task-lane-ptr' }, 'user');+ await updateTask('task-lane-ptr', {+ metadata: { existingBranch: 'cos/b', resumedFromAgentId: 'agent-x', resumeWorktreePath: '/w/agent-x' }+ }, 'user');+ const blocked = await updateTask('task-lane-ptr', {+ status: 'blocked',+ metadata: { blockedCategory: ORCHESTRATION_LANE_BLOCKED_CATEGORY }+ }, 'user');+ expect(blocked.metadata.existingBranch).toBe('cos/b');+ expect(blocked.metadata.resumeWorktreePath).toBe('/w/agent-x');+ expect(blocked.metadata.resumedFromAgentId).toBe('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