Memory graph for AI agents that learns what to retrieve — and what to suppress.
Project description
CrabPath
Pure graph engine for retrieval routing. Zero deps. Zero network calls. Caller provides embeddings and LLM callbacks.
Install
pip install crabpath # pure graph engine
pip install crabpath[embeddings] # + local embeddings (no API key)
Python API
from crabpath import split_workspace, traverse, apply_outcome, VectorIndex
# 1. Split workspace into graph + texts
graph, texts = split_workspace("./workspace")
# 2. Caller embeds (use whatever you have)
index = VectorIndex()
for nid, content in texts.items():
index.upsert(nid, your_embed_fn(content))
# 3. Query
seeds = index.search(your_embed_fn("how do I deploy"), top_k=8)
result = traverse(graph, seeds)
# 4. Learn
apply_outcome(graph, result.fired, outcome=1.0)
Batch Callbacks
from crabpath._batch import batch_or_single, batch_or_single_embed
# One call for all embeddings
vecs = batch_or_single_embed(
list(texts.items()),
embed_batch_fn=your_batch_embed
)
# One call for all LLM work
results = batch_or_single(
[{"id": "n0", "system": "summarize", "user": content}],
llm_batch_fn=your_batch_llm
)
Local Embeddings
pip install crabpath[embeddings]
from crabpath.embeddings import local_embed_fn, local_embed_batch_fn
# all-MiniLM-L6-v2, 80MB, CPU, no API key
Default Hash Embeddings
If you don’t install crabpath[embeddings], CrabPath uses a built-in zero-dependency
HashEmbedder (hash-v1, 1024 dimensions) for indexing and query vectors.
from crabpath import HashEmbedder
embedder = HashEmbedder() # default in CLI and default_embed
vec = embedder.embed("deploy to production")
vec2 = embedder.embed("deploy to production")
assert vec == vec2 # deterministic
The HashEmbedder is deterministic and dependency-free: it tokenizes text into
words and char n-grams, hashes features into a fixed vector size, and normalizes
to unit length.
Session Replay (warm start)
A fresh graph is 100% habitual — every edge requires deliberation. Replay warms it up by feeding historical session logs through the graph:
from crabpath import replay_queries, split_workspace
from crabpath.replay import extract_queries_from_dir
graph, texts = split_workspace("./workspace")
queries = extract_queries_from_dir("./sessions/")
replay_queries(graph=graph, queries=queries)
# Graph now has learned edges from real usage patterns
Or via CLI:
crabpath init --workspace ./ws --output ./data --sessions ./sessions/
# or separately:
crabpath replay --graph ./data/graph.json --sessions ./sessions/
On a 1,012-node graph, replaying 120 real queries created 39% cross-file edges and 5% reflex edges in seconds.
CLI (pure graph ops)
crabpath init --workspace W --output O [--sessions S]
crabpath query TEXT --graph G [--index I] [--query-vector-stdin] [--top N] [--json]
crabpath learn --graph G --outcome N --fired-ids a,b,c
crabpath replay --graph G --sessions S
crabpath health --graph G
crabpath merge --graph G
crabpath connect --graph G
crabpath journal [--stats]
Reproduce Results
git clone https://github.com/jonathangu/crabpath.git && cd crabpath
pip install -e . && python sims/run_all.py
8 deterministic sims. No API keys. See REPRODUCE.md.
Paper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crabpath-7.0.0.tar.gz.
File metadata
- Download URL: crabpath-7.0.0.tar.gz
- Upload date:
- Size: 50.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba0e0332f90f1d64b3df5d91757ada77d89b0dfdef3edab49e18bb7272455747
|
|
| MD5 |
a53fea813a56a42020986316405a4fd8
|
|
| BLAKE2b-256 |
1bcc3336558ea3894adf027681e5c0d7f63d2dcf857966e0824ebf3f5162d358
|
Provenance
The following attestation bundles were made for crabpath-7.0.0.tar.gz:
Publisher:
publish.yml on jonathangu/crabpath
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crabpath-7.0.0.tar.gz -
Subject digest:
ba0e0332f90f1d64b3df5d91757ada77d89b0dfdef3edab49e18bb7272455747 - Sigstore transparency entry: 1001185289
- Sigstore integration time:
-
Permalink:
jonathangu/crabpath@82c3defe65c9c7ea6709d16f376e940eb89838d4 -
Branch / Tag:
refs/tags/v7.0.0 - Owner: https://github.com/jonathangu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@82c3defe65c9c7ea6709d16f376e940eb89838d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file crabpath-7.0.0-py3-none-any.whl.
File metadata
- Download URL: crabpath-7.0.0-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92dd202ca226842e71c181536931092c8a8ea05cf8bd4291d946b137f375516e
|
|
| MD5 |
7bb2ff98117c5b589beb43d70cc90974
|
|
| BLAKE2b-256 |
b9e93b041737538d624d7106c6704a49f2ea4a69dbc150a041ab1d85394cb940
|
Provenance
The following attestation bundles were made for crabpath-7.0.0-py3-none-any.whl:
Publisher:
publish.yml on jonathangu/crabpath
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crabpath-7.0.0-py3-none-any.whl -
Subject digest:
92dd202ca226842e71c181536931092c8a8ea05cf8bd4291d946b137f375516e - Sigstore transparency entry: 1001185336
- Sigstore integration time:
-
Permalink:
jonathangu/crabpath@82c3defe65c9c7ea6709d16f376e940eb89838d4 -
Branch / Tag:
refs/tags/v7.0.0 - Owner: https://github.com/jonathangu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@82c3defe65c9c7ea6709d16f376e940eb89838d4 -
Trigger Event:
push
-
Statement type: