CouncilEx.Reliability.ETS (CouncilEx v0.1.0)

Copy Markdown View Source

In-memory ETS-backed CouncilEx.Reliability store.

Tracks per-member outcome counts bucketed by query feature digest. Score = beta-distribution mean over (successes, failures) per bucket: (α + 1) / (α + β + 2). Cold-start (no record) → nil, not 0.5, so callers can distinguish "no data" from "definitely uncertain".

Feature digest

query_features is hashed with :erlang.phash2/1 to a single bucket key. Pass features that capture similarity:

%{topic: "code_review", length_bucket: :long, language: :elixir}

Identical maps land in the same bucket. Map keys are sorted before hashing, so key order doesn't matter.

Limitations

  • No semantic similarity — exact-match buckets only. For nearest- neighbour over embeddings, plug a different store.
  • In-memory only. Wipe on BEAM restart.
  • Not cluster-aware. Each node has its own table.

Setup

Optional supervised init via your application:

children = [
  CouncilEx.Reliability.ETS
]

Or call init/0 lazily — every public function does this on first use.

Summary

Functions

Use as a child spec to create the table at app start. Idempotent. Calling init/0 from any process works just as well — calls are cheap and the table is :public.

Create the ETS table if it doesn't exist. Idempotent.

Wipe all stored data. Test-only.

Functions

child_spec(opts \\ [])

Use as a child spec to create the table at app start. Idempotent. Calling init/0 from any process works just as well — calls are cheap and the table is :public.

init()

Create the ETS table if it doesn't exist. Idempotent.

reset()

Wipe all stored data. Test-only.