From 6688c1f0270ed049c957d7d06482dc89544702ec Mon Sep 17 00:00:00 2001 From: "shumeiko.it" Date: Sat, 24 Oct 2026 12:08:51 +0200 Subject: [PATCH] test(server): drop the WaggleDance route round-trip test (P1.1) signal-emitter-integration.test.ts posted hook signals to /api/waggle-dance/signal on a real sidecar. The route left the sidecar with team mode; the emitter's own behaviour, fail-open included, stays covered in hive-mind-shim-core. --- .../tests/signal-emitter-integration.test.ts | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 packages/server/tests/signal-emitter-integration.test.ts diff --git a/packages/server/tests/signal-emitter-integration.test.ts b/packages/server/tests/signal-emitter-integration.test.ts deleted file mode 100644 index 6510928..0000000 --- a/packages/server/tests/signal-emitter-integration.test.ts +++ /dev/null @@ -1,104 +0,0 @@ -/** - * AI-OS Phase 1D — end-to-end integration test for the shim signal - * emitter against a real local Waggle sidecar. - * - * Lives in the server tests (not shim-core) because importing - * @waggle/server from shim-core would invert the dependency - * direction. The emitter is consumed via @waggle/hive-mind-shim-core - * just like a real hook package would. - * - * What this catches: - * - Schema drift between emitter body and server zod schema - * - URL path drift - * - HTTP semantics (status codes, response shape) - */ - -import { describe, it, expect, beforeAll, afterAll } from 'vitest'; -import fs from 'node:fs'; -import path from 'node:path'; -import os from 'node:os'; -import type { FastifyInstance } from 'fastify'; -import { MindDB, FrameStore, SessionStore } from '@waggle/core'; -import { emitSignalToWaggleDance } from '@waggle/hive-mind-shim-core'; -import { buildLocalServer } from '../src/local/index.js'; - -function createTmpDir(prefix: string): string { - return fs.mkdtempSync(path.join(os.tmpdir(), `waggle-shim-int-${prefix}-`)); -} - -function cleanupDir(dir: string): void { - try { - fs.rmSync(dir, { recursive: true, force: true }); - } catch { - /* best-effort */ - } -} - -describe('emitSignalToWaggleDance — real sidecar round-trip', () => { - let server: FastifyInstance; - let baseUrl: string; - let tmpDir: string; - - beforeAll(async () => { - tmpDir = createTmpDir('emit'); - const personalPath = path.join(tmpDir, 'personal.mind'); - const mind = new MindDB(personalPath); - const sessions = new SessionStore(mind); - const frames = new FrameStore(mind); - const s = sessions.create('emit-int-test'); - frames.createIFrame(s.gop_id, 'emit-int-test seed', 'normal'); - mind.close(); - - server = await buildLocalServer({ dataDir: tmpDir }); - // Bind to a random local port so we don't collide with any - // running sidecar on 3333. - baseUrl = await server.listen({ host: '127.0.0.1', port: 0 }); - }); - - afterAll(async () => { - if (server) await server.close(); - if (tmpDir) cleanupDir(tmpDir); - }); - - it('round-trips a discovery signal through the real route', async () => { - const out = await emitSignalToWaggleDance({ - type: 'broadcast', - subtype: 'discovery', - senderId: 'shim-int-test', - content: { tool: 'claude-code', topic: 'integration roundtrip' }, - url: baseUrl, - }); - expect(out).not.toBeNull(); - expect(out!.id).toBeTruthy(); - expect(out!.teamId).toBe('personal::shim-int-test'); - expect(out!.subtype).toBe('discovery'); - expect((out!.content as Record).tool).toBe('claude-code'); - }); - - it('round-trips a knowledge_match response with referenceId', async () => { - const out = await emitSignalToWaggleDance({ - type: 'response', - subtype: 'knowledge_match', - senderId: 'cursor', - referenceId: 'parent-msg-id', - content: { matched: ['e1', 'e2'], confidence: 0.91 }, - url: baseUrl, - }); - expect(out).not.toBeNull(); - expect(out!.referenceId).toBe('parent-msg-id'); - }); - - it('returns null when sidecar URL points to a closed port (fail-open)', async () => { - const out = await emitSignalToWaggleDance({ - type: 'broadcast', - subtype: 'discovery', - content: {}, - url: 'http://127.0.0.1:1', // closed - timeoutMs: 200, - onWarn: () => { - /* swallow for clean test output */ - }, - }); - expect(out).toBeNull(); - }); -});