test(server): move the remaining server tests onto the memory contract (P1.5)

- Workspace sessions, fleet runs, agent groups, loops, the file indexer,
  external tool runs, chat and the health endpoint are checked against the
  memory store instead of .mind files. Assertions on mind-cache pins and
  releases go with the pins; the drain and cancellation checks stay.
- Delete the sticky-erasure test (harvest import was removed) and the
  session-distillation test (distillation on workspace activation was
  removed).
- The saved-history retry test checks the conversation only: the failed
  user turn is kept in workspace memory by design (#3).
This commit is contained in:
shumeiko.it
2026-10-24 12:50:23 +02:00
parent 74a4e55be0
commit 122b45990e
12 changed files with 274 additions and 785 deletions

View File

@@ -3,7 +3,6 @@ import Fastify from 'fastify';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { MultiMindCache } from '@waggle/core';
import {
createSubAgentTools,
createWorkflowTools,
@@ -72,7 +71,6 @@ describe('isolated Fleet execution', () => {
: undefined,
} as never);
server.decorate('sessionManager', { getMaxSessions: () => 10, size: 0, getActive: () => [] } as never);
server.decorate('mindCache', { acquire: () => ({}), release: () => {} } as never);
server.decorate('agentState', {
currentModel: 'anthropic/current-fallback',
litellmApiKey: 'test-key',
@@ -147,7 +145,6 @@ describe('isolated Fleet execution', () => {
: undefined,
} as never);
server.decorate('sessionManager', { getMaxSessions: () => 10, size: 0, getActive: () => [] } as never);
server.decorate('mindCache', { acquire: () => ({}), release: () => {} } as never);
server.decorate('agentState', {
currentModel,
litellmApiKey: 'test-key',
@@ -226,7 +223,6 @@ describe('isolated Fleet execution', () => {
: undefined,
} as never);
server.decorate('sessionManager', { getMaxSessions: () => 10, size: 0, getActive: () => [] } as never);
server.decorate('mindCache', { acquire: () => ({}), release: () => {} } as never);
server.decorate('agentState', {
currentModel: 'test-model',
litellmApiKey: 'test-key',
@@ -289,7 +285,6 @@ describe('isolated Fleet execution', () => {
const workspaceDir = path.join(dataDir, 'project');
fs.mkdirSync(workspaceDir);
const registry = new AgentRunRegistry(path.join(dataDir, 'agent-runs.json'));
const releases: string[] = [];
const orchestrators: unknown[] = [];
const toolBuilds: Array<{ cwd: string; workspaceId?: string; tools: unknown[] }> = [];
const calls: Array<{ signal?: AbortSignal; tools: unknown[]; finish: ReturnType<typeof deferred<AgentResponse>> }> = [];
@@ -305,10 +300,6 @@ describe('isolated Fleet execution', () => {
: undefined,
} as never);
server.decorate('sessionManager', { getMaxSessions: () => 10, size: 0, getActive: () => [] } as never);
server.decorate('mindCache', {
acquire: (workspaceId: string) => ({ workspaceId }),
release: (workspaceId: string) => { releases.push(workspaceId); },
} as never);
server.decorate('agentState', {
currentModel: 'test-model',
litellmApiKey: 'test-key',
@@ -392,7 +383,6 @@ describe('isolated Fleet execution', () => {
memoryRefs: { status: 'complete' },
});
expect(memoryRuns).toHaveLength(2);
expect(releases).toEqual(['workspace-1', 'workspace-1']);
const restored = new AgentRunRegistry(path.join(dataDir, 'agent-runs.json'));
expect(restored.get(first.runId)?.status).toBe('cancelled');
@@ -400,17 +390,12 @@ describe('isolated Fleet execution', () => {
await server.close();
});
it('does not resolve cancellation before the real workspace mind pin is released', async () => {
it('does not resolve cancellation before the in-flight mutation drains', async () => {
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-fleet-cancel-drain-'));
tempDirs.push(dataDir);
const workspaceDir = path.join(dataDir, 'project');
fs.mkdirSync(workspaceDir);
const registry = new AgentRunRegistry(path.join(dataDir, 'agent-runs.json'));
const mindCache = new MultiMindCache({
maxOpen: 1,
allowedRoot: dataDir,
getMindPath: (workspaceId) => path.join(dataDir, `${workspaceId}.mind`),
});
const runnerStarted = deferred<void>();
const abortObserved = deferred<void>();
const runnerMayFinish = deferred<void>();
@@ -438,7 +423,6 @@ describe('isolated Fleet execution', () => {
server.decorate('sessionManager', {
getMaxSessions: () => 10, size: 0, getActive: () => [],
} as never);
server.decorate('mindCache', mindCache);
server.decorate('agentState', {
currentModel: 'test-model',
litellmApiKey: 'test-key',
@@ -487,7 +471,6 @@ describe('isolated Fleet execution', () => {
});
server.addHook('onClose', async () => {
registry.close();
mindCache.closeAll();
});
await server.register(fleetRoutes);
@@ -536,9 +519,6 @@ describe('isolated Fleet execution', () => {
expect(concurrentCancelSettled).toBe(false);
expect(registry.get(runId)?.status).toBe('cancelling');
mindCache.getOrOpen('pressure-1');
expect(mindCache.has('workspace-1')).toBe(true);
runnerMayFinish.resolve(undefined);
await recorderCalled.promise;
await new Promise((resolve) => setTimeout(resolve, 0));
@@ -574,9 +554,6 @@ describe('isolated Fleet execution', () => {
expect(terminalRunEvents).toEqual(['cancelled']);
await competing;
expect(competingAcquired).toBe(true);
mindCache.getOrOpen('pressure-2');
expect(mindCache.has('workspace-1')).toBe(false);
} finally {
runnerMayFinish.resolve(undefined);
mutationMayFinish.resolve(undefined);
@@ -719,7 +696,6 @@ describe('isolated Fleet execution', () => {
}),
} as never);
server.decorate('sessionManager', { getMaxSessions: () => 10, size: 0, getActive: () => [] } as never);
server.decorate('mindCache', { acquire: () => ({}), release: () => {} } as never);
server.decorate('agentState', {
currentModel: 'test-model',
litellmApiKey: 'test-key',
@@ -807,7 +783,6 @@ describe('isolated Fleet execution', () => {
get: () => ({ id: 'workspace-1', name: 'Project', group: 'test', created: new Date().toISOString(), directory: workspaceDir, model: 'test-model' }),
} as never);
server.decorate('sessionManager', { getMaxSessions: () => 1, size: 0, getActive: () => [] } as never);
server.decorate('mindCache', { acquire: () => ({}), release: () => {} } as never);
server.decorate('agentState', {
currentModel: 'test-model', litellmApiKey: 'key',
createSessionOrchestrator: () => ({ setGoalAncestry: () => {}, buildSystemPrompt: () => 'system' }),