DEV Community

Cover image for Gating GitHub Pull Requests for AST Review Friction and Phantom Python Imports (slopcodemonitor-action@v1)
Evan Mercer
Evan Mercer

Posted on

Gating GitHub Pull Requests for AST Review Friction and Phantom Python Imports (slopcodemonitor-action@v1)

AI-assisted code generation is not inherently a software defect - most engineering teams use coding assistants every day to ship faster.

The operational bottleneck is pull-request review throughput versus diff velocity. When 800-line diffs arrive faster than senior engineers can read them line by line, three structural risks slip into production:

  1. Undeclared & Hallucinated Imports (Slopsquatting): Top-level import statements that happen to resolve locally via transitive packages (or do not exist in pyproject.toml / requirements.txt at all).
  2. Silent Broad Exception Swallowing: except Exception: pass or empty catch {} blocks that make CI tests green while hiding production failures.
  3. Cognitive Ownership Debt: Deeply nested control flow (depth >= 6) and 150-line monolithic functions that nobody on on-call can safely debug.

To catch these deterministically in CI without external SaaS tokens or probabilistic "AI authorship detectors," I packaged our core heuristics into a zero-dependency composite GitHub Action: evan-mercer-dev/slopcodemonitor-action@v1, benchmarked directly against the 7,352 open-source repositories (~3.9B LOC) tracked on SlopCodeMonitor.

SlopCodeMonitor Supply-Chain & Review Cohort Benchmarks

Drop-In Workflow (.github/workflows/slopcodemonitor.yml)

The Action runs on standard ubuntu-latest runners in under 2 seconds using Python's built-in ast module:

name: Code Review & Supply-Chain Gate

on:
  pull_request:
  push:
    branches: [main]

jobs:
  review-risk:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: SlopCodeMonitor AST & Dependency Gate
        uses: evan-mercer-dev/slopcodemonitor-action@v1
        with:
          path: "."
          fail-on-score: "35"   # Omit or set "101" for non-blocking PR summaries
Enter fullscreen mode Exit fullscreen mode

Contextualizing Scores Against 7,352 Open-Source Repositories

Raw static warnings are hard to calibrate without ecosystem baselines. Every run writes a Markdown report into $GITHUB_STEP_SUMMARY comparing your repository's score against the empirical cohort means from slopcodemonitor.ai:

Language Ecosystem Scanned OSS Repos Mean Cohort Baseline (/100) Canonical Reference
Python 1,310 13.34 Python Benchmark
TypeScript 1,240 2.34 TypeScript Benchmark
JavaScript 555 3.48 JavaScript Benchmark
Rust 492 1.70 Rust Benchmark
Go 671 1.40 Go Benchmark

If your public repository is already among the 7,352 scanned projects (you can check via the Hugging Face Explorer Space or the Top 200 Monitored Repos Index), the Action automatically links your published AST evidence profile in the CI job summary.

Source, Tests & Feedback

If there are additional structural AST checks (e.g. Go or Rust syn patterns) you would find valuable in PR summaries, open an issue on slopcodemonitor-action!

Top comments (0)