# Audit Open Source Licenses in a Rust Project

An agent inventories mdBook's 273 locked crates into licenses.csv and finds no GPL, AGPL or SSPL; two r-efi versions offer LGPL as one of three choices.

[Run this on Rush](https://cloud.getrush.ai/run/license-audit/rust/). Opens the console with this prompt ready to send.

## What the agent does

The agent clones rust-lang/mdBook, installs rustup and gcc because the sandbox has neither, and runs `cargo test --locked` on the untouched clone. Then `cargo metadata --locked` gives it the whole lockfile graph: 273 packages, 12 of them workspace members.

A short script outside the repository walks that graph from the `mdbook` root and writes `licenses.csv` with each crate's declared `license` field, whether it is direct or transitive, and its shortest path. `licenses.md` lists what the request asked to flag and which top-level dependency brings each one in.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Clone https://github.com/rust-lang/mdBook, resolve its full dependency tree from the lockfile, and write licenses.csv (package, version, license, direct or transitive, path from the root) plus licenses.md summarizing any GPL, AGPL, LGPL, SSPL or unknown license and which top-level dependency brings it in."
}
```

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. 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

Tried on rust-lang/mdBook at 7fb5bc8e: 2 files changed, 300 insertions(+), `licenses.csv` (273 packages: 12 workspace members, 38 direct, 223 transitive) and `licenses.md`. It found no GPL, AGPL or SSPL. LGPL appears only as an option in `MIT OR Apache-2.0 OR LGPL-2.1-or-later` for `r-efi` 5.3.0 (through `axum`) and 6.0.0 (through `tempfile`). `cargo test --locked` passed before and after, ending `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s`.

For the reviewer: whether the LGPL-optional `r-efi` entries matter under your policy; the run treated them as permissive. The tree includes dev, build and Windows-only crates, so it is wider than what a Linux binary ships, and licenses come from Cargo.toml fields, not a scan of source files.

## Run it on every release you cut

Your release pipeline sends this request to `POST /o/{org}/sessions` with an API key, with your repository's URL in place of mdBook's. It holds the event stream, polls the session or waits for your webhook, then downloads `licenses.csv` and `licenses.md` as the session's artifacts by name; the run copied both to `/workspace/.rush/artifacts/`. The repository is named in the prompt, so no connected repository is needed.

## Why run it on Rush?

Both `r-efi` versions declare `MIT OR Apache-2.0 OR LGPL-2.1-or-later`; the run read the whole expression, treated them as permissive, and traced each to the dependency that pulls it in. The only unknown license is `mdbook-remove-emphasis`, an example crate in the workspace that `mdbook` does not depend on.

## Frequently asked questions

### Where does MPL-2.0 show up?

Only in mdBook's own workspace crates; `mdbook-html` adds `AND Apache-2.0 AND BSD-3-Clause AND CC-BY-4.0 AND MIT AND OFL-1.1` for its bundled assets. No external dependency is MPL-only.

### Why did the first test run fail?

The sandbox had no C linker, so `cargo test --locked` ended `error: could not compile 'quote' (build script) due to 1 previous error` with exit 101. After the agent installed gcc, the same command passed on the untouched clone.

## More Rust jobs

- [Turn Linear Issues Into Pull Requests for a Rust Service](https://getrush.ai/run/linear-issue-to-pr/rust/)
- [Review Pull Requests Automatically in a Rust Service](https://getrush.ai/run/review-pull-requests/rust/)
- [Run a Security Audit on a Rust Service](https://getrush.ai/run/security-audit/rust/)

## The same job in other apps

- [Audit Open Source Licenses in a Django Project](https://getrush.ai/run/license-audit/django/)
- [Audit the Dependency Licenses of an Electron App](https://getrush.ai/run/license-audit/electron/)
- [Audit Open Source Licenses in a Go Project](https://getrush.ai/run/license-audit/go/)

## Keep reading

- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
