interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / cortex-rs / README.md

155 lines · 6191 bytes Raw Blame History Rendered
1<p align="center">
2 <img src="assets/avatar.jpg" width="140" height="140" alt="AIEN Sovereign Intelligence" style="border-radius: 50%; border: 2px solid #f59e0b;">
3</p>
4
5# cortex-rs
6
7[![CI](https://github.com/aien-dev/cortex-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/aien-dev/cortex-rs/actions/workflows/ci.yml)
8[![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
9[![Security](https://img.shields.io/badge/tpm--vault-zero--disk--secrets-green.svg)](SECURITY.md)
10[![Standard](https://img.shields.io/badge/standard-unslop-black.svg)](CONTRIBUTING.md)
11[![Mission](https://img.shields.io/badge/mission-sovereign--defense-amber.svg)](https://drakestapleton.com)
12
13Native Rust memory engine with SQLite FTS5 lexical recall, bi-encoder vector similarity, and hardware-secured loopback isolation.
14
15## Overview
16
17`cortex-rs` is the Linux-hosted memory service (native Rust, Axum) that Atlas and the AIEN agent tools call for lexical and semantic recall. It is not the canonical memory owner: under [ADR 0022](https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/adr/0022-canonical-cortex-owner.md) the canonical Cortex owner at the Omega layer is omega `rx_cortex`, and under [ADR 0036](https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/adr/0036-release-v1-memory-owner.md) the memory the v1 release tests is `aien-allen-memory` attached to an engaged ALLEN identity.
18
19It provides hybrid search combining BM25 full-text indexing with ONNX vector embeddings, enabling autonomous agents to recall procedures, lessons, and architectural discoveries across thousands of turns without context collapse.
20
21## Features
22
23- **Sub-Millisecond Retrieval**: Pure compiled Rust using SQLite WAL mode and FTS5 inverted indexes with typical latency <1ms.
24- **Hybrid Semantic Recall**: Direct integration with local bi-encoder vector servers for cosine similarity and dense embedding scoring.
25- **Hardware Vault Security**: Zero plaintext secrets. All authentication uses bearer token validation bound to loopback interfaces (`127.0.0.1`).
26- **Graph & Provenance Traversal**: Bidirectional relationship edges (`cortex_claims`, `cortex_entities`) for deep contextual graph traversal.
27- **Unslop Standard**: Enforces clean technical facts without AI filler or speculative abstractions.
28
29## Turnkey Reproduction & Benchmarks
30
31Run the engine and observe live latency and throughput metrics directly with a single command.
32
33### 1. One-Line Docker Benchmark
34
35Execute the compiled native benchmark inside a container to evaluate SQLite WAL ingestion, FTS5 lexical retrieval, and graph claim traversal:
36
37```bash
38docker run --rm ghcr.io/aien-dev/cortex-rs:latest --bench
39```
40
41Or build and run locally with Docker:
42
43```bash
44docker build -t cortex-rs https://github.com/aien-dev/cortex-rs.git
45docker run --rm cortex-rs --bench
46```
47
48Verified benchmark output on Grace Blackwell GB10:
49
50```text
51================================================================================
52CORTEX-RS FLAGSHIP REPRODUCTION BENCHMARK
53Target: SQLite WAL + FTS5 Inverted Index + Graph Claim Traversal
54Records to ingest: 500
55================================================================================
56
57[1/3] Benchmarking Entity Ingestion (FTS5 + SQLite WAL)...
58[2/3] Benchmarking FTS5 Lexical Search across 500 records...
59[3/3] Benchmarking Bidirectional Graph Claim Traversal...
60
61================================================================================
62BENCHMARK RESULTS SUMMARY (Reproducible Single-Command Output)
63================================================================================
64Corpus Size: 500 entities
65Total Search Queries Run: 500
66--------------------------------------------------------------------------------
67METRIC p50 (µs) p95 (µs) p99 (µs) Rate / QPS
68--------------------------------------------------------------------------------
69Entity Ingestion (WAL+FTS5) 76.9 145.6 8121.9 4375.6 writes/s
70FTS5 Lexical Search 121.8 452.9 461.3 6341.2 qps
71Graph Claim Traversal 7.3 7.5 10.2 133247.2 qps
72--------------------------------------------------------------------------------
73Search p50 in milliseconds: 0.122 ms
74Search p99 in milliseconds: 0.461 ms
75================================================================================
76```
77
78### 2. Standalone Native Reproduction (Zero Docker)
79
80To run natively on Linux or macOS without Docker:
81
82```bash
83# Clone repository and execute the automated verification runner
84git clone https://github.com/aien-dev/cortex-rs.git
85cd cortex-rs
86./scripts/reproduce.sh
87```
88
89Or run the built-in benchmark directly with Cargo:
90
91```bash
92cargo run --release -- --bench --bench-records 1000
93```
94
95### 3. Running the Production Server
96
97#### Local Process
98
99```bash
100# Compile release binary
101cargo build --release
102
103# Run Cortex-RS on local loopback
104./target/release/cortex-rs --port 18080 --db-path ~/.config/cortex/cortex.db
105```
106
107#### Docker Container
108
109```bash
110docker run -d \
111 --name cortex-rs \
112 -p 18080:18080 \
113 -e CORTEX_TOKEN=your-vault-token \
114 ghcr.io/aien-dev/cortex-rs:latest
115```
116
117### 4. API Endpoints
118
119#### Health Check (Unauthenticated)
120
121```bash
122curl http://127.0.0.1:18080/health
123# {"runtime":"native-arm64-rust","service":"cortex-rs","space":"atlas-memory","status":"ok","version":"0.1.0"}
124```
125
126#### Entity Ingestion
127
128```bash
129curl -X POST http://127.0.0.1:18080/api/cortex/write \
130 -H "Authorization: Bearer <TOKEN>" \
131 -H "Content-Type: application/json" \
132 -d '{
133 "kind": "entity",
134 "value": {
135 "space": "atlas-memory",
136 "canonicalName": "system_module_1",
137 "entityType": "discovery",
138 "content": "Grace Blackwell GB10 unified memory architecture verification."
139 }
140 }'
141```
142
143#### Lexical Search
144
145```bash
146curl -G http://127.0.0.1:18080/api/cortex/search \
147 --data-urlencode "q=unified memory" \
148 -H "Authorization: Bearer <TOKEN>"
149```
150
151## License
152
153This repository is licensed under the **Apache License, Version 2.0 (with LLVM Exception)**.
154
155See [LICENSE](../../LICENSE) for the full legal text.