_ _ _____ _ _ ___
| \ | || _ || | | | / _ \
| \| || | | || | | |/ /_\ \
| . ` || | | || | | || _ |
| |\ |\ \_/ /\ \_/ /| | | |
\_| \_/ \___/ \___/ \_| |_/
Enterprise-grade AI inference coordination, multi-account credential pooling, native in-process job queueing, and resilient WebSocket streaming extracted from GALX.
β‘ Quickstart β’ ποΈ Architecture β’ π Gateway APIs β’ π₯ Shard Fleet β’ π₯¦ Queue Engine β’ π¦ Client SDKs β’ βοΈ Config Matrix β’ π³ Deployment β’ π§ͺ 23 Tests β’ π Wiki & Docs β’ π₯ Maintainers β’ π€ Contributing β’ π‘οΈ Security β’ π License
| Getting Started & Concepts | APIs & Integrations | Core Mechanics & Queues | Ops, Governance & Docs |
|---|---|---|---|
| β’ Why NOVA? | β’ Gateway API Reference | β’ Smooth Weighted Round Robin | β’ Knowledge Base Wiki |
| β’ Feature Comparison | β’ Tool Use & Function Calls | β’ Continuous Token Buckets | β’ Maintainers Charter |
| β’ 60-Second Quickstart | β’ Image Generation & Sharp | β’ Canary Circuit Breaker | β’ Maintainer Operations |
| β’ Multi-Language Clients | β’ Async Jobs & Streaming | β’ Native BroccoliQueue Engine | β’ Architecture Decision Records (ADRs) |
| β’ Architecture & Dataflow | β’ TypeScript Client SDK | β’ Distributed Fenced Leases | β’ Operational Runbooks |
| β’ Project Structure | β’ Shard Enrollment Guide | β’ 7-Layer Timeout Hierarchy | β’ Triage Playbooks |
| β’ Testing & 23-Test Suite | β’ Unified CLI Reference | β’ Bulkheads & Output Budgets | β’ Post-Mortems & Security Policy |
Deploying large-scale generative AI applications into production presents severe operational challenges:
β The Fragile Realities of Direct LLM Integration:
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
β Burst 429 Rate Limits β β Silent ITL Stalls β β Double-Billing Retries β
β Provider quotas halt β β WebSocket streams hang β β Network drops re-run β
β entire production apps. β β and leak socket handles.β β identical prompts. β
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
β Credential Leakage Risk β β Complex Vendor Baggage β β Disjointed Multi-Accountβ
β Forwarders leak tokens β β 150+ DB migrations, β β No unified pooling β
β & topology diagnostics. β β auth/edge cloud locks. β β across tiered accounts. β
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
NOVA is engineered to eliminate every single one of these failure modes:
- π Algorithmic Credential Pooling: Aggregates and load-balances across dozens of active shard accounts using Smooth Weighted Round Robin (SWRR), preventing burst quota exhaustion.
- β‘ Continuous Token-Bucket Governance: Real-time RPM and TPM tracking with 2-Phase Atomic Reservations and automatic Unconsumed Token Refunds upon stream completion.
- π‘οΈ Canary Circuit Breakers: Dissects transient errors (502/503/504/ITL stall) vs. terminal revocations (401/Invalid Key). Automatically quarantines failing shards with exponential full-jitter backoff and admits single-canary probes for safe recovery.
- π Resilient WebSocket Bridging: Bridges OpenAI/Codex WebSocket streaming with a 7-Layer Timeout Hierarchy, monitoring Inter-Token Latency (ITL) gaps and EWMA pacing to instantly drop dead streams.
- π₯¦ Native Infused Job Queue (BroccoliQueue): High-throughput, in-process persistent job queue on BroccoliDB tables with three MinHeaps, lease renewal heartbeats, exponential retries, and zero Redis/BullMQ dependencies.
- π Durable Stream Idempotency: SHA-256 prompt and parameter hashing with atomic in-flight stream collapsing, guaranteeing clients re-attaching to retries never double-bill your accounts.
- π‘οΈ Zero-Leak Privacy Firewall: Strips all upstream shard IDs, auth bearer keys, database connection strings, and raw stack traces from caller responses.
- ποΈ Distilled PostgreSQL Layer: Distills 159 legacy Supabase migrations into one clean, self-contained schema (db/schema.sql) with zero cloud vendor locks.
- ποΈ Autonomous Standalone Daemon (Zero Product Embedding): Engineered to run as an independent, out-of-process daemon/microservice acting as a producer and consumer of requests over standard wire protocols. It is never embedded inside a product layer, isolating event loops and eliminating coupled blast radii.
| Capability | Standard Reverse Proxy (Nginx / Envoy / Traefik) | Generic LLM Gateway (LiteLLM / Portkey) | Cloud Multi-Tenant PaaS (Supabase / AWS API GW) | NOVA Substrate (Relay + Pool Coordinator) |
|---|---|---|---|---|
| OpenAI-Compatible Wire Protocol | β (Raw HTTP only) | β (HTTP / REST) | β (Proprietary SDKs) | β Streaming SSE & Synchronous |
| Tool Use & Function Calling | β (None) | β (None) | β Strict Validation & Output Budgeting | |
| Algorithmic Credential Pooling | β (Static round robin) | β (Single tenant auth) | β Smooth Weighted Round Robin (SWRR) | |
| Two-Phase Token Bucket Rate Governance | β (Basic RPM limiter) | β (Credit ledger only) | β Continuous Leaky Bucket + Refund | |
| Circuit Breakers with Canary Probing | β (None) | β Transient vs. Terminal + Canary Slots | ||
| Resilient WebSocket Bridging | β (Blind TCP stream) | β (HTTP-to-HTTP only) | β (Edge functions only) | β 7-Layer Timeout Hierarchy & ITL Pacing |
| Durable Idempotency & Stream Attachment | β (None) | β (Manual implementation) | β Atomic In-Flight Stream Deduplication | |
| Privacy Firewall & Error Sanitization | β (Pass-through headers) | β (Raw upstream errors) | β Strict Zero-Leak Response Allowlist | |
| Embedded Write-Ahead-Log (WAL) Queue | β (None) | β Native Infused BroccoliQueue (3 Heaps) | ||
| Distributed Fenced Leases | β (None) | β (None) | β Monotonic Fencing Tokens (Postgres & Memory) | |
| Image Sanitization Pipeline | β (None) | β (Pass-through) | β In-Flight Sharp sRGB Normalizer | |
| Database Footprint | β (N/A) | β (150+ migrations & Supabase bloat) | β 1 Distilled Schema (Zero Supabase Bloat) | |
| Sub-Millisecond Routing Overhead | β (<1ms) | β (30ms - 100ms) | β <0.4ms In-Memory Microsecond Indexing |
Get NOVA running locally in less than 60 seconds. Zero external databases or cloud services required to start.
# Clone the repository
git clone https://github.com/CardSorting/NOVA-AI.git nova
cd nova
# Install dependencies (Node >= 20 required)
npm installExecute the comprehensive test suite (all 23 unit and integration tests run in under 700ms):
npm testStart the OpenAI-compatible gateway on port 3001 with a development API key:
npx tsx bin/nova.ts relay --port 3001 --api-key sk-nova-live-demoOutput:
======================================================================
π INFERENCE RELAY SERVER
======================================================================
Host: 127.0.0.1
Port: 3001
API Key: sk-nova-live-demo
Admin Key: key_admin_79d1...
----------------------------------------------------------------------
[NOVA Relay] Ready and listening on http://127.0.0.1:3001
Tip
NOVA automatically creates in-memory BroccoliDB tables for state checkpoints, idempotency hashes, and the embedded BroccoliQueue. You do not need to install or configure PostgreSQL to start serving requests locally!
NOVA provides 100% protocol fidelity with the OpenAI API. Point any standard SDK or HTTP client to http://127.0.0.1:3001/v1.
# Streaming Server-Sent Events (SSE)
curl -N http://127.0.0.1:3001/v1/chat/completions \
-H "Authorization: Bearer sk-nova-live-demo" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"stream": true,
"messages": [
{ "role": "system", "content": "You are a distributed systems expert." },
{ "role": "user", "content": "Why is SWRR superior to classic weighted round robin?" }
]
}'Install openai:
npm install openaiimport OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'http://127.0.0.1:3001/v1',
apiKey: 'sk-nova-live-demo'
});
async function main() {
const stream = await client.chat.completions.create({
model: 'gpt-4o',
stream: true,
messages: [{ role: 'user', content: 'Stream a 3-point summary of resilient gateways.' }]
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
}
main();Install openai:
pip install openaifrom openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:3001/v1",
api_key="sk-nova-live-demo"
)
response = client.chat.completions.create(
model="gpt-4o",
stream=True,
messages=[
{"role": "system", "content": "You are a kernel engineer."},
{"role": "user", "content": "Explain zero-copy socket ringbuffers."}
]
)
for chunk in response:
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="http://127.0.0.1:3001/v1",
api_key="sk-nova-live-demo",
model="gpt-4o",
temperature=0.2
)
response = llm.invoke("Design a fault-tolerant multi-tenant architecture.")
print(response.content)import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
configuration: {
baseURL: "http://127.0.0.1:3001/v1",
apiKey: "sk-nova-live-demo",
},
modelName: "gpt-4o",
temperature: 0.2,
});
const res = await model.invoke("Summarize the benefits of continuous token buckets.");
console.log(res.content);NOVA separates external API ingress from internal shard state management through a strictly partitioned Northbound / Southbound boundary:
[ Inbound Client Applications ]
(cURL / Python / TypeScript / OpenAI SDK)
β
βΌ HTTP / SSE
ββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββ
β NOVA RELAY GATEWAY (Port 3001) β
β β
β βββββββββββββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββββββ β
β β Timing-Safe API Auth β β Concurrency Bulkhead β β Output Budget β β
β β (Constant-Time HMAC) β β (Max 64 In-Flight) β β (Hard Token Cap)β β
β βββββββββββββ¬ββββββββββββ ββββββββββββ¬ββββββββββββ ββββββββββ¬βββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Durable Idempotency & Stream Collapsing Engine β β
β β (SHA-256 Prompt Hashing & Atomic Stream Attachment) β β
β ββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ β
β β Zero-Leak Privacy Firewall & Sanitizer β β
β β (Masks Shard Topology, Upstream Headers & Diagnostics) β β
β ββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
βΌ Internal Protocol / Grants βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NOVA POOL ROUTING SUBSTRATE (Port 3000) β
β β
β βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β Smooth Weighted Round β β Continuous Leaky Bucket β β
β β Robin (SWRR) Balancer β β Rate Governor (TPM & RPM) β β
β βββββββββββββββ¬ββββββββββββββ ββββββββββββββββ¬ββββββββββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β Circuit Breaker & Canary β β Native Infused BroccoliQueue β β
β β Probing Engine β β (3 MinHeaps, WAL Persist) β β
β βββββββββββββββ¬ββββββββββββββ ββββββββββββββββ¬ββββββββββββββββ β
β β β β
β βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Fenced Lease Coordination (Distributed Workers) β β
β β (PostgresExecutionStore / MemoryExecutionStore) β β
β ββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββ
βΌ βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β Upstream Shard A β β Upstream Shard B β β Upstream Shard C β
β OpenAI Direct WS β β Codex Enterprise β β Custom LLM Shard β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
sequenceDiagram
autonumber
actor Client as Client App (OpenAI SDK / NovaClient)
participant Relay as NovaRelayServer
participant Idemp as Idempotency Engine
participant Pool as NovaCredentialPool
participant Queue as BroccoliQueue (MinHeaps)
participant Shard as Upstream Shard (Codex/OpenAI)
participant Store as ExecutionStore (Postgres / Memory)
Client->>Relay: POST /v1/chat/completions (model, messages, stream: true)
Relay->>Relay: Verify Bearer Key (Timing-Safe) & Check Concurrency Bulkhead
Relay->>Idemp: Check SHA-256 Prompt Hash
alt Active In-Flight Stream Matches
Idemp-->>Relay: Attach to Active Stream
Relay-->>Client: Stream Existing Tokens (Zero Extra Billing)
else New Request
Relay->>Pool: Acquire Lease (Tenant, Estimated Tokens: 4000)
Pool->>Pool: SWRR Shard Selection & Check Circuit Breaker
Pool->>Pool: Rate Governor Reserves 4000 Tokens (2-Phase)
Pool->>Store: Fenced Lease Created (Fencing Token N)
Pool-->>Relay: Grant Lease (Shard Account, Fencing Token)
Relay->>Shard: Open/Reuse WS Connection (7-Layer Timeout Guard)
Relay->>Shard: Dispatch Payload Frame
loop Token Streaming with ITL Monitoring & Lease Heartbeats
Shard-->>Relay: WS Output Delta Frame
Relay->>Relay: Monitor EWMA Inter-Token Latency (Stall Check)
Relay->>Store: Renew Lease Heartbeat (prevent orphan recovery)
Relay-->>Client: SSE data: {"choices":[{"delta":{"content":"..."}}]}
end
Shard-->>Relay: Stream Completed (Actual Tokens Used: 1240)
Relay->>Pool: Release Lease (Actual Tokens: 1240, Success: true)
Pool->>Pool: Rate Governor Refunds 2760 Unconsumed Tokens
Pool->>Store: Settle Lease & Record Latency Metrics
Relay-->>Client: SSE data: [DONE]
end
Every public endpoint strictly adheres to the official OpenAI specifications while injecting robust enterprise resilience headers.
| Method | Path | Auth Scope | Description |
|---|---|---|---|
POST |
/v1/chat/completions |
Public / Tenant | Streaming (SSE) or synchronous chat completions with Tool Calls |
POST |
/v1/images/generations |
Public / Tenant | Synthesize images with Sharp sRGB profile normalizations |
GET |
/v1/models |
Public / Tenant | List active eligible models across all healthy shards |
GET |
/v1/jobs/:id |
Public / Tenant | Inspect asynchronous decoupled job status & usage |
GET |
/v1/jobs/:id/stream |
Public / Tenant | Re-attach or resume an active SSE token stream (Last-Event-ID) |
POST |
/v1/jobs/:id/cancel |
Public / Tenant | Instant wire abort & immediate lease release (<5ms) |
GET |
/v1/jobs/:id/receipt |
Public / Tenant | Inspect durable admission receipt record |
GET |
/health |
Unauthenticated | Kubernetes liveness probe (HTTP 200 OK) |
GET |
/health/ready |
Unauthenticated | Kubernetes readiness probe (verifies memory ceiling & healthy shards) |
GET |
/health/live |
Unauthenticated | Process liveness verification |
GET |
/metrics |
Admin Key | Prometheus-compatible real-time metrics exporter |
GET |
/telemetry / /api/telemetry |
Admin Key | Aggregated latency percentiles (p50, p95, p99) & throughput |
GET |
/api/capabilities |
Admin Key | View available model capabilities across shard fleet |
POST |
/api/capabilities/probe-image |
Admin Key | Probe shard image generation qualification |
GET |
/api/sites/contract |
Admin Key | Inspect site contract parameters |
GET |
/api/dashboard/stats |
Admin Key | Inspect real-time gateway metrics and active jobs |
POST |
/api/quota/profile |
Admin Key | Update quota profile and rate parameters |
POST |
/api/quota/reset |
Admin Key | Force reset rolling quota window for shards |
GET |
/api/quota/status |
Admin Key | View rolling quota utilization and limits |
POST |
/api/shards/enroll |
Admin Key | Dynamically enroll new shard credentials without restart |
POST |
/api/shards/sync |
Admin Key | Force reload and synchronization of shard accounts from PostgreSQL |
GET |
/api/shards |
Admin Key | Inspect shard fleet with masked API keys |
Generates chat completions for given messages. Supports streaming SSE, synchronous aggregation, tool calls, and parallel tool calls.
| Header | Type | Required | Description |
|---|---|---|---|
Authorization |
string |
Yes | Bearer <RELAY_API_KEY> |
Content-Type |
string |
Yes | application/json |
Idempotency-Key |
string |
Optional | Client UUID to collapse in-flight duplicate requests |
x-nova-tenant |
string |
Optional | Tenant identifier for fair queue scheduling and quota metering |
{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a precise technical architect." },
{ "role": "user", "content": "Fetch the status of the database cluster." }
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": false,
"tools": [
{
"type": "function",
"function": {
"name": "lookup_cluster_metrics",
"description": "Fetch real-time cluster metrics",
"parameters": {
"type": "object",
"properties": {
"cluster_id": { "type": "string" }
},
"required": ["cluster_id"]
}
}
}
],
"tool_choice": "auto",
"parallel_tool_calls": true
}View Synchronous Response (`stream: false`)
{
"id": "chatcmpl_9b7d81a29f8c4e",
"object": "chat.completion",
"created": 1729497600,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_98127391823",
"type": "function",
"function": {
"name": "lookup_cluster_metrics",
"arguments": "{\"cluster_id\":\"nova-primary\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 21,
"total_tokens": 63
}
}View Streaming Response (`stream: true`)
HTTP/1.1 200 OK
Content-Type: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
X-RateLimit-Limit-Tokens: 500000
X-RateLimit-Remaining-Tokens: 498760
data: {"id":"chatcmpl_9b7d","object":"chat.completion.chunk","created":1729497600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"The"},"finish_reason":null}]}
data: {"id":"chatcmpl_9b7d","object":"chat.completion.chunk","created":1729497600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" database"},"finish_reason":null}]}
data: {"id":"chatcmpl_9b7d","object":"chat.completion.chunk","created":1729497600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" cluster is operating normally."},"finish_reason":null}]}
data: [DONE]Synthesizes images using upstream image engines with automated Sharp-based sRGB profile normalizations and base64 security validation.
{
"prompt": "An isometric blueprint of a quantum computing cluster, cyan and dark obsidian palette",
"model": "gpt-image-1",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}{
"created": 1729497600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6..."
}
],
"artifact": {
"format": "png",
"width": 1024,
"height": 1024,
"channels": 4,
"byteLength": 248910
}
}When the cluster is under heavy burst load and the in-flight bulkhead is saturated, NOVA immediately returns HTTP 202 Accepted with an execution receipt:
{
"id": "job_01j982a17f",
"status": "queued",
"model": "gpt-4o",
"streamUrl": "/v1/jobs/job_01j982a17f/stream"
}Clients can poll GET /v1/jobs/:id or connect to GET /v1/jobs/:id/stream to receive tokens in real-time as soon as a worker dispatches the job. The NovaClient SDK handles this automatically.
NOVA supports dynamically pooling multiple upstream AI accounts without downtime. Shards can be enrolled through the administrative HTTP API or loaded from an encrypted local fleet file (.galx-shards.json).
curl -X POST http://127.0.0.1:3001/api/shards/enroll \
-H "Authorization: Bearer <RELAY_ADMIN_KEY>" \
-H "Content-Type: application/json" \
-d '{
"accountLabel": "Tier-1 Production OpenAI Shard",
"provider": "openai",
"authType": "api_key",
"apiKey": "sk-proj-prod-actual-upstream-key-here",
"weight": 5,
"priority": 10,
"maxTokens": 2000000,
"refillRatePerMinute": 1000000,
"maxRequests": 1000
}'Deploy a fleet of credentials locally or inside a container:
[
{
"id": "shard_openai_primary",
"accountLabel": "OpenAI Primary Enterprise",
"provider": "openai",
"authType": "api_key",
"apiKeyMasked": "sk-proj...9999",
"encryptedSecrets": {
"ciphertext": "a98f12...hex",
"iv": "3f81...hex",
"tag": "12da...hex",
"keyVersion": "v1"
},
"weight": 3,
"priority": 10,
"tokenBucket": {
"maxTokens": 1000000,
"remainingTokens": 1000000,
"refillRatePerMinute": 500000,
"maxRequests": 500,
"remainingRequests": 500
}
}
]All credentials stored in PostgreSQL or in .galx-shards.json are encrypted using AES-256-GCM envelope encryption with HKDF key derivation:
Master Secret ($GALX_VAULT_KEY)
β
βΌ HKDF (salt: "galx-vault-salt-2026", info: "galx-shard-isolation-v1")
Derived Encryption Key (256-bit)
β
βΌ AES-256-GCM
Ciphertext + 12-byte IV + 16-byte Auth Tag
β³ Bound to AAD: `${user_id}:${shard_id}:${provider}`
Note
Even if a database snapshot is compromised, credentials cannot be decrypted without the host master secret, and ciphertext cannot be transplanted across shards due to Additional Authenticated Data (AAD) binding.
NOVA natively embeds the high-throughput, in-process BroccoliQueue engine (src/queue/), eliminating external queue services (Redis, RabbitMQ, SQS, or BullMQ) while maintaining crash-resilient persistence on BroccoliDB tables.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BROCCOLIQUEUE ENGINE β
β β
β ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββ β
β β Ready Heap β β Delayed Heap β β Lease Heap β β
β β Priority DESC β β Deadlines ASC β β Expiry ASC β β
β βββββββββ¬βββββββββ βββββββββ¬βββββββββ βββββββ¬βββββββ β
ββββββββββββΌβββββββββββββββββββΌβββββββββββββββββΌββββββββββ
β β β
ββββββββββββββββββ΄βββββββββββββββββββΌβββββββββββββββββ΄βββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
β Worker Batch Claiming β β Scheduled Delay Timers β β Lease Heartbeat Renewalsβ
β O(1) Highest Priority β β O(log N) Time-To-Ready β β Prevent Orphan Recovery β
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ
- Zero External Dependencies: 100% self-contained in-memory indexed tables backed by an append-only WAL.
-
Three Internal MinHeaps for
$O(1)$ Scheduling:-
Ready Heap: Orders jobs by descending priority with FIFO sequence preservation (
priority DESC, sequence ASC). -
Delayed Heap: Orders delayed jobs by execution deadline (
availableAt ASC). -
Lease Heap: Tracks active worker leases by expiration (
leaseExpiresAt ASC) for sub-second crash recovery.
-
Ready Heap: Orders jobs by descending priority with FIFO sequence preservation (
-
Lease Renewal & Heartbeats (
context.heartbeat()): Long-running inference jobs (e.g., deep reasoning or image synthesis) automatically renew their leases, preventing premature recovery while keeping worker timeout ceilings tight. - Crash-Resilient WAL Recovery: Replays newline-delimited WAL frames with checksum validation on process restarts.
-
Per-Tenant Fairness & Bounded Waiting Room:
NovaRequestQueuecaps tenant burst queuing and uses deficit round-robin dispatch across tenant keys. -
Headless Backend Architecture: 100% clean backend execution with zero browser UI dependencies; queue observability is exposed through native
/metrics,/health, and internal telemetry endpoints.
import { BroccoliQueue, BroccoliDatabaseKernel } from './src/index.js';
// 1. Initialize queue on top of local BroccoliDB workspace
const db = new BroccoliDatabaseKernel({ workspaceRoot: './.broccolidb/queue-data' });
const queue = new BroccoliQueue({
db,
namespace: 'nova_inference',
retentionMs: 3600_000 // 1 hour terminal retention
});
await queue.start();
// 2. Register worker with lease heartbeats
const worker = queue.process('inference_tasks', async (job, context) => {
// Renew lease during long inference generations:
await context.heartbeat();
return { status: 'completed', result: 'Model output' };
}, { concurrency: 8, leaseDurationMs: 30_000 });
await worker.start();
// 3. Enqueue idempotent job batch
await queue.add('inference_tasks', { prompt: 'Synthesize report' }, {
priority: 10,
attempts: 3,
backoff: { type: 'exponential', delayMs: 1000 },
idempotencyKey: 'request_uuid_12345'
});NOVA ships with a zero-dependency async client (NovaClient).
import { NovaClient } from './src/index.js';
const client = new NovaClient({
baseUrl: 'http://127.0.0.1:3001',
apiKey: 'sk-nova-live-demo',
tenant: 'production-workload',
timeoutMs: 60_000
});// 1. Asynchronous Streaming Chat Completion
for await (const chunk of client.chatStream({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Explain monotonic fencing tokens.' }]
})) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
// 2. Synchronous Aggregated Chat
const response = await client.chat({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'What is 42?' }]
});
console.log(response.choices[0].message.content);
// 3. Image Synthesis with Automated Sharp Artifact Sanitization
const image = await client.generateImage({
prompt: 'A minimalist neon logo for an AI relay gateway',
size: '1024x1024'
});
console.log('Sanitized Image Format:', image.artifact?.contentType);
console.log('Sanitized Image Size:', `${image.artifact?.bytes.length} bytes`);
// 4. Model Capabilities Discovery
const models = await client.listModels();
console.log('Available models:', models.map(m => m.id));
// 5. Job Status Inspection
const job = await client.getJob('job_01j982a17f');
console.log('Job status:', job.status);NOVA provides a single entrypoint CLI with dedicated subcommands:
nova <command> [options]Starts the OpenAI-compatible HTTP and WebSocket gateway.
npx tsx bin/nova.ts relay [options]
# Or directly:
npx tsx bin/relay.ts [options]| Flag | Env Variable | Default | Description |
|---|---|---|---|
--port <number> |
PORT |
3001 |
TCP port to listen on |
--host <string> |
HOST |
127.0.0.1 |
Network interface to bind |
--api-key <string> |
RELAY_API_KEY |
key_live_<random> |
Bearer token required for public inference calls |
--admin-key <string> |
RELAY_ADMIN_KEY |
key_admin_<random> |
Bearer token required for /metrics and shard administration |
--ws-endpoint <url> |
CODEX_WS_ENDPOINT |
wss://chatgpt.com/... |
Upstream WebSocket endpoint for streaming models |
--help, -h |
β | β | Show CLI help text |
Starts the multi-worker credential pooling coordinator.
npx tsx bin/nova.ts pool [options]
# Or directly:
npx tsx bin/pool.ts [options]| Flag | Env Variable | Default | Description |
|---|---|---|---|
--port <number> |
PORT |
3000 |
Port for internal coordinator communication |
--inference-key <string> |
β | Auto-generated | Internal inference authorization key |
--central-origin <url> |
β | http://127.0.0.1:1 |
Central coordinator URL (mock or remote) |
--state-dir <path> |
β | OS Temp Dir | File system directory for BroccoliDB WAL queue & state checkpoints |
--help, -h |
β | β | Show CLI help text |
Applies the distilled schema and development seeds to PostgreSQL without Supabase.
npx tsx bin/nova.ts migrate [options]
# Or via npm scripts:
npm run db:migrate
npm run db:seed| Flag | Env Variable | Default | Description |
|---|---|---|---|
--url <string> |
DATABASE_URL |
postgresql://postgres:postgres@127.0.0.1:5432/nova |
PostgreSQL connection string |
--seed |
β | false |
Apply dev seed data (pools, runtimes, principals, test shard) |
--check |
β | false |
Test PostgreSQL connection and server version without applying migrations |
--help, -h |
β | β | Show CLI help text |
| Variable | Default | Description |
|---|---|---|
PORT |
3001 |
HTTP and WebSocket server port |
HOST |
127.0.0.1 |
Network interface binding |
RELAY_MAX_CONCURRENT_REQUESTS |
64 |
Maximum global simultaneous in-flight inference requests |
RELAY_MAX_RSS_MB |
384 |
Memory ceiling (MB). Readiness probe reports unhealthy if exceeded |
MAX_PAYLOAD_BYTES |
2097152 (2 MB) |
Maximum incoming HTTP JSON body size |
HTTP_BODY_TIMEOUT_MS |
10000 (10s) |
Slowloris protection read timeout for incoming HTTP request bodies |
RELAY_ALLOWED_ORIGINS |
* |
Comma-separated CORS allowed origin list |
| Variable | Default | Description |
|---|---|---|
RELAY_API_KEY |
Auto-generated | Public inference Bearer token (/v1/*) |
RELAY_API_KEYS |
β | Comma-delimited list of multiple active inference keys |
RELAY_ADMIN_API_KEY |
Auto-generated | Operator Bearer token (/metrics, /api/shards, etc.) |
GALX_VAULT_KEY |
β | AES-256-GCM master secret for decrypting shard credentials |
NOVA guards against slow, stalled, or dead upstream provider connections using a 7-layer defense:
| Layer | Environment Variable | Default | Behavioral Guarantee |
|---|---|---|---|
| Layer 0 | WS_CONNECT_TIMEOUT_MS |
15000 (15s) |
Hard ceiling for TCP + TLS + WebSocket upgrade handshake |
| Layer 1 | WS_TTFT_TIMEOUT_MS |
60000 (60s) |
Base ceiling for Time-To-First-Token |
| Layer 1b | DEEP_REASONING_TTFT_MULTIPLIER |
2.0 (120s) |
Multiplier for reasoning models (e.g. o1/o3/high-effort) |
| Layer 2 | ITL_GAP_THRESHOLD_MS |
8000 (8s) |
Stalling trigger when no new token arrives within interval |
| Layer 2b | ITL_CONSECUTIVE_LIMIT |
3 |
Max consecutive ITL stalls before terminating the stream |
| Layer 3 | WS_INTRA_CHUNK_TIMEOUT_MS |
45000 (45s) |
Silence window between chunks (resets on every token) |
| Layer 4 | CLIENT_DISCONNECT_GRACE_MS |
15000 (15s) |
Grace window for client cellular handoff or Wi-Fi reconnect |
| Layer 5 | SSE_KEEPALIVE_INTERVAL_MS |
15000 (15s) |
: ping\n\n comments preventing Cloudflare 100s idle drops |
| Layer 5b | WS_DEAD_PEER_PING_INTERVAL_MS |
20000 (20s) |
Outbound WS ping frames with full jitter |
| Layer 6 | JOB_MAX_WALL_TIME_MS |
300000 (5m) |
Absolute execution safety ceiling for any single job |
| Variable | Default | Description |
|---|---|---|
TENANT_RATE_LIMIT_PER_SEC |
50.0 |
Continuous leaky bucket drain rate per tenant |
TENANT_BURST_CAPACITY |
100 |
Maximum burst token allowance per tenant |
MAX_UPSTREAM_RETRIES |
3 |
Maximum automatic shard failovers before reporting failure |
RETRY_BASE_DELAY_MS |
500 |
Base exponential backoff delay |
RETRY_MAX_DELAY_MS |
5000 |
Maximum backoff ceiling with full jitter |
IDEMPOTENCY_TTL_MS |
120000 (2m) |
Time-to-live for prompt deduplication cache |
DRAIN_TIMEOUT_MS |
30000 (30s) |
Graceful shutdown drain deadline on SIGINT/SIGTERM |
Standard weighted round robin causes bursty shard selection (e.g. weights {A: 5, B: 1} would select AAAAAB). NOVA implements Nginx Smooth Weighted Round Robin:
- Every candidate shard starts with a dynamic
currentWeight = 0. - On each lease acquisition:
$$\text{currentWeight}_i \leftarrow \text{currentWeight}_i + \text{effectiveWeight}_i$$ - Select shard
$k$ with the maximum$\text{currentWeight}$ . - Deduct the total sum of all weights from the selected shard:
$$\text{currentWeight}_k \leftarrow \text{currentWeight}_k - \sum_j \text{effectiveWeight}_j$$ This guarantees perfectly interleaved request dispatch (e.g.AABAACA), minimizing burst contention and preventing upstream rate limit triggers.
import { NovaCredentialPool, NovaCredentialSubstrate } from './src/index.js';
const substrate = new NovaCredentialSubstrate();
const pool = new NovaCredentialPool(substrate, undefined, undefined, 'smooth_weighted_round_robin');NOVA implements continuous rate evaluation with sub-millisecond precision:
- Two-Phase Atomic Reservations: Before a request is dispatched, NOVA calculates an
estimatedTokensreservation (prompt tokens + estimated output tokens) and checks both RPM (Requests Per Minute) and TPM (Tokens Per Minute). - Automatic Unconsumed Refund: When the upstream stream concludes with actual token usage (e.g. reserved 4,000, consumed 1,200), the remaining 2,800 tokens are immediately credited back to the shard's bucket.
- Sliding 3-Hour Quota Log: Evaluates rolling quota health to throttle shards gracefully prior to provider rejection.
// 1. Reserve tokens
const reservation = await pool.acquireLease({
userId: 'tenant_enterprise',
provider: 'openai',
estimatedTokens: 4000
});
// 2. Release with refund
await pool.releaseLease(reservation.lease.leaseId, {
success: true,
actualTokensConsumed: 1200 // 2800 tokens automatically refunded!
});- Error Taxonomy Classification: Categorizes failures into Transient (HTTP 502/503/504, network reset, ITL stall) vs. Terminal (HTTP 401 Unauthorized, Account Revoked, Invalid Quota).
-
Outlier Shard Quarantine: A shard incurring 3 consecutive failures enters
cooldownwith AWS full-jitter backoff:$$\text{backoff} = \text{random}(0, \min(\text{maxDelay}, \text{baseDelay} \times 2^{\text{failures}}))$$ -
Single-Canary Half-Open Probing: When the cooldown expires, the shard transitions to
half-open. Exactly one canary request is admitted. If it succeeds, the shard is restored tohealthy; if it fails, cooldown doubles.
Distributed execution across multiple workers requires split-brain prevention:
- Every lease issued carries a monotonically increasing
fencingToken: bigint. - When an execution settles,
PostgresExecutionStoreverifies that the fencing token matches the current database generation viarelay_execution()stored procedure. - Stale or orphaned leases from partitioned workers are cleanly rejected.
Public callers must never gain visibility into internal infrastructure topology:
- Header Masking: Strips all
x-shard-id,x-account-key,cf-ray,openai-organization, and internal routing headers from public responses. - Error Sanitization: All raw upstream stack traces and diagnostic objects are encrypted with AES-256-GCM or masked into standard error codes (
upstream_error,quota_exceeded,gateway_timeout). - Telemetry Allowlist: Metrics emitted externally follow strict schema allowlists (
publicJob,publicUsage).
- Request Bulkhead (
RequestBulkhead): Limits global concurrency (default 64) and per-tenant concurrency (default 8) to prevent a single tenant from starving cluster resources. - Output Token Budget (
OutputBudget): Real-time monitoring of generated output bytes and tool call arguments against caller-requestedmax_tokens, gracefully closing the stream if the ceiling is reached.
NOVA eliminates all dependence on Supabase Cloud, Supabase Auth, Edge Functions, Stripe billing webhooks, and pgvector extensions. The 159 legacy migrations are distilled into a single, idempotent, production-ready schema (db/schema.sql).
| Legacy Component | Removal Rationale | NOVA Replacement |
|---|---|---|
auth.users & Supabase Auth |
Heavy vendor lock-in, external JWT overhead | Direct SHA-256 hashed API keys via private.nova_relay_principals |
pgvector & Semantic Embeddings |
Memory overhead, unneeded for gateway routing | Clean relational indexing on accounts, leases, and runtimes |
| Stripe Billing & Invoices | Non-core product bloat | Lightweight per-tenant token accounting |
| Persona & Workspace Social Data | Unneeded for inference gateway | Pure shard account credentials and fencing records |
| Supabase Studio & CLI | Complex developer setup | Standard vanilla PostgreSQL 14 - 17+ with zero cloud dependencies |
public.nova_shard_accounts
βββ id (PK, varchar)
βββ account_label, provider, auth_type
βββ encrypted_ciphertext, encrypted_iv, encrypted_tag (AES-256-GCM)
βββ token_bucket (max_tokens, remaining_tokens, refill_rate)
βββ stats (total_requests_served, total_tokens_consumed, average_latency_ms)
βββ fencing_token, status, cooldown_until_ms
public.nova_shard_leases
βββ id (PK, varchar)
βββ shard_id (FK -> nova_shard_accounts.id)
βββ fencing_token, reserved_tokens, state
βββ expires_at, heartbeat_at
private.nova_relay_principals
βββ id (PK, uuid)
βββ kind ('runtime' | 'operator' | 'registrar' | 'viewer')
βββ token_sha256 (SHA-256 digest of secret token)
βββ disabled (boolean)
private.relay_executions
βββ execution_id (PK, varchar)
βββ status ('reserved' | 'bound' | 'settled' | 'released')
βββ account_id, fencing_token, tokens_consumed
# 1. Apply single distilled schema:
npm run db:migrate
# 2. Apply schema AND development seed identities:
npm run db:seedDevelopment seed identities provisioned by db/seed.sql:
- Runtime Principal Token:
nova-dev-runtime-token - Operator Principal Token:
nova-dev-operator-token - Registrar Principal Token:
nova-dev-registrar-token - Viewer Principal Token:
nova-dev-viewer-token - Local Seed Shard:
nova_sh_000000000000000000000001(Synthetic healthy OpenAI shard)
version: '3.8'
services:
nova-postgres:
image: postgres:17-alpine
container_name: nova-postgres
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: production_postgres_password
POSTGRES_DB: nova
volumes:
- nova-db-data:/var/lib/postgresql/data
- ./db/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
- ./db/seed.sql:/docker-entrypoint-initdb.d/02-seed.sql:ro
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d nova"]
interval: 5s
timeout: 5s
retries: 5
nova-relay:
build: .
container_name: nova-relay
restart: unless-stopped
depends_on:
nova-postgres:
condition: service_healthy
environment:
PORT: "3001"
HOST: "0.0.0.0"
RELAY_API_KEY: "prod_live_your_secret_key_here"
RELAY_ADMIN_KEY: "prod_admin_your_secret_key_here"
DATABASE_URL: "postgresql://postgres:production_postgres_password@nova-postgres:5432/nova"
RELAY_MAX_CONCURRENT_REQUESTS: "128"
RELAY_MAX_RSS_MB: "512"
ports:
- "3001:3001"
volumes:
nova-db-data:Launch with:
docker compose up -dView Kubernetes Deployment & Service Manifest (`nova-k8s.yaml`)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nova-relay
labels:
app: nova-relay
spec:
replicas: 3
selector:
matchLabels:
app: nova-relay
template:
metadata:
labels:
app: nova-relay
spec:
containers:
- name: relay
image: nova-relay:latest
ports:
- containerPort: 3001
env:
- name: PORT
value: "3001"
- name: HOST
value: "0.0.0.0"
- name: RELAY_API_KEY
valueFrom:
secretKeyRef:
name: nova-secrets
key: api-key
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: nova-secrets
key: database-url
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "2000m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /health
port: 3001
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /health/ready
port: 3001
initialDelaySeconds: 3
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: nova-relay
spec:
type: ClusterIP
selector:
app: nova-relay
ports:
- port: 80
targetPort: 3001When terminating a pod or restarting a container:
SIGTERMis intercepted by NOVA.- Gateway immediately marks
/health/readyas unhealthy and rejects new connections withHTTP 503 server_draining. - In-flight streams are granted a 30-second completion grace period (
DRAIN_TIMEOUT_MS). - All active leases are settled and refunded, memory WAL tables flush to disk, and the process exits cleanly with code
0.
| HTTP Status | Error Code | Root Cause | Recommended Action |
|---|---|---|---|
401 |
unauthorized |
Missing or invalid Authorization: Bearer <key> header |
Verify key matches --api-key or RELAY_API_KEYS |
413 |
payload_too_large |
Request body exceeds MAX_PAYLOAD_BYTES (2 MB) |
Compress payload or truncate excessive message history |
429 |
rate_limit_exceeded |
Tenant continuous leaky bucket exceeded burst capacity | Implement backoff respecting the Retry-After header |
429 |
shard_exhausted |
All candidate shards have exhausted their rate bucket | Add more shard accounts to the pool or increase refill rate |
502 |
upstream_error |
Upstream provider returned 5xx or unparseable frame | NOVA automatically retries up to MAX_UPSTREAM_RETRIES |
503 |
server_draining |
Relay is undergoing graceful restart | Resend request after new pod / container instance is healthy |
504 |
itl_stall_detected |
Upstream WebSocket stalled with no token for >8s | Gateway automatically terminated stalled stream to free resources |
504 |
gateway_timeout |
Total execution exceeded JOB_MAX_WALL_TIME_MS (300s) |
Narrow request scope or reduce requested max_tokens |
NOVA is engineered for sub-millisecond dispatch overhead:
-
Relay Dispatch Latency:
$\le 0.38\text{ms}$ per request (measured via Node.jsperf_hooks). - SWRR Account Selection: Sub-microsecond execution using memory-mapped lookup tables.
-
SSE Frame Parsing: Zero-copy buffer slicing via
parseEventStream. - Memory Footprint: Bounded RSS ceiling with proactive garbage collection awareness.
# Execute 23 tests across all 7 test suites:
npm test
# Verify strict TypeScript type contracts:
npm run typecheck- credential-pool.test.ts (4 tests):
NovaRateGovernor calculates sliding window limits and parses durationsNovaCircuitBreaker dissects upstream errors and manages canary slotsNovaCredentialPool leases accounts using Smooth Weighted Round Robin (SWRR)NovaCredentialPool handles token reservation and release
- queue.test.ts (6 tests):
BroccoliQueue validates producer batches before changing tablesBroccoliQueue bulk enqueue copies payloads, preserves idempotency, and reports state countsBroccoliQueue coalesces concurrent writes into shared flush windowBroccoliQueue workers claim batches, renew leases via heartbeat, and complete jobsBroccoliQueue retries failing jobs with exponential backoff and tracks attemptsBroccoliQueue allows cancellation and pruning of expired jobs
- pool-queue.test.ts (1 test):
NovaRequestQueue enqueues, processes via worker, handles idempotency, and drains cleanly
- pool-runtime.test.ts (2 tests):
PoolExecution with MemoryExecutionStore persists reservations, binds leases, and settlesPool Central Server validates protocol routes and isolates caller roles
- postgres-db.test.ts (6 tests):
Distilled PostgreSQL schema is bloat-free and contains all required NOVA definitionsDistilled PostgreSQL seed script provides local development identitiesresolveDatabaseUrl handles custom URLs and fallback defaultsPostgresExecutionStore executes relay_execution stored procedurecentralQuery executes relay_control stored procedure and maps errorsmigrateDatabase mock runner executes schema and seed queries sequentially
- relay-client.test.ts (1 test):
NovaClient interacts end-to-end with NovaRelayServer for streaming and non-streaming inference
- relay-server.test.ts (3 tests):
Relay server rejects unauthenticated requests and enforces authorizationRelay server routes streaming chat completion through upstream WebSocketRelay server preserves idempotency and returns job status
nova/
βββ .github/
β βββ ISSUE_TEMPLATE/
β β βββ bug_report.md # Structured bug report template
β β βββ feature_request.md # Architectural feature request template
β β βββ config.yml # Community links & discussions config
β βββ PULL_REQUEST_TEMPLATE.md # Standardized PR verification checklist
βββ bin/
β βββ nova.ts # Unified CLI runner (relay, pool, migrate)
β βββ relay.ts # Standalone NOVA Relay Gateway CLI
β βββ pool.ts # Standalone NOVA Pool Runtime CLI
β βββ migrate.ts # Standalone PostgreSQL Migration CLI
βββ db/
β βββ schema.sql # Single distilled PostgreSQL schema (0 Supabase bloat)
β βββ seed.sql # Development seed data (pools, runtimes, principals, shard)
βββ src/
β βββ client/
β β βββ relay-client.ts # NovaClient async SDK (chatStream, chat, generateImage)
β β βββ stream-parser.ts # Resilient chunk-level SSE stream parser
β βββ db/
β β βββ postgres.ts # Native pg pool connection manager & health checker
β β βββ migrate.ts # Migration executor for schema.sql and seed.sql
β βββ pools/
β β βββ circuit-breaker.ts # NovaCircuitBreaker & canary slot governor
β β βββ credential-pool.ts # NovaCredentialPool (SWRR, 2-phase reservations)
β β βββ credential-substrate.ts # Reactive shard account registry
β β βββ lease-transition.ts # Health coalescing & state transitions
β β βββ pool-central.ts # Central coordinator HTTP server & RBAC
β β βββ pool-contracts.ts # TypeScript interfaces for pools, accounts & quotas
β β βββ pool-execution.ts # Fenced lease binding & Postgres/Memory execution stores
β β βββ pool-image-policy.ts # Dedicated image generation workload policy
β β βββ pool-protocol.ts # Wire protocol contracts & CentralClient
β β βββ pool-public-response.ts # Strict public DTO formatters
β β βββ pool-request-queue.ts# NovaRequestQueue BroccoliDB WAL queue
β β βββ pool-runtime.ts # NovaPoolRuntime worker coordinator
β β βββ pool-scheduler.ts # Fair queue dispatch scheduler
β β βββ rate-governor.ts # NovaRateGovernor continuous token bucket
β βββ queue/
β β βββ index.ts # Native infused BroccoliQueue entrypoint
β β βββ queue.ts # MinHeap-driven in-process job queue engine
β β βββ types.ts # Pure backend job queue contracts
β βββ relay/
β β βββ admission-lifecycle.ts # Request admission lifecycle hooks
β β βββ capability-registry.ts # Shard capability reverse index & routing
β β βββ codex-image-tool.ts # Upstream Codex image alias definitions
β β βββ completion-usage.ts # Token usage extractor
β β βββ function-tools.ts # Tool and function call validator & normalizer
β β βββ output-budget.ts # Output token budget ceiling monitor
β β βββ private-failure.ts # Zero-leak error masking & sanitization
β β βββ quota-policy.ts # Cooldown & quota deadline policies
β β βββ relay-server.ts # NovaRelayServer HTTP/WS engine & 7-layer timeouts
β β βββ request-bulkhead.ts # In-flight concurrency limiters
β β βββ request-policy.ts # JSON body validation & RequestError
β β βββ shard-registry.ts # AES-256-GCM shard credential vault
β β βββ telemetry.ts # In-memory telemetry aggregator
β βββ security/
β β βββ image-artifact.ts # Sharp sRGB sanitization & base64 validation
β βββ storage/
β β βββ memory-table.ts # Standalone BroccoliDbTable in-memory table
β β βββ table-aggregation.ts # Table aggregation engine
β β βββ table-contracts.ts # Storage interfaces
β βββ index.ts # Master library entrypoint exporting public APIs
βββ tests/ # 23 automated unit and integration tests across 7 suites
βββ docs/ # Complete Knowledge Base Wiki (ADRs, runbooks, playbooks, post-mortems)
β βββ README.md # Wiki portal & master docs index
β βββ setup/ # Setup and startup guides (local, cluster, DB, vault)
β βββ maintainers/ # Maintainer SOPs (releases, review, security, triage, DB migrations)
β βββ architecture/ # 7 Technical specs (SWRR, token buckets, MinHeaps, timeouts)
β βββ api/ # 4 API endpoint specifications & streaming wire guides
β βββ observability/ # Prometheus metrics catalog & latency tracing telemetry
β βββ sdks/ # Multi-language client integrations (TypeScript, Python, LangChain, cURL)
β βββ adrs/ # 6 Architecture Decision Records (SWRR, token buckets, queues, DB)
β βββ runbooks/ # 4 Operational SOPs (incidents, scaling, DB maintenance, shard rotation)
β βββ playbooks/ # 3 Fast-path triage playbooks (outages, ITL stalls, burst decoupling)
β βββ post-mortems/ # 2 Blameless post-mortem retrospective reports
βββ scripts/
β βββ lint-docs.ts # CI/CD documentation freshness & link integrity linter
βββ CHANGELOG.md # Semantic versioning release history & migration logs
βββ CODE_OF_CONDUCT.md # Contributor Covenant v2.1 code of conduct
βββ CONTRIBUTING.md # Contributor guide, architecture rules & PR checklist
βββ LICENSE # Official MIT open-source license
βββ MAINTAINERS.md # Maintainer roster, governance charter, voting thresholds & SLAs
βββ SECURITY.md # Security policy, reporting procedures & cryptographic guarantees
βββ README.md # Gateway documentation & operational runbooks
βββ package.json
βββ tsconfig.json
- Zero External Workspace Dependencies:
novadoes not import any files from external or parent directories (../). All required models, security routines, and storage drivers are self-contained. - Untouched Source Codebase: The parent GALX codebase remains in its pristine state with zero modifications.
- Public Privacy Firewall: All public DTOs format outputs through strict allowlists, preventing accidental disclosure of upstream telemetry, shard IDs, or internal failure diagnostics.
- Idempotent Distilled Database: db/schema.sql can be re-run safely multiple times against any PostgreSQL database without data loss.
- Autonomous Substrate & Non-Embedding Mandate: NOVA is strictly an out-of-process daemon and infrastructure substrate. It must never be embedded in-process inside another product layer or burdened with client UI or consumer business logic. See Anti-Scope-Creep Policy and ADR-0007.
We welcome community contributions, bug reports, and architectural improvements! Please consult our official guides before submitting pull requests:
- π Contributing Guide: Complete development setup, testing practices, strict TypeScript coding guidelines, conventional commit rules, and PR checklist.
- π Code of Conduct: Contributor Covenant v2.1 standards for an inclusive, harassment-free environment.
- π₯ Maintainers Charter: Project governance structure, consensus voting models, maintainer SLAs, and the path to maintainership.
- π οΈ Maintainer Operations Portal: Authoritative runbooks for SemVer releases, code reviews, coordinated CVE disclosures, and zero-downtime DB migrations.
# 1. Create a feature branch
git checkout -b feat/your-improvement
# 2. Verify all 23 unit & integration tests pass in <700ms
npm test
# 3. Verify 0 TypeScript strict type errors
npm run typecheck
# 4. Commit using Conventional Commits
git commit -m 'feat(queue): implement batch lease renewal heartbeats'Security and credential isolation are paramount in NOVA. Upstream credentials are protected via hardware-grade AES-256-GCM envelope encryption, constant-time authentication, and strict zero-leak egress firewalls.
- For vulnerability disclosures, please review our Security Policy.
- Please report vulnerabilities privately via GitHub Security Advisories or by emailing security@cardsorting.org. Do not open public issues for security vulnerabilities.
NOVA adheres to Semantic Versioning and follows Keep a Changelog. Detailed notes on features, fixes, and architectural evolutions are tracked in CHANGELOG.md.
Distributed under the MIT License. See LICENSE for full legal text and copyright notices. Copyright Β© 2026 CardSorting and NOVA Contributors.