Source: https://frameworkrecipes.dev/axum/

# Axum: preserve requirements through advanced agent edits

Work through Rust examples of real application boundaries: Keep Axum’s verified tenant inside the SQLx order update; Stop an Axum worker while it waits for queued input. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

[Download the Axum rule pack ZIP](https://reporules.fyi/axum/rule-pack.zip) · [Inspect the YAML rules](https://reporules.fyi/axum/rules.yaml)

Rust

## [Keep Axum’s verified tenant inside the SQLx order update](https://frameworkrecipes.dev/axum/tenant-conditional-write/)

Middleware can authenticate an Axum request while the handler still writes globally. Extract the verified actor and include tenant and owner in the SQL statement that changes state. The affected-row check rejects inaccessible or already transitioned rows.

Broken edit flagged · corrected edit passes

Rust

## [Stop an Axum worker while it waits for queued input](https://frameworkrecipes.dev/axum/owned-worker-shutdown/)

Graceful HTTP shutdown does not automatically stop a separately spawned worker. Give the worker a token, use a cancellation-safe channel receive, signal the token with server shutdown, and await the JoinHandle before the process exits.

Broken edit flagged · corrected edit passes

## Use a correction as a saved requirement

Choose the failure you need to prevent, add the scoped rule to your repository, and check both the broken and corrected implementation. Ask your agent to inspect the finding, repair the code and recheck the same rule. Keep framework tests beside the model check.

Perch keeps the requirement beside the code. Reuse the named check during the agent’s next edit and in CI, with cached answers free on unchanged requests.

[Official Axum documentation](https://docs.rs/axum/latest/axum/) · [All language and framework recipes](https://frameworkrecipes.dev/)

**Framework Recipes**

Implementation, failure path, check.

Published by Perch · © 2026 Verglas LLC. Framework Recipes is a Perch publication.

Perch’s MIT license covers the CLI; hosted model analysis is a paid service. Relevant source is sent to the configured model service.

[Perch CLI MIT license](https://github.com/lakeday-org/perch/blob/main/LICENSE) · [Article text](https://frameworkrecipes.dev/axum/index.md) · [Resource index](https://frameworkrecipes.dev/llms.txt)
