# `Mailglass.Credo.NoRawSandboxOwnership`
[🔗](https://github.com/szTheory/mailglass/blob/v2.7.0/credo_checks/no_raw_sandbox_ownership.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

Test code acquires and releases Ecto Sandbox pool ownership through
`Mailglass.TestSupport.SandboxOwnership`, not through
`Ecto.Adapters.SQL.Sandbox` directly.

Both confirmed HARNESS-01 leak sites (`test/support/mailer_case.ex` and
`test/mailglass/properties/webhook_idempotency_convergence_test.exs`)
shared one shape: acquire, then work that can raise, then register the
release — with the release registered last, so a raise in the middle
loses it entirely. `SandboxOwnership.checkout!/1` makes that ordering
structurally impossible to re-type by registering the release on the
statement immediately following acquisition. A raw `Sandbox.start_owner!`/
`Sandbox.mode`/`Sandbox.checkout` call outside the sanctioned door can
reintroduce the exact ordering bug this check exists to prevent.

## Check-Specific Parameters

Use the following parameters to configure this check:

### `:allowed_modules`

  Modules explicitly allowed to call Ecto.Adapters.SQL.Sandbox's ownership functions directly.

*This parameter defaults to* `[Mailglass.TestSupport.SandboxOwnership, Mailglass.TestSupport.SandboxOwnershipTest]`.

### `:included_path_prefixes`

  Only files in these path prefixes are linted.

*This parameter defaults to* `["test/"]`.

### `:forbidden_functions`

  Ecto.Adapters.SQL.Sandbox function names that are disallowed outside the door.

*This parameter defaults to* `[:mode, :start_owner!, :stop_owner, :checkout, :checkin]`.

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
