knowledge-rag 4.8.3 → 4.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,19 +230,32 @@ See [Changelog](#changelog) for full history.
|
|
|
230
230
|
flowchart TB
|
|
231
231
|
subgraph MCP["MCP SERVER (FastMCP)"]
|
|
232
232
|
direction TB
|
|
233
|
-
TOOLS["13 MCP Tools<br/>
|
|
233
|
+
TOOLS["13 MCP Tools (frozen, LEI 1)<br/>search_knowledge | get_document | search_similar<br/>add_document | add_from_url | update_document | remove_document<br/>reindex_documents | get_reindex_status<br/>list_categories | list_documents | get_index_stats | evaluate_retrieval"]
|
|
234
234
|
end
|
|
235
235
|
|
|
236
|
-
subgraph SEARCH["
|
|
236
|
+
subgraph SEARCH["SEARCH DISPATCH (v4.8.2+)"]
|
|
237
|
+
direction TB
|
|
238
|
+
SM["search_method dispatch<br/>auto | hybrid | fts5"]
|
|
239
|
+
QROUTER["QueryRouter (regex)<br/>lexical vs semantic<br/>(ADR-002)"]
|
|
240
|
+
FTS5PATH["FTS5 Fast-Path<br/>(exact identifiers <10ms)"]
|
|
241
|
+
HYBRIDPATH["Hybrid Pipeline<br/>(conceptual queries)"]
|
|
242
|
+
|
|
243
|
+
SM --> QROUTER
|
|
244
|
+
QROUTER -->|lexical| FTS5PATH
|
|
245
|
+
QROUTER -->|semantic| HYBRIDPATH
|
|
246
|
+
FTS5PATH -.->|not_ready / low_hits<br/>fallback| HYBRIDPATH
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
subgraph HYBRID["HYBRID PIPELINE"]
|
|
237
250
|
direction LR
|
|
238
|
-
|
|
251
|
+
KWROUTER["Keyword Router<br/>(word boundaries → category filter)"]
|
|
239
252
|
SEMANTIC["Semantic Search<br/>(ChromaDB)"]
|
|
240
253
|
BM25["BM25 Keyword<br/>(inverted-index + expansion)"]
|
|
241
254
|
RRF["Reciprocal Rank<br/>Fusion (RRF)"]
|
|
242
255
|
RERANK["Cross-Encoder<br/>Reranker"]
|
|
243
256
|
|
|
244
|
-
|
|
245
|
-
|
|
257
|
+
KWROUTER --> SEMANTIC
|
|
258
|
+
KWROUTER --> BM25
|
|
246
259
|
SEMANTIC --> RRF
|
|
247
260
|
BM25 --> RRF
|
|
248
261
|
RRF --> RERANK
|
|
@@ -250,9 +263,11 @@ flowchart TB
|
|
|
250
263
|
|
|
251
264
|
subgraph STORAGE["STORAGE LAYER"]
|
|
252
265
|
direction LR
|
|
253
|
-
CHROMA[("ChromaDB<br/>
|
|
254
|
-
|
|
266
|
+
CHROMA[("ChromaDB<br/>data/chroma_db/<br/>(vector store)")]
|
|
267
|
+
FTS5DB[("SQLite FTS5<br/>data/fts5_index.db<br/>(lexical index, ADR-001)")]
|
|
268
|
+
COLLECTIONS["8 Categories<br/>redteam | blueteam | ctf<br/>security | logscale<br/>development | aar | general"]
|
|
255
269
|
CHROMA --- COLLECTIONS
|
|
270
|
+
FTS5DB --- COLLECTIONS
|
|
256
271
|
end
|
|
257
272
|
|
|
258
273
|
subgraph EMBED["EMBEDDINGS (In-Process)"]
|
|
@@ -264,36 +279,55 @@ flowchart TB
|
|
|
264
279
|
subgraph INGEST["DOCUMENT INGESTION"]
|
|
265
280
|
PARSERS["20 Parsers<br/>MD | PDF | TXT | PY | C | H | CPP | JS | JSX | TS | TSX | JSON | XML | CSV<br/>DOCX | XLSX | PPTX | IPYNB | MQH | MQ4"]
|
|
266
281
|
CHUNKER["Chunking<br/>MD: section-aware<br/>Other: 1000 chars + 200 overlap"]
|
|
267
|
-
|
|
282
|
+
FTS5SYNC["FTS5 CRUD sync<br/>(v4.8.2 task 05)"]
|
|
283
|
+
PARSERS --> CHUNKER --> FTS5SYNC
|
|
268
284
|
end
|
|
269
285
|
|
|
270
286
|
CLAUDE["Claude Code"] --> MCP
|
|
271
287
|
MCP --> SEARCH
|
|
272
|
-
|
|
288
|
+
HYBRIDPATH --> HYBRID
|
|
289
|
+
FTS5PATH --> FTS5DB
|
|
290
|
+
HYBRID --> STORAGE
|
|
273
291
|
STORAGE --> EMBED
|
|
274
292
|
INGEST --> EMBED
|
|
275
293
|
EMBED --> STORAGE
|
|
294
|
+
FTS5SYNC --> FTS5DB
|
|
276
295
|
```
|
|
277
296
|
|
|
278
297
|
### Query Processing Flow
|
|
279
298
|
|
|
280
299
|
```mermaid
|
|
281
300
|
flowchart TB
|
|
282
|
-
QUERY["User Query<br/>'mimikatz credential dump'"] -->
|
|
301
|
+
QUERY["User Query<br/>'mimikatz credential dump' | 'CVE-2021-4034'"] --> METHOD
|
|
302
|
+
|
|
303
|
+
subgraph DISPATCH["Dispatch (v4.8.2+, ADR-006)"]
|
|
304
|
+
METHOD{"search_method<br/>auto | hybrid | fts5"}
|
|
305
|
+
AUTOROUTE["QueryRouter.classify()<br/>regex-based lexical detection"]
|
|
306
|
+
FASTPATH["FTS5 Fast-Path<br/>SQLite MATCH<br/>(<10ms cold, <2ms hot)"]
|
|
307
|
+
NOTREADY{"FTS5 ready<br/>AND hits >= min_hits?"}
|
|
308
|
+
|
|
309
|
+
METHOD -->|auto| AUTOROUTE
|
|
310
|
+
METHOD -->|fts5| FASTPATH
|
|
311
|
+
METHOD -->|hybrid| EXPAND
|
|
312
|
+
AUTOROUTE -->|lexical| FASTPATH
|
|
313
|
+
AUTOROUTE -->|semantic| EXPAND
|
|
314
|
+
FASTPATH --> NOTREADY
|
|
315
|
+
NOTREADY -->|no, fallback| EXPAND
|
|
316
|
+
end
|
|
283
317
|
|
|
284
|
-
subgraph EXPANSION["Query Expansion"]
|
|
318
|
+
subgraph EXPANSION["Query Expansion (hybrid path)"]
|
|
285
319
|
EXPAND["Synonym Expansion<br/>mimikatz -> mimikatz, sekurlsa, logonpasswords"]
|
|
286
320
|
end
|
|
287
321
|
|
|
288
|
-
EXPAND -->
|
|
322
|
+
EXPAND --> KWROUTER
|
|
289
323
|
|
|
290
|
-
subgraph ROUTING["Keyword Routing"]
|
|
291
|
-
|
|
324
|
+
subgraph ROUTING["Keyword Routing (category filter)"]
|
|
325
|
+
KWROUTER["Keyword Router<br/>(word boundaries)"]
|
|
292
326
|
MATCH{"Word Boundary<br/>Match?"}
|
|
293
327
|
CATEGORY["Filter: redteam"]
|
|
294
328
|
NOFILTER["No Filter"]
|
|
295
329
|
|
|
296
|
-
|
|
330
|
+
KWROUTER --> MATCH
|
|
297
331
|
MATCH -->|Yes| CATEGORY
|
|
298
332
|
MATCH -->|No| NOFILTER
|
|
299
333
|
end
|
|
@@ -326,7 +360,8 @@ flowchart TB
|
|
|
326
360
|
BM25 --> RRF
|
|
327
361
|
|
|
328
362
|
ADJ --> MINSCORE
|
|
329
|
-
|
|
363
|
+
NOTREADY -->|yes, hit| MINSCORE
|
|
364
|
+
SNIPPET --> RESULTS["Results<br/>search_method: fts5 | hybrid | semantic | keyword<br/>routed_by: fts5_router | none<br/>score + filtered_by_score + content_length"]
|
|
330
365
|
```
|
|
331
366
|
|
|
332
367
|
### Document Ingestion Flow
|
|
@@ -334,7 +369,7 @@ flowchart TB
|
|
|
334
369
|
```mermaid
|
|
335
370
|
flowchart LR
|
|
336
371
|
subgraph INPUT["Input"]
|
|
337
|
-
FILES["documents/<br/>├── security/<br/>├──
|
|
372
|
+
FILES["documents/<br/>├── security/<br/>│ ├── redteam/<br/>│ ├── blueteam/<br/>│ └── ctf/<br/>├── aar/<br/>├── logscale/<br/>├── development/<br/>└── general/"]
|
|
338
373
|
end
|
|
339
374
|
|
|
340
375
|
subgraph PARSE["Parse (20 formats)"]
|
|
@@ -354,9 +389,18 @@ flowchart LR
|
|
|
354
389
|
FASTEMBED["FastEmbed ONNX<br/>bge-small-en-v1.5<br/>(384D, CPU or GPU)"]
|
|
355
390
|
end
|
|
356
391
|
|
|
392
|
+
subgraph DISPATCH["Write Dispatch (v4.8.3, #161)"]
|
|
393
|
+
WCOL{"_write_collection<br/>routes writes"}
|
|
394
|
+
STAGING["Staging Collection<br/>(nuclear_rebuild only,<br/>keeps prod serving queries)"]
|
|
395
|
+
PROD["Production Collection<br/>(default)"]
|
|
396
|
+
WCOL -->|_staging_target set| STAGING
|
|
397
|
+
WCOL -->|default| PROD
|
|
398
|
+
end
|
|
399
|
+
|
|
357
400
|
subgraph STORE["Store"]
|
|
358
|
-
CHROMADB[("ChromaDB")]
|
|
359
|
-
BM25IDX["BM25 Index"]
|
|
401
|
+
CHROMADB[("ChromaDB<br/>data/chroma_db/")]
|
|
402
|
+
BM25IDX["BM25 Index<br/>(in-memory,<br/>rebuilt on write)"]
|
|
403
|
+
FTS5DB[("SQLite FTS5<br/>data/fts5_index.db<br/>(CRUD-synced, ADR-008)")]
|
|
360
404
|
end
|
|
361
405
|
|
|
362
406
|
FILES --> MD & PDF & OFFICE & CODE
|
|
@@ -365,14 +409,20 @@ flowchart LR
|
|
|
365
409
|
MDSPLIT --> DEDUP
|
|
366
410
|
TXTSPLIT --> DEDUP
|
|
367
411
|
DEDUP --> EMBED
|
|
368
|
-
EMBED -->
|
|
412
|
+
EMBED --> DISPATCH
|
|
413
|
+
STAGING --> CHROMADB
|
|
414
|
+
PROD --> CHROMADB
|
|
415
|
+
PROD --> BM25IDX
|
|
416
|
+
PROD --> FTS5DB
|
|
369
417
|
```
|
|
370
418
|
|
|
371
419
|
### hybrid_alpha Parameter Effect
|
|
372
420
|
|
|
421
|
+
`hybrid_alpha` weights RRF fusion between semantic and BM25 rankings on the **hybrid pipeline only**. When `search_method="auto"` and the QueryRouter classifies the query as lexical (e.g. `CVE-2021-4034`, `MDR-AD002`, `T1078.001`, file hashes), the FTS5 fast-path fires and `hybrid_alpha` is not consulted — FTS5 uses SQLite's native `bm25()` scoring exclusively. Pass `search_method="hybrid"` to force RRF fusion + rerank on every query if you want deterministic hybrid semantics regardless of the query shape.
|
|
422
|
+
|
|
373
423
|
```mermaid
|
|
374
424
|
flowchart LR
|
|
375
|
-
subgraph ALPHA["hybrid_alpha values"]
|
|
425
|
+
subgraph ALPHA["hybrid_alpha values (hybrid path only)"]
|
|
376
426
|
A0["0.0<br/>Pure BM25<br/>Instant"]
|
|
377
427
|
A3["0.3 (default)<br/>Keyword-heavy<br/>Fast"]
|
|
378
428
|
A5["0.5<br/>Balanced"]
|
|
@@ -381,7 +431,7 @@ flowchart LR
|
|
|
381
431
|
end
|
|
382
432
|
|
|
383
433
|
subgraph USE["Best For"]
|
|
384
|
-
U0["CVEs, tool names<br/>exact matches"]
|
|
434
|
+
U0["CVEs, tool names<br/>exact matches<br/>(consider FTS5 fast-path)"]
|
|
385
435
|
U3["Technical queries<br/>specific terms"]
|
|
386
436
|
U5["General queries"]
|
|
387
437
|
U7["Conceptual queries<br/>related topics"]
|
|
@@ -1435,6 +1485,23 @@ Common issues:
|
|
|
1435
1485
|
|
|
1436
1486
|
### Unreleased
|
|
1437
1487
|
|
|
1488
|
+
### v4.8.4 (2026-08-13) — Patch: security + durability + defensive fixes
|
|
1489
|
+
|
|
1490
|
+
**Recommended upgrade for anyone running HTTP/SSE transport with bearer auth on a non-loopback host, or relying on `reindex_documents(force=True)`.** Four independent fixes accumulated since v4.8.3: one previously blocked remote-with-auth deployments (#174), one silently corrupted durable index metadata after a failed rebuild (#173), and two defensive fixes hardened `.ipynb` ingestion (#175) and the nightly chaos suite (#164).
|
|
1491
|
+
|
|
1492
|
+
**Fixed:**
|
|
1493
|
+
|
|
1494
|
+
- **fix(security)** — create the HTTP MCP app with the configured `server_host`. On the bearer-auth path the app factory was called without a host, so it defaulted to `127.0.0.1` and MCP 2.0.0's localhost-only DNS-rebinding allowlist rejected a configured non-loopback host with `421 Invalid Host header` before auth ran — even though uvicorn was bound to that host. Remote/LAN deployments with auth are now reachable (#174).
|
|
1495
|
+
- **fix(reindex)** — restore durable metadata on a failed zero-downtime rebuild. The staging populate path persisted the staging map to `index_metadata.json` before validation ran; when validation failed, rollback restored only the in-memory `_indexed_docs`, leaving the file describing staging while memory held production. After a restart `_load_metadata` trusted the stale file, corrupting skip/update and embedding-dimension decisions. Rollback now re-persists the restored production metadata (#173).
|
|
1496
|
+
- **fix(ingestion)** — `_parse_ipynb` handled invalid JSON gracefully but then assumed the parsed notebook was a well-formed dict. A valid-JSON notebook with a null `metadata` or `cells` field, a non-dict cell, a bare list, or a dict cell whose `source` is not `str | list[str]` (a number, a dict, or a list with non-string items) crashed with `AttributeError`/`TypeError`. Guarded the notebook, `metadata`, `cells`, cell, and cell `source` lookups so a parseable-but-malformed notebook is handled the same as any other odd input (#175, thanks @eeshsaxena).
|
|
1497
|
+
- **fix(ci)** — the nightly chaos job (`pytest -m chaos`) aborted collection with `ModuleNotFoundError: No module named 'hypothesis'` because `tests/test_query_router.py` imported hypothesis at module top-level while the chaos job installs only `pytest psutil numpy`. Guarded the import with `pytest.importorskip("hypothesis")` so the module is skipped cleanly instead of failing the whole nightly run (#164).
|
|
1498
|
+
|
|
1499
|
+
**Docs:**
|
|
1500
|
+
|
|
1501
|
+
- **docs(architecture)** — sync the 4 Mermaid diagrams in `## Architecture` (System Overview, Query Processing Flow, Document Ingestion Flow, hybrid_alpha Parameter Effect) with the v4.8.2 FTS5 fast-path (ADR-002/003/006), the v4.8.3 `_write_collection` staging dispatcher (#161), and the current 8-category layout. The diagrams previously described only the pre-v4.8 hybrid pipeline and 4-category storage; they now also show FTS5 dispatch, fallback semantics, FTS5 CRUD sync (ADR-008), and the zero-downtime staging write path. `hybrid_alpha` now clarifies that the fast-path bypasses RRF entirely so the weighting only matters on the hybrid path.
|
|
1502
|
+
|
|
1503
|
+
**No breaking changes.** Backwards compat verified by `check_api_surface.py` (zero diff vs baseline). All 13 MCP tool parameter names frozen (verified by `tests/test_backwards_compat.py`).
|
|
1504
|
+
|
|
1438
1505
|
### v4.8.3 (2026-08-10) — Critical hotfix: nuclear-rebuild + smart-reindex hardening
|
|
1439
1506
|
|
|
1440
1507
|
**Recommended upgrade for any corpus with >1000 chunks or any user relying on `reindex_documents(force=True)` after a config change.** The v4.8.0 nuclear rebuild + v4.8.2 FTS5 fast-path have several latent state-management bugs that only trigger under a real-world combination (large corpus + rebuild + concurrent queries + FTS5 opt-in). Enterprise users with hacktricks-scale corpora (~50k+ chunks) are affected.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowledge-rag",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
4
4
|
"description": "Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking + 13 MCP Tools + 20 Format Parsers. Zero external servers.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"knowledge-rag": "./bin/cli.js"
|