The Cortex - Unified memory and state management service for Aperion
Project description
Aperion State Gateway — "The Cortex"
Unified memory and state management service for the Aperion AI platform.
The Cortex separates Reasoning (transient LLM processing) from Memory (persistent storage), providing a centralized service for context packing, vector search, and the event ledger.
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ THE CORTEX │
│ (Port 4949) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ HOT │ │ WARM │ │ COLD │ │
│ │ STATE │ │ CONTEXT │ │ STORAGE │ │
│ │ │ │ │ │ │ │
│ │ - Sessions │ │ - Token │ │ - Vector DB (Chroma) │ │
│ │ - Fast KV │ │ Packing │ │ - SQLite Archives │ │
│ │ - TTL Cache │ │ - LLM-ready │ │ - Training Ledger │ │
│ │ │ │ Output │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ API Endpoints (REST) │
│ │
│ GET /state/snapshot │
│ POST /vector/search │
│ GET /db/schema/{name} │
│ POST /audit/record │
│ GET /events/stream (SSE) │
└───────────────────────────────┘
Memory Tiering
Hot State
Active session data with low-latency access. In-memory with optional Redis backend.
Warm Context
The "Context Window" manager. Accepts raw messages/files and returns a token-optimized ContextPack ready for the LLM.
Cold Storage
Long-term persistence via Vector DB (ChromaDB/FAISS) and SQLite.
Quick Start
# Install from PyPI
pip install aperion-cortex
# Or install from source with dev dependencies
pip install -e ".[dev]"
# Run the service
aperion-cortex --port 4949
# Or with uvicorn directly
uvicorn aperion_cortex.service.app:app --host 0.0.0.0 --port 4949
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/state/snapshot |
GET | Returns signed ContextPack |
/vector/search |
POST | Semantic search |
/db/list |
GET | List databases |
/db/schema/{name} |
GET | Database introspection |
/audit/record |
POST | Log agent execution |
/events/stream |
GET | SSE event stream |
/healthz |
GET | Health check |
Docker
docker build -t aperion-cortex .
docker run -p 4949:4949 aperion-cortex
Environment Variables
| Variable | Default | Description |
|---|---|---|
CORTEX_PORT |
4949 |
Service port |
CORTEX_SIGNING_KEY |
(required) | Key for signing ContextPacks |
CORTEX_DB_PATH |
data/cortex.db |
SQLite database path |
CORTEX_VECTOR_BACKEND |
chroma |
Vector store: chroma or faiss |
CORTEX_EMBEDDING_MODEL |
all-MiniLM-L6-v2 |
Sentence transformer model |
CORTEX_LOG_LEVEL |
INFO |
Logging level |
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=aperion_cortex --cov-report=html
# Lint
ruff check src tests
# Type check
mypy src
License
MIT
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
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
File details
Details for the file aperion_cortex-1.2.1.tar.gz.
File metadata
- Download URL: aperion_cortex-1.2.1.tar.gz
- Upload date:
- Size: 96.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92269691fb788f536bbaf12d1b8f292eb8d029788a72f41f615b58c414c5f10b
|
|
| MD5 |
a8842f715ae094c85ceacddaa646eece
|
|
| BLAKE2b-256 |
b7e727c4b47eb534dedc742a831b83595553e46d62d0944177db4a946b8cc8f9
|
Provenance
The following attestation bundles were made for aperion_cortex-1.2.1.tar.gz:
Publisher:
release.yml on invictustitan2/aperion-state-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aperion_cortex-1.2.1.tar.gz -
Subject digest:
92269691fb788f536bbaf12d1b8f292eb8d029788a72f41f615b58c414c5f10b - Sigstore transparency entry: 941988825
- Sigstore integration time:
-
Permalink:
invictustitan2/aperion-state-gateway@64397071002aca696c97e1548f5a8cf85fa77af2 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/invictustitan2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64397071002aca696c97e1548f5a8cf85fa77af2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aperion_cortex-1.2.1-py3-none-any.whl.
File metadata
- Download URL: aperion_cortex-1.2.1-py3-none-any.whl
- Upload date:
- Size: 61.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69b481fc740d41e8cc17fe5288430679d8dd4e59aa8b1e09d6032882010c276a
|
|
| MD5 |
231ceeb6efa7bc775d672c3fef4fa168
|
|
| BLAKE2b-256 |
28c5441c5a216d777678e342cf1ac3c6d87f5088e068c0e369a489e45cbb1296
|
Provenance
The following attestation bundles were made for aperion_cortex-1.2.1-py3-none-any.whl:
Publisher:
release.yml on invictustitan2/aperion-state-gateway
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aperion_cortex-1.2.1-py3-none-any.whl -
Subject digest:
69b481fc740d41e8cc17fe5288430679d8dd4e59aa8b1e09d6032882010c276a - Sigstore transparency entry: 941988864
- Sigstore integration time:
-
Permalink:
invictustitan2/aperion-state-gateway@64397071002aca696c97e1548f5a8cf85fa77af2 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/invictustitan2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64397071002aca696c97e1548f5a8cf85fa77af2 -
Trigger Event:
push
-
Statement type: