Skip to main content

impact-gate

Measure and gate the structural decay a change introduces. Run it as a standalone CLI, a git pre-commit hook, or a plugin in GitHub, GitLab, and Jenkins CI.

Structural decay is complexity accreting into existing structures. A god-method grows another branch. A god-class gains another method. The gate scores a change against a base (main by default) with the change-impact measure:

impact = files_changed * Σ max(WMC_other, 1) * CC * Δlines      (over changed functions)

WMC_other is the complexity already in the container you are editing. It is measured on the pre-change state. So importing a brand-new file or class is cheap. Nothing was there before. Piling onto an already-heavy class is expensive. That is the decay signal.

When impact is too high, the gate asks you to simplify the change or refactor the code it touches. It can warn (report only) or block (fail the build).

This tool is the instrument for an experiment. The experiment studies how to control structural decay under AI-augmented development. The gate sits in front of every change, human or AI, so complexity cannot silently concentrate.

Fully standalone. The measure is vendored in impact_gate/core/. Only lizard is required at runtime.

Install

pip install impact-gate         # installs the `impact-gate` command

Or run it without installing anything, via the published image (git is bundled; mount the repo to score at /repo):

docker run --rm -v "$PWD:/repo" ghcr.io/officefloor/impact-gate \
  score --mode range --base origin/main

To hack on it locally, install from a checkout instead:

python -m venv .venv && . .venv/bin/activate
pip install -e '.[dev]'         # editable install plus the test deps

Use

# The commit you are about to make (pre-commit): staged vs HEAD. This is the default.
impact-gate score

# Uncommitted local edits: working tree vs HEAD.
impact-gate score --mode worktree

# CI or PR review: the committed branch vs main (merge-base..HEAD).
impact-gate score --mode range --base origin/main --format json

# Set thresholds and enforcement. You can also put these in .impact-gate.yml.
impact-gate score --warn-at 50000 --block-at 200000 --enforcement block

Exit codes. 0 means ok or warn (the change is allowed). 2 means blocked (impact too high under --enforcement block). 1 means a usage or environment error.

Every report also lists the files to consider for refactoring, ranked by their share of the impact. The change-level number gates; the per-file ranking points at where the decay is concentrating, so a file quietly growing into a god-class surfaces as a candidate before it blocks anything.

Grade against a distribution (the curve)

A raw threshold is hard to set: a typical change's impact varies by orders of magnitude across languages and projects. Instead of guessing a number, grade a change by its percentile against a distribution, and gate on the percentile.

# Build (or refresh) the project's own impact distribution from the merged history.
# Writes .impact-gate-baseline.json. Re-run it as the branch moves.
impact-gate baseline --base-ref main

# Gate on the grade instead of an absolute number.
impact-gate score --curve --warn-percentile 90 --block-percentile 98

The grade blends two distributions:

  • a seed prior shipped with the tool — per-language percentile tables built from a 20-repo open-source corpus, with a pooled fallback for languages not in the table;
  • the project baseline — the repo's own per-change distribution, walked from the merged mainline (only landed work; in-flight branches are never reached).

The blend weights the project by w = n / (n + K), where n is the number of landed changes behind the baseline and K (curve_prior_weight, default 200) is how much history it takes to trust the project over the seed. A fresh repo with no baseline file grades on the seed alone; a deep history leans on itself. The grade shows in every format next to the raw number.

Configure with .impact-gate.yml (repo root)

warn_at: 50000          # impact above which to warn
block_at: 200000        # impact above which to block
enforcement: warn       # off, warn, or block. Start on warn. Flip to block when ready.
tolerance: 1.0          # CI-adjustable multiplier on both thresholds. Above 1 is more lenient.
# measure_config: .impact-measure.yml   # optional: ignore globs and language overrides

# Grading curve (percentile gate). When enabled, warn_at/block_at are ignored and the
# gate uses the percentiles below instead.
curve_enabled: false           # gate on the percentile grade instead of absolute numbers
warn_percentile: 90            # grade at or above this warns
block_percentile: 98           # grade at or above this blocks
curve_prior_weight: 200        # K in w = n/(n+K): history needed to trust the project over the seed
baseline_file: .impact-gate-baseline.json   # where `impact-gate baseline` caches the distribution

CLI flags override the file. A CI job can pass --tolerance or --warn-at. So a team can dial tolerance without editing the repo. The curve knobs have flags too: --curve, --warn-percentile, --block-percentile, --baseline-file.

Use in GitHub Actions

Add a workflow to your repo. The action scores the PR branch against its base and writes a summary. fetch-depth: 0 is required so the base branch and merge-base are present.

name: Change impact
on: pull_request
permissions:
  contents: read
  pull-requests: write         # so the action can post the score as a PR comment
jobs:
  impact:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - uses: officefloor/ImpactGate@v1
        with:
          enforcement: warn        # switch to block when ready
          # warn-at: 50000
          # block-at: 200000
          # tolerance: 1.0

The score appears in the job summary and as a sticky comment on the PR (one comment, updated each run). In block mode the job fails when impact exceeds the block threshold. Make the check required in branch protection to gate merges. The comment needs pull-requests: write. Without it the run still passes and just skips the comment.

Roadmap

  • Core CLI. Score staged, worktree, or range. Warn or block. Text, JSON, markdown. Done.
  • GitHub Action. Composite action, job-summary report, and a sticky PR comment. Done.
  • Baseline and grading curve. impact-gate baseline profiles the project history; the gate blends a seed-corpus prior with the project's own distribution and grades a change by its percentile (score --curve). Done.
  • Distribution. pip install impact-gate, a ghcr.io/officefloor/impact-gate Docker image for any CI, and a version-tagged Action (@v0). Done.
  • More CI plugins. A GitLab CI template and a Jenkins shared library.
  • Hooks and IDE. An impact-gate install-hook for pre-commit. Editor integration over LSP.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

impact_gate-0.1.0.tar.gz (49.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

impact_gate-0.1.0-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file impact_gate-0.1.0.tar.gz.

File metadata

  • Download URL: impact_gate-0.1.0.tar.gz
  • Upload date:
  • Size: 49.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for impact_gate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 302e1174594885d428d10c08ec065032e60daa45c6d32ed77d3015a8bd490f85
MD5 1cde09aa541dedfbef61b19d393fb7f7
BLAKE2b-256 c69ffd500a71a24ad4064a687cf1282dbb4f0257fd33198b04801a5c1f7eb5d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for impact_gate-0.1.0.tar.gz:

Publisher: release.yml on officefloor/ImpactGate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file impact_gate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: impact_gate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for impact_gate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91c1d0ee7a9beb3b8f335fad077ab366b9a6372a91af53807d962e73ddafe47e
MD5 0410ef7b21ce90dcbfee20bafb174fdf
BLAKE2b-256 be74ee09c9db6a282f58d7161e0853cb4a556b4fdaf9acbfa0bbc020f6505d27

See more details on using hashes here.

Provenance

The following attestation bundles were made for impact_gate-0.1.0-py3-none-any.whl:

Publisher: release.yml on officefloor/ImpactGate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page