Toroidal Semantic Graph Retrieval
Tortus mascot — a smiling turtle whose shell is a toroidal semantic graph

Explainable multi-hop RAG · one pip install away

Tortus

Toroidal Semantic Graph Retrieval for explainable, multi-hop RAG.

“Query concepts, not just chunks. Return reasoning paths, not just citations.”

Abstract

Tortus is a local-first, package-distributable retrieval engine for explainable, multi-hop RAG over federated databases. By modeling knowledge bases as typed semantic graphs embedded onto a soft toroidal manifold, it lets developers query concepts rather than flat text chunks — and returns the exact evidence paths that connect disparate documents.

Standard RAG relies on flat vector search. It is excellent at retrieving single facts and weak when the answer requires connecting points across multiple documents. Bounded agentic loops try to fix this, but introduce latency, cost, and reliability concerns of their own.

Tortus offers the middle ground: topology-aware graph traversal without the unbounded agent loop. Wrapping axes into a toroidal neighborhood layout eliminates edge-clustering boundary effects and enables seamless portal hops between overlapping subgraphs.

Key features

Graph-aware traversal

Connects the dots across document boundaries using semantic relations and concept portals.

Deterministic local fallbacks

Runs entirely on-device out of the box with zero external configuration.

Built-in developer tooling

Interactive visual workbench, GraphQL API, and local telemetry reporting.

Empirical verification

Reproducible, multi-size scale evaluation harness ships with the package.

Try it in 30 seconds

Install Tortus, point it at your own docs, and ask the question you actually need answered.

pip install tortus-rag
tortus solve "Why did this incident happen, and what should we fix?" ./docs

Requires Python 3.12+. Runs out of the box with deterministic local embedding & synthesis — no keys required.

§1

The painful problem

The hard part of internal knowledge work is often not finding a relevant document. It is figuring out how several relevant documents connect.

In an incident review, the evidence might be split across an auth migration note, a gateway retry runbook, an observability guide, and the incident timeline. Search can find each fragment. A normal RAG answer can summarize the retrieved text. The painful part is still left to the user:

Tortus is built for that gap. It tries to answer “why did this happen?” or “what should we fix?” by returning the evidence path across documents, not only a list of matching chunks.

§2

Why current RAG fails at multi-hop

Most production RAG systems are strong at retrieving nearby text and weak at preserving relationships between ideas. That creates recurring failures:

Failure modeWhat happensWhy it matters
Chunk blindnessRetriever finds fragments but misses the path between them.Locally plausible, globally incomplete.
Boundary artifactsClusters and shards create artificial edges in the space.Cross-domain questions degrade where synthesis is needed.
Weak provenanceCitations point to documents, not to reasoning.Users cannot audit why facts were connected.
Hidden retrieval logicTraversal lives inside prompts and app code.Developers cannot inspect or constrain behavior.
Cost driftAgentic search expands until a budget stops it.Latency and LLM spend become unpredictable.
flat partitionartificial gaptoroidal wrapcontinuous
Fig. 1·Flat partitions create artificial distance between semantically near points. Toroidal wrapping preserves neighborhood continuity across boundaries.
§3

Core hypothesis · why a torus

A semantic graph embedded on a toroidal coordinate space can make retrieval more navigable by combining vector search for fast candidates, typed graph edges for explainable hops, toroidal locality for wraparound neighborhoods, GraphQL directives for developer-controlled traversal, and budget-aware synthesis over explicit evidence paths.

The torus is not treated as magic. It is a systems hypothesis to validate against measurable baselines — and replace if it does not hold.

JobExpected benefitWhat must be proven
Neighborhood traversalSmooth cyclic continuity around dense concept regions.Better multi-hop recall at equal latency.
ShardingLocality-preserving partitioning without hard semantic edges.Higher shard affinity and cache hit rate.
FederationPortal hops between overlapping subgraphs under budget.Better cross-domain path quality.
§4

Architecture

Tortus is a complete, package-distributable RAG engine designed to run locally or integrate as a service. Two pipelines — ingest on the left, query on the right — meet at the graph and toroidal embedding.

Documents · APIs · ticketsIngestion & normalizationConcept extractionTyped semantic graphToroidal embeddingANN indexGraph storeTopology shardsUser or LLM queryIntent parsingTop-k vector seedingDensity-aware traversalPortal hop plannerEvidence-bounded synthesisAnswer + reasoning path
Fig. 2·Ingest produces a typed semantic graph and a toroidal embedding; queries seed by vector, traverse by edge, hop portals under budget, and synthesize only from selected evidence.

Data model

EntityPurpose
ConceptNodeA concept, entity, claim, chunk, document section, API, decision, or event.
SemanticEdgeA typed relationship: supports, contradicts, depends_on, caused_by, implements, related_to.
SubgraphMembershipWeighted membership in domains, teams, products, sources, or tenants.
PortalEdgeA controlled cross-subgraph jump used when a query needs domain switching.
EvidenceSpanA source-backed span attached to a node or edge for traceability.
TraversalPolicyRuntime constraints: hop budget, latency, personalization, freshness, locality.
§5

Retrieval algorithm

