05 / 08Builder51 min lesson + lab

Retrieve, Traverse, and Synthesize

Build the answer path that combines filters, lexical search, embeddings, graph expansion, and bounded synthesis.

By the end

You can turn a question into a retrieval plan, assemble a compact evidence subgraph, and return a cited answer with useful gaps.

01

Compile the question into a plan

Before retrieving, identify the user's scope, entities, time frame, requested comparison or action, and consequence. A question about current ownership should favor active ownership edges; a question about why a decision changed needs historical claims and supersession. Save the plan so an operator can see what the engine believed the question required.

02

Build candidates with hybrid retrieval

Apply user, workspace, sensitivity, status, and time filters before content search. Combine exact lookup for names and IDs, keyword ranking for explicit language, vector similarity for conceptual matches, and graph seeds for known entities. Preserve each candidate's retrieval reason; independent methods agreeing on a source is useful evidence for reranking.

03

Expand a bounded evidence subgraph

Start from highly relevant nodes and follow only edge types useful to the question. Limit depth, fan-out, and total evidence. Traversing every neighbor creates a context explosion and increases leakage risk. Keep paths such as Project to Decision to Source so the answer can explain not only what it found but how related evidence entered the packet.

04

Rerank for relevance, authority, freshness, and diversity

A high-similarity duplicate is less valuable than an independent corroborating source. Score candidate evidence across question relevance, directness, source authority for this domain, freshness, identity confidence, and new information. Deduplicate mirrors and reserve context for conflicts or gaps that materially change the conclusion.

05

Synthesize claims with evidence attached

Ask the model to draft a set of claims, each with citation IDs, before composing polished prose. Validate that cited evidence supports the claim, then derive gaps and confidence. This claim-first sequence is more testable than producing an essay and searching for plausible citations afterward. If support fails, remove or qualify the claim.

Working reference

Commands and patterns

Search raw evidence before synthesis

gbrain search 'Why did Atlas change launch dates?' --explain

search exposes hybrid retrieval and ranking evidence without pretending the ranked snippets are already a conclusion.

Synthesize a cited answer around an anchor

gbrain think 'Why did Atlas change launch dates?' --anchor projects/atlas --json

think adds synthesis, citations, and gaps around a known slug. A configured model key is required for real synthesis; otherwise inspect gather-only output rather than claiming an answer was generated.

Inspect a bounded graph neighborhood

gbrain graph-query projects/atlas --depth 2

Shows explicit graph context separately, making it possible to compare what links add to ordinary search.

Diagnose why a known page did not rank

gbrain search diagnose 'Why did Atlas change launch dates?' --target projects/atlas

Runs the stock target-aware search diagnostic so you can repair retrieval instead of compensating with a larger synthesis prompt.

When the happy path breaks

Failure modes

01

Symptom

Graph retrieval returns a huge context packet and a vague answer.

Likely cause

Traversal has no question-specific edge allowlist, depth, or budget.

Recovery

Use a retrieval plan, follow only useful edge types, cap fan-out, and rank paths by evidence value.

02

Symptom

An answer includes citations that do not support individual claims.

Likely cause

Citations were assigned after prose generation.

Recovery

Generate claim-citation pairs first, validate support, then compose the response.

03

Symptom

Search retrieves private but semantically relevant material from another user.

Likely cause

Access filtering happened after candidate generation.

Recovery

Enforce ownership and workspace filters before lexical, vector, and graph retrieval.

Hands-on lab

Build a traceable hybrid query

Answer one relationship-heavy question and prove how every piece of evidence entered the result.

  1. 01Choose a question requiring at least two entities, one claim, and one source relationship.
  2. 02Create a retrieval plan with scope, time, entities, and allowed edge types.
  3. 03Collect candidates through exact, keyword, semantic, and graph paths.
  4. 04Rerank and select a bounded evidence subgraph.
  5. 05Generate claim-citation pairs, validate support, and compose the answer.
  6. 06Run without graph expansion and compare evidence coverage and answer quality.

Deliverable: Two query traces, one full and one graph-disabled, with a written explanation of the graph's measurable contribution.

Reusable artifact

Retrieval trace

A reusable receipt showing how a question became an evidence-backed answer.

question and normalized intent
user, workspace, access, and time scope
recognized entities and unresolved identity candidates
retrieval methods and candidate IDs
graph seeds, allowed edge types, paths, and limits
reranking factors and selected evidence
claim-citation pairs and support checks
answer, confidence, freshness, gaps, next step
latency, token use, model versions, and operation ID

Before you move on

Receipt checklist

  • Question-specific retrieval plan.
  • Candidate list with retrieval reasons.
  • Bounded graph paths attached to evidence.
  • Validated claim-to-citation map.
  • Full versus no-graph comparison.

Primary sources

Continue with the source

Home
Book
Blog
Calugaru Labs
GitHub
LinkedIn
Email
Theme