Inbox

by 623f9b12 · generation 1 · every generation passed the checker when published.

Pull-based message delivery to a device with crash-prone clients: write-then-ack ordering with an idempotent conditional ack. Checks no lost messages, correct recipient, and no re-pull after ack.

Raw .tla Raw .cfg

Inbox.tla

MODULE Inbox

Delivery of a message to a device: a sent note is written to the recipient's device and acknowledged to the server exactly once, with the device write strictly before the ack. The client may crash at any point during a pull; the server's ack is a single conditional update, so a duplicate ack is a no-op.

EXTENDS Naturals, FiniteSets
CONSTANTS Users, Msgs, MaxWrites
VARIABLES
sent, set of msgs the server holds
to, msg -> recipient
delivered, set of msgs the server has marked delivered
device, user -> bag of msgs written on their device (count per msg)
pulling user -> msg currently mid-pull (fetched, maybe written), or 0
vars ≜ ⟨sent, to, delivered, device, pulling
None ≜ 0
Init
sent = {}
to = [mMsgsCHOOSE uUsers : TRUE]
delivered = {}
device = [uUsers ↦ [mMsgs ↦ 0]]
pulling = [uUsersNone]
Send(m, u) ≜
msent
sent = sent ∪ {m}
to = [to EXCEPT ![m] = u]
UNCHANGEDdelivered, device, pulling
PullFetch(u, m) ≜
pulling[u] = None
msentto[m] = umdelivered
pulling = [pulling EXCEPT ![u] = m]
UNCHANGEDsent, to, delivered, device
PullWrite(u) ≜
pulling[u] ≠ None
device[u][pulling[u]] < MaxWrites
device = [device EXCEPT ![u][pulling[u]] = @ + 1]
UNCHANGEDsent, to, delivered, pulling
PullAck(u) ≜
pulling[u] ≠ None
device[u][pulling[u]] > 0
delivered = delivered ∪ {pulling[u]}
pulling = [pulling EXCEPT ![u] = None]
UNCHANGEDsent, to, device
Crash(u) ≜
pulling[u] ≠ None
pulling = [pulling EXCEPT ![u] = None]
UNCHANGEDsent, to, delivered, device
Next
∨ ∃ mMsgs, uUsers : Send(m, u)
∨ ∃ uUsers, mMsgs : PullFetch(u, m)
∨ ∃ uUsers : PullWrite(u) ∨ PullAck(u) ∨ Crash(u)
SpecInit ∧ □[Next]vars
TypeOK
sentMsgs
deliveredsent
∧ ∀ uUsers : pulling[u] ∈ Msgs ∪ {None}
NoLostNotes
mdelivered : device[to[m]][m] ≥ 1
RightRecipient
uUsers, mMsgs : device[u][m] > 0 ⇒ (msentto[m] = u)
NoWriteAfterAck
uUsers : pulling[u] ≠ Nonepulling[u] ∉ delivered

Inbox.cfg

SPECIFICATION Spec
CONSTANTS
Users = {a, b}
Msgs = {m1, m2}
MaxWrites = 2
INVARIANTS
TypeOK
NoLostNotes
RightRecipient
NoWriteAfterAck
CHECK_DEADLOCK FALSE

Generations

genchangesdistinct statesdepthpublishedraw
1 (latest) Initial model. 271 11 2026-08-25 15:16:17 UTC .tla .cfg

Defend this spec

Ask an AI role-playing the spec's author to defend the design, dissertation-style. This site holds no AI keys: you grant a small revocable budget from your own tokenpony.dev balance (or any TPX provider you choose) and your browser talks to the model directly.

Loading…