provable-contracts-macros 0.1.0

Proc macros for compile-time contract enforcement — #[contract] attribute
Documentation

provable-contracts-macros

Proc macros for compile-time contract enforcement.

#[contract] Attribute

Annotates a function with a provable-contracts YAML contract reference. At compile time, verifies the contract exists (via build.rs env vars) and registers the binding for audit.

use provable_contracts_macros::contract;

#[contract("rmsnorm-kernel-v1", equation = "rmsnorm")]
pub fn rms_norm(input: &[f32], weight: &[f32], eps: f32) -> Vec<f32> {
    // ...
}

How It Works

  1. build.rs in the consuming crate reads binding.yaml and sets CONTRACT_<NAME>_<EQ>=bound env vars for each implemented binding.

  2. #[contract("name", equation = "eq")] expands to a const that reads the corresponding env var via env!(). Missing env var = compile error.

  3. A static string in a dedicated link section registers the binding for runtime audit (when contract-audit feature is enabled).