Waggle kept its own tables in the memory database. Before the memory
engine can be replaced by mem0 they need a home of their own.
- add WaggleDB (<dataDir>/waggle.db). Automations, notifications, held
actions, skill hashes, thumbs feedback, cost tracking, the profile card
and awareness items live there. Their stores take a WaggleDB, so passing
a memory database is a type error.
- the profile card and awareness items are now per scope ('personal' or
'workspace:<id>') in one table each, instead of one table per .mind file
- on the first start, copy these tables from personal.mind and every
workspace.mind (importLegacyMindData). The legacy files are only read,
each scope is copied once and a table only while its target is empty.
- copy the logger, injection scanner, external-memory ingress guard,
WorkspaceManager and the embedders from @waggle/hive-mind-core into
@waggle/core, which now re-exports its own copies
- point the server, agent orchestrator and CLI at waggle.db; update the
tests that seeded these tables in a memory database
ADR-0007 records the layout and the licensing question about the copied
files.
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
/**
|
|
* In-process embedder tests — ported from
|
|
* hive-mind/packages/core/src/mind/inprocess-embedder.test.ts.
|
|
*
|
|
* Memory Sync Repair Step 2. Source: hive-mind file at HEAD c363257.
|
|
*
|
|
* Verbatim port — only the import path is adjusted from
|
|
* `./inprocess-embedder.js` to `../../src/mind/inprocess-embedder.js`
|
|
* to match waggle-os's tests/mind/ placement convention. Both repos
|
|
* export the same `normalizeDimensions(input, target)` shape with the
|
|
* documented "no-copy fast path when dims match" contract.
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { normalizeDimensions } from '../../src/embeddings/inprocess-embedder.js';
|
|
|
|
describe('normalizeDimensions (hive-mind port)', () => {
|
|
it('returns the same vector when lengths already match', () => {
|
|
const input = new Float32Array([1, 2, 3, 4]);
|
|
const output = normalizeDimensions(input, 4);
|
|
// Implementation intentionally returns the same reference when dims match
|
|
// — this is a public behavioural contract (no-copy fast path).
|
|
expect(output).toBe(input);
|
|
expect(Array.from(output)).toEqual([1, 2, 3, 4]);
|
|
});
|
|
|
|
it('zero-pads when the input is shorter than the target', () => {
|
|
const input = new Float32Array([1, 2, 3]);
|
|
const output = normalizeDimensions(input, 6);
|
|
expect(output.length).toBe(6);
|
|
expect(Array.from(output)).toEqual([1, 2, 3, 0, 0, 0]);
|
|
});
|
|
|
|
it('truncates when the input is longer than the target', () => {
|
|
const input = new Float32Array([1, 2, 3, 4, 5, 6]);
|
|
const output = normalizeDimensions(input, 3);
|
|
expect(output.length).toBe(3);
|
|
expect(Array.from(output)).toEqual([1, 2, 3]);
|
|
});
|
|
|
|
it('handles empty input by producing a zero-filled target vector', () => {
|
|
const input = new Float32Array([]);
|
|
const output = normalizeDimensions(input, 4);
|
|
expect(output.length).toBe(4);
|
|
expect(Array.from(output)).toEqual([0, 0, 0, 0]);
|
|
});
|
|
});
|