/**
 * `forget` MCP tool — delete a memory by id with user-authored immunity.
 *
 * G.3 architectural exception (read-only invariant): destruction must remain user-controllable.
 * Post retire-Rust write-path cutover (T-RETIRE-RUST-CUTOVER) this routes through the configured
 * `RagBackend.deleteLesson` (like `recall`/`memorize`), not the engine directly — so engine-present
 * users hit the engine and no-engine users hit libSQL, the same seam.
 *
 * The user-authored eviction-immunity invariant (`feedback_user_authored_lessons_immune`) is
 * enforced by the backend: `deleteLesson` throws `UserAuthoredImmunityError` for a `user`-authored
 * lesson unless `force` is set (libSQL checks the row's author; loop-engine maps the engine's
 * USER_MEMORY_IMMUNE/-32003). A not-found id returns `{ deleted: false }`, which this handler maps
 * to a typed `MemoryNotFoundError` (mirrors the old memoryGet existence pre-check). Explicit user
 * deletion is allowed (with force); automatic deletion is never wired here (the no-auto-delete
 * invariant).
 *
 * Imports from: zod, ../../rag/types.js.
 * Imported by: mcp/server.ts (handler map).
 */
import { z } from 'zod';
// Re-exported so existing importers (tests, callers) keep a single source for the typed error.
export { UserAuthoredImmunityError } from '../../rag/types.js';
export const ForgetSchema = z.object({
    id: z.string().min(1),
    force: z
        .boolean()
        .default(false)
        .describe('Required to delete a memory whose authored_by is "user"'),
});
/** Thrown when `forget` targets an id that does not exist (→ INVALID_PARAMS to the MCP caller). */
export class MemoryNotFoundError extends Error {
    id;
    constructor(id) {
        super(`Memory ${id} not found`);
        this.id = id;
        this.name = 'MemoryNotFoundError';
    }
}
export async function handleForget(args, backend) {
    const result = await backend.deleteLesson(args.id, { force: args.force });
    if (!result.deleted)
        throw new MemoryNotFoundError(args.id);
    return { deleted: true, id: args.id, forced: result.forced };
}
//# sourceMappingURL=forget.js.map