/** * Memory lifecycle routes (Wave 2b, ADR-002 memory_events log): * POST /memory/:id/invalidate { reason? } -> 200 { ok: true } | 400 | 401 | 404 | 409 * POST /memory/:id/supersede { new_id } -> 200 { ok: true } | 400 | 401 | 404 | 409 * POST /memory/:id/promote { scope } -> 200 { ok: true } | 400 | 401 | 404 | 409 * POST /memory/:id/restore -> 200 { ok: true } | 401 | 404 | 409 (FEAT-416, un-archive) * POST /memory/:id/unsupersede -> 200 { ok: true } | 401 | 404 | 409 (FEAT-442, un-supersede) * GET /memory/:id/history -> { id, history: MemoryEvent[] } | 401 | 404 * POST /memory/:id/used -> 200 { ok: true } | 401 | 404 * DELETE /memory/:id -> 200 { ok: true } | 401 | 404 (erasure v1, ADR-006 W5) * * `history` also backs the Wave 2c MCP `memory_history` tool. * `used` is the ADR-010 (2e) explicit recall-used signal — REST twin of the * MCP `submit_feedback` tool (src/mcp/server.ts; U5 canonical name — the * former `mark_memory_used` is now a one-release deprecated alias). * `restore` un-archives a memory previously archived by the W4.4 TTL policy * (src/storage/archival.ts) or by a manual `archive` event — mirrors * `invalidate`'s 404/409 semantics exactly (MemoryEventRepo.restore() already * throws MemoryNotFoundError/MemoryConflictError for the same two cases). * `unsupersede` (FEAT-442 reversal primitive) is the analogous un-do for * `supersede` — most commonly used to reverse an autonomous-consolidation * auto-accept, but works for any supersede (manual or auto). Un-hides the * LOSER; the winner is untouched (see MemoryEventRepo.unsupersede()'s doc * comment for exact semantics). Same 404/409 mapping. * * Error-class -> status mapping is centralized in `mapLifecycleError` below * (FEAT-435 conformance): MemoryNotFoundError always -> 404, and both * MemoryConflictError and InvalidScopeTransitionError (a valid id whose * current state makes the requested transition inapplicable — e.g. a * downward scope promotion) -> 409. 400 is reserved exclusively for * malformed/invalid request bodies (zod parse failures). Every verb below * routes its typed-error catch through this one helper so a future 5th verb * can't silently diverge — see tests/server/lifecycle.test.ts's * "lifecycle error-status conformance" suite. * * Exported (not just used internally) so `server/routes/capture-purge.ts` * (FEAT-467) reuses the exact same mapping for its batch-scoped verbs rather * than inventing a parallel error-status convention. */ import type { FastifyInstance, FastifyReply } from 'fastify'; import type { DB } from '../../storage/db.js'; /** * Uniform mapping from the repo's typed lifecycle errors to HTTP status + * error-body shape. `id` is the route's :id param, used as the 409 body's * `id` field (MemoryConflictError/InvalidScopeTransitionError carry no * atomId of their own). 404 uses `err.atomId` instead of the route `id` * because supersede's not-found can refer to either the source id or the * `new_id` target — both still surface under the same `id` key. Anything * else is rethrown for Fastify's default error handler. */ export declare function mapLifecycleError(err: unknown, id: string, reply: FastifyReply): FastifyReply, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>; export declare function lifecycleRoutes(db: DB): (app: FastifyInstance) => Promise;