Expand description
boundary-compiler — RFC 8785 JCS with boundary profiles and duplicate-key rejection.
§Overview
This crate implements RFC 8785 — JSON Canonicalization Scheme (JCS):
- Canonicalizer that serializes JSON into deterministic byte sequences
- Duplicate-key rejection (RFC 8785 mandates duplicate object keys are errors)
- blake3 Content-Digest of the JCS string
- Boundary profiles for dialect, schema ID+version, canonicalization profile, unknown-field policy, and resource ceilings
- JSON Schema validation (stub — always passes)
§Integration
This crate is intended to replace semantic_memory::graph::canonical_json_string()
with a standards-compliant JCS implementation.
§Example
use boundary_compiler::{Canonicalizer, ContentDigest, BoundaryProfile};
use serde_json::json;
let c = Canonicalizer::new();
let val = json!({"b": 2, "a": 1});
let canonical = c.canonicalize(&val).unwrap();
assert_eq!(canonical, r#"{"a":1,"b":2}"#);
let digest = ContentDigest::compute(&val).unwrap();
println!("Digest: {}", digest);§Error handling
All fallible operations use thiserror errors — no unwrap() or expect() in production.
Duplicate keys return JcsError::DuplicateKey, and schema validation failures return
JcsError::SchemaValidation.
Re-exports§
pub use canonicalizer::canonicalize_flexible;pub use canonicalizer::parse_and_validate;pub use canonicalizer::parse_with_dup_check;pub use canonicalizer::Canonicalizer;pub use digest::ContentDigest;pub use error::JcsError;pub use profile::BoundaryProfile;pub use schema::SchemaValidator;
Modules§
- canonicalizer
- RFC 8785 JSON Canonicalization (JCS) implementation.
- digest
- blake3 ContentDigest over JCS bytes.
- error
- Error types for boundary-compiler.
- profile
- Boundary profile definitions.
- schema
- Optional JSON Schema validation before and after JCS canonicalization.