Ashroot operation cost model and coverage ledger

3 November 2026. Source inspection at newstack a055647635638f0fbf2822fb9f9cae0348d824c6, SDK 51f050bae1ea43114c95bd21010355bf67163220. This is a benchmark design and source review, not a measured overhead claim. No product or fixture was changed for this review.

The requested question is: how close is an Ashroot operation to a well-structured implementation of exactly that operation? An existing handwritten application is not automatically the answer. Its structures, algorithm, safety checks and ownership work must first be reviewed against the required behavior.

What the comparison must show

Keep three related results, rather than naming an unproved globally optimal implementation a theoretical instruction floor:

  1. Structural lower bound: required logical searches, entry mutations, row decodes, ownership transfers and retirements. This can expose unnecessary work even when an existing SDK API cannot implement the best search path yet.
  2. Best-known direct reference: small handwritten, owner-private code using the best supported structure and safe algorithm for that case. It must have the same integrity, error, bound, ordering and retirement semantics. Inspect the underlying SDK primitive too; do not reproduce a bad adapter sequence.
  3. Ashroot: identical logical schema, inputs, starting population, observable results and required lifetime behavior through the public API.

Also measure an empty matched actor/Store/Wire frame. Report complete direct and Ashroot costs first, their absolute difference, and the difference relative to the direct implementation. Show frame-subtracted figures as additional context; they are not a replacement for complete IC instructions and page charges. Page charges are already included in complete replicated instructions.

"One insert" below means one logical collection mutation. A B-tree insertion can compare several keys, visit several nodes, split nodes, allocate storage and write several spans. Those physical costs must be measured separately. Five logical writes do not imply five stable writes or a constant instruction cost.

For a successful insert into one ordered primary table and four nonunique, nonsparse indexes, the mutation floor is one primary insertion plus four secondary insertions. Add the primary-presence decision, one row validation and four projections. A retained vacant-entry/search path can fuse the primary decision with insertion; a separate get followed by insert searches twice. Unique and foreign constraints add real preflight work; they are not framework overhead to subtract away.

Notation and structure choices

P is a primary search, V a full row decode/read, W a primary insertion or replacement, D a primary removal, J+/J- one secondary insertion/removal, U one uniqueness decision, F one parent-identity decision, S+n one ordered seek followed by n visited entries, and R retirement of an actual displaced owner. Counts refer to data operations, not SDK frame/header checks. i is the number of present indexes; c is the number of changed projected keys, and c_old/c_new count present old/new keys among those changes.

Engine Required reference representation for its main comparison Physical counters
Nyxus SDK Nyxus-allocated primary map and ordered index sets; resource-owning rows use admitted owners Key comparisons, tree searches, allocator calls/bytes, drops and retained capacity
Hylix Stable primary map and stable secondary collections with real branded ownership Provider reads/writes/bytes, node visits, key/value decodes, allocation/deallocation and actual owner retirement
Minima Ordered retained PK directory plus live-generation SlotArena payloads; retained ordered indexes, matching the supported hybrid representation Directory searches, slot-header/payload reads, encode/decode counts, workspace loans and stable writes

Minima arbitrary logical keys cannot be replaced with dense slot indexes to remove the directory. Presence must still reject stale directory-to-slot identities. Hylix keys-only work should decode no row payload; fixed descriptor decoding and copying the body of an owning Blob/String are separate counters.

Review alternatives where a structure choice is itself suspect. A unique secondary Map<ProjectedKey, PK> may be preferable to a composite set queried by prefix. Sorted migration input may admit balanced bulk construction. Such alternatives are separate named algorithm/layout variants, with their own admission and ownership proofs; they must not be hidden inside an "overhead" percentage against a differently specified operation.

A small direct reference may put its private containers in one owner rather than copying Ashroot's gate-plus-table-child layout. Record that choice: the result includes layout/owner-access overhead, not only function dispatch. It must still support the compared lifetime/migration behavior and never expose mutable rows or derived indexes. A flat owner is not presumed universally best as table count grows. Measure the owner/frame component and collection work separately so a layout choice cannot disguise redundant tree work.

Complete public data-operation coverage

The main surface has nineteen Database entry methods, eleven TableRead methods and five IndexView methods. Aliases share reference implementations but each public spelling needs a coverage entry and a compiled invocation.

