Logo Graphenium

Graphenium

Cộng đồng
lambda-alpha-labs

Local pre-flight linter and architecture gate for AI agents. Uses tree-sitter, Stack Graphs, and Datalog to mechanically block structural drift, layering bypasses, and scope creep on virtual ASTs before code changes land.

Nhà phát hànhlambda-alpha-labs
Kho mãGraphenium
Ngôn ngữRust
Bản fork
4
Sao
25
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Graphenium cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    25 sao và 4 bản fork từ kho mã được liên kết.

Graphenium is a local, pre-flight linter and external architecture gate for AI coding agents.

It enforces structural compliance on AI assistants (such as Claude Code, Cursor, Aider, and Grok) by mechanically blocking code changes that violate your module boundaries, bypass your service layers, or introduce architectural drift.

Standard developer tools help agents find files. Graphenium prevents agents from creating architectural debt.

text
Without Graphenium (Vibe-Coding)        With Graphenium (Containment)
--------------------------------        -----------------------------
Agent edits files blindly               Agent validates design pre-flight
Agent ignores architectural layers      Graphenium blocks direct boundary violations
Constraints decay in long chats         External Datalog engine enforces strict rules
Reviewer hunts for bypassed layers      Reviewer gets deterministic scope-creep audits
CI checks only test passing             CI fails on architectural drift

Binary: gm
Schema: 0.2.0
Status: AST + Stack Graphs resolver stable, pre-flight policy engine stable, zero-drift delta gating stable, telemetry overlay experimental


Why Graphenium Exists: The Containment Gap

AI coding agents are highly efficient at local edits, but they suffer from structural blindness and context decay. Over a long chat session, an agent will lose track of your system instructions and optimize for the path of least resistance (e.g., writing a raw database call inside an HTTP controller to make a local test pass).

Relying on "soft" guardrails like CLAUDE.md or system prompts to maintain design patterns does not work. When context windows get full, these constraints are dropped.

Graphenium establishes external engineering governance. It operates outside the LLM context, treating architectural boundaries as a strict, compiled contract.


The Core Technical Lifecycle: Design-then-Verify

Graphenium enforces an explicit three-step compiler loop on the agent:

  1. Declare Intent (Pre-Flight Spec): Before editing any code, the agent registers its planned changes (classes, methods, and dependencies) in a virtual planning workspace.
  2. Transitive Policy Solving: Graphenium's engine runs a local Datalog solver to analyze the proposed virtual AST. If the design bypasses an intermediary architectural layer or uses banned symbols, Graphenium blocks the plan and provides structural feedback.
  3. Zero-Drift Delta Gating: Even without a .graphenium/policy.json file, Graphenium applies in-memory modularity analysis (ΔQ) and surprise edge profiling to reject plans that mathematically degrade community structure.
  4. Post-Facto Compliance Audit: After the agent writes the code, Graphenium parses the physical modifications, ensuring that the agent did not touch files outside the declared scope, introduce unplanned dependencies, or fail to implement its declared spec.

Quick Start

sh
# 1. Initialize workspace
# Generates .grapheniumignore with standard project defaults
gm init

# 2. Build local AST and Stack Graphs index (No LLM keys required)
gm run . --no-semantic --no-viz

# 3. Diagnose codebase health and import resolution
gm doctor --graph graphenium-out/graph.json --resolution

# 4. Analyze structural neighborhoods
gm query "authentication flow" --budget 2000

# 5. Start the MCP server for AI coding agents
gm serve --graph graphenium-out/graph.json --watch

Installation

sh
# From a local checkout
cargo install --locked --path .

# Or use the platform installer
curl -fsSL https://raw.githubusercontent.com/lambda-alpha-labs/Graphenium/main/install.sh | sh

Requires Rust 1.81 or later. Tree-sitter language grammars are compiled and bundled.


Core Technical Capabilities

1. AST-Proven Provenance (Facts vs. Heuristics)

Most AI developer tools use LLMs to guess how modules depend on each other, leading to hallucinations. Graphenium establishes an index of compiler-proven truth using Tree-sitter and Stack Graphs. Every relationship carries explicit provenance:

  • EXTRACTED (AST-Proven): Compiler-backed facts (imports, type inheritance, explicit call signatures).
  • INFERRED (Heuristics): Semantic leads that the agent is forced to verify.
  • AMBIGUOUS (Collisions): Identifier collisions that force the agent to halt and inspect source files directly.

