Skip to main content

High-performance graph library for the Kelvin Agentic OS — petgraph-backed engine, 40+ algorithms, RDF/SPARQL, knowledge-graph tools

Project description

kaos-graph

Part of Kelvin Agentic OS (KAOS) — open agentic infrastructure for legal work, built by 273 Ventures. See the full KAOS package map for the rest of the stack.

PyPI - Version Python License CI

kaos-graph is a high-performance graph library for KAOS — a typed Python API over a pure-Rust core backed by petgraph and the oxrdf RDF engine. It provides the graph-algorithm and knowledge-graph building blocks the rest of the stack relies on: 40+ algorithms (PageRank, shortest paths, centrality, community detection, DAG ops), RDF/SPARQL parsing, and typed Python wrappers throughout.

It is dependency-light: the BASE install pulls only kaos-graph itself plus defusedxml (~250 KB pure-Python). Optional extras layer in the rest of the KAOS ecosystem.

Install

uv add kaos-graph
# or
pip install kaos-graph

kaos-graph requires Python 3.13 or newer. The published wheels are cp313-abi3 — one wheel per OS/architecture covers every CPython 3.13+ minor (3.13, 3.14, 3.15, …). No re-release needed when 3.15 ships.

Platform coverage: Linux x86_64 (manylinux + musllinux), Linux aarch64 (manylinux + musllinux), macOS arm64, Windows x86_64, Windows arm64.

Quick start

from kaos_graph import Graph
from kaos_graph.algorithms import pagerank, shortest_paths, topological_sort

g = Graph()
g.add_node("alice", role="engineer")
g.add_node("bob", role="manager")
g.add_edge("alice", "bob", relationship="reports_to")

# Algorithms
ranks = pagerank(g)
costs = shortest_paths(g, "alice")
order = topological_sort(g)

Concepts

The package is built around a small set of typed primitives.

