Minima fixed-width collections

Experimental collections over cdk-rsx-engine-minima. Retained Nyxus descriptors and scalar control own fixed payload bytes in exclusive stable blocks. Minima explains the physical contract, provider setup and restoration. Crate-local tests and the paper collections' source modules contain native oracle examples; actual IC KEEP, rollback and cost qualification follow the testing guide.

The shared graph guide covers this crate's mutable and frozen exact relationships, distinct from the approximate graph cutset sampler.

Core collections

Type Construction and access Constraint
FixedVec<T> new, push, extend_from_slice, pop, get, set, set_slice, get_many, scan Nonzero fixed values fit one 4 KiB node; contiguous slice writes and sorted grouped reads
SlotArena<T> new, allocate, allocate_from_slice, contains, get, get_many, set, remove, remove_discard A 16-byte slot header plus value fits a node; IDs include collection and generation; grouped reads are sorted by slot index
BitmapSet new(storage, id_bound), insert/insert_grouped, remove/remove_grouped, contains/contains_grouped, range Exact IDs below the bound; grouped inputs are sorted; allocation grows through the highest used block
FrozenHashMap<K, V>, FrozenHashSet<K> build with HashBuildConfig; get/contains, get_many/contains_many Finite transient build; duplicates reject; at most two buckets per scalar lookup; grouped requests preserve caller order; bounded reseed/growth can reject
FrozenSortedMap<K, V> build/from_sorted with SortedBuildConfig; get, get_many, scan Frozen ordered keys; duplicates reject; from_sorted requires increasing keys; bounded output scans
FrozenPrefixSums from_slice, prefix, prefix_many, sum Immutable nonnegative u64 sequence; sorted prefix endpoints use caller-owned output; total overflow rejects before allocation
BlockedBloomFilter<K> new/from_keys, insert, may_contain, prepared grouped probes Additive approximate membership; positives require exact lookup; no deletion
CountMinSketch<K> new, positive weighted add/add_many, estimate/estimate_many, estimate_many_with_scratch, additive merge Four 2,048-counter rows; no decrements or key enumeration; overflow rejects before writes
BlockedCountingBloom<K> insert, remove_known_present, may_contain, batch variants Eight banks of u16 counters per 512-byte block; every change must follow an authoritative exact-set transition
CuckooFilter<K> try_insert, remove_known_present, may_contain Four 16-bit fingerprints per bucket; bounded relocation can return unchanged Full before nominal capacity
FrozenBinaryFuse<K> build, replace, may_contain, may_contain_many Sealed 16-bit membership filter; bounded construction and scratch; strict false-positive space tradeoff, not a universal Bloom replacement
MinimaHll<K, P = 12> new(storage, seed), observe, observe_many, estimate, merge, clear Dense approximate distinct counts; P is 8..=16; merges require matching precision/key/hash contract and seed

All descriptors are move-only Nyxus Data; decoded keys/values and workspace are transient. An empty collection can claim no payload blocks. First storage rounds to exclusive 64 KiB blocks, even for a small bitset or P=12 HLL's 4 KiB register array. Clearing/replacing/dropping an owner reclaims only its whole blocks. Frozen indexes are rebuilt for changed content; they do not support point insertion. HLL's nominal error is statistical, not an exact-count guarantee.

Paper collections

These are thirteen additional algorithm directions. Rateless IBLT's encoder and decoder are two owners implementing one reconciliation capability. Source links own the complete APIs, limits and algorithm definitions; their provenance and NOTICE records identify primary papers, reference revisions and licenses.

