# Framework Recipes > Implementation, failure path, check. Published by Perch / Verglas LLC. Use the linked Markdown pages for reference. Canonical HTML pages provide navigation, source links and downloads. ## Pages - [FastAPI: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/fastapi/index.md): Advanced FastAPI correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Build a FastAPI endpoint that keeps discount limits intact | Framework Recipes](https://frameworkrecipes.dev/fastapi/intro/index.md): Create a validated FastAPI checkout endpoint, test its discount boundary, and use Perch to check later agent edits. - [Keep a FastAPI order update and its outbox event in one transaction | Framework Recipes](https://frameworkrecipes.dev/fastapi/outbox-transaction/index.md): Publishing a message after a database write leaves a crash window. An outbox row is written with the order state, so a worker can deliver it later. A unique event_key prevents accidental duplicate event insertion; a delivery consumer still needs its own deduplication. - [Preserve tenant authorization inside an atomic FastAPI update | Framework Recipes](https://frameworkrecipes.dev/fastapi/tenant-cancellation/index.md): A read-then-write authorization check has two boundaries: who can see the row, and whether the write still applies the same scope. Put tenant, owner, and pending status into the UPDATE itself. A concurrent cancellation can then change at most one pending row. - [Create a Django outbox event atomically with the order change | Framework Recipes](https://frameworkrecipes.dev/django/durable-outbox/index.md): An on_commit callback runs after commit but does not make message delivery durable. Store the event in the transaction and let a retrying worker publish it. Moving create outside the block makes a failed event insert leave a confirmed order without a delivery record. - [Django: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/django/index.md): Advanced Django correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Build a Django update that sends notifications after commit | Framework Recipes](https://frameworkrecipes.dev/django/intro/index.md): Use Django transactions to save an order update, defer notifications until commit, and check agent edits with a Perch rule. - [Keep Django cancellation writes scoped to the authenticated tenant | Framework Recipes](https://frameworkrecipes.dev/django/scoped-cancellation/index.md): A locked row prevents concurrent state changes while this transaction decides whether cancellation is allowed. The tenant restriction belongs in the lookup that acquires the row; a lock by itself is not an access check. - [Next.js: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/nextjs/index.md): Advanced Next.js correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Build a Next.js redirect route that stays on your origin | Framework Recipes](https://frameworkrecipes.dev/nextjs/intro/index.md): Create an App Router redirect handler, test untrusted return destinations, and use Perch to preserve the same-origin requirement. - [Prevent private Next.js order responses from entering shared caches | Framework Recipes](https://frameworkrecipes.dev/nextjs/private-response-cache/index.md): Authorization can be correct while a shared cache serves the previous customer’s response to the next request. Explicit private, no-store headers express the boundary to browsers and intermediaries; the tenant-scoped query expresses it to the database. - [Authorize a Next.js Server Action at the database write | Framework Recipes](https://frameworkrecipes.dev/nextjs/server-action-ownership/index.md): A Server Action is a server entry point. Hiding a button or protecting a layout does not authorize the mutation itself. Put identity scope and current state in the conditional write so the action remains protected when called directly. - [Express: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/express/index.md): Advanced Express correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Build an Express API that caps discounts before calculation | Framework Recipes](https://frameworkrecipes.dev/express/intro/index.md): Validate an Express JSON request, reject excessive discounts, and save the business limit as a Perch rule for agent edits. - [Return the PostgreSQL client after every Express transaction outcome | Framework Recipes](https://frameworkrecipes.dev/express/transaction-cleanup/index.md): 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. - [Reserve stock in Express with one conditional database update | Framework Recipes](https://frameworkrecipes.dev/express/transactional-reservation/index.md): 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. - [Rails: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/rails/index.md): Advanced Rails correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Build a Rails update that keeps privileged fields out of agent edits | Framework Recipes](https://frameworkrecipes.dev/rails/intro/index.md): Use Rails strong parameters to restrict an update endpoint, test unwanted fields, and preserve the allowlist with a Perch rule. - [Serialize Rails stock reservations with an Active Record row lock | Framework Recipes](https://frameworkrecipes.dev/rails/locked-stock/index.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. - [Reject stale Rails cancellation decisions with optimistic locking | Framework Recipes](https://frameworkrecipes.dev/rails/optimistic-cancellation/index.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. - [Dispatch Laravel order jobs only after the transaction commits | Framework Recipes](https://frameworkrecipes.dev/laravel/after-commit-job/index.md): A worker can pick up a queued job before the order transaction commits. Deferring dispatch prevents that race and discards dispatch when the transaction rolls back. It still leaves a durability question between committing state and successfully enqueuing a job. - [Use a conditional Laravel update to prevent overselling | Framework Recipes](https://frameworkrecipes.dev/laravel/atomic-reservation/index.md): Two requests can both pass a separate availability read. The conditional decrement lets the database decide against the current row when it performs the write. A unique tenant/SKU row and a nonnegative database constraint provide additional enforcement. - [Laravel: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/laravel/index.md): Advanced Laravel correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Build Laravel authorization that preserves record ownership | Framework Recipes](https://frameworkrecipes.dev/laravel/intro/index.md): Write a Laravel policy for owned records, test cross-user access, and save the same ownership requirement as a Perch rule. - [Flask: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/flask/index.md): Advanced Flask correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Flask request connections from leaking on error paths | Framework Recipes](https://frameworkrecipes.dev/flask/request-db-cleanup/index.md): Flask application-context teardown runs even when a request raises. A request-scoped connection belongs on g and must be removed and closed there. Closing only at the end of the happy-path route misses exceptions and early responses. - [Deduplicate a signed Flask webhook inside its state transaction | Framework Recipes](https://frameworkrecipes.dev/flask/webhook-deduplication/index.md): A provider may deliver an authenticated event several times. Signature verification establishes its origin; a unique receipt and a transaction establish whether this application already processed it. Neither check replaces the other. - [Fastify: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/fastify/index.md): Advanced Fastify correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Fastify permission hooks inside the protected plugin | Framework Recipes](https://frameworkrecipes.dev/fastify/plugin-permissions/index.md): Plugin encapsulation lets a permission hook cover the mutation routes without changing unrelated public routes. Authentication alone is insufficient: a signed-in read-only account must still be rejected before the handler changes an order. - [Keep Fastify reservation and order writes on the same transaction client | Framework Recipes](https://frameworkrecipes.dev/fastify/shared-transaction-client/index.md): A transaction callback can look atomic while a helper accidentally uses the pool. That helper’s write can commit independently. Pass the transaction client through every helper belonging to the reservation workflow, and let errors propagate to roll back. - [Hono: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/hono/index.md): Advanced Hono correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Enforce Hono JWT permissions after verification and before mutation | Framework Recipes](https://frameworkrecipes.dev/hono/jwt-permission-scope/index.md): Verifying a token signature does not decide whether the principal may write orders. The application must check the required permission and then pass trusted identity scope to its data adapter. An authenticated read-only token is the important negative control. - [Persist a Hono notification record before post-response dispatch | Framework Recipes](https://frameworkrecipes.dev/hono/waituntil-after-persistence/index.md): waitUntil extends execution after a response; it does not wait for an unrelated database transaction to commit. Persist order and outbox together, await the transaction, and only then schedule a delivery attempt. A durable worker must still discover undelivered rows if the request process dies. - [Keep Symfony inventory and order writes on one Doctrine transaction | Framework Recipes](https://frameworkrecipes.dev/symfony/dbal-transaction-handle/index.md): A transaction can commit invalid business state if the application ignores the result of a conditional write. The stock predicate prevents an overdraw, and the affected-row check prevents creating an order that reserved nothing. - [Symfony: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/symfony/index.md): Advanced Symfony correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Symfony object authorization before the order write | Framework Recipes](https://frameworkrecipes.dev/symfony/object-voter-before-write/index.md): A firewall establishes the signed-in user. A voter establishes whether that user may act on this particular order. Keep the object check inside the controller action because a route-level role check cannot express record ownership by itself. - [Spring Boot: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/spring-boot/index.md): Advanced Spring Boot correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Require Spring method security before a scoped order mutation | Framework Recipes](https://frameworkrecipes.dev/spring-boot/method-write-permission/index.md): A controller check can disappear when a second controller or scheduled task starts calling the same service. Method security puts the coarse write permission at the service boundary. The repository must still put tenant and owner predicates into its conditional update. - [Keep Spring order confirmation and its outbox write under one proxy transaction | Framework Recipes](https://frameworkrecipes.dev/spring-boot/transactional-outbox/index.md): Repository methods may each be transactional while the service action is not. Without the outer transaction, saving the order and inserting its event can commit independently. A public proxy-invoked service method supplies the required boundary. - [Apply backpressure to Ktor background work with a bounded coroutine channel | Framework Recipes](https://frameworkrecipes.dev/ktor/bounded-request-worker/index.md): Launching one detached coroutine per incoming request lets traffic outrun a slow downstream service. A finite channel bounds pending work; trySend tells the route when it must return an overload response. A lifecycle-owned scope keeps the worker attached to application shutdown. - [Preserve Kotlin coroutine cancellation in a Ktor service | Framework Recipes](https://frameworkrecipes.dev/ktor/cancellation-propagation/index.md): A broad exception handler can turn request cancellation into normal success. That prevents structured parents from stopping work and may cause the caller to send stale data or continue a mutation. Handle ordinary failures separately from cancellation. - [Ktor: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/ktor/index.md): Advanced Ktor correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Gin’s pooled context out of the background queue | Framework Recipes](https://frameworkrecipes.dev/gin/immutable-background-jobs/index.md): Gin contexts are reused after a request. Copy immutable values into a job and let a worker own its own context. An accepted response must mean the queue actually accepted the work; otherwise the caller has no signal to retry a lost task. - [Gin: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/gin/index.md): Advanced Gin correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Gin reservation and order creation on database/sql’s transaction handle | Framework Recipes](https://frameworkrecipes.dev/gin/reservation-transaction/index.md): Using sql.DB inside a transaction function can obtain a different pooled connection. An order written there may survive rollback of the stock update. Keep both writes on sql.Tx, check affected rows, defer rollback, and commit only after all steps succeed. - [Prevent privileged-field binding in an Echo profile mutation | Framework Recipes](https://frameworkrecipes.dev/echo/explicit-profile-dto/index.md): Binding an HTTP body directly into a business model can expose fields the form never displayed. A dedicated DTO plus explicit mapping makes the mutable fields visible. The regression here is an agent extending the mapper with a privileged assignment. - [Echo: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/echo/index.md): Advanced Echo correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Carry Echo cancellation through to the database query | Framework Recipes](https://frameworkrecipes.dev/echo/request-context-database/index.md): A response timeout does not automatically stop a database query that never receives its context. Thread the request context through the adapter and select a database driver that supports cancellation. Do not substitute context.Background inside request-owned operations. - [ASP.NET Core: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/aspnet-core/index.md): Advanced ASP.NET Core correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Return a conflict when EF Core detects a stale order edit | Framework Recipes](https://frameworkrecipes.dev/aspnet-core/optimistic-concurrency/index.md): A concurrency token lets EF put the expected row version into the UPDATE predicate. When another edit won, the application must return a conflict or explicitly resolve it, rather than tell the caller their old decision succeeded. - [Authorize the loaded ASP.NET Core order before saving changes | Framework Recipes](https://frameworkrecipes.dev/aspnet-core/resource-authorization/index.md): Authorize on the endpoint establishes broad access; an authorization handler over the loaded order establishes record-specific access. Ignoring the returned AuthorizationResult turns a policy invocation into a no-op. - [Phoenix: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/phoenix/index.md): Advanced Phoenix correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Phoenix order and audit changes in one Ecto.Multi | Framework Recipes](https://frameworkrecipes.dev/phoenix/multi-transaction/index.md): Ecto.Multi names each database operation and reports the failed step. Keeping order and audit in one Multi makes an invalid audit roll back the state transition. A successful placeholder callback can accidentally remove that guarantee while preserving the outer transaction shape. - [Insert an Oban job in the same transaction as the Phoenix order change | Framework Recipes](https://frameworkrecipes.dev/phoenix/oban-atomic-job/index.md): A queued job belongs in the same database commit as the business change when workers depend on that change. Oban’s Multi integration keeps the job row transactional and preserves Oban-specific insertion behavior. - [React: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/react/index.md): Advanced React correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Serialize and roll back an optimistic React cancellation | Framework Recipes](https://frameworkrecipes.dev/react/optimistic-mutation-rollback/index.md): An optimistic UI can falsely display a completed transition after the server rejected it. Keep a snapshot, allow only one mutation at a time, and use the server-returned state on acknowledgement. A rejected operation restores the local snapshot and exposes its failure. - [Keep old React search responses from replacing the current query | Framework Recipes](https://frameworkrecipes.dev/react/stale-request-cleanup/index.md): Requests can complete in a different order from the queries that started them. Aborting reduces wasted work; invalidating the old effect prevents a response already resolving from writing stale state. Protect the error branch as well as successful results. - [Vue: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/vue/index.md): Advanced Vue correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Dispose Vue realtime subscriptions when the owner disappears | Framework Recipes](https://frameworkrecipes.dev/vue/subscription-lifecycle/index.md): 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. - [Cancel and invalidate Vue watcher requests before the next await | Framework Recipes](https://frameworkrecipes.dev/vue/watcher-cancellation/index.md): A tenant selection can change while an older query is still in flight. A watcher cleanup belongs to that invocation, so it can stop and invalidate exactly the work the next invocation supersedes. The onCleanup argument also works where onWatcherCleanup is unavailable. - [Angular: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/angular/index.md): Advanced Angular correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Cancel obsolete Angular HttpClient searches with switchMap | Framework Recipes](https://frameworkrecipes.dev/angular/switchmap-search/index.md): A search stream can issue a new request before the previous response arrives. switchMap keeps the latest request as the active subscription; mergeMap permits older responses to continue into the results stream. Debouncing reduces traffic but does not replace cancellation. - [Keep Angular form extras out of the profile mutation payload | Framework Recipes](https://frameworkrecipes.dev/angular/typed-profile-projection/index.md): A form object can accumulate hidden control values and metadata during refactors. Explicit projection keeps privileged or stale fields from entering this API contract. TypeScript types do not remove unexpected runtime properties. - [SvelteKit: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/sveltekit/index.md): Advanced SvelteKit correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep SvelteKit private SSR responses out of shared caches | Framework Recipes](https://frameworkrecipes.dev/sveltekit/private-ssr-state/index.md): A server module is reused across requests. Returning request-local data is safe; putting it into a module-level store or a shared response cache can expose one user’s orders to another. Explicit response policy helps keep the load result outside shared caches. - [Authorize a SvelteKit form action before its conditional write | Framework Recipes](https://frameworkrecipes.dev/sveltekit/server-action-authorization/index.md): A protected page load does not protect its form action. Server actions must enforce their own identity and resource scope. Passing the verified tenant into the conditional mutation makes that boundary visible to both the code reviewer and the rule. - [Nuxt: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/nuxt/index.md): Advanced Nuxt correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Use Nuxt request-scoped state instead of a shared SSR ref | Framework Recipes](https://frameworkrecipes.dev/nuxt/request-local-ssr-state/index.md): A ref declared at module scope on the server can survive across requests. Nuxt useState supplies SSR-aware state tied to the current application/request and serialized for hydration. That prevents a later request from inheriting the previous customer’s draft. - [Keep Nuxt API mutations scoped to the server-verified session | Framework Recipes](https://frameworkrecipes.dev/nuxt/server-session-scope/index.md): Nuxt route middleware controls navigation, while a server/api endpoint can be called directly. Require the server session in the endpoint and carry its identity into the database predicate. Do not replace that scope with a tenant supplied in JSON. - [NestJS: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/nestjs/index.md): Advanced NestJS correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep NestJS event persistence on the supplied TypeORM transaction manager | Framework Recipes](https://frameworkrecipes.dev/nestjs/outbox-transaction-manager/index.md): TypeORM’s global manager can run outside the transaction callback’s connection. That can leave an event committed without its business change or a change committed without its event. Keep every related read and write on the manager supplied to the callback. - [Reject unlisted NestJS mutation fields at the validation pipe | Framework Recipes](https://frameworkrecipes.dev/nestjs/strict-input-boundary/index.md): A TypeScript DTO describes types to the compiler, not runtime JSON. A ValidationPipe with decorated DTO classes establishes a request boundary. Rejecting unexpected fields makes an attempted privileged assignment visible to the caller and tests. - [Axum: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/axum/index.md): Advanced Axum correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Stop an Axum worker while it waits for queued input | Framework Recipes](https://frameworkrecipes.dev/axum/owned-worker-shutdown/index.md): Graceful HTTP shutdown does not automatically stop a separately spawned worker. Give the worker a token, use a cancellation-safe channel receive, signal the token with server shutdown, and await the JoinHandle before the process exits. - [Keep Axum’s verified tenant inside the SQLx order update | Framework Recipes](https://frameworkrecipes.dev/axum/tenant-conditional-write/index.md): Middleware can authenticate an Axum request while the handler still writes globally. Extract the verified actor and include tenant and owner in the SQL statement that changes state. The affected-row check rejects inaccessible or already transitioned rows. - [Bound Actix import input before scheduling blocking work | Framework Recipes](https://frameworkrecipes.dev/actix-web/bounded-import-validation/index.md): Started blocking tasks are not automatically stopped by canceling the request future. Limit the input before spawning work, and keep the operation’s own work bounded. A shutdown timeout limits waiting; it does not forcibly cancel a running blocking closure. - [Actix Web: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/actix-web/index.md): Advanced Actix Web correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Actix order reads scoped by ReqData identity | Framework Recipes](https://frameworkrecipes.dev/actix-web/request-scoped-identity/index.md): ReqData carries identity inserted by request middleware. That proves the source of the identity, while the SQL predicate enforces which record can be returned. Omitting a tenant predicate during a query refactor can leak data despite correct authentication. - [Qt: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/qt/index.md): Advanced Qt correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Dispose Qt network replies after their completion signal | Framework Recipes](https://frameworkrecipes.dev/qt/network-reply-lifetime/index.md): 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. - [Protect Qt’s shared stock decision with one scoped mutex | Framework Recipes](https://frameworkrecipes.dev/qt/shared-stock-lock/index.md): The availability check and decrement form one critical section. Locking only the decrement still permits two readers to decide against the same old count. RAII releases the mutex on every return path. - [Keep Vapor’s order and audit writes on the Fluent transaction database | Framework Recipes](https://frameworkrecipes.dev/vapor/fluent-transaction-handle/index.md): Fluent hands the closure a database bound to its transaction. Using the request’s ordinary database for a second write can escape that boundary. Pass the transaction database to every helper participating in the state change. - [Vapor: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/vapor/index.md): Advanced Vapor correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Observe Swift task cancellation between bounded order-processing steps | Framework Recipes](https://frameworkrecipes.dev/vapor/swift-cancellation-check/index.md): Cancellation is cooperative in Swift. A canceled task may continue a loop unless the operation or loop observes cancellation. Check at safe boundaries before starting another side effect, while preserving a recovery policy for effects already underway. - [Reject stale Flutter search results after a newer query or disposal | Framework Recipes](https://frameworkrecipes.dev/flutter/generation-safe-search/index.md): mounted prevents state updates after disposal, but two requests can race while the widget remains mounted. A generation token identifies the current request and rejects an older result that completes later. - [Flutter: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/flutter/index.md): Advanced Flutter correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Cancel Flutter timers and streams when the screen is disposed | Framework Recipes](https://frameworkrecipes.dev/flutter/owned-subscription-disposal/index.md): 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. - [Shiny: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/shiny/index.md): Advanced Shiny correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Check Shiny session authorization inside the write observer | Framework Recipes](https://frameworkrecipes.dev/shiny/session-scoped-mutation/index.md): A hidden button is not permission enforcement. A Shiny observer can be triggered by a client input, so the write boundary must check the session’s verified permission and carry its tenant/user scope into the persistence adapter. - [Remove Shiny’s session-owned temporary files on session end | Framework Recipes](https://frameworkrecipes.dev/shiny/session-temp-cleanup/index.md): Session reports can contain private data and consume disk after the browser disconnects. Give each session its own directory and register cleanup with that session’s owner. A shared fixed path permits one session to overwrite or delete another’s report. - [Release http4s response resources after success or decoding failure | Framework Recipes](https://frameworkrecipes.dev/http4s/client-response-resource/index.md): 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. - [Keep a doobie reservation and order insert in one transaction | Framework Recipes](https://frameworkrecipes.dev/http4s/doobie-conditional-reservation/index.md): 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. - [http4s: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/http4s/index.md): Advanced http4s correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Ring: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/ring/index.md): Advanced Ring correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Keep Ring mutation permissions at the request handler | Framework Recipes](https://frameworkrecipes.dev/ring/session-permission-boundary/index.md): Ring represents a request as data, but that does not make every field trusted. A verified session may establish the actor; path and body values still describe what the caller requests. Apply the write permission in the handler and send trusted scope to the persistence function. - [Release Clojure file resources when parsing an order fails | Framework Recipes](https://frameworkrecipes.dev/ring/stream-close-on-exception/index.md): line-seq is lazy and depends on an open reader. Realize the needed result inside with-open, then return independent data. A lazy result returned after closing the reader fails later; a reader never closed leaks descriptors on exceptions. - [OpenResty: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/openresty/index.md): Advanced OpenResty correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Protect OpenResty stock decisions across workers with a shared lock | Framework Recipes](https://frameworkrecipes.dev/openresty/shared-dictionary-lock/index.md): 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. - [Do not acknowledge OpenResty background work before timer admission | Framework Recipes](https://frameworkrecipes.dev/openresty/timer-admission/index.md): 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. - [Preserve complete POSIX writes when appending an order record | Framework Recipes](https://frameworkrecipes.dev/posix/complete-write-loop/index.md): write may accept fewer bytes than requested or be interrupted before writing. A log append helper must keep the remaining slice and retry interruptions. Treat a zero-byte write as an error rather than spin forever. - [Close a POSIX file descriptor even when synchronization fails | Framework Recipes](https://frameworkrecipes.dev/posix/failure-path-descriptor/index.md): A failure to sync is precisely the path where cleanup is easy to skip. Attempt close independently of the fsync outcome and preserve the first durability error so the caller does not report successful persistence. - [POSIX services: preserve requirements through advanced agent edits | Framework Recipes](https://frameworkrecipes.dev/posix/index.md): Advanced POSIX services correctness recipes with Perch rules, source examples, failure-path tests and captured checks. - [Framework Recipes — correctness guides across languages and frameworks](https://frameworkrecipes.dev/index.md): Implementation recipes for transactions, authorization, concurrency and resource lifetime. Follow the code, exercise the failure path, then check the requirement after an agent edit.