lupin.Open console
Reliability & costs

Test concurrent budget admission with isolated local fixtures

Exercise reservation races, lost acknowledgments and durable rejection without purchasing resources or sending live provider requests.

Test the invariant at the database boundary

The important property is that concurrent admissions cannot each spend the same remaining headroom. A unit test of arithmetic alone cannot establish that. Exercise the actual reservation path against an isolated local database with the relevant migrations and a provider stub that records invocation count.

Lupin documents admission and reservation insertion in one serialized SQL statement. Its provider-cost and retail accounting paths preserve related reservation state around paid actions. A meaningful fixture should therefore observe durable rows and adapter calls, not only the boolean returned by an application helper.

Construct a small deterministic scenario

Create one synthetic workspace, a verified bounded rate and a budget that permits exactly one of two proposed actions. Give the actions distinct logical identities so the test concerns shared headroom rather than deduplication of one request. Start both admissions before allowing either caller to assume it has won.

Assert that only the admitted action reaches the stubbed provider and that the other returns the appropriate admission failure. Check settled and reserved totals through the same accounting view used operationally. Avoid assigning a live provider credential or using a real resource identifier in the fixture configuration.

Inject failures after each meaningful checkpoint

Add a case where reservation insertion commits but the acknowledgment is lost. The recovery path must preserve the original identity and avoid another provider effect. Add a provider acceptance followed by local projection failure to verify that known-result recovery completes local state rather than repeating the paid request.

Also inject failure while persisting a definitive admission rejection. The phone wrapper treats durable rejection as part of its replay contract; when that persistence fails, its response must preserve the reconciliation gate. A test that only checks an error status can miss a journal stuck in an unsafe or misleading phase.

Exercise release and settlement separately

A definitive provider rejection can release capacity. An unknown timeout must retain its reservation. Test both and verify that a later competing action is admitted only when headroom is genuinely available. Include a replay of an already accepted identity to check that it does not add another reservation or provider call.

For retail metering, inspect the associated settlement and outbox state independently from provider-cost estimates. The two accounting planes have different purposes, and a fixture should not force their monetary totals to match. Keep quantities, units, event identities and periods explicit in assertions.

Make teardown bounded and honest

Use a fresh local database or unique fixture namespace and remove only its synthetic files and rows. Configure the test to fail on unexpected network access. Track stub resources in memory so cleanup can assert there are none left without calling a live delete, stop, send or billing endpoint.

Report exactly what passed: concurrent local admission and the injected recovery scenarios. These checks do not measure production throughput, prove provider deduplication or validate a real invoice. Their value is narrower and concrete: the application preserves one budget decision and one external invocation under the failures that previously threatened that boundary.

Sources & verification

Reviewed against the checked-in Lupin implementation and official reference documentation on 2026-11-05. Operational examples are illustrative; no live paid action, provider mutation or external message was executed.

Prepared with AI assistance by Lupin editorial. How we research and maintain these guides.

Put it into practice

Give your agent the right tools.

Review the API, workspace requirements and permissions before enabling a workflow.

Register an agent See plans