agent-toolprint 0.1.0

Double-signed receipts for AI-agent tool invocations — DSSE + JCS + Ed25519, verifiable offline (Rust port of @p-vbordei/agent-toolprint)
Documentation
//! Receipt chaining — parent.id must equal child.parent.

use serde_json::Value;

use crate::envelope::envelope_payload_bytes;
use crate::types::validate_receipt;

pub fn chain(parent: &Value, child: &Value) -> bool {
    let p_bytes = match envelope_payload_bytes(parent) {
        Ok(b) => b,
        Err(_) => return false,
    };
    let c_bytes = match envelope_payload_bytes(child) {
        Ok(b) => b,
        Err(_) => return false,
    };
    let p: Value = match serde_json::from_slice(&p_bytes) {
        Ok(v) => v,
        Err(_) => return false,
    };
    let c: Value = match serde_json::from_slice(&c_bytes) {
        Ok(v) => v,
        Err(_) => return false,
    };
    if validate_receipt(&p).is_err() || validate_receipt(&c).is_err() {
        return false;
    }
    c.get("parent").and_then(Value::as_str) == p.get("id").and_then(Value::as_str)
}