S++Core systems, human-reviewable
ENGLISH EDITION · OCTOBER 15, 2026
ContentsComplete book

Chapter 20 — Quantum Properties, Call Bounds and Conserved Settlement

© 2026 S++ project contributors. All rights reserved. Book copyright.

Balances and inventory frequently face concurrent changes. “Enough when queried” is insufficient; actual settlement requires bounds and consistency. Quantum properties and services make that need explicit.

Properties and Deltas

Petstore declares wallet quantum and defines bilateral funding:

quantum update transferWalletFunds(
    Buyer, SettlementAccount, WalletFundingAgreement) {
    settlementAccount.balance -> buyer.wallet : walletFundingAgreement.amount;
}

The arrow moves one amount from the first position to the second. The amount is evaluated once, a negative or null amount is rejected, and zero has no effect. The compiler rejects a direct assignment or increment of a quantum field, so a transfer is the only way to change one. Two roles of one entity can move the same attribute between different keys, and writing the same endpoint on both sides is an error. Several transfers in one service are several movements, each with its own amount. The service states the relationship; bounds specify this call's range. Limits generally belong to wallet-role properties, so scenarios query them before passing them. One transfer service can serve wallets with different limits.

Transfers over a Collection

A slip with several lines moves each line's units between two holders. The quantum update loops over participant collections and each iteration is one conserved transfer; the whole slip is all or none:

quantum update moveSlip(Slip, Giving[], Receiving[]) {
    for (SlipLine line : slip.lines) {
        for (Giving source : givings) {
            for (Receiving target : receivings) {
                if (source.kind == line.kind && target.kind == line.kind) {
                    source.pieces -> target.pieces : line.units;
                }
            }
        }
    }
}

The two collections can be roles of one player, or one collection of the player. Each element is a distinct position of the player's conserved attribute. A transfer endpoint must be a participant parameter or an element of a loop over a participant collection parameter, otherwise compilation fails with SPP_QUANTUM_LOOP_ENDPOINT. A position is one object: key it once in its collection however many lines move it, because a key that occurs twice is rejected with QUANTUM_COLLECTION_IDENTITY_REQUIRED_OR_DUPLICATED.

Instead of the nested loops and if, the transfer can name its two positions with pick:

quantum update moveSlip(Slip, Giving[], Receiving[]) {
    for (SlipLine line : slip.lines) {
        Giving source = pick givings by owner = slip.giver and kind = line.kind;
        Receiving target = pick receivings by owner = slip.taker and kind = line.kind;
        source.pieces -> target.pieces : line.units;
    }
}

Each pick yields exactly one element of the collection parameter, and the local is that element, usable as a transfer endpoint. A line with no matching position is QUANTUM_MATCH_MISSING, and one matching two is QUANTUM_MATCH_AMBIGUOUS; either rolls back the whole slip, where the nested loops would silently do nothing or transfer twice. The key must cover the whole position identity, otherwise the compiler reports PICK_KEY_INCOMPLETE; fields that the find hydrating the collection already fixes may be left out. pick first and pick last state which of several matches to take. The same expression reads one element in a calculate or check.

The transaction locks positions in a consistent order, by attribute and then position key, to avoid cyclic lock acquisition. Bounds are checked once per command for each constrained position, against its authoritative starting value plus the net delta of all legs in that command. Intermediate leg balances are not separate admission conditions. If any bound fails, the entire command is rejected without applying any leg. Every position a call can debit, including the elements of a loop, needs an explicit entry in the call's bounds block, named by the scenario argument; an unlimited debit is written [null, null], and a missing entry is the compile error SPP_QUANTUM_BOUND_REQUIRED. The limit is a fact of the business transaction, usually read from the contract, so it is not declared on the account. Credit-only positions need no entry. An empty slip applies no transfer and is rejected. A boolean fact that nothing set is false in generated models.

Several domains can be composed in one application on one QService: the application binds every domain's quantum store to the same endpoint and namespace, and a consumer domain whose quantum roles are all played by other domains declares no store of its own. One transaction then reaches the service as one command covering every store it touches; stores bound to a different service are still reported as a distributed transfer that is not yet supported. Each domain contributes its own quantum definitions to the shared store; an attribute declared by several domains must be declared identically, or deployment fails with QUANTUM_DEFINITION_CONFLICT naming both domains. A play that moves no quantum needs no coordinator in any transaction mode, because the consumer only reads the provider's record. The service also enforces call bounds itself, inside the command, so no leg is applied when a bound is violated; the committed value of one quantum can also be read from the service without taking part in a transaction. The client reads the quantum facts of repository objects through that committed read, so a scenario sees its own settled commands, and a position is opened, idempotently, once the owner object has committed.

Query Wallet Limits First

A normal wallet may range from zero to 10,000 US dollars, while overdraft permits −500. Such facts belong to particular wallets rather than a hard-coded universal nonnegative transfer rule.

Payment queries the source lower bound; funding queries the destination upper bound; transfers obtain both sides' relevant limits. Adding 300 to 9,800 with a 10,000 maximum violates the range.

Limit queries retrieve settlement rules; balance queries support display or preliminary judgment. The scenario passes the limits, and execution checks them against actual settlement values. An earlier balance cannot guarantee success.

Bounds Apply at Settlement

Two requests see 100 and each pays 80. Both preliminary checks can pass, but at most one settles without overdraft. The quantum implementation processes current values and checks constraints before commit.

Limits are evaluated before the call; null disables that direction's check. It does not mean unknown amount or replace a legitimate funding source. Eligibility remains explicit validation.

For each constrained position q, let x(q) be its authoritative value and Δ(q) the sum of incoming amounts minus outgoing amounts in the command. Admission requires L(q) ≤ x(q) + Δ(q) ≤ U(q), omitting an unbounded side. For example, a position at 100 with lower bound 0 can send 150 and receive 80 within one command: its net delta is −70 and its final value is 30. The intermediate −50 is not a rejection condition. Separate commands do not share this netting permission; concurrent commands still require correct admission and atomic settlement. Conservation and all other constraints remain mandatory.

Conserve Actual Relationships

Payment source decrease and destination increase match. Reservation moves available to reserved; shipping reserved to sold. Each goods identity conserves separately; another product's increase cannot hide this one's loss.

Money and inventory use different dimensions, not one numerical conservation equation. They can cooperate under a scenario with separate conservation groups and an overall transaction or recovery plan.

Settlement Results and Participant Completion

The framework fills participants with settlement results. These describe the transaction's facts, not a global simultaneous snapshot across sources. Later transactions can continue changing values.

Ordinary prepared inputs remain stable as agreed; dynamic quantum facts belong to quantum execution. Business must not bypass it to save nonzero balance changes.

Automatic Inverse Transactions

Recovery applies opposite deltas to the original settlement participants, preserving later changes rather than restoring old balances. The system owns identity, deduplication and technical recovery. Chapter 21 distinguishes this automatic inverse from business reversal and compensation.


Part Contents · Full Book Contents · Previous Chapter · Next Chapter