Skip to content

test(sim): resubmit executed mutations - #82

Merged
kyscott18 merged 1 commit into
mainfrom
sim/resubmissions
Oct 27, 2026
Merged

kyscott18 merged 1 commit into
mainfrom
sim/resubmissions

Conversation

@kyscott18

Copy link
Copy Markdown
Collaborator

What

The simulation plan now resubmits mutations. A step drawn at SIM.generator.resubmitRate (0, 0.01, 0.1 or 1) calls execute twice, concurrently, with the same mutation. The first call must get the usual result. The second must fail with InvalidNonce, or with the step's own revert when the step is planned to revert, since a reverted mutation does not use its nonce.

Only steps sent through execute are resubmitted. A duplicate enqueue is an onchain transaction that is force-included and rejected, which needs a different event model.

Ordering

The first call is forked with Effect.forkChild(..., { startImmediately: true }). It runs at once, outside the sim's scheduler, until it waits on its result, which is after Queue.offer. Only then does the second call start. Production gives the same order, since the default scheduler starts fibers in fork order and execute reaches Queue.offer without suspending. Without startImmediately, the sim's seeded scheduler picks a random ready fiber, so either call could be queued first.

Validation

  • The run waits for every resubmission to be rejected, as well as every mutation to settle. A resubmission's rejected event no longer counts as its original settling.
  • A resubmission has the same mutation key as its original. For each resubmitted key, the validator takes the second received and the last rejected as the resubmission's events, checks they exist, and checks the rest against the usual expected statuses.
  • Arrival order for the FIFO and batch checks counts only the first received of each key.

The new draw in makePlan shifts later draws, so existing seeds will not reproduce the same runs.

Testing

  • tsc --noEmit and biome check pass.
  • Seeds with resubmissions pass: 0x80ff88d7d7c613a74ea464ffcde8c40c49cf44f9612656a0e7ab87851d227c99 (rate 1, 196 steps, batch), 0x51bc4127979feb9330845c0fd5795b63aea7c243a5edf0aa3977b99c26f91e0e (rate 0.1, FIFO), 0x4e21c5d7fdcdb68411066f7f2c5dc5f9d99f71e4933ba493b054faf148527aee (rate 1, batch).
  • With startImmediately off, 0x4e21… fails with step 0 (resubmit A): got success, want InvalidNonce.
  • 30 of 30 random seeds pass.

🤖 Generated with Claude Code

A step drawn at `SIM.generator.resubmitRate` executes its mutation twice,
concurrently. The first submission is forked with `startImmediately`, so it
is queued before the second starts, as in production. The second fails with
`InvalidNonce`, or with the step's own revert when the first one reverts.
The validator takes a resubmission's `received` and `rejected` events apart
from the first submission's, and counts only the first `received` of a key
as its arrival.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyscott18
kyscott18 merged commit 3af253f into main Oct 27, 2026
7 checks passed
@kyscott18
kyscott18 deleted the sim/resubmissions branch October 27, 2026 21:43
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