FN-6050: stop re-emitting existing mission advisories

Treat previously recorded unlinked-mission advisories as authoritative across insight states.

- remove the generated-only insight filter when checking for an existing unlinked mission advisory
- suppress duplicate advisories even when the existing insight is dismissed, archived, or confirmed
- expand reporter coverage to assert the broader duplicate-detection behavior and insight query shape

Files changed:
 .../unlinked-missions-advisory-reporter.test.ts    | 49 +++++++++++++---------
 .../src/unlinked-missions-advisory-reporter.ts     |  1 -
 2 files changed, 29 insertions(+), 21 deletions(-)

Fusion-Task-Id: FN-6050

Fusion-Task-Lineage: 5b9274f7-baf6-40c1-8a88-2fcc86c7ef14
This commit is contained in:
gsxdsm
2026-06-09 03:53:34 -07:00
parent 7c2d3f5f7a
commit df74a6b752
2 changed files with 28 additions and 20 deletions

View File

@@ -131,26 +131,35 @@ describe("UnlinkedMissionsAdvisoryReporter", () => {
expect(content.missionIds).toEqual(["M-UNLINKED-A", "M-UNLINKED-B"]);
});
it("does not emit a second advisory when an existing advisory insight already exists", async () => {
const insightStore = {
upsertInsight: vi.fn(),
listInsights: vi.fn().mockReturnValue([
{
title: UNLINKED_MISSIONS_ADVISORY_TITLE,
updatedAt: "2026-06-03T12:00:00.000Z",
provenance: { metadata: { advisoryKey: UNLINKED_MISSIONS_ADVISORY_KEY } },
},
]),
};
const store = createStore({
missions: [createMission({ id: "M-UNLINKED" })],
insightStore,
});
const reporter = new UnlinkedMissionsAdvisoryReporter({ store, projectId: "/tmp/project", logger });
it.each(["generated", "dismissed", "archived", "confirmed"] as const)(
"does not emit a second advisory when an existing %s advisory insight already exists",
async (status) => {
const insightStore = {
upsertInsight: vi.fn(),
listInsights: vi.fn().mockReturnValue([
{
title: UNLINKED_MISSIONS_ADVISORY_TITLE,
status,
updatedAt: "2026-06-03T12:00:00.000Z",
provenance: { metadata: { advisoryKey: UNLINKED_MISSIONS_ADVISORY_KEY } },
},
]),
};
const store = createStore({
missions: [createMission({ id: "M-UNLINKED" })],
insightStore,
});
const reporter = new UnlinkedMissionsAdvisoryReporter({ store, projectId: "/tmp/project", logger });
await expect(reporter.report()).resolves.toEqual({ alerted: false, reason: "already-reported" });
expect(insightStore.upsertInsight).not.toHaveBeenCalled();
});
await expect(reporter.report()).resolves.toEqual({ alerted: false, reason: "already-reported" });
expect(insightStore.listInsights).toHaveBeenCalledWith({
projectId: "/tmp/project",
category: "workflow",
limit: 10,
});
expect(insightStore.upsertInsight).not.toHaveBeenCalled();
},
);
it.each([
{ projectId: "", throwInsightStore: false },

View File

@@ -76,7 +76,6 @@ export class UnlinkedMissionsAdvisoryReporter {
const existingInsights = insightStore.listInsights({
projectId: this.projectId,
category: "workflow",
status: "generated",
limit: 10,
});
const existing = existingInsights.find(