OpenResty: preserve requirements through advanced agent edits
Work through Lua examples of real application boundaries: Protect OpenResty stock decisions across workers with a shared lock; Do not acknowledge OpenResty background work before timer admission. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.
Download the OpenResty rule pack ZIP · Inspect the YAML rules
Lua
A Lua module variable is per worker, while ngx.shared provides shared state. A get-then-set sequence still needs a lock when the operation consists of several steps. Check current availability under that lock and release it even if the operation raises.
Broken edit flagged · corrected edit passes
Lua
OpenResty has finite pending-timer capacity. A failed timer creation means the delivery task was never scheduled. Return an overload failure instead of telling the caller that absent work was accepted.
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 OpenResty documentation · All language and framework recipes