Autonomous Neuro-Symbolic Research & Algorithmic Discovery Engine
An autonomous neuro-symbolic continuous discovery system integrating a continuous execution heartbeat, cognitive memory with recursive compaction, RRF hybrid RAG search, multi-island evolutionary search (FunSearch), Counterexample-Guided Inductive Synthesis (CEGIS) with Z3, formal verification via Lean 4, dual-tier WASM/gVisor sandboxing, and automated GitHub GitOps PR publishing.
π View Interactive Mermaid Topology
flowchart TD
%% Styling and Themes
classDef control fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff;
classDef loop fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff;
classDef sched fill:#0f172a,stroke:#6366f1,stroke-width:2px,color:#fff;
classDef memory fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff;
classDef engine fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#fff;
classDef prover fill:#581c87,stroke:#a855f7,stroke-width:2px,color:#fff;
classDef sandbox fill:#0f172a,stroke:#10b981,stroke-width:2px,color:#fff;
classDef gitops fill:#0f172a,stroke:#a855f7,stroke-width:2px,color:#fff;
Deck["<b>FastAPI Real-Time Control Deck</b><br/>(WebSockets, SSE, Telemetry, CEGIS, Lean 4)"]:::control
Loop["<b>Continuous Agent Loop</b><br/>β’ Asynchronous Heartbeat<br/>β’ Multi-Turn Tools<br/>β’ Circuit Breaker"]:::loop
Sched["<b>Task Scheduler (Cron)</b><br/>β’ Live Countdown Deck<br/>β’ Dynamic Croniter<br/>β’ Nightly Discovery"]:::sched
Mem["<b>Cognitive Memory</b><br/>β’ Working Scratchpad<br/>β’ Reflexion (Self-Learn)<br/>β’ Episodic Compaction<br/>β’ RRF Hybrid Search"]:::memory
Evol["<b>Evolutionary Engine</b><br/>β’ FunSearch Service<br/>β’ Multi-Island Model<br/>β’ Behavioral Probes<br/>β’ Strategy Stagnation"]:::engine
Symb["<b>Neuro-Symbolic & CEGIS</b><br/>β’ AST-to-Z3 Transpiler<br/>β’ Singularity / Monotonic<br/>β’ Dynamic Suite Invariant<br/>β’ Lean 4 Kernel Prover"]:::prover
Sand["<b>Dual-Tier Sandboxing</b><br/>β’ WebAssembly (Fuel Cap)<br/>β’ 1-Page Linear Memory<br/>β’ gVisor (runsc) Fallback"]:::sandbox
Git["<b>GitOps PR Automation</b><br/>β’ Auto Feature Branch<br/>β’ Code + Lean Certificate<br/>β’ GitHub REST API PR Open"]:::gitops
Deck --> Loop
Deck --> Sched
Loop --> Mem
Loop --> Evol
Sched --> Evol
Sched --> Symb
Evol --> Sand
Symb --> Git
Symb -. "<b>CEGIS Invariant Feedback Loop</b>" .-> Evol
| Layer | Dependency | Fallback / Impact If Missing |
|---|---|---|
| LLM Provider | OPENAI_API_KEY (or Anthropic/Custom) in .env |
Island mutations and prompt synthesis require an active API key. |
| SMT & Formal Proofs | elan (Lean 4 compiler) + z3-solver |
Synthesizes Lean 4 code; verification requires elan toolchain on PATH. |
| Container Sandbox | Host Docker daemon with runsc (gVisor) runtime |
Automatic fallback: If Docker is offline, system automatically evaluates programs in-process via WebAssembly or local simulation. |
| WASM Runtime | wasmtime Python wheel |
Sub-millisecond in-process evaluations (<40Β΅s). |
| GitOps (Optional) | GITHUB_TOKEN + GITHUB_REPO |
Automated branch, commit, and PR creation via GitHub REST API. |
Clone the repository and run the automated bootstrap script:
git clone https://github.com/AmithKumar1/continuous-agent.git
cd continuous-agent
chmod +x setup.sh
./setup.sh(Windows users can run .\setup.ps1 in PowerShell)
Edit the generated .env file with your API credentials:
nano .env # Add your OPENAI_API_KEY, AGENT_API_TOKEN, etc.Activate the isolated environment and boot the FastAPI control dashboard:
source .venv/bin/activate
python main.pyOpen http://localhost:8000 in your browser to access the live telemetry pipeline, interactive Z3 invariant probe, and evolutionary island controls.
docker compose up --build -dIf running directly on macOS, Linux, or Windows without Docker:
-
Install Lean 4 via
elan(macOS/Linux):curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain leanprover/lean4:stable source $HOME/.elan/env
-
Install Python requirements:
pip install -r requirements.txt
-
Run pre-flight verification:
python preflight.py
-
Start the daemon:
python main.py
The FastAPI dashboard (http://localhost:8000) provides real-time telemetry over WebSockets:
-
Dynamic Animated SVG Pipeline Flowchart:
- Live visual progression:
IslandsβWASM SandboxβZ3 SMT ProverβLean 4 KernelβGitOps Dispatch. - Reverse rose-tinted CEGIS counterexample feedback beam on invariant violations.
- Dynamic stage controller with glowing SVG filters.
- Live visual progression:
-
High-DPI Canvas Radar Chart (
Island Population Dynamics):- Multi-axis behavioral tracking across 5 dimensions: Peak Fitness, Cluster Diversity, AST Parsimony, Throughput, and Invariant Soundness.
- Retina-scaled rendering (
devicePixelRatio). - Euclidean distance hit-testing (<18px) with pulsing halos and floating glassmorphic tooltip.
-
Nightly Discovery Scheduler:
- Live countdown display for cron-scheduled discovery runs (default
0 2 * * *). - Preset buttons and manual immediate dispatch trigger.
- Live countdown display for cron-scheduled discovery runs (default
-
Neuro-Symbolic CEGIS & Lean 4 Prover:
- Interactive heuristic editor with Singularity test presets.
- Live Z3 SMT contract checking with counterexample extraction.
- Lean 4 formal proof certificate generation and GitHub PR creation.
# Test WebAssembly JIT execution & fuel limits
python test_wasm_sandbox.py
# Test Lean 4 proof synthesis
python test_lean_verify.py
# Run empirical benchmark suite (Falkenauer U120 + Weibull Burst)
python benchmark_efficacy.pyContinuous Agent is benchmarked against classic online bin packing suites (Falkenauer U120 and Weibull Burst distribution streams) comparing discovered heuristics against established human baselines:
| Algorithm / Heuristic | Benchmark Set | Average Utilization | Optimal Bins Delta | Proof Status |
|---|---|---|---|---|
| Next Fit (NF) | Falkenauer U120 | 74.8% | +32.4% bins | Baseline |
| First Fit (FF) | Falkenauer U120 | 91.7% | +8.0% bins | Baseline |
| Best Fit (BF) | Falkenauer U120 | 92.0% | +7.6% bins | Baseline |
| Discovered Heuristic #1 | Falkenauer U120 | 92.0% | +7.6% bins | Lean 4 Verified |
| Next Fit (NF) | Weibull Burst | 80.1% | +22.7% bins | Baseline |
| First Fit (FF) | Weibull Burst | 95.1% | +3.3% bins | Baseline |
| Best Fit (BF) | Weibull Burst | 95.7% | +2.7% bins | Baseline |
| Discovered Heuristic #1 | Weibull Burst | 95.7% | +2.7% bins | Lean 4 Verified |
-
Two-Tier Model Routing (80β90% Cost Reduction):
- Routine island mutations are offloaded to local open-weight coding models (
qwen2.5-coder:7bvia Ollama/vLLM). - Frontier models (
gpt-4o-mini) are reserved exclusively for supervisor reflection and population restarts.
- Routine island mutations are offloaded to local open-weight coding models (
-
Expression-Only AST Diff Prompting:
- Prompting is restricted to mathematical return expressions (
return ...), avoiding ~350 tokens of repetitive boilerplate per evaluation cycle.
- Prompting is restricted to mathematical return expressions (
-
Semantic AST Memoization:
- Canonicalizes variable names (
bin_capacity$\rightarrow c$ ,item$\rightarrow i$ ) and deduplicates structurally identical heuristics in SQLite before evaluation.
- Canonicalizes variable names (
-
Staged Fail-Fast Pipeline:
- Evaluates cheap gates first:
AST Allowlist (<1ms)$\rightarrow$ WASM Smoke (<50Β΅s)$\rightarrow$ Z3 Probe (<15ms)$\rightarrow$ Full Benchmarks (<2ms)$\rightarrow$ Lean 4 Proofs.
- Evaluates cheap gates first:
-
Zero-Trust AST Guard:
- Pure mathematical allowlist (
agent/ast_guard.py) strictly blocksimport,exec(),eval(),open(), loops, and dunder attribute access before code execution.
- Pure mathematical allowlist (
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Web operator dashboard UI |
GET |
/api/status |
Current heartbeat iteration and agent state |
POST |
/api/pause |
Pause agent heartbeat loop |
POST |
/api/resume |
Resume agent heartbeat loop |
POST |
/api/trigger |
Trigger immediate single-cycle step |
GET |
/api/memory/core |
Read active working scratchpad |
POST |
/api/memory/core |
Set or update working scratchpad key/value |
GET |
/api/memory/heuristics |
Fetch learned operational rules |
GET |
/api/memory/search?q=... |
Hybrid RRF episodic memory search |
POST |
/api/funsearch/start |
Launch multi-island evolutionary search |
GET |
/api/funsearch/telemetry |
Real-time evolutionary search telemetry |
POST |
/api/cegis/probe |
Run Z3 contract verification on heuristic code |
POST |
/api/verify/lean |
Synthesize and check Lean 4 proof certificate |
POST |
/api/gitops/create-pr |
Open GitHub PR for verified heuristic |
GET |
/api/scheduler/status |
Cron schedule status and live countdown |
POST |
/api/scheduler/update |
Update cron schedule pattern |
POST |
/api/scheduler/trigger-now |
Launch overnight discovery pipeline immediately |
GET |
/api/evolution/pareto-profile |
Live non-dominated Pareto frontier and island entropy diagnostics |
GET |
/api/evolution/policy-audit |
Historical record of adaptive policy shifts and parallel beam evaluations |
GET |
/metrics |
Prometheus exposition endpoint with live SQLite state sync |
WS |
/ws/telemetry |
Real-time WebSocket event stream |
Continuous Agent exposes research-grade telemetry and alerting via native Prometheus exposition on /metrics:
- Evolutionary Population Health:
continuous_agent_island_fitness_best,continuous_agent_island_fitness_mean,continuous_agent_island_phenotypic_entropy,continuous_agent_island_pareto_count, andcontinuous_agent_island_stagnation_generations. - AST Cache & Transpiler Efficiency:
continuous_agent_ast_cache_lookups_total(hit/miss counters) andcontinuous_agent_ast_cache_hit_ratio. - Formal Verification Outcomes:
continuous_agent_lean_proofs_total(success, kernel_error, timeout) andcontinuous_agent_cegis_probes_total(verified, refuted, timeout). - Execution Cost Profiling:
continuous_agent_wasm_fuel_consumedhistogram tracking instruction fuel consumption distribution.
- Grafana Dashboard: Pre-configured definition in
deploy/grafana-dashboard.jsonprovides an 8-panel overview with Pareto convergence, entropy gauges, and verification latency. - Prometheus Alert Rules: Pre-configured alerts in
deploy/prometheus-alerts.ymlcovering phenotypic entropy decay (< 0.6), severe monoculture (< 0.2), prolonged fitness plateaus, Lean 4 proof kernel crashes, and process downtime. - Promtool Unit Testing: Comprehensive synthetic unit tests in
tests/test_prometheus_alerts.ymlvalidated via CI.
-
Bi-Objective Pareto Dominance: Evaluates heuristics balancing Packing Ratio (
$f_{\text{pack}} \in [0, 1]$ , maximize) against WASM Instruction Fuel ($f_{\text{cost}}$ , minimize) without arbitrary scalar weights. -
Fast Non-Dominated Sorting & Crowding Distance: Partitions populations into Pareto fronts (
$F_1, F_2, \dots$ ) and preserves diverse boundary trade-offs via crowding distance metrics. -
Phenotypic Shannon Entropy Decay: Tracks discrete decision cluster distribution over sliding generation windows; detects diversity collapse and flatlined fitness velocity:
-
H < H_threshold$\rightarrow$ triggers Ring Migration between islands. - Severe stagnation (
$> 2W$ generations)$\rightarrow$ triggers Cataclysmic Paradigm Restart.
-
-
Automated Schema Migration:
scripts/migrate_nsga2_schema.pyprovides non-destructive online upgrades addingpareto_rank,crowding_distance, and composite indexidx_heuristics_pareto.
-
Ring Migration Topology: When an island's Shannon entropy or fitness velocity plateaus,
execute_ring_migration()transfers non-dominated Pareto exemplars to downstream neighbor islands ($i \to (i+1)%N$ ), injecting novel decision phenotypes without losing accumulated elite fitness. -
Cataclysmic Paradigm Restarts: Under severe prolonged stagnation (
$> 2W$ generations),execute_cataclysmic_restart()purges non-Pareto individuals, preserves top Pareto stars, and switches the island's LLM mutation paradigm across orthogonal strategies (INVERSE_FIT_DIVERGENCE,STOCHASTIC_SCATTER,COMPACT_GREEDY). -
Entropy-Driven Thermal & Multi-Parameter Sampling Policy: Synchronously scales generation parameters based on the normalized entropy deficit
$D(H) = \max(0, 1 - H/H_{\text{target}})$ :-
Temperature:
$T \in [0.20, 0.95]$ -
Nucleus Sampling:
$top_p \in [0.70, 0.98]$ -
Mutation Beam Width:
$K \in [1, 4]$ parallel mutation proposals per prompt.
-
Temperature:
-
Policy Audit Trail: All adaptive parameter transitions and parallel beam candidate yields are persisted to the
supervisor_policy_audittable with composite indexing for inspection viaGET /api/evolution/policy-audit.
- Isolated Storage: Local SQLite databases (
agent_state.db) and ChromaDB vector collections (chroma_data/) are isolated and omitted from source control. - Scope Restriction: Autonomous security audits enforce explicit host allowlisting (
SECURITY_SCAN_ALLOWED_HOSTS). - Deadlock-Free Lock Ordering: Distributed tool execution enforces ordered resource locks to prevent concurrency deadlocks.
- Resource Limits: WASM execution enforces explicit fuel depletion bounds; gVisor fallback enforces read-only root filesystems and process limits.
- Authentication: REST API and WebSocket channels secured via
X-API-KeyorAuthorization: Bearer <token>.
- SQLite WAL Mode & Concurrency:
agent_state.dbruns withPRAGMA journal_mode = WAL,busy_timeout = 10000, andsynchronous = NORMAL, enabling lock-free concurrent reads during heavy evolutionary mutation batches. - Zero-Downtime Hot Backups:
scripts/backup_db.pyleverages SQLite's nativebackup()API with incremental 250-page slices, PRAGMA integrity verification, gzip compression, and rolling 14-snapshot rotation. - Automated Systemd Supervision: Automated 6-hour backups scheduled via
deploy/continuous-agent-backup.serviceanddeploy/continuous-agent-backup.timer. - Safe Disaster Recovery:
scripts/restore_db.pyexecutes staged restore in isolated sandboxes with pre-restore active archival,--dry-runschema census, and automated rollback upon swap failure:# Inspect snapshot without modifying active state python scripts/restore_db.py --dry-run # Restore latest snapshot with confirmation prompt python scripts/restore_db.py # Automated CI/CD restore python scripts/restore_db.py --source backups/agent_state_20260905_060000Z.db.gz --yes
MIT License. See LICENSE for details.