Commit b5a9ffb
committed
feat(graph): knowledge graph subpackage with dual-backend support
Add qp_vault.graph subpackage: GraphEngine facade, GraphStorageBackend
protocol, PostgreSQL (pg_trgm + recursive CTEs) and SQLite (FTS5 +
Python BFS) implementations. Intelligence services: KnowledgeExtractor,
EntityResolver, EntityDetector, EntityMaterializer, WikilinkResolver.
Membrane sanitization for LLM extraction. Every mutation fires VaultEvents
for capsule audit. Graph-augmented search via graph_boost parameter.
Comprehensive input validation: name/type/relation length caps, properties
size cap (50KB), tag limits, weight bounds, null byte stripping, direction
enum, self-edge/self-merge rejection, limit capping, graph_schema SQL
identifier validation.
177 graph tests + 63 security tests. 1048 total tests passing.
New files:
- src/qp_vault/graph/ (8 modules)
- src/qp_vault/membrane/sanitize.py
- tests/test_graph_*.py (8 test files)
- docs/knowledge-graph.md
Modified:
- enums.py (10 graph EventType values)
- protocols.py (GraphStorageBackend)
- storage/postgres.py (graph DDL, CTE, 20 methods, graph_schema)
- storage/sqlite.py (graph DDL, FTS5, BFS, 20 methods)
- vault.py (vault.graph property, graph_boost search)
- __init__.py (graph exports)
- pyproject.toml (graph extra)
- docs/index.md, architecture.md, api-reference.md, getting-started.md
Made-with: Cursor1 parent 8b93c81 commit b5a9ffb
File tree
29 files changed
+6680
-4
lines changed- docs
- src/qp_vault
- graph
- membrane
- storage
- tests
29 files changed
+6680
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
| |||
430 | 433 | | |
431 | 434 | | |
432 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
433 | 482 | | |
434 | 483 | | |
435 | 484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
36 | 45 | | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
155 | 179 | | |
156 | 180 | | |
157 | 181 | | |
| |||
170 | 194 | | |
171 | 195 | | |
172 | 196 | | |
| 197 | + | |
173 | 198 | | |
174 | 199 | | |
175 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
0 commit comments