Skip to main content

Relational Entities Query Language: a graph-native deterministic memory engine.

Project description

REQL

REQL is a local repository context index for coding agents and developer tools. It compiles source files and supported documents into a property graph, then answers bounded queries over code, symbols, tests, documents, dependencies, findings, and provenance.

The important part is that REQL turns a repository into queryable structure before an agent starts editing:

  • project compile scans the project, fingerprints artifacts, parses supported code and documents, and writes graph nodes, edges, cache records, compilation runs, and deltas;
  • retrieval commands such as query_context, query_explore, query_graph, and query_memories find lexical seed nodes, expand a bounded graph neighborhood, rank the result, and return compact source-backed context;
  • every result can point back to paths, line ranges, relationships, evidence, and graph provenance instead of relying on broad source dumps;
  • incremental compile and watch mode keep the graph current without rebuilding unchanged files.

REQL is deterministic by default. Compilation, storage, query, retrieval, analysis, reports, and MCP access work locally without mandatory LLM calls, accounts, hosted services, or an external graph database. Optional semantic adapters can exist at integration boundaries, but the core memory system remains usable on its own.

Quick Start

REQL requires Python 3.10 or newer. Install the package with pip:

python -m pip install reql

For local development from a checkout, install it in editable mode:

python -m pip install -e .

Compile a project and retrieve context:

reql project compile .
reql query_context --query "payment service"
reql query_memories --query "payment service" --limit 8 --json
reql query_explore --query "payment service serialization" --view owners --view code

From a source checkout, python cli.py ... exposes the same command surface without requiring an editable install:

python cli.py project compile .
python cli.py query_context --query "payment service"

Use the Python API directly:

from reql import MemoryGraph

graph = MemoryGraph.open(".reql/memory.reql")

try:
    graph.compile_project(".")

    context = graph.query_context("payment service")
    print(context)
finally:
    graph.close()

Install assistant instructions and start MCP when needed:

reql install codex
reql-mcp --read-only

Project/cache commands default storage to <project>/.reql/memory.reql; other commands default to ./.reql/memory.reql. Use --storage, --config, --set, and --json for automation. See docs/CLI.md for the complete command reference, query modes, install behavior, MCP startup, config lookup, reports, exports, and maintenance workflows.

Features

  • Local project compilation into a property graph with explicit provenance.
  • Retrieval with lexical seed nodes, bounded graph expansion, and chain-aware ranking.
  • Compact query_context, query_explore, query_graph, and query_memories outputs for coding-agent workflows.
  • Local block-file persistence with fixed-size pages, compressed records, locking, transactions, and compaction.
  • Incremental compilation cache with persistent compilation runs and graph deltas.
  • Artifact document parsing for Markdown, plain text, and PDF with graceful fallbacks.
  • Code artifact recognition for Python, TS/JS, Go, Rust, Java, C/C++, Ruby, C#, Kotlin, Scala, PHP, Swift, Lua, Zig, PowerShell, Elixir, Julia, Verilog, Fortran, Bash, SQL, Terraform, Apex, Pascal, Razor, and related extensions, with Tree-sitter AST graph extraction for recognized languages.
  • Static-analysis findings for cleanup-oriented queries.
  • Deterministic community detection, hub analysis, and bridge analysis with generic-node penalties.
  • Markdown reports, JSON export, standalone graph.html, guided launcher, installable CLI, typed Python API, and optional dependency-free MCP server.

Runtime Model

REQL works as a local repository index backed by a property graph:

  • project compile scans the project with default ignores plus configured include/exclude rules;
  • each artifact is fingerprinted, so unchanged files can be skipped on later compiles;
  • supported code files are parsed into modules, symbols, imports, calls, dependencies, endpoints, config records, tests, and static-analysis findings;
  • supported documents are split into source fragments, ranked document terms, raw observations, and document-to-code links when they explicitly name code symbols;
  • graph records keep file paths, line ranges, evidence, confidence, and provenance so query results can be traced back to source;
  • queries find lexical seed nodes, expand only a bounded graph neighborhood, rank the resulting records, and render compact context instead of dumping the repository;
  • project update and watch mode reuse the same incremental compiler and write CompilationRun, GraphDelta, and cache records for changed or deleted artifacts.

The core path is deterministic and local. Optional semantic adapters can exist at integration boundaries, but project compilation, storage, retrieval, reports, analysis, and MCP tools do not require model calls.

