Skip to main content

RAG_Wright

A domain-retargetable, open-core engine for hybrid retrieval + knowledge-graph RAG.

License: MIT Python 3.12 status: alpha

RAG_Wright parses documents, chunks and embeds them, runs hybrid (dense + sparse) search with reranking, extracts a knowledge graph with resolved entities, and answers cited, abstention-willing questions over a corpus — with provenance and confidence on every claim. What a document means (the vocabulary, schema, and constraints) lives in an ontology (.ttl), not in code, so standing up a new domain is a pack, not a fork.

Why it exists

Building a retrieval + knowledge-graph system for a new domain usually means rebuilding the same plumbing every time, or hardcoding one domain so deeply that the next one is a rewrite. RAG_Wright splits the two:

  • the engine (this repo) is the reusable, domain-neutral machinery — ingestion and query pipelines, a capability runtime, one store, and the model seam;
  • the domain is just an ontology pack + a few capabilities you author against the engine.

Answers carry citations and will abstain rather than guess, because retrieval over real corpora has to be trustworthy. It is open-core: a user-facing product is a separate repo that depends on the engine one way (Product → Engine, never the reverse). A runnable reference pack (a contract/compliance worked example) ships here so the engine is demoable out of the box — your product brings its own domain pack, not this one.

What you get

  • One store. ArcadeDB holds both the hybrid retrieval index and the knowledge graph — no cross-store join to keep consistent.
  • A capability runtime (ARD). Parsing, chunking, embedding, hybrid search, reranking, graph extraction, entity resolution, reasoning/generation and more are registered capabilities invoked by name through one API — and discoverable by task (discover), so an agent can plan over them. The engine ships with an empty catalog; you register your domain's capabilities (or opt into the reference pack).
  • Generic, hook-based ingestion. build_ingestion(extractor, ...) runs the engine's own pipeline (parse, chunk, segment, index, group into units, write) around your domain's extractor; every other step has a default you can override. It reads PDF, Office (Word, PowerPoint) and spreadsheets (including hidden sheets and row-per-record tables), ingests embedded files and PDF attachments as linked child documents, and comes with a structural evaluation (evaluate_ingestion) to tune it on your own samples.
  • A neutral default schema. A new workspace gets only the engine's types (Chunk, Entity, Span, Document and their edges); a domain's types come from its pack.
  • Knowledge in the ontology. Closed vocabularies, schema, SHACL constraints and mappings live in a .ttl pack; code holds mechanism only.
  • Model-neutral. Model access is a profile seam — OpenRouter by default, self-hosted open models (vLLM) supported — never a hardcoded provider.
  • Typed, provenance-first, test-driven. Ships with py.typed; every answer carries citations; capabilities are built eval-first (the evaluation harnesses are in eval/).

Documentation — start here

The whole doc set is under docs/. Pick your path:

  • New here? Read Concepts (the mental model), then run the Quickstart.
  • Installing / configuring? Installation → Configuration → Workspaces (what applies per workspace, per call and per process).
  • Building a product on the engine? The domain-adaptation guide walks the whole sequence (author a .ttl pack → build & register capabilities → eval-first → ingest → entity resolution → the product seam); a coding agent should drive it with the using-the-rag-wright-engine skill.
  • Measuring a capability? Evals: gold sets from your experts' files, a scorer per capability kind, a runner with repeats, a report your backend can return, optional Langfuse runs.
  • Building your product's agent? The agent harness: the third tier's design, every field a product declares, and where it goes quiet rather than failing.
  • Going deep? Architecture, the generated API reference, the Reference pack, and the ADR index.
  • Releases? See the CHANGELOG and how releases work (batched via release-please; products adopt them through automated dependency PRs).

Install

uv add rag-wright

This installs the latest PyPI release (0.1.0). The generic ingestion builder, the neutral default schema and the move of the reference pack to rag_wright.packs landed after 0.1.0; until the next release, depend on the engine from git or a local path to get them (see docs/installation.md). Code written against 0.1.0 migrates with the breaking-changes record.

