Chapter 9 — Service Cooperation and Execution Order¶
© 2026 S++ project contributors. All rights reserved. Book copyright.
Ordering requires buyer facts and goods prices before quotation. It does not require the buyer query to finish before the goods query starts. The execution order should follow the dependencies of the business, not the order in which its source happens to be written.
Three Sources of Waiting¶
| Source | Example | Consequence |
|---|---|---|
| Business agreement | Verify returned goods before refunding | Preserve the policy |
| Data dependency | Calculate subtotal before a discount that uses it | Preserve the producer–consumer relationship |
| Code arrangement | Query buyer and goods successively despite independent inputs | Remove unnecessary waiting |
The first two impose genuine constraints. The third is an execution choice, provided the operations do not interfere.
Dependencies and Join Points¶
A scenario can be understood as a dependency graph. Each operation consumes prepared inputs and produces facts, decisions or effects. An edge represents a required precedence, not necessarily a remote call.
┌─ Query buyer ─┐
Prepare inputs ───┤ ├─ Eligibility ─ Quote ─ Prepare inventory ─ Settle
└─ Query goods ─┘
At the join, both queries must have completed with usable results. An absent participant or technical failure prevents normal quotation. A parallel plan must also define what happens to outstanding branches and effects when execution fails.
Independence requires more than distinct service names. Queries fill in-memory facts and may conflict if they write the same property. Line calculations may run independently, but their subtotal must await the required results; concurrent writes to one accumulator require a safe reduction.
Settlement and Shared Writes¶
Two requests each reading a wallet of 100 and attempting to debit 80 may prepare concurrently. With a zero lower bound and no other changes, at most one debit can settle. Scheduling alone cannot enforce that invariant. Likewise, debit and credit must share a settlement outcome.
Under the quantum-first plan in Chapter 7, independent ordinary saves may overlap once settlement results and all required facts are ready. Conflicting writes still require protection, and completion must honor the transaction boundary.
The method is to identify inputs and outputs, preserve business and data dependencies, check interference, and specify join and failure semantics. Appendix B develops the formal conditions and counterexamples.
Part Contents · Full Book Contents · Previous Chapter · Next Chapter