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-clauselabel/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 ofCAPABILITY_ENHANCEMENTS_PLAN.mddefined 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.jsontests/cross_lang_capability/predicate_debug_report.jsontests/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
predicateagainst every entry incontexts_jsonand write aPredicateDebugReportto the out-param. MirrorsPredicateDebugReport::from_evaluations(pred, contexts). - net_
predicate_ ⚠evaluate_ with_ trace - Evaluate a wire-format
Predicateagainst(tags, metadata)and write aClauseTracetree to the out-param. - net_
predicate_ ⚠redact_ metadata_ keys - Apply the
redact_labelrewrite (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_labelrewrite across a wire-format trace tree (the JSON output ofnet_predicate_evaluate_with_trace).