This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built ๐ง ๐ป
Every competitive programmer and software engineer knows that sickening feeling in their stomach: you spend 40 minutes designing a graph algorithm, submit to the online judge, and immediately get hit with:
โ Wrong Answer on Test 23
You spend the next hour tearing your hair out, only to discover the culprit: you forgot 1LL during a multiplication, causing a silent 32-bit integer overflow. Or you forgot to call adj[i].clear() between multiple test cases.
The most painful part? You made this exact same mistake two weeks ago. And three weeks before that.
Human programmers don't fail randomlyโwe fail in our own consistent, idiosyncratic blind spots. Compilers verify types and syntax, but they have zero memory of your personal debugging history.
Introducing REVENANT ๐
REVENANT is an open-source error-memory daemon and CLI built specifically for competitive programmers (tailored for modern C++17). It transforms your machine into a personal memory bank that actively remembers how you fail.
Instead of running slow cloud LLMs after you get stuck, REVENANT introduces a Two-Path Architecture:
- โก The Hot Path (< 10ms Pre-Scan): Before your compiler (
g++) even runs, REVENANT instantly analyzes your source code against your personal "Graveyard" of past blunders. If it spots a signature pattern of a mistake that has haunted you before, it halts and warns you with spooky evidence before you waste a submission penalty. - ๐ง The Cold Path (Local Gemma 2 + MongoDB Vector Search): If your code fails a local test case (
WA,TLE,RTE), REVENANT automatically spins up Google's Gemma 2 (2B) offline via Ollama to perform a post-mortem, vectorizes the failure usingnomic-embed-text(768-dim embeddings), and indexes it in MongoDB Atlas Vector Search. - โณ Weakness Half-Life Decay: Sins you haven't committed in weeks gradually fade away into dormancy (half-life = 14 days), while recurrent blunders escalate into high-alert "Poltergeists".
Demo ๐ฌ
๐ป Pre-Compilation Haunting: REVENANT detects a 32-bit integer overflow before compilation, executes local test cases, and invokes local Gemma 2 for an automated root-cause diagnosis.
๐ The Graveyard: Active catalog of developer blind spots, showing occurrence counts, severity tiers, and exponentially decaying weakness scores.
๐ Cloud Graveyard Dashboard: Live web interface hosted on Render displaying real-time developer failure analytics and MongoDB Atlas sync status.
Quick Terminal Tour
# 1. Run local test cases with pre-compilation haunting
ghost run solution.cpp
# 2. Inspect your active Graveyard and current weakness scores
ghost graveyard
# 3. Commune with uncategorized failures: Gemma 2 synthesizes new Sin categories
ghost seance
# 4. Run the 100-run backtesting benchmark across historical test splits
ghost backtest
- ๐ Live Cloud Dashboard: https://revenant-wp4s.onrender.com/
- ๐ Live API Stream: https://revenant-wp4s.onrender.com/api/ghosts
- ๐ฉบ Health Check: https://revenant-wp4s.onrender.com/health
Code ๐ป
๐ป REVENANT: "Ghost in the Machine" Error-Memory Developer Tool
"Every mistake you make leaves a ghost behind. Ghosts linger, gain strength when repeated, fade when conquered, and haunt you before you run doomed code."
Built for DEV Open-Source AI Challenge: Week 4 (Theme: Ghost in the Machine) & Hacktoberfest 2026.
๐ฎ What is REVENANT?
Developers don't fail randomlyโwe fail systematically according to personal blind spots (32-bit integer overflows, unreset global vectors in test loops, 0-vs-1 indexing, negative modulo operations).
Linters are too generic, and running an LLM on every save or run is far too slow. REVENANT is a personalized error-memory tool that:
- Remembers how you personally fail by persisting failure snapshots into MongoDB Atlas.
- Warns you before you run doomed code via a <10ms Hot-Path Scanner (Zero AI latency on the hot path).
- Diagnoses failures using local Gemma via Ollama into strict JSON when tests fail.
- Summons Sรฉancesโฆ
The complete codebase is 100% open-source under the MIT license:
๐ GitHub Repository: https://github.com/the-curious-lad/revenant
Core Components
-
bin/ghost.jsโ Global CLI entry point (ghost run,ghost graveyard,ghost seance,ghost backtest). -
src/scanner/detectors.jsโ 16 canonical competitive programming sins with ReDoS-safe AST-like patterns and zero false alarms on passing code. -
src/ai/ollama.js&src/ai/diagnostician.jsโ Local Google Gemma 2 diagnostic engine with strict JSON schema validation. -
src/db/mongo.jsโ Official MongoDB Atlas client with native$vectorSearchand offline JSON fallback. -
src/eval/backtest.jsโ 100-run controlled benchmark evaluation engine. -
src/server.jsโ Express web server and REST API for cloud dashboard deployment on Render.
How I Built It ๐ ๏ธ
1. Offline AI: Local Google Gemma 2 via Ollama
Developers writing code under contest conditions or traveling often have zero internet access. We engineered REVENANT around Google's Gemma 2 (2B) running locally via Ollama:
- Zero API Latency: Local inference ensures no waiting for cloud API queues during tight practice sessions.
- Strict Schema Enforcement: When tests fail, REVENANT feeds compiler output and failed test diffs into Gemma 2 to produce clean, structured root-cause analyses and exact C++ diff recommendations.
-
Local Embeddings: We use
nomic-embed-textlocally to transform code contexts into 768-dimensional vectors without transmitting private code over the wire.
2. Semantic Memory: MongoDB Atlas Vector Search
When an unclassified or novel error occurs, REVENANT pushes the failure context and its 768-dim vector to MongoDB Atlas. Using Atlas's native $vectorSearch pipeline with cosine similarity:
- REVENANT identifies whether an uncategorized bug is semantically identical to a past failure (similarity โฅ 0.82).
- During
ghost seance, REVENANT clusters recurring uncategorized bugs and prompts Gemma 2 to invent and name entirely new Sin categories (e.g., "Modulo Subtraction Underflow").
3. Weakness Decay: The Ghost Half-Life Formula
A tool that nags you forever about a bug you fixed 6 months ago is annoying. REVENANT models memory using an exponential half-life decay formula:
Weakness(t) = Weaknessโ ร (0.5)^(ฮt / 14) + 1
- Every repeat mistake adds +1.0 weakness.
- Every 14 days of clean coding cuts weakness by 50%.
- Weakness below 0.2 enters Dormancy; weakness above 3.0 triggers Poltergeist priority in your terminal.
4. Zero False-Alarm Gate
To ensure REVENANT never slows down a programmer whose code is correct, we implemented a False-Alarm Verification Gate in src/scanner/validator.js. When testing against reference solutions from the famous Codeforces CP-31 Sheet (e.g., Helmets in Night, Connected Components), passing code triggers 0 false positives.
5. Cloud Graveyard on Render
While the CLI runs locally on your workstation to access g++ and local test files, REVENANT deploys a web service on Render via render.yaml. The Render service connects to MongoDB Atlas to render a real-time leaderboard of haunting sins and provides a public REST API for judges to inspect.
Benchmark & Empirical Verification ๐
๐ฌ Empirical Validation: Automated 100-run backtest benchmark simulating 70 historical training mistakes and 30 unseen evaluation problems from the Codeforces CP-31 sheet.
| Metric | Score | Significance |
|---|---|---|
| Precision | 100.0% | Every single pre-scan warning pointed to a genuine flaw. |
| Recall | 81.3% | Caught 13 out of 16 actual failure bugs before compilation. |
| False Alarm Rate | 0.0% | Passed 100% of verified clean solutions without interruption. |
| Overall Accuracy | 90.0% | Across 30 unseen test evaluation runs. |
| Pre-Scan Overhead | < 10ms | Imperceptible delay before compilation. |
Note on Language Extensibility: While REVENANT is currently optimized for competitive programming in modern C++17, its two-path scanning architecture can readily be extended to Python, Rust, and Go.
Why Does Open Innovation Matter? ๐
Why build this with open-source AI rather than a commercial cloud API?
- Protecting Contest Honor & Code Privacy: Competitive programming contests (ICPC, Codeforces, LeetCode) have strict honor codes against external API assistance. Sending source code to proprietary cloud servers risks violating contest rules or leaking solutions. Open weights running locally guarantee complete code privacy.
- Preserving Developer Flow State: Waiting 3 to 5 seconds for a commercial API on every compilation completely breaks developer focus. By pairing an instantaneous deterministic regex pre-scan (<10ms) with local Gemma 2 cold-path post-mortems, REVENANT never blocks your rhythm.
- True Reproducibility: Closed APIs change under the hood without notice. With open-weight models like Gemma 2:2b, your development tools behave predictably and remain reproducible forever.
The Spirit of It ๐ฏ๏ธ
Ghost in the Machine asks: what lingers inside our hardware when the monitors turn off?
When we spend hours debugging algorithms, our machines absorb our fatigue, our subconscious biases, and our recurring blind spots. The ghost haunting your terminal isn't some hostile AI entityโthe ghost is you.
It is the ghost of you at 3:00 AM submitting int instead of long long. It is the phantom of contest rating lost to a missing graph clear.
REVENANT captures those ghosts, catalogues them, and turns them into a watchful guardian that protects you from repeating your past mistakes.
Prize Categories ๐
We are entering REVENANT into the following tracks:
- Overall Challenge Winner / Ghost in the Machine Track: Directly embodies the theme by turning developer debugging trauma into an active, protective memory daemon.
- Google / Gemma Partner Track: Powered by local Gemma 2 (2B) via Ollama for offline test-failure diagnoses, structured diff recommendations, and Sin category synthesis.
-
MongoDB Atlas Partner Track: Leverages native MongoDB Atlas Vector Search (
$vectorSearch, 768-dim embeddings, cosine similarity) for semantic error deduplication and automated clustering. -
Render Partner Track: Cloud Graveyard Web Service and public REST API deployed automatically via
render.yamlon Render at https://revenant-wp4s.onrender.com/.
Acknowledgements & Tech Stack
- Google DeepMind for the Gemma 2 open-weight models
- MongoDB Atlas for managed cloud Vector Search
- Render for cloud hosting
- Ollama for local open-weight inference
- TLE Eliminators (CP-31 Sheet) for real-world competitive programming test problems
Huge thanks to DEV, Hacktoberfest, Google Gemma, MongoDB Atlas, and Render for this incredible challenge! Now I'm going to run a quick exorcism on my terminal and pray my 3:00 AM bugs don't come back to haunt me. Happy Hacktoberfest and Happy Halloween! ๐๐ป๐ฏ๏ธ




Top comments (0)