At query time, Tortus follows a bounded retrieval plan:

  1. Parse query intent, constraints, and GraphQL directives.
  2. Generate seed candidates with ANN vector search.
  3. Map candidates to graph nodes and toroidal coordinates.
  4. Estimate local density around each seed.
  5. Expand through typed edges using a density-aware radius.
  6. Score frontier nodes with similarity, edge weight, freshness, evidence quality, and policy.
  7. Trigger portal hops when frontier coverage is low or the query implies domain switching.
  8. Select evidence paths under hop, latency, and token budgets.
  9. Synthesize an answer only from selected evidence.
  10. Return the answer, confidence, path, and degraded-mode warnings.

Traversal score

score(next) =
    semantic_similarity(query, next)
  + edge_weight(current, next)
  + evidence_quality(next)
  + freshness_bias(next)
  − traversal_cost(next)
  − uncertainty_penalty(next)

The exact scoring function is intentionally replaceable. Tortus is built to make retrieval policies easy to compare, not to hard-code one strategy.

§6

Benchmark evidence

A scale sweep over 10 public engineering sources (Kubernetes, OpenTelemetry, W3C, RFCs, the Google SRE book), split into source-preserving doclets at 50, 200, 500, and 1000 documents. At the 1000-doclet point, graph-aware strategies recovered labeled path structure that rank-only baselines did not.

Table 1 · Strategy at 1000 docs

StrategyPassSource recallPath recallp95 ms
hybrid_graph_rerank_local1.000.751.0092.5
tortus_torus0.830.750.83162.2
vector_only_local0.000.830.0019.0
bm25_local0.000.670.0098.9

Benchmark · 118 questions · 1,652 rows

StrategyPassSourcePathFaithp95 ms
tortus_torus0.800.731.000.883.4
hybrid_graph_rerank_local0.800.741.000.885.7
bounded_agentic_local0.730.670.950.893.0
graph_local0.140.580.170.882.2
llamaindex_external0.010.720.030.887.5
hybrid_dense_bm25_local0.010.730.030.881.5
vector_only_local0.010.710.030.880.8
bm25_local0.020.650.030.881.0
§7

What Tortus beats — and does not, yet

ScenarioCurrent read
Single-hop factual retrievalVector, BM25, and Tortus all perform well; Tortus may be overhead.
Multi-hop incident analysisTortus is useful — it exposes the evidence path and portal hops.
Boundary-crossing questionsTortus helps when traversal must cross domains under budget.
Unanswerable questionsTortus withholds answers when selected evidence has no lexical support.
Large-scale production searchNot yet proven. FAISS support is the first step, not the endpoint.

Useful failure modes

  • Weather or stock queries return “not enough source-backed evidence” rather than forcing a path.
  • Broad incident queries can over-expand through portals if shared terms are too generic.
  • Local-only graph policies can find sources but miss expected boundary-crossing labels.
  • Layout-only probes can retrieve nearby nodes without proving a reasoning path.
§8

Quickstart

1 · Install

# Python 3.12+
pip install tortus-rag

# optional extras
pip install "tortus-rag[baselines]"
pip install "tortus-rag[api]"

2 · Solve in one command

tortus solve "Why did this incident happen, and what should we fix?" \
  ./docs https://example.com/runbook

Creates a hidden local project under ~/.tortus/projects/, snapshots the supplied files & URLs, builds the graph and vector index, traverses the evidence path, and returns a cited diagnosis, the likely root-cause path, recommended actions, and missing-evidence warnings.

3 · Try the packaged demo

tortus ingest --corpus acme-payments-demo --data-dir .tortus/acme-demo
tortus index  --corpus acme-payments-demo --data-dir .tortus/acme-demo
tortus query "What should Acme fix to stop EU refund trace fragmentation?" \
  --corpus acme-payments-demo --data-dir .tortus/acme-demo --explain

4 · Open the dashboard

pip install "tortus-rag[api]"
tortus serve --port 8010
# → http://127.0.0.1:8010

5 · Or use it from Python

import tortus
from tortus.config import Settings
from tortus.pipeline import build_index, load_engine

settings = Settings(TORTUS_CORPUS="public-engineering")
build_index(settings)
engine = load_engine(settings)

result = engine.answer("How do service accounts connect to tracing?")
print(result.answer)
for hop in result.reasoning_path:
    print(f"{hop.from_node} --[{hop.edge_type}]--> {hop.to_node}")
§9

Principles we ship by

  • Make retrieval inspectable before making it clever.
  • Treat LLMs as synthesis and policy helpers, not hidden databases.
  • Return evidence paths for claims that cross concepts.
  • Put budgets in the API, not only in deployment config.
  • Prefer replaceable retrieval policies over one monolithic agent loop.
  • Measure against boring baselines before adding exotic machinery.
§10

The roadmap

Tortus is a fully functional v2, but the retrieval space is evolving rapidly. The roadmap is built to push the limits of multi-hop recall and scale the toroidal engine under extreme data pressure.

  • Distributed graph sharding. Push beyond local memory toward partitioned graph databases (e.g. PostgreSQL + Apache AGE) so the toroidal policy scales to millions of nodes without latency degradation.
  • Learned portal routing. Replace hand-tuned edge-weight thresholds with a lightweight portal router that dynamically optimizes cross-domain jumps from path-level user feedback.
  • Streaming traversal paths. An async generator-based traversal engine that emits reasoning hops as they are visited, so client UIs can render live retrieval steps in real time.
  • Adversarial benchmark suites. A benchmark family built specifically to break path retrieval — contradictory source claims, semantic decoy bridges, duplicate context blocks.
  • Unified ingest connectors. Native connectors for enterprise sources (Postgres CDC, Notion, Confluence, Slack archives) under strict cryptographic provenance contracts.