DEV Community

Cover image for Inheritance Engine: resurrecting abandoned code with a local Gemma team, where the original gets a vote
Shailesh Vats
Shailesh Vats

Posted on Edited on

Inheritance Engine: resurrecting abandoned code with a local Gemma team, where the original gets a vote

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

On October 31, a Gemma model running on my laptop proposed a fix for a Python library last touched in 2014. A second Gemma agent, the Reviewer, approved it. All 126 of the project's existing tests passed.

The fix was still wrong. Behaviour probes compared the original author's code under Python 3.9 with the patched code under 3.12 and reported changed behaviour. The engine reverted the patch.

Abandoned code isn't necessarily dead code. Its author has moved on, but their intent survives in how the software behaves: the ghost that still gets a vote on what "restored" means. The Inheritance Record keeps the project's history, decisions, evidence and lineage, a little like an ofrenda.

What I Built

Inheritance Engine is a local workbench for inheriting software whose creator has moved on. The code is on GitHub, source-available under PolyForm Noncommercial 1.0.0, not an OSI-approved open-source licence.

  • Hunt: find candidates on GitHub, and optionally the web, with evidence instead of a score.
  • Inherit: the original stays a read-only clone at a recorded commit; work happens in a separate successor with pushing disabled.
  • Investigate: the Rust engine maps the code deterministically, then a team of Gemma agents (Lead, Historian, Restorer, Reviewer, Tester) works out what it was for. Every line they cite is re-read from disk.
  • Restore and verify: the agents propose and review patches; the engine tests and probes them in a restricted Docker sandbox and reverts what doesn't hold up.
  • Preserve: commit an INHERITANCE.md to the successor and export a versioned Inheritance Record: who wrote the code, what changed, and how each change was proven.

fn.py under investigation by the local Gemma agents, original preserved read-only

Demo

Demo video: real app footage

â–¶ Watch the 5-minute demo (MP4, with a synthetic-voice narration). Real app footage, driven by a script in headless Chrome. Corner badges label live, recorded, replayed, screenshot and fast-forwarded footage. Recorded October 31, with the Temporal, memory and CI part added November 1. How it was recorded.

The Catch

