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

fix: skip goal fidelity checks for swarm coordinators

[._.]/ Adam Eivy74a6da6a6ed9
diff --git a/server/services/agentFinalization.goalFidelity.test.js b/server/services/agentFinalization.goalFidelity.test.js
index 91e6371ff6..b84ed95a6d 100644
--- a/server/services/agentFinalization.goalFidelity.test.js
+++ b/server/services/agentFinalization.goalFidelity.test.js
@@ -175,7 +175,7 @@ beforeEach(() => {
vi.clearAllMocks();
getTaskOutputHook.mockResolvedValue(null);
isProgrammaticIoTaskType.mockReturnValue(false);
- resolveTaskHookType.mockReturnValue(null);
+ resolveTaskHookType.mockImplementation(task => task?.metadata?.analysisType || task?.metadata?.taskAnalysisType || task?.taskType || null);
resolveFailedTaskUpdate.mockImplementation(async (_task, analysis) => ({
status: 'pending',
metadata: { lastErrorCategory: analysis?.category || null },
@@ -195,6 +195,27 @@ describe('finalizeAgent — goal-fidelity gate', () => {
expect(args.backend).toBe('ollama');
});
+ it.each([
+ { swarmCount: 3, analysisType: 'claim-issue' },
+ { swarmCount: '3', analysisType: 'claim-issue-gitlab' },
+ { analysisType: 'branch-reconcile' },
+ ])('skips coordinator review before reading a diff or calling a model: %j', async metadata => {
+ runLocalGoalFidelityReviewMock.mockResolvedValue(verdict({ verdict: 'rethink' }));
+ await finalize({ task: { id: 'task-1', taskType: 'internal', description: 'Complete the batch', metadata } });
+ expect(completion()).toMatchObject({ success: true });
+ expect(completion().goalFidelity).toBeUndefined();
+ expect(runWindowDiffMock).not.toHaveBeenCalled();
+ expect(runLocalGoalFidelityReviewMock).not.toHaveBeenCalled();
+ expect(cosEvents.emit).not.toHaveBeenCalledWith(GOAL_FIDELITY_HOLD_EVENT, expect.anything());
+ expect(updateTaskMock).toHaveBeenCalledWith('task-1', expect.objectContaining({ status: 'completed' }), 'internal');
+ });
+
+ it.each([0, 1, undefined])('still judges single-issue claims with swarmCount %s', async swarmCount => {
+ await finalize({ task: { id: 'task-1', description: 'Fix the uploader', metadata: { analysisType: 'claim-issue', swarmCount } } });
+ expect(runLocalGoalFidelityReviewMock).toHaveBeenCalledOnce();
+ expect(completion().goalFidelity).toMatchObject({ verdict: 'ship' });
+ });
+
it('records a passing verdict without disturbing the run — absence is what means "never judged"', async () => {
await finalize();
const result = completion();
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.js
index 0e6aafb3f2..e4165005a5 100644
--- a/server/services/agentFinalization.js
+++ b/server/services/agentFinalization.js
@@ -520,6 +520,12 @@ function prVerificationAnalysis(verdict) {
async function evaluateGoalFidelity({ task, workspacePath, startedAt }) {
const none = (error = null) => ({ verdict: null, review: null, error });
if (!workspacePath || !task?.id) return none();
+ // A coordinator's run-window diff cannot represent work delegated across
+ // worker branches. Judge individual tasks, not the aggregate swarm objective.
+ // Stored Markdown metadata may carry numeric values as strings.
+ const workers = Number(task.metadata?.swarmCount);
+ if ((Number.isSafeInteger(workers) && workers > 1)
+ || resolveTaskHookType(task) === 'branch-reconcile') return none();
const objective = taskObjective(task);
if (!objective) return none();
const config = await getGoalFidelityConfig().catch(() => null);