/**
 * RAG types: `Lesson`, `RecallHit`, `RagBackend`.
 *
 * The `RagBackend` interface is the ONLY surface that `src/functions/rag.ts`
 * sees — no `@libsql/client` types leak past this boundary. That is what
 * makes the backend pluggable: Task 1.11 lands `libsql-lexical`, Task 1.12
 * lands `claude-auto-memory`, and neither requires touching the primitives.
 *
 * `embed()` returns `Promise<number[] | null>` rather than throwing on
 * embedder-down because the backend treats Ollama-absent as a degraded
 * (lexical-only) mode, not an error. The primitive caller decides what to
 * do with `null` — by default, `store_lesson` still inserts the row.
 *
 * Imports from: nothing (leaf type module).
 * Imported by: src/rag/* + src/functions/rag.ts.
 */
/**
 * The PURE eligibility predicate — the one place the cross/isolate rule lives, so it is unit-testable and
 * cannot drift. A hit is eligible iff it is `shared`, OR it is `project` AND its namespace matches the
 * recall scope. A null recall namespace (no project context) therefore matches ONLY `shared` rows
 * (fail-closed: project memory is never leaked when the project is unknown). Absent tier ⇒ `shared`.
 */
export function inScope(tier, namespace, scope) {
    if ((tier ?? 'shared') === 'shared')
        return true;
    return namespace != null && namespace === scope.namespace;
}
/**
 * Thrown by `deleteLesson` when the target is a `user`-authored lesson and `force` was not set.
 * Defined here (not in mcp/tools) so every backend can throw it without depending on the MCP layer
 * (`forget.ts` re-exports it for back-compat with existing imports). Mirrors the engine's
 * USER_MEMORY_IMMUNE (-32003) — explicit user deletion is allowed (with force); automatic eviction
 * of user memories is forbidden (the no-auto-delete invariant).
 */
export class UserAuthoredImmunityError extends Error {
    id;
    constructor(id) {
        super(`Memory ${id} is user-authored and eviction-immune. Pass force: true to delete.`);
        this.id = id;
        this.name = 'UserAuthoredImmunityError';
    }
}
//# sourceMappingURL=types.js.map