Skip to main content

Deterministic code knowledge graph: index with tree-sitter, query blast radius, mine risk memory from git, review diffs grounded in structure. No LLM required to build.

Project description

Graphora

The code knowledge graph that reviews your changes.

Deterministic indexing · Blast-radius analysis · Risk memory · Zero Docker required · $0 LLM cost to build

Python FalkorDB tree--sitter MCP Tests License

Graphora: source files flow into a live knowledge graph that powers blast radius, diff review with risk memory, and MCP tools for agents. 22,160 repo tokens shrink to 1,237.

pip install it as a library · run it as a CLI · plug it into any AI agent as an MCP server · or install the skill into 22 agents with one command


TL;DR: Graphora keeps a live structural graph of your codebase, built with tree-sitter and zero LLM calls, stored in FalkorDB or in a zero-setup embedded backend. When code changes, it reads the real blast radius (callers, callees, tests, importers) straight from the graph, remembers where the codebase broke before (risk memory mined from git history), and grounds every review claim in tagged, auditable facts. Measured result: 82 to 94% fewer prompt tokens than repo dumping on real pinned OSS repos, with more accurate reviews.

Why Graphora

AI code review and AI coding agents share the same blind spot: they see text, not structure.

Problem What goes wrong
Blind to blast radius A one-line change to a shared function looks harmless in isolation. Its callers, tests, and dependents live in other files, outside the diff.
Expensive to compensate The usual fix is stuffing more of the repo into the prompt. That burns tokens and still buries the signal in noise.
Hard to trust Without grounding, the model guesses. Reviewers cannot tell a grounded claim from a hallucination.
No memory of pain Every review starts from zero. The tool does not know that this exact function was hotfixed twice and reverted once.

Graphora fixes all four at the source:

Capability How
Live structural graph File, Function, Class, Module nodes; CALLS, DEFINED_IN, IMPORTS edges. Built deterministically with tree-sitter, updated incrementally.
Blast radius, not repo dumps Pure Cypher queries return exactly the callers, callees, covering tests, and importers of a change. Hundreds of tokens instead of tens of thousands.
Confidence tags on every fact EXTRACTED (explicit in source), INFERRED (single-candidate name resolution), AMBIGUOUS (multiple candidates, all linked and flagged). You always know what was read versus guessed.
Risk memory Git history mining links fix, hotfix, and revert commits to the exact symbols they touched. Each symbol carries fix_count, last_broke_at, and a risk_score that decays as the area stays quiet. Reviews warn on historically fragile code automatically.
Zero-setup or client-server Works instantly with an embedded pure-Python backend (JSON on disk, no Docker), or against a shared FalkorDB server for live Cypher and multi-project teams. Auto-detected.
11 languages Python, JavaScript, TypeScript (+JSX/TSX), Go, Java, Rust, C, C++, Ruby, PHP. Tree-sitter first, regex fallback.
$0 index cost No LLM, no embeddings, no network in the index path. Code never leaves your machine unless you enable the optional LLM review pass.

Quick start

# 1. Install (no server, no Docker needed)
pip install graphora-kg     # from PyPI, or: pip install -e . inside this repo

# 2. Build the graph and the risk memory (both offline, both $0)
graphora index /path/to/repo
graphora risk mine /path/to/repo

# 3. Use it
graphora blast my_function                 # who calls it, who tests it, did it break before
graphora risk top                          # the riskiest symbols in the codebase
graphora review --git-range main...HEAD --repo /path/to/repo
graphora benchmark /path/to/repo           # reproduce the token-cost numbers yourself

Zero configuration: without a FalkorDB server Graphora uses its embedded backend (pure Python, JSON at ~/.graphora). For live Cypher queries and team-shared graphs, start FalkorDB and Graphora picks it up automatically:

docker run -d --name graphora-falkordb -p 6379:6379 falkordb/falkordb:latest
# force a backend anytime with --backend embedded|falkordb|auto

Four ways to consume it

1. CLI

