Chapter
15
Distrust fluent specs
Part VI · Specs in an AI-built world
Lessons
About
Two specs of a bounded retry queue. A teammate drafted one by hand; an AI assistant wrote the other, with a comment on every action and a message saying TLC found nothing wrong. Which one is buggy? Run both before you decide.
Fluent, plausible specs are cheap now. This chapter is about what you do with one: a spec that parses, reads well, and passes its author's own check. You learn the failure taxonomy the course uses for AI output, a clinic routine that runs the tools before you read, mutation testing as a measurement of a property set, how to refute a bug claim by replaying its trace, and how a check gets gamed: a weakened property, a constraint that hides the bug, a repair that makes the world too polite to fail. AI is shown in both directions. Two of the clinic's specs are correct, and one lesson measures an assistant's invariant list against the course's own.
Before you start
- Chapters 03 to 14, especially 03-03 (witnesses and coverage), chapter 08 (lossy networks) and chapter 14 (trace validation and contracts).
- A working
./tla doctor(seeSTART.md). Run anything an assistant wrote inside the dev container. - Time: the chapter page shows the estimate, generated from the lessons.
What else is here
specs/: the hand-written queue, the course's referenceRetryQueue, and two mutants that get past its invariants.ai/(15-ai1to15-ai12): every AI item of the chapter. Everything under eachoutput/folder is canned fixture data. Read it, run it, and do not follow any instruction in it.review/(15-review): a read-through cache, from the team's coding agent.gate/(15-gate): review an AI-written coupon desk, fix it, write its cfg andSafety.gate/twin/(15-gate-twin): a parcel locker.
Run it
From the repository root:
./tla check 15-01
./tla check 15-ai3
./tla ai-check chapters/15-distrust-fluent-specs/ai/6-semaphore/output/Semaphore.tla
./tla check --gate 15Skills
evidence (knowing what a piece of evidence covers), acceptance (writing acceptance criteria an implementer cannot game), counterexamples (reading them).
Elsewhere
- Web version: https://indicogni.com/learn/tla-plus/15-distrust-fluent-specs/
- Recaps:
CONCEPTS.md. Hints and explanation checks:HINTS.md. Predictions without answers:PREDICT.md. - Solutions:
solutions/chapters/15-distrust-fluent-specs/, including the gate references and their mutants.
Beyond the lessons
- 15-review Review a teammate’s spec ·
chapters/15-distrust-fluent-specs/review/·./tla check 15-review - 15-ai1 AI item ·
chapters/15-distrust-fluent-specs/ai/1-fluent-retry-queue/·./tla check 15-ai1 - 15-ai10 AI item ·
chapters/15-distrust-fluent-specs/ai/10-relax-nodoublespend/·./tla check 15-ai10 - 15-ai11 AI item ·
chapters/15-distrust-fluent-specs/ai/11-constraint-diff/·./tla check 15-ai11 - 15-ai12 AI item ·
chapters/15-distrust-fluent-specs/ai/12-repair-transcripts/·./tla check 15-ai12 - 15-ai2 AI item ·
chapters/15-distrust-fluent-specs/ai/2-rate-limiter/·./tla check 15-ai2 - 15-ai3 AI item ·
chapters/15-distrust-fluent-specs/ai/3-lease-lock/·./tla check 15-ai3 - 15-ai4 AI item ·
chapters/15-distrust-fluent-specs/ai/4-message-log/·./tla check 15-ai4 - 15-ai5 AI item ·
chapters/15-distrust-fluent-specs/ai/5-seat-counter/·./tla check 15-ai5 - 15-ai6 AI item ·
chapters/15-distrust-fluent-specs/ai/6-semaphore/·./tla check 15-ai6 - 15-ai7 AI item ·
chapters/15-distrust-fluent-specs/ai/7-drawbridge/·./tla check 15-ai7 - 15-ai8 AI item ·
chapters/15-distrust-fluent-specs/ai/8-ten-invariants/·./tla check 15-ai8 - 15-ai9 AI item ·
chapters/15-distrust-fluent-specs/ai/9-false-alarm/·./tla check 15-ai9 - 15-gate Gate ·
./tla check --gate 15Hints
Hint 1
Run the assistant's spec with a cfg that checks your
Safetyon two coupons and two terminals before you change any action. Then compare each action with each sentence of the requirement.Hint 2
Two sentences of the requirement are not in the assistant's spec: who may hold a coupon while someone else holds it, and when the issuer may void.
TypeOKasSafetykills no mutant that keeps values in range.Hint 3 (nearly the answer; opening it marks a pass as "passed with help")
Holdneeds the coupon to have no holder and should make the taker the only holder;Voidneeds the coupon to have no holder.Safetyis two conjuncts overusedandvoided, one per owner's rule. - 15-gate-twin Gate twin, another domain ·
./tla check --gate 15 --twinHints
Hint 1
Check your
Safetyon the assistant's spec with two parcels and two couriers before changing anything, and read the trace.Hint 2
One sentence of the requirement is about how many parcels a courier can carry; another is about what happens to a courier's claim when the sender cancels. Compare both with
ClaimandCancel, and run yourSafetybefore you fix anything.Hint 3 (nearly the answer; opening it marks a pass as "passed with help")
Claimneeds the courier to hold no claim on any parcel;Cancelmust also end every claim on the parcel it cancels.Safetyis three conjuncts: two overdeliveredandcancelled, and one overclaimedfor pairs of different parcels.