Native Nyxus graph
Use the shared graph guide for application ownership, record-ID mapping and comparison with Minima's provider/workspace API.
NyxusGraph::new(vertices, reverse) constructs an exact directed, labelled,
weighted relationship collection in native retained containers using the explicit
Nyxus allocator. It requires no Store handle, stable-memory provider or collection
ID. An application's private Data owns it beneath its ordinary root composition.
Pin NyxusGraph::CONTRACT in the owning memory's dependencies. That constant pins
this package's complete graph interpretation; it deliberately does not claim to
be a standalone compiler/allocator certificate. Store's Catalog::digest always
includes cdk_rsx_engine_nyxus::ALLOCATOR_POLICY and MODULE_POLICY; the rooted physical digest
also includes COMPILER_SOURCE_CLASS and the complete kernel/owner field closure.
Thus a generated application root composes graph source, Nyxus allocator, compiler
recipe, native directory, buffer and scalar layouts before opening any pointer.
An independent consumer outside Store must supply the equivalent complete physical,
allocator and compiler contract itself. NyxusData alone is not that proof.
Logical vertex IDs are dense u64 values in [0, vertex_count). They are unrelated
to physical addresses and do not assert that a foreign business record is alive.
An edge is (target:u64, relation:u32, weight:u32). Identity and sorted order use
(relation,target) within a source; weight updates preserve identity. Zero values
and self loops are valid. Incoming results use predecessor IDs in target.
The optional reverse index is maintained exactly with each mutation.
upsert, remove and grow_vertices change revision only when the logical graph
changes. Growth appends IDs, preserving existing IDs and edges; shrinking rejects.
apply_batch has input-order sequential semantics: previous values retain input
order, repeated identities observe intermediate values, and each real transition
advances revision. All argument vertices validate before any mutation. Allocation
or internal failures trap; the IC supplies rollback, with no local transaction
promise for a returned error.
neighbors lends sorted native edges within the graph's borrow.
neighbors_into fills caller scratch using an exclusive logical EdgeKey anchor;
arbitrary anchors and zero-size output are valid. Pagination is weakly consistent
across mutations. No reference, owner guard or iterator may cross await.
Callers build intersections, recommendations and traversals over the actual
sorted edge/vertex IDs returned by neighbors and neighbors_into. They own
work limits, result bounds and transient scratch. The SDK supplies no native
persisted traversal cursor.
A shared &NyxusGraph implements
cdk_rsx_graph::AdjacencyRead directly, without a
provider, workspace or mutable graph loan. Minima graphs expose that logical
interface through a borrowed adapter. Both backends can use merge_neighbors
to emit exact common identities with both original weights from sorted pages.
The native oracle tests show graph construction, mutation and bounded queries. Native tests and compile-time physical gates are separate from the IC lifecycle checks described in testing.
Small neighborhoods use sorted contiguous retained edge buffers. Above 512 edges, a row promotes to sorted native leaves with at most 1,000 edges each. A compact directory stores each leaf's maximum key and exact cumulative rank; seeks read the directory and the selected leaf, while sequential iteration crosses leaves without flattening. The 16,000-byte leaf payload leaves room below the current allocator's 16 KiB span boundary. Interior insertions split a full leaf; tail appends preserve full old leaves. Deletions may merge adjacent leaves, and a row returns to a flat buffer at 256 edges. Empty rows release all backing. Exact-size unfiltered, unanchored iterator lengths read row metadata without edge payload.
Batches retain sequential results while grouping independent identities and maintaining the exact reverse projection. Flat rows merge larger sorted groups; large rows edit selected leaves and compact suffix-rank metadata. Preparation, sorting, rank maintenance and native allocation are explicit work. There are no tombstones, persisted transient caches or deferred reverse maintenance. This representation uses larger vertex-directory rows and may leave spare leaf capacity; read, seed and mutation costs depend on degree and allocator placement. Performance qualification and superseded alternatives belong in dated evidence.
Vertex directories contain a row for every admitted logical vertex. Releasing an empty adjacency frees its edge backing; directory growth still initializes the admitted rows. Bounded leaf shifts do not make total hub mutation constant time: suffix ranks and directory growth remain work.