2. Datalog-Powered Policy Solving

Static linters can check direct imports, but they are blind to multi-hop architectural bypasses. Graphenium solves this by compiling your codebase structure into logical facts and running an embedded Datalog inference engine (src/analyze/query.rs & stdlib.dl).

It uses first-order logic and fixed-point iteration to mathematically prove boundary violations over an infinite number of dependency hops.

3. Zero-Drift Delta Gating (Topological Entropy Guardrails)

Even without explicit policy rules, Graphenium applies in-memory modularity analysis to every planning workspace. The delta engine compares physical-only and virtual (plan-overlay) subgraphs, computing Louvain modularity deltas (ΔQ) and profiling surprise edges. Plans that degrade community structure or introduce architectural shortcuts (cross-community, peripheral→hub) are rejected automatically.

Available via evaluate_delta_gate (MCP), validate_plan (orchestrator), and gm check --delta --plan <id> (CLI).

4. Declarative Structural Governance

Enforce system design boundaries at commit-time or in CI. You declare rules in .graphenium/policy.json at the root of your repository:

json
{
  "rules": [
    {
      "type": "forbidden_dependency",
      "from_pattern": "src/controllers/**",
      "to_pattern": "src/db/**",
      "reason": "Controllers must use services, not access DB directly"
    },
    {
      "type": "strict_layering",
      "layers": [
        "src/serve/**",
        "src/analyze/**",
        "src/extract/**",
        "src/model/**"
      ],
      "reason": "Respect tiered architecture: serve -> analyze -> extract -> model"
    }
  ]
}

Use gm check --plan <id> --strict to run pre-flight policy checks and post-facto compliance audits in CI.

sh
# Topological delta gate (zero-config modularity protection)
gm check --delta --plan <id>

Technical Safeguards: Friction & Loop Mitigations

Traditional static analysis tools and natural-language guardrails (like CLAUDE.md or system prompts) fail when context windows fill up, leading to agent "vibe-coding" and rapid token consumption. Graphenium implements three structural safeguards to prevent developer friction and agent deadlock:

1. Mitigating the "Agent Deadlock" Loop (Pre-Flight Virtual ASTs)

  • The Friction: If an agent is blocked by a strict linter, it can fall into a token-wasting trial-and-error cycle (Propose → Blocked → Tweak → Blocked).
  • Graphenium's Mechanism: Graphenium prevents this loop by isolating change evaluations to a virtual planning workspace (create_planning_workspace). The agent registers its intent — classes, methods, and imports — before editing any physical files. Graphenium's pre-flight solver evaluates this virtual AST in milliseconds.
  • If a violation is found, the agent does not receive a vague natural-language rejection. It receives structured, compiler-proven topological path violations (e.g., demonstrating the exact transitively bypassed service layers). This allows the agent to correctly refactor its design plan in memory before wasting LLM tokens on physical file rewrites.

2. Solving "Policy Rot" (Zero-Config Topological Delta Gating)

  • The Friction: Declaring and maintaining strict architectural rules in a static JSON file (policy.json) introduces manual configuration overhead that fast-moving teams often neglect.
  • Graphenium's Mechanism: If no .graphenium/policy.json file is present in the repository, Graphenium dynamically falls back to Zero-Drift Delta Gating (gm check --delta). Instead of relying on static directory regexes, Graphenium uses its native Louvain community-detection engine to evaluate your codebase's current structural cohesion.
  • When an agent proposes a virtual plan, Graphenium calculates the modularity delta (ΔQ) and surprise coupling score of the new edges. It gracefully accepts your existing legacy complexity as the baseline, but mechanically blocks the agent from introducing new topological decay. No configuration files are required to protect your system's modularity.

3. Resolving Agent Integration Friction (Direct Skill-Folder Injection)

  • The Friction: Standard stateless MCP setups mean agents can easily bypass sequential "three-step" design loops (Declare → Solve → Post-audit), requiring manual developer mediation.
  • Graphenium's Mechanism: Graphenium circumvents this integration barrier by programmatically injecting its behavioral rules directly into the agentic runtime. During installation (install.sh or install.ps1), Graphenium copies its standard system skill instruction set (skills/graphenium/SKILL.md) directly into Claude Code's native skill directory (~/.claude/skills/graphenium/SKILL.md).
  • This ensures that the moment the assistant handshakes with Graphenium, it ingests explicit, structured operating parameters on how to manage virtual workspaces and resolve topological violations, without requiring the developer to configure system prompts manually.

