refactor: drop the one-time copy of legacy .mind data
The first start copied Waggle's tables and the memories of the commercial edition's .mind files into waggle.db and mem0. The product is still in development and nobody has data to bring over, so both copies, their tests and the legacy creation-time field are gone. ADR-0007 records the change.
This commit is contained in:
@@ -10,7 +10,7 @@ import Fastify, { type FastifyInstance, type FastifyRequest } from 'fastify';
|
||||
import cors from '@fastify/cors';
|
||||
import fastifyStatic from '@fastify/static';
|
||||
import websocket from '@fastify/websocket';
|
||||
import { WaggleDB, importLegacyMindData, workspaceDataScope, type LegacyMindSource, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, CronStore, AwarenessLayer, VaultStore, SkillHashStore, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore } from '@waggle/core';
|
||||
import { WaggleDB, workspaceDataScope, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, CronStore, AwarenessLayer, VaultStore, SkillHashStore, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore } from '@waggle/core';
|
||||
import { corsOriginAllowed } from './cors-config.js';
|
||||
import { InstallAuditStore } from './install-audit.js';
|
||||
import { selfBaseUrl, selfRequestHeaders } from './self-request.js';
|
||||
@@ -68,7 +68,6 @@ import type { RiskLevel } from '@waggle/shared';
|
||||
import { runConnectorFetch } from './connector-harvest.js';
|
||||
import { openMemoryStore } from './memory-runtime.js';
|
||||
import { MemoryExtractionQueue } from './memory-extraction.js';
|
||||
import { importLegacyMemories, type LegacyMemorySource } from './legacy-memory-import.js';
|
||||
import { PERSONAL_SCOPE, workspaceScope, type MemoryStore } from '@waggle/memory-contract';
|
||||
import { runLoopTick } from './loop-executor.js';
|
||||
import { enqueueHeldAction } from './held-action-executor.js';
|
||||
@@ -486,36 +485,14 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
|
||||
const defaultWorkspaceId = defaultWorkspaceConfig.id;
|
||||
server.decorate('workspaceManager', wsManager);
|
||||
|
||||
// The legacy memory file of earlier versions; only the one-time copies of
|
||||
// legacy data below read it, and nothing creates it any more.
|
||||
const personalPath = path.join(fullConfig.dataDir, 'personal.mind');
|
||||
|
||||
// Waggle's own data (automations, notifications, cost tracking, profile and
|
||||
// awareness) lives in waggle.db, apart from memory (ADR-0007). The first
|
||||
// start copies it from the legacy .mind files, which stay untouched.
|
||||
// awareness) lives in waggle.db, apart from memory (ADR-0007).
|
||||
const waggleDb = WaggleDB.openInDataDir(fullConfig.dataDir);
|
||||
server.decorate('waggleDb', waggleDb);
|
||||
const legacySources: LegacyMindSource[] = [{ path: personalPath, scope: 'personal' }];
|
||||
for (const ws of wsManager.list()) {
|
||||
try {
|
||||
legacySources.push({ path: wsManager.getMindPath(ws.id), scope: workspaceDataScope(ws.id) });
|
||||
} catch {
|
||||
// A workspace whose directory fails the path checks has nothing to copy.
|
||||
}
|
||||
}
|
||||
// Install audit store — persistent trail for capability install events. Its
|
||||
// table must exist before the legacy copy below, which fills it.
|
||||
// Install audit store — persistent trail for capability install events.
|
||||
const auditStore = new InstallAuditStore(waggleDb);
|
||||
server.decorate('auditStore', auditStore);
|
||||
|
||||
for (const report of importLegacyMindData(waggleDb, legacySources)) {
|
||||
if (report.status === 'imported') {
|
||||
log.info(`[waggle-db] copied legacy data for ${report.scope}: ${JSON.stringify(report.copied)}`);
|
||||
} else if (report.status === 'failed') {
|
||||
log.warn(`[waggle-db] could not copy legacy data for ${report.scope}: ${report.error}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Cron store — SQLite-backed schedule persistence for Solo
|
||||
const cronStore = new CronStore(waggleDb);
|
||||
server.decorate('cronStore', cronStore);
|
||||
@@ -2479,10 +2456,8 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
|
||||
// Stop MCP servers
|
||||
await mcpRuntime.stopAll().catch(() => {});
|
||||
|
||||
// Stop collecting chat turns for fact extraction and the legacy memory copy.
|
||||
// Stop collecting chat turns for fact extraction.
|
||||
memoryExtraction.stop();
|
||||
legacyMemoryImport.cancel();
|
||||
await legacyMemoryImport.done;
|
||||
|
||||
// Close all workspace sessions (new concurrent model)
|
||||
sessionManager.closeAll();
|
||||
@@ -2500,31 +2475,5 @@ export async function buildLocalServer(config: Partial<LocalConfig> = {}) {
|
||||
}
|
||||
});
|
||||
|
||||
// One-time copy of memories from the legacy .mind files into the memory
|
||||
// store, in the background; the legacy files are only read.
|
||||
const legacyMemoryImport = (() => {
|
||||
let cancelled = false;
|
||||
const sources: LegacyMemorySource[] = [{ path: personalPath, scope: PERSONAL_SCOPE }];
|
||||
for (const ws of wsManager.list()) {
|
||||
try {
|
||||
sources.push({ path: wsManager.getMindPath(ws.id), scope: workspaceScope(ws.id) });
|
||||
} catch {
|
||||
// A workspace whose directory fails the path checks has nothing to copy.
|
||||
}
|
||||
}
|
||||
const done = new Promise<void>(resolve => setImmediate(resolve))
|
||||
.then(() => importLegacyMemories(memory, waggleDb, sources, (report) => {
|
||||
if (report.status === 'imported') {
|
||||
log.info(`[memory] copied ${report.copied} legacy memories for ${report.scope} (${report.skipped} skipped)`);
|
||||
} else if (report.status === 'failed') {
|
||||
log.warn(`[memory] could not copy legacy memories for ${report.scope}: ${report.error}`);
|
||||
}
|
||||
}, () => cancelled))
|
||||
.then(() => undefined, (err: unknown) => {
|
||||
log.warn(`[memory] legacy memory copy stopped: ${err instanceof Error ? err.message : String(err)}`);
|
||||
});
|
||||
return { done, cancel: () => { cancelled = true; } };
|
||||
})();
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user