import { describe, expect, test } from "vitest"; import type { SubagentDetectionContext } from "#src/authority/subagent-context"; import { SubagentDetection } from "#src/authority/subagent-detection"; import { SubagentSessionRegistry } from "#src/authority/subagent-registry"; import { posixPathFlavor } from "#src/path/path-flavor"; function makeCtx(sessionId: string): SubagentDetectionContext { return { sessionManager: { getSessionDir: () => "", getSessionId: () => sessionId, }, }; } const subagentSessionsDir = "/agent/subagent-sessions"; // The detection sources themselves are covered exhaustively in // subagent-context.test.ts; these two tests pin the only branches this // wrapper owns: registry consult and registry-absent fallback. describe("SubagentDetection.isRegisteredChild", () => { test("returns true when the session id is registered", () => { const registry = new SubagentSessionRegistry(); registry.register("child-1", {}); const detection = new SubagentDetection({ subagentSessionsDir, flavor: posixPathFlavor, registry, }); expect(detection.isRegisteredChild(makeCtx("child-1"))).toBe(true); }); test("returns false when constructed without a registry", () => { const detection = new SubagentDetection({ subagentSessionsDir, flavor: posixPathFlavor, }); expect(detection.isRegisteredChild(makeCtx("child-1"))).toBe(false); }); });