Language Support

Graphenium supports mixed repositories with Rust, Python, Go, JavaScript, TypeScript, Java, C, C++, and C#.

C# projects receive build-boundary awareness through .sln and .csproj parsing, enabling Graphenium to model assemblies, namespaces, and project references as structural boundaries.


MCP Setup

Integrate Graphenium directly into your agent's execution loop. For tools that spawn MCP from the project directory, use the scripts/graphenium-mcp launcher (rebuilds only when the index is missing, keeping startup instantaneous).

sh
install -m 755 scripts/graphenium-mcp ~/.local/bin/graphenium-mcp

Claude Code

sh
claude mcp add graphenium --scope user -- gm serve --graph /path/to/graphenium-out/graph.json --watch

Grok

Configure in ~/.grok/config.toml:

toml
[mcp_servers.graphenium]
command = "/Users/<you>/.local/bin/graphenium-mcp"
args = []
enabled = true

Cursor

Add to ~/.cursor/mcp.json:

json
{
  "mcpServers": {
    "graphenium": {
      "command": "gm",
      "args": ["serve", "--graph", "/path/to/graphenium-out/graph.json", "--watch"]
    }
  }
}

Detailed Documentation Map

Root

DocumentPurpose
AI_SETUP.mdStep-by-step assistant setup playbook.
CONTRIBUTING.mdContributor guidelines and module reference.
CHANGELOG.mdRelease history and milestone summary.
SECURITY.mdLocal-first security guarantees and vulnerability reporting.
MANIFEST.mdComplete package manifest indexing all documentation.

Core Documentation (docs/)

DocumentPurpose
docs/GETTING_STARTED.mdInstallation, initial codebase indexing, and MCP setup.
docs/AGENT_WORKFLOWS.mdContainment workflows: pre-flight, in-edit planning, and verification.
docs/CI_AND_GOVERNANCE.mdEnforcing architecture policies in CI pipelines.
docs/COMMAND_REFERENCE.mdComplete CLI syntax and configuration arguments.
docs/MCP_TOOLS.mdBehavior specifications for MCP clients.
docs/ARCHITECTURE.mdIndexing pipelines, C# project references, and Datalog evaluation.
docs/TRUST_MODEL.mdUnder-the-hood details of AST-proven vs heuristic confidence.
docs/BENCHMARKING.mdPerformance metrics: latency, token budgets, and scaling limits.
docs/COMPARISON.mdWhy Graphenium is distinct from grep, AST tools, and GraphRAG.
docs/POSITIONING.mdMarket positioning, target personas, and competitive differentiation.
docs/HARNESS_ADAPTER.mdEmbedding Graphenium's structural engine as a library.
docs/WORKED_EXAMPLES.mdCase studies proving containment on real repositories.
docs/GRAPH_REPORT.mdInterpreting the generated codebase audit report.
docs/DOCUMENTATION_MAP.mdFull documentation ecosystem overview.

Agent Integration

DocumentPurpose
skills/graphenium/SKILL.mdAgentic skill instructions and containment behavior rules.
contrib/harness-adapter/README.mdEmbedding Graphenium's engine inside AI coding harnesses.

Case Studies (worked/)

DocumentPurpose
worked/README.mdOverview of structural containment case studies.
worked/TEMPLATE.mdTemplate for documenting new codebase case studies.
worked/graphenium-self-analysis/README.mdGraphenium self-analysis: applying the containment engine to itself.
worked/graphenium-self-analysis/sample-queries.mdSample query output on Graphenium's own codebase.

Contact & Enterprise


License

MIT. See docs/LICENSE.md.

Cài đặt

TypingMind
{
  "mcpServers": {
    "graphenium": {
      "command": "gm",
      "args": [
        "serve",
        "--graph",
        "/absolute/path/to/graphenium-out/graph.json"
      ]
    }
  }
}

Dùng MCP Graphenium với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Graphenium, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Graphenium làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Graphenium.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "graphenium": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Graphenium, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Graphenium.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Graphenium giúp tôi làm việc này không?
Graphenium
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Graphenium.

Câu hỏi thường gặp

Máy chủ MCP Graphenium dùng để làm gì?

Graphenium là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Graphenium với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Graphenium với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Graphenium với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Graphenium, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Graphenium với TypingMind?

Graphenium hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Graphenium cung cấp những công cụ nào trong TypingMind?

Graphenium cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Graphenium không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Graphenium yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