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
//! # Heap Module
//!
//! Explicit heap-based state management with nullifier tracking.
//!
//! ## Overview
//!
//! This module provides canonically encoded resources and a deterministic heap
//! for managing protocol state. Key features:
//!
//! - **Hash-Policy Reuse**: Resource IDs use the shared `Hasher` abstraction
//! - **Canonical Encoding**: Resource identity and leaf hashing use versioned
//! heap-local encodings and tagged preimages
//! - **Nullifier Tracking**: Consumed resources are tracked to prevent double-spending
//! - **Deterministic Operations**: Same operations produce identical results
//! - **Functional and Mutable APIs**: Both persistent and in-place update paths exist
//!
//! ## Lean Correspondence
//!
//! Resource concepts correspond to `lean/Runtime/Resources/HeapModel.lean`.
//! The Lean parity lane mirrors canonical encoding, tagged preimages,
//! ordering rules, and proof-path structure. Digest computation remains a
//! published-vector conformance target rather than a Lean-native hash model.
//!
//! ## Example
//!
//! ```rust
//! use telltale_runtime::heap::{DefaultHeapHasher, Heap, Resource};
//!
//! // Create a new heap
//! let heap = Heap::<DefaultHeapHasher>::new();
//!
//! // Allocate a channel resource
//! let (channel_id, heap) = heap.alloc_channel("Alice", "Bob");
//!
//! // Allocate a message
//! let (msg_id, heap) = heap.alloc_message(
//! "Alice", "Bob", "Ping", vec![1, 2, 3], 0
//! );
//!
//! // Read a resource
//! let resource = heap.read(&channel_id).unwrap();
//!
//! // Consume a resource (adds to nullifier set)
//! let heap = heap.consume(&msg_id).unwrap();
//!
//! // Resource is now nullified
//! assert!(heap.is_consumed(&msg_id));
//! ```
pub use ;
pub use Heap;
pub use ;
pub use ;
pub use ;