In Development Fail-Closed Parser libclang Engine Abigen.Desktop & Abigen.Core

Abigen (in development)

Point it at a C/C++ header, get reviewed, verified C# bindings — and keep them in sync as the native library moves.

Abigen generates C/C# interop bindings from C++ headers, then manages the ongoing relationship with the native library those bindings came from: tracking new releases, regenerating, verifying, and flagging what changed for human review before anything ships. It's a desktop app (Abigen.Desktop) on top of a managed project engine (Abigen.Core), which itself wraps HF Labs' own header-analysis and code-generation CLI rather than duplicating its parser or ABI decisions.

Core Philosophy Fail-Closed By Design

Binds only verifiable C-compatible types; rejects ambiguous ABI constructs with explicit reasons

Manifest Tracking Full SHA-256 Fingerprint

Records resolved libclang path, normalized include paths, defines, and exact compiler flags

Upstream Sync Automated Release Watcher

Monitors GitHub releases/feeds, diffs API word count against approved baselines, and flags changes

Verification Loop 5-Stage Validation

Native build, managed compilation, smoke tests, deterministic rerun & schema verification

Strict Boundary Isolation

A Narrow, Fail-Closed Generator, by Design

The generator does not attempt to bind arbitrary C++. It emits bindings only for what it can verify is safe: top-level C-compatible free functions, scalar and fixed-width integer types, plain structs with public scalar fields (including nested structs and fixed arrays), non-owning pointers to supported structs, and explicitly configured opaque native handles.

✓

Supported & Verifiable

Verified Safe
  • Top-level C-compatible free functions
  • Scalar and fixed-width integer types (int32_t, uint64_t, size_t, etc.)
  • Plain structs with public scalar fields & nested POD structs
  • Fixed-size primitive arrays (e.g., uint8_t[32])
  • Non-owning pointers to supported plain structs (ref/in semantics)
  • Explicitly configured opaque native handles with ownership metadata
✕

Fail-Closed Rejections (Never Guessed)

Strictly Rejected
  • C++ Namespaces & Classes with virtual method tables
  • Complex structs with non-trivial constructors/destructors
  • Unsupported or untyped C++ enums
  • C++ References (& and && rvalue references)
  • Struct-pointer returns with ambiguous ownership
  • C++ Templates, Overloads, Callbacks, Unions & Bitfields
🛡️

Never Guessing with Bare IntPtr

Everything else — namespaces, classes, complex structs, unsupported enums, references, struct-pointer returns, templates, callbacks, overloads, unions, bitfields — is rejected, not guessed at. Rejected declarations are reported with reasons and are never silently turned into a bare IntPtr binding that might be wrong.

Managed Project Engine

A Project, Not a One-Shot Run

Abigen.Core wraps each header/library pairing as a project with its own configuration: header paths, include paths and defines, target language standard (C++11 through C++23), an export policy (include/exclude patterns, name overrides, ownership metadata for handles), and a resolved libclang toolchain fingerprint recorded for reproducibility.

Every generation records a full manifest — the resolved libclang path and SHA-256 fingerprint, normalized include paths and defines, effective Clang arguments — so a binding set can be verified as reproducible later, not just trusted.

abigen_manifest.json • Reproducible Fingerprint
{
  "$schema": "https://hflabs.dev/schemas/abigen_project_v1.json",
  "projectName": "LevelZero.Core.Interop",
  "targetLanguageStandard": "C++17",
  "toolchain": {
    "libclangPath": "/opt/llvm-18/lib/libclang.so.18",
    "libclangSha256": "9f8a3c...b412e87",
    "effectiveClangArgs": [
      "-std=c++17",
      "-DZE_ENABLE_PREVIEW",
      "-I/usr/include/level_zero"
    ]
  },
  "exportPolicy": {
    "opaqueHandles": ["ze_driver_handle_t", "ze_device_handle_t"],
    "ownershipRules": { "ze_device_handle_t": "BorrowNonOwning" },
    "namePrefixTransform": "TrimPrefix(ze)"
  },
  "approvalState": "Approved",
  "lastVerifiedTimestamp": "2026-09-21T18:42:00Z"
}
📡
Continuous Upstream Sync

Release Tracking, Not a One-Time Export

A project can track a GitHub repository or a build feed and follow a version policy (latest-release by default). When a new release lands, Abigen surfaces it as an update, diffs the API surface word count against what was last approved, and lets you review before regenerating. An RSS server can publish that feed state out to other tools.

GitHub Release Watcher API Surface Word-Diff Embedded RSS Feed Server
⚖️
Human In The Loop

Review Before It's Trusted

Every project carries an approval state (unreviewed by default). The desktop app's API review dialog shows the generated report per project, and generation failures return a distinct, documented exit code rather than a silent partial success.

A verification workflow runs configurable native build, managed build, smoke-test, deterministic-rerun and schema-validation commands, and records the last verification timestamp and the workspace from the last failure, so a broken regeneration is diagnosable, not just red.

5-Stage Verification Workflow

Complete Automated Invariant Checking

1. Native Build

Compiles C ABI native shim with target toolchain to verify syntax and symbol visibility.

2. Managed Build

Invokes Roslyn compiler on generated C# P/Invoke bindings, verifying unsafe struct layouts.

3. Smoke Test

Executes automated native-to-managed roundtrip calls validating parameter passing and alignment.

4. Deterministic Rerun

Regenerates from identical headers and asserts bit-for-bit identical manifest and code output.

5. Schema Validation

Validates emitted metadata against HFLabs standard API and wire contract schemas.

Visual Project Command Center

Desktop Workflow (Abigen.Desktop)

The desktop app is a project dashboard: a grid of tracked projects and their status (not configured, ready, running, succeeded, generation failed, verification failed, update available, feed unavailable), a toolchain report dialog showing the resolved libclang evidence, an API review dialog per project, and a project editor for header paths, opaque handle types and export policy.

Abigen.Desktop v1.0 • Interop Project Dashboard libclang 18.1.8
+ New Tracked Project
⚡ Run Verification All
📋 libclang Toolchain Report
📡 RSS Feed Status
PROJECT NAME UPSTREAM VERSION STATUS FEED SOURCE API REVIEW DIFF ACTIONS
Intel LevelZero Core ABI v1.17.4 Succeeded GitHub Release 0 changes (Approved)
Graphcore Poplar C Shim v3.3.0 Update Available Build Feed +14 decls / -2 deprecated
HFLabs AVX512 Math Driver v2.1.0 Ready Local Git Baseline Synced
Heterogeneous RDMA Kernel v0.8.2-rc Verification Failed CI Webhook Smoke Test 0x04 Exit
Architectural Rationale

Why This Exists

“Hand-written P/Invoke bindings rot the moment the native library changes, and a general-purpose C++ binder papers over ABI decisions no one actually reviewed. Abigen keeps the boundary narrow enough to trust by construction, and keeps it current by watching the upstream release instead of waiting for someone to notice it drifted.”