Skip to content

Canonical API

The canonical API is a small graph of contracts rather than one mandatory runtime. @samesake/core defines the config vocabulary; the capability packages own pure algorithms and ports; backends provide I/O.

PrimitivePure package surfaceCapability factory
enrichenrich, enrichRow, gates, surfaces, dirty selection, evaluationcreateEnricher
resolvecandidate scoring and clusterBatchcreateEnricher().resolve
searchplanning, grounded NLQ, filters, cutoff, rankingcreateSearch

Search and facets are one capability. Retriever may expose facets alongside retrieval; a backend chooses whether counts are exact, approximate, or unsupported.

PortOwnerResponsibility
Retriever@samesake/queryExecute a RetrievalPlan and return ranked rows; optional facets live here.
EnrichStore@samesake/enrichPersist dirty, enriched, retryable, quarantined, and dead row state.
CandidateProvider@samesake/enrichBlock a row into candidates for pure resolution scoring.
VocabProvider@samesake/querySupply known field values for grounded query constraints.

The consumer supplies model closures (EmbedFn, GenerateFn, RerankFn, and optional image grounding) from @samesake/core. The core treats model identifiers and dimensions as opaque configuration.

@samesake/core
├── @samesake/enrich ── enrich + resolve cores and EnrichStore
├── @samesake/query ── search core, Retriever, VocabProvider, facets
├── @samesake/presets ── overridable domain bundles
└── @samesake/embed ── dual-form embedder wrapper
@samesake/postgres ── reference ports, exact facets, and bundle
  1. Tier 0 — pure function. Inject model closures and call the algorithm. Your workflow or application owns persistence and scheduling.
  2. Tier 1 — capability factory. createEnricher and createSearch compose a pure core with the ports you provide.
  3. Tier 2 — batteries bundle. A backend such as @samesake/postgres wires all three primitives over one backend and exposes migration and lifecycle methods.