Skip to content

fix: close the races that the new TLA+ models found, and add the models - #11

Merged
TudorAndrei merged 3 commits into
mainfrom
t3/fa8eb1bf
Nov 12, 2026
Merged

TudorAndrei merged 3 commits into
mainfrom
t3/fa8eb1bf

Conversation

@TudorAndrei

@TudorAndrei TudorAndrei commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Why

Only four node protocols had a TLA+ model. This adds models for the rest of the core (connecting, admission, reading a task's events, the agent socket, rosters, local administration) and fixes what TLC found with them. Every property that the code is meant to keep is now checked.

What changes

Six new models: DirectInvite, Admission, EventPaging, ConnectedAgent, ManagedRoster, PendingChange. ExecutionLease is back in line with the cancel code. specs/README.md lists what each one checks.

The fixes, by model:

Model What was wrong Fix
ExecutionLease A cancel kept for a turn that never started stopped the next run of the task Agent::forget, called when a run ends
DirectInvite Two sign_direct_invite calls for one person undid each other One call at a time in the process (SIGNING in invites.rs)
Admission The per-peer limit counted by agent name count goes by the caller's endpoint
Admission A full replay table dropped an entry before its TTL A full table answers Overloaded; REPLAY_LIMIT is 2408, all that the rate limit lets through in one TTL
Admission A task ID that another endpoint used refused the caller The row gets node-made IDs and keeps the caller's (node migration 018_task_caller_ids)
ConnectedAgent A cancel could reach the agent before its task; a turn could start on a connection that was over or replaced; a cancel was kept after its turn run_turn holds the pending lock until the task line is written; Turns::close; EarlyCancels::end drops the kept cancel
EventPaging follow stopped before the last page of events follow reads aetherMoreEvents
ManagedRoster A second spelling of the control URL brought a revoked member back A join does not clear revoked_at
ManagedRoster request_via_directory took a record of another agent validate_resolved compares the agent ID
ManagedRoster One expired or other-key record stopped directory sync for ever The sync skips such a record and moves the cursor
ManagedRoster Anyone could publish a revoked record again The control service refuses a record that does not expire after the last revoke, HTTP 409 (control migration 006_directory_record_marks)
PendingChange MCP UpdatePolicy saved a workspace or a higher limit with no confirmation Such a change is a pending change that the owner confirms in the UI; lowering stays direct
PendingChange A stop between the live change and its record lost the revision and the audit record The value, the revision and the audit record are one store transaction, written before the live change
PendingChange An expired pending change kept its ID queue_change removes expired rows

Behaviour that changes for an owner or an agent:

  • aether.settings.update_policy answers status: "pending" when it changes the task folder root or raises a limit.
  • After a directory revoke, the next record must expire later than the revoked one.
  • A caller that reuses its own task ID under another idempotency key gets "replay rejected", not "task store unavailable".
  • A connected agent that stops reading now also holds up cancels and a new connection, until it reads or closes.
  • An outbox task whose host always says "more events" stays active until the seven-day expiry.

Look at: keep_change in crates/aether-store/src/admin.rs and apply_now / settle in crates/aether/src/admin.rs; own_ids in crates/aether-store/src/tasks.rs; run_turn and serve in crates/aether/src/agent/connected.rs.

Evidence

  • mise run tla: all ten models pass, 4 min 55 s in total.
  • mise run fmt, mise run lint: pass.
  • mise run test: passes (429 unit tests in aether, 75 in aether-store, 96 feature scenarios).
  • Mutation checks on copies of the models: for each newly checked property, taking its fix out of the model made TLC report a violation.
  • New tests cover each fix, except the two below.
  • Not tested in Rust: the retry of a failed revert (settle), and the ID mapping in a2a_transport.rs (the store half is tested). The models cover both paths.
  • Not confirmed: most new tests were not run against the old code. The invite test and the MCP policy test did fail there.
  • Not run: mise run server-test, the hub-side features and the container proofs. No Elixir file changes.
  • Model limits: ConnectedAgent has one task ID; ManagedRoster has a directory log of three events (a run with four passed for the invariants only); Admission has one data value. The models do not read the code.

Merge danger

Door: one-way
Blast radius: every node and control service that upgrades

Two migrations add a column pair to the node's tasks table and a table to the control store; an older binary on an upgraded store was not tested. The wire formats do not change, so a node from this branch talks to released nodes and the hub as before. An MCP client that raised limits through update_policy now has to wait for the owner. mise run check takes about 5 minutes longer because of the models.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

TudorAndrei and others added 3 commits November 12, 2026 03:23
A lease renewal that failed before the start was confirmed left a cancel
in the adapter that no turn took. When the task was leased again, the
adapter cancelled its turn at the start, and the task ended as
unknown_result although no agent turn ran.

run_execution now calls Agent::forget after the renewal thread stops.
ExecutionLease.tla models the kept cancels and the single cancel of the
renewal thread, and checks NoSpuriousCancel.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rosters and admin changes

DirectInvite, Admission, EventPaging, ConnectedAgent, ManagedRoster and
PendingChange. specs/README.md lists what each model checks and each
property that TLC finds false, with the reason.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Invites: one sign_direct_invite call at a time. Admission: per-peer limit
by endpoint, no early replay eviction, node-made IDs on a task ID clash.
Connected agent: no cancel before its task, no turn on a connection that
is over, no cancel kept after its turn. Outbox: follow reads to the last
event page. Rosters: a revoke stays, a resolved record is for the agent
asked for, directory sync skips a record it cannot use, a revoked record
cannot be published again. Admin: MCP policy changes that widen access
need confirmation, and a change is stored with its revision and audit
record before it goes live.

Each model now checks the property that was false.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@TudorAndrei TudorAndrei changed the title fix(scheduler): drop a stale kept cancel, and add TLA+ models for the core protocols fix: close the races that the new TLA+ models found, and add the models Nov 12, 2026
@TudorAndrei
TudorAndrei merged commit a5ab699 into main Nov 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant