A graph model in production needs a stable snapshot, an eligibility gate and a useful route for entities absent from its embeddings.
Graph serving: handle new nodes, edge deletion and snapshot swaps
Version the graph
Store graph build ID, node-feature version, edge cutoff, model version and catalog snapshot with each recommendation. A new completion event should not partly update an embedding cache while the graph index remains old. Build and validate a new snapshot, then switch serving atomically. Publication boundaries are as important here as in warehouse backfills.
Cover cold nodes
A new lesson may have no collaborative edges. Use reviewed subject and prerequisite metadata or an editorial fallback instead of returning no result or a random embedding. Record fallback rate and its outcomes. Sparse-node slices reveal whether the fallback is actually helping.
Honor deletion
A withdrawn lesson must disappear from recommendations immediately even if it remains in a model artifact for reproducibility. Apply a serving-time eligibility gate, and schedule rebuild or deletion under the retention policy. Removing a learner’s history may require invalidating graph features and cached neighborhoods; do not treat a deleted edge as an ordinary negative preference.
Rehearse a swap
Serve graph version 47 while building version 48. Include a newly published lesson, a withdrawn lesson and one deleted learner edge. Verify every response logs one coherent version and never returns the withdrawn lesson. If the new index fails health checks, restore version 47 while preserving the withdrawal gate.
Implementation
def serve_graph_candidates(paths, published_paths, completed_paths):
return [path for path in paths
if path in published_paths and path not in completed_paths]Performance and operating cost
Filtering C candidates is O(C) expected time. Graph rebuild and embedding generation may be expensive; a versioned swap controls consistency, while the serving-time gate limits stale-index exposure at modest per-request cost.
Common Mistakes
- Do not serve a withdrawn node because it remains in a model artifact.
- Do not combine embeddings and graph edges from incompatible snapshots.
- Do not return an empty feed for every cold-start node.
