Overview
The operations module (src/ops/) provides portable utilities for managing evolver lifecycle, monitoring health, and performing maintenance. These commands are designed to work in any environment without platform dependencies.
Lifecycle Commands
Manage the evolver daemon with the lifecycle module:start
Start the evolver daemon in the background:Check for Running Instance
Scans for existing evolver processes:If found, exits without starting a new instance.
stop
Gracefully stop all running evolver loops:
Output:
restart
Stop and restart the evolver daemon:- Calls
stop()to terminate running instances - Waits 2 seconds (configurable)
- Calls
start()to spawn a new instance
status
Check if the evolver daemon is running:check
Perform health check and auto-restart if unhealthy:- Process running: At least one evolver PID found
- Log freshness: Log file modified within the last 30 minutes
log
View recent log output:tail -n 20 on the log file (memory/evolver_loop.log).
Options:
View more lines:
Health Monitoring
The health check module (src/ops/health_check.js) runs system diagnostics:
Health Checks
Environment Variables
Environment Variables
Checks for required secrets:
- Critical:
FEISHU_APP_ID,FEISHU_APP_SECRET(warning if missing) - Optional:
CLAWHUB_TOKEN,OPENAI_API_KEY(info if missing)
Disk Space
Disk Space
Monitors root filesystem usage:
- Warning: >80% used
- Critical: >90% used
Memory Usage
Memory Usage
Checks system memory:
- Critical: >95% used
Process Count (Linux only)
Process Count (Linux only)
Detects fork bombs or leaks:
- Warning: >2000 processes
Health Status
Cleanup Operations
The cleanup module (src/ops/cleanup.js) removes stale artifacts:
What Gets Cleaned
Removes old GEP prompt files frommemory/evolution/:
- Files matching
gep_prompt_*.jsonorgep_prompt_*.txt - Older than 24 hours
- Keeps at least 10 most recent files
- Enforces max 10 files total
Programmatic Usage
Self-Repair Mechanisms
The evolver includes built-in self-repair capabilities:Git Rollback
On evolution failure, the evolver automatically rolls back changes:Circuit Breaker
Prevents infinite repair loops by forcing innovation:Suicide Mechanism
In loop mode, the evolver restarts itself proactively:Process Discovery
The lifecycle module discovers running evolver processes by scanningps output:
Wake Triggers
The evolver supports external wake triggers via thesrc/ops/trigger.js module (not detailed in source, but referenced in operations index).
Expected usage:
Monitoring in Production
Recommended Setup
Monitoring Metrics
Key metrics to track:| Metric | Command | Threshold |
|---|---|---|
| Process uptime | ps -p $(cat memory/evolver_loop.pid) -o etime= | Greater than 0 |
| Memory usage | ps -p $(cat memory/evolver_loop.pid) -o rss= | Less than 500MB |
| Log freshness | stat -c %Y memory/evolver_loop.log | Less than 1800s |
| Cycle rate | grep "Starting cycle" memory/evolver_loop.log | tail -10 | 1-5/min |
| Error rate | grep -c "Evolution failed" memory/evolver_loop.log | Less than 10/day |
Operations Module API
For programmatic access:Troubleshooting
Daemon Won’t Start
Problem:start command returns “already_running” but no process is visible.
Solution: Remove stale lock files:
Health Check Fails
Problem:check reports unhealthy due to stagnation.
Solution: Inspect the log for errors:
- Evolution saturated (expected in steady-state)
- Git errors blocking solidify
- Validation failures
Stop Command Hangs
Problem:stop command doesn’t return.
Solution: Force kill the process:
Best Practices
- Use lifecycle commands: Don’t manage processes manually
- Run health checks periodically: Catch stagnation early
- Monitor logs: Set up alerting for “Evolution failed” patterns
- Enable log rotation: Prevent disk exhaustion
- Run cleanup regularly: Keep artifact directories lean
- Test rollback: Verify
EVOLVER_ROLLBACK_MODE=stashworks in your environment
Next Steps
Loop Mode
Deep dive into daemon behavior
Review Mode
Manual approval workflow
Strategy Presets
Configure evolution focus
Running Evolver
Basic execution guide