Type and source Construction and access Implemented variant and caller contract
FrozenRibbon&lt;K, VALUE_BYTES&gt; build/replace with RibbonBuildConfig; retrieve Standard Ribbon with 64 contiguous coefficients and exact assigned fixed bytes for build keys; bounded elimination/reseeding; no BuRR bumping or compression; unknown keys return arbitrary bytes
RatelessEncoder, RatelessDecoder Encoder new, add_sorted, next; decoder new(DecodeConfig), feed, advance, difference Incremental rateless IBLT over immutable sorted u64 sets; bounded retained work/progress; signed differences are readable only after Complete; caller authenticates matching snapshot/version streams
MementoFilter new(MementoConfig), try_insert/try_insert_many, may_contain/may_contain_range, remove_known_present/remove_known_present_many, check_integrity Fixed-geometry integer partitioning, quotient runs and compressed keepsakes; payload-local edits still scan compact metadata; exact set authorizes each transition; no fluid expansion
SetSketch&lt;K, M, BASE_MILLI, MAX_RANK&gt; new(storage, seed), observe/observe_many, estimate, joint/joint_many, joint_many_with_scratch, merge, clear Independent exponential-hash SetSketch, corrected cardinality and comparison-likelihood Jaccard estimates; direct O(M) updates; matching key/configuration/seed for union; no member enumeration
BreadcrumbFilter&lt;K&gt; new(BreadcrumbConfig), try_insert, may_contain, count, remove_known_present, scan_fingerprints Scalar C=2 primary/overflow mini-filters with breadcrumbs; counts and enumeration describe colliding fingerprints, not original keys; exact multiset authorizes changes
QSketch&lt;K, M, W&gt; new(storage, seed), observe/observe_many, estimate, merge, clear; W: ImmutableWeight<K> Quantized independent exponential registers and truncated maximum likelihood; each key has one pure finite positive immutable weight; duplicates do not add weight; direct O(M) update, no QSketch-Dyn
OmniSketch&lt;K, V, ATTRS, ROWS, WIDTH, SAMPLES&gt; new(storage, seed), append, query with OmniPredicate, merge_disjoint, clear Published append-only S1: configured attribute buckets and bounded bottom samples; equality conjunctions over any attribute subset; unique immutable record IDs and disjoint merge inputs; no range predicates or S2 deletion support
DDSketch&lt;BINS&gt; new(storage, config), observe/add/observe_many, quantile(numerator, denominator), quantiles_many, merge, clear Fixed positive numeric range plus exact zero; sorted rational quantiles share one counter scan; positive integer weights; configured relative error subject to floating-point rounding; negatives/nonfinite/out-of-range values and overflow reject; no bin collapse
ExaLogLog&lt;K, P&gt; new(storage, seed), observe, observe_many, estimate, merge, clear Paper's dense t=2,d=24 registers, aligned history union and maximum likelihood; batches borrow grouping scratch; no sparse mode, precision reduction, martingale estimate or optional finite-M bias correction
FrozenZor&lt;K&gt; build/replace with ZorBuildConfig; may_contain Five-segment peeling/intervention plus mandatory exceptional-key auxiliary; no false-negative pure variant; a positive still needs exact membership evidence
AerisFilter new(AerisConfig), try_insert/try_insert_many, may_contain_range, remove_known_present/remove_known_present_many, refine_false_positive Fixed-geometry growing prefix-free keepsakes; adaptation follows confirmed false positives using complete authoritative backing keys; bounded slots/hash length can reject unchanged; refinement must commit in an update
ExternalGraphSketch new(storage, vertices, seed), ingest/ingest_with_scratch, bounded flush, sample_cut with CutScratch, sample_prefixes Buffered vertex GF(2) cutset sampling for exact-authorized simple undirected graph changes; flush before extraction; NoSample is inconclusive; no full connectivity, MST or sparsifier API
FrozenPhobic&lt;K&gt; build/replace with PhobicBuildConfig; index PHOBIC optimized buckets, partitioned placement and interleaved bit-packed seeds; collision-free permutation for build keys; Some(index) does not establish unknown-key membership; directory metadata and whole blocks remain overhead

Normal preflight rejection leaves existing published payloads unchanged; incremental APIs separately retain their admitted bounded progress. Mutating backend failures trap and rely on IC rollback. Builders, staged images, sorting, retained directories, auxiliary filters, buffers and caller scratch are part of total cost. A smaller logical sketch payload does not imply a smaller physical allocation or cheaper complete IC operation.

Caller contracts

Ribbon retrieval and PHOBIC indexing require an independent membership decision when the caller does not already know the key. They are different from a membership filter, whose positives still require an authoritative exact lookup. ZOR always retains its exceptional-key path; omitting that path would lose keys.

Memento, Breadcrumb and Aeris require exact set/multiset evidence for mutations. Aeris removal takes the complete exact backing set before removal; remove the exact key only after success, in the same synchronous committed update. Refinement also takes the complete backing set for that dataset, including keys outside the false-positive query range. Read-only Aeris queries do not adapt.

Memento and Aeris mutation batches accept at most 1,024 keys and return one outcome per input in order. They decode once, check each intermediate insertion's capacity, and publish at most once. A rejected insertion does not discard earlier successes; a later input can still succeed. Aeris batch deletion takes the exact backing set before the complete batch and preserves colliding stored identities until their final exact key is removed. Commit matching exact-set transitions in the same synchronous update.

