English source · 6 min
Proof coverage of the commerce domain functions
Generated from proof/domain-inventory.json by scripts/formal/domain_inventory.py --write;
scripts/formal.py --check fails when a function in domain/ of core, pricing, inventory, checkout, payments, orders is in neither state below.
binds-proved-rule means the function decides through extracted, Lean-proved kernel rules; the input mapping around the call is reviewed Rust, not proved. unproved functions carry one of the reasons listed at the end. Nothing here proves SQL, HTTP or providers.
components/core has no domain/ module; its functions are infrastructure (store, cache, HTTP limits) and are not counted here. A domain/ module added to it is checked like the others.
Money runs on whole minor units (Minor, Money) and exact decimals and rationals (Decimal, Ratio); since 26 November the calculator no longer reproduces Shopware's binary64 steps: it computes exactly and rounds each amount once, half away from zero, per currency exponent. JSON numbers cross one boundary conversion (Decimal::from_wire/to_wire). Proved and bound: line totals (line_total), rounding of a quotient to the minor unit (rounded_quotient, also the calculator's cash-interval rounding in Rounding::price), sums (amount_sum), net = gross - tax (net_amount), discount within its base (discount_cap), and the quote-total theorems over any list of lines.
| Component | Functions | Binds a proved rule | Unproved |
|---|---|---|---|
| core | 0 | 0 | 0 |
| pricing | 106 | 9 | 97 |
| inventory | 6 | 1 | 5 |
| checkout | 24 | 3 | 21 |
| payments | 37 | 3 | 34 |
| orders | 39 | 4 | 35 |
| all | 212 | 20 | 192 |
Functions that bind proved rules
| Function | Rules |
|---|---|
components/checkout/src/domain/admin_order.rs::admit_payment |
admin_payment_admissible |
components/checkout/src/domain/cart_quote.rs::quote |
amount_sum, net_amount |
components/checkout/src/domain/review_binding.rs::validate |
checkout_review_admissible, revision_admissible |
components/inventory/src/domain/lines.rs::InventoryLines::new |
reservation_admissible |
components/orders/src/domain/order_transitions.rs::payment |
manual_payment_admissible |
components/orders/src/domain/order_workflow.rs::admitted_edge |
order_transition_admissible |
components/orders/src/domain/order_workflow.rs::guard |
cancellation_admissible, completion_admissible, order_edit_admissible |
components/orders/src/domain/order_workflow.rs::workflow |
delivery_split_admissible |
components/payments/src/domain/receipt_guard.rs::receipt_matches |
receipt_admissible |
components/payments/src/domain/refunds.rs::checked_total |
refund_admissible |
components/payments/src/domain/state.rs::transition |
payment_transition_admissible |
components/pricing/src/domain/decimal.rs::quotient |
rounded_quotient |
components/pricing/src/domain/discount.rs::allocate |
discount_cap |
components/pricing/src/domain/external_order.rs::PaidOrder::validate |
external_paid_total_admissible |
components/pricing/src/domain/external_order.rs::SourceAmount::valid |
external_amount_admissible |
components/pricing/src/domain/money.rs::Currency::new |
currency_scale_admissible |
components/pricing/src/domain/money.rs::Minor::times |
line_total |
components/pricing/src/domain/money.rs::unsigned_sum |
amount_sum |
components/pricing/src/domain/pricing.rs::Rounding::price |
line_total, rounded_quotient |
components/pricing/src/domain/quote.rs::QuoteTotals::new |
net_amount |
Unproved functions by reason
money-representation (59)
Money representation and exact arithmetic outside the bool/u64 subset: minor-unit types, decimal parsing and text, exact rationals in i128, the exact calculator's rule mix, the wire conversion of JSON numbers. Rounding, products and sums inside it are the proved rules; the rest is unit and property tested.
components/checkout/src/domain/cart_quote.rs:configuration_pricecomponents/checkout/src/domain/tax_lines.rs:tax_productscomponents/payments/src/domain/amounts.rs:format_amount,parse_amountcomponents/payments/src/domain/refunds.rs:usedcomponents/payments/src/domain/settlements.rs:capturedcomponents/pricing/src/domain/decimal.rs:Decimal::checked_add,Decimal::cmp,Decimal::deserialize,Decimal::eq,Decimal::fmt,Decimal::from_wire,Decimal::normalized,Decimal::parse,Decimal::partial_cmp,Decimal::serialize,Decimal::text,Decimal::to_wire,Ratio::abs,Ratio::checked_add,Ratio::checked_div,Ratio::checked_mul,Ratio::checked_sub,Ratio::cmp,Ratio::deserialize,Ratio::negated,Ratio::new,Ratio::partial_cmp,Ratio::reduced,Ratio::rounded,Ratio::significant,Ratio::significant_away,Ratio::significant_with,gcd,power,widecomponents/pricing/src/domain/money.rs:Currency::factor,Minor::decimal,Minor::from_decimal,Minor::from_unsigned,Minor::ratio,Minor::serialize,Minor::significant,Minor::unsigned,Money::checked_add,Money::decimal,Money::from_decimal,Money::new,Money::parse,Money::roundedcomponents/pricing/src/domain/pricing.rs:Rounding::new,Rounding::plain,calculate,merged_rules,percent,proportional_tax_rulescomponents/pricing/src/domain/quote.rs:LinePriceUpdate::new,QuoteTax::at_scale,QuoteTotals::of_lines
document-shape (23)
Reads, writes or projects JSON/serde documents; data mapping, not a decision rule.
components/checkout/src/domain/admin_order.rs:ordercomponents/checkout/src/domain/quote_view.rs:QuoteView::first_line,QuoteView::method,digital,flags,quote_viewcomponents/orders/src/domain/company_model.rs:order_prefix,public,resolvecomponents/orders/src/domain/import_product.rs:projectioncomponents/orders/src/domain/import_relations.rs:identity,productcomponents/orders/src/domain/order_fields.rs:order_fieldscomponents/orders/src/domain/order_patches.rs:TrackingUrl::of,strip_cart_tokencomponents/orders/src/domain/order_workflow.rs:WorkflowOrder::deliveriescomponents/payments/src/domain/attempt.rs:Attempt::ctx,context_ofcomponents/payments/src/domain/instructions.rs:snapshotcomponents/payments/src/domain/receipt_ref.rs:referencecomponents/payments/src/domain/settlements.rs:summarycomponents/pricing/src/domain/catalog.rs:public_extracomponents/pricing/src/domain/quote.rs:QuoteTax::from
text-and-locale (9)
Text, labels, locale or formatting; no commerce invariant to prove.
components/checkout/src/domain/cart_quote.rs:line_labelcomponents/orders/src/domain/company_model.rs:address,default_order_prefix,order_numbercomponents/orders/src/domain/import_product.rs:textcomponents/orders/src/domain/order_machine.rs:labelscomponents/payments/src/domain/diagnostics.rs:code,responsecomponents/pricing/src/domain/validation.rs:ValidationError::fmt
rendering (10)
Renders documents (receipt text or PDF); output layout, not a decision rule.
components/orders/src/domain/logo_image.rs:normalizecomponents/orders/src/domain/receipt_instructions.rs:linescomponents/orders/src/domain/receipt_pdf.rs:render,winansicomponents/orders/src/domain/receipt_text.rs:lines,pos_message,positions,seller_details,text,totals
validation-of-strings (19)
Validates identifiers, URLs, names or other strings and collections; outside the bool/u64 subset, covered by unit and HTTP tests.
components/checkout/src/domain/session_review.rs:keycomponents/inventory/src/domain/supply.rs:Config::validatecomponents/orders/src/domain/company_model.rs:valid_order_prefix,validatecomponents/payments/src/domain/amounts.rs:wire_currencycomponents/payments/src/domain/details_model.rs:Amount::validate,Details::validate,date,statuscomponents/payments/src/domain/instructions.rs:Instructions::validate,validatedcomponents/payments/src/domain/return_urls.rs:build,urlscomponents/payments/src/domain/service_config.rs:approval_transport,approval_url,validate_servicecomponents/pricing/src/domain/customer/address.rs:Address::validatecomponents/pricing/src/domain/customer/contact.rs:Contact::validate,valid_birthday
decision-outside-subset (29)
A pure decision over strings, enums or collections that the bool/u64 extractor cannot express; reviewed and unit tested, not extracted.
components/checkout/src/domain/cart_quote.rs:normalized_quantitycomponents/checkout/src/domain/session_payment.rs:attempt,has_saved_funding,provider,test_environmentcomponents/checkout/src/domain/session_review.rs:Review::admit_cart,Review::check_prepared_payment,Review::check_quote,Review::check_replay,receiptcomponents/inventory/src/domain/reorder.rs:admit,within_ceilingcomponents/orders/src/domain/order_machine.rs:OrderMachine::validatecomponents/orders/src/domain/order_transitions.rs:cancellation_blocker,deliverycomponents/orders/src/domain/order_workflow.rs:WorkflowOrder::external,external,terminalcomponents/payments/src/domain/attempt.rs:AttemptContext::cancomponents/payments/src/domain/capture_intent.rs:intentcomponents/payments/src/domain/instructions.rs:admitcomponents/payments/src/domain/receipt_ref.rs:ProviderReceipt::confirmed,identity,iscomponents/payments/src/domain/refunds.rs:capturecomponents/payments/src/domain/settlements.rs:closed,multicomponents/pricing/src/domain/context.rs:language_chain,select_tier
constructor-or-accessor (34)
Builds or reads a value without a decision of its own.
components/checkout/src/domain/session_review.rs:Review::sessioncomponents/inventory/src/domain/lines.rs:InventoryLines::ids,InventoryLines::quantitiescomponents/pricing/src/domain/cart.rs:default_channelcomponents/pricing/src/domain/customer/mod.rs:country_defaultcomponents/pricing/src/domain/decimal.rs:Decimal::integer,Decimal::is_zero,Decimal::new,Decimal::ratio,Decimal::scale,Decimal::units,Ratio::denominator,Ratio::integer,Ratio::is_negative,Ratio::is_zero,Ratio::numeratorcomponents/pricing/src/domain/money.rs:Currency::code,Currency::eur,Currency::scale,Currency::try_from,Minor::minor,Minor::new,Minor::same_scale,Minor::scale,Minor::zero,Money::amount,Money::currency,Money::minorcomponents/pricing/src/domain/pricing.rs:PriceInput::default,decimals,hundred,interval,yescomponents/pricing/src/domain/validation.rs:ValidationError::new
catalogue-data (3)
Returns fixed catalogue data (states, providers, schema); reviewed data, no rule.
components/orders/src/domain/creation_schema.rs:schemacomponents/orders/src/domain/order_machine.rs:default_machinecomponents/payments/src/domain/state.rs:code
signed-arithmetic (6)
Signed (i64) quantity or amount arithmetic outside the u64 subset; unit tested.
components/payments/src/domain/settlements.rs:statecomponents/pricing/src/domain/context.rs:fix_quantitycomponents/pricing/src/domain/money.rs:Minor::at_scale,Minor::checked_add,Minor::checked_sub,Minor::sum
Notes on single functions
components/checkout/src/domain/cart_quote.rs::quote: Line totals are the calculator's proved line_total in whole minor units; the quote adds them with amount_sum and splits net and tax with net_amount. The Lean quote-total theorems state these sums for any list of lines.components/checkout/src/domain/tax_lines.rs::tax_products: The net-preserving rate factor (100 + rate) / (100 + product rate) is exact; a converted snapshot price is kept at fifteen significant digits so its binary64 number reads back as that decimal.components/inventory/src/domain/lines.rs::InventoryLines::new: The new order holds nothing yet (held = 0); the reservation run theorems cover any later reserve/release sequence gated by the same rule.components/orders/src/domain/order_machine.rs::OrderMachine::validate: Graph validation of a configured machine (identifiers, labels, no edge out of a terminal state, reachability). The order run theorems do not rely on it: admitted_edge rechecks the listed target and the terminal source.components/orders/src/domain/order_transitions.rs::delivery: Delivery state strings; terminal orders are refused before it runs by guard (order_edit_admissible).components/orders/src/domain/order_workflow.rs::terminal: String membership; its result is the terminal input of the proved order_edit_admissible and order_transition_admissible.components/pricing/src/domain/decimal.rs::Decimal::from_wire: The one boundary conversion from a JSON number: the shortest decimal that reads back as the number (Rust f64 display digits); unit and property tested.components/pricing/src/domain/decimal.rs::quotient: Refuses operands outside the rule's range instead of letting it saturate; Ratio::rounded rounds every exact amount into minor units through it.components/pricing/src/domain/discount.rs::allocate: The cap is proved; the proportional integer allocation loop and its rounding are unit tested, not proved.components/pricing/src/domain/money.rs::Minor::times: Sign and overflow refusal around the proved product; the calculator's line totals and every quantity multiplication of a minor amount use it.components/pricing/src/domain/money.rs::unsigned_sum: Refuses an overflowing sum instead of letting the proved sum saturate.components/pricing/src/domain/pricing.rs::Rounding::plain: One rounding to the precision through Ratio::rounded, i.e. the proved rounded_quotient (bound in decimal.rs::quotient).components/pricing/src/domain/pricing.rs::Rounding::price: Cash rounding in whole minor units: rounded_quotient of the amount by the interval, times the interval by line_total (Lean cash_round_nearest_multiple); operands outside the rules' range are refused. The plain rounding before it is Rounding::plain.components/pricing/src/domain/pricing.rs::calculate: Exact Ratio arithmetic over decimals and rationals; every amount is rounded once, half away from zero, through Rounding::plain (proved rounded_quotient) and Rounding::price (proved rounded_quotient and line_total), the line total is the proved line_total (Minor::times). The rule mix and gross/net mapping are property tested (tests/properties.rs, tests/decimal_ties.rs), not extracted.components/pricing/src/domain/quote.rs::LinePriceUpdate::new: The unit price is total / quantity rounded once through Ratio::rounded (proved rounded_quotient).components/pricing/src/domain/quote.rs::QuoteTotals::new: Net quotes add the tax with the proved sum (through unsigned_sum), gross quotes take the proved net; negative amounts are refused.