Imagine pushing a quick update to an online store at 2 AM, going to sleep, and waking up to find out a tiny bug crashed the checkout page for every single customer. Right now, when a live website breaks, monitoring tools just send an alert and wait leaving the site broken for hours until a tired developer wakes up, hunts through error logs, writes a fix, tests it, and redeploys.
We asked: why does a website have to stay broken while waiting for a human?
We built WatchDog to give web apps an immune system. Instead of just reporting crashes, WatchDog catches an error the millisecond it happens, safely tests an AI written repair in a private sandbox, and swaps the fixed code into the live site in about two seconds before users even realize something went wrong.
What it does
WatchDog wraps around a live web application (demonstrated with AETHER, a multi-file e-commerce storefront) and runs a four-stage autonomous recovery pipeline:
- Real-Time Crash Interception: WatchDog supervises the live server process and continuously monitors its error stream. The instant an unhandled exception occurs, it parses the stack trace across multiple files (
app.pyandpricing_engine.py) to pinpoint the exact failing file, line number, and source context. - AI Patch & Regression Test Synthesis: WatchDog sends the crash context to Gemini, generating two structured artifacts: a complete, repaired replacement module and a brand-new
pytestregression test specifically targeting the failure path. - AST Security Firewall & Isolated Sandbox Verification: Before a single line of AI-generated code can execute, WatchDog runs a static Abstract Syntax Tree (AST) security audit to block dangerous module imports or shell commands (
os.system,subprocess,eval,exec). Approved candidates are then copied into a disposable temporary directory where the fullpytestsuite runs in isolation. - Atomic Hot-Swap & Immune Memory: Once all tests pass, WatchDog backs up the previous file, permanently appends the new regression test to the test suite (growing its "immune memory" after every incident), records a timestamped Git audit commit, and seamlessly reloads the live worker—cutting Mean Time to Recovery ($\text{MTTR}$) from minutes or hours down to \text{ seconds}$:
$$\text{MTTR}{\text{WatchDog}} = t{\text{intercept}} + t_{\text{synthesize}} + t_{\text{sandbox}} + t_{\text{swap}} \approx 20\text{s}$$
How we built it
- Supervisor & Control Plane (
orchestrator/): Built with Python, FastAPI, and Uvicorn to manage the supervised storefront subprocess (target_app/) asynchronously and stream real-time telemetry events over WebSockets. - Structured AI Synthesis (
patcher.py): Integrated the Google GenAI SDK (gemini-3.8-flash) with strict Pydantic JSON schemas and AST module completeness checks so responses are guaranteed to be valid, runnable Python modules paired with standalone regression tests. - Security & Verification Engine (
sandbox.py&deployer.py): Used Python's built-inastmodule for static code gating,tempfile+pytestfor isolated test execution, and automatedgitcommits for full auditability and one-click rollback. - Live Telemetry Dashboard (
dashboard/): Crafted a responsive, Apple-inspired control interface using HTML, Tailwind CSS, and vanilla JavaScript featuring an interactive chaos fault-injector and a simulated rogue-patch firewall audit.
Challenges we faced
- Preventing Partial-File Overwrites: Early iterations occasionally returned code snippets instead of complete modules, which would break imports on hot-swap. We solved this by enforcing strict JSON output schemas alongside an AST function-signature validator that rejects incomplete files before deployment.
- Ensuring AI Safety Without Trusting Blindly: Allowing an LLM to modify live server code introduces obvious security risks. Building the pre-execution AST firewall and isolated
pytestsandbox ensured that malformed or malicious candidate patches are caught and rejected without ever touching the running application. - Multi-File Stack Trace Resolution: Real production bugs rarely happen in the HTTP route handler—they happen in downstream business logic. Configuring the trace parser to walk the stack to the innermost application frame allowed WatchDog to diagnose and patch
pricing_engine.pyeven when crashes were triggered throughapp.py.
What we learned
Autonomous AI systems become genuinely dependable when paired with deterministic software engineering guardrails. Combining LLM reasoning with static AST analysis, isolated automated testing, and atomic Git-backed deployments turns AI from a passive coding assistant into a safe, self-healing runtime operator.
What's next for WatchDog
- Multi-Language Runtime Support: Extending the supervisor and AST security gates to Node.js/TypeScript and Go services.
- Canary Traffic Splitting: Gradually routing $5\% \rightarrow 50\% \rightarrow 100\%$ of live requests to newly patched workers while monitoring latency and error rates.
- Pull Request Automation: Automatically opening a reviewed GitHub Pull Request with the verified diff, root-cause diagnosis, and new regression test after every live hot-swap.
Built With
- ast
- fastapi
- gemini
- git
- google-gemini
- html5
- javascript
- pydantic
- pytest
- python
- tailwindcss
- uvicorn
- websockets