Ashroot design brief — 2 November 2026
Objective
Build an optional Rust crate named ashroot in this workspace. Preserve the
existing SDK and its direct collection APIs. Reproduce the useful integrity
semantics of the neighboring Motoko Ashroot without its standalone schema/code
generator: typed primary tables, multiple automatic indexes, foreign keys,
restrict/cascade deletion, private modular memory and explicit migrations.
Simplicity, execution cost and Wasm size are selection criteria, not follow-ups.
Requirements
- Persist ordinary admitted storage; keep code, bindings and query views transient.
- Typed unique primary keys, immutable through ordinary row replacement.
- Ordered and unique secondary indexes with exact changed-projection maintenance.
- Backend capabilities distinguish ordered, equality and spatial queries. A new backend needs actual retained ownership and representation proofs.
- Close mutation bypasses: no raw mutable primary/index or persisted row escapes.
- Relations validate source writes and target removal, use complete reverse indexes and cover clear/replacement/module retirement and conversion.
- Preserve module Data/MemoryKey privacy. Explicit static composition may connect participating owners in one Actor; never grant root arbitrary child access.
- Expected validation failures precede persistent mutation. Commit failures trap for IC rollback. Returned Err alone does not roll writes back.
- Bound operation work, especially cascades; specify cycles, diamonds, restrictions, nullable references, batches and failed operations precisely.
- Define pure validation/projection and deferred effects rather than permitting arbitrary reentrant mutation inside half-published changes.
- Compile known schema errors, leave changing input/ownership/bounds checks runtime.
- Include schema/projection/helper/order/backend/relationship policies in admission.
- Qualify real owner-local conversion and index rebuild, wrong-contract rejection, populated KEEP, rollback, useful-work costs and raw/prepared Wasm sizes.
Investigation
The existing Motoko implementation coordinates generated per-table checked writes through a transient aggregate. Direct restriction errors precede destructive policies; nested failures after cascade starts trap. Bulk writes preserve a successful prefix on ordinary error. All-cascade cycles are rejected. Current CDK Nyxus maps deliberately expose DerefMut/entry/iter_mut, so observer callbacks cannot enforce table invariants. A new opaque carrier and closed mutation surface are required. Current Store and allocators should remain unchanged.
Review lanes
- Integrity, safety and lifecycle: authority, bypasses, failure atomicity, graph semantics, boundedness, module retirement and conversion.
- Usability and developer experience: smallest readable static API, handwritten schemas, optional Rust declaration sugar, independent modules and backends.
- Persistence/migration: complete contracts, Nyxus/Hylix ownership, rebuilding, startup and predecessor admission.
- IC/performance/size: primary sources, branch/allocation/copy costs, generic code growth, faithful controls and actual target qualification design.
Each reviewer records findings, concrete alternatives and recommended changes in an assigned Markdown file. Root records the selected design and aspirational code before runtime implementation, then sends it back for adversarial review.
Source identities
Initial harness: b2cb4b9fb01073a3cd55131362fc226355b65853.
Pinned SDK: d0e53afc7b7fdc4b7cf4e2ccbe1e55a386133c4b.
Neighboring Ashroot is a read-only behavioral reference, not a product dependency.
Gates
Design review must resolve authority, backend ownership, schema closure, cycles, bounds, error/commit rules, lifecycle and interpretation before code. Implement the selected design with meaningful model/adversarial/compile-fail coverage. Run locked metadata, native checks, real Wasm builds and matching-artifact IC lifecycle/cost/size comparisons. Preserve failures and rejected optimizations. Do not infer current performance from historical receipts or native timing.