DEV Community

Cover image for REVENANT: The Error-Memory Daemon That Haunts Your Code Before You Compile ๐Ÿ‘ป
Akshat
Akshat

Posted on

REVENANT: The Error-Memory Daemon That Haunts Your Code Before You Compile ๐Ÿ‘ป

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission ๐Ÿ‘ป๐ŸŒผ

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:

  1. โšก 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.
  2. ๐ŸงŠ 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 using nomic-embed-text (768-dim embeddings), and indexes it in MongoDB Atlas Vector Search.
  3. โณ 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 ๐ŸŽฌ

REVENANT CLI Pre-Scan Warning and Gemma 2 Diagnosis

๐Ÿ‘ป 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.

REVENANT Graveyard Sin Roster

๐Ÿ“œ The Graveyard: Active catalog of developer blind spots, showing occurrence counts, severity tiers, and exponentially decaying weakness scores.

REVENANT Cloud Web Dashboard

๐ŸŒ 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
Enter fullscreen mode Exit fullscreen mode

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:

  1. Remembers how you personally fail by persisting failure snapshots into MongoDB Atlas.
  2. Warns you before you run doomed code via a <10ms Hot-Path Scanner (Zero AI latency on the hot path).
  3. Diagnoses failures using local Gemma via Ollama into strict JSON when tests fail.
  4. 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 $vectorSearch and 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-text locally 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 ๐Ÿ“Š

REVENANT 100-Run Backtest Benchmark Evaluation

๐Ÿ”ฌ 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?

  1. 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.
  2. 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.
  3. 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:

  1. Overall Challenge Winner / Ghost in the Machine Track: Directly embodies the theme by turning developer debugging trauma into an active, protective memory daemon.
  2. Google / Gemma Partner Track: Powered by local Gemma 2 (2B) via Ollama for offline test-failure diagnoses, structured diff recommendations, and Sin category synthesis.
  3. MongoDB Atlas Partner Track: Leverages native MongoDB Atlas Vector Search ($vectorSearch, 768-dim embeddings, cosine similarity) for semantic error deduplication and automated clustering.
  4. Render Partner Track: Cloud Graveyard Web Service and public REST API deployed automatically via render.yaml on 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)