feat(core): give Waggle its own database, apart from memory (P1.5)
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.
This commit is contained in:
@@ -52,6 +52,8 @@ export interface LoopTickDeps {
|
||||
schedule: LoopSchedule;
|
||||
/** The already-resolved workspace (or personal) mind for this loop. */
|
||||
mindDb: MindDB;
|
||||
/** Awareness items of the same scope, in waggle.db; the loop keeps its state there. */
|
||||
awareness: AwarenessLayer;
|
||||
/** Embedder for recall-by-meaning. */
|
||||
embedder: Embedder;
|
||||
/** Toolless completion against the local proxy/LiteLLM. */
|
||||
@@ -201,7 +203,7 @@ export function buildMakerPrompt(opts: {
|
||||
* memory-write failures ARE caught (best-effort, must not fail the whole tick).
|
||||
*/
|
||||
export async function runLoopTick(deps: LoopTickDeps): Promise<LoopTickResult> {
|
||||
const { schedule, mindDb, embedder, chat, log } = deps;
|
||||
const { schedule, mindDb, awareness, embedder, chat, log } = deps;
|
||||
|
||||
const spec = parseLoopSpec(schedule.job_config);
|
||||
if (!spec) {
|
||||
@@ -210,7 +212,6 @@ export async function runLoopTick(deps: LoopTickDeps): Promise<LoopTickResult> {
|
||||
}
|
||||
|
||||
const stateKey = `loop:${schedule.id}`; // namespaced so loops don't collide on awareness.status
|
||||
const awareness = new AwarenessLayer(mindDb);
|
||||
const prior = awareness.getByStatus(stateKey)[0];
|
||||
const priorMeta = prior ? awareness.parseMetadata(prior) : undefined;
|
||||
let priorResult = priorMeta ? String(priorMeta.result ?? '') : '';
|
||||
|
||||
Reference in New Issue
Block a user