Source: https://frameworkrecipes.dev/vapor/

# Vapor: preserve requirements through advanced agent edits

Work through Swift examples of real application boundaries: Keep Vapor’s order and audit writes on the Fluent transaction database; Observe Swift task cancellation between bounded order-processing steps. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

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

Swift

## [Keep Vapor’s order and audit writes on the Fluent transaction database](https://frameworkrecipes.dev/vapor/fluent-transaction-handle/)

Fluent hands the closure a database bound to its transaction. Using the request’s ordinary database for a second write can escape that boundary. Pass the transaction database to every helper participating in the state change.

Broken edit flagged · corrected edit passes

Swift

## [Observe Swift task cancellation between bounded order-processing steps](https://frameworkrecipes.dev/vapor/swift-cancellation-check/)

Cancellation is cooperative in Swift. A canceled task may continue a loop unless the operation or loop observes cancellation. Check at safe boundaries before starting another side effect, while preserving a recovery policy for effects already underway.

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 Vapor documentation](https://docs.vapor.codes/) · [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/vapor/index.md) · [Resource index](https://frameworkrecipes.dev/llms.txt)
