Express: preserve requirements through advanced agent edits
Work through JavaScript examples of real application boundaries: Reserve stock in Express with one conditional database update; Return the PostgreSQL client after every Express transaction outcome. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.
Download the Express rule pack ZIP · Inspect the YAML rules
JavaScript
Checking stock in JavaScript and then writing a new total permits two requests to reserve the same remaining unit. A conditional UPDATE puts the availability decision into the database statement that changes the row. Parameter binding keeps the SKU out of SQL syntax.
Broken edit flagged · corrected edit passes
JavaScript
A transaction helper often looks correct in a successful request while leaking a connection on an exception. Under load the pool exhausts and later requests wait indefinitely. finally covers the paths that normal return statements and rollback handlers miss.
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 Express documentation · All language and framework recipes