Framework RecipesImplementation, failure path, check

Agent repair workflows by failure

Reject stale edits and serialize competing writes

Put the availability decision inside a lock or conditional update, and reject edits based on an obsolete version. Choose the mechanism for the conflict: competing reservations and a customer submitting an old screen need different checks.

How do I keep two requests from changing the same stock or order incorrectly?

Choose the implementation for your framework. Each linked guide includes the source, integration prerequisites, failure-path tests, saved requirement and recorded check.

Existing captured source checks; these are individual examples
ImplementationSaved requirementBroken sourceCorrected sourceCapture date
Serialize Rails stock reservations with an Active Record row locklocked-stock-availabilityRule findingNo rule finding2026-10-14
Reject stale Rails cancellation decisions with optimistic lockingsubmitted-order-versionRule findingNo rule finding2026-10-14
Reserve stock in Express with one conditional database updatestock-never-negativeRule findingNo rule finding2026-10-14
Return a conflict when EF Core detects a stale order editstale-update-is-not-successRule findingNo rule finding2026-10-14

Inspect the requirement before installing it

The Serialize Rails stock reservations with an Active Record row lock example uses this requirement on app/services/reserve_stock.rb:

- name: locked-stock-availability
  where: "app/services/reserve_stock.rb"
  ensure: >-
    Inside the row lock, available stock must be checked against quantity before it is decremented. Reject reservations that exceed the locked stock.

Exact corrected source and broken edit · Recorded Perch output · Download this requirement

Make the agent check the requirement after its edit

Keep your existing perch.yaml. The scoped rule pack installs the saved requirement under .perch/rules/. Review its file selector and use the implementation’s integration prerequisites before adapting it to your application.

Install Perch and configure your agent

npm install -g @lakeday/perch
perch login
# Choose the setup command for your agent:
perch setup claude-code
# Or: perch setup codex
# Or: perch setup cursor

Check the edit and recheck the repair

curl -fL 'https://reporules.fyi/rails/locked-stock/rule-pack.zip' -o requirement.zip
unzip -n requirement.zip
perch check app/services/reserve_stock.rb --rules locked-stock-availability --json
# Read the finding, repair the implementation, then repeat:
perch check app/services/reserve_stock.rb --rules locked-stock-availability --json

Run the same check on the repaired working file before committing. Keep the application regression tests alongside it. Fresh model judgments can vary; an unchanged request can reuse its cached answer. A passing check does not prove application correctness.

Compare the implementations before choosing a rule

Keep the check tied to its source

The table reports saved checks on the exact linked source versions. Adapt the paths, adapters and regression tests to your repository. The example source may differ from the released framework or your service; the recorded outcome belongs to that example.

Other agent-edit failure paths · All framework recipes