You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Constitutional Agent-Based World - Enterprise Edition
A production-ready, enterprise-grade multi-agent simulation platform with advanced AI capabilities, security-first governance, and emergent behavior architecture.
CABW (Constitutional Agent-Based World) Enterprise is a comprehensive multi-agent simulation framework designed for research, development, and production deployments. It combines sophisticated agent behaviors, dynamic environments, teamwork systems, and security-first governance into a unified, extensible platform.
The platform is built around a constitutional governance model where security and policy enforcement are structurally unavoidable—not optional advisory functions that agents can bypass.
Features
Core Agent Systems
Feature
Description
Integrated Agents
Full-featured agents with behavior trees, emotions, needs, and memory
Advanced Emotions
PAD-based emotional system with 20 emotions, trauma tracking, and contagion
Complex Actions
Actions with preconditions, effects, costs, and composition
Behavior Trees
10+ node types for hierarchical decision-making with emergent patterns
Teamwork System
Dynamic team formation, 5 roles, shared goals, and coordination bonuses
Physiological Needs
Hunger, thirst, rest, safety, social, and achievement drives
OCEAN Personality
Big Five personality traits influencing all agent behaviors
Dynamic Environment
Weather (8 types), day/night cycle, seasons, and hazards (8 types)
Governance & Security
Feature
Description
Constitutional Layer
Structural enforcement—no action executes without authorization
PBAC
Policy-Based Access Control with 4 security levels and 10 capabilities
Execution Tokens
Single-use, immutable authorization for every action
Tamper-Evident Audit
Hash-chained audit logs for complete traceability
JWT Authentication
Secure API access with role-based permissions (VIEWER, OPERATOR, ADMIN, SYSTEM)
Rate Limiting
Per-subject rate limiting with automatic blocking
Simulation Engine
Feature
Description
Deterministic Replay
Seeded RNG + event-queue architecture for reproducible simulations
Event Queue
Serial event processing eliminates race conditions
Location-based deposits with extraction and regeneration
Scarcity Mechanics
Global and local scarcity tracking affects agent behavior
Quality & Durability
Resources have quality levels and degradation
World Generation
Feature
Description
Procedural Terrain
Perlin noise-based terrain generation
10 Terrain Types
Deep water, shallow water, beach, plains, forest, hills, mountains, snow, desert, swamp
Biome System
Temperature and moisture-based biome generation
Spawn Location Finding
Intelligent agent spawn point selection
REST API & WebSocket
Feature
Description
FastAPI Backend
High-performance async API
Real-time Updates
WebSocket streams for live simulation data
Full CRUD
Complete simulation, agent, and team management
Async SQLAlchemy
Database persistence with PostgreSQL/SQLite support
Quick Start
Requirements
Python: 3.10, 3.11, or 3.12
Database: PostgreSQL (recommended) or SQLite
Cache: Redis (optional, for distributed mode)
OS: Linux, macOS, or Windows
Installation
# Clone the repository
git clone https://github.com/Benhubbard9891/CABW.git
cd CABW
# Install with pip
pip install -e ".[dev]"# Or with Poetry
poetry install
# Install all optional dependencies
pip install -e ".[all]"
Running the Demo
# Run comprehensive demo
python demo_enhanced.py
# Run specific demo
python -c "import asynciofrom demo_enhanced import demo_teamworkasyncio.run(demo_teamwork())"
Starting the API Server
# Development (with auto-reload)
uvicorn src.cabw.api.main:app --reload
# Production
uvicorn src.cabw.api.main:app --host 0.0.0.0 --port 8000
Docker Deployment
# Build and run
docker-compose up --build
# Scale workers
docker-compose up --scale worker=4
# Horizontal scaling with Redis
docker-compose -f docker-compose.scale.yml up --scale worker=10
fromsrc.cabw.core.behavior_treeimportBehaviorTreeLibrary# Available behavior treeslibrary=BehaviorTreeLibrary()
trees=library.list_trees()
# ['combat', 'exploration', 'social', 'agent_ai']# Create tree with blackboardtree=library.create_tree('agent_ai', blackboard)
# Tick the treestatus=tree.tick() # SUCCESS, FAILURE, or RUNNING
fromsrc.cabw.simulation.engineimportEnhancedSimulation# Teams form automatically when:# - Hazards require coordination# - Goals need multiple agents# - Agents are in proximity# Or manually create teamsteam=simulation.team_manager.create_team(
name="Rescue_Squad",
description="Emergency response team"
)
# Add membersfromsrc.cabw.core.teamworkimportTeamMember, TeamRolemember=TeamMember(
agent_id=agent.agent_id,
role=TeamRole.LEADER,
coordination_skill=0.8
)
team.add_member(member)
Shared Goals
fromsrc.cabw.core.teamworkimportGoalTemplates# Create goal from templategoal=GoalTemplates.emergency_response(
description="Contain chemical spill",
urgency=0.9
)
# Assign to teamsimulation.team_manager.assign_goal_to_team(goal, team.team_id)
# Track progressprogress=goal.get_progress()
rewards=goal.calculate_rewards()
Environment System
Weather Control
fromsrc.cabw.core.world_featuresimportWeatherType# Set weathersimulation.environment.weather.weather_type=WeatherType.STORMsimulation.environment.weather.intensity=0.8# Weather affects:# - Agent emotions (fear, anxiety)# - Movement speed# - Team coordination# - Visibility
Hazard Management
# Hazards spawn dynamicallyhazard=simulation.environment._spawn_hazard()
# Propertieshazard.hazard_type# FIRE, FLOOD, COLLAPSE, etc.hazard.severity# MINOR to CATASTROPHIChazard.spread_rate# How fast it grows# Containment requires teamworkifhazard.get_requires_teamwork():
# Form response team automaticallypass
# All actions are auditedaudit_record=governor.audit_log[-1]
# Propertiesaudit_record.timestamp# datetime of the eventaudit_record.subject_id# who made the requestaudit_record.action# 'access', 'modify', 'delete', 'create', …audit_record.decision# 'allow' or 'deny'audit_record.decision_reason# human-readable explanation# Hash chain — tamper-evident linkage between consecutive recordsaudit_record.previous_hash# compute_hash() of the preceding recordaudit_record.record_hash# compute_hash() of this recordaudit_record.compute_hash() # recompute on-demand for verification
# Horizontal scaling with Redis
docker-compose -f docker-compose.scale.yml up --scale worker=10
# Database read replicas# Configure in config.py
Testing
# Run all tests
pytest tests/ -v
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test categories
pytest tests/ -v -m unit
pytest tests/ -v -m integration
pytest tests/ -v -m e2e
# Load testing
locust -f tests/load/locustfile.py