Production Requirement:
- MUST be supplied via
SECRET_KEYenvironment variable - MUST be strong random value (64+ bytes)
- MUST NOT be the legacy default
- Generate with:
python -c "import secrets; print(secrets.token_urlsafe(64))"
Development Behavior:
- Ephemeral key generated on boot
- Tokens invalidated on restart
- Loud warning logged
Production Requirement:
- MUST declare explicit origins via
ALLOWED_ORIGINS - Comma-separated list (no spaces)
- Example:
https://app.opensin.ai,https://docs.opensin.ai
Development Behavior:
- Falls back to localhost origins
- Loud warning logged
| Variable | Required | Description |
|---|---|---|
SECRET_KEY |
β Production | Strong random secret |
ALLOWED_ORIGINS |
β Production | Comma-separated allowed origins |
ENVIRONMENT |
β | development, staging, production |
CODE_SWARM_BASE_DIR |
β | Base directory for data storage |
Content-Security-Policy: Restricted sourcesX-Frame-Options: DENYX-Content-Type-Options: nosniffStrict-Transport-Security: max-age=31536000; includeSubDomains
- 1000 requests/hour default
- Configurable via
RATE_LIMITenv var - Redis-backed for distributed environments
- JWT with HS256
- 15 minute token expiration
- Refresh tokens with 7 day expiration
- RBAC with 3 roles:
user,agent,admin
- Prometheus metrics enabled by default
- Sentry integration optional
- Health checks:
/health,/ready
-
SECRET_KEYset to strong random value -
ALLOWED_ORIGINSset to production domains -
ENVIRONMENT=production - Database with TLS connection
- Redis with TLS connection
- All secrets in secure vault (not in repo)
- CI/CD pipeline with security scanning
- Trivy: Filesystem scanning for vulnerabilities
- Bandit: Python code security analysis
- Safety: Python dependency vulnerability scanning
- Snyk: Container image scanning
| Severity | Response Time | Escalation |
|---|---|---|
| Critical | < 1 hour | CEO + Security Team |
| High | < 4 hours | Security Team |
| Medium | < 24 hours | Development Team |
| Low | < 72 hours | Developer On-Call |
name: Code-Swarm Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
PYTHON_VERSION: "3.11"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests
run: |
pytest tests/ --cov=api --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v4name: Code-Swarm Security Scan
on:
push:
branches: [ main ]
schedule:
- cron: '0 0 * * *'
env:
PYTHON_VERSION: "3.11"
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Security scan
uses: aquasecurity/trivy-action@master
with:
scan-type: "fs"
scan-ref: "."
format: "table"
exit-code: "1"
severity: "CRITICAL,HIGH"-
Vercel Deployment:
npm install -g vercel vercel pull --yes --environment=production --token=$VERCEL_TOKEN vercel build --prod --token=$VERCEL_TOKEN vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN
-
Environment Variables:
# Set required env vars in Vercel vercel env add SECRET_KEY production vercel env add ALLOWED_ORIGINS production vercel env add ENVIRONMENT production
# Make executable
chmod +x vercel-deploy.sh
# Deploy to preview
./vercel-deploy.sh preview
# Deploy to production
./vercel-deploy.sh production| Variable | Description | Example |
|---|---|---|
SECRET_KEY |
Strong random secret | python -c "import secrets; print(secrets.token_urlsafe(64))" |
ALLOWED_ORIGINS |
Comma-separated allowed origins | https://app.opensin.ai,https://docs.opensin.ai |
ENVIRONMENT |
production or preview |
production |
VERCEL_TOKEN |
Vercel API token | vercel token create |
- Verify
/healthendpoint returns 200 OK - Verify
/docsSwagger UI is accessible - Test authentication flow
- Verify CORS headers are correct
- Set up monitoring and alerts
- Configure custom domain
- Set up SSL certificates
# Make executable
chmod +x vercel-deploy-prod.sh
# Deploy to production
./vercel-deploy-prod.sh| Variable | Production Value | Description |
|---|---|---|
SECRET_KEY |
FJ9wyxt_wMEPV6pYvu2Ptt_pP04q1OjbNgVM3ZnhltUD6zPnHQh-sAqXajbuohLUq7nwe6Iihj0L6RnpMknyog |
Strong random secret |
ALLOWED_ORIGINS |
https://app.opensin.ai,https://docs.opensin.ai |
Production domains |
ENVIRONMENT |
production |
Production mode |
DATABASE_URL |
postgresql://opensin:S3cur3P@ssw0rd@db.opensin.ai:5432/code_swarm_prod |
Production database |
REDIS_URL |
redis://:R3d1sP@ssw0rd@cache.opensin.ai:6379/0 |
Production cache |
PRIMARY_MODEL |
fireworks-ai/minimax-m2.7 |
Primary agent model |
VISION_MODEL |
nvidia/nvidia/nemotron-3-nano-omni |
Vision model |
-
Health Check
curl https://api.opensin.ai/health
-
Metrics
curl https://api.opensin.ai/metrics
-
Swagger UI
https://api.opensin.ai/docs
- Prometheus: https://prometheus.opensin.ai
- Grafana: https://grafana.opensin.ai/d/code-swarm
- Sentry: https://sentry.io/organizations/opensin/
- Logs: https://logs.opensin.ai
- Critical: CEO + Security Team
- High: Security Team
- Medium: Development Team
- Low: Developer On-Call