Skip to main content

Module predicate

Module predicate 

Source
Expand description

C FFI for stateless predicate evaluation (Phase 9c of CAPABILITY_SYSTEM_SDK_PLAN.md). Pure helpers — no handles, no state. Mirrors the SDK-layer evaluatePredicate / evaluate_predicate surface every binding ships, exposed at the C ABI for raw consumers (C / C++ / Zig / Swift / etc.). C FFI for stateless predicate evaluation (Phase 9c of CAPABILITY_SYSTEM_SDK_PLAN.md).

Pure helpers — no handles, no state. The substrate’s Predicate::evaluate_unplanned(ctx) is mirrored across all four bindings (Rust SDK, TS, Python, Go) at the SDK layer; this module brings the same surface to raw C consumers (C / C++ / Zig / Swift / Java JNI / etc.) so they can evaluate predicates locally without going through nRPC.

All inputs cross as NUL-terminated UTF-8 JSON strings:

  • predicate_json — wire-format PredicateWire JSON. The same shape every binding emits / accepts; cross-binding compat is pinned by tests/cross_lang_capability/predicate_eval.json.
  • tags_json — JSON array of tag strings, e.g. ["hardware.gpu", "scope:tenant:foo"]. Reserved-prefix tags are accepted (parsed via the privileged path).
  • metadata_json — JSON object of string -> string, e.g. {"intent": "ml-training", "region": "us-east"}.

Cross-binding contract: the same (predicate, tags, metadata) triple produces identical booleans across every binding. Drift between the C surface and the substrate’s evaluator surfaces as a fixture-driven CI failure on the offending side.

§Safety

Every entry point is unsafe extern "C" and inherits the module-wide FFI safety contract (see ffi/mod.rs and include/net.h).

Functions§

net_predicate_evaluate
Evaluate a wire-format Predicate against a (tags, metadata) context. Mirrors Predicate::evaluate_unplanned(ctx) from the substrate.
net_predicate_to_where_header
Encode a wire-format Predicate as the canonical net-where: request-header value.