Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions src/lib/cloister/deacon-swarm-finalization.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/lib/cloister/deacon-swarm-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type { resolveAutomaticSwarmPolicy } from '../swarm-policy.js';
import type { PersistedTaskOperation } from '../xbrief/dag.js';
import type { XBriefDocument, XBriefItem } from '../xbrief/types.js';
import type { FeatureWorkspace } from './deacon-workspaces.js';
import type { RequestIssueReviewResult } from './deacon-swarm-finalization.js';
import type {
clearSwarmCompletionObservationRecord,
readSwarmCompletionObservation,
Expand Down Expand Up @@ -84,8 +83,6 @@ export interface CoordinateSwarmSlotsDeps {
readSlotCompletion?: (workspacePath: string, issueId: string, slotIndex: number) => PanIssueSwarmSlotCompletion | undefined;
/** Delete a stale durable marker that does not belong to the active item. */
clearSlotCompletion?: (workspacePath: string, issueId: string, slotIndex: number) => Promise<void>;
getFinalizedAt: (issueId: string, workspacePath: string) => string | undefined;
setFinalizedAt: (issueId: string, workspacePath: string, finalizedAt: string) => void;
/** Re-evaluated immediately before every slot spawn. */
shouldDispatch?: (issueId: string) => boolean;
readSwarmHold?: typeof readSwarmHold;
Expand All @@ -103,8 +100,6 @@ export interface CoordinateSwarmSlotsDeps {
resolveAutomaticSwarmPolicy?: typeof resolveAutomaticSwarmPolicy;
getReleasedSlotBranch?: (issueId: string, workspacePath: string, slotIndex: number) => string | undefined;
clearReleasedSlot?: (workspacePath: string, issueId: string, slotIndex: number) => Promise<void>;
/** Request issue-level review after the feature branch contains every item. */
requestIssueReview: (issueId: string, workspacePath: string) => Promise<RequestIssueReviewResult>;
}

export interface SlotAssignment {
Expand Down
27 changes: 4 additions & 23 deletions src/lib/cloister/deacon-swarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ import type { CoordinateSwarmSlotsDeps } from './deacon-swarm-types.js';
export type { CoordinateSwarmSlotsDeps } from './deacon-swarm-types.js';
import { gcMergedSlots, reapMergedSlotAgent } from './deacon-swarm-gc.js';
import { gcMergedSlotsAndAdvance } from './deacon-swarm-advance.js';
import { defaultRequestIssueReview, finalizeSwarmIssueIfComplete } from './deacon-swarm-finalization.js';
import { clearReleasedBlockedSwarmSlot, clearSwarmSlotCompletion, clearSwarmSlotOwnership, createMinimalIssueRecord, readSwarmHold, writeSwarmFinalizedAt, writeSwarmForemanTakeover } from './deacon-swarm-record.js';
import { clearReleasedBlockedSwarmSlot, clearSwarmSlotCompletion, clearSwarmSlotOwnership, createMinimalIssueRecord, readSwarmHold, writeSwarmForemanTakeover } from './deacon-swarm-record.js';
import { fireTieredCommitHooks } from './swarm-tiered-hooks.js';
import { applySupersededSlotHighWater, archiveFailedSwarmSlot, requeueFailedSwarmSlots } from './swarm-failed-slot.js';
import { archiveBlockedSwarmSlot, defaultIsSlotBranchPushed, prepareReleasedSwarmSlot, releaseBlockedSlots } from './swarm-blocked-slot.js';
Expand Down Expand Up @@ -157,13 +156,10 @@ const defaultDeps: CoordinateSwarmSlotsDeps = {
readStatusOverrides: defaultReadStatusOverrides,
readSlotCompletion: defaultReadSlotCompletion,
clearSlotCompletion: clearSwarmSlotCompletion,
getFinalizedAt: getSwarmFinalizedAt,
setFinalizedAt: recordSwarmFinalizedAt,
recordForemanTakeover: writeSwarmForemanTakeover,
ensureSwarmForeman,
sendStallEvent: (agentId, message) => messageAgent(agentId, message, 'deacon:swarm-stall'),
resolveAutomaticSwarmPolicy,
requestIssueReview: defaultRequestIssueReview,
};

function defaultGetMaxSlotIndex(): number {
Expand Down Expand Up @@ -309,10 +305,7 @@ export async function coordinateSwarmSlots(
if (!dispatchEligible) {
const hasSlotState = reconciled.merged.length > 0 || reconciled.inFlight.length > 0
|| reconciled.branches.length > 0 || reconciled.agents.length > 0;
if (!hasSlotState) {
actions.push(...await finalizeSwarmIssueIfComplete(issueId, workspace.workspacePath, doc, deps));
continue;
}
if (!hasSlotState) continue;
actions.push(`[swarm] considered ${issueId}: endgame (merge/cleanup only)`);
}
actions.push(...await releaseBlockedSlots(issueId, workspace.workspacePath, doc, reconciled, deps));
Expand All @@ -329,12 +322,8 @@ export async function coordinateSwarmSlots(
actions.push(...requeue.actions);
actions.push(...await mergeReadySlots(issueId, workspace.workspacePath, doc, classified, deps, blockedSlotIndexes));
actions.push(...await gcMergedSlotsAndAdvance(issueId, workspace.workspacePath, reconciled, deps, async () => {
const finalized = await finalizeSwarmIssueIfComplete(issueId, workspace.workspacePath, spec.document, deps);
if (!dispatchEligible) return finalized;
return [
...finalized,
...await dispatchNextWave(issueId, workspace.workspacePath, requeue.doc, reconciled, analyzeSwarmReadiness(requeue.doc), deps, blockedSlotIndexes, blockedItemIds),
];
if (!dispatchEligible) return [];
return dispatchNextWave(issueId, workspace.workspacePath, requeue.doc, reconciled, analyzeSwarmReadiness(requeue.doc), deps, blockedSlotIndexes, blockedItemIds);
}));
recordSwarmAdvanceSuccess(issueId);
} catch (err) {
Expand Down Expand Up @@ -671,14 +660,6 @@ export function getFailedMergeBlocks(issueId: string, workspacePath?: string): F
return [...bySlot.values()].sort((a, b) => a.slotIndex - b.slotIndex);
}

export function getSwarmFinalizedAt(issueId: string, workspacePath?: string): string | undefined {
return workspacePath ? readIssueRecordForWorkspaceSync(workspacePath, issueId.toUpperCase())?.swarm?.finalizedAt : undefined;
}

export async function recordSwarmFinalizedAt(issueId: string, workspacePath: string, finalizedAt: string): Promise<void> {
await writeSwarmFinalizedAt(workspacePath, issueId.toUpperCase(), finalizedAt);
}

export async function recordFailedMergeBlock(block: FailedMergeBlock, workspacePath?: string): Promise<void> {
const normalizedBlock = { ...block, issueId: block.issueId.toUpperCase() };
failedMergeBlocks.set(`${normalizedBlock.issueId}:${normalizedBlock.slotIndex}`, normalizedBlock);
Expand Down
Loading