graphora index PATH                 Build the graph for a repository (no LLM)
graphora blast SYMBOL [...]         Blast radius: callers, callees, tests, risk
graphora review [--diff F|--git-range R]   Grounded diff review (LLM optional via --llm)
graphora risk mine PATH             Mine git fix/revert history into the graph
graphora risk top                   Riskiest symbols, ranked
graphora benchmark PATH             Reproducible token-cost benchmark
graphora serve-mcp                  Serve the graph to AI agents over MCP
graphora install-skill [all|AGENT]  Install the Graphora skill for 22 AI coding agents
graphora stats                      Node and edge counts

Every graph command accepts --backend auto|falkordb|embedded (default: auto).

2. Python library

from graphora import GraphStore, index_repository, blast_radius
from graphora.blast import blast_radius_for_diff
from graphora.risk import mine_risk_memory, risk_report

store = index_repository("/path/to/repo")          # deterministic build
mine_risk_memory(store, "/path/to/repo")           # teach it the history

# CI gate: block changes to called-but-untested symbols, three lines
radius = blast_radius_for_diff(store, pr_diff)
untested = [s.name for s in radius.symbols if s.callers and not s.tests]
assert not untested, f"Changed symbols with callers but no tests: {untested}"

3. MCP server (for AI agents)

graphora serve-mcp --project myrepo

Exposes blast_radius, review_diff, risk_top, find_symbol, and graph_stats to Copilot CLI, Claude Code, Cursor, or any MCP client. The server instructs agents to check the blast radius before editing a symbol, which turns Graphora into a guardrail for AI-generated changes.

4. One-command skill install (22 agents)

graphora install-skill all          # or: graphora install-skill claude-code cursor copilot
graphora install-skill --list      # see all supported agents

Writes the Graphora workflow rule (check blast radius before editing, run a grounded review before committing, consult risk memory) into each agent's project config: .claude/skills/, .cursor/rules/, .github/instructions/, AGENTS.md, GEMINI.md, Windsurf, Cline, Roo, Continue, Amazon Q, Zed, Goose, Aider, and more. Idempotent; existing files are preserved, shared files get a marked block.

Risk memory: the graph learns where the codebase breaks

Graphora mines git history (deterministically, zero LLM) for fix, hotfix, bugfix, and revert commits, and attributes each one to the exact functions and classes it touched, using both diff lines and hunk-header context.

risk_score = (1 - 0.7^fix_count) * 0.5^(months_since_last_fix / 6)

A symbol fixed often and recently scores near 1.0. A quiet area decays by half every 6 months. Reviews then carry findings no stateless tool can produce:

risk-memory falkordb/asyncio/cluster.py:9: Is_Cluster was involved in 2 past fix/revert commits (last: 2025-03-13), risk score 0.08, 2 callers. Review extra carefully.

The longer Graphora runs on a repository, the smarter it gets. That compounds.

Benchmarks

Measured on real repositories, fully deterministic, zero network. Full methodology and reproduction commands in BENCHMARKS.md.

Public benchmark on pinned OSS commits, reproducible with python3 scripts/public_benchmark.py:

Repository Commit Whole-repo dump Relevant files Graphora blast radius Savings
flask 36e4a824f3 147,390 tokens 124,205 tokens 21,534 tokens 85.4%
requests f361ead047 101,739 tokens 80,360 tokens 10,331 tokens 89.8%
click b67832c216 225,373 tokens 190,236 tokens 39,534 tokens 82.5%
falkordb-py 971f1d124e 59,866 tokens 40,638 tokens 3,550 tokens 94.1%

Graph build cost in LLM credits: $0, by construction. The "relevant files" column is the honest baseline: every file a reviewer would have to read to learn what the blast radius states directly.

Use cases

