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

address review (claude): stop the lane's own alternate from being quietly rewritten

Adam Eivy2cb4f728ff5d
diff --git a/server/lib/taskBlockCategories.js b/server/lib/taskBlockCategories.js
index 64c90e8b5d..bd1c1e9a5e 100644
--- a/server/lib/taskBlockCategories.js
+++ b/server/lib/taskBlockCategories.js
@@ -60,12 +60,25 @@ 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 agent
AGENT_PAUSED_CATEGORY, // user paused; resumable on demand
'challenge-escalation', // parked awaiting the user's arbitration
'app-unresolved',
- 'workspace-invalid'
+ '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.
+ ORCHESTRATION_LANE_BLOCKED_CATEGORY
]);
/**
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.js
index fa268ddd66..d7c47507f5 100644
--- a/server/services/agentLifecycle.js
+++ b/server/services/agentLifecycle.js
@@ -45,6 +45,7 @@ import { spawnAgentViaRunner, getRunnerHealth, classifyRunnerSpawnFailure, RUNNE
import { MAX_TOTAL_SPAWNS, normalizeReviewers } from '../lib/validation.js';
import { isInternalTaskId } from '../lib/taskParser.js';
import { isRetryHeld } from '../lib/taskRetryHold.js';
+import { ORCHESTRATION_LANE_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';
@@ -425,7 +426,7 @@ async function runAgentSpawn(task) {
metadata: {
...task.metadata,
blockedReason: resolution.error,
- blockedCategory: lane ? 'orchestration-lane-unavailable' : 'provider-config',
+ blockedCategory: lane ? ORCHESTRATION_LANE_BLOCKED_CATEGORY : 'provider-config',
...(lane ? { orchestrationLane: lane } : {}),
blockedAt: new Date().toISOString()
}
diff --git a/server/services/agentLifecycle.test.js b/server/services/agentLifecycle.test.js
index 74393abf20..d691196c36 100644
--- a/server/services/agentLifecycle.test.js
+++ b/server/services/agentLifecycle.test.js
@@ -635,7 +635,11 @@ describe('runAgentSpawn source — permanent provider-config failure blocks the
const idx = AGENT_LIFECYCLE_SRC.indexOf('const resolution = await resolveAgentProviderAndModel(task)');
const body = AGENT_LIFECYCLE_SRC.slice(idx, idx + RESOLUTION_FAILURE_WINDOW);
expect(body, 'reads the structured lane detail').toMatch(/const lane = resolution\.orchestrationLane/);
- expect(body, 'has its own block category').toMatch(/'orchestration-lane-unavailable'/);
+ // The category is referenced through the shared constant, not re-typed: the
+ // failure sweep exempts the same value, and two literals would drift.
+ expect(body, 'has its own block category').toMatch(/ORCHESTRATION_LANE_BLOCKED_CATEGORY/);
+ expect(AGENT_LIFECYCLE_SRC, 'takes the category from the shared module')
+ .toMatch(/import \{ ORCHESTRATION_LANE_BLOCKED_CATEGORY \} from '\.\.\/lib\/taskBlockCategories\.js';/);
expect(body, 'carries the detail onto the task').toMatch(/orchestrationLane: lane/);
expect(body, 'records the refusal in the ledger').toMatch(/kind: 'run\.lane-refused'/);
});
diff --git a/server/services/agentProviderResolution.js b/server/services/agentProviderResolution.js
index 109c9fa2c7..9818e5a590 100644
--- a/server/services/agentProviderResolution.js
+++ b/server/services/agentProviderResolution.js
@@ -18,7 +18,7 @@ import { getActiveProvider, getAllProviders, getProviderById } from './providers
import { isProviderAvailable, getFallbackProvider, getProviderStatus } from './providerStatus.js';
import { selectModelForRole, selectModelForTask } from './agentModelSelection.js';
import { modelPinIsOffered } from '../lib/localProviderRuntime.js';
-import { PRIMARY_ORCHESTRATION_ROLE, roleAssignment } from '../lib/orchestrationProfile.js';
+import { PRIMARY_ORCHESTRATION_ROLE, isOrchestratedTask, roleAssignment } from '../lib/orchestrationProfile.js';
import { publicReviewPostureForTask, resolvePublicReviewProvider } from './publicReviewProviderSelection.js';
/**
@@ -397,7 +397,16 @@ async function resolveOrdinaryProviderAndModel(task) {
const providerSwapped = userProviderMissing || provider.id !== directProviderId;
const pinnedProviderId = userProviderId || directProviderId;
const isUserPin = modelSelection.tier === 'user-specified' && !fallbackModelPin;
- const isUserPinnedModel = isUserPin && !providerSwapped;
+ // A lane's own `fallbackModel` is as explicit as `metadata.model` — the user
+ // named THIS model FOR THIS alternate (#5993). The `models` list is a
+ // convenience enumeration the pass-through CLIs don't enforce, and whose alias
+ // forms already disagree across records (see the note below), so downgrading
+ // the pin to the alternate's default here would silently run the lane on a
+ // model nobody chose — the model-axis substitution the `no-model` refusal
+ // above exists to close, arriving one branch later.
+ const isLaneAlternateModel = Boolean(laneSubstitution)
+ && fallbackModelPin != null && fallbackModelPin === lane?.fallbackModel;
+ const isUserPinnedModel = (isUserPin && !providerSwapped) || isLaneAlternateModel;
if (isUserPin && providerSwapped && !(provider.models || []).includes(selectedModel)) {
// Handled here rather than left to the list check below, which can't fire at
// all for a fallback provider that enumerates no `models`.
@@ -450,11 +459,14 @@ async function resolveOrdinaryProviderAndModel(task) {
// What the run ledger records so `/cos/runs` can show the tier split really
// happened (#5993): the role this run was dispatched as, the provider it
// ACTUALLY ran on, and the one substitution — if any — the lane accepted.
- // Absent on a `direct`-mode run, which has no roles to account for.
- ...(roleAssign ? {
+ // Gated on the RUN being orchestrated, not on this role being pinned: a
+ // profile that pins only the cheap implementer/reviewer lanes and leaves the
+ // architect on the run default is a normal config, and it is exactly the run
+ // whose tier split is worth showing. Absent on a `direct`-mode run.
+ ...(isOrchestratedTask(task) ? {
orchestrationLane: {
role: laneRole,
- requestedProvider: roleAssign.provider || directProviderId,
+ requestedProvider: roleAssign?.provider || directProviderId,
providerId: provider.id,
model: selectedModel,
...(laneSubstitution ? { substitution: laneSubstitution } : {}),
diff --git a/server/services/agentProviderResolution.test.js b/server/services/agentProviderResolution.test.js
index 7b0b1e9ba2..78a6312c41 100644
--- a/server/services/agentProviderResolution.test.js
+++ b/server/services/agentProviderResolution.test.js
@@ -762,8 +762,13 @@ describe('resolveAgentProviderAndModel — what a same-role alternate must satis
expect(r.orchestrationLane.substitution.to).toBe('p-cheap-2');
});
+ // The alternate enumerates a DIFFERENT model on purpose: a provider's `models`
+ // list is a convenience enumeration the pass-through CLIs never enforce, so
+ // letting it downgrade the user's configured fallbackModel to the alternate's
+ // own default would re-open the model-axis substitution on the one path that
+ // is allowed to swap providers at all.
it('carries a model-pinned lane onto its alternate using the configured fallbackModel', async () => {
- const alternate = { id: 'p-cheap-2', type: 'cli', models: ['alt-m'], defaultModel: 'alt-default' };
+ const alternate = { id: 'p-cheap-2', type: 'cli', models: ['something-else'], defaultModel: 'alt-default' };
getProviderById.mockImplementation(async (id) => (
id === 'p-cheap' ? { id, type: 'cli', defaultModel: 'm-cheap' } : alternate
));
@@ -781,3 +786,32 @@ describe('resolveAgentProviderAndModel — what a same-role alternate must satis
expect(r.selectedModel).toBe('alt-m');
});
});
+
+/**
+ * The run ledger's tier accounting keys off the RUN being orchestrated, not off
+ * the architect happening to be pinned — a profile that pins only the cheap
+ * implementer/reviewer lanes is a normal config, and its split is the one most
+ * worth showing.
+ */
+describe('resolveAgentProviderAndModel — orchestration accounting coverage', () => {
+ it('accounts for an orchestrated run whose profile pins no architect', async () => {
+ const provider = { id: 'p-active', type: 'cli', models: ['m-default'] };
+ getActiveProvider.mockResolvedValue(provider);
+
+ const r = await resolveAgentProviderAndModel({
+ id: 'task-no-architect',
+ metadata: {
+ orchestrationMode: 'orchestrated',
+ orchestrationProfile: { implementer: { provider: 'p-cheap' }, reviewer: { provider: 'p-cheap' } },
+ },
+ });
+
+ expect(r.ok).toBe(true);
+ expect(r.orchestrationLane).toEqual({
+ role: 'architect',
+ requestedProvider: 'p-active',
+ providerId: 'p-active',
+ model: 'm-default',
+ });
+ });
+});
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index 748a33cbf7..2c8c9a37f4 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -118,6 +118,7 @@ import {
} from './cosTaskStore.js';
import { AGENT_PAUSED_CATEGORY, PAUSE_METADATA_KEYS, registerPauseReleaseAdapter, __resetPauseReleaseAdapter } from '../lib/taskPauseHold.js';
import { MAX_TOTAL_SPAWNS } from '../lib/cosValidation.js';
+import { ORCHESTRATION_LANE_BLOCKED_CATEGORY } from '../lib/taskBlockCategories.js';
const USER_FILE = join('/root', 'TASKS.md');
const COS_FILE = join('/root', 'COS-TASKS.md');
@@ -1730,6 +1731,24 @@ describe('cosTaskStore — stale failure-artifact reaper (#2619)', () => {
expect(after.tasks.find(t => t.id === 'task-stop').status).toBe('blocked');
});
+ // A fail-closed orchestration lane (#5993) stops the run ON PURPOSE and waits
+ // on a user config fix. Retiring it to `completed` after 14 days would convert
+ // that deliberate loud stop into the silent success the whole feature exists
+ // to prevent — so it is exempt like the other user-decision blocks.
+ it('leaves a refused orchestration lane for the user however long it sits', async () => {
+ await addTask({ description: 'lane blocked', id: 'task-lane-old', priority: 'LOW' }, 'user', { now: NOW });
+ await updateTask('task-lane-old', {
+ status: 'blocked',
+ metadata: { blockedCategory: ORCHESTRATION_LANE_BLOCKED_CATEGORY, blockedAt: daysAgo(90) },
+ }, 'user', { now: NOW });
+ const res = await sweepResolvedFailureTasks({ now: NOW });
+ expect(res.reaped).toBe(0);
+ const after = await getUserTasks();
+ const task = after.tasks.find(t => t.id === 'task-lane-old');
+ expect(task.status).toBe('blocked');
+ expect(task.metadata.resolution).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 });
diff --git a/server/services/promptSections/orchestrationDoctrine.test.js b/server/services/promptSections/orchestrationDoctrine.test.js
index 793d48eb16..9ece340682 100644
--- a/server/services/promptSections/orchestrationDoctrine.test.js
+++ b/server/services/promptSections/orchestrationDoctrine.test.js
@@ -62,7 +62,7 @@ describe('fail-closed lane doctrine (#5993)', () => {
implementer: { provider: 'p-cheap', fallbackProvider: 'p-cheap-2', fallbackModel: 'm-cheap-2' },
}));
expect(section).toContain('the lane may use `p-cheap-2` with model `m-cheap-2` — and nothing else');
- expect(section).not.toContain('the run STOPS — no other provider is substituted for this lane.\n- **implementer**');
+ expect(section.split('\n').find(l => l.startsWith('- **implementer**'))).not.toContain('STOPS');
});
it('says nothing about substitution for a role that pins nothing', () => {