Files
clawhdf5/crates/clawhdf5-agent/Cargo.toml
T
osobhandClaude Opus 4.8 8f9dbd812c feat: integrate HNSW into agent search, fix Python 3.14 build
Resolves two gaps found in a project-state review:

1. Python build was broken: PyO3/numpy 0.23 caps at Python 3.13 but the
   environment has 3.14. Bumped to 0.28 and updated the two breaking APIs
   (PyObject -> Py<PyAny>, allow_threads -> detach). The extension module now
   imports and round-trips under Python 3.14, unblocking cargo build --workspace.

2. The "HNSW vector search over agent memories" headline was unwired:
   clawhdf5-ann had zero dependents and the agent used a linear cosine+BM25 scan.
   - clawhdf5-ann is now a live index: insert, mark_deleted (soft delete with a
     deleted bitset, traversed but never returned), compact, and a format
     version tag (v2) with backward-compatible load of v1 files.
   - clawhdf5-agent wires HNSW behind the `hnsw` feature (ON by default). The
     index mirrors the cache (node id == cache index) and self-heals: it rebuilds
     whenever hnsw_synced_len drifts from cache.len(), so unhooked pushes can't
     desync it. Non-indexable stores (no/zero-dim/mixed embeddings) and queries
     whose dim doesn't match fall back to the exact linear scan.
   - hybrid.rs gains merge_vector_keyword, shared by the linear and HNSW paths.
   - tests/hnsw_integration.rs validates recall vs a brute-force oracle plus
     insert/delete/batch behaviour.

Disable HNSW for exact search with `--no-default-features --features float16`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-03 07:10:48 +00:00

63 lines
2.2 KiB
TOML

[package]
name = "clawhdf5-agent"
version = "2.0.0"
edition = "2024"
description = "HDF5-backed persistent memory store for on-device AI agents"
license = "MIT"
repository = "https://github.com/redclawsystems/clawhdf5"
readme = "README.md"
keywords = ["agent", "memory", "hdf5", "vector-search", "embedding"]
categories = ["database", "science", "algorithms"]
[dependencies]
clawhdf5-format = { path = "../clawhdf5-format", version = "2.0.0", features = ["parallel", "fast-checksum"] }
clawhdf5 = { path = "../clawhdf5", version = "2.0.0" }
clawhdf5-io = { path = "../clawhdf5-io", version = "2.0.0", features = ["mmap"] }
clawhdf5-accel = { path = "../clawhdf5-accel", version = "2.0.0" }
clawhdf5-ann = { path = "../clawhdf5-ann", version = "2.0.0", optional = true }
clawhdf5-gpu = { path = "../clawhdf5-gpu", version = "2.0.0", optional = true, default-features = false }
serde = { version = "1", features = ["derive"] }
byteorder = "1"
half = { version = "2", optional = true }
rayon = { version = "1", optional = true }
matrixmultiply = { version = "0.3", optional = true }
cblas-sys = { version = "0.1", optional = true }
tokio = { version = "1", features = ["rt", "sync", "macros", "time"], optional = true }
[target.'cfg(target_os = "macos")'.dependencies]
accelerate-src = { version = "0.3", optional = true }
[target.'cfg(not(target_os = "macos"))'.dependencies]
openblas-src = { version = "0.10", optional = true, features = ["cblas"] }
[dev-dependencies]
tempfile = "3"
criterion = "0.5"
rayon = "1"
tokio = { version = "1", features = ["rt-multi-thread", "sync", "macros"] }
[[bench]]
name = "bench"
harness = false
[[bench]]
name = "memory_bench"
harness = false
[features]
default = ["float16", "hnsw"]
float16 = ["half"]
parallel = ["rayon"]
# HNSW approximate-nearest-neighbour acceleration for the vector stage of
# hybrid_search. On by default; the index is rebuilt from the cache on demand
# and stays self-consistent with the persisted memory store. Disable with
# `--no-default-features` (plus re-enabling other defaults) to force the exact
# linear cosine scan.
hnsw = ["clawhdf5-ann"]
agent = []
gpu = ["clawhdf5-gpu/gpu-wgpu"]
fast-math = ["matrixmultiply"]
accelerate = ["accelerate-src", "cblas-sys"]
openblas = ["openblas-src", "cblas-sys"]
async = ["tokio"]