Skip to main content

Module proof_serializer

Module proof_serializer 

Source
Expand description

Proof Serializer

Serializes and deserializes distributed backward-chaining proof trees for storage in IPLD and transmission over the network.

A ProofTreeInput (logical tree) is flattened in DFS order into a SerializedProof whose proof_id is the FNV-1a hex digest of the sorted, concatenated node IDs. Round-trip fidelity is guaranteed: every field, binding, and topology is reconstructed by ProofSerializer::deserialize.

§Examples

use ipfrs_tensorlogic::proof_serializer::{
    ProofNodeInput, ProofSerializer, ProofTreeInput,
};
use std::collections::HashMap;

// Build a trivial single-node proof.
let mut nodes = HashMap::new();
nodes.insert(
    "n0".to_string(),
    ProofNodeInput {
        rule_id: None,
        bindings: HashMap::new(),
        children: vec![],
        peer_id: None,
    },
);
let input = ProofTreeInput {
    root_goal: "n0".to_string(),
    nodes,
    proved: true,
};

let ser = ProofSerializer::default();
let proof = ser.serialize(&input).expect("example: should succeed in docs");
assert!(proof.proved);
assert_eq!(proof.depth, 0);
assert_eq!(proof.edge_count, 0);

Structs§

ProofNodeInput
A single node as provided by the caller prior to serialization.
ProofNodeRecord
A flattened representation of one node, suitable for storage and transmission.
ProofSerializer
Serializes and deserializes distributed proof trees.
ProofSerializerStats
Atomic counters tracking ProofSerializer activity.
ProofSerializerStatsSnapshot
A point-in-time snapshot of ProofSerializerStats counters.
ProofTreeInput
Full proof tree as produced by the distributed backward chainer.
SerializedProof
A fully serialized proof tree, ready for IPLD storage or network transmission.

Enums§

ProofSerError
Errors produced by ProofSerializer.