Repository navigation
test(formal): model-check the step journal's epoch fencing with TLA+ - #491
Merged
Merged
Conversation
earakely-scale
approved these changes
Nov 4, 2026
The store promises that a write from a rolled-back or superseded attempt never lands, and that replaying the live journal reproduces the stored context. Unit tests reach a few interleavings of that promise. TLC checks all of them within a bound, and each mutation shows a guard is load-bearing. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…safe `one` exited 0 when TLC could not check the model. A relative AGENTENV_TLA_CACHE broke once run changed directory, and concurrent cold runs shared one temporary download file. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
andrewpark-scaleai
force-pushed
the
andrew-park/formal-step-journal
branch
from
November 4, 2026 21:13
256b1df to
12eedbe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The task-instance store promises that a write from a rolled-back or superseded attempt never lands, and that replaying the live journal reproduces the stored context. The unit tests check a few hand-picked orders of those writes. This adds a TLA+ model of the store calls and the scheduler that makes them. TLC checks every order within a small bound: one retry, a cancelled step whose write lands late, and a second process that re-registers the run.
tst/formal/step_journal/StepJournal.tlanames the code that each action stands for.check.shfetches TLC 1.7.4, checks its sha256, and runs the baseline or the mutation suite.AGENTS.mdbeside the model says which code it covers, how to read a counterexample, and how to update the model.AGENTS.mdliststst/formal/as a by-hand tier.The model describes the code with the
seed_contextfence from #490. Without that fence,takeover.cfgfails.No CI job runs the check. It needs Java and one download from GitHub, and the baseline takes about 30 seconds, so CI wiring is left for a separate decision. The guide lists what the model does not cover, such as context contents, store failures and other task shapes.
How it was tested
tst/formal/step_journal/check.sh:singleandtakeoverhold, at 4,697 and 3,104,845 distinct states.check.sh mutations: each of the 9 mutations that removes a guard breaks the invariants it names.NoCasGenerationCheckholds as expected, because every re-register also incrementsattempt_epoch.javaonPATH,check.shexits 2 with a message that names the problem.

Confidence Score: 5/5
The PR appears safe to merge; no actionable new issues remain.Summary
Adds a manually run TLA+ model of the step journal’s epoch fences and replay behavior.
Review used the full PR diff because the ancestry and merge-base checks did not pass. TLC was not run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Register run and capture epoch] --> B[Write seed and journal row] B --> C[Run steps] C --> D[Write journal row] D --> E{Epoch and generation still match?} E -->|Yes| F[Save completion] E -->|No| G[Reject completion and remove its row] C --> H[Retry] H --> I[Undo steps and advance epoch] I --> C J[Second process registers run] --> K[Advance epoch and generation]Reviews (3) · Last reviewed commit: "fix(formal): fail check.sh one on a TLC ..." · Reviewed by Greptile