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:
shumeiko.it
2026-10-23 14:31:28 +02:00
parent 20567ecb10
commit ad2ca875cb
65 changed files with 6131 additions and 201 deletions

View File

@@ -37,6 +37,7 @@ about the user live in mem0, and that facts are extracted in the background, in
5. **Not memory.** The user's profile card (name, role, department, style and the other
identity fields), the task list (awareness) and the other Waggle tables move to `waggle.db`
in P1.5. What the model learns about the user is memory: kind 'profile', personal scope.
Done on 2026-10-23, see "waggle.db" below.
6. **Extraction policy.** Facts are extracted in the background, in batches (after several
turns or a pause), with the model the user chose, through the sidecar's built-in
OpenAI-compatible proxy. A setting turns it off. Wiring this is part of P1.5.
@@ -71,3 +72,32 @@ about the user live in mem0, and that facts are extracted in the background, in
at personal scale and should be revisited if a store grows past tens of thousands.
- mem0 keeps its SQLite handles open for the life of the process; `close` only marks the store
closed.
## waggle.db (P1.5, day 6)
`WaggleDB` in `@waggle/core` opens `<dataDir>/waggle.db`. It holds:
- automations: `cron_schedules`, `cron_execution_history`, `cron_run_leases`;
- `notifications` and held actions (`pending_actions`);
- `skill_hashes` and thumbs feedback (`feedback_entries`);
- cost tracking: `execution_traces`, `execution_trace_spend`,
`execution_trace_spend_reservations`;
- the profile card (`profiles`) and awareness items (`awareness_items`), one set per scope:
`personal` or `workspace:<id>`.
The stores of these tables take a `WaggleDB`, not a generic SQLite handle, so handing them a
memory database is a type error. Telemetry (`telemetry.db`) and the audit log (`audit.db`)
already had their own files and stay there.
On the first start the server copies these tables from the legacy `personal.mind`, and the
profile and awareness items of every `workspace.mind`, into `waggle.db`
(`importLegacyMindData`). The legacy files are only read, because the data directory may be
shared with the commercial edition; each scope is copied once (recorded in `waggle_meta`) and a
table only while its target is empty.
The logger, injection scanner, external-memory ingress guard, `WorkspaceManager` and the
embedders were copied from `@waggle/hive-mind-core` into `@waggle/core`, which now re-exports
its own copies. The substrate keeps its copies until it is removed. Those files came from an
Apache-2.0 package into the MIT `core` package; both are Egzakta's code, and the licence of the
copies is part of the licensing review.

View File

@@ -21,7 +21,7 @@ work packages wait for the answer.
| Topic | Temporary choice | Blocks |
|---|---|---|
| Licensing review | Technical license checks continue | P2.3, P2.6 |
| Licensing review (includes code copied from the Apache-2.0 `hive-mind-core` into MIT `core`, ADR-0007) | Technical license checks continue | P2.3, P2.6 |
| Product name and system identifiers | Temporary names | P1.3d, P2.6 |
| Location of the public repository | Manual builds on each OS | P1.3d, P2.6 |
| Supported platforms for v1 | Windows x64, macOS arm64 and x64, Linux x64 (glibc) | P1.3b, P1.3d |