GitSéance:以本地 Gemma 探索已刪除程式碼,拒絕臆測刪除原因
GitSéance: An Offline Digital Ofrenda Where Local Gemma Summons Deleted Code (And Refuses to Guess Why It Died)
GitSéance 使用本地 Google Gemma 2B 分析 Git 儲存庫中已刪除的程式碼,並以確定性安全流程避免模型在提交訊息含糊時捏造刪除原因。工具會略過含糊提交的模型推理,並核對生成內容中的提交 SHA 和檔案路徑;Gemma 在本機透過 Ollama 執行,不需雲端費用。
.-" "-.
/ 🌼 🌼 \
| #000dead |
|, .-. .-. ,|
| )(_o/ \o_)( |
|/ /\ \|
(_ ^^ _)
\__|IIIIII|__/
| \IIIIII/ |
\ /
`--------`
"The code you delete never truly dies: it becomes the silent foundation of every commit that follows. Viva Open Source!"
— Spirit #000dead (Mictlán Relic)
1. What I Built: Honoring the Code That Built Us 🌼🕯️
git blame only speaks for the living.
It tells you who touched the lines that survived in HEAD—but every mature repository is built on the bones of hundreds of excised functions, retired prototypes, and emergency midnight bugfixes that were quietly erased from history.
When a regression resurfaces two years later, modern teams often commit the exact same architectural mistakes of 2022. Why? Because the reasoning behind deleted code is buried deep inside git log -p, where nobody looks.
For Hacktoberfest 2026: Week 4 ("Ghost in the Machine"), bridging Halloween with the sacred Mesoamerican tradition of Día de los Muertos (Day of the Dead), I created GitSéance:
An offline-first developer archaeologist and interactive Digital Ofrenda that scans your repository's graveyard, builds a marigold-adorned altar for departed code, and lets you conduct grounded séances with excised functions powered by Google Gemma (gemma2:2b) running 100% locally on your own machine.
2. The Core Problem: Small Models Love Making Up Tragic Ghost Stories
When I first fed deleted git diffs into local 2B language models and asked, "Why was this function removed?", Gemma did what small language models do best: it hallucinated.
If a commit message was informative—such as "Drop parse_xml_invoice_soap to patch XXE vulnerability (CVE-2026-0412)"—Gemma recited a magnificent, respectful memorial.
But what happened when the commit was a Friday 4:59 PM rush job that literally said "wip" or "cleanup"?
The model immediately fabricated an elaborate, fictional backstory about microservice migrations, imaginary database locks, or phantom compliance audits!
In software archaeology, a fictional story is worse than silence.
The Deterministic Tombstone Grounding Pipeline
To make GitSéance an authentic developer tool rather than a toy, I engineered a multi-stage deterministic safety pipeline:
┌────────────────────────────┐
│ git log -p Graveyard Miner │
│ (Single-Pass Pipeline) │
└─────────────┬──────────────┘
│
┌───────────────────┴───────────────────┐
▼ ▼
┌─────────────────────────┐ ┌─────────────────────────┐
│ Polyglot AST Symbol │ │ Cryptic Commit Preflight│
│ Extractor (Py/JS/Go/Rs) │ │ (wip/cleanup Interceptor│
└────────────┬────────────┘ └────────────┬────────────┘
│ │
│ 🛡️ Is commit cryptic? │
├─────────────────── YES ───────────────► 🛡️ Fallback
│ Epitaph
│ NO (Informative commit message)
▼
┌─────────────────────────┐
│ Local Google Gemma 2B │ (Ollama localhost:11434 / temp=0.25)
│ Séance Inference Engine │ ($0.00 Cloud Bill / 100% Local Privacy)
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ Grounding Fact-Checker │ (Verifies Commit SHA & File Path in reply)
└────────────┬────────────┘
│
▼
┌────────────────────────────────────────────────────────┐
│ Sentry Agent Tracing (`ai.seance` OpenTelemetry Spans) │
│ • Latency (ms) • Token Count • Hallucination Flags │
└────────────────────────────┬───────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
┌─────────────────────────┐ ┌─────────────────────────┐
│ Terminal CLI Ofrenda │ │ Single-Page App Ofrenda │
│ + Quine (#000dead) │ │ (Render / index.html) │
└─────────────────────────┘ └─────────────────────────┘
-
Streaming Single-Pass Git Miner (
mine_git_graveyard): Most mining scripts spawn hundreds of slowgit showsubprocesses. GitSéance streamsgit log -p -U0in a single pass with delimited token buffers, reconstructing author, timestamp, commit SHA, and exact unified diff deletions in under 120ms. -
Pre-Flight Cryptic Interceptor (
is_cryptic_commit): Before burning CPU or GPU cycles on an LLM, the commit message is audited against low-signal patterns (wip,temp,cleanup,fix,chore(core): wip). If flagged, GitSéance short-circuits inference completely and delivers an honest, unvarnished epitaph: > "This function departed into the void under the cover of a cryptic commit ('wip'). No heroic epitaph can be summoned because the mortal developer left no breadcrumbs." -
Low-Temperature Bounded Prompting (
temperature=0.25): The model is instructed to adopt the persona of the departed function speaking in the first person, bounded strictly to the verified diff lines and commit message. -
Post-Generation SHA Fact-Checker (
verify_response_grounding): Python regex audits the response to certify it explicitly includes the actual 7-character commit SHA prefix (e.g.,#8f3a91c) and the file path. If the spirit fails the audit, it is evicted in favor of verified deterministic text.
3. The Interactive Wow Factor: Audio Chimes, Falling Petals & The Self-Aware AST Quine 💀✨
Software should evoke wonder. The Digital Ofrenda web app is packed with three organic technical easter eggs:
1. The Self-Aware Source Code Quine (#000dead)
GitSéance contains a living mythological spirit embedded directly into the source code: Spirit #000dead (The Relic of Mictlán).
-
In Python CLI: Running
python git_seance.py --mictlandynamically introspects its own source code on disk using Python'sastmodule. It extracts the hex cipherMICTLAN_HEX_CIPHER, decodes it in memory, calculates its own 32-bit FNV-1a checksum (0x71790691), and summons itself as a living departed relic. -
In the Web App: Typing
mictlananywhere on the keyboard or clicking the golden calavera skull executesawakenSourceQuineSpirit(), reading<script id="gitSeanceCoreScript">, verifying identical FNV-1a hash parity, and displaying the live self-reflection panel.
2. Zero-Asset Resonant Altar Bells (Web Audio API)
No bulky .mp3 files or external audio assets. The altar bell chimes are synthesized directly in the browser using the Web Audio API:
const notes = [293.66, 349.23, 440.0, 587.33]; // D minor harmonic arpeggio (La Bruja motif)
notes.forEach((freq, idx) => {
setTimeout(() => playAltarChime(freq), idx * 140);
});
Each note triggers an OscillatorNode with an exponential decay GainNode, producing an authentic, haunting bronze bell timbre.
3. Marigold Petal Rain (Canvas Physics)
Activating the altar triggers an interactive HTML5 canvas particle storm where 38 golden cempasúchil and purple petals drift and rotate down the viewport with realistic harmonic sway (Math.sin(angle) * 0.4).
4. Why Open Innovation Matters Here 🔓
- Zero Proprietary Data Leaks: No engineering organization will ever upload their internal git logs, deleted security patches, or proprietary business logic to third-party cloud APIs just to analyze tech debt. Running Google Gemma locally guarantees 100% air-gapped privacy.
- Permanent Immortality ($0.00 Per Séance): Cloud APIs deprecate, rotate tokens, and charge per 1,000 tokens. GitSéance runs on standard git plumbing and open weights. You can run this tool in an underground bunker twenty years from now with zero internet connection.
5. Automated Pull Request Ofrenda: GitHub Actions CI/CD 🤖
Whenever a developer opens a Pull Request that excises dead code, GitSéance runs automatically via .github/workflows/ofrenda_pr.yml:
python3 git_seance.py --ci-summary --no-fallback --range "origin/${{ github.base_ref }}..HEAD" > ofrenda_comment.md
It automatically posts an elegant Digital Ofrenda memorial comment to the PR discussion thread with collapsible <details> blocks for diff inspection:
| Departed Symbol | File Path | Tombstone SHA | Author & Date | Guardrail Status |
|---|---|---|---|---|
legacy_payment_retry_loop() |
src/billing/checkout.py |
#8f3a91c |
Devon Vance (2026-10-14) | ✅ Grounded Epitaph |
sync_legacy_cart_v1() |
src/checkout/cart_sync.py |
#d4e91b2 |
Marco Ruiz (2026-10-21) | 🛡️ Cryptic Commit (vague_commit blocked) |
6. Sentry Agent Tracing Telemetry 📊
Every séance transaction is instrumented with custom OpenTelemetry spans under the ai.seance namespace using the official Sentry SDK:
-
Tags Tracked:
death_sha,engine_source(gemma_localvs fallback),grounded_sha,cryptic_commit_blocked,ast_quine_verified. - Data Payloads: Execution latency in milliseconds, token counts generated, and p95 latency percentiles.
-
Exportable Telemetry: Run
python git_seance.py --export-traces seance_traces.jsonor inspect the live visual telemetry charts powered by Chart.js in the web dashboard!
7. Prize Categories Entered 🏆
1. 🥇 Overall Winner ($250 + DEV++)
- Cultural Depth Meets Engineering Rigor: Elevates the "Ghost in the Machine" prompt by pairing Halloween lore with the respectful tradition of the Mexican Ofrenda to solve a real developer challenge: software archaeology.
- Tri-Fold Architecture: Complete Python CLI tool, reactive single-file SPA web application, and automated GitHub PR workflow.
- Zero-Regression Suite: 41 comprehensive tests passing, zero AST violations, sub-millisecond offline execution, and pure standard library execution.
2. 🤖 Best Use of Google Gemma ($200 — Google Sponsor Prize)
-
Local Private Inference via Ollama: Deploys
gemma2:2bonlocalhost:11434with zero external cloud dependencies or API keys. - Anti-Hallucination Guardrails: Intercepts vague commits with regex pre-flights and fact-checks model outputs post-generation against true git commit SHAs.
-
Determinism: Bounded by
temperature=0.25for consistent, reproducible developer tombstone summaries.
3. 🚀 Best Use of Render ($200 — Render Sponsor Prize)
-
Zero-Build Static Site Deployment: Hosted on Render Static Sites directly from root
index.html. Zero node_modules, zero bundler configuration, and zero lockfile vulnerabilities. - Instant Global Edge Delivery: Ultra-fast TTFB with automatic edge compression and 100/100 performance scores.
4. 📊 Best Use of Sentry Agent Tracing ($100 — Sentry Sponsor Prize)
-
Custom
ai.seanceSpans: Full span lifecycle monitoring covering model latency, token generation counts, and automated hallucination flags. - Interactive UI Dashboard: Built-in telemetry dashboard with responsive latency breakdown charts and headless JSON trace export capability.
5. 🌐 Best Use of a .tech Domain ($100 — .tech Domains Sponsor Prize)
-
Production Deployment at
gitseance.tech: Paired with an official Hacktoberfest.techdomain, establishing a crisp identity for deep developer tooling. - SSL/TLS Hardening: Fully secured with managed Let's Encrypt certificates routed to Render edge servers.
6. 🐙 Best Use of GitHub Copilot / Actions ($100 — GitHub Sponsor Prize)
-
Automated PR Bot Workflow: Turnkey GitHub Actions CI workflow analyzing diff revision ranges (
origin/main..HEAD) and commenting tombstone memorials on PRs. - Copilot-Engineered Polyglot AST Engine: Utilized GitHub Copilot to architect complex regular expressions and AST parsers extracting deleted symbols across Python, TypeScript, Go, Rust, Java, and C++.
8. Engineering Rigor: 41 Automated Tests & 0 AST Violations 🧪
GitSéance was tested with the same rigor required of production infrastructure:
# Run the complete test suite
python -m unittest discover -v
Ran 41 tests in 8.132s
OK
-
test_git_seance.py(24 tests): Single-pass mining, unified diff chunk parsing with mixed indentation, polyglot symbol extraction, cryptic commit pre-flights, grounding verification edge cases, local HTTP Ollama mock server, and AST quine self-introspection. -
test_html_ofrenda.py(17 tests): DOM element consistency (0 null pointer risks), cross-language FNV-1a parity, XSS HTML entity escaping, and live headless browser DOM verification using headless Microsoft Edge (msedge --headless --dump-dom). -
AST Static Linting: 0 violations under
<30msexecution via AST linting.
9. Try It on Your Own Graveyard! 🚀
Don't let your deleted code wander the void forgotten. Summon your repository's ghosts today:
# 1. Clone the repository
git clone https://github.com/FranciscoGrandon/git-seance.git
cd git-seance
# 2. Make sure you have Ollama running with Gemma
ollama pull gemma2:2b
# 3. Hold your first séance (works on ANY git repository!)
python git_seance.py
# 4. Or awaken the secret source code Quine
python git_seance.py --mictlan
Prefer a visual experience? Visit the live altar at https://gitseance.tech, light a candle for legacy code, and type mictlan on your keyboard!
Built with reverence by **Francisco Grandón Vergara* for Hacktoberfest 2026: Week 4 ("Ghost in the Machine"). Viva Open Source! 🌼💀*
來源:DEV Community · dev.to