test(server): check waggle.db and the memory store instead of mind files (P1.5)

- trust wiring: read install_audit from waggle.db through the server; the
  old checks read a legacy personal.mind that nothing writes any more.
- data dir: a fresh install is marked by waggle.db, not personal.mind.
- backup: expect waggle.db and memory/ in the archive.
- cross-platform: replace the MindDB block with waggle.db checks (file, WAL,
  foreign keys) and memory round trips (plain, Unicode, 100 KB) through
  server.memory. FTS5 and session CRUD were legacy-engine features.
- store fixtures (install audit, cron) open WaggleDB instead of MindDB.
This commit is contained in:
shumeiko.it
2026-10-24 17:07:10 +02:00
parent 6573f817b0
commit f57d618bea
10 changed files with 76 additions and 183 deletions

View File

@@ -3,7 +3,7 @@
*
* Validates that:
* 1. InstallAuditStore is instantiated and wired at runtime
* 2. Install operations record audit entries in the .mind DB
* 2. Install operations record audit entries in waggle.db
* 3. Existing non-trust approvals remain backward-compatible
*/
@@ -11,8 +11,6 @@ import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import Database from 'better-sqlite3';
import { MindDB } from '@waggle/core';
import { buildLocalServer } from '../../src/local/index.js';
import type { FastifyInstance } from 'fastify';
import { injectWithAuth } from '../test-utils.js';
@@ -24,11 +22,6 @@ describe('Trust Model Runtime Wiring', () => {
beforeAll(async () => {
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-trust-wire-'));
// Create personal.mind
const personalPath = path.join(tmpDir, 'personal.mind');
const mind = new MindDB(personalPath);
mind.close();
// Create skills dir with marker to prevent auto-install of starter skills
const skillsDir = path.join(tmpDir, 'skills');
fs.mkdirSync(skillsDir, { recursive: true });
@@ -44,12 +37,9 @@ describe('Trust Model Runtime Wiring', () => {
describe('Audit store wiring', () => {
it('install_audit table exists after server startup', () => {
const personalPath = path.join(tmpDir, 'personal.mind');
const db = new Database(personalPath);
const table = db.prepare(
const table = server.waggleDb.getDatabase().prepare(
"SELECT name FROM sqlite_master WHERE type='table' AND name='install_audit'",
).get() as { name: string } | undefined;
db.close();
expect(table).toBeDefined();
expect(table!.name).toBe('install_audit');
});
@@ -98,10 +88,7 @@ describe('Trust Model Runtime Wiring', () => {
});
it('duplicate install does not create new audit entries', async () => {
const personalPath = path.join(tmpDir, 'personal.mind');
const db1 = new Database(personalPath);
const before = (db1.prepare("SELECT count(*) as c FROM install_audit").get() as { c: number }).c;
db1.close();
const before = server.auditStore.getAll().length;
// Try to install already-installed skill
const res = await injectWithAuth(server, {
@@ -110,9 +97,7 @@ describe('Trust Model Runtime Wiring', () => {
});
expect(res.statusCode).toBe(409);
const db2 = new Database(personalPath);
const after = (db2.prepare("SELECT count(*) as c FROM install_audit").get() as { c: number }).c;
db2.close();
const after = server.auditStore.getAll().length;
// Server route handles duplicate before reaching skill-tools,
// so no new audit entries should be created via the API route