Production engineering
Reveal answer and reasoning
The capstone groups a conditional document mutation, a request receipt and a publication intent in one local SQLite transaction. That is a storage boundary, not a complete distributed business workflow. The command identity binds quantity and the original typed If-Match condition. A compatible replay can return its saved result only while that result version remains the current document version. A controlled response failure after commit makes those distinctions visible: the response can be503 while mutation, receipt and event already exist.
No authenticated purchase, broker consumer or external exactly-once action is provisioned by this Development-only classroom protocol.
PipelineLabs parses If-Match through typed header APIs, requires a supported request key and begins a SQLite write transaction before reading the relevant document version and applying the command decision. Existing receipts compare their saved payload and result version; new commands evaluate the strong condition against the transactional current version. The same transaction updates the document, inserts the request record and inserts an outbox row, then commits. failAfterCommit returns503 afterward without undoing those rows.
Replaying the original key, quantity and condition can return a version/replay receipt without another event. The receipt is deliberately not a full freshly fetched document representation.
What a strong answer covers
- The capstone groups a conditional document mutation, a request receipt and a publication intent in one local SQLite transaction.
- PipelineLabs parses If-Match through typed header APIs, requires a supported request key and begins a SQLite write transaction before reading the relevant document version and applying the command decision.
- Request equivalence is explicit and narrower than an unrestricted semantic comparison: quantity and the serialized original typed condition are bound together.
Common pitfall
Request equivalence is explicit and narrower than an unrestricted semantic comparison: quantity and the serialized original typed condition are bound together. Reusing a key with changed meaning conflicts. Later unrelated writes can also make an otherwise matching saved receipt noncurrent, producing409 under this chosen protocol. A new stale condition produces412 instead. SQLite's immediate write ownership makes this local decision boundary inspectable, but no general cross-database transaction guarantee follows. The outbox row records intent only; publication, consumer replay handling, ordering and effects outside this database need separate owners. A successful receipt does not demonstrate that any broker or remote consumer ran.
Follow-up questions
- Why does replacing the original If-Match value with the result ETag change the saved request identity during a replay?
- Why does an outbox row prove persisted intent rather than broker publication or a consumer effect?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.