HTMLCSSJAVASCRIPTANGULARINTERVIEW QUESTIONSSQLPYTHONJAVAPHPHOW TOW3.CSSCC++C#BOOTSTRAPREACTNEXTJSMYSQLJQUERYEXCELXMLDJANGONUMPYPANDASNODEJSDSATYPESCRIPTANGULARJSGITPOSTGRESQLMONGODBASPAIRGOKOTLINSWIFTSASSVUEGEN AIAGENTIC AIPROMPT ENGINEERINGDOCKERKUBERNETESSPRINGSPRING BOOTUNIXSCIPYAWSCYBERSECURITYDATA SCIENCEINTRO TO PROGRAMMINGINTRO TO HTML & CSSBASHRUSTTOOLS
AI-Powered Full Stack Tutorial 0/70 lessons ~6 min read Lesson 33“React, Next.js, Node, PostgreSQL, LLMs, RAG, agents, and production AI apps”
Knowledge Graphs and Graph-Enhanced Retrieval
Priya's follow-up was fixed in Lesson 32.
Course progress0%
Focus
24 guided sections
Practice signal
Examples included
Career prep
Interview Q&A included
AI-Powered Full Stack Development · Lesson 33 · RAG, Search and Knowledge Systems
Lesson Overview
Priya's follow-up was fixed in Lesson 32. The standalone query named PostgreSQL pgvector. Hybrid search then returned chunks that mention indexes, distance operators, and a caution about filters. She asked a different question next: "What should I finish before that lesson, and which later lesson uses hybrid search?" The sentences she needed are not all inside the pgvector chunks. The curriculum says the pgvector lesson depends on embeddings and on relational modeling. The hybrid-search lesson comes after it. Those facts are edges in the catalog. A similarity search can miss an edge that was never written as a paragraph next to the entity.
Someone on the team proposed a shortcut: ask the model, at question time, to invent the prerequisite list from memory. That list looked plausible and cited nothing. Another proposal loaded the entire course graph into the prompt. The prompt included lessons Priya's tenant does not license, and the token bill jumped for a question that needed two hops.
This lesson adds a graph reader beside the vector retriever. Nodes are lessons, concepts, and documents. Edges are typed, tenant-scoped, and marked authored or extracted. Query time is a bounded walk. It is not a moment when the model inserts edges. Walk results are chunk ids and paths. They merge with vector hits. Lesson 34 still decides which of those chunks the session may read. This lesson refuses to treat a node id as permission.
Planning assumptions:
The lab graph is an in-memory adjacency list behind GraphReader. Production can store the same edges in PostgreSQL.
Default walk: depth 2, fan-out 8 per node. Both are product limits you can test.
Authored edges come from the curriculum publisher. Extracted edges come from an index-time job and must carry sourceChunkId. An extracted edge without a source is ignored.
Expansion returns ids. It does not attach chunk text. Hydrating text is a scoped read in Lesson 34 and the capstone.
No graph database vendor account is required. Cypher, Gremlin, and recursive SQL are adapter concerns.
The standalone query from Conversational Memory and Context Management is still what you embed. The graph runs when a validated lesson slot or a linked entity gives you a start node.
Learning Objectives
By the end of this lesson you will be able to:
Define a property graph as nodes, directed labeled edges, and small attributes such as trust and source chunk.
Explain which questions a vector index answers poorly: multi-hop prerequisites, "what comes next," and relations that are not restated in the chunk.
Separate an authored catalog graph from an extracted mention graph, and store trust on every edge.
Reject extracted edges that lack a source chunk id.
Traverse with an explicit depth cap, a fan-out cap, and a visited set so cycles and popular nodes stay bounded.
Apply tenantId on every hop so a reused node id in another tenant is invisible.
Score authored edges above extracted edges and decay score by depth.
Merge graph chunk ids with vector chunk ids without duplicating ids, and cap the merged list.
Keep query time read-only. Edge creation happens in publishing or ingestion, not in the ask path.
Describe local neighborhood search and why corpus-wide community summaries are a later, carefully isolated job.
Avoid placing raw node labels in the system role. Graph facts are data.
Cache an authored adjacency list only with a tenant key and a catalog version.
Test depth, fan-out, cycles, cross-tenant hops, and sourceless extracted edges without a network call.
Hand Lesson 35 a pure expander the orchestrator can run after the slot is known.
State when to skip the graph: a definitional question with no start node.
Prerequisites
Lesson 32 slots, especially lessonId, which is the usual start node.
You do not need a dedicated graph product. You need a GraphReader you can fake in tests.
What is Knowledge Graphs and Graph-Enhanced Retrieval?
A knowledge graph here is a directed graph your application stores and queries. A node is an entity with an id, a tenant, and a type such as lesson, concept, or document. An edge links two nodes with a relation such as prerequisite_of, part_of, mentions, or uses. Graph-enhanced retrieval means: find a few start nodes, walk a short distance, collect chunk ids that sit on those nodes, and union them with the chunk ids from vector or keyword search before you rerank and prompt.
The purpose is structure. Similarity finds passages that talk like the query. It does not reliably walk "A depends on B, and C uses A" unless some chunk happens to contain that whole chain. Curriculum data already has the chain. Using it is ordinary engineering.
Graphs in software are older than this wave of retrieval. Page rank, social networks, and foreign keys are graphs. What changed is the temptation to extract entities from unstructured text with a model and then trust the extraction as if a publisher had written it. That extraction is probabilistic. The walk over stored edges is deterministic. TechLearningPro keeps both, labeled by trust, and lets authored curriculum edges outrank extracted ones.
You will also hear GraphRAG used for a specific research and product pattern: extract entities, cluster them into communities, summarize each community, and answer corpus-level questions from those summaries. That global path is expensive and dangerous if communities are built from more than one tenant. This lesson implements local expansion, the neighborhood of a start node. Community summaries are named so you can recognize them, and they stay out of the ask path until a design review isolates them per tenant.
Term
Meaning in this lesson
Node
Tenant-scoped entity id
Edge
Directed relation with trust and optional source chunk
Authored
Written by the curriculum publisher
Extracted
Proposed at index time and stored only with a source chunk
Start node
Usually the lesson id from a validated slot
Fan-out
Maximum edges followed from one node
Depth
Maximum hops from the start
Graph hit
A node reached by the walk, plus chunk id, depth, and trust
Local search
Neighborhood expansion
Global search
Community summaries, deferred
Why Do We Need It?
text
Vector search on the pgvector lesson
|
v
Chunks that mention indexes, not the prerequisite edge
|
v
The model invents "finish Git" or you paste the whole catalog
|
v
Bounded walk on authored edges
|
v
Prerequisite and successor chunk ids merge with vector hits
Benefits:
Prerequisite and "what uses this" questions follow data the curriculum team already maintains.
The prompt receives a handful of extra chunks, not the catalog.
Extracted edges stay explainable because each one points at a source chunk.
A cycle in prerequisites cannot spin the request.
A node id collision in another tenant cannot pull that tenant's neighborhood into the walk.
Real World Example
TechLearningPro's catalog publisher writes edges: embeddings prerequisite_of pgvector, relational modeling prerequisite_of pgvector, and pgvector uses hybrid search. Priya's slot lessonId is the pgvector node. An outgoing walk with depth 2 and fan-out 8 follows uses to hybrid search and then to reranking. It does not step backward along prerequisite_of. The earlier lessons are incoming edges. The exercise adds edgesTo so that question returns chunk-embeddings and chunk-sql from those edges. Outgoing and incoming reads stay separate so a hop cannot reverse a prerequisite. The chunk ids that survive join the hybrid-search candidates. The reranker from Lesson 29 can prefer them because the walk marked them authored.
Microsoft's GraphRAG write-ups popularized community summaries for questions such as "what themes dominate this corpus?" Google's knowledge panels and Amazon's product graphs are curated graphs with strict schemas, closer to our authored catalog than to a fresh extraction on every question. Banks model counterparties and accounts as graphs and still authorize every read. A hospital's terminology map links a drug to a formulary document. None of those systems let an ask-time model insert an edge that bypasses the schema. Extraction, when it exists, is a pipeline with a human or a validator in front of the store. TechLearningPro uses the same split. The publisher path is how prerequisites ship. The extractor path is how an uploaded handbook can mention a lesson. The ask path only reads.
Internal Working
The route already holds a session and, from Lesson 32, a validated lessonId slot. If there is no start node, the orchestrator skips expansion and uses vector candidates alone.
The expander calls GraphReader.edgesFrom(tenantId, nodeId). The reader returns only edges stored for that tenant. A shared platform catalog is a tenant id such as platform, not a query without a tenant.
Edges are filtered. extracted without sourceChunkId is dropped. Relations outside the known set are dropped.
From each node the walk takes at most maxFanout edges. Authored edges sort ahead of extracted edges so the cap keeps the catalog links when a popular node has many mentions.
Newly reached nodes enqueue with depth + 1. Nodes already visited are not enqueued again. The walk stops enqueueing when depth would exceed maxDepth.
Each accepted hop becomes a GraphHit with nodeId, chunkId, depth, trust, and a short via string such as prerequisite_of. chunkId may be null for a pure concept node. Null chunk ids do not enter the merge list.
mergeCandidates unions vector chunk ids and graph chunk ids. It keeps the first occurrence, prefers graph ids that are authored when trimming to limit, and never invents an id.
The orchestrator hydrates chunk text with the Lesson 34 visibility check. This package does not return text.
Index time, a separate job, may call a model to propose edges as JSON. Valid proposals insert rows with trust = extracted and the chunk they came from. Invalid JSON inserts nothing. The ask path does not run that job.
Logs record tenant id, start node ids, hit count, and the caps. They do not record full extracted labels at info level.
Filter trust, cap fan-out, cap depth, mark visited
|
v
GraphHit list
|
v
mergeCandidates(vectorChunkIds, graphHits, limit)
|
v
Scoped hydrate in the next lesson
|
x The model does not write edges here
Request flow on the ask path is read-only. Response flow is a list of chunk ids plus path metadata the trace can store. Component interaction: memory supplies the start id, hybrid search supplies vector ids, the expander supplies graph ids, the merge function returns the union, and the visibility layer loads text.
Deep Dive
What an edge means
prerequisite_of points from the lesson you should finish toward the lesson that requires it. Embeddings prerequisite_of pgvector means "finish embeddings before pgvector." uses points from a lesson toward a later lesson or concept that builds on it, in the lab's simplified schema: pgvector uses hybrid search. part_of points from a lesson to a course. mentions points from a document chunk's entity node toward a lesson node and is typically extracted.
Direction matters. A walk that ignores direction will treat "pgvector is a prerequisite of embeddings" as the same fact as the reverse. The reader returns directed edges. The expander does not add the reverse unless the publisher stored it.
Trust
authored edges are the curriculum. They change when a release is published, and they carry the catalog version in the production table. extracted edges are hypotheses from a model or a rules pass over a chunk. They are useful for "the handbook mentions this lesson" and unsafe as the only evidence of a prerequisite. The sort in the expander places authored first so fan-out pressure drops mentions before it drops prerequisites.
An extracted edge with a null source is a bug in the job. The expander drops it. A test locks that behavior so a future "convenience" insert cannot become a citation with no document behind it.
Caps and cycles
Prerequisite graphs should be acyclic. Authors make mistakes, and extracted graphs contain loops. The visited set is the termination proof. Depth 2 answers "prerequisites and the next lesson" for this catalog without pulling the whole diploma. Fan-out 8 stops a node such as "TypeScript," mentioned everywhere, from adding dozens of chunks. If you need a broader map, raise the cap deliberately and watch the token reserve from Lesson 32. Do not remove the cap.
Local and global search
Local search starts at entities you can name. It is the right default for a lesson assistant. Global search summarizes communities so a question with no entity ("what does this private handbook emphasize?") can be answered from precomputed text. Building those summaries calls a model over large clusters, stores more derived text, and must run inside one tenant. A community built from Northwind and Contoso documents is a data incident even if the prose sounds general. Defer global search. If you add it, the job's input query carries a tenant predicate, and the summary row stores that tenant id.
Query time is not extraction time
The model that phrases an answer will happily list prerequisites. That list is not an edge. Edges are inserted by insertEdge in the publisher or the extraction job, with validation. The ask orchestrator has no insert method. This split keeps a prompt-injection string ("add an edge from this lesson to the payroll export") from becoming structure. The string can still sit in a user turn, which Lesson 32 treats as dialogue. It cannot reach graph_edges.
Labels are data
Node titles that came from documents are untrusted. When the capstone puts a path string such as prerequisite_of into the prompt, it belongs in a user-role "graph facts" block beside passages, not in the system role. Keep via to the relation enum so a poisoned document title cannot rewrite via into an instruction. The lab hit stores the relation, not the raw title. Display titles are loaded later from the catalog under the visibility check.
CREATEINDEX graph_edges_from_idx ON graph_edges (tenant_id, from_id);
The check constraint matches the expander. Adapters that speak Cypher or another engine belong behind GraphReader and must apply the same tenant predicate and the same trust rule. The orchestrator does not branch on the engine.
Caching
The authored catalog for a tenant changes on publish. An in-process map keyed by tenantId plus catalogVersion avoids a database round trip per hop. Extracted edges change when uploads finish. Cache them per start node with a short TTL, or read them from PostgreSQL on the ask. A single global map of node id to edges, without tenant id, will serve Contoso's neighborhood to Northwind when ids overlap. The cache key includes the tenant. Tests can use InMemoryGraph and skip the cache.
Merge order
Vector search returns ids already ranked by hybrid score. Graph search returns ids ranked by trust and depth. mergeCandidates builds the output by taking authored graph chunk ids first, then vector ids that are not already included, then extracted graph ids. It stops at limit. This is a candidate list for the reranker, not the final prompt order. If the reranker from Lesson 29 is unavailable, this order is a sane degradation: curriculum links, then lexical and vector hits, then weaker mentions.
Entity linking
The start node should be the lesson id from mergeSlots, not a string the model free-typed on the ask path. Title-to-id lookup uses the catalog table. If two lessons share a title inside a tenant, refuse to start the walk from the title alone and require the id. Ambiguous links are how a walk begins at the wrong node and looks confident.
Code Examples
Place the package in packages/knowledge/src/graph/. The ask orchestrator depends on expand.ts. Publishers depend on insertEdge.
insertEdge is the write gate for jobs and publishers. The ask route does not import it. Rejection is how a bad extraction batch fails closed instead of storing a half edge.
The prerequisite test starts at embeddings because the stored edge points from embeddings to pgvector. Walking only outward from pgvector answers "what uses this lesson." If the product question is "what are the prerequisites of pgvector," store or also index the reverse lookup the publisher intends, for example edges queried by to_id. The reader in production can expose edgesTo for that question. The lab makes the direction explicit so you do not pretend an undirected bag of links is a prerequisite list.
Add edgesTo when you implement the publisher query. Keep the same tenant filter and caps.
Upload chunk --> extraction JSON --> insertEdge(trust=extracted) or rejected
Ask route -----x----> insertEdge
Real-Time Enterprise Example
On each ask, the TechLearningPro orchestrator expands only when slots.lessonId is present. The platform catalog tenant is platform. A customer-specific upload graph uses the customer tenant id. The walk never unions those readers without an explicit allow in Lesson 34. Hit chunk ids are written on the Lesson 31 trace as ids, together with depth and trust, so an evaluator can see that a prerequisite chunk arrived from the graph rather than from similarity.
When the catalog release flips catalog_version, the process drops its adjacency cache for that tenant. In-flight requests finish on the version they read at the start of the request. You do not mutate the array the walker is iterating.
Challenge: a popular concept node and a strict token budget. Fan-out 8 and merge limit 12 keep the candidate list inside passageTokenReserve after hydration trims text. If the reranker is down, the merge order still puts authored chunks first. You do not raise fan-out to 200 to "be complete" on a learner-facing request. A staff curriculum browser can page through edges with a different endpoint that does not call the model.
A second constraint: the extraction model is unavailable during ingest. The job stores the chunk and zero extracted edges. Search still works through vectors and authored edges. The job does not block the upload on extraction, and it does not write a placeholder edge.
Performance Optimization
The hot path is a few indexed lookups, not a model call. edgesFrom hits (tenant_id, from_id). Depth 2 with fan-out 8 reads at most 1 + 8 nodes' edge lists in the worst shape, and fewer when the visited set bites. That is small next to embedding the query.
Cache authored adjacency by tenantId and catalogVersion. Do not cache extracted edges for a long time, because uploads arrive all day. Do not build the cache at process start by scanning every tenant. Load a tenant on first use.
Skip expansion when there is no start id. A definitional question pays for hybrid search only. Record graph_skipped=no_start on the trace so a quality drop is explainable.
Community detection, entity extraction, and summary generation belong on the ingest queue from the background-jobs lessons, with a tenant on the job payload. They must not run inside the ask request. CPU on the ask path stays in the walk and the merge, both of which allocate bounded arrays.
If you later push the walk into a recursive SQL query, keep the depth cap in SQL so a bad edge set cannot return a million rows to Node. The application caps remain even if the SQL cap fails open. Defense in depth here is two limits, not a hope that the planner is careful.
Security
Authentication. The expander does not establish identity. It receives tenantId from the session scope.
Authorization. A node id is not a grant. Every hop filters on tenant. Chunk text is loaded later by the visibility function.
Tenant isolation. Contoso edges are not returned for a platform or Northwind walk. Tests cover colliding node ids.
Integrity.insertEdge rejects sourceless extracted edges, self-loops, and unknown relations. The ask path cannot call it.
Injection. Relation names are an enum. Document titles are not copied into via. Graph facts in the prompt are data in a non-system message.
Least privilege. The ask role can SELECT edges for the session tenant and the licensed platform catalog. The publisher role can insert authored edges for a release. The extractor role can insert extracted edges for the upload's tenant only.
Derived data. Community summaries, if you add them, are tenant-scoped rows with the same isolation as chunks.
OWASP issues that match: broken object level authorization on node ids, and injection if labels are promoted into instructions. The controls are the tenant predicate, the enum, and the read-only ask path.
Common Mistakes
Asking the model to invent prerequisites at question time. Symptom: a fluent list with no chunk ids. Cause: the graph was skipped. Fix: walk stored edges and cite the chunks on those nodes.
Undirected hops. Symptom: the assistant says pgvector is a prerequisite of the embeddings lesson. Cause: the walk followed edges backward. Fix: honor direction, and add edgesTo explicitly for "what points at this node."
No depth cap. Symptom: one question loads a whole diploma. Cause: recursion until the component ends. Fix: maxDepth.
No fan-out cap. Symptom: the concept "TypeScript" adds hundreds of chunks and blows the passage budget. Cause: every edge was a candidate. Fix: maxFanout, authored first.
No visited set. Symptom: a cycle pegs the CPU. Cause: extracted edges loop. Fix: mark nodes visited before enqueueing.
Extracted edges without sources. Symptom: a citation that opens no document. Cause: the job stored a hunch. Fix: reject on insert and drop on read.
A global node cache. Symptom: another tenant's runbook chunk id appears. Cause: the map key was the node id alone. Fix: key by tenant id and catalog version.
Writing edges from the ask handler. Symptom: a user sentence becomes structure. Cause: the model output was inserted. Fix: insert only in publisher and ingest jobs.
Putting node titles in the system prompt. Symptom: an uploaded PDF changes assistant policy. Cause: labels were treated as instructions. Fix: relation enums in a data block.
Replacing vectors with the graph. Symptom: "What is an embedding?" fails because the definition chunk is not a neighbor of a slot. Cause: expansion was the only retriever. Fix: merge with hybrid hits, and skip the graph when there is no start node.
Building cross-tenant communities. Symptom: a summary mentions another customer's handbook. Cause: the clustering job scanned graph_edges without tenant_id. Fix: defer global search, and predicate every job.
Hydrating chunk text inside the expander. Symptom: instructor-only text enters the prompt before the visibility check. Cause: the graph package grew a shortcut. Fix: return ids. Lesson 34 loads text.
Best Practices
Store directed, typed edges with a tenant id.
Mark every edge authored or extracted.
Require a source chunk on extracted edges.
Publish curriculum edges through a release, not through the model on the ask path.
Start walks from validated lesson ids.
Cap depth and fan-out.
Visit each node once.
Sort authored edges ahead of extracted edges before applying fan-out.
Keep query-time expansion read-only.
Merge graph chunk ids with vector chunk ids and cap the union.
Let the reranker make the final order when it is healthy.
Skip the walk when no start node exists, and trace that skip.
Filter tenant_id in the reader, not after the prompt is built.
Cache authored adjacency with tenant id and catalog version.
Keep extracted-edge cache TTLs short, or skip that cache.
Validate extraction JSON before insert. Store nothing when parsing fails.
Put graph facts in a data block, using the relation enum.
Record depth, trust, and chunk ids on the evaluation trace.
Add edgesTo as an explicit query when the product asks for incoming prerequisites.
Fail the extraction job soft so uploads still become searchable through vectors and authored edges.
Keep community summaries out of the learner ask path until they are per tenant.
Test colliding node ids across tenants on every change to GraphReader.
Interview Questions & Answers
Beginner
What does the graph add that vectors do not?
Vectors find chunks whose text is similar to the query. The graph follows stored relationships such as prerequisites and "uses" even when those relationships are not written inside the chunk you matched. You still keep vectors for definitional questions.
What is the difference between an authored edge and an extracted edge?
An authored edge is published with the curriculum. An extracted edge is a structured guess from a document, stored only with the chunk it came from. The walk prefers authored edges when fan-out is tight. Extracted edges without a source are dropped.
Why is the ask path not allowed to insert edges?
Inserts are how a sentence becomes durable structure. A learner message, including one that says to link a lesson to a private document, stays in the conversation. Edges change only in the publisher and the ingest job, after validation.
Intermediate
How do you stop a walk from exploding?
Cap the depth, cap the edges followed from each node, and record visited node ids so cycles terminate. Sort authored edges first so the fan-out budget spends itself on curriculum links. Cap the merged candidate list again before hydration.
Why can a prerequisite question miss if you only walk outward from the lesson?
Direction is part of the fact. If the edge is embeddings prerequisite_of pgvector, a walk that starts at pgvector and follows outgoing edges will not step back to embeddings. You add a reader method that fetches incoming edges and you test it. You do not silently treat every edge as bidirectional.
What is local search versus global GraphRAG-style search?
Local search expands the neighborhood of a known entity and returns chunk ids. Global search answers corpus-level questions from community summaries built ahead of time. The assistant uses local search. Global summaries are a separate, tenant-scoped batch if you ever need them.
Senior
How would you test a new graph adapter?
Point the same tests at it: depth cap, fan-out preference for authored edges, cycle termination, sourceless extracted edges ignored, and a foreign tenant's edge hidden when node ids collide. The in-memory reader is the contract. An adapter that can only pass by returning every edge in the database is wrong even if the happy path looks smarter.
Where should extraction failures land?
On the ingest job, as a counted metric, with the chunk still searchable by hybrid retrieval and still attached to authored edges. The ask path does not wait for extraction and does not fabricate an edge because the job failed. A retry of the job is idempotent on the primary key (tenant_id, from_id, relation, to_id).
Architect
How does this stay compatible with permissions?
The expander returns ids inside one tenant walk. It does not return text. The visibility function loads text and may drop an id the graph could see at the platform layer but the learner cannot open, such as an instructor note. Lesson 34 is the decision. The graph is a candidate generator. Candidate generators are a common place to leak, so the hydrate step checks again.
When would you adopt a dedicated graph database?
When traversals deeper than this catalog, or heavier analytics, stop fitting comfortable indexed lookups in PostgreSQL, and an adapter can still enforce tenant, trust, depth, and fan-out. Until then the table is easier to back up, authorize, and test with the rest of the product. The orchestrator depends on GraphReader either way.
Knowledge Check
1. What problem does this capability solve?
Similarity search misses structured curriculum facts that live as relationships rather than as wording in one chunk. A bounded graph walk adds those neighboring chunk ids to the candidate list without pasting the catalog into the prompt.
2. What alternatives exist, and when would you choose each?
Vectors alone fit definitional questions and small corpora with no reliable edges. A fully authored graph fits a curriculum you already edit. Extraction fits uploaded documents whose relationships were never modeled, with a lower trust and a source chunk. Global community summaries fit offline theme questions inside one tenant. Ask-time invention of edges fits none of these.
3. Which data, identity, and trust boundaries matter?
Edges carry tenant_id. Start nodes come from validated slots. Extracted edges carry a source chunk. The ask role reads. The publisher and extractor write on their own paths. Chunk text stays behind the visibility check. Relation labels in the prompt are the enum, not raw document titles.
4. What can fail, and how should the system respond?
A missing start node skips the walk. A cycle ends through the visited set. Fan-out and depth caps truncate the neighborhood. A bad extracted edge is rejected at insert and ignored if it is already in a fake. A foreign tenant contributes no hops. If the edge store is down, retrieval continues with vector candidates and the trace records graph_unavailable.
5. How would you test quality, security, performance, and cost?
Unit tests cover direction, depth, fan-out, cycles, sourceless edges, merge order, and cross-tenant node ids. Quality review checks that prerequisite questions cite the neighbor chunks on a labeled eval set. Performance review checks that the ask path does not call an extraction model. Cost review checks that fan-out cannot pull hundreds of chunks into the passage budget.
Practical Exercise
Implement packages/knowledge/src/graph/ and run the tests. Add edgesTo on the reader and a test that a walk for prerequisites of pgvector returns chunk-embeddings and chunk-sql using incoming prerequisite_of edges. Keep the tenant filter. Write two sentences on why that method must not follow edges in both directions at once.
Deliverable and Rubric
Submit the diagram of ask path versus index path, the graph package, the test output, and a short note on depth, fan-out, and why community summaries are deferred.
Area
Weight
Conceptual accuracy and architecture
20%
Working implementation and code quality
25%
Security, privacy, and responsible AI
20%
Testing, reliability, and observability
20%
Documentation and decision rationale
15%
Key Takeaways
Graph-enhanced retrieval adds structured neighbors. It does not replace hybrid search.
Incoming and outgoing reads are different methods.
Merge candidates, then let visibility and reranking continue.
Return chunk ids, not chunk text.
Cache with a tenant key and a catalog version.
Skip the walk when there is no start node.
Keep community summaries off the learner ask path.
Relation enums are the only graph strings that belong near the prompt.
The capstone calls this expander after memory and before the answer model.
Summary
Lesson 33 gives TechLearningPro a way to follow the curriculum. Prerequisites and successor lessons are edges with a tenant, a direction, and a trust level. The ask path walks a short distance from a validated lesson id, merges chunk ids with vector hits, and leaves permission to the next lesson. Extraction can enrich uploads later, on a job, with a source chunk or not at all. The assistant you ship in the capstone can cite a prerequisite because the publisher stored it, not because a model guessed it under pressure.
Next Lesson Preview
Enterprise RAG: Permissions, Tenancy and Data Isolation is the gate in front of every chunk id this walk can produce. You will build an access scope from the session, filter retrieval before any prompt is assembled, and prove with a test that the nearest chunk in another tenant never reaches the model. The graph and the memory store stay useful only if that filter holds.
Further Reading
PostgreSQL WITH queries if you later move the bounded walk into recursive SQL. Keep the depth cap in the query.
Vendor documentation for any graph engine you place behind GraphReader. Record the URL and the date in the adapter. The orchestrator tests stay on the in-memory contract.
Ready to mark this lesson complete?Track your journey across the entire course.