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
//! Tenant-scoped session-variable helper for the RLS-enforced
//! `entelix_vectors` table (invariant #11 defense in depth,
//! mirroring 's treatment of the
//! `entelix-persistence` and `entelix-graphmemory-pg` tables).
//!
//! Every tenant-scoped query opens a transaction, calls
//! [`set_tenant_session`] to stamp `entelix.tenant_id` for the
//! duration of the transaction, runs its query, and commits.
//! `set_config(name, value, true)` mirrors `SET LOCAL` semantics
//! — the variable is scoped to the enclosing transaction; pool
//! connections that return to the pool carry no leftover state.
//!
//! Per-companion replication of the helper (rather than a
//! centralised crate) is deliberate: `entelix-memory`
//! is sqlx-free by, and inventing a new utility crate
//! for one helper is over-engineered. The 6-line function is
//! trivial and identical across companions.
use TenantId;
use Error;
use Executor;
use Postgres;
use cratePgVectorStoreError;
/// Stamp the current transaction's `entelix.tenant_id` session
/// variable. The third argument to `set_config` is `is_local =
/// true`, scoping the assignment to the enclosing transaction
/// (mirrors `SET LOCAL` semantics). Takes the typed [`TenantId`]
/// so the policy cannot be armed with a tenantless value.
pub async