# Add an MSRV Check to a Tokio Project

Yes. An agent finds the oldest Rust toolchain that builds your Tokio crate from its lockfile, pins it as rust-version, adds a CI job for it and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-msrv-check/tokio/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from the manifest and the lockfile, because a minimum supported Rust version is a fact about the dependency tree as it is pinned, not about the code alone. In a crate laid out like tokio-rs/mini-redis, `Cargo.toml` declares `edition = "2018"` and no `rust-version` at all; it asks for `tokio = "1"` with `features = ["full"]`, `clap = "4.2.7"` with `derive`, `bytes = "1"`, `tokio-stream = "0.1"`, `tracing = "0.1.34"` and `tracing-subscriber = "0.3.11"`, plus four `optional` OpenTelemetry crates behind an `otel` feature. `Cargo.lock` is committed, at lockfile `version = 3`, and resolves those to tokio 1.32.0, clap 4.4.2, bytes 1.5.0 and tracing-subscriber 0.3.17 across 160 packages. `.github/workflows/ci.yml` runs `cargo build --verbose`, the same build with `--features otel`, `cargo test --verbose` twice the same way and `cargo fmt --all --check` on Ubuntu, macOS and Windows, with whatever stable toolchain the runner image ships; nothing pins a version.

Next it finds the floor. In its sandbox the agent installs toolchains with `rustup toolchain install <version> --profile minimal` and runs `cargo +<version> check --locked --all-features` on each, walking back from the current stable until the check fails. `--locked` matters: it keeps the resolved versions in `Cargo.lock`, so the answer is the version the repository actually builds with, not one `cargo update` would pick. The agent reads the first failure to see which crate set the floor, checking that crate's own `rust-version` in its unpacked source under the registry cache, and records it in the pull request. Because `--all-features` pulls in the OpenTelemetry crates, the floor it finds holds for the `otel` build too, which is the one CI already exercises separately.

Then it writes the number down where Cargo reads it: `rust-version = "<floor>"` under `[package]` in `Cargo.toml`, beside `edition`. From then on a toolchain older than that refuses the crate with a message naming the field, and `cargo publish` carries it into the registry metadata. The agent leaves the lockfile version alone, since a lockfile at `version = 3` is readable by every toolchain the floor could name, and says so in the description.

Last it makes CI hold the line. A new `msrv` job in `ci.yml` installs exactly that toolchain with the `dtolnay/rust-toolchain` action pinned to the version string, then runs `cargo check --locked --all-features` and `cargo test --locked` on `ubuntu-latest` only; the three-OS matrix is for the stable build and does not need to triple the MSRV cost. The agent runs the whole workflow locally before pushing: the three stable commands the file already had, then the new job's two commands on the pinned toolchain, and quotes each exit status. It does not run `cargo update`, bump the edition or touch `src/`.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add an MSRV check to this Tokio crate. Read Cargo.toml, Cargo.lock and .github/workflows/ci.yml first. Find the oldest toolchain that passes cargo check --locked --all-features by installing candidate toolchains with rustup and walking back from stable; name the dependency that sets the floor. Set rust-version in [package] to that version. Add an msrv job to ci.yml that installs exactly that toolchain and runs cargo check --locked --all-features and cargo test --locked on ubuntu-latest. Do not run cargo update, do not change the edition, do not touch src/. Run the existing CI commands on stable and the new job's commands on the pinned toolchain, and quote the results. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request with two files changed: one `rust-version` line in `Cargo.toml` and one new job in `.github/workflows/ci.yml`. The description names the toolchain, the crate in the lockfile whose own `rust-version` set it, and the command whose failure on the next-older toolchain proved it, then quotes the stable build, the `otel` build, the tests and `cargo fmt --all --check` from the existing jobs and `cargo check` and `cargo test` from the new one, each with its exit status.

The run's record keeps every `cargo +<version> check` the agent tried, so a reviewer can see the walk back from stable and the exact error at the floor rather than trusting a number.

Before merging, a reviewer decides whether the floor is where the project wants it. The agent reports the lowest version that works today; a maintainer may choose a higher, rounder one to leave room, and that is a one-line edit in both files.

## Run it on every pull request that bumps a dependency

Once `rust-version` is set, the question returns with every dependency bump: does the new crate still build on the floor? A `github` trigger on `pull_request.opened` and `pull_request.synchronize` starts a run for each pull request a person opens, with a prompt asking the agent to run `cargo check --locked --all-features` on the pinned toolchain against that branch and post one review that quotes the first error if it fails. The trigger adds the pull request after the prompt, so the prompt names no branch.

A pull request a bot opens never fires that trigger, so for Dependabot's weekly bumps a handler on the reader's server receives GitHub's pull request webhook and sends `POST /o/{org}/sessions` with the pull request's `…/pull/<n>` URL in `resources` and a `request_id` that is a UUID v5 of the head commit SHA, so a redelivered webhook returns the run already started. When a bump raises the floor, the review says which crate did it and what the new `rust-version` would have to be, and the maintainer decides between the bump and the floor with the evidence in front of them.

## Why run it on Rush?

Finding an MSRV by hand means installing half a dozen toolchains and waiting for a full check on each, which is why most crates either never declare one or declare one nobody has verified. In a Rush sandbox the agent does the installs and the checks in sequence, with `--locked` so the answer is about the committed lockfile, and the record shows every attempt.

The result is a pull request a maintainer can read in a minute: one line in the manifest, one job in CI, and the evidence for the number. Across every Rust repository a team keeps, the job runs in parallel, one sandbox and one pull request each, and each pull request's floor is the one its own lockfile sets.

## Frequently asked questions

### Why check with --locked instead of letting Cargo resolve?

Because the repository commits `Cargo.lock`, and the version that matters is the one those pinned crates need. Without `--locked`, an older toolchain's Cargo could pick older dependency versions and report a lower floor than the lockfile actually builds with, and CI, which uses the lockfile, would then fail.

### Does the otel feature change the answer?

It can, since it pulls in four optional OpenTelemetry crates with floors of their own. The agent checks with `--all-features` so the number covers the `otel` build the existing CI already runs, and the new job checks with the same flag.

### Will the new job run on Windows and macOS too?

No. The MSRV job runs on `ubuntu-latest` only; the three-OS matrix stays for the stable build. Whether a crate compiles on an old toolchain is the same question on every platform, so one runner answers it.

### What if we want a higher floor than the one found?

Set it. The agent reports the lowest version that works today and leaves the choice of policy to the maintainer; raising the number is one edit in `Cargo.toml` and the same string in the workflow's toolchain line.

## More Tokio jobs

- [Add Mutation Testing to a Tokio Project](https://getrush.ai/run/add-mutation-testing/tokio/)
- [Add Prometheus Metrics to a Tokio Server](https://getrush.ai/run/add-prometheus-metrics/tokio/)
- [Add a Release Workflow With Prebuilt Binaries to a Tokio Server](https://getrush.ai/run/add-release-workflow/tokio/)

## The same job on other stacks

- [Add a Minimum Supported Rust Version Check to a Rust CLI](https://getrush.ai/run/add-msrv-check/rust-cli/)

## More jobs like this: Hand off a long task

- [Serve Storybook Stories From the App's MSW Handlers](https://getrush.ai/run/add-msw-to-storybook/msw/)
- [Convert a Compose Project's Dockerfiles to Multi-stage Builds](https://getrush.ai/run/add-multi-stage-builds/docker-compose/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
