The system. A semantic product search service for several retailer tenants. Each tenant's catalogue is its own tenant within a collection; queries combine keyword and vector retrieval so that both "a quiet keyboard for an open-plan office" and "KB-4471-B" work; results are filterable by brand, price and availability; and a reranker improves the top results. Most tenants are small and idle; a few are large and busy.
Three invariants must hold:
- Measured relevance meets a declared threshold on a ground-truth set, reported separately for conceptual and exact-match queries, at the configuration actually deployed - including the quantiser and the
ef. - No query can return another tenant's data, and no query can execute without a tenant, both proved by tests through every code path.
- The memory footprint is within the declared budget at the declared object count, verified by measurement, with the quantisation and
efchosen from the Module 4 surface rather than defaulted.
Invariant 3 is this capstone's distinguishing requirement and the one that separates it from the Pinecone capstone. There, capacity was someone else's problem and cost was read units. Here you are sizing the hardware, and the recall you chose is the memory you pay for - so the design must show the trade-off it made and the numbers it made it on.
What is assessed. 20% knowledge checks, 35% laboratory portfolio, 15% troubleshooting practical, 30% capstone. Three things carry the capstone.
Relevance measured at the deployed configuration. Not at the defaults, and not unquantised: the recall you report must be the recall of the collection as configured, including the quantiser, the rescore_limit and the ef. A relevance number measured on an unquantised index and a deployment that uses binary quantisation is a false claim, and it is an easy one to make by accident.
A priced recall trade-off. The Module 4 surface, the point you chose on it, and the hardware consequence: "SQ at ef 256 gives 0.95 recall at 18 ms in three 64 GB nodes; unquantised gives 0.96 at 26 ms in three 160 GB nodes; we take SQ."
Tenant isolation proved, and the tenant lifecycle used. The isolation tests, plus the memory measurement showing INACTIVE tenants costing nothing - because hosting many idle tenants cheaply is the architectural reason to choose this design and the capstone should demonstrate it working.
Deliverables: architecture diagram including the vectoriser and reranker path; the collection schema with every indexing and skip flag justified; the ground-truth set split by question type; the evaluation harness; the Module 4 quantisation surface; source code including the single tenant code path, batch import with failure handling and the hybrid query configuration; reproducible catalogue; benchmark report with relevance at the deployed configuration and the tenant lifecycle memory measurements; security review including the RBAC definitions and the isolation tests; recovery runbook with measured RPO and RTO and both restore traps covered; sizing and cost plan with the managed comparison; and a short design defence.
# ================= Invariants, as runnable checks ==================
# 1. *** RELEVANCE AT THE DEPLOYED CONFIGURATION. *** Not at the
# defaults, and NOT UNQUANTISED.
DEPLOYED = {
"quantizer": "sq", "rescore_limit": 200,
"ef": 256, "ef_construction": 256, "max_connections": 32,
"alpha": 0.6, "fusion": "RELATIVE_SCORE", "rerank": True,
}
def assert_relevance(coll, gt_conceptual, gt_exact, thresholds):
cfg = coll.config.get().vector_index_config
# *** CONFIRM THE COLLECTION IS ACTUALLY IN THE DEPLOYED
# *** CONFIGURATION BEFORE MEASURING. This assertion is the one
# *** that prevents the false claim. ***
assert cfg.ef == DEPLOYED["ef"], (cfg.ef, DEPLOYED["ef"])
assert cfg.quantizer is not None, "measured on an UNQUANTISED index"
c = evaluate(coll, gt_conceptual, **DEPLOYED)
e = evaluate(coll, gt_exact, **DEPLOYED)
for name, got, want in [
("conceptual recall@5", c["recall@5"], thresholds["c_recall5"]),
("conceptual mrr", c["mrr"], thresholds["c_mrr"]),
("exact recall@5", e["recall@5"], thresholds["e_recall5"]),
("exact mrr", e["mrr"], thresholds["e_mrr"]),
]:
assert got >= want, f"{name}: {got:.3f} < {want:.3f}"
return c, e
#
# *** A RELEVANCE NUMBER MEASURED ON AN UNQUANTISED INDEX AND A
# *** DEPLOYMENT THAT USES BINARY QUANTISATION IS A FALSE CLAIM -
# *** AND IT IS AN EASY ONE TO MAKE BY ACCIDENT ***, because the
# obvious way to benchmark is on a clean collection. The assertion
# above is cheap and it closes that door.
# 2. *** NO CROSS-TENANT READ, AND NO TENANTLESS QUERY. *** Both,
# through every code path.
def test_tenant_isolation():
acme = Principal(tenant_id="acme")
coll = client.collections.get("TenantProduct")
# Seed something only globex has, with a distinctive token:
coll.with_tenant("globex").data.insert(
properties={"title": "Globex internal zorblatt-9981",
"sku": "GX-9981", "brand": "Globex",
"categories": ["internal"], "price": 0.0,
"in_stock": False,
"released": "2026-01-01T00:00:00Z"},
uuid=generate_uuid5("GX-9981"))
wait_for_index_queue_to_drain() # Module 6: objects can be
# stored and not yet
# searchable
# (a) NO CROSS-TENANT READ, through EVERY entry point:
for fn in (search, autocomplete, facet_counts, export_results):
got = fn(acme, "zorblatt-9981")
assert not any("GX-9981" == o.properties.get("sku")
for o in objects_of(got)), fn.__name__
# (b) *** NO TENANTLESS QUERY. *** This must RAISE, and the fact
# that it raises is the architectural argument:
try:
coll.query.hybrid(query="zorblatt-9981", alpha=0.6, limit=10)
assert False, "a tenantless query was served"
except Exception as e:
assert "tenant" in str(e).lower(), e
# (c) a principal with no tenant is REFUSED, not defaulted:
try:
search(Principal(tenant_id=None), "anything")
assert False, "a principal with no tenant was served"
except PermissionError:
pass
# Structural check: EXACTLY ONE call site computes a tenant.
# grep -rn 'with_tenant(' src/ | grep -v 'with_tenant(tenant_for' | wc -l
# -> 0
# 3. *** MEMORY WITHIN THE DECLARED BUDGET, VERIFIED BY
# *** MEASUREMENT. ***
def assert_memory_budget(budget_gb):
used = resident_memory_gb()
assert used <= budget_gb, f"{used} GB > {budget_gb} GB budget"
# And the tenant lifecycle, which is WHY this design was chosen:
# 200 tenants ACTIVE ___ GB
# 10 ACTIVE / 190 INACTIVE ___ GB <- the architectural
# capability, measured
# first query to a reactivated tenant ___ ms
# ================= Declare the baseline BEFORE measuring ==========
#
# Deployment: 3 nodes, RF=3, Docker/Kubernetes, self-hosted
# Vectoriser: text2vec-transformers, LOCAL (nothing leaves the
# boundary - a privacy decision, stated)
# Metric: cosine (as the model specifies)
# Collection: multi-tenancy ENABLED, auto creation and activation,
# DYNAMIC index (flat below 10,000, HNSW above) because
# MOST TENANTS ARE SMALL
# Index: ef_construction=256, max_connections=32 (set BEFORE
# the import, because changing them means a rebuild)
# Quantiser: SQ, rescore_limit=200
# Search ef: 256
# Retrieval: hybrid alpha=0.6, RELATIVE_SCORE fusion,
# query_properties=["sku^3","title^2","description"],
# reranker module over 50 candidates -> top 10
# Objects: 20,000,000 across 200 tenants (Zipf-distributed, so
# a few tenants hold most of it - a UNIFORM test
# distribution does not exercise the lifecycle)
#
# DECLARED THRESHOLDS - invariant 1, AT THE DEPLOYED CONFIG:
# conceptual exact-match
# recall@5 >= 0.92 >= 0.93
# recall@10 >= 0.96 >= 0.97
# MRR >= 0.85 >= 0.88
#
# LATENCY, split by component:
# vectorise the query p95 < 30 ms
# hybrid retrieval p95 < 25 ms
# rerank (50 cands) p95 < 150 ms
# end to end p95 < 220 ms
#
# MEMORY - invariant 3:
# budget <= 135 GB total across 3 nodes
# measured, 200 tenants ACTIVE ___ GB
# measured, 190 INACTIVE ___ GB
#
# CONSISTENCY, per operation (Module 5):
# product search ONE (staleness acceptable, measured)
# stock check QUORUM (it is not)
# catalogue write QUORUM
# measured stale-read rate at ONE ___ %
#
# RPO/RTO: restore from backup ___ min (exact vectors)
# rebuild from source ___ min (current module version)
# -> and WHICH the runbook performs, and why
# ================= *** THE PRICED RECALL TRADE-OFF *** ============
# From the Module 4 surface, the point chosen and its hardware
# consequence - this paragraph is the capstone's centre:
#
# "Unquantised at ef=256 gives conceptual recall@5 0.96 at 26 ms
# p95 and needs 3 x 160 GB nodes. SQ with rescore_limit=200 at
# ef=256 gives 0.95 at 18 ms and needs 3 x 64 GB. BQ with
# rescore_limit=400 gives 0.91 at 13 ms and needs 3 x 48 GB.
#
# We take SQ: one point of recall for 60% less memory, and the
# memory saved is what lets us host 200 tenants on three nodes.
# BQ's four-point drop is below our declared threshold, so it is
# not available to us at this model - though it would be if we
# raised rescore_limit further, at a latency we have not
# budgeted for."
#
# *** THAT IS THE PARAGRAPH THE WHOLE COURSE EXISTS TO MAKE
# *** POSSIBLE: a relevance decision, a measured alternative, and a
# *** hardware price. ***
# ================= Failure modes ==================================
# *** WRONG RESULTS, NO ERROR the characteristic vector
# failure. Only a SCHEDULED
# relevance measurement detects
# it. ***
# relevance measured on an *** A FALSE CLAIM. *** Assert the
# unquantised index configuration before measuring.
# ef too low silently poor recall. The
# commonest self-hosted problem.
# ef_construction changed after NO EFFECT. Set it before the
# the import import, or reimport.
# max_connections changed requires an index REBUILD.
# quantiser enabled without recall drops hard and nobody
# rescoring looks. 0.71 vs 0.91 for BQ.
# PQ enabled before enough data a poorly trained codebook. It
# needs a training set.
# non-semantic props vectorised diluted vectors. 0.74 vs 0.89.
# exact SKU, vector only hybrid with a weighted sku
# property, or BM25.
# selective filter recall drops. The dynamic/flat
# index, or a higher ef.
# index queue behind an import objects stored and NOT
# SEARCHABLE. Looks like missing
# data. Watch the queue.
# partial batch failure silently dropped objects. Check
# failed_objects, retry with
# deterministic UUIDs.
# tenantless query *** AN ERROR - which is the
# point, and better than a
# namespace design. ***
# tenant from a request param THE WRONG DATA. One code path.
# anonymous access left on anyone can DROP A COLLECTION.
# shard count outgrown NO RESHARDING. New collection,
# reimport. Hence multi-tenancy,
# where tenants ARE shards.
# restore with the collection REFUSED. Drop first, or restore
# present elsewhere and repoint.
# restore without the module REFUSED. The compose file is
# part of the backup.
# upgrade with an index format a rolling upgrade becomes a
# change REIMPORT. Read the release notes.
# model changed in a module THE VECTORS CHANGE and recall
# image moves silently. Pin the image
# tag, and re-measure after any
# bump.
#
# Verify after every restore and every upgrade with invariant 1, not
# with an object count. A full collection with the wrong vectors
# looks exactly like a correct one.
Open this example in the editor and change it. Nothing you type is saved.
Discussion
No questions on this topic yet. Sign in to ask the first one.