""" _config.py — receipts kit stub. The script in this folder was originally run with a vault-internal _config module that wires up provider clients (xAI), handles proxy-routed API keys, and provides shared helpers for retry, bootstrap CIs, and effect-size computation. This file replaces that module with a documented stub. Importing it will succeed; calling any function will raise NotImplementedError with a pointer to the docstring describing what the original did. To reproduce the experiment end-to-end, replace each NotImplementedError body with a call to your own provider's SDK. What the original module does is reconstructible from the function signatures and the call sites in `script.py`. The bootstrap and effect-size helpers are also pure-python equivalents available in `scipy.stats`. """ import math def _stub(name, summary): raise NotImplementedError( f"_config.{name} is a stub. {summary} " f"Replace with a call to your provider's SDK to reproduce." ) def get_xai_client(): """Return an xAI client. Original used a proxy-routed wrapper around the OpenAI SDK pointed at the xAI base URL with the XAI_API_KEY environment variable. """ _stub("get_xai_client", "Original returned an OpenAI-compatible client with " "base_url=https://api.x.ai/v1 and api_key=os.environ['XAI_API_KEY'].") def call_generator(client, model, messages, max_retries=5, **kwargs): """Send a chat-completion request with retry on transient failure. Returns the response text. """ _stub("call_generator", "Original wrapped client.chat.completions.create with retry " "and returned response.choices[0].message.content.") def hedges_g(scores_a, scores_b): """Hedges' g effect size (small-sample bias correction on Cohen's d). Pure-stdlib implementation; no API dependency. Useful as-is for re-running the analysis on this kit's data.json. """ n_a, n_b = len(scores_a), len(scores_b) if n_a < 2 or n_b < 2: return 0.0 mean_a = sum(scores_a) / n_a mean_b = sum(scores_b) / n_b var_a = sum((x - mean_a) ** 2 for x in scores_a) / (n_a - 1) var_b = sum((x - mean_b) ** 2 for x in scores_b) / (n_b - 1) pooled_sd = math.sqrt(((n_a - 1) * var_a + (n_b - 1) * var_b) / (n_a + n_b - 2)) if pooled_sd == 0: return 0.0 d = (mean_a - mean_b) / pooled_sd j = 1 - (3 / (4 * (n_a + n_b) - 9)) return d * j def bootstrap_ci(scores_a, scores_b, n=10000, ci=0.95): """Bootstrap CI on Hedges' g between two groups. Pure-stdlib implementation; no API dependency. Returns a dict with d, ci_lower, ci_upper. """ import random rng = random.Random(0) a, b = list(scores_a), list(scores_b) if len(a) < 2 or len(b) < 2: return {"d": 0.0, "ci_lower": 0.0, "ci_upper": 0.0} samples = [] for _ in range(n): sa = [rng.choice(a) for _ in range(len(a))] sb = [rng.choice(b) for _ in range(len(b))] samples.append(hedges_g(sa, sb)) samples.sort() lo_idx = int(((1 - ci) / 2) * n) hi_idx = int((1 - (1 - ci) / 2) * n) - 1 return { "d": hedges_g(a, b), "ci_lower": samples[lo_idx], "ci_upper": samples[hi_idx], }