ImmutableWeight is a mathematical function of canonical key identity. Pin its source/configuration in its CONTRACT; changing a repeated key's weight violates QSketch's model. Count-Min and DDSketch instead count repeated observations. OmniSketch appends distinct immutable records; it cannot verify global ID uniqueness or disjoint merge inputs from bounded samples. Its estimates can have large relative errors when few samples survive a conjunction.

Count-Min grouped estimates accept at most 4,096 keys and preserve input order, including duplicates. estimate_scratch_len returns four CountMinQueryEntry entries per key, four bytes each, for estimate_many_with_scratch; the caller also supplies one output entry per key and a workspace. Only the used scratch prefix is overwritten. The convenience estimate_many allocates grouping scratch for populated nonsingleton batches. Its singleton uses scalar access without that allocation. Grouped reads fetch a bounding span per active source node and skip later counters after a zero minimum. Bounds/provider rejection precedes output changes; a backend read failure may leave partially updated output. This is borrowed transient preparation, not a stable-data cache or a local transaction.

SetSketch joint_many compares one reference with at most 4,096 compatible peers in the supplied order, including duplicates, using one output per peer. It reads the reference and computes its corrected cardinality once. A singleton uses the scalar path; references of at most 2,048 registers reuse the two supplied node workspaces without allocation. Larger references allocate at most 64 KiB, or joint_many_with_scratch borrows at least PAYLOAD_BYTES of caller scratch and one node workspace. Both methods retain the scalar register comparisons and likelihood. Contracts, seeds and providers are checked before output changes; later read, corrupt-rank or saturation errors can leave a completed output prefix. Scratch holds no authority and is rebuilt on every call.

OmniSketch's CELL_BYTES, CELLS_PER_NODE and NODE_COUNT expose its fixed packing geometry. Complete cells include their header and all configured sample slots, remain within one logical node, and participate in the interpretation contract. Grouped queries retain logical cells_read counts even when several selected cells share one provider read. Allocation rounds to exclusive blocks.

Rateless sessions retain their snapshot identities until complete or explicitly discarded. Work limits, insufficient symbols and checksum failures do not prove reconciliation. Graph changes must mirror successful exact-graph transitions; duplicate toggles violate the simple-graph model. A sampled cut edge is a probabilistic extraction, while NoSample never certifies an empty cut.

Fixed values and borrowed workspace

use cdk_rsx_collections_minima::{
    FixedBytes, FixedText, FixedVec, NodeBuffer, Result, Storage,
};

fn values(storage: &mut dyn Storage) -> Result<FixedVec<u64>> {
    let mut buffer = NodeBuffer::new();
    let mut workspace = buffer.workspace();
    let mut values = FixedVec::<u64>::new(storage)?;
    let index = values.push(storage, &42, &mut workspace)?;
    assert_eq!(values.get(storage, index, &mut workspace)?, Some(42));
    Ok(values) // move into the owner's retained Data
}

let bytes = FixedBytes(*b"0123456789"); // exactly ten bytes
let text = FixedText::<4>::new("éé")?; // four UTF-8 bytes
# Ok::<(), cdk_rsx_collections_minima::Error>(())

Integers use fixed little-endian bytes. Arrays, tuples and fixed_record! compose fixed fields without per-entry lengths, tags or Rust-layout padding. Exact text has no truncation or ambiguous padding. FixedKey additionally pins canonical equality bytes and comparison semantics. Collection geometry checks execute at compilation; dynamic bounds and live generations remain checked.

One caller-owned NodeBuffer lends a thin Workspace sequentially to many collections. Stable source nodes remain aligned; scratch destinations need no special alignment. Scalar APIs copy only their known span: a vector value, bitmap byte, HLL register or 32-byte Bloom block. Grouped reads fetch one bounding span per needed logical 4 KiB node. Supply nondecreasing indices for FixedVec::get_many or BitmapSet::contains_grouped; SlotArena IDs must share its owner and be ordered by slot index. Duplicates are visited separately; stale slot generations and missing slots yield None. Bloom probes are prepared explicitly and sorted by page().

FrozenHashMap::get_many, FrozenHashSet::contains_many and FrozenSortedMap::get_many accept arbitrary key order and fill equally sized caller-owned outputs in request order. Hash batches group primary buckets, then backup buckets for misses, using transient bucket/index scratch. Duplicate requests remain separate. Length mismatches reject before allocation or output changes; later read/decode errors can leave completed output positions changed.

