AI coding assistants like Cursor, Claude Code, Copilot, and Devin are insanely good at writing syntax. But they suffer from a fundamental flaw: Contextual Amnesia.
An LLM refactoring an endpoint has no idea that a specific parameter was introduced 6 months ago to meet a performance SLA, or that modifying a function breaks an implicit co-change dependency with another module.
When team size grows or senior developers leave, this knowledge debt leads to silent architectural decay.
To solve this without sending your codebase or graph data to third-party cloud services, I built LORE—a local-first engine that constructs a 5-layer Knowledge Graph from your repository evidence to act as a semantic firewall during code modifications.
**What LORE Does (Detector & CI/CD Gatekeeper)
**LORE is an architectural regression detector and CI/CD gatekeeper. It intercepts code diffs (via CLI, pre-commit hooks, MCP, or SARIF output in CI/CD) and validates them against historical constraints mined from your repository.
The Knowledge Graph combines five analysis layers into a local SQLite database using sqlite-vec for C-accelerated offline vector embeddings:
-
L1 (Structural AST): Multi-language symbol extraction using
tree-sitterandlibcst(Python, Go, TypeScript/JS). -
L2 (Local Semantic Vector Store): Local embeddings generated for symbol intent and docstrings via
sqlite-vec. - L3 (Historical Co-Changes & Fragility): Mines historical Git commit co-occurrence patterns to detect coupled files and symbol fix-density.
- L4 (Decisional Links): Connects structural symbols to past PRs, commits, and Architectural Decision Records (ADRs).
5. L5 (Policy & Boundary Guard): Detects removed entry guards and comparison operator shifts (> weakening to >=).
Empirical Performance (Django & LangChain Benchmark)
To test detection accuracy without synthetic LLM data, I evaluated LORE over 199 real commits from the Git histories of Django (django/django) and LangChain (langchain-ai/langchain) using a strict Time-Split Protocol ($T_{\text{split}}$) to prevent data leakage:
| Metric | Performance | Impact |
| :--- | :---: | :--- |
| High-Signal Precision | 97.2% [85.8%–99.5%] | When LORE issues a critical alert, 97.2% of the time it is a true regression. |
| Clean PR False Positive Rate | 1.0% [0.2%–5.4%] | Near-zero alert fatigue on benign refactoring and documentation PRs. |
| Overall Noise Reduction | 88.7% Reduction | Precision-calibrated thresholds eliminate alert fatigue in production pipelines. |
Quick Start: Trying LORE in 60 Seconds
1. Install via PyPI
bash
pip install lore-kg
2. Initialize & Index Your Repository
Run the bootstrap helper inside your local project:
bash
lore init .
3. Audit Local Diffs or PR Commit Ranges
Run an architectural audit generating native SARIF 2.1.0 output for GitHub Code Scanning:
bash
lore gh-check --commit-range "origin/main...HEAD" --format sarif --fail-on critical
4. Connect to Cursor or Claude Desktop via MCP
LORE exposes a local Model Context Protocol (MCP) server so AI tools can query architectural rules before writing code:
bash
lore mcp
GitHub Action Integration
You can integrate LORE directly into your GitHub Actions workflow:
yaml
name: LORE Architectural Guard
on:
pull_request:
branches: [ main ]
jobs:
lore-guard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install lore-kg
- run: lore gh-check --commit-range "origin/main...HEAD" --format sarif --fail-on critical > lore-results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: lore-results.sarif
Open Source & Community
LORE is 100% open-source under the MIT License.
GitHub Repository: https://github.com/filippogabriele19/lore
PyPI Package: https://pypi.org/project/lore-kg/
I'd love to hear your thoughts, feedback, or ideas on AST-level co-change mining and local codebase governance!
Top comments (0)