import assert from "node:assert/strict";
import { test } from "vitest";
import { runAgentEndMemoryBackfill } from "../bootstrap/register-hooks.js";

test("agent_end memory backfill invokes the embedding repair sweep", async () => {
	let calls = 0;

	await runAgentEndMemoryBackfill(async () => {
		calls += 1;
	});

	assert.equal(calls, 1);
});

test("agent_end memory backfill failures do not break the lifecycle", async () => {
	await runAgentEndMemoryBackfill(async () => {
		throw new Error("gateway offline");
	});
});
