1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! # entelix-memory-pgvector
//!
//! Concrete [`entelix_memory::VectorStore`] implementation backed by
//! Postgres + the pgvector extension.
//!
//! Companion to the trait-only [`entelix_memory`] crate:
//! sqlx + pgvector specifics live here so users who plug their own
//! `VectorStore` pay nothing in compile time.
//!
//! ## One-call setup
//!
//! ```ignore
//! use entelix_memory_pgvector::{DistanceMetric, IndexKind, PgVectorStore};
//!
//! let store = PgVectorStore::builder(1536)
//! .with_connection_string("postgres://localhost/entelix")
//! .with_distance(DistanceMetric::Cosine)
//! .with_index_kind(IndexKind::Hnsw)
//! .build()
//! .await?;
//! ```
//!
//! ## Multi-tenancy
//!
//! Single-table design with a composite `(namespace_key, doc_id)`
//! primary key. Every read / write / count / list rides a
//! `WHERE namespace_key = $1` anchor — invariant 11 / F2 demand
//! structural tenant isolation, and the composite PK doubles as
//! the B-tree index that anchor relies on.
//!
//! ## Schema-as-code escape hatch
//!
//! Operators that own the schema externally (DBA-managed, IaC,
//! migration pipeline) call [`PgVectorStoreBuilder::with_auto_migrate`]
//! with `false` — the builder
//! skips extension creation, table creation, and index
//! provisioning, trusting the operator to have stamped them.
// `Postgres`, `pgvector` ride through doc strings as vendor names.
// `pub(crate)` items inside private modules are the canonical
// crate-internal helper pattern.
pub use ;
pub use ;