Framework RecipesImplementation, failure path, check

Django: preserve requirements through advanced agent edits

Work through Python examples of real application boundaries: Keep Django cancellation writes scoped to the authenticated tenant; Create a Django outbox event atomically with the order change. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

Download the Django rule pack ZIP · Inspect the YAML rules

Python

Keep Django cancellation writes scoped to the authenticated tenant

A locked row prevents concurrent state changes while this transaction decides whether cancellation is allowed. The tenant restriction belongs in the lookup that acquires the row; a lock by itself is not an access check.

Broken edit flagged · corrected edit passes

Python

Create a Django outbox event atomically with the order change

An on_commit callback runs after commit but does not make message delivery durable. Store the event in the transaction and let a retrying worker publish it. Moving create outside the block makes a failed event insert leave a confirmed order without a delivery record.

Broken edit flagged · corrected edit passes

Introductory framework example

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 Django documentation · All language and framework recipes