abi-forge
Reusable ABI governance and polyglot binding generator for C shared libraries.
From a single C header, abi-forge produces a versioned IDL snapshot and generates bindings for every language you need — with built-in breakage detection and governance.
What it does
| Stage | What happens |
|---|---|
| Parse | Clang-preprocesses your C header into a stable IDL JSON snapshot |
| Govern | Diffs every new snapshot against the baseline; flags removals, signature changes, enum shifts as typed errors (ABI001–ABI007, SARIF-compatible) |
| Generate | Runs your chosen language generators from the IDL: C#, Python, Rust, TypeScript, Go |
| Enforce | CI fails on ABI regressions; waivers require explicit approval with TTL |
Language targets
| Language | Output | Mechanism |
|---|---|---|
| C# (.NET) | P/Invoke + SafeHandle wrappers + async layer | Roslyn source generator (generator_sdk/csharp/) |
| Python | ctypes module with IntEnum, OOP handles, CFUNCTYPE | generator_sdk/python_bindings_generator.py |
| Rust | #[repr(C)] enums + extern "C" block |
generator_sdk/rust_ffi_generator.py |
| TypeScript | ffi-napi + OOP wrappers with [Symbol.dispose] |
generator_sdk/typescript_bindings_generator.py |
| Go | cgo package with struct wrappers and runtime.SetFinalizer |
generator_sdk/go_bindings_generator.py |
Real-world example
LumenRTC — a .NET wrapper over libwebrtc — uses abi-forge to govern its C ABI and generate all language bindings from a single IDL snapshot. See abi/config.json there for a complete production configuration.
Quick start
Requirements
- Python 3.10+
- clang (for header parsing)
- .NET SDK 10+ (optional, only for C# bindings)
Bootstrap a new target
# Add abi-forge as a submodule
git submodule add https://github.com/vitkuz573/abi-forge.git tools/abi_framework
# Bootstrap: scaffolds abi/config.json + initial metadata
python3 tools/abi_framework/abi_framework.py bootstrap \
--target mylib \
--header path/to/mylib.h \
--namespace MyLib \
--generate-python \
--generate-rust
# Parse header → IDL snapshot
python3 tools/abi_framework/abi_framework.py generate \
--config abi/config.json --skip-binary
# Generate all bindings from IDL
python3 tools/abi_framework/abi_framework.py codegen \
--config abi/config.json --skip-binary
# Lock current IDL as baseline (first time)
python3 tools/abi_framework/abi_framework.py generate-baseline --target mylib
ABI governance in CI
# Fail on regressions
python3 tools/abi_framework/abi_framework.py check \
--config abi/config.json --skip-binary
# Full SARIF report for GitHub code scanning
python3 tools/abi_framework/abi_framework.py check-all \
--config abi/config.json --skip-binary --sarif-out abi-report.sarif
Health dashboard
python3 tools/abi_framework/abi_framework.py status --config abi/config.json
Repository structure
abi-forge/
├── abi_framework.py # CLI entry point
├── src/abi_framework_core/ # core: parse, diff, snapshot, policy, orchestration
│ └── commands/ # subcommands: generate, codegen, check, release, status, …
├── generator_sdk/ # language generators (Python, Rust, TypeScript, Go, C#-scaffold)
│ └── plugin.manifest.json # plugin declarations for all built-in generators
├── abi_codegen_core/ # shared codegen primitives (native exports, required functions)
├── abi_roslyn_codegen/ # Roslyn source generator for C# P/Invoke + managed API
├── tests/ # 99 tests covering orchestration, generators, governance
└── schemas/ # JSON schemas for IDL, config, managed_api
Config overview (abi/config.json)
{
"targets": {
"mylib": {
"header": {
"path": "include/mylib.h",
"symbol_prefix": "mylib_",
"api_macro": "MYLIB_API"
},
"codegen": {
"idl_output": "abi/generated/mylib/mylib.idl.json"
},
"baseline_path": "abi/baselines/mylib.json",
"bindings": {
"generators": [
{
"manifest": "{repo_root}/tools/abi_framework/generator_sdk/plugin.manifest.json",
"plugins": [
"abi_framework.python_bindings",
"abi_framework.rust_ffi",
"abi_framework.typescript_bindings",
"abi_framework.go_bindings"
]
}
]
}
}
}
}
ABI error types (SARIF rules)
| Rule | Meaning |
|---|---|
ABI001 |
Function removed from public API |
ABI002 |
Function signature changed |
ABI003 |
Enum value added, removed, or renumbered |
ABI004 |
Struct layout changed |
ABI005 |
Bindings metadata mismatch |
ABI006 |
Version policy violation |
ABI007 |
Warning (non-breaking) |
License
MIT
Metadata
Release files for abi-forge 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| abi_forge-1.0.5.tar.gz | 164.7 kB | Without provenance | Details for abi_forge-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| abi_forge-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for abi_forge-1.0.5-py3-none-any.whl |
Total release size: 337.9 kB
Release files / abi_forge-1.0.5.tar.gz
| Download URL | abi_forge-1.0.5.tar.gz |
|---|---|
| Size | 164.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5b816c09c9eb66c8c02e4c52be6305d9145e989ae5027aa82b4a8f68007fb40
|
|
BLAKE2b-256 checksum How to use checksums |
efcf271a8d58c37fb75abd24ceba2c29b599768c4091d04054e17cfb8dfe4c17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / abi_forge-1.0.5-py3-none-any.whl
| Download URL | abi_forge-1.0.5-py3-none-any.whl |
|---|---|
| Size | 173.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eae39c282145625df6ef518f71e27787fb0b8ff5e42278c70d9712142f3a22b4
|
|
BLAKE2b-256 checksum How to use checksums |
e523f9306db88fe514532324a4ce015e2b68a019865822e86195b0d57efb345a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for abi-forge 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.