Project Hermit is a Mobile-native, closed-loop autonomous self-optimization engine and dynamic Model Context Protocol (MCP) tool host. Operating as a background daemon (hermit_daemon.py), Hermit continuously discovers, profiles, refactors, and tests Python payload routines inside isolated RAM-disk sandbox environments (sandbox.py) using LLM-driven code synthesis combined with deterministic mathematical and AST mutators (math_mutator.py, qubo_mutator.py).
Project Hermit resolves five critical operational failures common to long-horizon autonomous AI systems:
-
Queue Starvation (Phase 1 vs. Phase 2 Dual-Phase Scheduling): Prevents high-latency functions from monopolizing mutation cycles by alternating between exploration of zero-merge functions sorted by optimization headroom (
$H = \text{latency} \times \text{complexity}$ ) and exploitation of bottleneck functions with concurrency caps (MAX_CONSECUTIVE = 3). -
Strategy Oscillation (6-Merge Sequence Pattern Banning): Replaces simplistic count-based strategy banning with sequence pattern detection (
A-B-A-BorA-B-C-A-B-Cover a 6-merge window), eliminating false-positive bans on newly merged successful code. -
RAM Measurement Distortion (Fork-Based Grandchild Isolation): Captures exact, non-cumulative peak RSS per candidate run, eliminating historical
RUSAGE_CHILDRENcumulative noise. -
Thermal & Quota Resilience: Predictively throttles execution based on CPU temperature trend slopes (
/sys/class/thermal/) and enforces pacing delay guards between outbound LLM API requests. -
Host Protection & Introspection Rollback (
IMMUTABLE_FUNCTIONS): Protects core host looper functions (get_next_target,sandbox_run,detect_oscillation) from self-mutation and automatically rolls back failed introspection patches via versioned database snapshots (.hermit_backup_v*).
Project Hermit was engineered through Human-AI Collaboration between the developer and the Google Antigravity CLI:
- Development Environment & Host Hardware: Built and benchmarked entirely on a Samsung Galaxy A36 running Termux inside a PRoot virtualized Linux environment.
- Human-AI Collaboration Model:
- Developer: Directed project goals, identified mobile hardware constraints (thermal throttling on ARM/mobile devices, queue starvation, memory reporting issues), defined system requirements, and guided architectural iterations.
- Google Antigravity CLI: Served as the AI pair programmer in Termux/PRoot to implement AST mutator engines, write verification test suites, refactor core engines, and generate full repository documentation artifacts.
graph TD
A[HermitDaemon - Dual-Phase Scheduler] -->|1. Select Target Skill| B[StaticMCPHost / Orchestrator]
B -->|2. Check Quota & Pacing| C[API Key & Pacing Guard]
B -->|3. Synthesize Mutation| D[Mutator Engines: Math / QUBO / LLM]
D -->|4. Generate Candidate Code| E[Sandbox Execution Harness]
E -->|5. RAM Disk Isolation tmpfs| F[AST Code Safety Analyzer]
F -->|6. Child Fork Execution| G[Verification & Benchmark Harness]
G -->|7. Multi-Objective Score| H[Pareto Evaluation & Baseline Hash Check]
H -->|Pass: Merge Candidate| I[SQLite hermit_memory.db & Hot Reload]
H -->|Fail: Log Anti-Pattern| J[Anti-Pattern Store & Banned Strategies]
All detailed documentation, architectural specs, threat models, and research ledgers generated under the Repository Reconstruction Roadmap (v1.0) standard are located in the docs directory.
| Document | Description |
|---|---|
| PROJECT_OVERVIEW.md | Core purpose, problem statement, engineering goals, target users, and non-goals. |
| ARCHITECTURE.md | Module responsibilities, Mermaid execution flows, dynamic MCP server payload decoupling, and APIs. |
| HISTORY.md | Chronological history across 19 release directories (v0.0.1 to v0.1.9) and architectural pivots. |
| DESIGN_DECISIONS.md | Engineering trade-offs, rejected alternatives, sandbox security choices, and optimization rationale. |
| FEATURES.md | Detailed inventory of host engines, specialized AST mutators (Math & QUBO), and active payload tables. |
| INSTALL.md | Prerequisites, virtual environment setup, API key environment configuration, and test commands. |
| USAGE.md | Quick start steps, background daemon controls, monitoring operations, and interactive CLI usage. |
| API.md | Complete Python API reference for Orchestrator, HermitDaemon, sandbox.py, and AST safety analyzers. |
| CONFIGURATION.md | Environment variables, runtime parameters, default settings, and database table schemas. |
| SECURITY.md | Threat model, AST static safety filtering (analyze_code_safety), and RAM disk isolation. |
| PERFORMANCE.md | Empirical latency gains, AST/QUBO math mutator efficiency, memory footprint, and thermal scaling. |
| TESTING.md | Multi-layered test hierarchy, frozen baseline harness hash verification, and downstream regression tests. |
| RESEARCH.md | Researcher agent architecture (researcher.py), experimental hypotheses, notes storage, and conclusions. |
| LIMITATIONS.md | Technical debt, token cost escalation on complex functions, Linux kernel bounds, and unsupported features. |
| PROJECT_STATUS.md | Living project status, recent v0.1.9 hardening achievements, and current development priorities. |
| NEXT_STEPS.md | Future roadmap (Docker sandboxing, AST mutator expansion, remote MCP transport, dynamic RL scheduling). |
| PROJECT_EVIDENCE.md | Raw Pass A evidence extraction log containing un-summarized facts from 1,157 files. |
| PROJECT_MANIFEST.md | Phase 0 project inventory manifest detailing directory file counts and schema tables. |
| READINESS_SCORE.md | Final Repository Evaluation Report assigning Project Hermit a score of 96/100 (A+). |
cd project-hermit-git/v0.1.9
python3 -m venv venv
source venv/bin/activate
pip install google-genai psutil
# Export your Gemini API key
export GEMINI_API_KEY="your-actual-api-key"# Run structural host verification test
python3 orchestrator.py --mode shadow_test
# Run main integration test suite (17/17 passing)
python3 test_hermit.pypython3 hermit_daemon.pypython3 monitor_evolution.pyThis project is licensed under the Apache License 2.0 - see the LICENSE file for details.