# 🔍 Cortex Server: Feature Gap Analysis & Roadmap

This document outlines the missing capabilities required to evolve the **Cortex Boss (Server)** from a Proof of Concept into a highly available, secure, and scalable central orchestrator.

## 1. 💾 Registry & Task Persistence
Currently, the `NodeRegistry` and `WorkPool` are entirely in-memory.
- **The Gap**: If the server restarts, all active node sessions, task histories, and heartbeat data are lost.
- **Required**: A persistent backend (e.g., PostgreSQL or Redis) to store node metadata, lifelong audit logs, and the global task queue state.

## 2. ⚖️ Vertical & Horizontal Scalability
The server is currently a single-process gRPC listener.
- **The Gap**: A single server cannot scale to thousands of active mTLS connections or handle geographic distribution.
- **Required**: A stateless server design where node connections can be balanced across a cluster using a shared message broker (like RabbitMQ or NATS) for task dispatch.

## 3. 🎯 Advanced Scheduling & Capability Routing
The `TaskAssistant` uses basic "best manager" logic.
- **The Gap**: No support for complex constraints (e.g., "Node must have NVIDIA GPU", "Node must be in US-East region", "Task priority: High").
- **Required**: A sophisticated scheduler that matches task requirements against node capabilities and real-time health metrics (Telemetric Routing).

## 4. 🔐 mTLS Certificate Lifecycle Management
Certificates are currently static files manually generated.
- **The Gap**: No mechanism for automatic renewal, revocation, or hardware-backed security (HSM).
- **Required**: Integration with a Certificate Authority (CA) like HashiCorp Vault or AWS Private CA to manage automatic node cert rotation and CRL (Certificate Revocation List) checking.

## 5. 📜 Immutable Audit & Compliance
The server lacks a "Black Box" recorder.
- **The Gap**: No forensic record of which command was authorized by which user and executed on which node.
- **Required**: An immutable audit log where every `TaskRequest` and signed `TaskResponse` is archived with cryptographic timestamps for security auditing.

## 🏢 Multi-Tenancy & Resource Isolation
- **Tenant Guardrails**: Logic to ensure Node A (owned by User X) can never receive a task from User Y.
- **Resource Quotas**: Limiting the number of concurrent tasks a specific user or node group can consume.
- **Web Console / API**: A management UI to visualize the global fleet, manually cancel "zombie" tasks, and update node policies.

---
> [!TIP]
> This roadmap transforms the server from a "gRPC Bridge" into a "Sovereign Control Plane" capable of managing enterprise-scale distributed intelligence.
