lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

README.md (12377B)


      1 # Radroots domain
      2 
      3 The generated `NOTICE` retains the pinned currency facts, original data
      4 attribution and license texts, and selected MIT timezone dependency material.
      5 Keep it with derived artifacts. Regenerate it from the source-owned contract
      6 with `cargo extbuild run -- cargo xtask generate data-notices --write`;
      7 `--check` and canonical contract validation enforce byte freshness.
      8 
      9 Independently implemented exact values for the shared SDK successor. This
     10 pre-release package provides validated values and public sale-option offer
     11 terms. It does not execute commands, install agreements or establish stock.
     12 
     13 `Decimal` has a nonnegative coefficient up to 999999999999 and scale 0–6.
     14 Construction normalizes fractional trailing zeros. String admission requires
     15 that canonical representation; JSON uses strings exclusively. `PositiveDecimal`
     16 additionally rejects zero. Checked addition and subtraction are exact and
     17 reject results outside the supported representation. No floating conversion
     18 or implicit rounding is available.
     19 
     20 The package supports `no_std`; `serde` and `std` are independent features.
     21 It performs no I/O, clock, randomness, storage or network work.
     22 
     23 `Currency` admits the 165 fixed supported currency/fund codes and their exact
     24 minor-unit exponents. Unknown codes and unavailable minor units never receive
     25 a guessed exponent. `MinorAmount` admits canonical integer strings up to
     26 999999999999999. `Money` checks the explicit wire exponent against that registry
     27 and performs checked signed 128-bit addition/subtraction within one currency.
     28 JSON minor amounts remain strings; private monetary diagnostics are redacted.
     29 Explicit zero money does not imply a price mode.
     30 
     31 `FixedPrice` validates at most eight strictly increasing same-currency tiers
     32 and one discount in basis points 0–10000. It selects the greatest applicable
     33 threshold, applies the discount before rounding, and rounds once per net line
     34 using half-even checked signed 128-bit rational arithmetic. `checked_order_total`
     35 sums one through 32 rounded lines and an explicit same-currency fulfillment
     36 charge within the money cap. The calculation uses one selected sale-unit basis
     37 and performs no implicit physical conversion. Sale options validate purchase
     38 rules before using this engine. Complete bilateral terms, agreement installation
     39 and command effects remain separate requirements; calculations establish no
     40 authorization or stock.
     41 
     42 `Quantity` uses the existing measurement identity and exact decimal bounds.
     43 Conversions between g/kg and mL/L are explicit and reject precision loss;
     44 arithmetic requires matching units. `each` counts remain integral.
     45 
     46 `stock` supplies exact pool values for the durable-executor implementation.
     47 `StockTicks` admits canonical integer strings from0 through10^18; JSON numbers
     48 are rejected. `PoolUnit` requires an explicit physical unit and precision0–6,
     49 with integral `each` counts. Quantity conversion rejects rounding and implicit
     50 unit changes. `PoolBalances` checks the sum of available, preparatory hold,
     51 committed hold, physical quarantine, consumed, waste and removed against
     52 introduced stock. Released stock is a movement, and promises or deficits cannot
     53 fill a physical balance. A `PoolSnapshot` retains a distinct pool ID and declared
     54 revision. These data claims grant no write permission or stock authority.
     55 
     56 `ContentMeasure` descriptors distinguish fixed, estimated and unspecified
     57 contents; estimates do not provide fixed conversions or stock backing. Existing
     58 sale options validate selected amounts against their minimum, increment and
     59 integral package/count rules. Advertised supply establishes no quantity ceiling
     60 or actual availability. Sale-unit packages retain all three content modes;
     61 complete bilateral-term integration remains separate.
     62 
     63 `VariableWeight` retains a positive inclusive measurement range, exact rate and
     64 basis, and an explicit same-currency maximum total. Its minimum is feasible
     65 within the cap. Final measurements must use the declared unit, remain in range,
     66 and recompute within the cap using the same half-even engine without a discount.
     67 An in-range measurement can still exceed the cap and require refusal; this does
     68 not amend the terms or consume stock. Offer/line scaling and installation remain
     69 the responsibility of complete enclosing validated terms and execution.
     70 
     71 Order, thread, workspace, executor and operation IDs have distinct Rust types.
     72 Each stores 32 bytes and uses exactly 64 lowercase hexadecimal characters in
     73 strings and JSON. Byte/string construction validates representation; generation
     74 belongs to the execution owner's qualified CSPRNG boundary.
     75 
     76 `listing::ListingId` is the distinct 128-bit stable coordinate discriminator;
     77 `ListingOptionId` is a 256-bit sale-choice identity. Public listing terms bound
     78 and deduplicate options, retain an exact selected default, and validate positive
     79 increments/minimums without floating conversion. Package and `each` quantities
     80 remain integral; measured units imply no conversion. Quote-required prices
     81 contain no invented zero amount or currency. Fixed options retain their complete
     82 rate/basis, discount and tiers; `fixed_line` validates the selected purchase
     83 amount before calculating it. Variable option bounds and caps describe one
     84 sale unit and require complete absolute agreement terms before installation.
     85 Optional opaque authority and
     86 producer metadata establish no permission or endpoint trust. These immutable
     87 terms serialize public data explicitly and redact ordinary diagnostics.
     88 
     89 `listing::Media` retains bounded, nonempty URL/MIME claims, exact alternative
     90 text and a declared SHA-256 digest. Construction does not normalize claims,
     91 approve an endpoint, fetch a file, verify its contents or promise a decoder.
     92 `ListingTerms::new` requires the explicit media list, with at most eight
     93 references and preserved order. Empty media is explicit. Media descriptors
     94 serialize complete exact strings and have no unchecked deserialization route.
     95 
     96 `Supply::Estimated` retains an exact nonnegative amount and an explicit nullable
     97 `Window`. Package and `each` estimates remain integral. Estimates are neither
     98 stock balances nor reservations, ceilings or current-availability guarantees.
     99 `Window` requires strictly ordered absolute Unix-second instants and an exact
    100 canonical `TimeZoneId` from the already pinned no_std `jiff-tzdb` 0.1.8 / IANA
    101 2026c data (MIT OR Unlicense). No system zone, clock, local wall-time, offset or
    102 fold is inferred. The timezone dependency retains its own upstream notices.
    103 Private fulfillment data retains a required window, explicit pickup/delivery
    104 mode and bounded zeroizing address/instructions/contact. It has no public wire
    105 serialization and grants no agreement, destination or delivery authority.
    106 
    107 `Terms` retains complete immutable bilateral values: one through32 uniquely
    108 identified lines, one through8 uniquely identified private fulfillment groups,
    109 explicit distinct buyer/seller participants, original listing revision/product/option snapshots,
    110 selected positive purchase amounts, fulfillment fee, aggregate cap and supply
    111 commitment. Every line names a declared group and a source coordinate for the
    112 named seller. Coordinate/revision bytes and snapshots remain unverified claims
    113 until independent authenticated source admission.
    114 
    115 `AgreementPrice` admits resolved fixed or absolute variable measurement terms;
    116 quote-required has no agreed-price representation. `AgreedFixedPrice` retains
    117 the selected rate/threshold, basis and discount independently of the unchanged
    118 public option. It uses the shared half-even primitive and refuses a selected
    119 threshold above the purchased amount. Lines validate original purchase rules
    120 and recompute the declared fixed total or explicit variable cap. `Terms` sums
    121 those checked maxima and the explicit fee in one currency within the money cap.
    122 Variable line bounds are explicit absolute values; construction performs no
    123 per-sale-unit scaling. Future promises retain a required expected window and
    124 bounded nonempty risk disclosure, with no physical hold. Cancellation and
    125 rounding identities are fixed by the supported value contract.
    126 
    127 Private terms, line/group data and supply promises expose borrowed accessors
    128 and redacted diagnostics, with no automatic serialization/deserialization.
    129 Their constructors grant no participant consent, installed agreement, signer
    130 permission or stock effect. Private wire/hash admission remains separate.
    131 
    132 Line and group identities cannot be substituted:
    133 
    134 ```compile_fail
    135 use radroots_domain::{AgreementLineId, FulfillmentGroupId};
    136 let group = FulfillmentGroupId::from_bytes([0; 32]);
    137 let _: AgreementLineId = group;
    138 ```
    139 
    140 Private terms have no automatic public wire encoder:
    141 
    142 ```compile_fail
    143 fn encode(terms: &radroots_domain::Terms) {
    144     let _ = serde_json::to_string(terms);
    145 }
    146 ```
    147 
    148 `CommerceContent` retains the19 supported logical record families as immutable
    149 private data before protocol-owned canonical record-ID computation. Its header
    150 requires distinct participants, a participant author, a positive sequence with
    151 the explicit first/later previous-link shape, and at most8 strictly sorted
    152 unique full parent digests. Fixed seller/buyer record roles are checked; all
    153 non-quote families require an order ID. Terms-bearing records match header
    154 participants and declare their exact listing sources. Each payload's required
    155 source references and the author's previous record must appear in the parent
    156 set. Source-array, line, text and parent bounds apply jointly; construction
    157 refuses missing references and never silently omits them to fit a limit.
    158 
    159 Complete payloads preserve typed terms digests, positive seller sequences,
    160 explicit authority claims, bounded line/measurement assertions, issue data and
    161 resolution proposals. Measurements cannot repeat or name a line outside their
    162 handover claim. Private text is zeroizing and diagnostics are redacted. There is
    163 no automatic serialization/deserialization, numeric Nostr rumor kind, ambient
    164 clock, signature or installed effect. An exact zero observation remains data;
    165 it never grants a movement, release or trusted measurement.
    166 
    167 Declared parent membership is not authenticated coverage. Actual parent
    168 author/thread/order/type/sequence continuity, counterparty consent, source and
    169 terms hashes, deadline readiness, measurement economics and cumulative business
    170 state remain separate admission/execution requirements. Record and terms
    171 digests remain distinct from unsigned chat rumors and signed carrier IDs.
    172 
    173 ```compile_fail
    174 use radroots_domain::{RecordId, TermsDigest};
    175 let _: TermsDigest = RecordId::from_bytes([0; 32]);
    176 ```
    177 
    178 ```compile_fail
    179 fn encode(content: &radroots_domain::CommerceContent) {
    180     let _ = serde_json::to_string(content);
    181 }
    182 ```
    183 
    184 Namespaces remain separate across native calls:
    185 
    186 ```compile_fail
    187 use radroots_domain::{OperationId, WorkspaceId};
    188 let operation = OperationId::from_bytes([0; 32]);
    189 let _: WorkspaceId = operation;
    190 ```
    191 
    192 Byte inputs have a fixed width:
    193 
    194 ```compile_fail
    195 use radroots_domain::OperationId;
    196 let _ = OperationId::from_bytes([0; 31]);
    197 ```
    198 
    199 Actor, authority, checkpoint, approval, expected-order and complete captured
    200 context descriptors validate their representations without authenticating a
    201 principal. Sequence, generation and wall time use exact canonical decimal
    202 strings. Required nullable fields remain explicit JSON nulls. Checkpoint missing
    203 sources retain full digests independently of structured-record identity.
    204 `CommandContextData` is untrusted data; only an authenticated execution session
    205 can construct the opaque executable context.
    206 
    207 `ChatMessage` owns a bounded logical participant view, with separate message,
    208 thread, author, peer, creation time and inquiry/source or reply relation. Plain
    209 text has the shared 4,096 UTF-8 byte limit before JSON/encryption expansion;
    210 empty text and Unicode contents are preserved exactly. Private text uses
    211 zeroizing owned storage and redacted diagnostics, with no automatic payload
    212 serialization. Constructing a value proves no signature, history or installation.
    213 
    214 Crate-owned Rust is licensed under MIT OR Apache-2.0; see LICENSE-MIT and
    215 LICENSE-APACHE. The minimal derived currency data retains its upstream
    216 Apache-2.0 license, copyright and attribution in
    217 `data/currency_registry_v1.license` and `data/currency_registry_v1.notice`.
    218 No upstream Rust/generator, country/name data or official XML is included.