feat(FN-3580): restore canonical agent lifecycle and remove terminated agen

This merge restores the canonical agent lifecycle with termination scoped at the run level (FN-3580, 4 steps), adds sender-side wake recipient override for messages, and introduces test isolation CI enforcement with a stuck-requeue race fix. UI changes remove terminated-agent indicators from AgentDe

Fusion-Task-Id: FN-3580
This commit is contained in:
Fusion
2026-05-06 10:18:27 -07:00
committed by gsxdsm
parent b3aa9f9890
commit 1ce47fd870
24 changed files with 216 additions and 286 deletions

View File

@@ -1258,8 +1258,8 @@ describe("InProcessRuntime", () => {
});
});
describe("ephemeral termination cleanup", () => {
it("auto-deletes ephemeral agent when it transitions to terminated via agent:stateChanged", async () => {
describe("ephemeral paused-state cleanup", () => {
it("auto-deletes ephemeral agent when it transitions to paused via agent:stateChanged", async () => {
vi.useFakeTimers();
try {
@@ -1284,7 +1284,7 @@ describe("InProcessRuntime", () => {
let agents = await store.listAgents({ includeEphemeral: true });
expect(agents.some((a: Agent) => a.id === agent.id)).toBe(true);
// Emit agent:stateChanged event to trigger termination
// Emit agent:stateChanged event to trigger cleanup
store.emit("agent:stateChanged", agent.id, "running", "paused");
// Wait for async handler
@@ -1302,7 +1302,7 @@ describe("InProcessRuntime", () => {
}
}, 30000);
it("does not auto-delete non-ephemeral agent when it transitions to terminated", async () => {
it("does not auto-delete non-ephemeral agent when it transitions to paused", async () => {
vi.useFakeTimers();
try {
@@ -1323,7 +1323,7 @@ describe("InProcessRuntime", () => {
let agents = await store.listAgents();
expect(agents.some((a: Agent) => a.id === agent.id)).toBe(true);
// Emit agent:stateChanged event to trigger termination
// Emit agent:stateChanged event to trigger cleanup
store.emit("agent:stateChanged", agent.id, "active", "paused");
// Wait for async handler
@@ -1593,12 +1593,12 @@ describe("InProcessRuntime", () => {
});
describe("startup ephemeral sweep", () => {
it("cleans terminated ephemeral agents on startup", async () => {
it("cleans paused ephemeral agents on startup", async () => {
const { AgentStore } = await import("@fusion/core");
const preStore = new AgentStore({ rootDir: join(testDir, ".fusion") });
await preStore.init();
const orphan = await preStore.createAgent({
name: "orphan-terminated",
name: "orphan-paused",
role: "executor",
metadata: { agentKind: "task-worker" },
runtimeConfig: { enabled: false },