Public method(s) Structural floor / reference work Required distinct cases
Database::read Owner/health and selected-table admission; no collection operation until callback asks for one Empty callback, several operations in one read frame, wrong/poisoned access
Database::with_row, TableRead::with_row One P; hit lends/decodes one V, miss none; identical scalar mapper/output Hit, miss, owning payload projected without body copy, mapper reads selected fields
Database::contains_key, TableRead::contains_key One key-only P, zero V; Minima adds its live slot header Hit/miss, stale Minima slot refusal; SDK contains_by is the Hylix primitive
TableRead::len, is_empty Stored cardinality; zero tree walk and zero row decode Empty/nonempty, already-bound table versus full read envelope
TableRead::scan_keys S+n primary keys, zero V, bounded caller buffer Empty buffer, empty/reversed bounds, inclusive/exclusive bounds, exclusive after, full page and short final page
TableRead::rows, visit_rows One primary range seek, then exactly visited row reads; no result staging array Construction without consumption, limit zero, bounded prefix, mapper error, early drop, take, filtering with visit budget applied before filtering
TableRead::lookup One P for each consumed caller ID; one V per hit; order/misses retained Repeated/unsorted IDs, hit/miss mixture, zero/max bound, untouched iterator suffix, mapper/backend error
TableRead::index, query Borrow a statically selected capability; no tree work merely constructing the view Built-in query equivalence, one representative custom read capability; no mutable-state escape
IndexView::len, is_empty Stored index cardinality Sparse absent/present populations, empty/nonempty
IndexView::first One equality/lower-bound seek and selected ID; zero primary V Miss, unique hit, nonunique ties returning first PK
IndexView::scan, entries S+n secondary pairs, zero primary V; buffer/iterator bounds respected Same range/pagination cases as primary scans; zero consumption, fused error, early drop
TableRead::index_rows S+n secondary entries plus one primary P and V per visited hit Top 1/100, repeated projected keys, descending ties, early take/filter; stale secondary ID is corruption
Database::insert Primary vacancy decision fused with W where supported; validation, i projections, i J+, relevant U/F; actual input transfers once Success, duplicate, invalid row, unique refusal at each index position, missing parent, sparse keys, self-parent shortcut, owning input disposal on refusal
Database::replace One old-row decision/read; validation and old/new projections; c_old J- + c_new J+ + W + R; checks only relevant changed constraints Missing; no index changes; one/all changed indexes; absent↔present; unchanged unique/FK; refusal before mutation; owning replacement retires once
Database::upsert Insert or replace floor, without a separate full probe just to dispatch again Both outcomes plus their refusal cases; result discriminator and exact state
Database::update_with Existing-row read also supplies the factory; remaining replace floor; no reread just to build input Missing never calls factory; factory error; scalar/owning replacement; nested already-bound reads allowed by contract
insert_many, replace_many, upsert_many One frame/context for a prefix; per-row scalar floor in input order N=0/1/16/100; first/middle/last refusal; exact inserted/replaced counts; failed key; failed item consumed; suffix untouched; iterator/factory panic rollback
Database::atomic Successful closure's ordinary work plus an error branch; no overlay, journal or copy of the database Successful composition; early/late error traps whole IC execution; native failure requires discard/restore
remove, remove_with_effects Same operation with different result shape: required graph discovery, old-row reads, i J- + D + R for each deleted row; SetNull work separately below Missing, no dependents, Restrict, cascade tree/diamond/cycle, SetNull, all row/edge/byte refusals, actual trap rollback
remove_many One complete preflight over supplied roots; deduplicate affected rows and retire each once Duplicate roots still count against examined-root bound; missing root; shared descendants; mixed policies; no successful prefix on expected refusal
clear_table Enumerate that table's identities and enforce its relationship graph; bulk reset only where the same contract proves it valid Empty, bounded refusal, external incoming edges, self-Restrict/cycles, sparse indexes; do not substitute whole-domain semantics
clear_all Read counts for admission, clear primary/index ownership directly, retire all owners; no FK walk or per-row index projection Empty positive budgets, zero budgets, row/byte refusal, all tables/indexes empty, exact retirement and writable repopulation
Database::create, bind, minima_root Correct owner/child creation or binding/installed-contract validation; no primary-row scan for ordinary bind 0/1/many tables, indexes 0/1/4; valid/wrong resources, healthy/quarantined image; cold restoration and populated KEEP