The demo inherits kachayev/fn.py, "Functional programming in Python" (Apache-2.0, about 3.4k stars, last commit October 2014). On Python 3.12 its tests can't even start: ImportError: cannot import name 'Iterable' from 'collections'.

  1. Gemma got the tests running. On October 28, two kept repairs took the suite from "can't start" to 126 passed. The second, commit cd83239, also passed three behaviour probes, but all three used plain positional functions.
  2. Neither covered variadic @curried. A manual check comparing the original on 3.9 with the successor on 3.12 showed different behaviour for functions with *args and **kwargs. Reading the diff, the likely cause was cd83239 counting signature(f).parameters, which includes them. I reopened the issue with that finding.
  3. The reference was already set. During investigation, the decay scan picked Python 3.9, the newest runtime fn.py's own code still works on, for running the original.
  4. Gemma proposed a fix, and Gemma approved it. After the reopening, two attempts were rejected on October 28 and three more on October 31. In a sixth attempt, also on October 31, the Restorer replaced cd83239's signature(f) with getfullargspec(f), without importing it, and counted arguments with f.prflags. That attribute doesn't exist. The Reviewer approved: "root cause addressed: yes, regression risk: low".
  5. The tests passed anyway. All 126 passed before the patch and all 126 after, both on Python 3.12. None of them exercises variadic @curried.
  6. The probes raised a warning, not a controlled diagnosis. The Tester wrote three: the first reproduces my note; the others test plain and default arguments, and a *args/**kwargs signature. Run on the original under 3.9 and the successor under 3.12, all three reported "changed". On the first, the original printed (1, 2), then raised TypeError; the successor raised NameError on all three. Reading the diff, that NameError comes from the missing import. There was no same-runtime control.
  7. The engine reverted it and kept the attempt, the approving review and the probe result in the record. fn.py stays restoring, not verified.

Replay: Reviewer approval, 126 tests passing before and after, and the probe result that reverted the patch

During development, a different fix used inspect.signature(f).parameters but left spec.args below it. All 126 tests passed, yet calling the decorator by hand raised AttributeError. That is why behaviour probes exist. The cd83239 case is why a person's finding can reopen an issue and outrank green tests.

You can reproduce the catch without a model. A replay reuses the recorded patch, Reviewer verdict and probe code; it regenerates no model decision. Everything else runs live: clone, Docker tests, probes, decision, revert and a fresh Inheritance Record. You need Rust, Git and Docker, and no GPU:

git clone https://github.com/shaileshvats/inheritance-engine && cd inheritance-engine
cargo run --release
# then open http://127.0.0.1:7878 → "Replay a recorded catch" → Run this replay
Enter fullscreen mode Exit fullscreen mode

The first build compiles from source in about 13 minutes on my 16 GB laptop. Subsequent laptop replay jobs took 9–80 seconds across five runs; a fresh-clone check took 61 seconds end to end. The GitHub Actions replay step took about 8 seconds on its runner. It runs on every push, after earlier steps build the engine and pull images, with no model or secrets, and fails unless the probe still catches the patch.

How I Built It

The model proposes; the engine verifies. The trusted part is one Rust binary (axum, SQLite, tokio). It never executes inherited code itself. Docker is the UI's default and recommended mode; the API requires an explicit choice. There, tests and probes run with a read-only root filesystem, all capabilities dropped, memory, CPU and process limits, and no network; installing dependencies is the one networked step. No model ever chooses a shell command, edits are exact and atomic inside the successor, and a "verified" claim without a real citation is downgraded. In the recorded investigation, 21 of 22 citations checked out. 61 Rust tests cover these rules; the Mastra and Temporal companions have 26 and 11.

Gemma 4 E4B: every agent, on my laptop

Every agent role, the Hunter included, runs on Gemma 4 E4B in LM Studio, with JSON-schema constrained output. Inheriting someone's code shouldn't mean uploading it: in the default local_only mode the engine refuses to send repository content to non-loopback model endpoints. With open weights, the model named in each record stays on my disk even if an API is retired. Inheritance Engine uses no paid API, subscription or hosting. Gemma wrote correct fixes and caught a real bug as Reviewer. It also wrote plausible wrong ones, which is why it never has the last word.

Mastra: issue triage and the Lead

A Mastra workflow, triage-upstream-issues, reads the original's open issues (24 for fn.py) and has Gemma compare each with the successor's changes. "Addressed" only survives if it cites a repair or commit that exists. In the first run it marked #91, the Iterable ImportError, as addressed and cited the exact repair and commit. On a re-run Gemma made the same claim without a citation, and the engine downgraded it to needs a human. The Lead Engineer chat also runs through Mastra with read-only tools; Mastra doesn't drive the Rust restoration pipeline.

Sentry: traces without the code

Both processes trace to Sentry: jobs as agent runs, Gemma calls with role, tokens and latency, sandbox runs as tool calls. One 8.78-minute investigation broke down into a 17.85 s plan step and a 3.39-minute Historian call. I checked the metadata-only rule three ways: auditing payloads before they were sent, querying Sentry's stored spans for content attributes (zero), and scanning all 26 audited payloads for lines of inherited source (none). That work exposed a real gap, Mastra's exporter bypassing the usual scrubbing hook, so the check now sits in the transport. It's evidence for those payloads, not a blanket guarantee.

Sentry: one Gemma call with tokens, latency and "No input for this span"

Temporal: surviving a worker crash

The optional Temporal companion chains a full run's engine jobs, 15–25 minutes of local Gemma work, into one durable workflow, inheritAndRestore. It waits out a model or Docker that is down, follows each job with heartbeats and gives a failed job one more run. I tested it on smokesignal, a second inherited library, by killing the worker with SIGKILL mid-restore. A new worker picked up the same engine job, and the workflow went on through web research, triage and the record: 19 minutes, 86 history events, no job started twice. The new worker also hit two heartbeat timeouts I haven't explained, so I doubled the timeout. It runs on a local dev server.

Temporal UI: the workflow completed after a worker kill

SerpApi: when GitHub search isn't enough

For "python event signal dispatch library", GitHub's search returned a JavaScript essay, a Flask template, a system-design primer and a PHP daemon. SerpApi added pallets-eco/blinker and nitely/python-signals, which actually do that, each re-fetched from the GitHub API so its evidence is real. Per-inheritance web research must cite real results, and for fn.py it found the documentation site. It isn't always relevant: on smokesignal, Gemma called Python's built-in signal module a "successor"; no cited source named the project, so the engine downgraded it to a mention. Only search text and public repository names are sent, on the free plan.

Tiger Data: a memory of every repair

The restoration memory stores every repair attempt (outcome, the engine's reason, review and probe verdict) in self-hosted Postgres on Tiger Data's open-source timescaledb-ha image, with pgvector, pgvectorscale's DiskANN index and a local nomic-embed-text model. It stays local because repair text can quote inherited source. The Lead searches it with hybrid keyword and vector ranking. Asked from smokesignal whether another project had fixed an import broken by modern Python, the Lead cited four real fn.py repairs, including the patch from the catch; re-running its memory query returns exactly those four. It also said none of fn.py's fixes for that issue were kept. That is wrong: one was (cd83239), and it ranked 15th.

The Lead citing another project's repairs from the memory: real ids, some wrong reasons

The PRD and code were AI-assisted: I worked with Claude throughout, and the runtime agents are Gemma.

Why Does Open Innovation Matter?

Because preservation can't depend on a service that might disappear. Gemma's weights live on my disk, so the record of which model wrote each patch outlives any API.

Because inheriting code shouldn't mean uploading it. In local_only mode the engine never sends repository code to a non-loopback model.

Because I could change the parts. When Ollama's registry wouldn't serve models to my old client, I pointed the same adapter at LM Studio. One environment variable can give the Reviewer a bigger Gemma. Running it costs ₹0: no paid API, subscription or hosting.

Limitations

  • The probes crossed Python versions. The original ran on 3.9 and the patched code on 3.12, so the probes could not isolate the patch as the cause.
  • Neither inherited repository is restored. fn.py's reopened *args issue is still open after six further Gemma attempts. smokesignal went from tests that couldn't start to 7 passing; its 28 remaining failures, from Python 3 changes to bound methods, are unsolved.
  • The decisive invariant came from me, not the probes. Probes only cover what the Tester thinks to check, and they have no same-runtime control.
  • Search relevance is uneven. The engine can check that a source exists, not that it's relevant.
  • Memory answers are leads, not evidence. The memory holds 26 attempts from two projects. Retrieval is checkable, but Gemma sometimes misstates what a precedent shows.
  • Narrow and not perfectly isolated. Verification covers public Python and Node.js repositories only. Docker is not a perfect security boundary, and optional native mode has little isolation.

Prize Categories

  • Gemma: every agent role runs locally on Gemma 4 E4B.
  • Mastra: upstream-issue triage that must cite real repairs or commits.
  • Sentry Agent Tracing: metadata-only agent traces, audited for leaked source code.
  • SerpApi: web search found libraries GitHub's own search missed.
  • Temporal: a durable inheritance workflow that survived a killed worker.
  • Tiger Data: self-hosted pgvectorscale memory of every repair attempt.

Software doesn't have to die with its creator. It can be inherited, understood, repaired, and given a future.

Top comments (0)