SlotArena::allocate_from_slice returns a transient Vec<SlotId> in scalar allocation order, including free-slot reuse. It checks counts, addresses and free headers before mutation and writes adjacent complete slots per node. Reused slots add a transient index permutation; include its preparation and the returned vector's allocation when comparing with scalar calls.

SlotArena::remove_discard checks the same address, header and generation as remove, but discards the encoded payload without decoding it or borrowing a workspace. It reads and writes only the 16-byte slot header. It does not validate the payload's encoded bits; use remove when that validation or its decoded value is needed. Both preserve free-list order and retire saturated generations.

FixedVec::extend_from_slice returns the appended index range; set_slice replaces an in-bounds contiguous range. Both encode one write per occupied node span without reading old values or clearing node tails. prefix_many requires nondecreasing endpoints in 0..=len and an equally sized output slice; repeated endpoints are allowed. It reads each interior node group once and uses retained totals for endpoints zero and len.

DDSketch::quantiles_many takes at most 4,096 nondecreasing rational probabilities (numerator, denominator), with nonzero denominator and numerator <= denominator. The equally sized caller output preserves repeats; an empty sketch yields None. It shares a counter scan and the normal workspace. ExaLogLog::observe_many accepts at most 4,096 keys plus at least one reusable ExaLogLogBatchEntry per key. It hashes and sorts that scratch internally, so keys need not be sorted, then reads and writes grouped register spans. Its statistics count final changed registers, not intermediate scalar changes.

Include preparation and sorting in performance measurements. Prefer scalar calls when already distant requests provide too little page reuse to repay that work. Repeated narrow reads of one source page may lose first-read eligibility. HLL, SetSketch, QSketch, ExaLogLog and OmniSketch merge explicitly need two buffers; check each signature for their borrow order. Other algorithms expose additional bounded scratch or work budgets.

Visitors consume decoded owned values synchronously. No node view, workspace, module guard or provider loan may cross await. Scalar HLL also exposes observe_with_scratch when a full node workspace is unnecessary.

Sketches and deletable filters

Count-Min estimates the frequency of a supplied key; it cannot discover the most frequent keys. Its positive updates can overestimate through collisions. Merge adds matching matrices and is not idempotent. Convenience batches select sparse or dense staging; caller-scratch APIs expose that choice. Dense batches and merges stage a bounded 64 KiB proposed matrix before overflow admission.

Counting Bloom and cuckoo filters do not establish exact membership. Insert only after a successful absent-to-present transition in the exact set; delete only after a successful present-to-absent transition. Skip duplicate insertions and absent removals. If a filter rejects after the set changed, trap the IC update to roll both back. Never delete based solely on may_contain.

Binary fuse consumes the complete deduplicated set and verifies all original keys before publishing a replacement. It trades build scratch and immutability for dense fingerprints. Hashes are pinned by each type's contract and retained seed; statistical errors/false positives are not adversarial guarantees.

Root ownership and admission

Store Root and these descriptors in private root-attached Nyxus Data. Construct collections through the shared Arena/Storage; moving a complete descriptor into Data publishes ownership. Drop returns owned blocks through retained authority without consulting a transient active-provider context. Nonowning SlotId/collection identities do not manufacture another durable owner.

A retained Option<SlotId> in Nyxus Data fails layout admission. Declare explicit cases such as Shelved = 0 and Borrowed(SlotId) = 1 in the owner's versioned memory. Store tagged-enum recipe

Retained admission carries each selected carrier's interpretation policy automatically through its required NyxusData proof. Typed CONTRACTs include the owning production source, shared helper algorithms, base engine and erased logical Fixed::CONTRACT parameters. Value-specific MementoConfig::contract(), BreadcrumbConfig::contract() or AerisConfig::contract() remain explicit dependencies when an owner pins that configuration. Custom fixed encoding, comparator, immutable-weight and other interpretation sources remain explicit owner dependencies. Changing codec, ordering, hash or geometry requires explicit owner conversion under the upgrade contract.

Per-collection source recipes use explicit production file closures. They exclude test items, documentation and unrelated collection implementations while retaining the complete relevant helper source. This runs on the build host and emits constant digests; no runtime source enumeration or hashing is added.

The foundation README owns single-provider Hylix composition, teardown and Arena::open restoration. Minima does not add a third Store Memory selector or alter the existing Hylix/Nyxus engine paths.

Package guides

Minima guide, Algorithm inventory.