For Rows, Entries and Lookup, exercise the implemented Iterator::next and size_hint and the fused end/error behavior. Standard iterator combinators are caller computation, not separate Ashroot storage algorithms. Count actual candidate visits, mapped rows and copied output bytes so a short result cannot conceal a full scan.

Descending order reverses the projected key, while the PK tie-break remains ascending. Reversing an entire (score, PK) iterator changes tie behavior and is not an equivalent fast reference.

Relationships, planner and migration

planner::plan is independently callable over Graph; bench it on a counted in-memory graph to expose pure planning allocations/visits separately from storage. Plan::{logical_bytes,rows,nullifies,len,is_empty} are stored-field or slice accessors, with zero graph queries. Then measure the integrated delete.

For each distinct deleted row, the direct algorithm must discover all applicable reverse edges and compute its old index entries. Deduplicate cascades by exact (table, PK) identity; a diamond or cycle cannot delete/retire a row twice. Count every examined reverse edge, not only affected rows. Current Restrict is immediate even when a dependent also appears among scheduled deletions; a reference must not turn it into deferred NO ACTION semantics. Bounds and stale identity checks remain part of the comparison.

Group SetNull edits per surviving row, compose all selected field clears, then validate that complete candidate once. Perform cross-row uniqueness checks before any mutation; remove all old index entries before inserting the new ones. One surviving row with three cleared references is one row patch, not three replacements. Include conflicts against unaffected rows and other patches, nullable rows also deleted by another edge, unchanged projected keys, failure after previous successful mutation, and exact nullified/deleted counts.

Migration public behavior Required reference algorithm
migrate, from, mappers! One synchronous upgrade; static action/source selection; unique source selection and all target coverage checked before data work; from and tuple construction are not row operations
Reindex Preserve primary ownership; scan each retained row once to validate/build target indexes; retire old indexes; no primary reinsertion
Recode + Sink::store Visit each source row once, map/store exactly one target owner at the preserved ID, build its indexes and retire the source; final FK validation after all targets exist
NativeValues Consume each native row once and move unchanged owning fields; use ordered/balanced primary construction if supported, not an assumed n independent root searches
HylixValues Preserve its linear balanced owning-value builder; compare primary construction plus required index build, not blindly fused n log n insertion
New Construct empty target owner/indexes; zero source rows
Seed + TableSink::store Deterministic target construction with PK/row/unique preflight and population bounds; complete final FK pass

Track migration owner transfer, removed-field/source-table retirement, peak source/target/index coexistence, foreign checks and allocations. Final FK validation scans only foreign-bearing tables and performs a parent identity check only for a present strong reference; preserve the documented conservative edge-budget admission. The public shared byte limit does not cap arbitrary mapper or backend allocation. Empty zero-budget migrations, row/edge refusal, missing final parent, unique collision and late upgrade trap belong in the ledger.

The runtime benchmark is the whole upgrade, including provider restoration, source/target admission, ownership retirement, publication and rebind. DTS slices are one execution, not separate messages. No theoretical floor may omit target validation or count a partial conversion as completed work.

Other public surfaces and extension points

Text::{new,as_str,as_bytes,len,is_empty}, TryFrom<&str>, AsRef<str>, key encoding/decoding and ordering need a small primitive suite: valid/overlength UTF-8, short and full inline keys, canonical decode failures and tuple/descending comparisons. Inline Text::new zeroes its fixed capacity; count those bytes. Use the same key/projection functions in the direct and Ashroot arms, and report their isolated cost rather than attributing it to coordinator dispatch.

Resources::minima includes root/provider matching and one shared reusable buffer owner. Measure resource creation/restoration separately from warm table operations. Clone/default and BatchCounts::{len,is_empty} are tiny field or reference-count operations; mark them covered as helpers, not database searches.

TableSpec, Projection, NullableProjection, custom Definition/Query, Backend, RowStorage, OrderedStorage and RowCursor are extension contracts. Their arbitrary user implementations cannot have one universal cost. Cover every built-in path, one transparent custom index/query fixture, and expose their primitive costs in the ledger. Publicly named infrastructure gated by the unconstructible Permit, sealed traversal/membership traits, metadata and type aliases are not independent application mutation APIs.

