Native representation certificates

const ABI: Physical = physical::<Concrete>(); compiles the actual target's field/pointee graph, including private standard-library allocation nodes. physical_type(TypeId) also admits explicitly exposed private allocator roots. Target sizes and alignments are frozen during const evaluation. The cold, allocation-free ABI.digest() hashes those facts and exact array lengths from fresh compiler metadata. The metadata is transient; only the digest may enter the saved image. TypeId numbers, vtable addresses and code pointers do not enter the hash.

Ordinary Physical catalogs retain no full compiler type names or name-method vtables. Diagnostic tools explicitly request const INFO: PhysicalDiagnostics = physical_diagnostics::<Concrete>(); and call INFO.visit(|name, size, align| ...). physical_diagnostics_type(TypeId) covers private allocator roots. INFO.physical() exposes the identical certificate; names contribute neither physical nor interpretation identity. Both constructors use the same const-only traversal, so enabling diagnostics changes no admission rule and requires no application-wide feature.

The const-only builder has explicit work limits. Only visited records are frozen into immutable compiled slices; unused capacity is not emitted into the bounded static window. A runtime Physical holds slice references, not a padded graph. The physical graph bounds are 512 types and 4096 edges. A separate 2048-type scratch bound compiles the interpretation closure; only its used, flat proof metadata is emitted. These are compile-time work bounds, not per-record storage allocations.

Physical::interpretation_digest() folds required NyxusData policies from the physical graph. A retained CodecCarrier, currently Store's Record<Data>, separately seeds a codec-only walk of its complete encoded payload. That walk includes logical generic/field types such as erased collection keys and values; an unused Codec implementation on native data contributes no codec policy. The unsafe carrier proof requires exactly one logical type argument, and const construction checks its shape and compiled Codec proof. Each walk uses a visited set, so recursive types do not evaluate recursive policy constants. Owning module markers are separate catalog entries. The physical nodes, edges and digest() remain independent of this policy slice: ordinary physical binding does not traverse or hash interpretation metadata. Only catalog admission combines both digests.

catalog_digest(&[&Physical], &[[u8; 32]], &[[u8; 32]]) combines independent physical, semantic and policy inputs. Its build-generated source class qualifies the compiler executable/driver/LLVM, complete pinned standard-library source, target facts/flags and this crate's recipes. It never hashes the application executable or unrelated business code. A different compiler is rejected even if the currently measured fields happen to match. The source class complements the measured private layouts; a compiler fingerprint alone cannot describe them. The qualified build path uses that pinned source with -Zbuild-std=std,panic_abort and checksum-fresh dependencies. Hashing rust-src does not prove an arbitrary prebuilt standard library was compiled from it; that build path is mandatory. The hashed generator manifest pins its complete syn/quote/proc-macro2/unicode-ident dependency set. The qualified build uses their unpatched registry identities and locked checksums; arbitrary Cargo dependency overrides are outside this class.

Store's catalog::<Root>() compiles the owning module type closure from certified Children, ChildSlot and ChildMap declarations, adding allocator roots, directory and kernel policies. Generated SDK roots derive the catalog from their actor service and add explicit application policies. Reflecting an outer record alone cannot discover child types behind opaque IDs. See upgrade admission. semantic_source frames each frozen memory version and its custom Ord/Eq/Hash/Drop dependencies. Active configuration that selects different semantics belongs in those inputs too. Equal field layouts do not authorize a changed comparator; conversion must reindex it. Raw source text is const-hashed before catalog composition, keeping it out of Wasm statics. semantic_contract(version, inputs, dependencies) additionally frames selected generic payload/child contract digests without converting them to source text. Nyxus's ALLOCATOR_POLICY and Store's MODULE_POLICY qualify their kernel sources. Actual carrier proofs supply their complete implementation-family, helper and engine recipes; concrete encoded key/value contracts remain included. There is no root-wide Collections/Wire fallback. Derived proofs hash selected declaration tokens, while custom Ord/Eq/Hash/Drop, serializer, saved-Wire and configuration contracts remain explicit frozen-owner inputs. The mechanism collects implementation policies; it does not prove arbitrary semantic equality.

The package is not upgrade authorization by itself. A lifecycle must compare the saved catalog with its compiled current or exact predecessor catalog before opening any retained pointer, dispatch the exact source reader, and publish the target only after successful conversion. The SDK typed-root startup guard owns this ordering. Native metadata checks do not by themselves qualify an application lifecycle.

cdk-rsx-wasm prepare consumes a nonallocating internal __cdk_rsx_memory_abi_admit(i32) -> i32 hook and requires an explicit pre-upgrade hook. On KEEP it first validates fixed bootstrap words and the old-code clean marker at base+80, consumes that marker, replays new statics, then requires admission to return exactly one. Marker consumption makes the next skip-pre-upgrade fail even when a custom original lifecycle omits the SDK's additional running marker. Only then does it call the original post-upgrade lifecycle. Init calls admission with zero after replay; KEEP uses one. There is no ordinary or exact-artifact fallback path. The hook must validate the complete catalog and selected source version; the transformer cannot infer those policies or prove its Rust body allocation-free. Actual typed-root KEEP qualification is still separate from native metadata checks and artifact transformation.

Startup ordering is: fixed raw bootstrap and successful old-code shutdown marker; replay new transient statics; compute the target digest without allocations; validate the accepted source class/contract; then open the retained allocator and interpret native pointers. Fresh vtable metadata must never be read before new passive segments are initialized. IC rollback makes a digest rejection atomic.

The initial recipe covers sized records, Vec/VecDeque element allocations, concrete Rc, BTreeMap/BTreeSet private leaf/internal nodes and RefCell/Cell infrastructure. MaybeUninit is a storage recipe, not a claim that unused array elements, inactive parent indexes or padding are initialized. The pinned std algorithms determine initialized prefixes and leaf/internal allocation selection.

The private standard-library Rust enum recipe is a two-case None/Some layout whose Some payload has exactly one NonNull niche and no padding or other invalid bits; equal size and zero Some offset leave no room for a separate discriminator. This covers private BTree roots and parent links. Arbitrary enums and ordinary Option<u64> reject at compile time. Source-controlled application enums use #[derive(cdk_rsx_memory_abi::Tagged)] on repr(C,u8) payload or repr(u8) nullary declarations. Every case requires an explicit unsigned-byte literal. The derive emits immutable tag names/values; reflection measures actual variant fields and offsets. The cold digest checks both descriptions match and frames tag width, values, names and payload graph. Other representations reject. Rust selects cfg input before derives; freeze that selected configuration in the semantic contract. The generated raw metadata receiver requires the pinned arbitrary_self_types_pointers feature and never forms a data reference. Unsized Rc allocations and HashMap erased tables remain unsupported.

Two pinned reflection MVP bugs have bounded workarounds: Type::info panics on tuples, so a sealed tuple marker selects the kind while normal reflection still measures fields; array_len panics on private constant aliases, so a sealed [T; N] raw-pointer metadata method supplies exact N, including zero-sized values. RawVec's capacity scalar and NonNull's pattern pointer have explicit narrow source-qualified recipes. Other pattern types remain rejected.

The pinned reflection MVP also misses the Hylix metadata blanket when it repeats an explicit 'static bound already guaranteed at the TypeId boundary. The Codec bridge and Record proof deliberately avoid that redundant spelling. Focused tests assert actual bridge selection and changed interpretation for erased record/map key/value codecs, separately from equal physical layouts. Native recursive Rc<Self> has its own const-construction check. These are tested compiler-recipe constraints, not a general Rust ABI guarantee.

License

This crate is available under the ICP3V License.