In legacy or fast-moving codebases, production logs are often the most honest documentation you have. When an application crashes at 2:00 AM with zero unit test coverage, developers typically follow the same manual routine: read the stack trace, locate the failing method, write a test to reproduce the crash, patch the edge case, and verify the build.
I wanted to see if I could automate that entire loop—starting with zero unit tests and using only runtime log files as the source of truth—while running the AI model 100% locally on an 8GB NVIDIA Jetson Orin Nano.
The result is split across two open-source repositories:
- The Target Application: springboot-calculator-seed — A deliberately unhardened Spring Boot REST API with zero unit tests.
- The Autonomous Repair Control Plane: defect-repair-agent — A Python orchestrator that parses logs, slices Java ASTs, generates JUnit 5 tests and patches via Ollama (
qwen2.5-coder:3b), and verifies fixes with Maven.
Here is how the system works, how it turns raw stack traces into dynamic regression tests, and what it took to make a 3-billion-parameter edge model reliable.
1. The Starting Point: Zero Tests, Real Runtime Crashes
To "eat our own dog food," I built springboot-calculator-seed with four atomic service methods (add, subtract, multiply, divide) accepting generic Java Number wrapper objects—and intentionally omitted all input validation and unit tests.
Because the methods were unhardened, sending malformed or edge-case HTTP requests immediately produced genuine production stack traces in logs/app.log:
POST /api/calc/dividewith{"a": 10, "b": 0}threwjava.lang.ArithmeticException: / by zero.POST /api/calc/addwith{"a": 10}(leavingbasnull) threwjava.lang.NullPointerException.
At this stage, the log file was the only signal describing what was broken and how the application was actually failing.
2. The Split-Node Architecture: Edge AI + Workstation Build
Running an LLM, a Python orchestrator, and a Java/Maven JVM build simultaneously on an 8GB Jetson Orin Nano quickly exhausts unified RAM. To keep inference fast and memory flat, I split the pipeline across two machines on my local network:
┌──────────────────────────────────────────────┐ LAN (HTTP) ┌────────────────────────────────┐ │ 64GB Windows Workstation │ ───────────────► │ NVIDIA Jetson Orin Nano │ │ (defect-repair-agent Control Plane) │ │ (8GB Unified RAM - Headless) │ │ │ │ │ │ 1. log_parser.py -> Extract stack frame │ │ • Ubuntu multi-user.target │ │ 2. java_slicer.py -> Slice atomic method │ │ • Ollama API (:11434) │ │ 3. jetson_agent.py -> Enforce guardrails │ ◄─────────────── │ • qwen2.5-coder:3b │ │ 4. verifier.py -> Run mvnw.cmd test │ Test & Patch │ (num_ctx: 4096) │ └──────────────────────────────────────────────┘ └────────────────────────────────┘
- 8GB Jetson Orin Nano (Inference Appliance): Booted into headless mode (
multi-user.target) to free ~700 MB of GUI overhead, running Ollama withqwen2.5-coder:3b(~1.9 GB weights) and a strictnum_ctx: 4096cap. - 64GB Workstation (Control Plane & Build Runner): Executes defect-repair-agent, parses logs, slices Java source files, and runs
mvnw.cmd testlocally.
3. How Logs Drive Dynamic Unit Test Creation & Defect Repair
Instead of asking an LLM to scan an entire repository blindly, the pipeline uses the production stack trace as a surgical scalpel across four stages:
Stage 1: Stack Trace Extraction (log_parser.py)
log_parser.py scans logs/app.log, deduplicates repeated exceptions, and extracts the exact application frame (com.aiops.governance.calculator.service.CalculatorService), method name, exception type, and crashing line number.
Stage 2: Atomic AST Slicing (java_slicer.py)
Small 3B models lose accuracy when fed hundreds of lines of boilerplate. Using tree-sitter-java, java_slicer.py parses the target .java file and slices out only the exact method containing the crashing line—keeping the prompt tiny, focused, and fast.
Stage 3: Test-First Synthesis (jetson_agent.py)
Using the stack trace and the sliced method, the Jetson generates artifacts in three distinct steps:
- Dynamic JUnit 5 Test Generation: Because the repository started with zero tests,
jetson_agent.pyfirst generates a brand-new JUnit 5 test class (CalculatorService_divideAutoTest.javaandCalculatorService_addAutoTest.java) targeting the exact failure inputs from the log. - Closed-Loop Bug Reproduction: Before touching any application code,
verifier.pyrunsmvnw.cmd test. The newly generated test must fail against the unpatched code—proving it genuinely reproduces the production crash. - Atomic Method Patching: Once reproduction is confirmed, the Jetson rewrites only the sliced method to handle the edge case (
IllegalArgumentExceptiononnullor zero divisor), andverifier.pypatches the exact line range while keeping a.baksafety backup.
Stage 4: Verification & Auto-Rollback (verifier.py)
verifier.py runs mvnw.cmd test again. If the patch compiles and passes both the new regression test and existing tests, the fix is kept. If anything fails, verifier.py feeds the Maven [ERROR] lines back to the Jetson for a self-correction retry—and automatically restores the .bak file if all attempts fail.
4. What Made a 3B Model Reliable: Deterministic Guardrails
One of the biggest lessons from building defect-repair-agent is that prompts alone aren't enough for small local models—Python guardrails are essential:
- Atomic Method Boundaries: Writing single-responsibility methods meant
qwen2.5-coder:3bonly ever had to reason about 6–10 lines of Java at a time. - Automatic Import Injection: When the 3B model occasionally omitted
import org.junit.jupiter.api.Test;, Python injected the standard JUnit 5 imports deterministically before compiling. - Contract Normalization: Rather than letting the generated test and generated fix disagree on which exception class to throw, Python normalized the expected contract (
IllegalArgumentException) across both artifacts. - Dynamic Exception Anchoring: Anchoring the prompt directly to the parsed stack trace (
NullPointerExceptionvs.ArithmeticException) prevented the model from hallucinating unrelated edge cases (like testing division by zero insideadd()).
5. Live Execution Proof
Running .venv\Scripts\python.exe verifier.py against logs/app.log automatically generated the missing JUnit 5 test suite and hardened both crashing methods:
========================================== [DEFECT] java.lang.ArithmeticException in com.aiops.governance.calculator.service.CalculatorService.divide() (Line 31) [1/4] Asking Jetson (qwen2.5-coder:3b) to generate JUnit 5 reproduction test... [2/4] Running mvnw test to verify bug reproduction... [OK] Bug reproduced! Test failed as expected. [3/4] Asking Jetson (qwen2.5-coder:3b) to generate method fix (Attempt 1/2)... [4/4] Running mvnw test to verify patched method (Attempt 1/2)... [SUCCESS] Fix verified! CalculatorService.java patched and CalculatorService_divideAutoTest.java passes.
What started as an untested Spring Boot API with runtime crashes in a log file ended with verified, passing JUnit 5 regression tests and hardened service methods—built autonomously on an 8GB edge GPU.
Explore the Code & What's Next
Both repositories are available on GitHub:
- Target Spring Boot App: github.com/htotapally/springboot-calculator-seed
- Python Repair Orchestrator: github.com/htotapally/defect-repair-agent
Next, I plan to expand the pipeline with real-time file tailing (log_watcher.py), automated Git branch/PR creation so human developers can review verified fixes with one click, and benchmarking qwen2.5-coder:7b on the Jetson as an automatic fallback tier for more complex service methods.




