Skip to main content

Configuration

Surrogate OS is configured through environment variables and a typed configuration file.

Environment Variables

API Server

VariableDefaultDescription
PORT3001API server port
DATABASE_URLpostgresql://surrogate:surrogate_dev@localhost:5432/surrogate_osPostgreSQL connection
JWT_SECRETsurrogate-dev-secret-change-in-prodJWT signing secret
JWT_ACCESS_EXPIRY15mAccess token TTL
JWT_REFRESH_EXPIRY7dRefresh token TTL
OTEL_ENDPOINThttp://localhost:4318OpenTelemetry collector
LOG_LEVELinfoLogging level
NODE_ENVdevelopmentEnvironment

Safety Configuration

Safety settings are architectural constraints. Several cannot be disabled regardless of configuration.

// surrogate.config.ts
export default {
identity: {
personaSource: 'library', // 'library' | 'custom' | 'generated'
personaId: 'P-001',
orgDnaPath: './org-documents/',
jurisdictionOverride: null
},

safety: {
humanAuthThreshold: 'MEDIUM', // LOW | MEDIUM | HIGH | CRITICAL_ONLY
killSwitchEnabled: true, // ⚠️ CANNOT be set to false
auditLevel: 'FULL',
biasMonitoring: true, // ⚠️ CANNOT be disabled for welfare roles
identityIntegrityLock: true // ⚠️ CANNOT be disabled
},

interfaces: {
chat: { enabled: true, port: 3000 },
voice: { enabled: false, provider: 'twilio' },
api: { enabled: true, port: 8080 },
humanoid: {
enabled: false, // Phase 4 feature
platform: 'figure-01',
physicalAuthRequired: true, // ⚠️ CANNOT be set to false
killSwitchHardware: true
}
},

learning: {
shiftDebrief: true,
sopAutoUpdate: false, // Manual approval required
federatedLearning: true,
contributionConsent: true
}
};

Immutable Constraints

These are enforced in code and cannot be overridden by any config, prompt, or API call:

const IMMUTABLE_CONSTRAINTS = {
AI_IDENTITY_DISCLOSURE: 'ALWAYS',
HUMAN_OVERRIDE_POSSIBLE: 'ALWAYS',
AUDIT_LOG_IMMUTABLE: true,
KILL_SWITCH_ACTIVE: 'ALWAYS',
PHYSICAL_AUTH_FOR_HUMAN_CONTACT: 'ALWAYS',
PERSONA_MID_OP_SWITCH: 'BLOCKED',
MAX_AUTONOMOUS_RISK_LEVEL: 2 // L3+ always requires human auth
} as const;

Multi-Tenant Configuration

Each organization gets its own PostgreSQL schema. Tenant routing is handled automatically:

// Per-org encryption (BYOK)
const tenantConfig = {
orgId: 'org_nhs_trust_001',
schema: 'tenant_nhs_trust_001',
encryptionKey: 'customer-provided-key', // Org holds, not us
vectorDbNamespace: 'nhs_trust_001',
dataResidency: 'UK'
};

Testing

npm test                  # Full test suite
npm run test:unit # Unit tests
npm run test:safety # Required before production deployment
npm run test:validation # Domain expert validation

Safety Test Coverage Requirements

CategoryRequiredStatus
Kill switch response100%
Human auth enforcement100%
Identity disclosure100%
SOP compliance>95%
Bias detection triggers>90%
Escalation accuracy>95%🔄 In Progress
Physical hard stop100%📋 Phase 4