# SystemOneDSL Usage Rules

- Use `use SystemOneDSL, otp_app: :my_app, cache: SystemOneDSL.Cache.ETS` to define compile-time verified `%SystemOneDSL.Prepared{}` decision contracts (`defnoul`, `defchoice`, `defscore`, `defcontract`, `defjev`, `defalias`).
- Evaluations execute through `ReqLLM.Evaluation.evaluate/4` (default model `"typesafe:jev-latest"`), returning `{:ok, %ReqLLM.Response{object: %{...}}}` with string-keyed answers.
- Target any `ReqLLM.Evaluation` provider per module (`use SystemOneDSL, model: "google:gemini-decision-1"`) or per call (`evaluate(:key, state, model: "openai:gpt-6-luna")`).
- API keys are resolved strictly per provider (`TYPESAFE_API_KEY` for `typesafe:*`, `GEMINI_API_KEY`/`GOOGLE_API_KEY` for `google:*`, `OPENAI_API_KEY` for `openai:*`, `OPENROUTER_API_KEY` for `openrouter:*`, plus `:req_llm` application config) — never leaking credentials across providers.
- Use `SystemOneDSL.fetch_answer/2`, `SystemOneDSL.fetch_answer!/2`, `SystemOneDSL.choice?/2`, and `SystemOneDSL.probability/2` to inspect `%ReqLLM.Response{object: ...}` (or plain map test doubles) interchangeably with atom or string keys.
- Cache keys (`SystemOneDSL.Cache.identity/3`) include the resolved model spec to prevent cross-model collisions. Provider refusals (`%{"type" => "refusal"}`) are never cached.
- Never pass retired `backend:`, `decisions_mode:`, or `auth_mode:` options; use `:model`, `:evaluate_path`, and `:provider_options` instead.
- Pass `cached: false` to forward `x-ai-cache: bypass` via `req_http_options` headers without clobbering caller-supplied headers.
- For offline unit tests, pass `eval_fn: fn state -> {:ok, %{answers: ...}} end` or `req_http_options: [plug: {Req.Test, MyStub}]`.
