CodeSampleX

Sample

nimble_pool 1.1.0: Verify that start_link eagerly checks worker module existence and validates pool_size type

Verified sample for hex nimble_pool 1.1.0: Verify that start_link eagerly checks worker module existence and validates pool_size type. The contract ran on…

sha256:f3bdf79601e6d0cb079ae5187e83d3ea06e4b2ed2c35f223db15ccb9dd6be4d8

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment elixir linux x64 elixir elixir mix

Verification-run environments

Environment Contract Stages Run
elixir 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-16
elixir 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-18

Case

HOW
Goal
Verify that start_link eagerly checks worker module existence and validates pool_size type
Packages
Symbols
  • NimblePool.start_link
Environment
elixir
Created
2026-08-16T15:08:03Z

Contract

  1. NimblePool.start_link/1 with lazy: true eagerly ensures the worker module is loaded in init/1 and fails pool startup with an ArgumentError when the module is not found.
  2. NimblePool.start_link/1 strictly validates that :pool_size is a positive integer, raising an ArgumentError when passed atom options like :infinity that passed comparison in earlier versions.
  3. NimblePool.start_link/1 raises an ArgumentError when the required :worker option is omitted.

Files

  • NOTES.md
  • csx.json
  • mix.exs
  • mix.lock
  • test/contract_test.exs
  • test/test_helper.exs

Download the source artifact (tar.gz)

Source

NOTES.md
# NimblePool Worker and Option Validation

## What search_known_solution answered
`search_known_solution` returned existing sample `sha256:5dad1cd6420c0a31a656d4e6fa5d703e0a95522ccd354cd1b912b127624eaab9` (which demonstrates the `terminate_pool/2` GenServer state map structure on `v1.1.0`) and sample `sha256:604e80e0559a8cef2559c7cc549e4743383c6e7bd9a35924598667d1152f2ad7` (which proves idle worker ping throttling); this sample investigates startup option and worker module load validation changes introduced in `v1.1.0`.

## How the wrong version fails
On `v1.0.0`, starting a lazy pool (`lazy: true`) with an unresolvable worker module or an atom like `pool_size: :infinity` silently succeeds with a green build, returning `{:ok, pid}` instead of failing pool startup with an `ArgumentError`.
csx.json
{"buildCommand":["mix","deps.compile","--no-deps-check"],"case":{"believed":"A model expects that starting a lazy pool with lazy: true defers worker module validation until checkout, allowing start_link to return {:ok, pid} even when given an unresolvable worker module or an atom :infinity for pool_size.","caseId":"case:sha256:5343fe19c31eb054d01a5fce6de44c20f27beadbabe563192c3471728f6effda","contract":["NimblePool.start_link/1 with lazy: true eagerly ensures the worker module is loaded in init/1 and fails pool startup with an ArgumentError when the module is not found.","NimblePool.start_link/1 strictly validates that :pool_size is a positive integer, raising an ArgumentError when passed atom options like :infinity that passed comparison in earlier versions.","NimblePool.start_link/1 raises an ArgumentError when the required :worker option is omitted."],"goal":"Verify that start_link eagerly checks worker module existence and validates pool_size type","kind":"HOW","packages":["pkg:hex/nimble_pool@1.1.0"],"schemaVersion":1,"symbols":["NimblePool.start_link"]},"contractCommand":["mix","test","--no-deps-check"],"environment":{"arch":"x64","ecosystem":"hex","executionContext":"elixir","language":"elixir","os":"linux","packageManager":"mix","runtime":"elixir","schemaVersion":1},"license":"MIT-0","packages":["pkg:hex/nimble_pool@1.1.0"],"schemaVersion":1,"symbols":["NimblePool.start_link"],"verifierAdapter":"hex@1"}
mix.exs
defmodule NimblePoolOptionValidation.MixProject do
  use Mix.Project

  def project do
    [
      app: :nimble_pool_option_validation,
      version: "0.1.0",
      elixir: "~> 1.14 or ~> 1.15 or ~> 1.16 or ~> 1.17 or ~> 1.18",
      deps: deps()
    ]
  end

  def application do
    [extra_applications: []]
  end

  defp deps do
    [{:nimble_pool, "1.1.0"}]
  end
end
mix.lock
%{
  "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
}
test/contract_test.exs
defmodule WorkerValidationContractTest do
  use ExUnit.Case, async: false

  defmodule ValidWorker do
    @behaviour NimblePool

    @impl true
    def init_pool(arg), do: {:ok, arg}

    @impl true
    def init_worker(pool_state), do: {:ok, :worker_state, pool_state}

    @impl true
    def handle_checkout(_command, _from, worker_state, pool_state) do
      {:ok, :client_state, worker_state, pool_state}
    end

    @impl true
    def handle_checkin(_client_state, _from, worker_state, pool_state) do
      {:ok, worker_state, pool_state}
    end

    @impl true
    def terminate_worker(_reason, _worker_state, pool_state) do
      {:ok, pool_state}
    end
  end

  test "lazy: true pool eagerly validates worker module existence during start_link" do
    Process.flag(:trap_exit, true)
    unloaded_module = :NonExistentWorkerModule

    result = NimblePool.start_link(worker: {unloaded_module, :arg}, lazy: true)

    assert match?({:error, {%ArgumentError{message: "failed to load worker module " <> _}, _}}, result)
  end

  test "pool_size must be a positive integer, rejecting atoms like :infinity" do
    assert_raise ArgumentError, ~r/pool_size must be a positive integer/, fn ->
      NimblePool.start_link(worker: {ValidWorker, []}, pool_size: :infinity, lazy: true)
    end
  end

  test "omitting the required :worker option raises ArgumentError" do
    assert_raise ArgumentError, ~r/missing required :worker option/, fn ->
      NimblePool.start_link([])
    end
  end
end
test/test_helper.exs
ExUnit.start()

Origin Seeder

csx-seed