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 (codex): preserve manual swarm count

[._.]/ Adam Eivydd8e165d2581
diff --git a/server/routes/cos.test.js b/server/routes/cos.test.js
index b36fd24537..c1cc90c6c9 100644
--- a/server/routes/cos.test.js
+++ b/server/routes/cos.test.js
@@ -1126,7 +1126,8 @@ describe('CoS Routes', () => {
optionalReviewers: [],
reviewerMaxRounds: { codex: 2 },
reviewerModels: {},
- reviewerEfforts: { codex: 'high' }
+ reviewerEfforts: { codex: 'high' },
+ swarmCount: 6
}
});
cos.addTask.mockResolvedValue({ id: 'task-sd-next-reviewers', status: 'pending' });
@@ -1144,6 +1145,7 @@ describe('CoS Routes', () => {
reviewerMaxRounds: { codex: 2 },
reviewerModels: {},
reviewerEfforts: { codex: 'high' },
+ swarmCount: 6,
claimFlow: true
});
// `reviewLoop` stays off — the claim prompt owns its own review sequence.
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index b9a621b39e..752853482b 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -541,6 +541,12 @@ export async function buildClaimWorkTask(app, {
// names — the reviewer pin is emitted once from there (#4770).
const delegatedMeta = taskSchedule.DEFAULT_TASK_INTERVALS[promptTaskType]?.taskMetadata || {};
const taskMetadata = { ...reviewerConfigMetadata(claimReviewers), claimFlow: true };
+ // The manual `/do:next` path persists this non-raw task through addTask's
+ // metadata allowlist before agentLifecycle sees it. Carry the same count that
+ // rendered the swarm block so Codex can size its session to root + workers.
+ // A pinned target suppresses swarmBlock above and therefore must not retain a
+ // stale configured count.
+ if (swarmBlock) taskMetadata.swarmCount = metadata.swarmCount;
if ('useWorktree' in delegatedMeta) taskMetadata.useWorktree = delegatedMeta.useWorktree;
if ('openPR' in delegatedMeta) taskMetadata.openPR = delegatedMeta.openPR;
diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.js
index 54e84d3460..f9989fe7c8 100644
--- a/server/services/cosTaskGenerator.test.js
+++ b/server/services/cosTaskGenerator.test.js
@@ -80,7 +80,7 @@ import {
applyPerpetualDrainCap
} from './cosTaskGenerator.js';
import { cosEvents } from './cosEvents.js';
-import { DEFAULT_TASK_INTERVALS } from './taskSchedule.js';
+import { DEFAULT_TASK_INTERVALS, getTaskInterval } from './taskSchedule.js';
import { MAX_TOTAL_SPAWNS } from '../lib/validation.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -1681,4 +1681,28 @@ describe('buildClaimWorkTask reviewer pin', () => {
expect(prompt).toContain('Reviewers: claude,@alice');
expect(taskMetadata.reviewers).toEqual(['claude']);
});
+
+ it('persists the cloud swarm count that the manual claim prompt renders', async () => {
+ getTaskInterval.mockResolvedValueOnce({
+ prompt: null,
+ taskMetadata: { reviewers: ['codex'], swarmCount: 6 },
+ });
+
+ const { prompt, taskMetadata } = await buildClaimWorkTask(app);
+
+ expect(prompt).toContain('--swarm=6');
+ expect(taskMetadata.swarmCount).toBe(6);
+ });
+
+ it('does not persist a configured swarm count when a manual claim pins one target', async () => {
+ getTaskInterval.mockResolvedValueOnce({
+ prompt: null,
+ taskMetadata: { reviewers: ['codex'], swarmCount: 6 },
+ });
+
+ const { prompt, taskMetadata } = await buildClaimWorkTask(app, { target: '42' });
+
+ expect(prompt).not.toContain('--swarm=6');
+ expect(taskMetadata.swarmCount).toBeUndefined();
+ });
});
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index beafe7ee93..2f9873455b 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -16,7 +16,7 @@ import { readFile, writeFile, stat } from 'fs/promises';
import { existsSync } from 'fs';
import { join } from 'path';
import { parseTasksMarkdown, groupTasksByStatus, getAutoApprovedTasks, getAwaitingApprovalTasks, generateTasksMarkdown, hasKnownPrefix } from '../lib/taskParser.js';
-import { REVIEW_STOP_MODES, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, KEYED_REVIEWER_PINS } from '../lib/validation.js';
+import { KEYED_REVIEWER_PINS, MAX_TOTAL_SPAWNS, REVIEW_STOP_MODES, SWARM_COUNT_MAX, SWARM_COUNT_MIN, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers } from '../lib/validation.js';
import { isPlainObject } from '../lib/objects.js';
import { PR_COMPLETIONS, PR_COMPLETION_VALUES } from '../lib/prDisposition.js';
import { RETRY_HOLD_KEY, RETRY_HOLD_SINCE_KEY } from '../lib/taskRetryHold.js';
@@ -31,7 +31,6 @@ import { cosEvents } from './cosEvents.js';
import { CLAIM_METADATA_KEYS, TARGET_INSTANCE_KEY, getTargetInstance } from './cosTaskClaim.js';
import { mergeTaskLists } from './cosTaskMerge.js';
import { canChallenge, getChallengeCount, buildChallengePatch, buildChallengeResolutionPatch, classifyRecheckOutcome, MAX_CHALLENGES_PER_TASK } from './cosChallenge.js';
-import { MAX_TOTAL_SPAWNS } from '../lib/validation.js';
import { runLocalCodeReview, getCodeReviewDefaults } from './codeReview.js';
// First non-empty line of a string. Used by addTask dedup: stored descriptions
@@ -445,6 +444,13 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
// known (see server/lib/slashdoInvocation.js).
if (taskData.slashdoCommand) metadata.slashdoCommand = taskData.slashdoCommand;
if (taskData.slashdoArgs) metadata.slashdoArgs = taskData.slashdoArgs;
+ // Manual `/do:next` claim swarms are non-raw tasks. Their prompt already
+ // names the fan-out, and agentLifecycle needs this count after the markdown
+ // round-trip to lift a cloud Codex session to root + configured workers.
+ const swarmCount = Number(taskData.swarmCount);
+ if (Number.isSafeInteger(swarmCount) && swarmCount >= SWARM_COUNT_MIN && swarmCount <= SWARM_COUNT_MAX) {
+ metadata.swarmCount = swarmCount;
+ }
if (taskData.malwareScan && typeof taskData.malwareScan === 'object' && !Array.isArray(taskData.malwareScan)) {
metadata.malwareScan = taskData.malwareScan;
}
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index aa60f5299f..fd1265d583 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -507,6 +507,23 @@ describe('cosTaskStore.addTask', () => {
expect(tasks.find(t => t.id === created.id).metadata.claimTarget).toBe('42');
});
+ it('persists a manual claim swarm count through the task markdown round-trip', async () => {
+ const created = await addTask({
+ description: 'Claim six independent GitHub issues for Example App',
+ app: 'example-app',
+ swarmCount: 6,
+ }, 'user');
+
+ expect(created.metadata.swarmCount).toBe(6);
+ const { tasks } = await getUserTasks();
+ expect(tasks.find(t => t.id === created.id).metadata.swarmCount).toBe(6);
+ });
+
+ it('drops an out-of-range manual claim swarm count', async () => {
+ const created = await addTask({ description: 'Invalid claim swarm', swarmCount: 7 }, 'user');
+ expect(created.metadata.swarmCount).toBeUndefined();
+ });
+
it('persists malware scan report ownership through the task markdown round-trip', async () => {
const malwareScan = { linkId: 'a3d2c4e8-810a-4d1a-8ab1-94d3e0a13f8d', reportId: 'b38bdf75-3fe2-498c-9c36-7d512dc078d1' };
const created = await addTask({ description: 'Malware scan: example/repo', malwareScan }, 'user');