Skip to main content
Glama

Verify Rust Parity

verify_rust_parity
Idempotent

Compile and run a sandboxed differential FFI harness that compares a C/C++ reference symbol against a candidate Rust function, shrinking failing inputs and reporting bit/ULP divergence.

Instructions

Compile and execute a sandboxed differential FFI property-testing harness comparing a C/C++ reference symbol (from a compiled shared library or inline C source code) against a candidate reconstructed Rust function across deterministic boundary cases and SplitMix64 randomized inputs. Automatically shrinks any failing counterexample via binary-search reduction and reports exact bit/ULP divergence and OS sandbox telemetry (bwrap/prlimit on Linux, sandbox-exec on macOS, Job Objects on Windows).

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "seed": 1337420,
      "arg_types": [
        "u32",
        "u32"
      ],
      "iterations": 10000,
      "timeout_ms": 20000,
      "return_type": "u32",
      "symbol_name": "add_u32",
      "harness_mode": "native-rustc",
      "c_source_code": "#include <stdint.h>\nuint32_t add_u32(uint32_t a, uint32_t b) { return a + b; }",
      "rust_source_code": "pub fn add_u32(a: u32, b: u32) -> u32 { a.wrapping_add(b) }",
      "float_ulp_tolerance": 0
    },
    "name": "verify_rust_parity"
  }
}

Input Schema

NameRequiredDescriptionDefault
seedNoDeterministic 64-bit PRNG seed for reproducible differential fuzzing.
arg_typesYesOrdered list of C ABI parameter types accepted by both the C symbol and Rust function (1 to 16 arguments; 'bytes' passes (*const u8, usize) to C and &[u8] to Rust).
iterationsNoNumber of randomized FFI property-testing iterations to execute in addition to deterministic boundary cases (default 10000).
timeout_msNoHard wall-clock timeout in milliseconds for sandboxed execution (default 20000).
return_typeYesScalar C ABI return type produced by both the C symbol and Rust function.
symbol_nameYesExported C ABI symbol name to test (e.g., 'compute_packet_crc32c').
harness_modeNoExecution harness mode: 'native-rustc' (default zero-network fast path using stdlib FFI dlopen + SplitMix64 + binary-search shrinker) or 'cargo-proptest' (Cargo workspace harness).
rust_fn_nameNoRust function identifier in rust_source_code to invoke (defaults to symbol_name).
c_source_codeNoOptional C reference source code to compile into a shared library when verifying a decompiled or standalone C function.
forbid_unsafeNoWhether to enforce #![forbid(unsafe_code)] at compile time on the candidate Rust module (default true; set to false only when intentionally testing candidate code that uses unsafe).
html_report_pathNoOptional file path to write an Antigravity generative_ui-compliant HTML parity report when status === 'verified_bit_exact'.
rust_source_codeYesCandidate safe Rust source code defining pub fn <rust_fn_name>(...) or pub extern "C" fn <rust_fn_name>(...).
target_binary_pathNoOptional absolute path to a compiled C/C++ shared library (.so, .dylib, .dll) or object/binary exporting symbol_name.
float_ulp_toleranceNoMaximum allowed IEEE-754 ULP (Units in the Last Place) distance for f32/f64 return values (default 0 for strict bit-exact equivalence).
scaffold_output_dirNoOptional directory path where a pure standalone verified #![forbid(unsafe_code)] Rust Cargo crate (Cargo.toml, src/lib.rs, tests/parity_regression.rs) will be scaffolded without HTML clutter when status === 'verified_bit_exact'.
remediated_rust_source_codeNoOptional remediated Safe Rust source code (e.g., <fn>_remediated) to include alongside the bit-exact C-oracle reconstruction in the scaffolded Cargo crate.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare mutation/open-world/idempotent/destructive flags; the description goes well beyond by disclosing the sandboxing implementation per OS (bwrap/prlimit, sandbox-exec, Job Objects), a hard execution timeout, automatic binary-search shrinking of counterexamples, and exact bit/ULP divergence plus sandbox telemetry reporting. This is exactly the operational context an agent needs before invoking an execution-heavy tool and is consistent with readOnlyHint=false and openWorldHint=true.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, both dense but front-loaded with the core action (compile and execute the differential harness) before the result-handling details. The jargon load is high and the first sentence runs long, but every clause contributes distinct information about behavior or output.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 16-parameter execution tool with no output schema, the description covers the full pipeline: reference acquisition, comparison method, failure reduction, divergence reporting, and sandbox mechanism. It does not enumerate result status values (e.g. 'verified_bit_exact', referenced only in schema property text) or side effects like crate scaffolding, leaving a small gap for a highly complex tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so per-parameter meaning (arg_types ABI mapping, seed, ULP tolerance, harness modes, scaffold/report paths) is already fully documented in structured data. The description adds only aggregate semantics — deterministic boundary cases plus SplitMix64 randomized inputs, and shrinking via binary-search reduction — which is useful framing but not parameter-level detail, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific compound verb and resource: compile and execute a sandboxed differential FFI property-testing harness comparing a C/C++ reference symbol against a candidate Rust function. The scope (FFI symbol-level equivalence, deterministic + randomized inputs) is precise enough to distinguish it from sibling diagnostic tools like compare_functions or inspect_rust_cpp_binary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The scenario is implied by phrases like 'candidate reconstructed Rust function' and the schema's 'decompiled or standalone C function', so an agent can infer this is a post-reconstruction verification step, but there is no explicit when-to-use/when-not-to-use statement and no sibling alternative is named. Guidance is inferable rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools