Skip to main content

Module predicate_debug

Module predicate_debug 

Source
Expand description

C FFI for predicate debug-session helpers (Phase 9d of CAPABILITY_SYSTEM_SDK_PLAN.md). Pure helpers — single-eval evaluate_with_trace, corpus-wide aggregate_debug_report, and host-side redact_metadata_keys. Mirror what every other binding ships at the SDK layer; exposed at the C ABI for raw consumers. C FFI for predicate debug-session helpers (Phase 9d of CAPABILITY_SYSTEM_SDK_PLAN.md).

Three pure helpers — no handles, no state — exposing what every other binding ships at the SDK layer:

  • net_predicate_evaluate_with_trace — single-evaluation trace tree (per-clause label / result / children).
  • net_predicate_aggregate_debug_report — corpus-wide aggregator: total / matched / per-clause (evaluated, matched) rollup keyed by debug label.
  • net_predicate_redact_metadata_keys — host-side scrubber that rewrites metadata-clause labels before persistence. The substrate doesn’t ship a redaction implementation (Phase 6 of CAPABILITY_ENHANCEMENTS_PLAN.md defined the API but only the trace + aggregator landed); each binding implements it. This module ports the same logic the TS / Python / Go SDKs ship.

Cross-binding contracts pinned by:

  • tests/cross_lang_capability/predicate_trace.json
  • tests/cross_lang_capability/predicate_debug_report.json
  • tests/cross_lang_capability/predicate_debug_report_redacted.json

Wire shapes mirror the test renderers in tests/cross_lang_capability_fixtures.rs.

§Safety

Every entry point is unsafe extern "C" and inherits the module-wide FFI safety contract (see ffi/mod.rs and include/net.h): NUL-terminated UTF-8 JSON inputs, valid out-parameter pointers, caller-frees-Rust-allocated-strings.

Functions§

net_predicate_aggregate_debug_report
Run predicate against every entry in contexts_json and write a PredicateDebugReport to the out-param. Mirrors PredicateDebugReport::from_evaluations(pred, contexts).
net_predicate_evaluate_with_trace
Evaluate a wire-format Predicate against (tags, metadata) and write a ClauseTrace tree to the out-param.
net_predicate_redact_metadata_keys
Apply the redact_label rewrite (private helper above) across a wire-format report and write the redacted report to the out-param.
net_predicate_redact_trace_metadata_keys
Apply the redact_label rewrite across a wire-format trace tree (the JSON output of net_predicate_evaluate_with_trace).