Agent repair workflows by failure
Release resources on success, failure and disposal
Keep release or disposal on every path that ends ownership, including exceptions and cancellation. A successful request alone cannot reveal a connection leak; check the error path and the lifetime of the component that owns the resource.
How do I keep an agent edit from leaking a connection or subscription?
Choose the implementation for your framework. Each linked guide includes the source, integration prerequisites, failure-path tests, saved requirement and recorded check.
| Implementation | Saved requirement | Broken source | Corrected source | Capture date |
|---|---|---|---|---|
| Return the PostgreSQL client after every Express transaction outcome | transaction-releases-client | Rule finding | No rule finding | 2026-10-14 |
| Dispose Qt network replies after their completion signal | reply-has-deferred-deletion | Rule finding | No rule finding | 2026-10-14 |
| Dispose Vue realtime subscriptions when the owner disappears | feed-scope-disposes-resources | Rule finding | No rule finding | 2026-10-14 |
| Cancel Flutter timers and streams when the screen is disposed | screen-disposes-owned-work | Rule finding | No rule finding | 2026-10-14 |
Inspect the requirement before installing it
The Return the PostgreSQL client after every Express transaction outcome example uses this requirement on transaction.cjs:
- name: transaction-releases-client
where: "transaction.cjs"
ensure: >-
The withTransaction helper returns every acquired PostgreSQL client to its pool by executing client.release() in finally, including when the operation or rollback throws. A finally block containing only a comment leaves the acquired client unreleased.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/express/transaction-cleanup/rule-pack.zip' -o requirement.zip
unzip -n requirement.zip
perch check transaction.cjs --rules transaction-releases-client --json
# Read the finding, repair the implementation, then repeat:
perch check transaction.cjs --rules transaction-releases-client --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
- Return the PostgreSQL client after every Express transaction outcome
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. Inspect its rule pack.
- Dispose Qt network replies after their completion signal
A QNetworkReply remains an owned resource after the request finishes. Deferred deletion avoids deleting it directly from a signal callback while Qt is still delivering that signal. The owner destruction path aborts pending work; reply lifetime remains tied to completion and the manager. Inspect its rule pack.
- Dispose Vue realtime subscriptions when the owner disappears
A component can disappear while its socket and callback remain alive. That leaks resources and can continue collecting one tenant’s events after the user navigates elsewhere. Pair acquisition with scope disposal and invalidate callbacks that were already queued. Inspect its rule pack.
- Cancel Flutter timers and streams when the screen is disposed
Checking mounted suppresses callbacks but does not release the resources producing them. Cancel the subscription and timer when the State owner ends so navigation does not accumulate hidden work. Inspect its rule pack.
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.