Concept What it is
Graph Property graph backed by petgraph::StableDiGraph. String-keyed nodes with JSON-valued properties; edges with arbitrary properties; multi-graph semantics opt-in. Stable node refs across mutations (additions/removals don't invalidate handles).
Node / Edge / Triple Typed dataclass results emitted at the FFI boundary. Node(id, properties), Edge(source, target, properties), Triple(subject, predicate, object).
Algorithms 40+ functions in kaos_graph.algorithms covering traversal (BFS/DFS, topological sort), shortest paths (Dijkstra, A*, Bellman-Ford, Floyd-Warshall), centrality (PageRank, betweenness, closeness, eigenvector), community (Louvain, label propagation), connectivity (SCC, weakly-connected, articulation points, bridges), structure (cycles, cliques, isomorphism, max flow), and DAG ops (longest path, critical path).
Sparse PageRank O((V+E)·n) instead of petgraph's O(V²·E·n). FOLIO ontology (~25K nodes, ~36K edges): 7 ms vs petgraph's 105 s. The marketing-grade benchmark exercised on every CI run.
RDF / SPARQL oxrdf + oxrdfio parsers (Turtle, N-Triples, N-Quads, RDF/XML, TriG) with byte / triple / size caps applied at the FFI boundary. SPARQL via pyoxigraph opt-in through the [rdf] extra.
I/O & bridges JSON (round-trippable), GraphML / GEXF (defusedxml-hardened), edgelist, adjacency-list, mermaid, dot. NetworkX bridge; Polars / DuckDB tabular bridge planned via the [tabular] extra in 0.1.0a2.
Knowledge graph Schema, KnowledgeGraph, fact ingestion, reasoning rules, ontology bridges.
Storage VFS-backed save_to_vfs / load_from_vfs with name validation against namespace escape.

CLI

kaos-graph ships a kaos-graph administrative CLI plus an optional kaos-graph-serve MCP server (loopback-only by default):

kaos-graph version          # version info
kaos-graph serve            # forwards to kaos-graph-serve (stdio MCP)
kaos-graph-serve            # MCP server, stdio transport
kaos-graph-serve --http     # MCP server, streamable HTTP (loopback only)

Note: 17 MCP tools are registered by register_graph_tools() and become available with pip install kaos-graph[mcp] once the kaos-mcp companion package publishes (planned for 0.1.0a2).

Compatibility & status

Aspect
Python 3.13, 3.14 (informational matrix entries for 3.14t free-threaded and 3.15-dev). One cp313-abi3 wheel per OS/arch covers all 3.13+ minors.
OS Linux (manylinux + musllinux, x86_64 + aarch64), macOS arm64, Windows x86_64, Windows arm64. macOS x86_64 deliberately skipped (Apple ended Intel sales in 2023).
Maturity Alpha. The public API is documented in kaos_graph.__all__.
Stability policy Pre-1.0: minor bumps may change behaviour. Every change is documented in CHANGELOG.md.
Test coverage 173 Rust unit tests + 402 Python tests passing (575 total). 38 dedicated security regressions covering the audit-pass A2 + two follow-up rounds.
Type checker Validated with ty, Astral's Python type checker.

Companion packages

kaos-graph is one of the packages in the Kelvin Agentic OS. The broader stack:

Package Layer What it does
kaos-core Core Foundational runtime, MCP-native types, registries, execution engine, VFS
kaos-content Core Typed document AST: Block/Inline, provenance, views
kaos-mcp Bridge FastMCP server, kaos management CLI, MCP resource templates
kaos-pdf Extraction PDF → AST with provenance
kaos-web Extraction Web extraction, browser automation, search, domain intelligence
kaos-office Extraction DOCX / PPTX / XLSX readers + writers to AST
kaos-tabular Extraction DuckDB-powered SQL analytics
kaos-source Data Government + financial data connectors (Federal Register, eCFR, EDGAR, GovInfo, PACER, GLEIF)
kaos-llm-client LLM Multi-provider LLM transport
kaos-llm-core LLM Typed LLM programming (Signatures, Programs, Optimizers)
kaos-nlp-core Primitives (Rust) High-performance NLP primitives
kaos-nlp-transformers ML Dense embeddings + retrieval
kaos-graph Primitives (Rust) Graph algorithms + RDF/SPARQL
kaos-ml-core Primitives (Rust) Classical ML on the document AST
kaos-citations Legal Legal citation extraction, resolution, verification
kaos-agents Agentic Agent runtime, memory, recipes
kaos-reference Sample Reference module for module authors

Packages depend on kaos-core; everything else is opt-in. Mix and match the ones you need.

Development

git clone https://github.com/273v/kaos-graph
cd kaos-graph
uv sync --group dev --extra rdf
uv run maturin develop --release

Install pre-commit hooks (recommended — they run the same checks as CI on every commit, scoped to staged files):

uvx pre-commit install
uvx pre-commit run --all-files     # one-time full sweep

Manual QA commands (the same set CI runs):

cargo fmt --check
cargo clippy --no-default-features --all-targets -- -D warnings
cargo test --no-default-features --lib
uv run ruff format --check python/kaos_graph tests
uv run ruff check python/kaos_graph tests
uv run ty check python/kaos_graph tests
uv run pytest tests/

Build from source

uv build
uv pip install dist/*.whl

Contributing

Issues and pull requests are welcome. By contributing you certify the Developer Certificate of Origin v1.1 — sign every commit with git commit -s. Please open an issue before starting on a non-trivial change so we can align on scope.

Security

For security issues, please do not file a public issue. Report privately via GitHub Private Vulnerability Reporting or email security@273ventures.com. See SECURITY.md for the full disclosure policy.

License

Apache License 2.0 — see LICENSE and NOTICE.

Copyright 2026 273 Ventures LLC. Built for kelvin.legal.

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

kaos_graph-0.1.0a2.tar.gz (170.5 kB view details)

Uploaded Source

Built Distributions

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

kaos_graph-0.1.0a2-cp313-abi3-win_arm64.whl (946.8 kB view details)

Uploaded CPython 3.13+Windows ARM64

kaos_graph-0.1.0a2-cp313-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.13+Windows x86-64

kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13+musllinux: musl 1.2+ x86-64

kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.13+musllinux: musl 1.2+ ARM64

kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ x86-64

kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

kaos_graph-0.1.0a2-cp313-abi3-macosx_11_0_arm64.whl (993.5 kB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

File details

Details for the file kaos_graph-0.1.0a2.tar.gz.

File metadata

  • Download URL: kaos_graph-0.1.0a2.tar.gz
  • Upload date:
  • Size: 170.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kaos_graph-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 322cf236e164072175d5abf68977c2864cf04fcd2fbeb48ef731f973b1beddfe
MD5 c978a9374ad7c609bf7cc7e322e2297f
BLAKE2b-256 7a0c4af36c0decd40555d2cc3c692d8bb2147e3bbd6cb804b9bd3f3a804e7b3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2.tar.gz:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-win_arm64.whl.

File metadata

  • Download URL: kaos_graph-0.1.0a2-cp313-abi3-win_arm64.whl
  • Upload date:
  • Size: 946.8 kB
  • Tags: CPython 3.13+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 3c032cb6b4e2ec94bc05b5d65cbe1b6a24785e60bda955365ec56d68fba9d66d
MD5 2515237d465a9405ddaebe666a41eaaa
BLAKE2b-256 818450e558ebf16708b1c6adbef0e0b797ea8ca3e11f3d9f5214eedb6f2c03f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-win_arm64.whl:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5d4fec7cd457f05171b2f0721fc7ad234232095a68d611ebc9a4ef8756bc3b43
MD5 30e85e10bb2687e5f92f9268528ae8b8
BLAKE2b-256 01dff43c68203aa88f69362cbf560a0b5052151d7bcc7afd6dff13105c42a7c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-win_amd64.whl:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4cc1c835c6927f7047ea77285396d624afc26a0f71d6744b44e4792ac3eeeea5
MD5 f20cc708c531c7ad1608f1a19c0afbd9
BLAKE2b-256 42b8a78ba781e48f9497a9b726b6363bc45c4346a31afa66b5473fbd5dd6a78a

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1c2786ebb0b59accbadc0e4882468010c2830ebcfb685422d929e8ac2152c701
MD5 cf6f339ac67f8a5e31522a465226005b
BLAKE2b-256 9d19f2e005f2544074c13e1a62e976ca609468ec674652145e0bfaece117b146

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5fdb939f5592128e0afc12052087a9f76eb3e2c460132fc3b6ec3aca32226502
MD5 1322fa2b88532786f64aba3cf3e4e01a
BLAKE2b-256 8ea01fc706bfb1a513c4118eca7dfa51bbf560c5baae6ca56db628c9bc37bf26

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 807b5a0a92eba5999baa875d06f0643b960976ea6226581e4b864fd66ab5ebc5
MD5 24e9958dbe2e0afdcd176107954221df
BLAKE2b-256 fabe6cdff416aa089add7c20e35a74bfc4aacd901775b2a3e3bf6e07dd918ad8

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on 273v/kaos-graph

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

File details

Details for the file kaos_graph-0.1.0a2-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kaos_graph-0.1.0a2-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e68451d38c4a7965c872baf0754b69f5bbf4477475f344052b920e15e07d8f3d
MD5 2f73cd8145048741ad4b8e1c68ed91ad
BLAKE2b-256 5f601ee843f1fae48a2e181b6085a68a45ee7292da80e9b312c9a66d6f6a1236

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaos_graph-0.1.0a2-cp313-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on 273v/kaos-graph

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