Skip to main content

Module sharded

Module sharded 

Source
Expand description

Tenant-partitioned CSR index.

The graph engine multiplexes many tenants onto one per-core CsrIndex. Historically that multiplexing was done by prepending "{tid}:" to every node key before handing it to the CSR — a lexical scheme that required every API boundary (results, traversal output, algorithm emit) to strip the prefix on the way back out. The heuristic strippers were fragile (mangled any id that happened to match the shape) and the strip was opt-in (forgetting it leaked internal keys to clients).

ShardedCsrIndex replaces that scheme with structural partitioning: one independent CsrIndex per tenant, keyed in a HashMap<TenantId, _>. Node keys inside a partition are the raw user-visible names — no prefix, no strip, no heuristic. Cross-tenant access is not a question of auth checks; it is structurally impossible because partitions don’t share key space.

§Invariants

  • One tenant per partition. Every CsrIndex held in partitions contains only one tenant’s nodes and edges. Mixing is a programming bug, not a runtime condition.
  • No key prefixing. Callers pass user-visible names directly; the partition never sees a scoped form.
  • Partition lifecycle is explicit. get_or_create constructs on first use; drop_partition removes atomically. No auto-eviction at this layer (belongs to a future pool-management concern).
  • Data Plane shape preserved. This type is !Send in the same way CsrIndex is (via Cell<u32> access counters). It is owned by a single Data Plane core.

Structs§

ShardedCsrIndex
Per-tenant partitioned CSR index.