def-autonomy is a lightweight Python-based cybernetic control library implementing the Dynamic Drive-Evaluation-Function (DEF) decision-making engine [1.3]. This framework adapts biophysiologically inspired principles of homeostatic self-regulation to design robust, self-adaptive autonomous software agents.
Unlike traditional deep reinforcement learning controllers that require substantial compute resources and are prone to unpredictable training distribution shifts, or hardcoded Finite State Machines (FSMs) that lack behavioral flexibility, def-autonomy evaluates candidate actions dynamically. It operates by continuous vector-projection of state-space deficits against environmental affordance gradients under shifting behavioral regimes.
The core architecture functions by mapping standard engineering telemetry to physiological state primitives:
| Biological Term | Cybernetic Translation | Simulator Implementation Variables |
|---|---|---|
| Satiety ( |
Primary System Utility / Buffer Headroom | Available compute slots, battery levels, network headroom |
| Toxicity ( |
System Stress / Performance Penalties | Node request latency, HTTP error rate, hardware degradation |
| Metabolic Decay | System Idle Overhead | Idle host pricing, static network egress fees, passive battery loss |
| Threat Event ( |
External System Vulnerability Risk | Unmitigated DDoS request surges, critical hardware faults |
| Foraging/Exploitation | Nominal Utility Execution Regime | Processing client queries, running indexing jobs |
| Survival | Active Hazard Mitigation Regime | Rate limiting, hot-swapping instances, shedding client loads |
| Conservation | System Consolidation / Optimization | Node consolidation, standby power mode, garbage collection |
def-autonomy/
βββ .gitignore # Ignores byte-code, virtualenvs, output figures, and raw datasets
βββ requirements.txt # Single dependency (numpy >= 1.20.0)
βββ README.md # Framework manual, setup instructions, and mathematical specifications
βββ def_core.py # Abstract Dynamic Drive-Evaluation-Function agent core
βββ def_optimizer.py # Complete (ΞΌ + Ξ») Evolutionary Strategy optimizer
βββ example_autoscaler.py # Concrete cloud infrastructure resource simulation environment
βββ tests/
βββ __init__.py # Configures testing paths and package boundaries
βββ test_core.py # Comprehensive test suite for state boundaries and drive dynamics
# Clone the codebase
git clone https://github.com/your-username/def-autonomy.git
cd def-autonomy
# Initialize and launch virtual environment
python -m venv venv
source venv/bin/activate # On Windows run: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtExecute the physical simulator, which models a cluster managing variable traffic demands, resource exhaustion boundaries, and periodic security vulnerabilities:
python example_autoscaler.pyRun the localized evolutionary strategy to discover optimized policy weights that minimize system error rates and maximize survival steps:
python def_optimizer.pyVerify the structural integrity of the mathematical boundaries and behavioral transitions:
python -m unittest tests/test_core.pyThis section details the formal mathematical formulations executed inside the def_core.py controller and simulated across the environment step loops.
The internal physiological state of the cybernetic agent is defined at any discrete time
-
$x_{0, t} \in [0, 10]$ represents the System Headroom / Satiety (e.g., free memory or available worker threads). -
$x_{1, t} \in [0, 10]$ represents the Operational Stress / Toxicity / Error Rate (e.g., request latency or thread queue depth).
The long-term infrastructure capacities are managed by auxiliary scalar state variables:
-
$x_{c, t} \in [0, 10]$ represents Catabolic Resource Capacity (e.g., absolute virtual machine allocation limit). -
$x_{e, t} \in [0.1, 10]$ represents Active Energy/Memory Headroom (e.g., active heap size).
The spatial state coordinates of the agent and environmental features are:
-
$ag_t \in \mathbb{R}^2$ : Physical coordinate center of the agent. -
$pf_t \in \mathbb{R}^2$ : Physical coordinate center of the nearest resource target. -
$thr_t \in \mathbb{R}^2$ : Physical coordinate center of the nearest threat/hazard.
The raw spatial distances to physical opportunities and constraints are mapped to exponential sensory feedback signals (
The positive and negative stimulus profiles are converted as follows:
The agent dynamically updates its target state vector
Where:
-
$\theta_{\text{threat}}$ represents the threat activation boundary parameter (threat_radius). -
$\theta_{\text{forage}}$ represents the foraging activation threshold parameter (exploitation_trigger_thresh). -
$\theta_{\text{conserv}}$ represents the conservation activation threshold parameter (conservation_trigger_thresh).
The homeostatic target vector
The environmental divergence
The sensory gating weight
Operational efficiency
The genome contains mapping matrices
Applying a sigmoidal activation models policy selection probability:
The agent evaluates utility
Where:
-
$G_{\text{field}} = 1.0$ represents the baseline goal field inhibition. -
$\zeta_t$ is an emergency scalar defined as: $$\zeta_t = \begin{cases} 1.0 + e^{-\frac{d_{\text{threat}}}{\theta_{\text{gate}}}}, & \text{if } cl_t = \text{SURVIVAL} \ 1.0, & \text{otherwise} \end{cases}$$ (where $\theta_{\text{gate}}$ represents the threat gate radius parameter,threat_gate_radius)
The system selects the optimal action index $a^$: $$a^ = \arg\max_{j} U_j$$
Once the optimal policy action index is selected, physical movement vectors (
The physical step uses the speed limit parameter v_max):
Physiological and metabolic capacities decay linearly at each discrete time step: