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


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-1.2.1.tar.gz (96.6 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-1.2.1-py3-none-any.whl (61.8 kB view details)

Uploaded Python 3

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

Hashes for aperion_cortex-1.2.1.tar.gz
Algorithm Hash digest
SHA256 92269691fb788f536bbaf12d1b8f292eb8d029788a72f41f615b58c414c5f10b
MD5 a8842f715ae094c85ceacddaa646eece
BLAKE2b-256 b7e727c4b47eb534dedc742a831b83595553e46d62d0944177db4a946b8cc8f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for aperion_cortex-1.2.1.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-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

Hashes for aperion_cortex-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69b481fc740d41e8cc17fe5288430679d8dd4e59aa8b1e09d6032882010c276a
MD5 231ceeb6efa7bc775d672c3fef4fa168
BLAKE2b-256 28c5441c5a216d777678e342cf1ac3c6d87f5088e068c0e369a489e45cbb1296

See more details on using hashes here.

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

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