1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Active Infinity (Active ∞) — the canonical binary form of Active modules.
//!
//! Active Infinity is a graph-native, unit-aware, secret-safe, canonical,
//! content-addressed binary data language for the Active ecosystem. It is the
//! runtime, storage, network and agent-to-agent exchange format for Active
//! modules: safer and faster than JSON for configuration and data, deterministic
//! by construction, and designed so that an untrusted buffer can be validated
//! in one bounded pass before any of it is trusted.
//!
//! # Quick start
//!
//! ```
//! use active_infinity::{Inode, InfinityModule, encode, decode, content_hash};
//!
//! let mut module = InfinityModule::new();
//! let hello = module.push(Inode::Str("hello".into()));
//! let number = module.push(Inode::Int(42));
//! let table = module.push(Inode::Table {
//! fields: vec![("greeting".into(), hello), ("answer".into(), number)],
//! });
//! module.set_root(Some(table));
//!
//! let bytes = encode(&module).unwrap();
//! let decoded = decode(&bytes).unwrap();
//! assert_eq!(decoded, module);
//! assert_eq!(encode(&decoded).unwrap(), bytes);
//! assert_eq!(content_hash(&bytes).unwrap(), content_hash(&encode(&decoded).unwrap()).unwrap());
//! ```
//!
//! # The four guarantees
//!
//! 1. **Canonical identity.** Logically equal modules encode to identical
//! bytes, and the Blake3 content hash covers the whole canonical payload, so
//! content addressing is a real identity (`canonical`, `encode`).
//! 2. **Fail-closed validation.** Wrong magic/version, truncation, out-of-range
//! offsets and counts, invalid UTF-8, unknown unit discriminants, cycles,
//! unreachable nodes, non-canonical slack and size bombs are rejected with
//! stable machine-readable codes before allocation (`validate`, `error`).
//! 3. **Secrets stay secrets.** Secret material is a structural kind, never
//! equals anything (no oracle), carries no `Debug`/`Display`/`Serialize`
//! path, and is absent from every export path (`ir::SecretBytes`).
//! 4. **Zero-copy and streaming.** A validated buffer can be read through
//! [`view::InfinityView`] without copying strings or blobs, and a module can
//! be shipped as ordered frames that reassemble to the identical canonical
//! bytes and hash, including incremental deltas (`stream`).
//!
//! # Feature flags
//!
//! - `active-core` (default): interop with the Active text language IR
//! (`interop::from_active_core`, `to_active_core`).
//! - `json` (default): the redacted JSON projection
//! (`interop::to_redacted_json`).
//!
//! Both can be disabled for a dependency-free wire codec.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use to_protobuf;
pub use ;
pub use UnitTag;
pub use ;
pub use ;
/// Crate version.
pub const VERSION: &str = env!;
/// Magic bytes at the start of every Active Infinity module.
pub const MAGIC: = MAGIC;
/// Compute the Blake3-256 content hash of a validated image.
///
/// The hash covers the whole canonical payload with the stored hash field
/// zeroed, so it changes when any canonical byte changes and is stable across
/// runs and processes.
/// Hex form of [`content_hash`].
/// Encode a module and return `(bytes, hash)`.