Enterprise-grade decision engine & vector operations API
Stateless Β· SPARC-compliant Β· Production-hardened
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ruvector Service β
β β
β βββββββββββ ββββββββββββ βββββββββββββ ββββββββββββββββββ β
β β Ingest β β Query β β Simulate β β Decisions β β
β β Handler β β Handler β β Handler β β & Approvals β β
β ββββββ¬βββββ ββββββ¬ββββββ βββββββ¬ββββββ βββββββββ¬βββββββββ β
β β β β β β
β ββββββΌβββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌβββββββββ β
β β Middleware Layer β β
β β Validation Β· Correlation Β· Metrics Β· Latency Budget β β
β ββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββ β
β β β β
β ββββββΌββββββββββ ββββββββββββΌββββββββ β
β β VectorClient β β DatabaseClient β β
β β (RuvVector) β β (PostgreSQL) β β
β ββββββββββββββββ ββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Feature
Description
π
Execution Authority
HMAC-SHA256 signed execution IDs β Ruvector is the sole minting authority
π
Decision Events
Real-time decision event polling & ingestion for orchestration engines
π§
Learning Signals
Approval learning and feedback assimilation agents with latency budgets
β‘
Circuit Breaker
Automatic failure isolation with configurable thresholds and recovery
π
Prometheus Metrics
Full observability with request duration, throughput, and pool gauges
π
Graceful Shutdown
Connection draining within configurable timeout on SIGTERM/SIGINT
π‘οΈ
Startup Hardening
4-phase boot: env assertions β DB init β storage health β data integrity
π³
Cloud Run Ready
Stateless, single-process, <256 MB baseline, 8080 health-checked
Method
Endpoint
Description
GET
/health
π’ Liveness probe with database connectivity check
GET
/ready
π’ Readiness probe with VectorClient dependency check
GET
/metrics
π Prometheus metrics (requests, latency, connections, circuit state)
GET
/metadata
π Service metadata and capability discovery
Method
Endpoint
Description
POST
/v1/plans
Create a new plan
GET
/v1/plans
List plans (filterable by org_id)
GET
/v1/plans/:id
Retrieve a plan by ID
DELETE
/v1/plans/:id
Delete a plan
Method
Endpoint
Description
POST
/v1/deployments
Create a deployment record
GET
/v1/deployments
List deployments (filter by environment, status)
GET
/v1/deployments/:id
Retrieve a deployment by ID
PUT
/v1/deployments/:id
Update a deployment
DELETE
/v1/deployments/:id
Delete a deployment
Decisions & Approvals API
Method
Endpoint
Description
POST
/v1/decisions
Store a new decision record
GET
/v1/decisions
List decisions
GET
/v1/decisions/:id
Retrieve a decision by ID
POST
/decision/approval
Process approval event and apply learning
Method
Endpoint
Description
POST
/v1/executions/accept
π Synchronous execution acceptance (canonical mint)
GET
/v1/executions/:id
Retrieve an execution record
GET
/v1/executions
List executions
POST
/v1/executions/validate
Validate execution ID + authority signature
Method
Endpoint
Description
POST
/v1/simulations
Accept simulation intent and mint execution authority
Method
Endpoint
Description
GET
/events/decisions
π‘ Poll decision events (cursor-based, supports types, after, limit)
POST
/events/decisions
π₯ Ingest decision events from orchestration
Method
Endpoint
Description
POST
/learning/learn
Approval learning agent (latency-budgeted)
POST
/learning/assimilate
Feedback assimilation agent (latency-budgeted)
GET
/learning/inspect
Inspect learning events (read-only)
Method
Endpoint
Description
POST
/ingest
Ingest a normalized event with vector embedding
POST
/query
Query vectors with similarity search and filters
POST
/simulate
Multi-vector similarity search for recommendations
POST
/graph
Graph operations
POST
/predict
Run ML predictions
Node.js 20.x LTS or higher
PostgreSQL 16+
RuvVector backend service
cp .env.example .env
# Edit .env with your configuration
All configuration is via environment variables. No .env files in production.
Variable
Description
EXECUTION_HMAC_SECRET
π HMAC-SHA256 signing secret for execution authority
RUVVECTOR_DB_PASSWORD
PostgreSQL password
Variable
Default
Description
RUVVECTOR_DB_HOST
localhost
Database hostname
RUVVECTOR_DB_PORT
5432
Database port
RUVVECTOR_DB_NAME
ruvector-postgres
Database name
RUVVECTOR_DB_USER
postgres
Database user
RUVVECTOR_DB_PASSWORD
β
Database password
RUVVECTOR_DB_MAX_CONNECTIONS
20
Connection pool size
RUVVECTOR_DB_IDLE_TIMEOUT
30000
Idle timeout (ms)
RUVVECTOR_DB_CONNECTION_TIMEOUT
10000
Connection timeout (ms)
RUVVECTOR_DB_SSL
false
Enable SSL
Variable
Default
Description
RUVVECTOR_SERVICE_URL
http://localhost:6379
RuvVector service URL
RUVVECTOR_API_KEY
β
API key (optional)
RUVVECTOR_TIMEOUT
30000
Request timeout (ms)
RUVVECTOR_POOL_SIZE
10
Connection pool size
Variable
Default
Description
CIRCUIT_BREAKER_THRESHOLD
5
Failures before opening
CIRCUIT_BREAKER_TIMEOUT
30000
Open state duration (ms)
CIRCUIT_BREAKER_RESET
60000
Full reset timeout (ms)
Variable
Default
Description
PORT
3000
HTTP listen port
LOG_LEVEL
info
Log level (debug, info, warn, error, fatal)
SHUTDOWN_TIMEOUT
30000
Graceful shutdown timeout (ms)
MAX_LATENCY_MS
2000
Learning endpoint latency budget (ms)
METRICS_ENABLED
true
Enable Prometheus metrics
METRICS_PORT
9090
Metrics port
# Build
docker build -t ruvector-service .
# Run
docker run -p 8080:8080 --env-file .env ruvector-service
βοΈ Deploy to Cloud Run
gcloud run deploy ruvector-service \
--source=. \
--region=us-central1 \
--port=8080 \
--memory=256Mi \
--cpu=1 \
--max-instances=10 \
--set-env-vars=" NODE_ENV=production,LOG_LEVEL=info,MAX_LATENCY_MS=2000,RUVVECTOR_DB_SSL=true" \
--set-secrets=" RUVVECTOR_DB_HOST=RUVECTOR_DB_HOST:latest,RUVVECTOR_DB_PORT=RUVECTOR_DB_PORT:latest,RUVVECTOR_DB_NAME=RUVECTOR_DB_NAME:latest,RUVVECTOR_DB_USER=RUVECTOR_DB_USER:latest,RUVVECTOR_DB_PASSWORD=RUVECTOR_DB_PASSWORD:latest,EXECUTION_HMAC_SECRET=EXECUTION_HMAC_SECRET:latest" \
--add-cloudsql-instances=agentics-dev:us-central1:ruvector-postgres \
--allow-unauthenticated
# Unit tests
npm test
# Integration tests
npm run test:integration
# Watch mode
npm run test:watch
Available at GET /metrics:
Metric
Type
Description
http_request_duration_seconds
Histogram
Request latency by endpoint
http_requests_total
Counter
Total requests by endpoint and status
active_connections
Gauge
Current active connections
vector_operation_duration_seconds
Histogram
Vector operation latency
vector_operations_total
Counter
Total vector operations
ποΈ Project Structure
ruvector-service/
βββ src/
β βββ index.ts # π Application entry point & route registration
β βββ config/
β β βββ index.ts # βοΈ Environment variable configuration
β βββ handlers/
β β βββ health.ts # Health & readiness probes
β β βββ ingest.ts # Vector ingestion
β β βββ query.ts # Vector querying
β β βββ simulate.ts # Similarity simulations
β β βββ plans.ts # Plans CRUD
β β βββ deployments.ts # Deployments CRUD
β β βββ decisions.ts # Decisions API
β β βββ approvals.ts # Approval processing
β β βββ executions.ts # Execution authority minting
β β βββ simulations.ts # Simulation intent acceptance
β β βββ decisionEvents.ts # Decision event polling & ingestion
β β βββ learning.ts # Learning signal agents
β βββ clients/
β β βββ VectorClient.ts # RuvVector backend client
β β βββ DatabaseClient.ts # PostgreSQL connection pool
β βββ middleware/
β β βββ validation.ts # Zod request validation
β β βββ errorHandler.ts # Error handling
β β βββ latencyBudget.ts # Learning endpoint latency enforcement
β βββ guards/
β β βββ immutability.ts # Historical data integrity checks
β βββ startup.ts # Startup hardening assertions
β βββ utils/
β βββ logger.ts # Pino structured logging
β βββ metrics.ts # Prometheus metric definitions
β βββ correlation.ts # Correlation ID utilities
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
βββ scripts/
β βββ deploy.sh # Deployment script (ruv-cloud)
β βββ deploy-cloudrun.sh # Deployment script (agentics-dev)
βββ Dockerfile # Multi-stage production build
βββ cloudbuild.yaml # Google Cloud Build pipeline
βββ tsconfig.json # TypeScript configuration
βββ jest.config.js # Jest test configuration
βββ .env.example # Environment variable reference
βββ package.json # Dependencies and scripts
π¨ Error Response Format
All errors follow a consistent SPARC-compliant structure:
{
"error" : " error_code" ,
"message" : " Human-readable error message" ,
"correlationId" : " uuid" ,
"details" : []
}
ISC