-
-
Centralized modernization hub tracking AST architecture discovery, historical blast radius, and 1,000-app enterprise fleet triage.
-
Interactive multi-tier AST dependency graph mapping controllers, services, and call flows with real-time blast impact tracing.
-
Topological 4-wave refactoring simulator with side-by-side Grep vs. AST precision analysis and zero-downtime dual-write previews.
-
Audits live Git WIP diffs against the AST call graph to flag outdated callers, verify invariants, and generate seamless handover patches.
-
One-click repository ingestion supporting public Git URLs and local ZIP archives with automated AST extraction and Git history mining.
Inspiration
Every software engineer knows the silent tax of developer shift transitions and enterprise legacy systems: the incomplete handover crisis.
In fast-moving engineering organizations spanning multiple shifts, time zones, or remote sprints, over 40% of maintenance engineering hours are burned reconstructing partially implemented features. A developer begins refactoring a critical domain signature across 18 call sites, reaches site 12, hits the end of their shift, commits an unmerged WIP branch or leaves a local stash, and clocks off. The incoming engineer is handed a wall of raw git diff text, forced to guess what was finished, what invariants were violated, and which downstream services are silently calling an outdated contract.
At the same time, legacy migrations and cloud modernizations face the homonym false alarm trap. Traditional search utilities like grep, regex linters, or naive code search fail on dynamic aliases, destructured parameters, and comment homonyms. Meanwhile, generic LLM "chat with your repo" wrappers invent hallucinated file paths, hallucinate non-existent functions, and lack compiler-level grounding.
We were inspired by a fundamental thesis:
Source code is not just a collection of text tokens for an LLM prompt—it is an evolving, multidimensional mathematical dataset.
By marrying compiler-grade abstract syntax trees (Tree-Sitter), temporal Git transaction archaeology, Daikon-style dynamic and statistical invariant mining, and peer-reviewed systematic edit inference (LASE, Getafix, Refazer), we set out to build a platform that turns codebase comprehension, shift continuity, and cloud migration into a verifiable, deterministic science.
What it does
CodeArchaeologist Studio is a compiler-grade software archaeology and live shift handover continuation platform. It replaces speculative guessing with compiler-verified evidence and actionable patches.
1. 🔄 Live Shift Handover & Broken Contract Auditor
Hooks directly into the local repository's live Git state (git diff HEAD, git diff --cached, git stash show -p, or branch diff). It extracts changed symbols and modified signatures, traverses the Tree-Sitter AST call multigraph, and flags every caller across the repository that still invokes the obsolete contract. It then automatically synthesizes executable unified diff patches (git apply-ready) for every missing site.
2. 🛡️ Daikon-Style Mined Invariant Shield
Learns implicit repository invariants from type definitions, enum bounds, test assertions, and historical commit transactions (e.g., "In 95%+ of historical commits, updating PaymentEntity requires updating TaxLedger"). If an active WIP branch breaks an established architectural invariant, it alerts the incoming engineer immediately.
3. 🧬 SystemDNA: Migration Plan Preview
Provides an architectural preview of complex refactoring and cloud migration workflows before applying destructive changes. Using Kahn’s topological sort, it sequences migrations into 4 deterministic waves (DB & Models → Domain Services → API Ingress → Clients) and generates zero-downtime dual-write SQL triggers and shadow columns (ext_customer_id).
4. 🔍 Measured AST vs. Grep Precision Matrix
Runs an empirical side-by-side accuracy evaluation on the actual codebase. Naive text grep matches 47 instances (38.3% precision due to string literals, comments, and third-party homonyms), whereas our Tree-Sitter AST resolver isolates the true 18 invocation sites with 85.7% to 100% measured empirical precision—with zero synthetic floor padding.
5. 🛡️ Algorithmic Chesterton's Fence & Knowledge-Loss Map
Quantifies the hidden refactoring danger of any file before an engineer touches it: $$\text{FenceScore}(f) = 0.35 \cdot \text{AuthorLoss}(f) + 0.25 \cdot \text{CouplingRisk}(f) + 0.20 \cdot \text{AgeWeight}(f) + 0.20 \cdot \text{TestDeficit}(f)$$ It flags "orphan modules"—critical files where 100% of the historical authors have left the organization.
6. 📊 Multi-Repository Blast Radius Evaluation
Evaluates blast radius change impact on labeled multi-file commits ($\ge 2$ files changed together) across 3 distinct production repositories (TypeScript/Node, Python/FastAPI+React, and JavaScript/React+Node), scoring an authentic Macro Precision of 70.8%, Macro Recall of 91.7%, and Macro F1 of 0.799.
7. 🤖 Grounded Evidence AI (Fact-Checked Citations)
An intelligent chat interface backed by Hybrid Reciprocal Rank Fusion (Dense Vector + BM25). Every cited file path, line coordinate, symbol reference, and commit hash is verified against the AST database before being rendered. If evidence is missing, it returns an explicit safe fallback rather than hallucinating.
How we built it
We designed CodeArchaeologist Studio as an integrated 8-phase compiler and data science pipeline:
- Phase 1: Ingestion & Line Normalization: Safe Git cloning, ZIP archive extraction with Zip Slip defense, and unified LF normalization.
- Phase 2: Compiler-Grade AST Parser: Native C ABI Tree-Sitter (
tree-sitter==0.25.2) parsers for TypeScript, JavaScript, TSX, Java, Go, and Python. - Phase 3: Multigraph Topology Engine: NetworkX directed multigraph mapping structural relationships:
$$\mathcal{G} = (\mathcal{V},\, \mathcal{E},\, \tau_V,\, \tau_E)$$
where $\mathcal{V}$ represents AST components and $\mathcal{E}$ represents semantic edges (
IMPORTS,CALLS,EXTENDS,IMPLEMENTS). - Phase 4: Git Transaction Archaeology: Temporal commit log analysis, developer churn entropy, and author departure calculations.
- Phase 5: Knowledge RAG & Grounding Verifier: Hybrid Reciprocal Rank Fusion (RRF): $$\text{RRF}(d) = \sum_{m \in {\text{Dense},\, \text{BM25}}} \frac{1}{k + \text{rank}_m(d)}, \quad k = 60$$ backed by an AST Grounding Verifier that fact-checks citations against disk before display.
- Phase 6: Calibrated Blast Radius Model: Hybrid change impact combining BFS reachability with Jaccard commit co-change: $$J(u, v) = \frac{|\mathcal{C}(u) \cap \mathcal{C}(v)|}{|\mathcal{C}(u) \cup \mathcal{C}(v)|}$$ $$\text{RiskScore}(u, v) = w_1 \cdot \frac{1}{\text{dist}(u, v)} + w_2 \cdot J(u, v) + w_3 \cdot \frac{\text{LOC}(v)}{\sum_{k \in \mathcal{V}} \text{LOC}(k)}$$
- Phase 7: Scientific Evaluation Suite: Reproducible benchmarks (HalfDone-Bench + Multi-Repo Benchmark) computing un-floored precision, recall, and F1.
- Phase 8: Modernization & Handover Engine: SystemDNA 4-wave refactoring previews and Live Git Shift Handover patch synthesis.
Tech Stack:
- Backend: Python 3.11+, FastAPI, Uvicorn, NetworkX, GitPython, SQLite (WAL mode), and FastMCP (Model Context Protocol).
- Frontend Studio: React 18, TypeScript, Vite, Tailwind CSS, Lucide icons, D3-powered topology visualization.
Challenges we ran into
Tree-Sitter C ABI Memory Hazards on Windows: During native AST parsing of deep React TSX component hierarchies on Windows Python 3.13, cyclic garbage collection caused native memory access violations (
0xC0000005). We traced this to struct offset mismatches betweentree-sitter 0.26.0andtree-sitter-typescript 0.23.2. We resolved this by standardizing ontree-sitter==0.25.2, which maintains strict C ABI 14 and 15 backward compatibility across all language grammars.Re-entrant Lock Deadlocks in Asynchronous Pipelines: When ingesting complex codebases, background file analyzers occasionally deadlocked. We tracked this down to a non-reentrant standard
threading.Lock()being invoked recursively during deep import alias resolution. Upgrading the synchronizer tothreading.RLock()permanently eliminated lock starvation.Inferring Intent from Partial Diffs: A unified diff contains line changes, not programmer intent. To generalize developer transformations from an uncommitted WIP diff (e.g., distinguishing a localized one-off edit from an incomplete systematic refactoring), we implemented anti-unification patterns inspired by LASE and Getafix, comparing AST subtree diffs to extract parameterizable rewrite templates.
Eliminating Fictitious Score Floors: Many developer tools hide analysis uncertainty behind synthetic minimum scores or marketing claims of "100% precision". We completely eliminated all artificial score floors. If an AST traversal identifies potential callers that a developer chose not to touch, precision drops honestly to 50% or 62.5%. Defensible data science builds real credibility.
Accomplishments that we're proud of
- Live Handover on Real Git Data: Successfully inspecting unstaged working trees, staged diffs, and stash objects, passing changed symbols through the AST call graph, and flagging outdated callers with generated unified diff patches.
- Multi-Repository Empirical Benchmarks: Evaluating our blast radius engine against 12 historical multi-file commits across 3 independent repositories with a verified Macro Precision of 70.8%, Recall of 91.7%, and F1 of 0.799.
- 100% Test Suite Coverage: Passing 50 out of 50 test cases (
pytest tests -vin ~32s) covering Tree-Sitter parsing, Git handover diff auditing, Chesterton's Fence risk, and RAG grounding verification. - FastMCP Protocol Server: Complete Model Context Protocol server exposing
get_shift_handover,calculate_blast_radius,get_chesterton_fence_score, andmine_safety_invariantsdirectly to IDE agents like Cursor and Claude Desktop. - Responsive Zero-Clip UI: Engineered an adaptive navigation header that guarantees all 8 studio modules render cleanly without clipping or overflow at 90%, 100%, and 125% zoom levels.
What we learned
- ASTs beat regex by orders of magnitude: Regex cannot differentiate between a variable, a function definition, an import alias, and a comment string. Compiler-grade AST parsing with scope tracking is mandatory for reliable software analysis.
- The power of commit co-change graphs: Combining structural AST reachability with historical Git commit co-change patterns produces far more accurate blast radius predictions than static code analysis alone. Software is socio-technical; how humans modify files together over years reveals couplings that no import statement shows.
- Honesty creates credibility: In AI and data science tooling, eliminating "zero hallucination" hyperbole and reporting real measured false positives (38.3% grep vs. 85.7% AST) makes a product exponentially more trustworthy to senior engineers and enterprise architects.
What's next for Code Archaeologist
- IDE Companion Extension: Packaging CodeArchaeologist as a native VS Code and JetBrains extension that runs real-time contract audits in the developer's status bar as they code.
- Automated CI/CD Handover Bot: A GitHub Action that runs upon opening a PR labeled
WIP, automatically generating the 3-column Shift Handover briefing and flagging unmigrated call sites directly in PR review comments. - Cross-Repo Semantic Call Graphs: Expanding Tree-Sitter AST resolution across repository boundaries using SCIP/LSIF indexing for multi-repo microservice fleets.
- Active Invariant Enforcement: Integrating pre-commit hooks that enforce mined invariants, preventing commits that introduce statistical anomalies into the codebase.