refactor(server): serve memory and Memory Center from the memory contract (P1.5)
The memory HTTP API reads and writes server.memory instead of the legacy
MultiMind, FrameStore, SessionStore, KnowledgeGraph, MindErasure,
SuppressionStore and RawArchive objects.
- memory.ts: search (personal, workspace, all, global), frames list, write,
edit and delete, stats and quick capture on the contract. Ids are strings.
The access-count route is gone. New GET /api/memory/capabilities and
PUT /api/memory/settings { extraction } for background fact extraction.
- memory-center.ts: list, get, create, patch, archive, confirm, trace,
delete, erase and merge on the contract. Archive sets importance
'temporary' (skipped by recall) and remembers the old importance; confirm
stamps metadata.confirmedAt; 'unreviewed' means extracted in the
background and not confirmed. Erase forgets one memory or every memory of
a chat session. The original-source and suppression routes are removed:
there is no raw archive and no harvest to re-import from.
- knowledge.ts returns an empty graph (not part of v1).
- export.ts writes memories/personal.json and memories/workspace-<id>.json
from the contract.
- identity.ts loses a dead resolver; the erase safety check recognizes
waggle.db.
- memory-records.ts holds the scope, status and creation-time helpers.
- normalizeToMemory stays in memory-center-legacy.ts until home.ts and
artifacts.ts read memory through the contract.
- @waggle/shared MemoryKind follows the contract's kinds; Memory gains
origin and sessionId.
Tests: new memory-routes and memory-center tests on the in-memory store;
local-mode and data-export tests seed memory through the contract; tests of
removed behaviour (source, suppression, sticky erasure, graph projection,
legacy normalizer, old erase and stats) are deleted.
This commit is contained in:
@@ -365,9 +365,10 @@ export type Scope = 'personal' | 'workspace' | 'team' | 'organization';
|
||||
/** 0-100 confidence score for a memory / provenance signal. */
|
||||
export type Confidence = number;
|
||||
|
||||
/** Mirrors `MEMORY_KINDS` of `@waggle/memory-contract` (ADR-0007). */
|
||||
export type MemoryKind =
|
||||
| 'fact' | 'decision' | 'task' | 'preference'
|
||||
| 'strategy' | 'learning' | 'goal' | 'entity';
|
||||
| 'fact' | 'event' | 'preference' | 'profile'
|
||||
| 'decision' | 'summary' | 'note';
|
||||
export type ArtifactKind =
|
||||
| 'document' | 'presentation' | 'spreadsheet' | 'dashboard'
|
||||
| 'research' | 'code' | 'media' | 'design' | 'other';
|
||||
@@ -633,25 +634,19 @@ export interface Command {
|
||||
payload?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// === UX-Refactor Memory entity (PRD §15.4 / shared-types-delta §3b) ===
|
||||
// The normalized contract the sidecar `memory.ts` route layer exposes to the
|
||||
// Memory Center. The PERSISTED row lives in `@waggle/hive-mind-core`
|
||||
// (`memory_frames`); a route-layer normalizer (Phase 2B) projects the row +
|
||||
// its JSON `metadata` blob into this shape. `kind/confidence/scope/status/
|
||||
// sourceId/tags/evidence/related*` ride `memory_frames.metadata` (added by the
|
||||
// idempotent ADD-COLUMN migration M1 in Phase 2B); the base columns map 1:1
|
||||
// (`content`, `created_at`, `last_accessed`, `importance`, `source`).
|
||||
// === Memory entity (PRD §15.4) ===
|
||||
// What the Memory Center routes (`/api/memory[/:id]`) return: a memory record of
|
||||
// `@waggle/memory-contract` plus the Memory Center's own fields, which live in
|
||||
// the record's metadata (see packages/server/src/local/memory-records.ts).
|
||||
|
||||
/**
|
||||
* Memory lifecycle state (PRD §12.4 / §14.4), reconciled with the Phase-2 gate
|
||||
* ratifications (2026-06-09):
|
||||
* - `unreviewed` — freshly imported, pending non-blocking review (C33: import
|
||||
* commits immediately but lands unreviewed; Memory Center "needs review" filter).
|
||||
* - `archived` — reversible soft-status (A8 Archive).
|
||||
* - `deprecated` — superseded (A8 Deprecate; mirrors the existing `importance`).
|
||||
* - `low_confidence` / `conflict` — surfaced for review; may be derived at
|
||||
* recall-time (S04 C10) rather than persisted.
|
||||
* - Delete is a HARD delete (A8) — there is no `trash`/tombstone state in v1.
|
||||
* Memory lifecycle state. The memory contract produces three of them:
|
||||
* - `active`;
|
||||
* - `unreviewed`: extracted from a chat in the background and not yet
|
||||
* confirmed by the user (Memory Center "needs review" filter);
|
||||
* - `archived`: reversible, hidden from recall.
|
||||
* `low_confidence`, `conflict` and `deprecated` are not produced in v1.
|
||||
* Delete is a hard delete; there is no trash.
|
||||
*/
|
||||
export type MemoryStatus =
|
||||
| 'active' | 'unreviewed' | 'low_confidence' | 'conflict' | 'deprecated' | 'archived';
|
||||
@@ -664,18 +659,18 @@ export interface Memory {
|
||||
scope: Scope;
|
||||
workspaceId?: string;
|
||||
teamId?: string | null;
|
||||
/** Provenance class — maps from `memory_frames.source` (FrameSource). */
|
||||
/** Provenance: user_stated, tool_verified, agent_inferred, import or system. */
|
||||
source: string;
|
||||
/** Producer of the memory, e.g. 'chat-write-back', 'extraction', 'quick-capture'. */
|
||||
origin?: string | null;
|
||||
/** Chat session the memory came from, when there is one. */
|
||||
sessionId?: string | null;
|
||||
/** Not set by the memory contract in v1. */
|
||||
sourceId?: string | null;
|
||||
/** Not set by the memory contract in v1. */
|
||||
sourceUrl?: string | null;
|
||||
/** #7: whether a verbatim raw_archive row is linked (metadata.archiveUids), i.e.
|
||||
* whether "View original source" can actually load. Distinct from sourceId — an
|
||||
* auto-synced harvest summary carries a sourceId but no archive link, so the
|
||||
* affordance gates on THIS, not on sourceId presence. */
|
||||
hasOriginalSource?: boolean;
|
||||
/** 0-100; B2 heuristic at import (source-trust × adapter × dedup). */
|
||||
/** 0-100. Not set by the memory contract in v1. */
|
||||
confidence?: Confidence;
|
||||
/** Reuses the substrate `Importance` union (`frames.ts`). */
|
||||
importance: 'critical' | 'important' | 'normal' | 'temporary' | 'deprecated';
|
||||
evidence?: string[];
|
||||
tags?: string[];
|
||||
@@ -684,7 +679,6 @@ export interface Memory {
|
||||
status: MemoryStatus;
|
||||
createdAt: string;
|
||||
updatedAt?: string;
|
||||
lastAccessedAt?: string;
|
||||
}
|
||||
|
||||
// === UX-Refactor Artifact entity (PRD §15.6 / shared-types-delta §4a) ===
|
||||
|
||||
Reference in New Issue
Block a user