Chapter
08
Messages in a world that loses them
Part II · Safety and the language
Lessons
About
The network loses messages, delivers some twice, and delivers others out of order. How do you model reordering without a line about it?
With a set. This chapter models a network as the set of messages in flight, and shows what that one choice gives you for free: every arrival order, duplicates whenever the receiver leaves a message in the set, and loss whenever it never takes one. You will see where a set is the wrong container, what a queue promises and what believing it costs, why the alternating bit protocol depends on that promise, and how an idempotent receiver turns "at least once" into the effect of "once".
Before you start
- Chapters 05 to 07: sets, functions and
EXCEPT, interleaving, and actions with parameters. - Chapter 03's habits: a witness and full coverage for every pass.
- Time: the chapter page shows the estimate, generated from the lessons.
What else is here
specs/:ConfigPush,DepositLink,PingSetandPingBag,AlternatingBit,PaymentRetry,TaskBoard, and the variants the lessons run.review/(08-review): a teammate's order-tracking model.ai/1-assumes-fifo/(08-ai1): an agent's pull request on newsletter preferences.ai/2-correct-dedup/(08-ai2): an agent's deduplication of device events. Decide, with evidence, whether its claim holds.gate/(08-gate): notifications, delivered at least once and displayed once;gate/twin/(08-gate-twin): sensor readings counted once. The skeletons supply the interface; you write everything else.
Run it
From the repository root:
./tla check 08-01
./tla check 08-review
./tla check --gate 08Skills
hostile-env (modelling a hostile environment), abstraction (choosing the abstraction).
Elsewhere
- Web version: https://indicogni.com/learn/tla-plus/08-messages/
- Recaps:
CONCEPTS.md. Hints and explanation checks:HINTS.md. Predictions without answers:PREDICT.md. - Solutions:
solutions/chapters/08-messages/, including the gate references and their mutants. - Further reading: the alternating bit protocol was introduced by K. A. Bartlett, R. A. Scantlebury and P. T. Wilkinson, "A note on reliable full-duplex transmission over half-duplex links", Communications of the ACM 12(5), 1969. This chapter's version, names and constants are the course's own.
Beyond the lessons
- 08-review Review a teammate’s spec ·
chapters/08-messages/review/·./tla check 08-review - 08-ai1 AI item ·
chapters/08-messages/ai/1-assumes-fifo/·./tla check 08-ai1 - 08-ai2 AI item ·
chapters/08-messages/ai/2-correct-dedup/·./tla check 08-ai2 - 08-gate Gate ·
./tla check --gate 08Hints
Hint 1
Write
TypeOKandInitfirst, thenSendandHandleAck, which each change one variable. Run your cfg after each action, and expectDeliverto need the most thought.Hint 2
Nothing is ever taken out of
netoracks.DeliverandRedeliverdiffer only in whether the phone has seenn.Deliverchanges three variables.Redeliverwrites onlyacks, and in every reachable state that leavesacksas it was, because the first acknowledgement is still there. Write every new value from unprimed values.Hint 3 (nearly the answer; opening it marks a pass as "passed with help")
Safetyhas two halves, one per clause of the owner's sentence. The first is aboutshown. The second relatesunackedandshown: when may a notification leaveunacked? - 08-gate-twin Gate twin, another domain ·
./tla check --gate 08 --twinHints
Hint 1
Write
TypeOKandInitfirst, thenTransmitandConfirm, which each change one variable. Run your cfg after each action, and expectStoreto need the most thought.Hint 2
Nothing is ever taken out of
uplinkorconfirms.StoreandReconfirmdiffer only in whether the collector has storedr.Storechanges three variables.Reconfirmwrites onlyconfirms, and in every reachable state that leavesconfirmsas it was, because the first confirmation is still there. Write every new value from unprimed values.Hint 3 (nearly the answer; opening it marks a pass as "passed with help")
Safetyhas two halves, one per clause of the operator's sentence. The first is aboutcounted. The second relatesoutboxandcounted: when may a reading leave the outbox? - CP2 Checkpoint CP2 follows this chapter: mixed items from every chapter so far, with no hints.