Python SDK for Recall by VecLabs — cryptographic memory layer for AI agents
Project description
solvec — Python SDK for Recall by VecLabs
Cryptographic memory layer for AI agents. Fast. Private. Verifiable on Solana.
Installation
pip install solvec
# With Solana verification (Phase 2)
pip install "solvec[solana]"
# With Shadow Drive (Phase 5)
pip install "solvec[shadow-drive]"
# Full install
pip install "solvec[all]"
Quick Start
from solvec import SolVec
sv = SolVec()
collection = sv.collection("agent-memory", dimensions=1536)
# Insert memories
collection.upsert([
{"id": "mem_001", "values": embedding, "metadata": {"source": "conversation"}},
{"id": "mem_002", "values": embedding2, "metadata": {"source": "document"}},
])
# Semantic search
response = collection.query(vector=query_embedding, top_k=5)
for match in response.matches:
print(f"{match.id}: {match.score:.4f} — {match.metadata}")
Phase 4: Encryption
from solvec import SolVec, EncryptionConfig
sv = SolVec(
encryption=EncryptionConfig(
enabled=True,
passphrase="your-secret-passphrase"
)
)
collection = sv.collection("encrypted-memories", dimensions=1536)
# All vectors and metadata are encrypted at rest using AES-256-GCM
Phase 2: Solana Verification
from solvec import SolVec, SolanaConfig
sv = SolVec(
solana=SolanaConfig(
enabled=True,
network="devnet",
keypair="/path/to/keypair.json"
)
)
collection = sv.collection("verified-memories", dimensions=1536)
# After upsert, Merkle root is posted to Solana asynchronously
collection.upsert([{"id": "mem_001", "values": embedding}])
# Verify integrity
result = collection.verify()
print(f"Tampered: {not result.verified}")
Phase 5: Shadow Drive
from solvec import SolVec, ShadowDriveConfig
sv = SolVec(
shadow_drive=ShadowDriveConfig(
enabled=True,
keypair="/path/to/keypair.json",
snapshot_interval=10, # snapshot every 10 writes
)
)
collection = sv.collection("persistent-memories", dimensions=1536)
Phase 6: Memory Inspector
from solvec import SolVec, InspectorQuery
sv = SolVec()
collection = sv.collection("agent-memory", dimensions=1536)
# Write some memories
collection.upsert([
{"id": "mem_001", "values": embedding1, "metadata": {"type": "episodic"}},
{"id": "mem_002", "values": embedding2, "metadata": {"type": "semantic"}},
])
# Get the inspector
inspector = collection.inspector()
# Fast collection stats
stats = inspector.stats()
print(f"Total: {stats.total_memories} memories")
print(f"Size: {stats.memory_usage_bytes} bytes")
print(f"Merkle root: {stats.current_merkle_root}")
# Filter memories
result = inspector.inspect(InspectorQuery(
metadata_filter={"type": "episodic"},
limit=20,
))
for record in result.memories:
print(f"{record.id} — written at {record.written_at}ms")
# Get a single record
record = inspector.get("mem_001")
print(f"Vector dim: {len(record.vector)}")
print(f"Merkle root at write: {record.merkle_root_at_write}")
# Semantic search with full records
matches = inspector.search_with_records(query_vector, k=5)
for score, record in matches:
print(f"{record.id}: {score:.4f}")
# Merkle history
history = inspector.merkle_history()
for entry in history:
print(f"{entry.trigger} — {entry.memory_count_at_time} memories — {entry.root[:16]}...")
# Tamper detection
proof = inspector.verify()
print("All good" if proof["match"] else "TAMPERED!")
API Reference
SolVec
SolVec(
encryption: EncryptionConfig = None,
solana: SolanaConfig = None,
shadow_drive: ShadowDriveConfig = None,
)
| Method | Description |
|---|---|
collection(name, dimensions, metric) |
Get or create a named collection |
list_collections() |
List all collection names |
drop_collection(name) |
Remove a collection from registry |
SolVecCollection
| Method | Returns | Description |
|---|---|---|
upsert(records) |
UpsertResponse |
Insert or update vectors |
query(vector, top_k, filter) |
QueryResponse |
Similarity search |
delete(ids) |
DeleteResponse |
Delete by ID |
fetch(ids) |
dict |
Fetch by exact ID |
describe_index_stats() |
CollectionStats |
Basic statistics |
verify() |
VerificationResult |
Merkle root verification |
inspector() |
MemoryInspector |
Get Memory Inspector (Phase 6) |
MemoryInspector
| Method | Returns | Description |
|---|---|---|
stats() |
InspectorCollectionStats |
O(1) collection stats |
inspect(query) |
InspectionResult |
Filtered memory list |
get(id) |
MemoryRecord | None |
Single record by ID |
search_with_records(vector, k) |
list[tuple[float, MemoryRecord]] |
Search with full records |
merkle_history() |
list[MerkleHistoryEntry] |
Root change history |
verify() |
dict |
Tamper detection |
Running Tests
cd sdk/python
pip install -e ".[dev]"
pytest tests/ -v
Expected: 41 tests passing — 12 collection, 8 encryption, 6 merkle, 11 inspector, 4 shadow drive.
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
solvec-0.1.0a7.tar.gz
(19.2 kB
view details)
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
solvec-0.1.0a7-py3-none-any.whl
(18.0 kB
view details)
File details
Details for the file solvec-0.1.0a7.tar.gz.
File metadata
- Download URL: solvec-0.1.0a7.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c8318df594b9c68eca6bd70d86bcad69b2aee403e0ff55404e24e4f8e4e1ad6
|
|
| MD5 |
f00bd44d693cc369b4516f953fa0aff7
|
|
| BLAKE2b-256 |
0884833d0f137dfd782673378b5ebce6465594bd8dc002a755a3d84a7a490ecc
|
File details
Details for the file solvec-0.1.0a7-py3-none-any.whl.
File metadata
- Download URL: solvec-0.1.0a7-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64960ac6de77433faa13ba64e828f52a3d8ed78aa0a472daba7be651266c3f9
|
|
| MD5 |
b065cb3dd50f714a01730b288706e6a6
|
|
| BLAKE2b-256 |
ed39324541415461063fb14d70c0ca69a8576a8c6e93f2ec4ea75edc57023904
|