Framework RecipesImplementation, failure path, check

http4s: preserve requirements through advanced agent edits

Work through Scala examples of real application boundaries: Release http4s response resources after success or decoding failure; Keep a doobie reservation and order insert in one transaction. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

Download the http4s rule pack ZIP · Inspect the YAML rules

Scala

Release http4s response resources after success or decoding failure

http4s client responses are Resources because their body streams and connections need finalization. Converting a Resource to an allocated pair transfers cleanup responsibility to the caller. Discarding that finalizer can exhaust the connection pool.

Broken edit flagged · corrected edit passes

Scala

Keep a doobie reservation and order insert in one transaction

doobie ConnectionIO composes statements on one connection when the combined action is transacted. Checking the affected-row count inside that action ensures insufficient stock aborts before order creation and rolls back any prior write.

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 http4s documentation · All language and framework recipes