Interactive Launcher

The project root launcher.py starts a guided terminal menu when run without arguments. It uses ./.reql/memory.reql in the current working directory by default and lets you choose actions interactively without writing command-line arguments:

python launcher.py

You can pass a storage path directly:

python launcher.py --storage .reql/memory.reql

The menu guides these workflows:

  • create or open a graph storage file and initialize it;
  • list available graph files under .reql/, open them, inspect them, or delete managed .reql files after an explicit name confirmation;
  • retrieve ranked code records or compose bounded agent context;
  • scan and incrementally compile projects;
  • run predefined REQL queries or custom graph queries;
  • inspect stats, communities, hubs, and graph analysis;
  • export Markdown reports, JSON, and standalone graph.html;
  • print Codex and Claude Desktop MCP configuration for reql-mcp.

For command-line automation, use python cli.py ... or reql:

reql project compile .
reql query_memories --query "payment service" --limit 5 --json
reql query "FIND nodes WHERE type = 'Function' LIMIT 10"

Documentation

The README gives the project overview and common workflows. The focused documentation lives under docs/:

  • Architecture: layers, storage port, compile flow, retrieval, maintenance, and deterministic analysis.
  • CLI: command reference for compilation, retrieval, graph queries, exports, configuration, install helpers, and MCP startup.
  • Configuration: conf.yaml, overrides, scan rules, cache settings, document ingest, analysis toggles, and loader behavior.
  • REQL language: first-class graph commands plus FIND, MATCH, PATH, SEARCH, RETRIEVE, EXPLAIN, filters, and examples.
  • Schema: core node records, edge records, code types, and relations used in the graph.
  • Storage: block adapter, data locality, compression, inspection, compaction, locking, transactions, and bounded operations.
  • Artifact ingestion: supported document inputs, parser behavior, graph output, and graceful fallbacks.
  • Code analysis: language support, Tree-sitter parsing, extracted symbols, static-analysis findings, and example queries.
  • Incremental compilation: dirty planning, cache entries, deltas, deletion handling, and failure behavior.
  • Graph analysis: deterministic communities, hubs, bridge signals, CLI usage, REQL examples, and known analysis limits.
  • Reporting: generated Markdown reports and standalone HTML graph export.
  • MCP server: stdio/HTTP server startup, tool descriptions, Codex and Claude configuration, workflow, and security notes.
  • Extending: storage adapters, extractors, engines, and adding node or edge types.

Main Pipeline

REQL has a project compile pipeline. compile builds a technical graph for programming agents from scanning, AST/static analysis, document parsing, and deterministic document-to-code linking. It does not extract memories from chat or non-code prose.

Retrieval:

query
  -> tokenization
  -> lexical seed-node search
  -> bounded graph expansion
  -> graph-aware ranking
  -> subgraph or context block

Maintenance:

activation and usage signals
  -> salience update
  -> sidecar retrieval usage updates
  -> provenance preservation

Compile-time project scan:

project directory
  -> recursive scanner
  -> default ignore rules and config include/exclude filtering
  -> file classification and SHA-256 fingerprints
  -> Project + Directory + File + SourceArtifact nodes
  -> CONTAINS edges

Project compile uses the same fingerprinting path and built-in default ignores. Put additional compile exclusions in the configured scan.exclude list.

Incremental compilation:

SourceArtifact fingerprints
  -> ArtifactCacheEntry comparison
  -> dirty and deleted artifact set
  -> deterministic compile graph updates
  -> CompilationRun
  -> GraphDelta

Artifact document parsing:

SourceArtifact bytes
  -> document parser
  -> DocumentFragment records
  -> SourceFragment nodes
  -> provenance and document relations

Code analysis:

code artifact
  -> AST/static parser when supported
  -> Module / Package / Class / Interface / Function / Method / useful Variable nodes
  -> Import / Dependency / Endpoint / Schema / Config / Test nodes
  -> CONTAINS / DEFINES / METHOD / IMPORTS / CALLS / REFERENCES / INHERITS edges
  -> DEPENDS_ON / IMPORTS_FROM / RE_EXPORTS / READS / WRITES / RETURNS edges
  -> RAISES / DECORATED_BY / HANDLES_ROUTE / HAS_FINDING edges
  -> StaticAnalysisFinding cleanup candidates for unused code

Graph analysis:

