-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add TLA+ model for deployment concurrency leases #23030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
desertaxle
wants to merge
9
commits into
main
Choose a base branch
from
codex/tla-plus-deployment-concurrency
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,510
−4
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
149b932
Add TLA+ deployment concurrency model
desertaxle e04dc07
Replace TLA+ plans with durable guidance
desertaxle b7928ed
Condense TLA+ maintenance guidance
desertaxle ce9e5f3
Remove TLA+ model adoption status
desertaxle 4858719
Point server agents to TLA+ model
desertaxle a0a8aad
Fix TLA+ counterexample coverage
desertaxle 032e6a7
Model duplicate reapers and reacquisition
desertaxle f52502a
Clarify TLA+ model scope and refinement
desertaxle ce88c86
Clarify TLA+ slot-writer assumption
desertaxle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: TLA+ model check | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| pull_request: | ||
| paths: | ||
| - .github/workflows/tla-plus.yaml | ||
| - "formal/tla/**" | ||
|
|
||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - .github/workflows/tla-plus.yaml | ||
| - "formal/tla/**" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| env: | ||
| TLA_TOOLS_VERSION: "1.7.4" | ||
| TLA_MODEL_DIR: formal/tla/deployment-concurrency | ||
|
|
||
| jobs: | ||
| check-deployment-concurrency: | ||
| name: Deployment concurrency | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Java | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: temurin | ||
| java-version: "21" | ||
|
|
||
| - name: Download TLA+ tools | ||
| run: | | ||
| tla_tools_url="https://github.com/tlaplus/tlaplus/releases/download/" | ||
| tla_tools_url+="v${TLA_TOOLS_VERSION}/tla2tools.jar" | ||
| tla_tools_sha256="936a262061c914694dfd669a543be2457" | ||
| tla_tools_sha256+="3c45d5aa0ff20a8b96b23d01e050e88" | ||
| curl --fail --location --silent --show-error \ | ||
| "$tla_tools_url" \ | ||
| --output "$RUNNER_TEMP/tla2tools.jar" | ||
| printf '%s %s\n' \ | ||
| "$tla_tools_sha256" \ | ||
| "$RUNNER_TEMP/tla2tools.jar" \ | ||
| | sha256sum --check - | ||
|
|
||
| - name: Check target protocol | ||
| run: | | ||
| mkdir -p "$RUNNER_TEMP/tlc/target" | ||
| java -XX:+UseParallelGC \ | ||
| -jar "$RUNNER_TEMP/tla2tools.jar" \ | ||
| -workers 1 \ | ||
| -metadir "$RUNNER_TEMP/tlc/target" \ | ||
| -config "$TLA_MODEL_DIR/DeploymentConcurrency.cfg" \ | ||
| "$TLA_MODEL_DIR/DeploymentConcurrency.tla" | ||
|
|
||
| - name: Check expected counterexamples | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| check_counterexample() { | ||
| local config="$1" | ||
| local invariant="$2" | ||
| local name="${config%.cfg}" | ||
| local output="$RUNNER_TEMP/tlc/${name}.log" | ||
|
|
||
| mkdir -p "$RUNNER_TEMP/tlc/$name" | ||
| set +e | ||
| java -XX:+UseParallelGC \ | ||
| -jar "$RUNNER_TEMP/tla2tools.jar" \ | ||
| -workers 1 \ | ||
| -metadir "$RUNNER_TEMP/tlc/$name" \ | ||
| -config "$TLA_MODEL_DIR/$config" \ | ||
| "$TLA_MODEL_DIR/DeploymentConcurrency.tla" \ | ||
| 2>&1 | tee "$output" | ||
| local status="${PIPESTATUS[0]}" | ||
| set -e | ||
|
|
||
| if [[ "$status" -ne 12 ]]; then | ||
| echo "Expected TLC exit 12 for $config, got $status" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| if ! grep -Fq "Invariant $invariant is violated." "$output"; then | ||
| echo "Expected $config to violate $invariant" >&2 | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| check_counterexample \ | ||
| CounterexampleStaleReap.cfg \ | ||
| RenewWinsAgainstStaleScan | ||
| check_counterexample \ | ||
| CounterexampleFallbackRelease.cfg \ | ||
| NoForeignRelease | ||
| check_counterexample \ | ||
| CounterexampleReadPresentRelease.cfg \ | ||
| NoForeignRelease | ||
| check_counterexample \ | ||
| CounterexampleFlowRunDeletion.cfg \ | ||
| NoForeignRelease |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # TLA+ Protocol Models | ||
|
|
||
| Add a model only when a bounded concurrency question can change a design or | ||
| preserve a regression that cheaper tests cannot establish. | ||
|
|
||
| ## Model contract | ||
|
|
||
| - Label each configuration as current, target, or intentionally unsafe. Model | ||
| or isolate current failure behavior before a repair; a target remains a | ||
| proposal until mapped production tests pass. | ||
| - Keep independently durable stores, queues, transactions, and clocks distinct | ||
| unless production makes them atomic. State fairness and availability | ||
| assumptions; never infer liveness from a safety-only run. | ||
| - For each design-critical safety claim, include an unsafe configuration that | ||
| violates the exact named invariant, with bounds that admit the contested | ||
| trace and make critical actions reachable. | ||
|
|
||
| Each model README records its question, owner, bounds, assumptions and | ||
| exclusions, configuration status, invariants, commands and expected results, | ||
| action/state-to-production mapping, and review triggers. Every production | ||
| writer of modeled state must map to an action or be explicitly out of scope. | ||
|
|
||
| Translate relevant counterexamples into deterministic behavior tests using | ||
| explicit barriers, not sleeps. A target is implemented only when mapped | ||
| contract tests pass; check database locking or serialization against | ||
| PostgreSQL. Keep the model and its test oracle independent of production code. | ||
|
|
||
| ## CI and lifecycle | ||
|
|
||
| - Pin JDK and TLA+ tool versions, verify downloads by checksum, run targets as | ||
| expected-green, and verify each unsafe configuration's exact exit and named | ||
| invariant. Do not commit tool JARs or TLC metadata. | ||
| - Keep a new check advisory until its owner accepts the scope, invariants, | ||
| runtime, and diagnostics. | ||
| - Remove an unowned, unmappable, or obsolete model and its dedicated CI; | ||
| preserve useful production regressions. | ||
24 changes: 24 additions & 0 deletions
24
formal/tla/deployment-concurrency/CounterexampleFallbackRelease.cfg
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| \* Expected to violate NoForeignRelease with the live-claim guard off. | ||
| SPECIFICATION FallbackSpec | ||
|
|
||
| CONSTANTS | ||
| Runs = {r1, r2} | ||
| LeaseIds = {l1, l2} | ||
| Limit = 1 | ||
| MaxEpoch = 2 | ||
| NoRun = NoRun | ||
| NoLease = NoLease | ||
| RecheckExpiryAtRevoke = TRUE | ||
| FallbackDecrementsAggregate = TRUE | ||
| RequireClaimForDecrement = FALSE | ||
|
|
||
| CHECK_DEADLOCK FALSE | ||
|
|
||
| INVARIANTS | ||
| TypeOK | ||
| CounterBounds | ||
| ClaimCapacitySafety | ||
| OwnershipConsistent | ||
| NoForeignRelease | ||
| AccountingConsistent | ||
| RenewWinsAgainstStaleScan |
24 changes: 24 additions & 0 deletions
24
formal/tla/deployment-concurrency/CounterexampleFlowRunDeletion.cfg
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| \* Expected to violate NoForeignRelease after deletion leaves its lease live. | ||
| SPECIFICATION DeletionSpec | ||
|
|
||
| CONSTANTS | ||
| Runs = {r1, r2} | ||
| LeaseIds = {l1, l2} | ||
| Limit = 1 | ||
| MaxEpoch = 2 | ||
| NoRun = NoRun | ||
| NoLease = NoLease | ||
| RecheckExpiryAtRevoke = TRUE | ||
| FallbackDecrementsAggregate = FALSE | ||
| RequireClaimForDecrement = FALSE | ||
|
|
||
| CHECK_DEADLOCK FALSE | ||
|
|
||
| INVARIANTS | ||
| TypeOK | ||
| CounterBounds | ||
| ClaimCapacitySafety | ||
| OwnershipConsistent | ||
| NoForeignRelease | ||
| AccountingConsistent | ||
| RenewWinsAgainstStaleScan |
24 changes: 24 additions & 0 deletions
24
formal/tla/deployment-concurrency/CounterexampleReadPresentRelease.cfg
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| \* Expected to violate NoForeignRelease under the current split release order. | ||
| SPECIFICATION ReadPresentSpec | ||
|
|
||
| CONSTANTS | ||
| Runs = {r1, r2} | ||
| LeaseIds = {l1, l2} | ||
| Limit = 1 | ||
| MaxEpoch = 2 | ||
| NoRun = NoRun | ||
| NoLease = NoLease | ||
| RecheckExpiryAtRevoke = TRUE | ||
| FallbackDecrementsAggregate = FALSE | ||
| RequireClaimForDecrement = FALSE | ||
|
|
||
| CHECK_DEADLOCK FALSE | ||
|
|
||
| INVARIANTS | ||
| TypeOK | ||
| CounterBounds | ||
| ClaimCapacitySafety | ||
| OwnershipConsistent | ||
| NoForeignRelease | ||
| AccountingConsistent | ||
| RenewWinsAgainstStaleScan |
24 changes: 24 additions & 0 deletions
24
formal/tla/deployment-concurrency/CounterexampleStaleReap.cfg
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| \* Expected to violate RenewWinsAgainstStaleScan with the deadline guard off. | ||
| SPECIFICATION StaleReapSpec | ||
|
|
||
| CONSTANTS | ||
| Runs = {r1, r2} | ||
| LeaseIds = {l1, l2} | ||
| Limit = 1 | ||
| MaxEpoch = 2 | ||
| NoRun = NoRun | ||
| NoLease = NoLease | ||
| RecheckExpiryAtRevoke = FALSE | ||
| FallbackDecrementsAggregate = FALSE | ||
| RequireClaimForDecrement = TRUE | ||
|
|
||
| CHECK_DEADLOCK FALSE | ||
|
|
||
| INVARIANTS | ||
| TypeOK | ||
| CounterBounds | ||
| ClaimCapacitySafety | ||
| OwnershipConsistent | ||
| RenewWinsAgainstStaleScan | ||
| NoForeignRelease | ||
| AccountingConsistent |
23 changes: 23 additions & 0 deletions
23
formal/tla/deployment-concurrency/DeploymentConcurrency.cfg
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| SPECIFICATION ClaimAuthoritySpec | ||
|
|
||
| CONSTANTS | ||
| Runs = {r1, r2} | ||
| LeaseIds = {l1, l2} | ||
| Limit = 1 | ||
| MaxEpoch = 2 | ||
| NoRun = NoRun | ||
| NoLease = NoLease | ||
| RecheckExpiryAtRevoke = TRUE | ||
| FallbackDecrementsAggregate = FALSE | ||
| RequireClaimForDecrement = TRUE | ||
|
|
||
| CHECK_DEADLOCK FALSE | ||
|
|
||
| INVARIANTS | ||
| TypeOK | ||
| CounterBounds | ||
| ClaimCapacitySafety | ||
| OwnershipConsistent | ||
| NoForeignRelease | ||
| AccountingConsistent | ||
| RenewWinsAgainstStaleScan |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.