test(FN-5003): assert noop audit emission in merge recovery

Fusion-Task-Id: FN-5003
Fusion-Task-Lineage: c5f1f326-934b-4cfc-8ba9-a2ac70a4f4f4
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 22:35:13 -07:00
committed by gsxdsm
parent 18e827dc81
commit a61dfd3f5d
2 changed files with 36 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ type MockTaskStore = {
logEntry: ReturnType<typeof vi.fn>;
getActiveMergingTask: ReturnType<typeof vi.fn>;
createTask: ReturnType<typeof vi.fn>;
recordRunAuditEvent: ReturnType<typeof vi.fn>;
on: ReturnType<typeof vi.fn>;
off: ReturnType<typeof vi.fn>;
};
@@ -129,6 +130,7 @@ function makeStore({
id: "FN-9999",
description: input.description,
})),
recordRunAuditEvent: vi.fn(async () => undefined),
on: vi.fn(),
off: vi.fn(),
};
@@ -765,6 +767,17 @@ describe("ProjectEngine merge error recovery", () => {
expect.stringContaining("[verification] post-finalize verification failed for already-on-main fast-path; no action"),
"VerificationError",
);
expect(store.recordRunAuditEvent).toHaveBeenCalledWith(expect.objectContaining({
domain: "database",
mutationType: "task:post-finalize-verification-no-op",
target: TASK_ID,
metadata: expect.objectContaining({
taskId: TASK_ID,
commitSha: "abcdef1234567890",
failedCommand: null,
exitCode: null,
}),
}));
});
it("moves task back to in-progress with merge-remediation status on verification errors", async () => {

View File

@@ -1573,10 +1573,33 @@ export class ProjectEngine {
const shortSha = typeof commitSha === "string" && commitSha.length > 0
? commitSha.slice(0, 8)
: "unknown";
const failedCommand = err instanceof VerificationError
? err.verificationResult?.testResult?.command ?? err.verificationResult?.buildResult?.command ?? null
: null;
const exitCode = err instanceof VerificationError
? err.verificationResult?.testResult?.exitCode ?? err.verificationResult?.buildResult?.exitCode ?? null
: null;
const errorTail = errorMsg.length > 200 ? `${errorMsg.slice(0, 200)}` : errorMsg;
const message = `[verification] post-finalize verification failed for already-on-main fast-path; no action (commit=${shortSha}, error=${errorTail})`;
await store.logEntry(taskId, message, "VerificationError").catch(() => undefined);
runtimeLog.log(`Auto-merge: ${taskId} ${message}`);
const auditor = createRunAuditor(store, {
runId: generateSyntheticRunId("auto-merge", taskId),
agentId: "auto-merge",
taskId,
phase: "merge",
});
await auditor.database({
type: "task:post-finalize-verification-no-op",
target: taskId,
metadata: {
taskId,
commitSha,
failedCommand,
exitCode,
errorTail,
},
}).catch(() => undefined);
continue;
}