import type { RequestHandler } from 'express'; import { z, type ZodError } from 'zod'; import { LemmaApiError } from '../../../contracts/errors.js'; import type { CreateMemoryRequest, MemoryClaim, MemoryState } from '../../../contracts/api-v2.types.js'; import type { Evidence } from '../../../contracts/evidence.js'; import type { BrainStore } from '../../../contracts/store.js'; export declare const MAX_CLAIMS = 50; export declare const MAX_VERIFY_IDS = 200; export declare const MAX_BODY_BYTES = 1000000; export declare const EvidenceSchema: z.ZodObject<{ files: z.ZodRecord; symbols: z.ZodRecord; symbolsNormalized: z.ZodRecord; branch: z.ZodOptional; commit: z.ZodOptional; }, z.core.$strip>; export declare const CreateMemoryRequestSchema: z.ZodObject<{ claims: z.ZodArray>; symbols: z.ZodOptional>>; }, z.core.$strip>>; evidence: z.ZodObject<{ files: z.ZodRecord; symbols: z.ZodRecord; symbolsNormalized: z.ZodRecord; branch: z.ZodOptional; commit: z.ZodOptional; }, z.core.$strip>; derivedFrom: z.ZodOptional>; }, z.core.$strip>; /** Turns the first zod issue into the API's stable invalid_request shape — never a raw zod dump. */ export declare function zodToApiError(error: ZodError): LemmaApiError; /** What Lane C persists via `BrainStore.put`. `query`/`response` feed the store's * BM25 indexing (see FileBrainStore.searchCandidates) — same convention the v1 * Brain already writes, so a v2-written record stays searchable. */ export interface StoredMemory { claims: MemoryClaim[]; derivedFrom?: string[]; query: string; response: string; createdAt: number; } declare function isStoredMemory(v: unknown): v is StoredMemory; /** * Builds the persisted claims from the request: each claim only tracks the * files/symbols it explicitly declared, hashed from the top-level `evidence` * bundle the client supplied. A declared path/symbol with no matching hash in * `evidence` is a malformed request (the client can't establish a baseline it * never sent) — this throws `invalid_request` naming the missing field, it never * silently stores an untracked claim. */ export declare function buildClaims(body: CreateMemoryRequest): MemoryClaim[]; export interface MemoryStateResult { state: MemoryState; staleFiles: string[]; cosmeticChanges: string[]; } /** * Aggregates a memory's claims into one `MemoryState`. Precedence is worst-case * fail-closed: any claim `unverified` ⇒ the memory is `unverified` (even if other * claims are provably stale); otherwise any claim `stale` ⇒ `stale`; otherwise * `fresh`. A memory whose claims track nothing is always `fresh` (nothing to go * stale) — same as `TheBrainV2.checkClaimFreshness` for an evidence-less claim. * * `contradicted` is not produced here: detecting two stored claims about the same * subject diverging is not part of this lane's acceptance criteria (see plan §3, * Lane C) — noted under lane-notes/C.md ## decisions. */ export declare function computeMemoryState(claims: MemoryClaim[], currentEvidence: Evidence | undefined): MemoryStateResult; export interface MemoriesDeps { store: Pick; } /** POST /v2/memories */ export declare function createMemoryHandler(deps: MemoriesDeps): RequestHandler; /** DELETE /v2/memories/:id */ export declare function forgetMemoryHandler(deps: MemoriesDeps): RequestHandler; export { isStoredMemory }; export default createMemoryHandler; //# sourceMappingURL=memories.d.ts.map