サンプル
nimble_pool 1.1.0: Verify that start_link eagerly checks worker module existence and validates pool_size type
検証済みサンプル — hex nimble_pool 1.1.0: Verify that start_link eagerly checks worker module existence and validates pool_size type. elixir 1 · linux alpine/x64 …
sha256:f3bdf79601e6d0cb079ae5187e83d3ea06e4b2ed2c35f223db15ccb9dd6be4d8
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 2
宣言された環境
elixir linux x64 elixir elixir mix
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- Verify that start_link eagerly checks worker module existence and validates pool_size type
- パッケージ
- シンボル
-
- NimblePool.start_link
- 環境
- elixir
- 作成日
- 2026-08-16T15:08:03Z
コントラクト
- 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.
ファイル
- NOTES.md
- csx.json
- mix.exs
- mix.lock
- test/contract_test.exs
- test/test_helper.exs
ソース
# 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`.
{"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"}
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
%{
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
}
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
ExUnit.start()