# Rails: preserve requirements through advanced agent edits - [Serialize Rails stock reservations with an Active Record row lock](https://frameworkrecipes.dev/rails/locked-stock/guide.md): The lock reloads the record and serializes competing reservations. An availability check made before taking the lock can become stale. Keeping the check, decrement, and save inside with_lock makes the inventory decision atomic for that row. - [locked-stock-availability rule pack](https://reporules.fyi/rails/locked-stock/rule-pack.zip): YAML requirement and agent task. - [Reject stale Rails cancellation decisions with optimistic locking](https://frameworkrecipes.dev/rails/optimistic-cancellation/guide.md): Active Record detects a write conflict after the record is loaded, but it cannot infer that a customer made a decision using an older screen. Compare the submitted version first, then let lock_version protect the save from a race that occurs during this request. - [submitted-order-version rule pack](https://reporules.fyi/rails/optimistic-cancellation/rule-pack.zip): YAML requirement and agent task. - [Framework rule pack](https://reporules.fyi/rails/rule-pack.zip): All requirements from this framework site.