/** * Canonical project/agent/entity recall-filter contract (FEAT-424). * * Source of truth: `contracts/schemas/retrieval-query.v1.schema.json` * `filters.project` / `filters.agent` / `filters.entity` — the ADR-005 * shared retrieval contract shipped as `@astragenie/astramem-contracts`. * That JSON Schema (and its generated `contracts/types/retrieval-query.v1.d.ts` * / `contracts/zod/retrieval-query.v1.ts` companions) is what `astramem-plugin` * and the memory SaaS backend should adopt to close FEAT-424's cross-repo * drift — see docs/recall-filters.md "Canonical contract" section. * * Why this file exists instead of importing `contracts/zod/retrieval-query.v1.ts` * directly: this repo's `tsconfig.json` scopes `compilerOptions.rootDir` to * `src/` (so `dist/` mirrors `src/`'s structure 1:1 for the published CLI — * see CLAUDE.md's `dist/cli/index.js` paths). `contracts/` lives outside * `src/`, so `tsc -p .` fails with TS6059 ("File is not under 'rootDir'") on * any direct import of the generated contracts package from daemon source. * Widening `rootDir` is out of scope for a contract-unification slice — it * would move every `dist/*` path the CLI, service installer, and CLAUDE.md * document. * * These three exports are therefore a **hand-mirrored, byte-for-byte** * reflection of the canonical schema's `filters.{project,agent,entity}` * shape (verified identical to `z.union([z.string(), z.array(z.string())])` * emitted by `contracts/generate-zod.mjs` for `project`/`agent`, and * `z.string()` for `entity`). `tests/contracts/recall-filter-parity.test.ts` * is the regression gate: it loads the canonical JSON Schema at runtime and * asserts these definitions accept/reject the same values. Any change to the * project/agent/entity filter shape MUST land in * `contracts/schemas/retrieval-query.v1.schema.json` first, then be mirrored * here — the parity test fails the build otherwise. * * FEAT-429: the three schemas below are now sourced from the single * filter-descriptor registry (`./filter-registry.ts`) instead of being * hand-defined here directly. Every existing import of these three names * (routes, MCP server, the parity test above) is unaffected — the registry * entry in `filter-registry.ts` is now the one place a project/agent/entity * shape change needs to land, and it also drives the route/MCP parsing and * the SQL WHERE-clause builder that used to be hand-rolled per surface. * * #112 (U3-local) AC-4 — scope-conflict resolution, recorded explicitly per * the issue's mandate: this slice keeps path (a), the hand-mirrored + * parity-tested copy described above, and treats it as satisfying "consume * the package" in spirit. `rootDir` is NOT widened and no runtime import from * `contracts/` into `src/` was added. Parity coverage was extended to every * additional field this issue touches: * - `filters.type` — `search.ts` now imports `MEMORY_TYPES` from * `src/contracts/memory.ts` (the existing single source of truth for the * type union) instead of re-declaring it; `recall-filter-parity.test.ts` * gained a case asserting that union stays byte-identical to this same * canonical schema's `filters.type` enum. * - `text`/`limit` (POST /recall's ADR-005 field names) vs. the legacy * `query`/`k` spellings — a plain field-name alias, not a shape mirror; * covered by request-level tests in `tests/server/search.test.ts` rather * than an ajv parity case, since both names already resolve to the exact * `string`/`integer` types the canonical schema declares. */ import type { z } from 'zod'; /** * `filters.project` — exact match on `memories.project`. A single string is * `project = ?`; a string[] is `project IN (...)` (OR-semantics). An empty * array is "no constraint", never match-nothing. Absent -> all projects. */ export declare const ProjectFilterSchema: z.ZodOptional]>>; /** * `filters.agent` — exact match on provenance `agent`/`agent_type`. A single * string is `agent = ?`; a string[] is `agent IN (...)` (OR-semantics). * AND-composes with `project` when both are present. Absent -> all agents. */ export declare const AgentFilterSchema: z.ZodOptional]>>; /** * `filters.entity` — entity name filter (FEAT-402), resolved via the * normalize seam (case/whitespace-insensitive, exact match then substring * fallback). An unresolvable name yields zero results, not an unfiltered set. */ export declare const EntityFilterSchema: z.ZodOptional; /** * `filters.repo` — atom@2 repo/project consolidation (plan 20260709): * accepted as a UX-alias input only (CLI/MCP/API back-compat) and folded * into `project`'s OR-list at the SQL boundary (src/search/search.ts's * `mergeRepoAlias` call site) — never its own `memories.repo` SQL column. * Scalar string only (no OR-list semantics on the input side). Absent -> * no additional constraint beyond whatever `project` already carries. */ export declare const RepoFilterSchema: z.ZodOptional; /** * `filters.since` — epoch-ms lower bound on `memories.created_at` * (inclusive, `created_at >= since`). Absent -> no lower bound (FEAT-429 * SLICE-B). */ export declare const SinceFilterSchema: z.ZodOptional; /** Convenience bundle for surfaces that accept all registry filters as a group — built from the registry. */ export declare const RecallFilterFieldsSchema: z.ZodObject>>, z.core.$strip>; export type RecallFilterFields = z.infer;