The deterministic contract layer for AI-modified codebases — effects, purity, contracts, and blast radius, with zero LLM calls.
Project description
CodeGraph IR (CGIR)
The deterministic contract layer for AI-modified codebases. Agents write more of the code than you can review. CGIR reads a repo and — with zero LLM calls — tells you what each component is (effects, purity, contract, entrypoints, call surface) and whether a change altered it. Think ruff, but for architecture instead of style: fast, static, hallucination-free.
Distributed as codegraph-ir; the command and import package are both
cgir.
Install
uv tool install codegraph-ir # isolated CLI (recommended); or: pipx install codegraph-ir
cgir --version
For library/agent use in a project: uv pip install codegraph-ir
(extras: [mcp] for the agent server, [api] for the HTTP surface,
[llm] for regeneration).
The local loop
cgir scan . # build the .cgir index (Python, TypeScript, Go)
cgir watch . # keep it live: re-scan + show contract drift on save
cgir pack app.service.charge --repo . # minimal context bundle for one component
cgir impact app.service.charge # blast radius: affected callers, entrypoints, tests
cgir impact app.service.charge --candidate new.py --repo . # radius narrowed by the real delta
cgir verify app.service.charge --candidate new.py --repo . # contract-check an edit
cgir hook install # pre-commit seatbelt: block contract-breaking commits
pack → edit → impact → verify → hook, with watch keeping the index
fresh underneath — an always-on membrane you and your agent both consult.
Gate CI on contract drift
The GitHub Action scans a PR's base and head and
fails the build on drift — a pure function that starts hitting the network, a
service that stops persisting, a new POST /admin route — deterministically,
with no per-seat LLM cost:
- uses: asonkiya/llm-semantic-compilers@v0
with:
fail-on: "effect-gain:net effect-gain:fs effect-gain:db effect-loss:net effect-loss:fs effect-loss:db"
The default rule set is evidence-based: replaying real commit history, the I/O effect rules fire on ~0–10% of commits, each a genuine change in a component's I/O surface.
Agents as first-class users
cgir mcp --index .cgir serves the index over MCP. Instead of grepping, an
agent calls search / pack to load minimal context, impact to see what a
change touches, and verify / impact_of_change to contract-check its own
edit before proposing it. See examples/ for a worked
agent-PR case study.
Docs
docs/strategy.md— positioning: the deterministic contract layerdocs/status.md— what runs today, test coverage, milestonesdocs/gate-noise.md— false-alarm measurement on real historydocs/github-action.md— CI contract-diff gatedocs/experiment-log.md— rewrite-readiness / contract-preservation benchmarksdocs/architecture.md— layered pipeline, data model, extension seamsdocs/languages.md— adding a language (theLanguageAdapterseam)Code-IR.md— full product specificationRELEASING.md— how to cut a release
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codegraph_ir-0.2.0.tar.gz.
File metadata
- Download URL: codegraph_ir-0.2.0.tar.gz
- Upload date:
- Size: 188.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b18c899133cc01a4f1d0dafebb0d62badb1bfb4d9baf19e9dc440b202028950
|
|
| MD5 |
5c1f9a6300e665b55d72040ae004ee9b
|
|
| BLAKE2b-256 |
ff5571701f7b8880bda6116d301c9fa533214e13e00ef68c5e7c7bf43adac159
|
Provenance
The following attestation bundles were made for codegraph_ir-0.2.0.tar.gz:
Publisher:
release.yml on asonkiya/llm-semantic-compilers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codegraph_ir-0.2.0.tar.gz -
Subject digest:
3b18c899133cc01a4f1d0dafebb0d62badb1bfb4d9baf19e9dc440b202028950 - Sigstore transparency entry: 2145633910
- Sigstore integration time:
-
Permalink:
asonkiya/llm-semantic-compilers@a4c0a9007acee2b8cc35dbe1bd1eab199b448883 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/asonkiya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a4c0a9007acee2b8cc35dbe1bd1eab199b448883 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codegraph_ir-0.2.0-py3-none-any.whl.
File metadata
- Download URL: codegraph_ir-0.2.0-py3-none-any.whl
- Upload date:
- Size: 120.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b1cd5ce0d7a71b473d1d654eb97d586fe841da2ed62d466d56f40fba65e3ad9
|
|
| MD5 |
f6b19c03380fe8cb828dc945f69455d6
|
|
| BLAKE2b-256 |
cf321836bf5ea4b172b2d4397382fc977f35a2c30d981cb47317594d35c4009a
|
Provenance
The following attestation bundles were made for codegraph_ir-0.2.0-py3-none-any.whl:
Publisher:
release.yml on asonkiya/llm-semantic-compilers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codegraph_ir-0.2.0-py3-none-any.whl -
Subject digest:
1b1cd5ce0d7a71b473d1d654eb97d586fe841da2ed62d466d56f40fba65e3ad9 - Sigstore transparency entry: 2145633920
- Sigstore integration time:
-
Permalink:
asonkiya/llm-semantic-compilers@a4c0a9007acee2b8cc35dbe1bd1eab199b448883 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/asonkiya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a4c0a9007acee2b8cc35dbe1bd1eab199b448883 -
Trigger Event:
push
-
Statement type: