Skip to main content

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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aperion_cortex-0.1.0.tar.gz (96.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aperion_cortex-0.1.0-py3-none-any.whl (61.8 kB view details)

Uploaded Python 3

File details

Details for the file aperion_cortex-0.1.0.tar.gz.

File metadata

  • Download URL: aperion_cortex-0.1.0.tar.gz
  • Upload date:
  • Size: 96.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aperion_cortex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f1c25de5e86a8da7720e2828855248e9793f6b9bc49b1d44f74ad3dac756190
MD5 870f682fd01c3d23d6d017b21adcb635
BLAKE2b-256 6baa13906bca4a665a0654058948450d6be96d36b00f2e51d3801a0124a0d10f

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_cortex-0.1.0.tar.gz:

Publisher: release.yml on invictustitan2/aperion-state-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aperion_cortex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aperion_cortex-0.1.0-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

Hashes for aperion_cortex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c319ab9818df328641a194a0df761e69a17b5ecb71fbd446970c59609049ee8
MD5 52d663af7a8b51c1c936db89ce7e95ab
BLAKE2b-256 2e03c0b8f276466d759bca86321f567f0c2f34e4fe49602368b5160253db994f

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_cortex-0.1.0-py3-none-any.whl:

Publisher: release.yml on invictustitan2/aperion-state-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page