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

test([issue-13265]): verify delivery fields across finalization contracts

[._.]/ Adam Eivyd54f20daf926
diff --git a/server/services/agentFinalization.goalFidelity.test.js b/server/services/agentFinalization.goalFidelity.test.js
index 59a3be7d8d..967a491ec1 100644
--- a/server/services/agentFinalization.goalFidelity.test.js
+++ b/server/services/agentFinalization.goalFidelity.test.js
@@ -141,8 +141,8 @@ describe('finalizeAgent — private report delivery', () => {
getTaskOutputHook.mockResolvedValue(async () => ({ accepted: true, reportId: 'report-example' }));
expect(await finishPrivate()).toMatchObject({ success: true });
expect(completion()).toMatchObject({ success: true, validationPassed: true });
- expect(updateTaskMock).toHaveBeenCalledWith('private-task', { status: 'completed' }, 'internal');
- expect(completeAgentRun).toHaveBeenCalledWith('private-run', 'Private security assessment: see the local Review Hub report.', 0, 1000, null, null);
+ expect(updateTaskMock).toHaveBeenCalledWith('private-task', expect.objectContaining({ status: 'completed' }), 'internal');
+ expect(completeAgentRun).toHaveBeenCalledWith('private-run', 'Private security assessment: see the local Review Hub report.', 0, 1000, null, null, expect.objectContaining({ executionSuccess: true }));
expect(runLocalGoalFidelityReviewMock).not.toHaveBeenCalled();
});
@@ -155,8 +155,8 @@ describe('finalizeAgent — private report delivery', () => {
getTaskOutputHook.mockResolvedValue(hook);
expect(await finishPrivate()).toMatchObject({ success: false });
expect(completion()).toMatchObject({ success: false, validationPassed: false });
- expect(updateTaskMock).toHaveBeenCalledWith('private-task', { status: 'blocked' }, 'internal');
- expect(completeAgentRun).toHaveBeenCalledWith('private-run', 'Private security assessment report was not verified; inspect the local assessment archive.', 0, 1000, expect.any(Object), false);
+ expect(updateTaskMock).toHaveBeenCalledWith('private-task', expect.objectContaining({ status: 'blocked' }), 'internal');
+ expect(completeAgentRun).toHaveBeenCalledWith('private-run', 'Private security assessment report was not verified; inspect the local assessment archive.', 0, 1000, expect.any(Object), false, expect.objectContaining({ executionSuccess: true }));
});
it('fails closed when report delivery outlives the completion timeout', async () => {
@@ -167,7 +167,7 @@ describe('finalizeAgent — private report delivery', () => {
const finished = finishPrivate();
await vi.advanceTimersByTimeAsync(5 * 60_000);
expect(await finished).toMatchObject({ success: false });
- expect(updateTaskMock).toHaveBeenCalledWith('private-task', { status: 'blocked' }, 'internal');
+ expect(updateTaskMock).toHaveBeenCalledWith('private-task', expect.objectContaining({ status: 'blocked' }), 'internal');
expect(completeAgentRun.mock.calls[0][5]).toBe(false);
settle({ accepted: true, reportId: 'late-report' });
await vi.advanceTimersByTimeAsync(0);
@@ -361,7 +361,7 @@ describe('finalizeAgent — goal-fidelity gate', () => {
expect(emitLog).not.toHaveBeenCalledWith('warn', expect.stringContaining('not judgeable from a diff'), expect.anything());
expect(cosEvents.emit).not.toHaveBeenCalledWith(GOAL_FIDELITY_HOLD_EVENT, expect.anything());
expect(runGoalFidelityFollowUpMock).not.toHaveBeenCalled();
- expect(updateTaskMock).toHaveBeenCalledWith(task.id, { status: 'completed' }, 'internal');
+ expect(updateTaskMock).toHaveBeenCalledWith(task.id, expect.objectContaining({ status: 'completed' }), 'internal');
});
it.each([
@@ -530,7 +530,7 @@ describe('finalizeAgent — goal-fidelity gate', () => {
const finalized = await finalize({ runId: 'fidelity-held-run', prExpected: true });
expect(finalized).toMatchObject({ success: false, cleanupEvidence: { ok: true } });
expect(completeAgentRun).toHaveBeenCalledWith('fidelity-held-run', 'done', 0, 1000,
- expect.objectContaining({ category: GOAL_FIDELITY_CATEGORY }), false);
+ expect.objectContaining({ category: GOAL_FIDELITY_CATEGORY }), false, expect.objectContaining({ executionSuccess: true }));
const result = completion();
expect(result.success).toBe(false);
@@ -547,7 +547,7 @@ describe('finalizeAgent — goal-fidelity gate', () => {
});
it('preserves a drift diagnosis over a missing PR and skips fidelity', async () => {
- getAgentRecord.mockResolvedValueOnce({ metadata: { primaryCheckoutBaseline: {} } });
+ getAgentRecord.mockResolvedValue({ metadata: { primaryCheckoutBaseline: {} } });
detectPrimaryCheckoutDrift.mockResolvedValueOnce({
drifted: true, category: 'primary-checkout-mutated', message: 'Primary checkout changed',
});
@@ -575,7 +575,7 @@ describe('finalizeAgent — goal-fidelity gate', () => {
completionReason: terminatedByUser ? 'user-terminated' : 'failed',
});
expect(finished).toMatchObject({ success: false, cleanupEvidence: { ok: true } });
- expect(completeAgentRun).toHaveBeenCalledWith('failed-run', 'done', 0, 1000, analysis, false);
+ expect(completeAgentRun).toHaveBeenCalledWith('failed-run', 'done', 0, 1000, analysis, false, expect.objectContaining({ executionSuccess: false }));
expect(completion()).toMatchObject({
success: false, completionReason: terminatedByUser ? 'user-terminated' : 'failed',
});
diff --git a/server/services/agentFinalization.prVerification.test.js b/server/services/agentFinalization.prVerification.test.js
index 766c045d0b..dd1679113b 100644
--- a/server/services/agentFinalization.prVerification.test.js
+++ b/server/services/agentFinalization.prVerification.test.js
@@ -616,13 +616,13 @@ describe('finalizeAgent — a PR-shaped run with no PR is not a success (#3358)'
await finalize({ runId: 'run-1' });
// 6th arg is the explicit success override — without it the run history
// would keep reporting success off `exitCode === 0`.
- expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, expect.anything(), false);
+ expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, expect.anything(), false, expect.objectContaining({ executionSuccess: true }));
});
it('leaves the run record alone when the PR is confirmed', async () => {
onBranch('claim/issue-1');
await finalize({ runId: 'run-1' });
- expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, null, null);
+ expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, null, null, expect.objectContaining({ executionSuccess: true }));
});
it('records forge-unreachable (not a generic failure) when gh cannot be reached', async () => {
diff --git a/server/services/agentFinalization.primaryCheckoutDrift.test.js b/server/services/agentFinalization.primaryCheckoutDrift.test.js
index e4bd53078e..5cecae2f56 100644
--- a/server/services/agentFinalization.primaryCheckoutDrift.test.js
+++ b/server/services/agentFinalization.primaryCheckoutDrift.test.js
@@ -178,14 +178,14 @@ describe('finalizeAgent — a worktree run that mutated the primary is not a suc
it('marks the RUN record failed too, even though the process exited 0', async () => {
detectPrimaryCheckoutDriftMock.mockResolvedValue(DRIFT);
await finalize({ runId: 'run-1' });
- expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, expect.anything(), false);
+ expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, expect.anything(), false, expect.objectContaining({ executionSuccess: true }));
});
it('leaves an undrifted run completely unaffected', async () => {
await finalize({ runId: 'run-1' });
expect(completeAgentMock).toHaveBeenCalledWith('agent-1', expect.objectContaining({ success: true }));
expect(updateTaskMock).toHaveBeenCalledWith('task-1', expect.objectContaining({ status: 'completed' }), 'internal');
- expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, null, null);
+ expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, null, null, expect.objectContaining({ executionSuccess: true }));
});
it('does not overwrite the diagnosis of a run that already failed', async () => {
@@ -224,7 +224,7 @@ describe('finalizeAgent — a worktree run that mutated the primary is not a suc
expect(completeAgentMock).toHaveBeenCalledWith('agent-1', expect.objectContaining({ success: true }));
expect(updateTaskMock).toHaveBeenCalledWith('task-1', expect.objectContaining({ status: 'completed' }), 'internal');
// The run record is a clean success — no error analysis, not force-failed.
- expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, null, null);
+ expect(completeAgentRunMock).toHaveBeenCalledWith('run-1', 'done', 0, 1000, null, null, expect.objectContaining({ executionSuccess: true }));
// ...but the unreviewed commits are still surfaced.
expect(emitLog).toHaveBeenCalledWith('warn', expect.stringContaining('not attributable to agent-1'), expect.anything());
});