CrabPath
Pure graph core: zero required deps and no network calls. Caller provides callbacks.
Design Tenets
- No network calls in core
- No secret discovery (no dotfiles, keychain, or env probing)
- No subprocess provider wrappers
- Embedder identity in state metadata; dimension mismatches are errors
- One canonical state format (
state.json)
Quick Start
from crabpath import split_workspace, HashEmbedder, VectorIndex
graph, texts = split_workspace("./workspace")
embedder = HashEmbedder()
index = VectorIndex()
for nid, content in texts.items():
index.upsert(nid, embedder.embed(content))
Embeddings and LLM callbacks
- Default:
HashEmbedder (hash-v1, 1024-dim)
- Real: callback
embed_fn / embed_batch_fn (e.g., text-embedding-3-small)
- LLM routing: callback
llm_fn using gpt-5-mini (example)
Session Replay
replay_queries(graph, queries) can warm-start from historical turns.
CLI
--state is preferred:
crabpath query TEXT --state S [--top N] [--json]
crabpath query TEXT --state S --chat-id CID
crabpath doctor --state S
crabpath info --state S
crabpath init --workspace W --output O --embedder openai
crabpath query TEXT --state S --llm openai
crabpath inject --state S --type TEACHING [--type DIRECTIVE]
Real-time correction flow:
python3 query_brain.py --chat-id CHAT_ID
python3 learn_correction.py --chat-id CHAT_ID
Quick Reference
crabpath init/query/learn/inject/health/doctor/info
query_brain.py --chat-id and learn_correction.py for real-time correction pipelines
query_brain.py traversal limits: beam_width=8, max_hops=30, fire_threshold=0.01
- Hard traversal caps:
max_fired_nodes and max_context_chars (defaults None; query_brain.py defaults max_context_chars=20000)
examples/correction_flow/, examples/cold_start/, examples/openai_embedder/
API Reference
- Core lifecycle:
split_workspace
load_state
save_state
ManagedState
VectorIndex
- Traversal and learning:
traverse
TraversalConfig
TraversalConfig.beam_width, .max_hops, .fire_threshold, .max_fired_nodes, .max_context_chars, .reflex_threshold, .habitual_range, .inhibitory_threshold
TraversalResult
apply_outcome
- Runtime injection APIs:
inject_node
inject_correction
inject_batch
- Maintenance helpers:
suggest_connections, apply_connections
suggest_merges, apply_merge
measure_health, autotune, replay_queries
- Embedding utilities:
HashEmbedder
OpenAIEmbedder
default_embed
default_embed_batch
openai_llm_fn
- LLM routing callbacks:
- Graph primitives:
Node
Edge
Graph
split_workspace
generate_summaries
CLI Commands
crabpath init --workspace W --output O [--sessions S] [--embedder openai]
crabpath query TEXT --state S [--top N] [--json] [--chat-id CHAT_ID]
crabpath learn --state S --outcome N --fired-ids a,b,c [--json]
crabpath inject --state S --id NODE_ID --content TEXT [--type CORRECTION|TEACHING|DIRECTIVE] [--json] [--connect-min-sim 0.0]
crabpath inject --state S --id NODE_ID --content TEXT --type TEACHING
crabpath inject --state S --id NODE_ID --content TEXT --type DIRECTIVE
crabpath health --state S
crabpath doctor --state S
crabpath info --state S
crabpath replay --state S --sessions S
crabpath merge --state S [--llm openai]
crabpath connect --state S [--llm openai]
crabpath journal [--stats]
query_brain.py --chat-id CHAT_ID
learn_correction.py --chat-id CHAT_ID
Traversal defaults
beam_width=8
max_hops=30
fire_threshold=0.01
reflex_threshold=0.6
habitual_range=0.2-0.6
inhibitory_threshold=-0.01
max_fired_nodes (hard node-count cap, default None)
max_context_chars (hard context cap, default None; query_brain.py default is 20000)
Paper
https://jonathangu.com/crabpath/
1---
2name: crabpath
3description: Memory graph engine with caller-provided embed and LLM callbacks; core is pure, with real-time correction flow and optional OpenAI integration.
4metadata:
5 source: https://skillmd.com/skills/modbender/crabpath
6 openclaw:
7 emoji: "🦀"
8 requires:
9 python: ">=3.10"
10---
11
12# CrabPath
13
14Pure graph core: zero required deps and no network calls. Caller provides callbacks.
15
16## Design Tenets
17
18- No network calls in core
19- No secret discovery (no dotfiles, keychain, or env probing)
20- No subprocess provider wrappers
21- Embedder identity in state metadata; dimension mismatches are errors
22- One canonical state format (`state.json`)
23
24## Quick Start
25
26```python
27from crabpath import split_workspace, HashEmbedder, VectorIndex
28
29graph, texts = split_workspace("./workspace")
30embedder = HashEmbedder()
31index = VectorIndex()
32for nid, content in texts.items():
33 index.upsert(nid, embedder.embed(content))
34```
35
36## Embeddings and LLM callbacks
37
38- Default: `HashEmbedder` (hash-v1, 1024-dim)
39- Real: callback `embed_fn` / `embed_batch_fn` (e.g., `text-embedding-3-small`)
40- LLM routing: callback `llm_fn` using `gpt-5-mini` (example)
41
42## Session Replay
43
44`replay_queries(graph, queries)` can warm-start from historical turns.
45
46## CLI
47
48`--state` is preferred:
49
50`crabpath query TEXT --state S [--top N] [--json]`
51`crabpath query TEXT --state S --chat-id CID`
52
53`crabpath doctor --state S`
54`crabpath info --state S`
55`crabpath init --workspace W --output O --embedder openai`
56`crabpath query TEXT --state S --llm openai`
57`crabpath inject --state S --type TEACHING [--type DIRECTIVE]`
58
59Real-time correction flow:
60`python3 query_brain.py --chat-id CHAT_ID`
61`python3 learn_correction.py --chat-id CHAT_ID`
62
63## Quick Reference
64- `crabpath init/query/learn/inject/health/doctor/info`
65- `query_brain.py --chat-id` and `learn_correction.py` for real-time correction pipelines
66- `query_brain.py` traversal limits: `beam_width=8`, `max_hops=30`, `fire_threshold=0.01`
67- Hard traversal caps: `max_fired_nodes` and `max_context_chars` (defaults `None`; `query_brain.py` defaults `max_context_chars=20000`)
68- `examples/correction_flow/`, `examples/cold_start/`, `examples/openai_embedder/`
69
70## API Reference
71
72- Core lifecycle:
73 - `split_workspace`
74 - `load_state`
75 - `save_state`
76 - `ManagedState`
77 - `VectorIndex`
78- Traversal and learning:
79 - `traverse`
80 - `TraversalConfig`
81 - `TraversalConfig.beam_width`, `.max_hops`, `.fire_threshold`, `.max_fired_nodes`, `.max_context_chars`, `.reflex_threshold`, `.habitual_range`, `.inhibitory_threshold`
82 - `TraversalResult`
83 - `apply_outcome`
84- Runtime injection APIs:
85 - `inject_node`
86 - `inject_correction`
87 - `inject_batch`
88- Maintenance helpers:
89 - `suggest_connections`, `apply_connections`
90 - `suggest_merges`, `apply_merge`
91 - `measure_health`, `autotune`, `replay_queries`
92- Embedding utilities:
93 - `HashEmbedder`
94 - `OpenAIEmbedder`
95 - `default_embed`
96 - `default_embed_batch`
97 - `openai_llm_fn`
98- LLM routing callbacks:
99 - `chat_completion`
100- Graph primitives:
101 - `Node`
102 - `Edge`
103 - `Graph`
104 - `split_workspace`
105 - `generate_summaries`
106
107## CLI Commands
108
109- `crabpath init --workspace W --output O [--sessions S] [--embedder openai]`
110- `crabpath query TEXT --state S [--top N] [--json] [--chat-id CHAT_ID]`
111- `crabpath learn --state S --outcome N --fired-ids a,b,c [--json]`
112- `crabpath inject --state S --id NODE_ID --content TEXT [--type CORRECTION|TEACHING|DIRECTIVE] [--json] [--connect-min-sim 0.0]`
113- `crabpath inject --state S --id NODE_ID --content TEXT --type TEACHING`
114- `crabpath inject --state S --id NODE_ID --content TEXT --type DIRECTIVE`
115- `crabpath health --state S`
116- `crabpath doctor --state S`
117- `crabpath info --state S`
118- `crabpath replay --state S --sessions S`
119- `crabpath merge --state S [--llm openai]`
120- `crabpath connect --state S [--llm openai]`
121- `crabpath journal [--stats]`
122- `query_brain.py --chat-id CHAT_ID`
123- `learn_correction.py --chat-id CHAT_ID`
124
125## Traversal defaults
126
127- `beam_width=8`
128- `max_hops=30`
129- `fire_threshold=0.01`
130- `reflex_threshold=0.6`
131- `habitual_range=0.2-0.6`
132- `inhibitory_threshold=-0.01`
133- `max_fired_nodes` (hard node-count cap, default `None`)
134- `max_context_chars` (hard context cap, default `None`; `query_brain.py` default is `20000`)
135
136## Paper
137
138https://jonathangu.com/crabpath/