Skip to main content
Glama

semver-gate

Python 3.10+ Rust: 2021 (Pure Safe) License: MIT Dependencies: Zero MCP: 8 Stdio Tools

Catch breaking Python AST shifts, PEP 562 lazy-import gaps, __slots__ mock breaks, C-ABI drops, and leaked .whl files before PyPI publish.

Minor Python releases often break callers silently through reordered arguments, removed __getattr__ loaders, missing py.typed markers, or leaked .env files inside wheels. semver-gate combines a zero-dependency Python AST and archive auditor with a #![forbid(unsafe_code)] Rust scanner (semver-gate-rs). It also includes a 7-Law Release FSM, a Classic TDD witness emitter, and an 8-tool Stdio MCP server.


Before and After

RAW DIFF (BLOCKED · SG_PARAM_REMOVED + SG_SLOTS_NO_DICT + SG_PEP561_MISSING):
- def fetch(url: str, timeout: int = 10) -> str  -->  def fetch(url: str) -> str
- class Client added __slots__ = ("timeout",) without "__dict__"
- wheel omits py.typed marker
VERIFIED RELEASE (PASS · knot="sg-..." · 7/7 Release FSM Laws):
- Added optional keyword-only parameters with defaults (SG_SAFE_ADDITION)
- Kept "__dict__" inside __slots__ or class-level patch parity
- Included py.typed and verified zero zip-slip or secret leaks

Related MCP server: diff-sentinel

Six Audited Contract Surfaces

#

Contract Surface

Detected Regressions

1

AST Signatures

Removed functions/methods, removed or reordered parameters, sync/async flips, default changes.

2

PEP 562 & __slots__

Removed __getattr__ lazy loaders, __slots__ without __dict__, broken mock.patch targets.

3

Exception MRO

Narrowed base classes on *Error and *Exception types.

4

Wheel & Sdist Security

Zip-slip ../ entries (CWE-22) and leaked .env, .bak, or key files (CWE-200).

5

PEP 561 & Packaging

Missing py.typed markers, requires-python bumps, and unrequested core dependency additions.

6

Rust / C-ABI

Removed pub extern "C" fn symbols and #[no_mangle] export drops.


Architecture

flowchart LR
    SRC["Base vs Target Python / Rust / Wheel"] --> AST["AST & In-Memory Archive Auditor"]
    SRC --> RUST["semver-gate-rs (Pure Safe Rust)"]
    AST --> FSM["7-Law Release FSM + SHA-256 Receipt"]
    RUST --> FSM
    FSM --> WIT["Classic TDD Pytest Witness Emitter"]

Installation

pip install "git+https://github.com/skupriienko/semver-gate.git"

For local development with the Pure Safe Rust scanner:

git clone https://github.com/skupriienko/semver-gate.git
cd semver-gate
cargo build --release --manifest-path rust/Cargo.toml
pip install -e ".[dev]"

Quickstart

from semver_gate import audit_source_pair, evaluate_release_fsm, generate_tdd_witness

base = {"pkg/api.py": "def fetch(url: str, timeout: int = 10) -> str:\n    return url\n"}
target = {"pkg/api.py": "def fetch(url: str) -> str:\n    return url\n"}

report = audit_source_pair(base, target)
fsm = evaluate_release_fsm(report, version_bump="minor")
print("Passed:", report.passed, "FSM:", fsm["verdict"])
print(generate_tdd_witness(report))

CLI Commands

semver-gate diff ./base_src ./target_src --json
semver-gate wheel ./dist/mypkg-1.0.0-py3-none-any.whl --json
semver-gate abi ./rust/src/lib.rs
semver-gate witness ./base_src ./target_src
semver-gate benchmark

MCP Server Setup

Register semver-gate as a Stdio JSON-RPC 2.0 server (8 tools, <= 8,000 char output):

{
  "mcpServers": {
    "semver-gate": {
      "command": "semver-gate",
      "args": ["mcp"]
    }
  }
}

Tools: semver_diff, semver_wheel, semver_abi, semver_witness, semver_fsm, semver_chain, semver_laws, semver_benchmark.


When NOT to Use

  • Do not use semver-gate to run full downstream integration test suites; run pytest in a clean environment for behavioral runtime coverage.

  • Do not use semver-gate for non-Python, non-Rust binary .so symbol tables when nm or objdump is needed.


Testing

cargo test --manifest-path rust/Cargo.toml
pytest -q -W error

See docs/ARCHITECTURE_AND_RATIONALE.md for the 5-layer engineering rationale.

License

MIT License. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Evidence-backed, read-only codebase diagnostics for coding agents: secrets, dependency, RLS, and source-impact audits with a verify loop and PR review verdicts. Never writes files or uses the network by default.
      7
      122 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to audit git diffs, scan for leaked secrets and unsafe APIs, detect breaking changes, triage issues, generate changelogs, and assess repository hygiene through native stdio JSON-RPC tools.
      7
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes thirty callable tools that let any MCP client audit server manifests, detect poisoned tool descriptions, config files and long-term memory, catch tool rug-pulls, check known vulnerabilities and package authenticity, and statically screen tool code for SSRF, path traversal and command injection risk. It also simulates whether a proposed agent action should auto-approve or be held for human review.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides six MCP tools for AI-reliability work: grading LLM stacks from call logs, verifying source compilation, watching GitHub release drift, dry-running browser plans, auditing Actions workflows for fail-open settings, and gating drafts on human approval.
      MIT