import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { BEHAVIORAL_SPEC } from '@waggle/agent'; import { buildLocalServer } from '../src/local/index.js'; import type { FastifyInstance } from 'fastify'; describe('activeBehavioralSpec integration', () => { let tmpDir: string; beforeAll(() => { tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-active-spec-')); }); afterAll(() => { try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch { /* ignore */ } }); it('serves the compiled behavioral spec baseline', async () => { const server = await buildLocalServer({ dataDir: tmpDir }); try { expect(server.activeBehavioralSpec).toBeDefined(); expect(server.activeBehavioralSpec.rules).toBe(BEHAVIORAL_SPEC.rules); expect(server.activeBehavioralSpec.coreLoop).toBe(BEHAVIORAL_SPEC.coreLoop); } finally { await server.close(); } }); });