chaotic_semantic_memory
chaotic_semantic_memory is a Rust crate for AI memory systems built on:
- 10240-bit hyperdimensional vectors
- chaotic echo-state reservoirs
- libSQL persistence
It targets both native and wasm32 builds with explicit threading guards.
Quick Links
| Resource | Link |
|---|---|
| Documentation | docs.rs/chaotic_semantic_memory |
| Crates.io | crates.io/crates/chaotic_semantic_memory |
| Issues | GitHub Issues |
| Changelog | CHANGELOG.md |
Status
| Property | Value |
|---|---|
| Version | 0.1.0 |
| MSRV | Rust 1.85 |
| License | MIT |
| Targets | Native, wasm32-unknown-unknown |
Installation
Enable WASM bindings when needed:
[]
= { = "0.1.0", = ["wasm"] }
Core Components
hyperdim: binary hypervector math (HVec10240) and similarity operationsreservoir: sparse chaotic reservoir dynamics with spectral radius controlssingularity: concept graph, associations, retrieval, and memory limitsframework: high-level async orchestration APIpersistence: libSQL-backed storage (native only)wasm: JS-facing bindings for browser/runtime integrationcli: Command-line interface (csmbinary)
CLI Usage
The csm binary provides command-line access:
# Inject a concept
# Find similar concepts
# Create associations
# Export memory state
# Import memory state
# Generate shell completions
CLI Commands
| Command | Description |
|---|---|
inject |
Inject a new concept with a random or provided vector |
probe |
Find similar concepts by concept ID |
associate |
Create an association between two concepts |
export |
Export memory state to JSON or binary |
import |
Import memory state from file |
version |
Show version information |
completions |
Generate shell completions |
Quick Start
use *;
async
See examples/proof_of_concept.rs for an end-to-end flow.
See examples/basic_in_memory.rs for the minimal in-memory workflow.
Configuration
ChaoticSemanticFramework::builder() exposes runtime tuning knobs.
| Parameter | Default | Valid Range | Effect |
|---|---|---|---|
reservoir_size |
50_000 |
> 0 |
Reservoir capacity and memory footprint |
reservoir_input_size |
10_240 |
> 0 |
Width of each sequence step |
chaos_strength |
0.1 |
0.0..=1.0 (recommended) |
Noise amplitude in chaotic updates |
enable_persistence |
true |
boolean | Enables libSQL persistence setup |
max_concepts |
None |
optional positive | Evicts oldest concepts when reached |
max_associations_per_concept |
None |
optional positive | Keeps strongest associations only |
connection_pool_size |
10 |
>= 1 |
Turso/libSQL remote pool size |
max_probe_top_k |
10_000 |
>= 1 |
Input guard for probe and batch probes |
max_metadata_bytes |
None |
optional positive | Metadata payload size guard |
concept_cache_size |
1_000 |
>= 1 |
Similarity query cache capacity |
Tuning Guide
- Small workloads: disable persistence and use
reservoir_sizearound10_240. - Mid-sized workloads: keep defaults and set
max_conceptsto enforce memory ceilings. - Large workloads: keep persistence enabled, increase
connection_pool_size, and tunemax_probe_top_kto practical limits.
API Patterns
In-memory flow:
let framework = builder
.without_persistence
.build
.await?;
Persistent flow:
let framework = builder
.with_local_db
.build
.await?;
Batch APIs for bulk workloads:
framework.inject_concepts.await?;
framework.associate_many.await?;
let hits = framework.probe_batch.await?;
Load semantics:
load_replace(): clear in-memory state, then load persisted data.load_merge(): merge persisted state into current in-memory state.
WASM Build
Notes:
- WASM threading-sensitive paths are guarded with
#[cfg(not(target_arch = "wasm32"))]. - Persistence is intentionally unavailable on
wasm32in this crate build. - WASM parity APIs include
processSequence,exportToBytes, andimportFromBytes.
Development Gates
LOC policy: each source file in src/ must stay at or below 500 lines.
Mutation Testing
Install cargo-mutants once:
Run profiles:
Reports are written under progress/mutation/.
Benchmark Gates
Primary perf gate: reservoir_step_50k < 100us.
Security
Reporting Vulnerabilities
Please report security vulnerabilities privately via GitHub Security Advisories.
Do not file public issues for security bugs.
Supported Versions
| Version | Supported |
|---|---|
| 0.1.x | Yes |
Security Features
- No hardcoded secrets or credentials in source code
- Input validation on all public APIs
- Memory limits enforced via
max_concepts,max_metadata_bytes, andmax_probe_top_k - WASM build excludes persistence layer (no filesystem access)
License
MIT