refactor(server): search memory through the contract in artifacts, agent runs, route proposals and onboarding (P1.5)

- Artifact Center related search lists personal and workspace memories
  through server.memory and finds related chat sessions in the session
  files (UF-034).
- /api/agent/run searches the requested workspace's memory, or personal
  memory when no known workspace is given.
- Executor briefs search only the workspace's own memory and leave out
  temporary memories in the query; route proposals no longer borrow a
  mind from the cache.
- Onboarding treats any personal memory as evidence of prior use.
- The service no longer creates personal.mind on a fresh install, and
  isFirstRun also looks for waggle.db.
This commit is contained in:
shumeiko.it
2026-10-24 12:50:15 +02:00
parent e9ed8c0765
commit f310333970
13 changed files with 239 additions and 219 deletions

View File

@@ -3,7 +3,6 @@ import fs from 'node:fs';
import net from 'node:net';
import path from 'node:path';
import os from 'node:os';
import { MindDB } from '@waggle/core';
import { startService } from '../src/local/service.js';
import { getLiteLLMStatus, selectLiteLLMPython } from '../src/local/lifecycle.js';
import { PROVIDER_ENV_NAMES } from '../src/local/provider-env.js';
@@ -76,8 +75,7 @@ describe('Agent Service', () => {
// Create a default.mind (simulating pre-M4 layout)
const defaultPath = path.join(dataDir, 'default.mind');
const mind = new MindDB(defaultPath);
mind.close();
fs.writeFileSync(defaultPath, '');
expect(fs.existsSync(defaultPath)).toBe(true);
const port = randomPort();
@@ -90,7 +88,7 @@ describe('Agent Service', () => {
expect(fs.existsSync(defaultPath)).toBe(false);
});
it('creates personal.mind if fresh install (no default.mind)', async () => {
it('creates waggle.db and the memory directory on a fresh install', async () => {
const dataDir = makeTmpDir();
tmpDirs.push(dataDir);
const port = randomPort();
@@ -98,8 +96,8 @@ describe('Agent Service', () => {
const { server } = await startService({ dataDir, port, skipLiteLLM: true });
cleanups.push(async () => { await server.close(); });
const personalPath = path.join(dataDir, 'personal.mind');
expect(fs.existsSync(personalPath)).toBe(true);
expect(fs.existsSync(path.join(dataDir, 'waggle.db'))).toBe(true);
expect(fs.existsSync(path.join(dataDir, 'memory'))).toBe(true);
});
it('returns running server (health check works)', async () => {