Opaque module memories
cdk-rsx-store owns the typed module tree, owner-private memory keys, scoped
read/write views, child attachment accounting, explicit conversion and root
lifecycle. Store is its transient capability; Actor<M> binds the active root.
Services hold nonowning ModuleRef identities and project one existing access
frame through binding::Memory/MemoryView.
A frozen Nyxus memory version declares separate Data: NyxusData and
Children: ModuleChildren. Use #[cdk_rsx_store::memory(owner = crate::owner)]
to generate its opaque marker, private KEY, source contract and actual-cell ABI;
add children = Children when needed. Nyxus is the default engine; the explicit
hylix option selects Hylix for the complete Data record. Each owner may compose
several private memories with different engines and attach them at any depth.
catalog::<Root>() compiles the complete
owning type closure instead of maintaining a separate list of module types.
Writable references expose only Data. ChildSlot and
ChildMap keep attachments private, require a write Scope to mutate, and cannot
be moved into ordinary retained data. Detached children may be created, moved
and attached inside one frame. Unattached candidates retire when that frame ends;
ordinary service references never pin a module. Module keys stay private to the
owner's memory folder.
Store depends on Nyxus, Hylix and Platform, not Collections. Its directory and child maps use std containers with explicit Nyxus directly. Public container algorithms and their semantic recipes remain with Collections. Native module cells retain their actual private RefCell/children carriers, exposed solely as PhysicalModule/PhysicalDirectory roots for compiler-derived certificates.
The persisted directory links vacant slots through their unused pointer words. Creation pops the head or appends, checking global generation exhaustion before mutation; retirement pushes a slot back without scanning live modules. Slot storage retains its peak capacity, and fresh generations reject earlier bindings.
Wasm initialize/reopen retains the selected admitted directory-pointer cache,
slot namespaces/generations, binding epochs and scoped loans. Reopening requires
the complete closed ABI/source catalog before typed-pointer interpretation.
MODULE_POLICY: [u8;32] is a build-host hash of the exact backend/access/children
rules; include it with engine/Collections policies and admitted module roots.
Native failure poisoning remains test-host behavior; IC rollback owns atomicity.
No journal or second transaction system is introduced.
hylix::Record<D> selects Hylix records inside this same module tree.
The native module Data is only the record's allocation identity; D: HylixValue
contains scalars and fixed-size stable collection handles. The memory attribute's
hylix option generates the ordinary ModuleMemory and Hylix module contracts.
The owner uses hylix::binding::Memory and hylix::create. The first access
decodes the module record into the actor frame; later guards borrow its current
value under the existing native module borrow. Successful frame finalization
publishes each remaining dirty record once and discards the decoded workspace.
Read-only frames do not publish. Retirement/conversion consumes the current
buffered value before freeing its record. Collection entries remain separate
stable allocations: their Edit guards still publish rows on Drop. No guard
exposes a reference into stable memory or may cross await.
Attach one exclusively owned stable arena with Store::with_hylix before
installation/opening. Existing Actor read/write frames activate read-only or
mutable byte access once per scope. Recreate and explicitly open the arena after
transient teardown; never format on an unknown saved contract. The directory,
native cell descriptors and child-attachment metadata remain retained in this
shared engine composition. Domain scalar and collection data may be stable,
but this does not support an upgrade that discards the retained heap.
Provider finalization after the callback traps on failure; ordinary returned
business errors still finalize writes. See the
Hylix provider contract.
Stable ownership transfers are explicit. A newly constructed carrier supplies
one owner; insertion or Record construction consumes that owner. Snapshot Drop
does not retire resources, and unchanged writeback does no retain/release scan.
Move or explicitly retire displaced fields and removed entries; explicitly share
before persisting an additional shared edge. True module retirement delegates to
the complete compiled HylixValue::retire recipe. Owner-local conversion uses
Record::into_value to free the old record while moving its nested handles into
the successor. Store does not know concrete collection types.
Current application patterns are in conventions, with engine boundaries, upgrade admission and qualification guidance.
Package guides
Authoring, Architecture, Upgrades.
License
This crate is available under the ICP3V License.