graph nodes and edges
  -> deterministic community detection
  -> specificity-aware hub scoring
  -> cross-community bridge edges
  -> Community nodes, BRIDGES_COMMUNITY edges, and hub properties

Project Structure

src/api/
|-- memory_graph.py         # Public facade
|-- __init__.py             # Public Python API exports
src/agents/
|-- install.py              # Agent skill/instruction installers
|-- __init__.py             # Agent installer exports
src/mcp/
|-- tools.py                # Dependency-free MCP tool handlers
`-- server.py               # stdio and HTTP JSON-RPC MCP transports
src/memory/
|-- domain/                 # Pure models, constants, ids, time, exceptions
|-- ports/                  # Storage and extractor protocols
|-- infrastructure/         # Concrete adapters
|   `-- block/              # BlockGraphStore
|-- extraction/             # Deterministic query/source extraction and optional adapters
|-- artifacts/              # Project scanning, file classification, fingerprints
|-- engines/                # Numeric and maintenance engines
|   |-- activation.py       # Spreading activation
|   `-- salience.py         # Salience scoring
|-- services/               # Application orchestration
|   |-- retrieval.py
|   |-- incremental_compilation.py
|   `-- project_watch.py
|-- query/                  # REQL lexer, parser, AST, and evaluator
|-- analysis/               # Communities, centrality, specificity, hubs, bridges
|-- reporting/              # Markdown reports
|-- config/                 # conf.yaml models and loader
`-- cli.py                  # Command-line interface

Public API

The main entry point is MemoryGraph. The canonical public import is from reql import MemoryGraph.

from reql import MemoryGraph

graph = MemoryGraph.open(".reql/memory.reql")

Main operations:

  • retrieve(query)
  • compose_context(query)
  • query_context(query)
  • query_explore(query)
  • query_graph(query)
  • query_memories(query)
  • query_memories_payload(query)
  • export_json()
  • query(statement)
  • compile_project(path)
  • update_project(path)
  • project_status(path)
  • project_report(path, output_dir=...)
  • cache_status(path)
  • clear_cache(path)
  • list_deltas()
  • show_delta(delta_id)
  • detect_communities(project_id=...)
  • analyze_hubs(project_id=..., limit=...)

Extending the Project

New Storage Backend

Implement memory.ports.graph_store.GraphStore and pass it to the facade:

from reql import MemoryGraph

store = MyGraphStore(...)
graph = MemoryGraph(store)

The bundled block backend is portable local persistence, not an architectural constraint.

New Extractor

Implement SemanticExtractor:

class MyExtractor:
    def extract(self, text: str):
        ...

graph = MemoryGraph.open(".reql/memory.reql", extractor=MyExtractor())

The extractor is used for query seed discovery. Project document ingest is handled by the local deterministic compiler path. The default MemoryGraph.open() extractor is dependency-free and deterministic.

Compile mode structurally parses text document fragments and links explicit documentation mentions back to compiled code symbols where possible.

New Node or Edge Types

Types are strings. To keep them coherent:

  1. add constants in domain/constants.py;
  2. update compiler, retrieval, reporting, or analysis code if dedicated logic is needed;
  3. add integration tests when the new type changes retrieval, salience, or graph analysis.

License

MIT. See LICENSE.

Contributing

See CONTRIBUTING.md for development setup, contribution guidelines, and pull request expectations.

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

reql-0.1.0.tar.gz (279.5 kB view details)

Uploaded Source

Built Distribution

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

reql-0.1.0-py3-none-any.whl (287.7 kB view details)

Uploaded Python 3

File details

Details for the file reql-0.1.0.tar.gz.

File metadata

  • Download URL: reql-0.1.0.tar.gz
  • Upload date:
  • Size: 279.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for reql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fead9f128c9f42bd3441faa112a4b601497e1d140a6815d95ff2077480d21cde
MD5 6a05040453b6fe49a390c11f1ba1b91c
BLAKE2b-256 eeaa6f83e931135bc80c9893864edab4616dd3350fe6d1b91b099d4bfa75235f

See more details on using hashes here.

File details

Details for the file reql-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: reql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 287.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for reql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe36ebdcba71109b7b92b18e80b12a496ab0ba5204da8347ef0cd7ee165ab6ac
MD5 cbd05778db96df04fc165a04713535b5
BLAKE2b-256 fcbd22e3dfdf5faf4f6d8398611098fbad84a52409b94337ad847923e5f19d21

See more details on using hashes here.

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