15-01
Chapter 15 · Distrust fluent specs
How plausible specs fail
00Recall
Two cards from 03-05 (what a passing TypeOK lets you say, and what CHECK_DEADLOCK FALSE changes about the system) and one from 06-05 (why a proper end is a guarded Finished step). All three are about the same thing: a green check that says less than it seems to. This chapter is that idea, applied to specs you did not write.
03-05-a from TypeOK, and the check you didn't configure
The cfg names only INVARIANT TypeOK, and TLC finds no violation. May you say the thermostat keeps the room comfortable?
Show answer
No, for two reasons. TLC never checked Comfortable, because the cfg did not name it. And even a cfg that names it gives "no violation found in this model": one finite model, not a proof.
03-05-b from TypeOK, and the check you didn't configure
What does CHECK_DEADLOCK FALSE change about the system?
Show answer
Nothing. It turns off TLC's deadlock report; any stuck state is still there.
06-05-b from Deadlock as TLC reports it
Why mark a proper end with a guarded Finished step rather than CHECK_DEADLOCK FALSE?
Show answer
Finished silences the report only in the intended end state, so every other stuck state is still reported. CHECK_DEADLOCK FALSE hides them all.
Skip recall Recall is never required.
01Commit
Two specs of a bounded retry queue. Workers take a job, try it, and acknowledge it or report a failure; a failed job is retried until it has used MaxAttempts tries, then it goes to a dead-letter set.
specs/RetryQueueByHand.tlais a teammate's first draft: one status per job, terse comments, aTODO. Its cfg checksTypeOKand the requirementAttemptsBounded, with two jobs andMaxAttempts = 2.ai/1-fluent-retry-queue/output/RetryQueue.tlacame from an AI assistant: four sets, a comment on every action, four invariants, a witness, and a message saying TLC found no violation, every action fired and the witness was reached. Its cfg uses two jobs andMaxAttempts = 1.
Commit a
Two retry queues, one drafted by a teammate and one written by an assistant, each checked with its author's cfg. Which one has a bug?
- The teammate's. It reads like a first draft, and the assistant's check passed.
- The assistant's. Model output needs checking; a colleague's draft less so.
- Both.
- Neither. Each author ran TLC on their own cfg.
Answer Both.
- If you picked A
- The assistant's check passed in a model where its bug cannot happen. A pass is a statement about one model, and this model is too small for the one action that matters to run. Polish is not evidence either way.
- If you picked B
- The teammate's draft fails its own cfg on the first run. TLC does not care who wrote a spec, and neither should your review: judge each one by what a check shows.
- If you picked D
- One of them did run TLC on its own cfg and got a violation. The other got a pass in a model too small to contain its bug. "I ran TLC" is where a review starts.
Commit b
The assistant's cfg sets MaxAttempts = 1, and ./tla ai-check reports that every action in Next fires. What does that tell you about Requeue, the helper that Fail calls when a job has attempts left?
- Nothing about Requeue.
- Requeue ran at least once, or coverage would have flagged it.
- The run is broken: Requeue is not an action of Next, so TLC should have refused it.
Answer Nothing about Requeue.
- If you picked B
- Requeue is a helper inside Fail, not an action of Next, and Fail fired every time a job failed, through DeadLetter.
- If you picked C
- Helpers are ordinary operators. TLC evaluates Requeue(j) only when Fail's IF picks it, and with MaxAttempts = 1 that condition is never true. Nothing is wrong with the run; it is just not looking where the bug is.
02Lab
Run both specs as their authors did:
./tla check chapters/15-distrust-fluent-specs/specs/RetryQueueByHand.cfg
./tla check 15-ai1
./tla ai-check chapters/15-distrust-fluent-specs/ai/1-fluent-retry-queue/output/RetryQueue.tlaThe last command is the full report on the assistant's spec, with the coverage and witness lines its message quotes.
15-distrust-fluent-specs/specs/RetryQueueByHand15-distrust-fluent-specs/specs/RetryQueueByHand RetryQueueByHand.cfg (Jobs={j1, j2}, MaxAttempts=2)
parse ok
model check: invariant AttemptsBounded violated; trace has 6 states (5 steps); 37 distinct states
expected outcome met: violation AttemptsBounded
trace (changed variables only; ./tla trace --full shows all):
1 Init status = (j1 :> "queued" @@ j2 :> "queued"), tries = (j1 :> 0 @@ j2 :> 0)
2 StartJob status: (j1 :> "queued" @@ j2 :> "queued") -> (j1 :> "running" @@ j2 :> "queued"), tries: (j1 :> 0 @@ j2 :> 0) -> (j1 :> 1 @@ j2 :> 0)
3 RetryJob status: (j1 :> "running" @@ j2 :> "queued") -> (j1 :> "queued" @@ j2 :> "queued")
4 StartJob status: (j1 :> "queued" @@ j2 :> "queued") -> (j1 :> "running" @@ j2 :> "queued"), tries: (j1 :> 1 @@ j2 :> 0) -> (j1 :> 2 @@ j2 :> 0)
5 RetryJob status: (j1 :> "running" @@ j2 :> "queued") -> (j1 :> "queued" @@ j2 :> "queued")
6 StartJob status: (j1 :> "queued" @@ j2 :> "queued") -> (j1 :> "running" @@ j2 :> "queued"), tries: (j1 :> 2 @@ j2 :> 0) -> (j1 :> 3 @@ j2 :> 0)15-distrust-fluent-specs/ai/1-fluent-retry-queue/output/RetryQueue15-ai1 RetryQueue.cfg (Jobs={j1, j2}, MaxAttempts=1)
parse ok
model check: no violation found in 16 distinct states (29 generated, depth 5)
expected outcome met: pass
coverage: all 4 actions fired
witness AllSettled reached (trace of 5 states)Reveal for commit a
Both. The teammate's draft violates AttemptsBounded in a trace of 6 states (5 steps): RetryJob checks tries[j] <= MaxAttempts where it needed <, so a job that has used its last try goes back to the queue and is started once more. The assistant's queue passes, after 16 distinct states, and is also wrong: its Requeue puts the job back in pending and leaves it in inflight. With MaxAttempts = 1 the requeue never runs, so no invariant ever meets it. In 15-ai1 you raise the constant and watch NoDoubleDelivery fail.
Reveal for commit b
Nothing about Requeue. The coverage line of ./tla ai-check reports per named action of Next. Fail fired, through its DeadLetter branch, every time a job failed; the Requeue branch needs attempts[j] < MaxAttempts, and a job reaches Fail only after Deliver has raised its count to MaxAttempts, so the condition is never true. The claim "every action fires" was true, and the conclusion a reader draws from it was not. TLC's own coverage report, in the raw log that ./tla names, counts every expression it evaluated; there, the lines of Requeue were never evaluated.
03Reason
If you picked the teammate's draft, you let the polish stand in for the check. If you picked the assistant's, you were right about one spec for a reason that would mislead you about the next. TLC does not care who wrote a spec. Neither should your review. And if you read "every action fired" as "every line ran", you read more into the coverage line than it says.
So what does a plausible spec look like? It parses. It reads well. And it passes its author's own check. That last part is the trap. Each of the two queues failed in a way its author's cfg could not see, and each way has a name.
Write something before openingthe assistant's spec has two flaws working together. Name them in your own words.
The first is in the spec: Requeue frames the wrong variable. "Nothing else changes" is a promise that inflight stays as it is, so a requeued job is waiting and running at once. The second is in the configuration: one attempt per job is a model in which no job is ever retried, so the first flaw never runs. The frame bug alone is caught by any model in which a job can retry. The small model alone hides nothing, because there is nothing to hide. Together they pass.
Those two names come from a fixed list, the course's failure taxonomy. Every AI item in the course carries one or more of its tags. They fall into three families: what the spec says, what the model and cfg let TLC see, and what someone claims about the result. The table gives one example of each tag and the check that usually reveals it.
| Tag | What it looks like | Usually revealed by |
|---|---|---|
hallucinated-operator | Min used as if Naturals defined it | SANY (15-ai2) |
missing-enabling-condition | Acquire checks the caller's own lease, not everyone's | a violation (15-ai3) |
missing-frame | a variable left out of a step, or the wrong one held still | a TLC error, or a violation in a big enough model (15-01-ex1, 15-ai1) |
wrong-fairness | weak fairness where the system needs strong, or fairness the hardware never promised | a liveness violation, or a pass that assumes too much (15-mx) |
vacuous-property | a property over a set nothing ever adds to | mutation: it kills nothing (15-ai4) |
over-constrained-init | Init pins a variable the real system can start anywhere | coverage (15-ai5) |
stuttering-blind | a property or mapping that breaks when another part of the system takes a step | chapter 04, chapter 11 |
type-only-invariant | TypeOK as the only safety claim | mutation (03-ai1) |
refinement-mapping-wrong | implementation states mapped to the wrong abstract states | the refinement check (chapter 11) |
assumes-fifo | a network modelled as a queue when it can reorder | a violation once the channel is a set (chapter 08) |
unbounded-model | a counter with no bound, so TLC never finishes | a run that never ends (chapter 12) |
model-too-small | constants too small for the bug to fit | a violation in a bigger model (15-ai1, 15-01-ex2) |
deadlock-masked | CHECK_DEADLOCK FALSE over a real stuck state | a deadlock once the switch is gone (03-review) |
property-not-configured | the requirement is defined but not named in the cfg | reading the cfg (03-05, 15-01-ex2) |
constraint-hides-bug | a CONSTRAINT that cuts out the failing behaviors | coverage and witnesses (15-ai11) |
symmetry-unsound | SYMMETRY with liveness, or over values that are not interchangeable | TLC's warning (12-03) |
overclaimed-evidence | a message that says more than the check showed | you, with the output in hand (03-ai1) |
spec-gaming | weakening the check instead of fixing the system | protected files, witness and coverage reruns (15-05) |
correct | no flaw in what is claimed | evidence: witnesses, coverage, killed mutants (15-ai6, 15-ai7) |
The table is not for memorising. It is a set of questions to ask of any spec you did not write, and of your own: does every variable change only where it should? Can every guarded branch run in this model? Is the requirement in the cfg at all?
Write something before openingthe last paragraph of the assistant's message says a larger MaxAttempts "only adds more retries of the same shape". Which tag is that, and what would have tested it?
overclaimed-evidence: one result about one model, stated as a claim about every model. The test is cheap: run the cfg with MaxAttempts = 2, the smallest value that lets a job be retried. A good habit is to pick constants so that every guarded branch can run, and say why in a comment, as the course's specs/RetryQueue.cfg does.
The teammate's draft was caught by the plainest tool there is: the requirement was in the cfg, and TLC refuted it on the first run. Being caught is not a failure of the author. Shipping a check that cannot catch anything is.
04In your editor
The two queues are chapters/15-distrust-fluent-specs/specs/RetryQueueByHand.tla and chapters/15-distrust-fluent-specs/ai/1-fluent-retry-queue/output/RetryQueue.tla. The course's reference queue, with every guarded branch reachable, is specs/RetryQueue.tla. Check this lesson's exercises and specs with:
./tla check 15-01The command runs several cfgs. Read the RetryQueue.cfg block from specs/ first: it is the reference passing, with every action firing and both witnesses reached.
15-distrust-fluent-specs/specs/RetryQueue15-distrust-fluent-specs/specs/RetryQueue RetryQueue.cfg (Jobs={j1, j2}, MaxAttempts=2)
parse ok
model check: no violation found in 49 distinct states (94 generated, depth 9)
expected outcome met: pass
coverage: all 5 actions fired
witness RetriedThenDone reached (trace of 5 states)
witness DeadLettered reached (trace of 5 states)05Practice
Warm-up. The reference queue with one frame cut short. TLC refuses to run it, and tells you why.
Core. An assistant's print spooler and its three-line cfg. Three configuration-side tags hide in those three lines; fix the cfg so that TLC can see the bug.
AI item. 15-ai1: the assistant's queue from this lesson. Raise the constant, read the trace, and write down why the assistant's own check could not see it.
15-01-ex1Warm-up5 min
15-01-ex1 · Frame the ack
Tier: warm-up. Time: about 5 minutes.
The course's retry queue from 15-01, with one line of Ack cut short. It is a missing-frame flaw, and here TLC stops with an error the first time it tries to take an Ack step, before any invariant can be violated.
- Run
./tla check 15-01-ex1and read the error. Which action does TLC name, and which variable? - Say in one sentence what a successful attempt should do to that variable. Then fill gap g1 in
RetryQueue.tla. - Run the check again. It must pass with every action firing and both witnesses reached.
TLC stops because it cannot compute the state after Ack. A missing frame does not always stop TLC: in 15-ai1 the frame is present and wrong, and the spec runs. Before you move on, write down which of the two you would rather meet in review.
Hints: HINTS.md, under "15-01-ex1 hint 1" to "hint 3". The solution is in solutions/chapters/15-distrust-fluent-specs/exercises/01-ex1-frame-the-ack/; open it after you have a passing answer of your own.
If TLC finds no violation but an action never fires or a witness is not reached, ./tla prints "goal not met" and exits with code 1.
Done when: ./tla check 15-01-ex1 prints "goal met: pass".
./tla check 15-01-ex1
Repo chapters/15-distrust-fluent-specs/exercises/01-ex1-frame-the-ack/
Hints
Hint 1
TLC names one action and one variable. Look at the action's UNCHANGED tuple and list the variables it does not mention.
Hint 2
A successful attempt moves the job from inflight to done. Does it hand the job out again? Then the attempt counter has no reason to change.
Hint 3 (nearly the answer)
The fix is one name in Ack's frame. Which variable does TLC say is not defined, and does a successful attempt change it? Delete the \* GAP marker when you are done.
15-01-ex2Core8 min
15-01-ex2 · Configure the spooler
Tier: core. Time: about 8 minutes.
An assistant wrote Spooler.tla, a print spooler for one printer, and a three-line cfg. The spec states the requirement as OnePrinting. The cfg passes. Three of the configuration-side tags from 15-01 are in those three lines.
- Run
./tla check 15-01-ex2. It passes. Before reading on, write down the three tags you suspect. - For each line in gap g1 of
Spooler.cfg, ask what it hides. How many jobs does the model have, and can one job show two jobs printing at once? Which claims does the cfg ask TLC to check, and is the requirement one of them? The comment gives a reason for one end: what else would the switch hide? - Rewrite gap g1 with the checks this model needs. Keep
SPECIFICATION Spec. Run the check and read the trace.
The goal is a violation: once the cfg checks what it should, TLC finds the bug in Start. You do not fix the spec in this exercise. The check grades the first two tags; the violation comes before any deadlock, so it cannot see whether you kept the switch. That part is yours: if a switch stays in your cfg, its comment must say what real deadlock it would also hide.
Hints: HINTS.md, under "15-01-ex2 hint 1" to "hint 3". The solution is in solutions/chapters/15-distrust-fluent-specs/exercises/01-ex2-configure-the-spooler/; open it after you have an answer of your own.
Done when: ./tla check 15-01-ex2 prints "goal met: violation OnePrinting".
./tla check 15-01-ex2
Repo chapters/15-distrust-fluent-specs/exercises/01-ex2-configure-the-spooler/
Hints
Hint 1
Read the three lines as three answers: how big is the model, which claims are checked, and which outcome is switched off?
Hint 2
With one job, at most one job can ever be printing, so OnePrinting cannot fail. The requirement is defined in the module but not named in the cfg. The deadlock comment describes an end the spec does not mark with a step.
Hint 3 (nearly the answer)
Give Jobs two model values, add an INVARIANT line for OnePrinting after TypeOK, and remove CHECK_DEADLOCK FALSE. If the stuck state is a proper end, mark it in the spec with a guarded Finished step, as in 06-05, instead of switching the check off. TLC then shows two jobs printing at once.
06Explain it
Open NOTES.md and answer the three prompts under 15-01, about the Core exercise.
What I built, and why it is correct:
Which assumption, if false, breaks it:
What TLC did not check here:Compare your answers with "15-01 check your explanation" in HINTS.md.
After you writeCheck your explanation
Good: "I configured the spooler with two jobs and named OnePrinting, so TLC could reach a state where two jobs print at once, and it did: Start has no guard on the printer being free. The assumption that breaks it is the model size: with one job the requirement cannot fail. TLC did not check that the spooler ever finishes, or any number of jobs other than two."
Weak: "I fixed the cfg and now TLC finds the bug, so the cfg is correct."
The weak answer names no tag and no reason. It does not say why the original cfg could not fail, which is the whole lesson.
Done?