record!, table!, projection!, nullable_projection!, database!, list!, positions! and source/contract checking run during authoring/compilation. Mark compile-only work as such. Generated validators, projections, into_stable ownership transfer and query methods are runtime work counted with their corresponding operations. Do not infer purity or arbitrary helper equivalence from macro syntax.

Source findings to test first

These are hypotheses and observed call sequences, not measured savings:

  1. Scalar mutation always uses RowStorage::get before put. Insert duplicate detection therefore decodes a present Hylix/Minima value even though only identity is needed; successful writes repeat the primary search. Native SDK maps expose BTreeMap::entry. A direct ordinary-four-index reference can retain that entry through index preflights. It cannot automatically do this for self-FKs to another key, because the entry borrows the same primary map mutably. Error ordering also constrains moving FK/unique checks before the primary decision. Do not model an unavailable read-capable prepared entry as a measured primitive.
  2. Minima put/remove rediscover the directory entry after preflight. Missing insert currently searches the directory in get, again in put, then again for insert; existing replace and removal also repeat identity lookups and slot checks. Count both the retained directory and stable header/payload operations.
  3. Hylix scan_keys/keys use SDK range/keys iterators that decode the value. A key-only ordered cursor should need zero row decodes. This also affects clear_table root collection. The primitive floor must expose the missing key-only iterator capability instead of copying it into the supposedly ideal reference.
  4. Scalar deletion always allocates the generic planner's Vec/visited set, performs an existence probe, then Head::erase reads the row and removes it with another primary search. A statically no-incoming-relationship target can have a much smaller direct algorithm. The current compile-time optimization skips SetNull patch preparation, not graph planning itself. Preserve logical limits, refusals, old projections and owner retirement in any specialization.
  5. Unique indexes currently use composite ordered sets and prefix-range conflict queries. Compare a direct unique-key map or point-capable search before calling the extra range machinery unavoidable. Sparse absence and unchanged keys must perform no index write or irrelevant unique/FK query.
  6. NativeValues consumes ascending source IDs but inserts each into the new primary map separately. Investigate a fallible sorted primary builder while maintaining indexes and preserving owners. Recode also retains source indexes through target growth; pure owner-local mappers cannot inspect those indexes. Early retirement may reduce peak coexistence where lifecycle rules permit it. Keep Hylix's existing balanced construction advantage.
  7. Batch mutation reuses a gate/context but still enters each table read/write separately. Measure repeated single calls, the current prefix batch and a direct owner-borrow-once loop. Expected partial-prefix semantics prohibit sorting/reordering inputs or validating the entire suffix in advance.

Practical benchmark shape and gates

Put maintained fixtures, direct controls, case definitions and reporting under bench/ashroot-overhead/. Use one shared bounded Wire protocol and equivalent compile-selected direct/Ashroot implementations for each engine, with frozen handwritten versioned owners. Avoid a runtime generic table/index registry in the measured path. Keep native count instrumentation out of release Wasm.

Start with one primary table and four distinct ordinary projections, then add separate zero/one-index, unique, sparse and relational schemas. A foreign index already provides its ordered reverse lookup; do not add a redundant identical ordered index merely to make the fixture heavier. Include portable rows and separate owning-payload cases. Feed runtime inputs and consume matching outputs so compilation cannot remove the intended work.

Use counter-based native checks first: searches/comparisons, node/header bytes, value decodes, projection/validator/factory calls, allocations and retirements. Assert exact operation counts where meaningful, and the same final row/index oracle. Then build fresh canonical IC artifacts and record whole replicated instructions, body counters, included page charges, cycles, physical calls, logical work, grown memory and prepared/Code/canonical-compressed module sizes. Complete snapshots and owner ledgers establish correctness separately from cost.

Populate arms with the same insertion order and distribution, including leaf boundaries/splits, repeated secondary keys, absent/present sparse values, and small/large rows. Run point/range cases at several populations and returned counts, plus zero/missing/refusal cases. Keep a coverage table with a status and source/result identity for every method/engine/behavior; unsupported mapper modes are explicitly not applicable, and unrun cases are not performance claims.

Optimize only after the reference oracle and structural ledger agree. Re-run the affected operation cases and lifecycle/retirement checks after each change. SDK runtime changes also require the separate matched Nyxus RRT and Hylix RRts Heavy16 controls. The earlier simplification's handwritten control remains historical evidence; it is not this new structural floor.