Five real, captured scenarios in USECASES.md:

  1. Cross-file impact review with zero LLM: a one-line diff, callers and covering tests read straight from the graph, ~197 tokens of context.
  2. Risk hotspot mining on a real codebase: 231 commits of falkordb-py history, the async cluster code correctly surfaced as the trouble spot.
  3. AI agents over MCP: a live stdio session calling blast_radius, risk_top, find_symbol.
  4. A CI gate in three lines of library code, plus incremental re-indexing.
  5. Ambiguity honesty: duplicate symbol names tagged AMBIGUOUS instead of silently guessed.

Architecture

                        ┌────────────────────────────────────────────┐
   source files ───────▶│  tree-sitter parse (deterministic, $0)     │
   git history  ───────▶│  risk miner (fix/revert attribution, $0)   │
                        └───────────────────┬────────────────────────┘
                                            ▼
                       code graph (FalkorDB or embedded)
                 File · Function · Class · Module · FixCommit
              CALLS / DEFINED_IN / IMPORTS / FIXED  (confidence-tagged)
                                            │
              ┌──────────────┬──────────────┼───────────────┬─────────────┐
              ▼              ▼              ▼               ▼             ▼
           CLI           library API     MCP server     benchmark    skill installer
        (terminal)      (CI gates,      (AI agents)    (reproducible)  (22 agents)
                         refactors)

Graph model per project: graphora:{project} in FalkorDB, or ~/.graphora/{project}.json embedded. Incremental updates re-parse only changed files. The optional LLM review pass (litellm, any provider) receives the diff plus the compact blast radius, never the repository.

Enterprise notes

  • Privacy: the index path is fully local. No code, no metadata leaves the machine unless the optional --llm review is enabled, and then only the diff plus a few hundred tokens of graph facts are sent to your configured provider.
  • Determinism: identical input produces identical graphs, reviews, and benchmark numbers. No embeddings drift, no model version drift in the core.
  • Multi-project: one FalkorDB instance serves many project graphs (graphora:{project}), so a single shared server can back a whole team. Solo developers need no server at all (embedded backend).
  • Auditability: every review claim traces to a tagged graph fact; every risk score traces to specific commits (FixCommit nodes with sha, date, subject).
  • Incremental cost: re-index only changed files on push; risk mining is idempotent per commit.

Testing

80 tests, all passing: parser (11 languages), FalkorDB store, embedded store (including backend-parity tests), blast radius, risk memory, CLI, MCP server, skill installer, and benchmarks. Integration tests run against a live FalkorDB and real scripted git repositories, and skip cleanly when FalkorDB is absent.

python3 -m pytest tests -q        # 80 passed

The test-per-phase methodology and the bugs the suite caught are documented in USECASES.md.

Requirements

Requirement Version Notes
Python 3.10+
FalkorDB optional for the client-server backend; embedded backend needs nothing
git any for risk memory mining
litellm optional only for review --llm
mcp optional only for serve-mcp

Languages indexed today: Python, JavaScript, TypeScript, Go, Java, Rust, C, C++, Ruby, PHP (tree-sitter grammars, regex fallback).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphora_kg-0.2.0.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphora_kg-0.2.0-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file graphora_kg-0.2.0.tar.gz.

File metadata

  • Download URL: graphora_kg-0.2.0.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for graphora_kg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cd799507b4a0e8ec17f79f34f7a357aed836249b596e3beb32c14e292ed368c8
MD5 71298469c2c35c1b0474f6b75f63f4a2
BLAKE2b-256 20b714d1bc7d552d212ac0dedb9291a1d900eede168084708fc570d76008afcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphora_kg-0.2.0.tar.gz:

Publisher: release.yml on Naseem77/Graphora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphora_kg-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: graphora_kg-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for graphora_kg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc2cdb55cac2094710ed630a559329fa9c4139cdcb45b4a3a613e165181b0aaa
MD5 9b88cbc4a787998d1cdc4d34ffb1363a
BLAKE2b-256 0070a7bf3e9025db7c9425e28ccda77aea09581264a1d48b255d0cd7fc08a328

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphora_kg-0.2.0-py3-none-any.whl:

Publisher: release.yml on Naseem77/Graphora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page