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

raise a notification card when a catalog refresh retires a pinned model (#7332)

[._.]/ Adam Eivyf9a0269c4aa3
diff --git a/server/services/modelPinAudit.js b/server/services/modelPinAudit.js
index 36f98419c2..0e28deeda0 100644
--- a/server/services/modelPinAudit.js
+++ b/server/services/modelPinAudit.js
@@ -50,9 +50,11 @@ import { getSettings, updateSettingsWith } from './settings.js';
* mock unless they share a single in-flight promise.
*/
let appsModule = null;
+let notificationsModule = null;
let providersModule = null;
let taskScheduleModule = null;
const loadAppsModule = () => (appsModule ||= import('./apps.js'));
+const loadNotificationsModule = () => (notificationsModule ||= import('./notifications.js'));
const loadProvidersModule = () => (providersModule ||= import('./providers.js'));
const loadTaskScheduleModule = () => (taskScheduleModule ||= import('./taskSchedule.js'));
@@ -307,13 +309,21 @@ const withoutKey = (parent, key) => {
* stored resolves to `{ cleared: false }` rather than throwing — the pin is
* already gone, which is the outcome the caller wanted.
*
+ * The retired-pin notification card (#7332) is retracted either way: a card
+ * naming a pin that is no longer stored is a loop the user cannot close, and
+ * `cleared: false` means the pin is already gone, not that the card is still
+ * earned. Retraction must never fail the clear the user actually asked for.
+ *
* @param {string} pinId
* @returns {Promise<{cleared: boolean, id: string}>}
*/
export async function clearModelPin(pinId) {
const pins = await collectModelPins();
const pin = pins.find((candidate) => candidate.id === pinId);
- if (!pin) return { cleared: false, id: pinId };
- await PIN_SOURCES.find((source) => source.kind === pin.kind).clear(pin);
- return { cleared: true, id: pinId };
+ if (pin) await PIN_SOURCES.find((source) => source.kind === pin.kind).clear(pin);
+ const { removeByMetadata } = await loadNotificationsModule();
+ await removeByMetadata('pinId', pinId).catch((error) => {
+ console.error(`❌ Retracting retired-pin notification for ${pinId} failed: ${error.message}`);
+ });
+ return { cleared: Boolean(pin), id: pinId };
}
diff --git a/server/services/modelPinAudit.test.js b/server/services/modelPinAudit.test.js
index d37f402e62..51ff54a8c1 100644
--- a/server/services/modelPinAudit.test.js
+++ b/server/services/modelPinAudit.test.js
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
vi.mock('./providers.js', () => ({ listProviders: vi.fn() }));
+vi.mock('./notifications.js', () => ({ removeByMetadata: vi.fn() }));
vi.mock('./settings.js', () => ({ getSettings: vi.fn(), updateSettingsWith: vi.fn() }));
vi.mock('./taskSchedule.js', () => ({ loadSchedule: vi.fn(), updateTaskInterval: vi.fn() }));
vi.mock('./apps.js', () => ({
@@ -9,6 +10,7 @@ vi.mock('./apps.js', () => ({
}));
const { listProviders } = await import('./providers.js');
+const { removeByMetadata } = await import('./notifications.js');
const { getSettings, updateSettingsWith } = await import('./settings.js');
const { loadSchedule, updateTaskInterval } = await import('./taskSchedule.js');
const { getActiveApps, updateAppTaskTypeOverride } = await import('./apps.js');
@@ -34,6 +36,7 @@ beforeEach(() => {
getSettings.mockResolvedValue(settingsWith({}));
loadSchedule.mockResolvedValue({ tasks: {} });
getActiveApps.mockResolvedValue([]);
+ removeByMetadata.mockResolvedValue({ success: true, removed: 0 });
});
describe('image-gen pin coverage', () => {
@@ -189,6 +192,35 @@ describe('clearModelPin', () => {
expect(updateAppTaskTypeOverride).toHaveBeenCalledWith('app-1', 'audit', { model: null });
});
+ it('retracts the pin\'s notification card (#7332)', async () => {
+ getSettings.mockResolvedValue(settingsWith({
+ imageGen: { agy: { enabled: true, model: 'gemini-3.5-flash-low' } },
+ }));
+ await clearModelPin('settings:imageGen.agy.model');
+ expect(removeByMetadata).toHaveBeenCalledWith('pinId', 'settings:imageGen.agy.model');
+ });
+
+ it('retracts the card even for an id that names no stored pin', async () => {
+ // The pin is already gone, so the card is a loop the user cannot close by
+ // any other means — leaving it up is the failure, not the retraction.
+ await clearModelPin('settings:imageGen.agy.model');
+ expect(removeByMetadata).toHaveBeenCalledWith('pinId', 'settings:imageGen.agy.model');
+ });
+
+ it('still reports the clear when retracting the card fails', async () => {
+ const errored = vi.spyOn(console, 'error').mockImplementation(() => {});
+ getSettings.mockResolvedValue(settingsWith({
+ imageGen: { agy: { enabled: true, model: 'gemini-3.5-flash-low' } },
+ }));
+ removeByMetadata.mockRejectedValueOnce(new Error('notifications.json unwritable'));
+
+ await expect(clearModelPin('settings:imageGen.agy.model')).resolves.toEqual({
+ cleared: true, id: 'settings:imageGen.agy.model',
+ });
+ expect(errored.mock.calls[0][0]).toContain('notifications.json unwritable');
+ errored.mockRestore();
+ });
+
it('reaches no writer for an id that names no collected pin', async () => {
// The re-collect is a write-target ALLOWLIST, not just a freshness check:
// the route bounds `pinId` to a string and nothing more, and
diff --git a/server/services/modelPinAuditNotifier.js b/server/services/modelPinAuditNotifier.js
index e107e9720d..6de8730c89 100644
--- a/server/services/modelPinAuditNotifier.js
+++ b/server/services/modelPinAuditNotifier.js
@@ -1,35 +1,32 @@
/**
- * Announce a retired model pin at the moment it becomes observable (#7328).
+ * Announce a retired model pin at the moment it becomes observable (#7332).
*
* `modelPinAudit.js` derives the stale set on READ, which is the right rule —
* it catches pins that rotted before it shipped and needs nothing persisted.
* What derive-on-read cannot do is tell anybody: without this, a pin stays
- * quietly broken until the user happens to open Settings → Providers.
+ * quietly broken until the user happens to open Settings → Providers. On a
+ * single-user PM2 install a `console.log` reaches nobody either, so the
+ * announcement is a notification CARD, with the log line kept beside it as the
+ * operator trail.
*
* A catalog refresh is that moment, so this runs from the toolkit's
- * `onProvidersSaved` host extension point (wired in `bootstrap.js`) and logs.
- * It is a TRIGGER for the existing audit, never a second source of truth: no
- * membership rule lives here, no stale set is persisted, and nothing is written
- * inside `server/lib/aiToolkit/` (its AGENTS.md forbids that).
+ * `onProvidersSaved` host extension point (wired in `bootstrap.js`). It is a
+ * TRIGGER for the existing audit, never a second source of truth: no membership
+ * rule lives here, no stale set is persisted by this module, and nothing is
+ * written inside `server/lib/aiToolkit/` (its AGENTS.md forbids that).
*
- * **Transition only.** `providers.json` is written by a refresh, a legacy
- * `PATCH /api/providers/:id`, a migration and a boot seed alike, so an install
- * carrying one rotted pin would narrate on every one of them forever. The ids
- * reported last time are held in process memory and re-announced only when a
- * pin that was NOT stale then is stale now. Nothing is persisted — a restart
- * re-announcing once is the accepted cost of keeping this off disk and off the
- * federation layer.
- */
-
-/**
- * The pin ids reported by the last SUCCESSFUL audit.
+ * **The card IS the dedupe state.** `providers.json` is written by a refresh, a
+ * legacy `PATCH /api/providers/:id`, a migration and a boot seed alike, so an
+ * install carrying one rotted pin would narrate on every one of them forever.
+ * `notifications.exists(type, 'pinId', id)` answers "has this pin already been
+ * announced?" from the durable record itself — so a restart cannot re-announce,
+ * which is exactly what an in-process transition set could not promise. The
+ * card is retracted when the pin is cleared (`modelPinAudit.clearModelPin`), so
+ * a pin that is re-created and rots again announces again.
*
- * Only a successful audit may replace this. A failed one that wrote an empty
- * set here would forget what it had already announced, so the next successful
- * audit would re-announce a pin the user was told about — the exact narration
- * loop this module exists to prevent.
+ * `data/notifications.json` is machine-local — nothing in `server/` federates
+ * it — so this raises no privacy or sync question.
*/
-let lastReportedStaleIds = new Set();
/**
* At most one audit runs, and at most one more is queued behind it.
@@ -40,7 +37,8 @@ let lastReportedStaleIds = new Set();
* and the graph's own projection write re-enters this hook from inside a pass
* it latches itself out of. Each of those saves would otherwise pay a full
* audit whose answer depends only on the FINAL state, so all but the last is
- * wasted. Coalescing bounds a burst of N writes at two audits.
+ * wasted. Coalescing bounds a burst of N writes at two audits. This is about
+ * write-latency alone — the announcement's own dedupe is the persisted card.
*
* A queued caller gets the in-flight promise. That cannot cycle back on itself:
* the audit only READS the pin stores, and never writes `providers.json`.
@@ -48,9 +46,14 @@ let lastReportedStaleIds = new Set();
let running = null;
let queued = false;
-/** Test seam: forget what was reported so the next audit announces again. */
-export function resetStaleModelPinReport() {
- lastReportedStaleIds = new Set();
+/**
+ * Test seam: drop the in-flight coalescing state between cases.
+ *
+ * Deliberately NOT a "forget what was announced" reset — there is no such state
+ * here. What was announced lives in `data/notifications.json`, which is why a
+ * restart stays silent.
+ */
+export function resetModelPinReportState() {
running = null;
queued = false;
}
@@ -63,22 +66,56 @@ export function resetStaleModelPinReport() {
* they share a single in-flight promise.
*/
let auditModule = null;
+let notificationsModule = null;
const loadAuditModule = () => (auditModule ||= import('./modelPinAudit.js'));
+const loadNotificationsModule = () => (notificationsModule ||= import('./notifications.js'));
+
+/**
+ * One card per pin, so each carries the pin's own `href`/`location` and can be
+ * retracted independently when that one pin is cleared. A single rolled-up card
+ * could do neither.
+ */
+async function announce(pin, provider) {
+ const { addNotification, exists, NOTIFICATION_TYPES, PRIORITY_LEVELS } =
+ await loadNotificationsModule();
+ // The persisted card is the dedupe record: already announced, still true.
+ if (await exists(NOTIFICATION_TYPES.AGENT_WARNING, 'pinId', pin.id)) return false;
+ const providerName = provider?.name || pin.providerId;
+ await addNotification({
+ type: NOTIFICATION_TYPES.AGENT_WARNING,
+ title: 'Pinned model retired',
+ description: `${pin.label} pins "${pin.model}", which ${providerName} no longer offers`
+ + ` — clear it in ${pin.location}.`,
+ priority: PRIORITY_LEVELS.MEDIUM,
+ link: pin.href || null,
+ metadata: { pinId: pin.id, kind: pin.kind, providerId: pin.providerId, model: pin.model },
+ });
+ return true;
+}
async function reportOnce() {
const { auditModelPins } = await loadAuditModule();
- const { pins } = await auditModelPins();
- const staleIds = new Set(pins.map((pin) => pin.id));
- // A pin that was already stale last time is not news. Only a pin that has
- // newly rotted earns a line, so the normal state (nothing stale, or the same
- // stale set as before) is silent.
- const newlyStale = [...staleIds].filter((id) => !lastReportedStaleIds.has(id));
- // Assign the full set, not just the new ids: a pin the user clears drops out
- // here, so rotting again later announces again.
- lastReportedStaleIds = staleIds;
- if (newlyStale.length === 0) return;
- console.log(`⚠️ ${newlyStale.length} of ${staleIds.size} stored model pin(s) now name a retired model`
- + ' — review Settings → Providers');
+ const { pins, providers } = await auditModelPins();
+ if (pins.length === 0) return;
+ // Sequential, not Promise.all: `addNotification` and `exists` share one file,
+ // and two concurrent announcements of the same pin would both miss the card
+ // the other is about to write.
+ //
+ // Each pin's announcement is independent, so one that fails must not take the
+ // rest of the run with it — a transient write error on the first pin would
+ // otherwise silently drop every pin behind it, and the coalescing guard means
+ // the next audit may be a whole burst away.
+ let announced = 0;
+ for (const pin of pins) {
+ const raised = await announce(pin, providers?.[pin.providerId]).catch((error) => {
+ console.error(`❌ Announcing retired model pin ${pin.id} failed: ${error.message}`);
+ return false;
+ });
+ if (raised) announced += 1;
+ }
+ if (announced === 0) return;
+ console.log(`⚠️ ${announced} of ${pins.length} stored model pin(s) now name a retired model`
+ + ' — see Notifications');
}
async function drain() {
@@ -86,8 +123,9 @@ async function drain() {
queued = false;
// The hook is non-fatal by contract: the `providers.json` write has already
// landed, and its callers include boot warmups and schedulers with no
- // Express `next(err)` to bubble to. Log and continue, leaving
- // `lastReportedStaleIds` untouched so the next audit still announces.
+ // Express `next(err)` to bubble to. A failed audit — or a failed
+ // notification write — must never fail the provider save; the next refresh
+ // re-derives the same stale set and announces whatever is still missing.
await reportOnce().catch((error) => {
console.error(`❌ Model pin audit after provider save failed: ${error.message}`);
});
@@ -96,7 +134,8 @@ async function drain() {
}
/**
- * Audit the stored model pins and log any that newly went stale. Never rejects.
+ * Audit the stored model pins and raise a card for any that newly went stale.
+ * Never rejects.
*
* @returns {Promise<void>}
*/
diff --git a/server/services/modelPinAuditNotifier.test.js b/server/services/modelPinAuditNotifier.test.js
index 6464544c81..21cf3b8d65 100644
--- a/server/services/modelPinAuditNotifier.test.js
+++ b/server/services/modelPinAuditNotifier.test.js
@@ -1,10 +1,12 @@
/**
- * Retired-pin announcement on a catalog refresh (#7328).
+ * Retired-pin announcement on a catalog refresh (#7332).
*
* The regressions these uniquely catch: an install with one rotted pin
- * re-narrating on every `providers.json` write (there is no other transition
- * tracker), a throwing audit turning a landed provider save into a failure, and
- * the bootstrap hook losing one of its two consumers when the other is edited.
+ * re-raising a card on every `providers.json` write (the persisted card is the
+ * only dedupe state — there is no in-process tracker to fall back on), a
+ * throwing audit or a failing notification write turning a landed provider save
+ * into a failure, and the bootstrap hook losing one of its two consumers when
+ * the other is edited.
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
@@ -14,20 +16,55 @@ import { dirname, join } from 'path';
import { stripCommentsAndNormalize } from '../lib/mirrorParity.js';
vi.mock('./modelPinAudit.js', () => ({ auditModelPins: vi.fn() }));
+vi.mock('./notifications.js', () => ({
+ addNotification: vi.fn(),
+ exists: vi.fn(),
+ NOTIFICATION_TYPES: { AGENT_WARNING: 'agent_warning' },
+ PRIORITY_LEVELS: { LOW: 'low', MEDIUM: 'medium', HIGH: 'high' },
+}));
const { auditModelPins } = await import('./modelPinAudit.js');
+const { addNotification, exists } = await import('./notifications.js');
const {
- reportRetiredModelPins, resetStaleModelPinReport,
+ reportRetiredModelPins, resetModelPinReportState,
} = await import('./modelPinAuditNotifier.js');
-const audited = (...ids) => ({ pins: ids.map((id) => ({ id })), providers: {} });
+const pin = (id, overrides = {}) => ({
+ id,
+ kind: 'imageGen',
+ providerId: 'antigravity-cli',
+ model: 'retired-model-1',
+ label: 'Agy CLI image model',
+ location: 'Settings → Media Gen → Image Gen',
+ href: '/media/image?settings=1',
+ ...overrides,
+});
+
+const audited = (...pins) => ({
+ pins,
+ providers: Object.fromEntries(pins.map((p) => [p.providerId, { id: p.providerId, name: 'Agy CLI' }])),
+});
+
+/**
+ * The persisted notification store, as the module sees it: `exists` answers
+ * from what `addNotification` has already written. Mocking the two independently
+ * would let the dedupe pass while the real round-trip is broken.
+ */
+function backNotificationsWithAStore() {
+ const cards = [];
+ exists.mockImplementation(async (type, field, value) =>
+ cards.some((card) => card.type === type && card.metadata?.[field] === value));
+ addNotification.mockImplementation(async (card) => { cards.push(card); return card; });
+ return cards;
+}
let logged;
let errored;
beforeEach(() => {
vi.clearAllMocks();
- resetStaleModelPinReport();
+ resetModelPinReportState();
+ backNotificationsWithAStore();
logged = vi.spyOn(console, 'log').mockImplementation(() => {});
errored = vi.spyOn(console, 'error').mockImplementation(() => {});
});
@@ -38,81 +75,137 @@ afterEach(() => {
});
describe('reportRetiredModelPins', () => {
- it('announces once, naming how many pins went stale', async () => {
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model', 'task:brain-sync'));
+ it('raises one card per stale pin, naming it and linking where it lives', async () => {
+ auditModelPins.mockResolvedValue(audited(
+ pin('settings:imageGen.agy.model'),
+ pin('task:brain-sync', {
+ kind: 'task', label: 'brain-sync task model', model: 'retired-model-2',
+ location: 'Chief of Staff → Schedule', href: '/cos/schedule',
+ }),
+ ));
+
+ await reportRetiredModelPins();
+
+ expect(addNotification).toHaveBeenCalledTimes(2);
+ const [first, second] = addNotification.mock.calls.map(([card]) => card);
+ expect(first.type).toBe('agent_warning');
+ expect(first.metadata.pinId).toBe('settings:imageGen.agy.model');
+ expect(first.description).toContain('Agy CLI image model');
+ expect(first.description).toContain('retired-model-1');
+ expect(first.description).toContain('Settings → Media Gen → Image Gen');
+ expect(first.link).toBe('/media/image?settings=1');
+ expect(second.link).toBe('/cos/schedule');
+ expect(second.metadata.pinId).toBe('task:brain-sync');
+ });
+
+ it('keeps a single-line log trail beside the cards', async () => {
+ auditModelPins.mockResolvedValue(audited(pin('settings:imageGen.agy.model')));
await reportRetiredModelPins();
expect(logged).toHaveBeenCalledTimes(1);
- expect(logged.mock.calls[0][0]).toContain('2 of 2 stored model pin(s)');
+ expect(logged.mock.calls[0][0]).toContain('1 of 1 stored model pin(s)');
// Single-line, and never a dump of the pin array (AGENTS.md logging rule).
expect(logged.mock.calls[0][0]).not.toContain('\n');
expect(logged.mock.calls[0][0]).not.toContain('settings:imageGen.agy.model');
});
- it('stays silent on a later refresh that finds the SAME stale set', async () => {
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
+ it('raises nothing on a later refresh that finds the SAME stale set', async () => {
+ auditModelPins.mockResolvedValue(audited(pin('settings:imageGen.agy.model')));
await reportRetiredModelPins();
+ addNotification.mockClear();
logged.mockClear();
await reportRetiredModelPins();
await reportRetiredModelPins();
+ expect(addNotification).not.toHaveBeenCalled();
expect(logged).not.toHaveBeenCalled();
});
+ it('stays silent across a RESTART, because the card is the dedupe record', async () => {
+ auditModelPins.mockResolvedValue(audited(pin('settings:imageGen.agy.model')));
+ await reportRetiredModelPins();
+ addNotification.mockClear();
+
+ // A restart drops every in-process tracker; the persisted card survives.
+ resetModelPinReportState();
+ await reportRetiredModelPins();
+
+ expect(addNotification).not.toHaveBeenCalled();
+ });
+
it('stays silent on every refresh when nothing is stale', async () => {
auditModelPins.mockResolvedValue(audited());
await reportRetiredModelPins();
await reportRetiredModelPins();
+ expect(addNotification).not.toHaveBeenCalled();
expect(logged).not.toHaveBeenCalled();
});
it('announces only the pin that NEWLY rotted, alongside the running total', async () => {
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
+ auditModelPins.mockResolvedValue(audited(pin('settings:imageGen.agy.model')));
await reportRetiredModelPins();
+ addNotification.mockClear();
logged.mockClear();
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model', 'task:brain-sync'));
+ auditModelPins.mockResolvedValue(audited(
+ pin('settings:imageGen.agy.model'),
+ pin('task:brain-sync', { kind: 'task' }),
+ ));
await reportRetiredModelPins();
- expect(logged).toHaveBeenCalledTimes(1);
+ expect(addNotification).toHaveBeenCalledTimes(1);
+ expect(addNotification.mock.calls[0][0].metadata.pinId).toBe('task:brain-sync');
expect(logged.mock.calls[0][0]).toContain('1 of 2 stored model pin(s)');
});
- it('announces again after the user clears a pin that later rots a second time', async () => {
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
- await reportRetiredModelPins();
-
- // Cleared back to inherit — it drops out of the stale set entirely.
- auditModelPins.mockResolvedValue(audited());
- await reportRetiredModelPins();
- logged.mockClear();
+ it('falls back to the provider id when the audit names no provider record', async () => {
+ auditModelPins.mockResolvedValue({ pins: [pin('settings:imageGen.agy.model')], providers: {} });
- // Re-pinned, and rotted again: this is news, not the set we already reported.
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
await reportRetiredModelPins();
- expect(logged).toHaveBeenCalledTimes(1);
+ expect(addNotification.mock.calls[0][0].description).toContain('antigravity-cli');
});
- it('never rejects when the audit throws, and does not forget what it announced', async () => {
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
- await reportRetiredModelPins();
- logged.mockClear();
-
+ it('never rejects when the audit throws, and raises no card', async () => {
auditModelPins.mockRejectedValue(new Error('settings store unreadable'));
+
await expect(reportRetiredModelPins()).resolves.toBeUndefined();
+
expect(errored.mock.calls[0][0]).toContain('settings store unreadable');
+ expect(addNotification).not.toHaveBeenCalled();
+ });
- // The failure must leave the reported set alone. Clearing it here would make
- // the very next audit re-announce a pin the user was already told about.
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
- await reportRetiredModelPins();
+ it('announces the remaining pins when one pin\'s write fails', async () => {
+ // The coalescing guard means the next audit may be a whole burst away, so a
+ // transient failure on the first pin must not silently drop the rest.
+ auditModelPins.mockResolvedValue(audited(
+ pin('settings:imageGen.agy.model'),
+ pin('task:brain-sync', { kind: 'task' }),
+ ));
+ addNotification.mockRejectedValueOnce(new Error('notifications.json unwritable'));
- expect(logged).not.toHaveBeenCalled();
+ await expect(reportRetiredModelPins()).resolves.toBeUndefined();
+
+ expect(addNotification).toHaveBeenCalledTimes(2);
+ expect(addNotification.mock.calls[1][0].metadata.pinId).toBe('task:brain-sync');
+ expect(logged.mock.calls[0][0]).toContain('1 of 2 stored model pin(s)');
+ });
+
+ it('never rejects when the notification write fails, and re-announces next refresh', async () => {
+ auditModelPins.mockResolvedValue(audited(pin('settings:imageGen.agy.model')));
+ addNotification.mockRejectedValueOnce(new Error('notifications.json unwritable'));
+
+ await expect(reportRetiredModelPins()).resolves.toBeUndefined();
+ expect(errored.mock.calls[0][0]).toContain('notifications.json unwritable');
+
+ // Nothing persisted, so the pin is still unannounced — the next refresh owes
+ // the user the card the failed write never produced.
+ await reportRetiredModelPins();
+ expect(addNotification).toHaveBeenCalledTimes(2);
});
it('coalesces a burst of provider saves into two audits, not one per save', async () => {
@@ -121,7 +214,7 @@ describe('reportRetiredModelPins', () => {
// last reads state that is already superseded.
let release;
auditModelPins.mockReturnValueOnce(new Promise((resolve) => { release = resolve; }));
- auditModelPins.mockResolvedValue(audited('settings:imageGen.agy.model'));
+ auditModelPins.mockResolvedValue(audited(pin('settings:imageGen.agy.model')));
const burst = Promise.all([
reportRetiredModelPins(), reportRetiredModelPins(),
@@ -136,7 +229,7 @@ describe('reportRetiredModelPins', () => {
// One in flight plus one covering everything that landed behind it.
expect(auditModelPins).toHaveBeenCalledTimes(2);
// And the final state is what got reported, not the superseded first read.
- expect(logged).toHaveBeenCalledTimes(1);
+ expect(addNotification).toHaveBeenCalledTimes(1);
});
});