ARCH2.md (1246B)
1 # ARCH2 - BOLT #1 Stabilization Architecture Notes 2 3 ## Goals 4 5 - Complete fundamental type coverage (signed + truncated unsigned ints). 6 - Tighten protocol validation (feature padding, message size limits). 7 - Clarify extension TLV handling in the API surface. 8 - Decompose the monolithic module into focused components while 9 preserving existing public API via re-exports. 10 11 ## Module Responsibilities 12 13 - Lightning.Protocol.BOLT1.Prim 14 - Integer encoders/decoders, BigSize, truncated integers. 15 - Minimality and bounds checks. 16 17 - Lightning.Protocol.BOLT1.TLV 18 - TLV record/stream types and parsing strategies. 19 - Extension TLV validation policy. 20 21 - Lightning.Protocol.BOLT1.Message 22 - Message ADTs, feature bitset helpers, init TLVs. 23 - Invariant enforcement for message constructors. 24 25 - Lightning.Protocol.BOLT1.Codec 26 - Message payload encoding/decoding. 27 - Envelope handling and message size limits. 28 29 - Lightning.Protocol.BOLT1 30 - Re-export of public API for external consumers. 31 32 ## Validation Strategy 33 34 - Reject non-minimal BigSize encodings. 35 - Reject unknown even TLVs in extensions unless the caller uses a 36 raw/unsafe TLV decoder explicitly. 37 - Enforce byte-aligned init feature bitsets. 38 - Enforce maximum 65535 byte envelope size. 39