Runtime prerequisites: ArcadeDB (the store: your product runs its own instance and owns its data, including the knowledge graph; see docs/installation.md); a model provider (an OpenRouter key by default, or a self-hosted endpoint); and, only for NER (named entity recognition), the optional extra uv add 'rag-wright[ner]' + uv run python -m spacy download en_core_web_sm.

Quickstart (shape)

The whole public surface is rag_wright.api. The full runnable walkthrough (ingest a document, then query it) is in docs/quickstart.md / examples/quickstart.py:

import asyncio
from rag_wright.api import EngineConfig, StoreConfig, open_workspace, load_reference_pack, ainvoke_subgraph

load_reference_pack()  # opt in to the contract/compliance worked example (the engine ships an empty catalog)

config = EngineConfig(store=StoreConfig(host="localhost", port="2480", user="root", password="<arcadedb-password>"))
ws = open_workspace(config, corpus="demo")  # corpus = the backend DB name

# assumes ACME_MSA was already ingested (the ingest step is in docs/quickstart.md)
async def main():
    out = await ainvoke_subgraph(
        "intra_document_qa", {"contract_id": "ACME_MSA", "question": "What is the liability cap?"}, resources=ws)
    print(out["answer"].answer, out["answer"].citations)   # a grounded, cited answer (or an abstention)

asyncio.run(main())

Status

Alpha. Releases are published to PyPI (0.1.0 is the latest); newer engine work is on main until the next batched release. The bundled reference pack is a worked example, not the product; restrictively-licensed evaluation corpora (CUAD/ACORD) are not shipped.

Development

Python with uv (never bare python/pip):

uv sync && uv run pytest && uv run ruff check .

Layout

src/rag_wright/
  api/           the stable, domain-agnostic public surface (import everything from here)
  capabilities/  the capability catalog + ARD runtime (manifests, registry, the invoker)
  ingestion/     the generic ingestion builder (build_ingestion), default segmenter/grouper, table rows, eval
  contracts/     Pydantic contracts + the shared identifiers (chunk_id, entity_id) and the ingestion hook contracts
  subgraphs/     the generic LangGraph scaffolding, semantic chunking and graph extraction
  models/        the model-profile seam (OpenRouter default / self-hosted open models)
  ontology/      the generic pack-schema reader + entity-registry derivation
  pack_sdk/      the pack-author tier: what a domain pack imports beyond rag_wright.api
  store/         the single ArcadeDB store behind the query seam
  spans/         page_map (page and bounding-box positions of spans)
  corpus/        document parsing + embedded-file extraction
  skills/        authored SKILL.md content for the generic capabilities
  util/          shared, capability-agnostic utilities
  packs/         the reference pack: packs/contracts (contract domain) and packs/compliance (built on it),
                 each with its pack.py, ontology (.ttl), capabilities, graphs, skills and MCP servers
docs/            documentation (docs/archive/ holds superseded/historical material)

Licensed under MIT. Working rules for coding agents are in CLAUDE.md.

Metadata

Release files for rag-wright 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rag-wright 0.13.0
File Size Uploaded
rag_wright-0.13.0.tar.gz 2.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for rag-wright 0.13.0
File Interpreter ABI Platform
rag_wright-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.8 MB

Release files / rag_wright-0.13.0.tar.gz

Download URL rag_wright-0.13.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
0c9386038fe84545dc2e00aa4d34f71d02023fb015a75d52fd95287cfe2020fd
BLAKE2b-256 checksum
How to use checksums
5efc850860b1d429a19c9ba3a8e676838f8edc2a53da24cec35fb55449e9e8ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / rag_wright-0.13.0-py3-none-any.whl

Download URL rag_wright-0.13.0-py3-none-any.whl
Size 943.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d03f6a94660990b67ea7355ffecc854660166de154bf0d31a96c3552d80e395
BLAKE2b-256 checksum
How to use checksums
845c30b0a9ca49b320e642b9abb18cb64c697633d6ada2e68113d7af972efe45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release history Release notifications | RSS feed

0.14.0

2 release files

This release

0.13.0 This release

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page