fix: name commander active runner count

This commit is contained in:
Codex
2026-05-23 01:01:53 +00:00
parent 031c3fda39
commit 982f21ec62
6 changed files with 81 additions and 3 deletions
@@ -169,6 +169,9 @@ function assertQueuesShape(label: string, result: unknown, expectedView: string)
assertCondition(activity.databaseRunningTaskCount === 1, `${label} activity should distinguish database running tasks`, activity);
assertCondition(activity.heartbeatFreshActiveTaskCount === 1, `${label} activity should distinguish heartbeat-fresh active runners`, activity);
assertCondition(activity.schedulerLocalActiveQueueCount === 1, `${label} activity should distinguish scheduler-local active queues`, activity);
const commanderConcurrency = asRecord(activity.commanderConcurrency);
assertCondition(commanderConcurrency.activeRunnerCount === 1, `${label} activity should expose commander-facing active runner count`, commanderConcurrency);
assertCondition(commanderConcurrency.activeRunnerCountField === "activity.effectiveActiveTaskCount", `${label} activity should name the active runner count field`, commanderConcurrency);
assertCondition(activity.activeQueueIdsScope === "scheduler-local-active-run-slots", `${label} activity should label activeQueueIds scope`, activity);
assertCondition(Array.isArray(queues.activeTaskIds), `${label} activeTaskIds should be present`, queues);
assertCondition(Array.isArray(queues.queuedTaskIds), `${label} queuedTaskIds should be present`, queues);
@@ -183,6 +186,7 @@ function assertSplitBrainLiveActivity(label: string, result: unknown): void {
assertCondition(totals.databaseRunningTaskCount === 8, `${label} should foreground DB running task count`, totals);
assertCondition(totals.databaseActiveTaskCount === 8, `${label} should foreground DB active task count`, totals);
assertCondition(totals.heartbeatFreshActiveTaskCount === 8, `${label} should foreground heartbeat-effective active runners`, totals);
assertCondition(totals.commanderActiveRunnerCount === 8, `${label} should mirror commander active count in totals`, totals);
assertCondition(totals.effectiveActiveTaskCount === 8, `${label} should foreground effective active task count`, totals);
assertCondition(asArray(queues.activeQueueIds).length === 0, `${label} activeQueueIds should remain the scheduler-local list`, queues);
assertCondition(queues.activeQueueIdsScope === "scheduler-local-active-run-slots", `${label} activeQueueIds should be scoped`, queues);
@@ -196,6 +200,13 @@ function assertSplitBrainLiveActivity(label: string, result: unknown): void {
assertCondition(activity.schedulerLocalActiveRunSlotCount === 0, `${label} activity should expose scheduler-local slot count`, activity);
assertCondition(activity.runnableQueueCount === 0, `${label} activity should expose runnable queue count`, activity);
assertCondition(activity.splitBrainLive === true, `${label} activity should preserve split-brain live`, activity);
assertCondition(activity.splitBrainDisposition === "live-count-as-active", `${label} activity should count live split-brain as active`, activity);
const commanderConcurrency = asRecord(queues.commanderConcurrency);
assertCondition(commanderConcurrency.activeRunnerCount === 8, `${label} should expose commander-facing active runner count`, commanderConcurrency);
assertCondition(commanderConcurrency.activeRunnerCountField === "activity.effectiveActiveTaskCount", `${label} should name the active runner count field`, commanderConcurrency);
assertCondition(commanderConcurrency.splitBrainDisposition === "live-count-as-active", `${label} should classify live split-brain capacity`, commanderConcurrency);
assertCondition(commanderConcurrency.interventionRequired === false, `${label} should not require intervention for fresh split-brain`, commanderConcurrency);
assertCondition(String(commanderConcurrency.decisionRule ?? "").includes("15 - activeRunnerCount"), `${label} should give 15-concurrency arithmetic`, commanderConcurrency);
assertCondition(String(activity.activeQueueIdsNote ?? "").includes("zero local queue ids does not mean zero active runners"), `${label} activity note should prevent zero-active misread`, activity);
assertCondition(String(activity.interpretation ?? "").includes("continue supervision"), `${label} activity interpretation should keep supervision action`, activity);
}
@@ -256,6 +267,7 @@ export function runCodeQueueQueuesShapeContract(): JsonRecord {
"full explicit limit remains bounded and paged",
"offset pagination",
"split-brain live activity counts distinguish scheduler-local queues, DB running tasks, and heartbeat-fresh runners",
"commander concurrency block names the active runner count and 15-concurrency rule",
],
};
}
@@ -255,6 +255,7 @@ export function runCodeQueueSupervisorDisclosureContract(): JsonRecord {
const omittedCounts = asRecord(listBudget.omittedCounts);
const splitBrainLiveView = asRecord(asRecord(splitBrainLive).supervisor);
const splitBrainLiveActivity = asRecord(splitBrainLiveView.activity);
const splitBrainLiveConcurrency = asRecord(splitBrainLiveView.commanderConcurrency);
const splitBrainLiveCounts = asRecord(splitBrainLiveView.counts);
assertCondition(supervisorBody.length < fullBody.length * 0.55, "supervisor output should be materially smaller than full output", { supervisorChars: supervisorBody.length, fullChars: fullBody.length });
@@ -294,6 +295,7 @@ export function runCodeQueueSupervisorDisclosureContract(): JsonRecord {
assertCondition(asArray(unreadFilteredSection.items).length <= 3, "unread list should be locally paged below --limit", unreadFilteredSection);
assertCondition(unreadFilteredBody.length < 14_000, "unread output should remain bounded", { chars: unreadFilteredBody.length });
assertCondition(splitBrainLiveCounts.running === 8, "split-brain supervisor should preserve DB running task count", splitBrainLiveCounts);
assertCondition(splitBrainLiveCounts.commanderActiveRunnerCount === 8, "split-brain supervisor should mirror commander active count in counts", splitBrainLiveCounts);
assertCondition(splitBrainLiveCounts.effectiveActive === 8, "split-brain supervisor should foreground effective active count", splitBrainLiveCounts);
assertCondition(splitBrainLiveCounts.databaseRunning === 8, "split-brain supervisor should distinguish database running tasks", splitBrainLiveCounts);
assertCondition(splitBrainLiveCounts.heartbeatFreshActive === 8, "split-brain supervisor should distinguish heartbeat-effective active runners", splitBrainLiveCounts);
@@ -305,6 +307,13 @@ export function runCodeQueueSupervisorDisclosureContract(): JsonRecord {
assertCondition(splitBrainLiveActivity.schedulerLocalActiveQueueCount === 0, "split-brain supervisor activity should expose scheduler-local queue count", splitBrainLiveActivity);
assertCondition(splitBrainLiveActivity.schedulerLocalActiveRunSlotCount === 0, "split-brain supervisor activity should expose scheduler-local slot count", splitBrainLiveActivity);
assertCondition(splitBrainLiveActivity.splitBrainLive === true, "split-brain supervisor activity should mark live split-brain", splitBrainLiveActivity);
assertCondition(splitBrainLiveActivity.splitBrainDisposition === "live-count-as-active", "split-brain supervisor activity should classify live split-brain as active capacity", splitBrainLiveActivity);
assertCondition(splitBrainLiveActivity.commanderConcurrency !== undefined, "split-brain supervisor activity should include commander concurrency guidance", splitBrainLiveActivity);
assertCondition(splitBrainLiveConcurrency.activeRunnerCount === 8, "split-brain supervisor should expose commander-facing active runner count", splitBrainLiveConcurrency);
assertCondition(splitBrainLiveConcurrency.activeRunnerCountField === "activity.effectiveActiveTaskCount", "split-brain supervisor should name the field to use", splitBrainLiveConcurrency);
assertCondition(splitBrainLiveConcurrency.splitBrainDisposition === "live-count-as-active", "split-brain supervisor should explain live split-brain disposition", splitBrainLiveConcurrency);
assertCondition(splitBrainLiveConcurrency.interventionRequired === false, "fresh split-brain supervisor should not require intervention", splitBrainLiveConcurrency);
assertCondition(String(splitBrainLiveConcurrency.decisionRule ?? "").includes("15 - activeRunnerCount"), "split-brain supervisor should give 15-concurrency arithmetic", splitBrainLiveConcurrency);
assertCondition(String(splitBrainLiveActivity.activeQueueIdsNote ?? "").includes("zero local queue ids does not mean zero active runners"), "split-brain supervisor activity should explain activeQueueIds are local-only", splitBrainLiveActivity);
assertCondition(String(splitBrainLiveActivity.interpretation ?? "").includes("continue supervision"), "split-brain supervisor activity should not imply scheduler stoppage", splitBrainLiveActivity);
@@ -320,6 +329,7 @@ export function runCodeQueueSupervisorDisclosureContract(): JsonRecord {
"drill-down commands preserved",
"full view remains detailed",
"split-brain live supervisor activity distinguishes scheduler-local, database, and heartbeat counts",
"commander concurrency block names the active runner count and 15-concurrency rule",
],
supervisorChars: supervisorBody.length,
fullChars: fullBody.length,
+55
View File
@@ -1359,6 +1359,12 @@ function compactCodeQueueActivity(
stringListCount(rawDiagnostics.heartbeatRiskTaskIds),
stringListCount(compactDiagnostics.heartbeatRiskTaskIds),
) ?? 0;
const staleRecoveryCandidateTaskCount = firstFiniteNumber(
rawLiveness.staleRecoveryCandidateTaskCount,
compactLiveness.staleRecoveryCandidateTaskCount,
stringListCount(rawDiagnostics.staleRecoveryCandidateTaskIds),
stringListCount(compactDiagnostics.staleRecoveryCandidateTaskIds),
) ?? 0;
const schedulerLocalActiveRunSlotCount = firstFiniteNumber(
rawDiagnostics.schedulerActiveRunSlotCount,
queue.schedulerActiveRunSlotCount,
@@ -1367,6 +1373,10 @@ function compactCodeQueueActivity(
);
const runnableQueueCount = firstFiniteNumber(options.runnableQueueCount, queue.runnableQueueCount);
const effectiveActiveTaskCount = Math.max(databaseActiveTaskCount, databaseRunningTaskCount, heartbeatFreshActiveTaskCount);
const executionState = asString(rawDiagnostics.state ?? compactDiagnostics.state);
const effectiveLiveness = asString(rawDiagnostics.effectiveLiveness ?? compactDiagnostics.effectiveLiveness ?? rawLiveness.effectiveLiveness ?? compactLiveness.effectiveLiveness);
const recommendedAction = asString(rawDiagnostics.recommendedAction ?? compactDiagnostics.recommendedAction ?? rawLiveness.recommendedAction ?? compactLiveness.recommendedAction);
const splitBrain = asBoolean(rawDiagnostics.splitBrain) || asBoolean(compactDiagnostics.splitBrain) || executionState === "split-brain";
const splitBrainLive = splitBrainLiveFromDiagnostics(rawDiagnostics) || splitBrainLiveFromDiagnostics(compactDiagnostics);
const effectiveActiveSource = heartbeatFreshActiveTaskCount > 0 && heartbeatFreshActiveTaskCount >= databaseActiveTaskCount
? "heartbeat-fresh"
@@ -1378,6 +1388,39 @@ function compactCodeQueueActivity(
const activeQueueIdsNote = schedulerLocalActiveQueueIds.length === 0 && effectiveActiveTaskCount > 0
? "activeQueueIds are scheduler-local only; zero local queue ids does not mean zero active runners when database or heartbeat counts are nonzero."
: "activeQueueIds are scheduler-local active-run slots; use effectiveActiveTaskCount for commander concurrency decisions.";
const recommendedActionIntervenes = recommendedAction.length > 0 && recommendedAction !== "continue-supervision";
const interventionRequired = heartbeatRiskTaskCount > 0 || staleRecoveryCandidateTaskCount > 0 || recommendedActionIntervenes || (splitBrain && !splitBrainLive);
const splitBrainDisposition = splitBrainLive
? "live-count-as-active"
: splitBrain
? "risk-investigate-before-new-work"
: "not-split-brain";
const splitBrainReason = splitBrainLive
? "database active/running tasks have fresh heartbeat evidence and no heartbeat-risk candidates in the compact summary."
: splitBrain
? "split-brain without fresh-heartbeat live evidence is risky; inspect heartbeat risk, stale recovery candidates, and raw diagnostics before changing capacity."
: "control-plane and execution-plane activity signals are not split-brain.";
const interventionReason = splitBrainLive
? "fresh heartbeat makes split-brain live; count these runners as active and continue supervision."
: heartbeatRiskTaskCount > 0
? "heartbeat risk is present; inspect before adding replacement work or recovering tasks."
: staleRecoveryCandidateTaskCount > 0
? "stale recovery candidates are present; follow the recovery runbook before changing concurrency."
: recommendedActionIntervenes
? `execution diagnostics recommend ${recommendedAction}; intervene before adding work.`
: splitBrain
? "split-brain is not proven live; inspect raw diagnostics before treating capacity as available."
: "no intervention signal in compact activity summary.";
const commanderConcurrency = {
activeRunnerCount: effectiveActiveTaskCount,
activeRunnerCountField: "activity.effectiveActiveTaskCount",
activeRunnerCountSource: effectiveActiveSource,
decisionRule: "subtract activeRunnerCount from the commander concurrency target; for a 15-runner policy, remaining slots = 15 - activeRunnerCount.",
splitBrainDisposition,
splitBrainReason,
interventionRequired,
interventionReason,
};
return {
effectiveActiveTaskCount,
effectiveActiveSource,
@@ -1386,10 +1429,16 @@ function compactCodeQueueActivity(
heartbeatFreshActiveTaskCount,
activeHeartbeatTaskCount,
heartbeatRiskTaskCount,
staleRecoveryCandidateTaskCount,
schedulerLocalActiveQueueCount: schedulerLocalActiveQueueIds.length,
schedulerLocalActiveRunSlotCount,
runnableQueueCount,
effectiveLiveness: effectiveLiveness || null,
recommendedAction: recommendedAction || null,
splitBrainLive,
splitBrainDisposition,
splitBrainReason,
commanderConcurrency,
activeQueueIdsScope: "scheduler-local-active-run-slots",
activeQueueIdsNote,
interpretation: splitBrainLive
@@ -2454,6 +2503,7 @@ function codexTasksOverviewResult(
const pagination = taskPage.pagination;
const diagnostics = supervisorExecutionDiagnostics(asRecord(taskPage.queue)?.executionDiagnostics);
const activity = compactCodeQueueActivity(asRecord(taskPage.queue) ?? {}, diagnostics);
const commanderConcurrency = asRecord(activity.commanderConcurrency) ?? {};
const visibleSupervisorItems = [...runningSection.items, ...unreadSection.items, ...recentSection.items, ...queuedSection.items];
const classifierCounts = visibleSupervisorItems.reduce((counts, item) => {
const key = item.kind;
@@ -2504,12 +2554,14 @@ function codexTasksOverviewResult(
completedUnread: unreadSection.count,
recentCompleted: recentSection.count,
queued: queuedSection.count,
commanderActiveRunnerCount: asNumber(commanderConcurrency.activeRunnerCount, 0),
effectiveActive: asNumber(activity.effectiveActiveTaskCount, 0),
databaseRunning: asNumber(activity.databaseRunningTaskCount, 0),
heartbeatFreshActive: asNumber(activity.heartbeatFreshActiveTaskCount, 0),
schedulerLocalActiveQueues: asNumber(activity.schedulerLocalActiveQueueCount, 0),
},
classifierCounts,
commanderConcurrency,
activity,
executionDiagnostics: diagnostics,
degraded,
@@ -2803,6 +2855,7 @@ function compactQueuesResponse(body: Record<string, unknown>, options: CodexQueu
const visible = selected.slice(options.offset, options.offset + options.limit);
const diagnostics = compactQueueExecutionDiagnostics(queue.executionDiagnostics);
const activity = compactCodeQueueActivity(queue, diagnostics, { schedulerLocalActiveQueueIds: activeIds, runnableQueueCount: runnableQueues.length });
const commanderConcurrency = asRecord(activity.commanderConcurrency) ?? {};
const activeTaskIds = boundedUniqueStringList(queue.activeTaskIds, Math.min(options.limit, maxTasksLimit));
const queuedTaskIds = boundedUniqueStringList(queue.queuedTaskIds, Math.min(options.limit, maxTasksLimit));
const nextOffset = options.offset + visible.length;
@@ -2832,6 +2885,7 @@ function compactQueuesResponse(body: Record<string, unknown>, options: CodexQueu
activeQueueCount: activeIds.length,
activeQueueCountScope: "scheduler-local-active-run-slots",
schedulerLocalActiveQueueCount: activeIds.length,
commanderActiveRunnerCount: commanderConcurrency.activeRunnerCount,
effectiveActiveTaskCount: activity.effectiveActiveTaskCount,
databaseRunningTaskCount: activity.databaseRunningTaskCount,
databaseActiveTaskCount: activity.databaseActiveTaskCount,
@@ -2840,6 +2894,7 @@ function compactQueuesResponse(body: Record<string, unknown>, options: CodexQueu
unreadQueueCount: unreadQueues.length,
runnableQueueCount: runnableQueues.length,
},
commanderConcurrency,
activity,
activeQueueIds: queue.activeQueueIds ?? [],
activeQueueIdsScope: "scheduler-local-active-run-slots",
+1
View File
@@ -287,6 +287,7 @@ function codexHelp(): unknown {
activityFields: {
path: "data.queues.activity and data.supervisor.activity",
effectiveActiveTaskCount: "Commander-facing active count derived from database active/running tasks and heartbeat-fresh runners.",
commanderConcurrency: "Use data.supervisor.commanderConcurrency.activeRunnerCount or data.queues.commanderConcurrency.activeRunnerCount for concurrency decisions; the block states the 15-runner arithmetic and intervention signal.",
schedulerLocalActiveQueueCount: "Only queues currently visible in this scheduler-local active-run slot view; zero does not override DB or heartbeat activity.",
heartbeatFreshActiveTaskCount: "Heartbeat-effective active runner count used to avoid split-brain zero-active mistakes.",
},