Chapter 19 — Transaction Boundaries, Execution Plans and Deployment Capabilities¶
© 2026 S++ project contributors. All rights reserved. Book copyright.
“These changes must hold together” is a business requirement; resources and protocols are implementation. SPP expresses boundaries with transaction, APP selects strategy, PHY supplies real resources, and generated plans connect them.
Ordinary Updates Default to Optimistic Locking¶
The system retains query baselines. After scenario calculation and validation, built-in updates conditionally write against those baselines. If another request changed ordinary facts, the update reports conflict rather than overwriting them. APP defines retry or recovery.
Two requests read one profile. The first changes address; the second changes phone using stale facts. Its save must detect the changed baseline instead of restoring the old address with the whole old profile. Optimistic locking avoids holding a record lock throughout query and calculation while checking competition at write time.
Finds that load the participants of an updating service are plain snapshot reads, inside or outside a transaction. They take no row locks. Locking happens afterwards, once per transaction, so two scenarios that find the same positions in opposite order cannot deadlock in the database before they reach the quantum step.
| Queried Facts | What Protects Them |
|---|---|
| Ordinary participant | The write locks the row and compares the revision token read at the find. A fact changed by another transaction since then is rejected with PERSISTENCE_VERSION_CONFLICT; the caller re-reads and retries the scenario |
| Quantum facts | No ordinary read lock. The transaction locks every position it moves in one sorted order, by attribute and then position key, and checks bounds at settlement |
| Participant with ordinary and quantum facts | Ordinary facts are protected by the revision compare at the write; quantum facts by the sorted settlement lock |
Query the APP declares locked |
Keeps its row lock, because the application asked for it; declare it only on one scalar key |
SPP does not write select for update. The runtime locks at the write and at settlement, not at the find. Locking an ordinary record does not mean locking wallet quantum facts. The transaction reads reference describes the earlier read-locking design; this chapter reflects the current rule.
Local Joint Commit¶
Petstore develop uses LOCAL. Domains share a JVM and the required database, schema and connection resources, so quantum and ordinary changes enter one local transaction. Recovery applies within that resource scope. A LOCAL transaction whose calls make no quantum transfer commits as a plain JDBC transaction on its one shared resource; a quantum transfer in LOCAL still requires that shared resource.
The same database name does not prove a common transaction connection. Separate processes do not gain LOCAL merely by accessing one database. Compilation and startup validate actual identities.
Phased Execution¶
Outside LOCAL, a concentrated quantum group may settle first, followed by ordinary groups according to mode. Saga restores committed phases. A later ordinary rollback cannot undo an already committed quantum change.
Plans require explicit recovery capabilities. Unsupported combinations should be rejected rather than inventing compensation. Joint success across phases differs from single-resource atomic commit.
Nested Boundaries¶
REQUIRED joins the current boundary; ending it does not commit separately. Payment uses it for a logical scope, not independently committing payment before order.
REQUIRES_NEW is independent and does not automatically enter the outer recovery chain. Independent account opening may remain completed after outer failure and needs its own handling. Appendix E describes example-backend propagation support.
Automatic Quantum-First Planning¶
Ordinary updates are built-in and contain no business query, calculation or validation. Scenarios supply complete facts through preparation and quantum results.
Ordinary saves do not affect quantum inputs or outcomes; fixed quantum deltas can be aggregated or reordered only under the applicable command and settlement constraints. The compiler therefore schedules quantum transactions before ordinary updates within a boundary, allowing unordered or merged execution. Serial groups arrange post-settlement calculations and validations before ready saves run concurrently. Runtime supplies context, resources, joining and failure handling. “After quantum services” describes phases; LOCAL can still commit them together at the end.
Business Rejection and Technical Failure¶
SPP omits try/catch/throw: business conditions are explicit checks, while APP defines technical-failure policy and runtime/PHY execute it. A failing check exits its enclosing bare block; at transaction scope it rolls back the transaction. breakTransaction rolls back from any depth (Chapter 15).
A database failure is not evidence that an order is absent; a payment timeout is not evidence that settlement failed. APP must confirm uncertain outcomes before retry or business disposition. Generated Java and runtime may use exceptions internally. See participant execution.
Business Failure Compensation¶
SPP handles business failures: once conditions are known not to hold, what should happen to established results? Different businesses may choose different responses.
Insufficient inventory may lead to waiting for restocking or cancellation and refund. The framework confirms reservations and payment, but cannot choose for parties. transaction { ... } fail { ... } expresses post-failure business operations. Technical execution and recovery occur first; the adjacent fail receives failure facts. Its saves use a new explicit transaction.
| Failure | Decision Required from Business Developers |
|---|---|
| Admission rejects before changes | Reject with reason; do not refund a debit that never happened |
| Inventory held but later business validation rejects | Whether to cancel, releasing the actual reservation if canceled |
| Payment settled but fulfillment impossible | Keep payment for later handling, or cancel, refund and release holds |
| Application independently accepted but approval rejected | Keep for retry or mark rejected/canceled, and decide fee treatment |
| Goods delivered but later business cannot finish | Return, refund or another remedy; state changes do not return physical goods |
These are decisions, not a universal instruction to reverse all steps. Uncommitted changes can roll back; quantum services automatically reverse original transactions without a separately written business inverse. Business still decides cancellation, release or continued fulfillment. Later partial refunds or fees are new activities, not erasing original payment history.
Compensation respects layering. Refund eligibility is SPP; timeout executing the refund is APP. SPP defines qualifications, amounts and result; APP confirms, retries and recovers. Timeout is not business rejection.
Example: Retain an Accepted Reservation and Record Rejection¶
Petstore saves acceptance before reserving inventory. With ten available and eleven requested, acceptance exists but reservation cannot settle. The scenario retains the original number and records rejection for insufficient stock. From the actual scenario, omitting initial checks:
transaction { insertPetReservationAgreement; }
prepareReservationInventory; findStockLine; identify(stockLines);
transaction {
reserveRequestedInventory bounds {
stockLines.available: [0, null]; stockLines.reserved: [0, null]; };
confirmPetReservation; updatePetReservationAgreement;
} fail {
if (ResultInfo.failure.recoveryStatus == "ROLLED_BACK" || ResultInfo.failure.recoveryStatus == "REVERSED") {
findStockLine; identify(stockLines);
rejectPetReservation;
transaction { updatePetReservationAgreement; }
}
}
The first transaction independently saves acceptance; failure of the later one does not delete it. Success marks RESERVED. Failure first rolls back uncommitted effects or automatically reverses the settled quantum phase, then enters fail.
ResultInfo is a built-in scenario participant, not an input declaration. The example acts only for ROLLED_BACK or REVERSED: confirmed rollback or recovery of committed phases. It re-queries stock, calculates rejection and saves state in a fresh transaction, outside the failed boundary.
Rejection calculation marks REJECTED and distinguishes INSUFFICIENT_STOCK from RESERVATION_NOT_COMPLETED using recovered stock and requested quantity. Ten available against eleven yields the same reservation number, insufficient-stock reason and unchanged 10 available/0 reserved. A later ordinary-save fault despite sufficient stock instead records reservation not completed.
fail does not manually add inventory back. System rollback or automatic reversal handles that; fail expresses the business choice to preserve acceptance and record final rejection.
Unknown outcomes give RECOVERY_REQUIRED, so this example does not declare safe rejection. fail may record pending verification facts, but technical failure continues to APP and is not considered recovered merely because fail ran. After successful handling, status remains FAILED with handled true, rather than converting the original transaction to success. Current support is outer transaction fail in serial scenarios; multiple input contracts use fail(targetContract). See failure and system results.
Technical Recovery Policy¶
APP defines original-request confirmation, permitted retries, durable recovery tasks and escalation. A timeout alone does not trigger cancellation or refund. The same policy applies to compensation execution: confirm actual effects and prevent duplicates before reporting completion.
Report Actual Results¶
Request failure may mean no commit, partially committed phases or an unknown outcome. Settlement and recovery evidence determine actual state; an HTTP error alone does not prove rollback everywhere.
Explicit transaction semantics and deployment capabilities turn boundaries into reliable promises. Appendices D and F state detailed support.
Part Contents · Full Book Contents · Previous Chapter · Next Chapter