# mesa-clm documentation — full corpus Each page below begins with its canonical URL followed by its original Markdown, OKF frontmatter included. ---8<--- https://idss-mesa.github.io/mesa-clm/getting-started/configuration/ --- title: "Configuration" description: "Configure mesa-clm with a YAML file, MESA_CLM_ environment variables or flags; precedence, the sections, secrets, and the CLM fallbacks." type: Reference tags: - getting-started - configuration - environment generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/plan-2026-09-28.md" title: "mesa-clm implementation plan (v1.1, 2026-09-28)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Configuration Precedence, highest first: command-line flag, environment variable, YAML file (`--config FILE`), built-in default. Environment variables use the `MESA_CLM_` prefix and `__` to descend into a section: `MESA_CLM_HISTORY__BACKEND=spool` sets `history.backend`. The model is `mesa_clm.config.Config`; a secret-free `config_sha256` is recorded on every run. Data lives under `~/.mesa/clm/` (provenance, locks, features, artifacts, heads, secrets, spool). Two CLM names are honoured as fallbacks so an upstream `clm` client environment keeps working: `CLM_BASE_URL` and `CLM_API_KEY`. Every `*_API_KEY` field has a `*_API_KEY_FILE` twin that reads a raw 0600 file; `MESA_CLM_SECRETS=auto|env|file|keyring` chooses where secrets come from. When neither `clm.api_key` nor `clm.api_key_file` is set, the key is read from `~/.mesa/clm/secrets/clm.key` if that file exists (what `mesa-clm serve keys --init` writes), and likewise `encoder.key` for the encoder: only in the `auto` and `file` modes, after an inline value, a configured file and (in `auto`) the keyring; an explicit empty value (`MESA_CLM_CLM__API_KEY_FILE=`) turns the default off, and so does an explicit `null` in the YAML file, which is why `config.yaml.example` keeps the four key settings commented out. The default is resolved when the key is read, never stored in the configuration, so `config_sha256` does not change with it, and the file must pass the same 0600 and owner rules as any key file. No secret is ever logged, hashed into a fingerprint or written to a run record, and a configuration error never shows a value or a snippet of the file (a YAML syntax error names the file, line and column). ## Sections | Section | What it configures | |---|---| | `clm` | The clm-serve URL (`http://127.0.0.1:8700`), key (default file `~/.mesa/clm/secrets/clm.key`), model (`clm-latest`, `clm-raw` or a promoted head), `allow_remote` (needs https). | | `encoder` | The vLLM pooling URL (`http://127.0.0.1:8090`), key (default file `~/.mesa/clm/secrets/encoder.key`), `max_len` (4096, the server's window; clients truncate at 4,095), and `tokenizer_json` (the pinned Qwen3 `tokenizer.json`, counted by the `tokenize` extra when the encoder has no `/tokenize`; unset, the token guard over-counts with `ceil(chars / 2)`). | | `decider` | `tier`: `auto` (the best promoted artifact, else `zero_shot`), `zero_shot`, `calibrated`, `probe`, `head`, or `ols_rank` (the degraded OLS top-1 method for every candidate group, proposed-only, DESIGN D28); `ols_rank_fallback` (default `false`): whether `annotate --provider clm` at tier `auto` runs `ols_rank` when clm-serve does not answer instead of refusing; `ols_rank_tasks` (default `[term.fits]`, DESIGN A1's K1): the candidate-group tasks `ols_rank` decides whatever the tier (a YAML list, or `MESA_CLM_DECIDER__OLS_RANK_TASKS` as a list, a comma-separated string or `none`); `[]` asks CLM about `term.fits` too, an audit run; `closed_choice` (default `rules`, DESIGN A6): who answers the closed choices, `rules` (every non-identifier column annotated whatever the planner says; aspects from the planner's hint and the M0 lookup over the packaged table frozen from the registered labels snapshot, else DESIGN A8's fallback by the column's dtype and unit (`measurement` then `unit` for a numeric or unit-bearing column, the lookup's prior order without `taxon` for a string column; two kept, never `taxon`); value kind "the term label"; CLM's answers recorded audit-only) or `clm` (the M2 behaviour; `MESA_CLM_DECIDER__CLOSED_CHOICE`, `annotate --closed-choice`). Requests always use temperature 1; calibration is client-side. | | `planner` | The reasoning model that only plans: `static` (default in 0.1.0), `claude`, `gateway`. | | `claude` | Credentials profile and model for the planner and the second opinion. | | `policy` | Profile (`prod` needs `calibrated` for auto-writes and a passing audit row; `dev` allows `--history none`), thresholds file (`policy_defaults.yaml`), and `results_root` (M4, `MESA_CLM_POLICY__RESULTS_ROOT`): where a numeric auto's cite `bench/results//.json#` is resolved and where the committed snapshots `bench/snapshots/*.parquet` are hashed (never opened for their labels); `null` (the default) means the checkout root when `mesa_clm` runs from a `src/` checkout, else `~/.mesa/clm/results`. `learn fit`, `learn promote` and the doctor's `artifacts` check read it too. | | `artifacts` | `dir` (default `~/.mesa/clm/artifacts`): the learned artifacts under `////v/` with `CURRENT.json` beside the versions (M4); `strict` (default `true`): refuse a version whose fingerprints are not the live ones, whose framings lock is not the code's, or an entry whose question key is stale (K4); `false` drops such entries with a warning noted on the run and serves `zero_shot` for them. A hash mismatch is refused whatever `strict` says. | | `features` | The feature cache under `~/.mesa/clm/features//` (M1); the probe path reads it as a vector cache and never writes it. | | `provenance`, `ducklake` | Sidecar DSN (`duckdb:///~/.mesa/clm/provenance.duckdb`, a bare `*.duckdb` path, or `postgresql://`), TTL for abandoned runs; local DuckLake catalog for development. The DuckDB sidecar, its lock and everything mesa-clm creates for it are owner-only (0700/0600). | | `history` | `backend` (`direct`, `spool`, `none`, `auto`), `multiwriter`, spool root, lock paths (`$MESA_HOME/locks/mesa-catalog.lock` plus neon's when configured). | | `apply` | Batch size (≤500 operations per call) and the token bucket (`max_calls_per_s`, default 5). | | `ols` | OLS base URL and the fixture directory for replay. | | `neon` | The neon-ducklake root, iRODS root and curation-sync switch for the adapter (0.2.0). | The configuration module is ported from mesa-anyjev in M0; the serving-facing sections (`clm`, `encoder`, `decider`) are live since M1 (`annotate --provider clm`, `doctor --serve`), `artifacts` and `policy.results_root` since M4's pre-run commit, and `history`/`apply` become live in M3. The authoritative field list is the `mesa_clm.config` model and `config.yaml.example` in the repository. ---8<--- https://idss-mesa.github.io/mesa-clm/getting-started/install/ --- title: "Install" description: "Install mesa-clm with uv, the command line that exists after milestones M1, M2 and M4's pre-run commit (annotate, explain, review, feedback, framings, provenance, serve, features, labels, bench, learn, artifacts, audit, doctor), the extras, and what a serving host needs." type: Guide tags: - getting-started - install generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: research resource: "https://github.com/idss-mesa/mesa-clm/blob/main/RESEARCH.md" title: "mesa-clm verified facts (RESEARCH.md)" author: "team:idss-mesa" - id: plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/plan-2026-09-28.md" title: "mesa-clm implementation plan (v1.1, 2026-09-28)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Install ```bash git clone https://github.com/idss-mesa/mesa-clm cd mesa-clm uv sync --all-extras # dev install; nothing here pulls torch or vllm uv run pytest -q # hermetic suite sha256sum -c vendored.sha256 # vendored CLM and AnyJev files are byte-identical uv run mesa-clm doctor # pins, versions, plugin API, policy, stores ``` Python 3.11 or newer. `mesa-mcp` and `mesa-ducklake` come from pinned git commits (`pyproject.toml`, `[tool.uv.sources]`; DESIGN D0); neither is on PyPI. The core is a torch-free HTTP client: it never depends on `contrastive-lm`, torch or vllm, and the vendored CLM `schema.py` is the only upstream code it imports (DESIGN D4). ## Command line (milestones M1, M2 and M4 pre-run) `mesa-clm --help` lists the verbs that exist. Global options go before the verb: `--config` (a YAML file; `MESA_CLM_*` variables and flags override it), `--provenance` (the sidecar DSN, `duckdb:///`, a bare `.duckdb` or `postgresql://…`) and `--actor` (recorded on labels, runs and overrides; default `$USER`; never blank). The `labels`, `bench`, `annotate`, `explain`, `review`, `feedback`, `provenance` and, from M4, `learn`, `artifacts` and `audit` verbs also accept `--provenance` and `--actor` after the verb; `doctor`, `framings`, `serve` and `features` do not. In a `duckdb:///` DSN the path follows the third slash, so `duckdb:///x.duckdb` is relative to the working directory and `duckdb:////tmp/x.duckdb` is absolute. Exit codes: 0 ok; 1 the verb ran and failed (a doctor failure, framing drift, an unreachable clm-serve, an OLS replay miss, another owner's run, an export that could not be written); 2 a configuration or usage problem (an unreadable config file or card, a missing or rejected key, a bad argument). No verb prints a key: a configuration error names the field and the problem (or, for a YAML syntax error, the file, line and column), never the value or a snippet of the file, and `serve keys` names files only. Everything mesa-clm writes for its state (the sidecar and its lock, the feature store, run exports, `annotate --out`) is owner-only, directories 0700 and files 0600, whatever the umask. | Verb | What it does | |---|---| | `doctor [--quick] [--serve] [--json]` | What this host can run (below). `--quick` skips the vendored-file hashing and, outside serve mode, the serving-lock verification; in serve mode it keeps the light probes and skips the slow ones unless `--serve` is given. `--serve` forces every live serving probe; `--json` prints `{ok, summary, checks[]}`. | | `framings --check \| --update-lock [--lock PATH]` | The framing keys against `framings.lock.json` (DESIGN D1): `--check` exits 1 on drift (CI runs it); `--update-lock` rewrites the lock after a deliberate framing change, which rotates that framing's `question_key`. | | `annotate --card PATH [--provider clm\|fake] [--planner static\|gateway\|claude] [--tier auto\|zero_shot\|calibrated\|probe\|head\|ols_rank] [--ols-rank-tasks TASKS\|none] [--closed-choice rules\|clm] [--owner O] [--out FILE\|-] [--eval-result] [--fake-seed N]` | Decide one dataset card (a local file; CLI only, DESIGN D26) and record the run in the sidecar. Prints a summary (run id, proposals, abstentions by reason, decisions, CLM calls, input tokens, seconds, fingerprint, the tasks `ols_rank` decided, who answered the closed choices) and the next step; `--out` writes the run as JSON (`-` for stdout), `--eval-result` the neon-avu-eval result shape instead. `term.fits` groups are decided by `ols_rank` by default (`decider.ols_rank_tasks`, K1 in DESIGN A1); `--ols-rank-tasks none` asks CLM about them too, an audit run. The closed choices (annotate, aspect, value kind) are answered by rules by default (`decider.closed_choice: rules`, DESIGN A6): CLM's answers to them are recorded audit-only, and the aspect lookup reads the table shipped in the package (frozen from the registered labels snapshot; no sidecar is read); `--closed-choice clm` runs the M2 behaviour. Every outcome is proposed-only: the shipped policy has `auto: null` everywhere. | | `explain --run-id ID \| --irods-path P [--limit N]` | A run read back from the sidecar: slim decisions, the top three options per group, links and the groups waiting for a reviewer. Run ids may be given as a unique prefix (at least 4 hex digits). | | `review --run-id ID [--pick GROUP=OPTION_KEY\|none]... [--decline GROUP]...` | Answer a run's pending groups. Without `--pick`/`--decline` it is interactive and needs a terminal: each group's candidates with `p_fit` and the anchor, then a number picks, `0` or `n` is "none of these", `d` declines, `s` (or Enter) skips, `q` (or end of input) quits; its answers are curator labels (`via=cli`, DESIGN A2). The non-interactive form answers pending groups only, each once per call, and checks every answer before recording any; at a terminal its answers are curator labels, without one (a script, a pipe, an agent's shell) they are recorded like a plain tool call (`via=tool`: `agent_pick` at weight 0, never fold-eligible) and the verb says so on stderr. A decline keeps only an override row. A curator's answer settles a group; an agent's leaves it pending for a curator, whose answer replaces it. | | `feedback --group-id G --action pick\|reject\|decline [--option-key KEY\|none]` | One answer for any group of your runs (a full id or a unique prefix); `pick` needs `--option-key` (`none` is "none of these"), `reject` is "none of these". At a terminal `via=cli`, otherwise `via=tool` as above. | | `provenance migrate [--dsn DSN]` | Create or upgrade the `mesa_clm` schema (DuckDB: the bootstrap; Postgres: the packaged migrations, `pg` extra). | | `provenance export --run-id ID --out DIR` | Parquet copy of a run's rows plus `manifest.json` under `DIR//` (0700, files 0600); the run is marked exported only once the copy is written and verified. | | `provenance import PATH` | Commit an exported run into the configured sidecar (refused when the run exists). | | `provenance prune [--ttl-days N] [--dry-run]` | Delete the local rows of terminal runs and of abandoned runs past the TTL (default `provenance.ttl_days`); `--dry-run` lists what would go. | | `serve keys --init \| --rotate [--secrets-dir DIR]` | The two bearer key files and the units' env files, all 0600 in a 0700 directory (default `~/.mesa/clm/secrets`, which mesa-clm reads by default; another directory prints the `export MESA_CLM_*__API_KEY_FILE=…` lines). Prints paths, never a key; `--rotate` also prints the `systemctl --user restart` command to run (the running units keep the old keys until restarted). | | `serve units [--home DIR]` | Print the rendered systemd user units (installing and enabling them stays a user action). | | `serve lock --check [--lock PATH] [--home DIR] [--require-live]` | Verify `serving/serving.lock.json` against this host (patch files, installed lock copy, serve clone and applied patches, schema, head file, image and running container); exit 1 on any failure. Absent pieces are skipped unless `--require-live`. | | `labels ingest-neon-eval --eval-root DIR [--exclude-models a,b]` | Silver labels from a neon-avu-eval checkout (`tests/fixtures/neon-avu-eval` in this repository), terms resolved through OLS (`MESA_CLM_OLS__FIXTURES=replay` for the recorded fixtures). | | `labels import-anyjev --dsn DSN [--trust-curator]` | Labels from a mesa-anyjev sidecar, opened read-only, re-identified per DESIGN D1. Its `curator` rows arrive as `agent_pick` at weight 0 (mesa-anyjev let a plain tool call mint them) unless `--trust-curator`, which needs a terminal (DESIGN A2). | | `labels ingest-teacher --neon-root DIR [--cards-dir DIR]` | **M4.** Teacher labels (DESIGN D19) from a neon-ducklake checkout's `curation/generic/.validated.json` files into the store, Yes only, `teacher` at weight 0.5, never fold-eligible, leak group the product; a column resolves to every table card of its product under `sites/SRER/cards/anyjev` that carries it, items without a resolvable column are dropped and counted; OLS terms through the OLS layer (`MESA_CLM_OLS__FIXTURES=replay` replays `tests/fixtures/ols-teacher/`). Prints the report (rows per task, drops per reason, the corpus hash). See [Learning and bench](../concepts/learning-and-bench.md). | | `labels snapshot [--out PATH]` | Freeze the store to Parquet and print its `labels_sha256` (DESIGN D30); default `bench/snapshots/.parquet`. | | `labels stats` | Counts per task, source, label and weight as JSON. | | `bench baselines [--out-dir DIR] [--date D] [--snapshot PATH] [--B N] [--seed S]` | The no-model controls per task (`lookup_prob`, novel-key, leave-one-product-out) into `//baselines.json` and `.md`, stamped with the snapshot's `labels_sha256`; the default snapshot `bench/snapshots/.parquet` is written when missing and refused when the store has changed since. | | `bench mde [--n-sims N] ...` | The minimum detectable effect under rule R at the realised label counts, into `//mde.json`. | | `bench framing \| run \| x2 \| table` | **M2.** X1 (`x1.json`, `--decide --from` replays one), the zero_shot and calibrated cells (`tiers.json`), the X2 baselines (`x2.json`) and the markdown table over results files; they read only the registered snapshot and take B, the seed and alpha from the registration ([Learning and bench](../concepts/learning-and-bench.md)). | | `bench x3 [--date D] [--out-dir DIR] [--snapshot PATH] [--force]` | **M4 (pre-run).** X3: the nested probe cells of every task (specs × fitters × hyperparameters chosen by inner leave-one-card-out) into `//x3.json` and `x3.md`; only the registered snapshot (any other file is refused, none is written); no option for B, the seed, alpha, the grid, the framings or the models; `--force` replaces an existing file. | | `bench k2 [--date D] [--x3-from X3_JSON] [--force]` | **M4 (pre-run).** K2: the value verdict per task (a, b or c) over the committed `tiers.json` and `x2.json` (pinned by sha256; other bytes are refused) and this date's `x3.json`, into `k2.json` and `k2.md`; `bench table` lists the verdicts. | | `bench x4 [--date D] [--snapshot PATH] [--teacher-snapshot PATH] [--minus-opus-snapshot PATH\|none] [--force]` | **M4 (pre-run).** X4: the teacher ablation on `term.fits` and `column.ontology_fits` (three arms on identical folds, scored on silver and on silver-minus-Opus) into `x4.json` and `x4.md`; the teacher and silver-minus-Opus snapshots default to the M4 registration's pins, and a run without them is written unregistered. | | `bench e2e --loco [--date D] [--force]` | **Planned (M4 second wave).** The end-to-end leave-one-card-out measure (report-only: consensus-all recall against AnyJev's static recall, anchor-abstain precision); the verb exists and exits with a usage error naming the second wave until the fold provider ships by amendment. | | `learn fit [--date D] [--tasks T] [--snapshot PATH] [--x3 PATH] [--tiers PATH] [--out-dir DIR]` | **M4.** Fit the full-data probes and the A1 calibrators from the registered snapshot and the feature store into a new immutable artifacts version per served model (`~/.mesa/clm/artifacts////v/`), each entry citing `bench/results//x3.json` or the pinned `tiers.json` (the defaults); refuses, writing nothing, when the framings lock, the fingerprints or the probe grid deviate from the M4 registration; a copy of the manifest and probes goes to `//artifacts_v/`. Never promotes; serving host only. | | `learn promote --version N --task T [--tier probe\|calibrated] [--k2 PATH] [--date D] [--model M]` | **M4.** Put one task's artifact of version N into `CURRENT.json` when the four promotion rules pass (a qualifying pre-registered nested cell cited, a K2 verdict a or b for that tier, new ≻ current on NLL and ≽ on accuracy within 0.01 when something is already promoted, no head before M7); nothing is written when a rule fails. | | `artifacts publish --to DIR [--version N] [--model M]` | **M4.** Copy a version (default the newest) under `DIR////v/` and verify the copy against its manifest; a local path or mount only (the iRODS transport is planned with M3's `irods_io`). | | `artifacts pull --from DIR --version N [--verify\|--no-verify] [--model M]` | **M4.** Copy a version in, re-hashing every file against the manifest (`--verify`, the default); a mismatch places nothing. `CURRENT.json` is never pulled: promotion is a local decision. | | `audit sample --n N --min-cards M (--runs IDS \| --since DATE) [--all-tiers] --out FILE` | **M4.** Draw a stratified, seeded sample of your annotate decisions on non-bench cards (a bench card refuses the whole sample) into a file of ids, strata, the sampling mode (`artifact_only`) and the reviewer's checklist, no card content; default 100 decisions over at least 5 cards. By default only decisions that carry an `artifact_version` (a promoted artifact's) are drawn, the would-be-auto decile computed per task over them, since only those can feed an `audits` row; `--all-tiers` adds the `zero_shot` and `ols_rank` decisions for the report-only precision. A run set without an artifact-backed decision is refused with the flag named. | | `audit review --file FILE` | **M4.** Review the sample at a terminal (required, like `review`): each decision with its target (scope and column name, site or dataset), the column's description, dtype and unit, the aspect and ontology its group searched and the OLS queries sent (for `column.ontology_fits`: the aspect, and that the candidates are ontologies), the tier marked plainly (`probe/clm v1 (platt)`; `zero_shot/clm (uncalibrated: p_fit is σ(s_c), saturates near 1)`), then its group's candidates; `c` correct, `i` incorrect, `s` skip, `q` quit; verdicts mint curator labels outside every fold and the file is rewritten after each answer. | | `audit record --file FILE` | **M4.** Write one `audits` row per `(task_key, artifact_version)` among the reviewed would-be-auto decisions, with its pass rule; decisions that apply no artifact get no row, and a sample drawn with `--all-tiers` reports how many reviewed items had none (`report_only`). The proposed-precision Clopper–Pearson interval is printed, report-only. | | `features build --snapshot PATH [--tasks T] [--framings F] [--batch N]` | Embed every X1/X2 text of a frozen snapshot that the store of the live `encoder_fp` lacks (`~/.mesa/clm/features//`), one text per request by default, after the exact token guard; refuses an encoder that is not the serving lock's. Serving host only. | | `features export-npz --out DIR` | The store as CLM's `TextCache` file for `finetune.py --embed-cache DIR` (refused below the 0.9999 fp16 round-trip gate). | | `features project [--model clm-latest\|clm-raw]` | Cache the pinned head's 512-d projections of every stored vector. | | `features stats [--json]` | Every feature store under `features.dir`. | The label verbs (`labels`, `bench`) need a DuckDB sidecar; the annotation and provenance verbs also take a Postgres DSN. Exit codes are unchanged by M4: a refused registered input, a failed promotion rule, a tampered pull or an unservable tier is 1; a missing `--neon-root`, a bad `--since` or `bench e2e` without `--loco` is 2. No M4 verb has run on the snapshot's labels yet: `design/m4-analysis-plan.md` fixes what each does before any result exists. **Owners and curator labels (DESIGN D21, A2).** A run belongs to its owner: `annotate --owner` (default `--actor`, itself `$USER`). `explain`, `review` and `feedback` act as `--actor` and refuse another owner's run with exit 1 (the message never names that owner); on a shared Postgres sidecar they act only as the OS account. Curator labels come only from an interactive terminal (or, from M3, an MRTR elicitation): `isatty()` is the check, so a process that deliberately allocates a pseudo-terminal under the curator's account still passes it (DESIGN A2, "Residual risk"). **Providers and an unreachable clm-serve.** `--provider fake` is a deterministic offline fake (hashed n-grams; `--fake-seed` picks the fake head): it exercises the pipeline, the policy and the sidecar and is never evidence. `--provider clm` (the default) talks to the loopback serving pair with the keys from the configuration (by default `~/.mesa/clm/secrets/clm.key` and `encoder.key`), stamps every record with the fingerprint of the serving lock the host runs (`~/.mesa/clm/serving.lock.json`, else the checkout's `serving/serving.lock.json`; refused when it contradicts the vendored schema or the checkout's lock), and runs a pre-flight first: clm-serve's `/health`, then, with the keys, the served models and the encoder's model, window and route against the lock. A missing or rejected key, a `clm.model` clm-serve does not serve or an encoder that is not the lock's is never degraded (exit 2), and a request clm-serve refuses mid-run (401, 403, 404) fails the run (recorded `failed`, exit 1). When clm-serve does not answer: * tier `auto` with `decider.ols_rank_fallback: true` (`MESA_CLM_DECIDER__OLS_RANK_FALLBACK`) runs the degraded `ols_rank` method instead (the OLS top-1 per group, proposed-only, never auto; DESIGN D28) and the run says `degraded`; * otherwise the verb refuses with exit 1 (the plugin's `decider_unavailable`), and an explicit CLM tier (`zero_shot`, `calibrated`, …) always refuses; * `--tier ols_rank` (or `decider.tier: ols_rank`) never needs clm-serve for the candidate groups; the closed choices (annotate, aspect, value kind) are still asked and recorded `unavailable` when it is down (audit-only under DESIGN A6's rules, which need no CLM answer: every column keeps its aspects). A learned tier the provider cannot serve is refused before any request (exit 1): `--tier calibrated` or `--tier probe` needs a promoted artifact of that tier for every task that `ols_rank` does not decide (`decider.ols_rank_tasks`), which `learn fit` then `learn promote` write (M4); `head` arrives with M7. Tier `auto` serves the best promoted tier per question key (a promoted probe, else a promoted calibrator, else `zero_shot`); an artifact a version holds but `CURRENT.json` does not promote is never served. `learn promote --version 1 --task term.fits --tier probe` (run once on the serving host after DESIGN A7) changes what `term.fits` gets at tier `auto`: its groups are decided by the promoted probe at level `probe` (proposed-only, the specificity refinement asked) instead of `ols_rank`, and the summary and the `--out` JSON name it under `probe_tasks`; a host without that `CURRENT.json` keeps the K1 `ols_rank` proposals. An OLS replay miss fails the run (exit 1): what was decided before it is committed with status `failed`. The M0 bench sequence, as run for `bench/results/2026-09-29/`: `labels ingest-neon-eval --eval-root tests/fixtures/neon-avu-eval` → `labels snapshot --out bench/snapshots/2026-09-29.parquet` → `bench baselines --date 2026-09-29` → `bench mde --date 2026-09-29`. The [quickstart](quickstart.md) walks through annotate, explain and review. ## The doctor Every check prints `ok`, `WARN` or `FAIL`; the doctor exits 1 on any failure. The M0 checks cover the vendored files (`vendored.sha256`), the configuration's secret-free hash, Python, duckdb (the 2.x window, DESIGN A9), mesa-mcp and mesa-ducklake against their pinned commits, mesa-mcp's plugin API and the `clm` entry point, the policy defaults, the provenance path, the label store, key files (configured or the serving pair's defaults, named "(default)"; stat-ed for mode 0600, never read), the eval root and the OLS fixtures. M1 adds: | Check | What it compares | |---|---| | `framings lock` | The framing keys against `framings.lock.json` (the `framings --check` rule). | | `schema sha256` | The vendored CLM `schema.py` hash every record cites against its `vendored.sha256` entry and the serving pin. | | `sidecar schema` | The `mesa_clm` schema version of the configured sidecar, read without creating anything but the D11 lock file (a DuckDB file opened read-only under the shared flock; Postgres through the migration table). Older: warn and `provenance migrate`; newer than this mesa-clm: fail. | | `feature store` | The store of the live `encoder_fp` under `features.dir` (M1): format 2 (float32 vectors), the vector recipe it was built under against the live serving lock's (another one, or a format-1 store, fails: every read would be refused), the export's float16 gate; stores of other fingerprints are listed, never read. | | `artifacts` | **M4.** The learned artifacts of the served head under `artifacts.dir` (`///`): `CURRENT.json` parses, each promoted version's manifest loads with the live lock's fingerprints and the code's framings lock and holds the promoted entry, and each promotion's cite names a results file under `policy.results_root` that holds the cell; promoted artifacts filed under another framings lock are a warning (the provider refuses them, K4). "none yet" and "nothing promoted" are ok; the check is skipped when no serving lock verifies on the host. The artifacts tree joins the `permissions` targets. | | `permissions` | Group or other bits on mesa-clm's state (the data home and its `locks/` and `secrets/`, the sidecar with its `.wal` and lock, the feature stores): a warning naming the paths and the `chmod` that fixes them. The doctor never repairs; the next write through mesa-clm tightens its own lock and store files. | | `serving lock` | `serve lock --check` when the serving home `~/.mesa/clm` exists; skipped by `--quick` unless in serve mode. | | `host` | `MemAvailable`; a warning below the encoder's 8 GiB running floor. | | `gpu_budget` | Active CARC vLLM backends (`systemctl list-units carc-vllm@*`, read-only); a warning when they are active and `MemAvailable` is below the 32 GiB the encoder needs to start. | | `serving` | Outside serve mode, one line: whether the encoder and clm-serve answer `/health` (a warning when not). | Every configured URL first passes the clients' loopback rule (loopback, or `MESA_CLM_CLM__ALLOW_REMOTE=1` and https; never credentials in the URL) and is printed redacted; a URL that does not is a failure and is never called. **Serve mode** (`--serve`, or automatically when both `mesa-clm-encoder.service` and `mesa-clm-serve.service` are active) replaces the `serving` line with live probes: `serving binds` (both ports listen on loopback only, in sockets of this account, from `ss -ltne`; while the socket unit is active the encoder's port is the user manager's), `encoder socket` (`~/.mesa/clm/run` holds only the encoder's socket), `serving units` (the units systemd loaded are the checkout's rendering and the running proxy was started from them, sandboxed), `encoder health` and `clm-serve health` (`/health` 200 without a key), `encoder auth` and `clm-serve auth` (the 401 matrix: without a key, every route vLLM registers on the encoder and an unknown path, and clm-serve's `GET /v1/models`, `POST /v1/systemone` and `POST /v1/rank`, must answer 401; any other answer fails), `encoder models` (`qwen3-8b` listed with the lock's model, window and route) and `clm-serve models` (`clm-latest` and `clm-raw`), and `clm golden` (one fixed `/v1/systemone` question answered over every key, each probability above 0, summing to 1). Under `--serve`, or in serve mode without `--quick`, the slow probes follow: `encoder goldens` (the reference texts of `encoder_golden_.npz` embedded one per request must equal the reference bitwise, and as one batch agree within 1 − 1e-6), `encoder long input` (a text longer than the window completes, truncated to 4,095 tokens from the left, with cosine ≥ 0.9999 against its last 4,095 token ids), `clm parity` (the golden question recomputed locally, encoder plus the pinned head's numpy export, within 1e-4 of clm-serve) and `clm drift` (a warning only: the CLM README quickstart against issue #15 with the unrounded differences, and the tides rank against the model card). An unreachable endpoint, a missing key or a failed slow probe fails under `--serve`, and under auto-detected serve mode without `--quick`; otherwise it is a warning. An open route and a key the server rejects (401) always fail. Serve mode also reads the encoder container's network namespace (`encoder network`: a listener on a non-loopback address next to an interface besides `lo` fails) and warns when the headroom timer is stopped; every doctor run checks the live `encoder_fp`'s `feature store` (its format and the vector recipe it was built under). The records of the live runs are `bench/results/2026-10-01/doctor_serve.json` (DESIGN A3/A4) and `doctor_serve_m1c.json` (A5). ## Extras | Extra | Adds | When | |---|---|---| | `bench` | `scikit-learn` | The PR #13 logistic-regression baseline replica in the bench (M2). | | `tokenize` | `tokenizers` | Exact Qwen3 token counts for the client token guard when the encoder's `/tokenize` is unavailable (M1). | | `claude` | `anthropic` | The Claude planner and the second-opinion provider. | | `pg` | `psycopg` | The optional Postgres dialect of the provenance sidecar (DuckDB per host is the default). | | `e2e` | `mcp` | The end-to-end test over MCP stdio (M3). | | `docs` | `zensical`, `pyyaml` | Building this site. | | `dev` | pytest, ruff, mypy, `requests` | Development; `requests` only for the vendored CLM client used as a test oracle. | ## Serving hosts (milestone M1) Annotation with `--provider clm` needs the two serving processes described in [Serving](../concepts/serving.md) and the runbook [Serving](../deploy/serving.md): a vLLM pooling container serving `Qwen/Qwen3-8B` on `127.0.0.1:8090` and a patched `clm-serve` on `127.0.0.1:8700`, both keyed. In 0.1.0 they run on one GPU host (sparky-1); the core refuses a non-loopback URL unless `MESA_CLM_CLM__ALLOW_REMOTE=1` is set **and** the URL is `https://` (use an `ssh -L` forward otherwise). The keys `mesa-clm serve keys --init` writes, `~/.mesa/clm/secrets/clm.key` and `encoder.key`, are read by default; point mesa-clm elsewhere with the key-file settings (paths, never the keys): ```bash # only when the keys live elsewhere; an explicit empty value switches the default off export MESA_CLM_CLM__API_KEY_FILE=/path/to/clm.key export MESA_CLM_ENCODER__API_KEY_FILE=/path/to/encoder.key # optional: exact token counts for the guard when the encoder has no /tokenize (tokenize extra) export MESA_CLM_ENCODER__TOKENIZER_JSON=~/.cache/huggingface/hub/models--Qwen--Qwen3-8B/snapshots//tokenizer.json uv run mesa-clm doctor --serve ``` The token guard counts each context through the encoder's `/tokenize` first, then the `tokenize` extra over `encoder.tokenizer_json`, else a conservative `ceil(chars / 2)`; a context over `max_len - 16` tokens is never sent and abstains as `truncated`. Everything else (labels, snapshots, baselines, `annotate --provider fake`, review, provenance) runs without a GPU. ## As a mesa-mcp plugin (milestone M3) Installed beside mesa-mcp (≥ `c74f3aa`, which has the entry-point loader), mesa-clm registers the five `mesa_clm_*` tools under the surface `clm` through the `mesa_mcp.tools` entry point `clm`. The umbrella installer (`idss-mesa/docs` `install.sh`) makes it opt-in (`MESA_PLUGINS="mesa-anyjev mesa-clm"`) because serving exists only on the GPU host. ---8<--- https://idss-mesa.github.io/mesa-clm/getting-started/quickstart/ --- title: "Quickstart" description: "Annotate a dataset card, read the run back, review its pending groups and export it: offline with the fake provider and the recorded OLS fixtures, then on the serving host with the real CLM provider." type: Guide tags: - getting-started - quickstart - annotate - review generated: by: "claude/opus-5.5" at: "2026-10-04T18:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/plan-2026-09-28.md" title: "mesa-clm implementation plan (v1.1, 2026-09-28)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Quickstart This walks one dataset card through the decide phase (milestone M1): `annotate` decides and records, `explain` reads the run back, `review` and `feedback` answer the groups that wait for a reviewer, and `provenance export` copies the run out of the sidecar. Nothing here writes iRODS or the MESA history; `apply` and `revert` arrive with milestone M3. Every outcome is **proposed-only**: the shipped policy has `auto: null` for every task, so no decision becomes `auto` until a calibrated tier is cited in milestone M4 (DESIGN D8, D10). ## Offline, with the fake provider From a checkout (`uv sync --all-extras`, see [Install](install.md)). The fake provider is a deterministic hashed-n-gram stand-in for CLM: it exercises the pipeline, the policy and the sidecar, and **it is never evidence**; its probabilities mean nothing about the card. OLS is replayed from the recorded fixtures, so nothing touches the network. ```bash export MESA_CLM_OLS__FIXTURES=replay # recorded EMBL-EBI OLS4 responses only export MESA_CLM_OLS__FIXTURES_DIR=tests/fixtures/ols export MESA_CLM_PROVENANCE__DSN=duckdb:////tmp/mesa-clm-quickstart/provenance.duckdb uv run mesa-clm annotate --card tests/fixtures/cards/DP1.10003.001.brd_countdata.md \ --provider fake --fake-seed 5 --out run.json ``` Mind the slashes in a DuckDB DSN: the path starts after `duckdb:///`, so `duckdb:///x.duckdb` is `x.duckdb` in the working directory and `duckdb:////tmp/x.duckdb` (four slashes) is the absolute `/tmp/x.duckdb`. Without `--provenance` or the variable the sidecar is `~/.mesa/clm/provenance.duckdb`. Without `MESA_CLM_OLS__FIXTURES` the default (`off`) queries the live EMBL-EBI OLS. `--fake-seed` picks the fake head. Under the shipped closed-choice rules (DESIGN A6) every non-identifier column is annotated whatever the head answers, since its answers to the closed choices are recorded for audit only; under `--closed-choice clm` (the M2 behaviour) seed 5 answers "Yes" to enough columns that every step asked of the provider runs on the fixture cards, while the default seed 0 annotates few columns. Under the shipped default (K1, DESIGN A1) the `term.fits` steps are not among those the provider answers: `ols_rank` decides Q4–Q6 and the specificity refinement Q4b (D24) is not asked, so add `--ols-rank-tasks none` (an audit run) for the provider to answer the `term.fits` steps and Q4b too. `annotate` prints a summary: * `run (owner …, card …, tier …)`: the run id (commands below accept a unique prefix of at least 4 hex digits), the owner (`--owner`, default `--actor`, default `$USER`) and the tier; * the counts: proposals kept, groups abstained, decisions recorded, CLM requests, the encoder tokens they cost, the wall time, and `degraded` when any group fell back to the `ols_rank` method or a CLM answer was unavailable; * `outcomes`: decisions per outcome (`proposed`, `abstain`, `rejected`, `rule`, …); * `abstained`: groups that propose nothing, by reason (`anchor_won`: "none of these" ranked first; `no_candidates`: OLS found nothing; `duplicate`, `over_cap`: the keep rule, DESIGN D25); * `fingerprint`: `encoder_fp`, `clm_model_fp` and the first characters of `serving_lock_sha`, the D5 bundle stamped on every decision (the fake has its own, with route `fake`, so a fake run can never pass for a real one); * `ols_rank tasks: term.fits`: since DESIGN A1 the `term.fits` groups (the column terms, the site biomes, the taxon) are decided by `ols_rank` by default, because the registered framing experiment found no qualifying framing for that task (K1); their proposals are the OLS top-1 of each group, with no `p_fit`, and the column-to-ontology questions (Q3) are asked with the A1 framing F9. `--ols-rank-tasks none` asks the provider about `term.fits` too: an audit run, which the line then says; * `closed choices: rules`: since DESIGN A6 the closed choices are answered by rules (every non-identifier column annotated; its aspects from the planner's hint and the M0 lookup over the table shipped in the package, frozen from the registered labels snapshot, or else the fallback of DESIGN A8 for a column that table has not seen: `measurement` then `unit` for a numeric or unit-bearing column, the lookup's prior order without `taxon` for a string column, two kept; the value kind "the term label"), and the provider's answers to them are recorded audit-only (outcome `abstain`, reason `audit_only_a6`; the line counts them). The fixture card is a bench card, so its own labels are left out of the lookup and the other six cards' labels choose its columns' aspects wherever they share a column name. `--closed-choice clm` runs the M2 behaviour, which the line then says; * the provider note and `next: mesa-clm review --run-id `. `--out run.json` holds the full run: every proposal with its attribute, value, unit, CURIE, `p_fit`, level (`zero_shot` for CLM, `none` for `ols_rank`), calibration, method and rationale, plus the abstentions, `ols_rank_tasks`, `closed_choice` and `n_audit_only`. `--out -` prints it instead, and `--eval-result` writes the neon-avu-eval result shape so its scoring scripts run unchanged. ### Read the run back ```bash uv run mesa-clm explain --run-id # decisions, top-3 options per group, links, pending groups uv run mesa-clm explain --irods-path /zone/home/you/data.csv # your runs with links at that path (after apply, M3) ``` Only the owner's runs are shown: `explain`, `review` and `feedback` act as `--actor` and refuse another owner's run (DESIGN D21). ### Review ```bash uv run mesa-clm review --run-id ``` Interactive, and it needs a terminal. For each group that waits for a reviewer (term groups that are proposed, escalated to a human, or whose anchor won, and groups only an agent has answered so far) it shows the target, aspect and ontology, then the offered candidates best `p_fit` first (in OLS order for an `ols_rank` group), numbered, and `0. none of these (the anchor)`. Answer with a number to accept that candidate, `0` or `n` for none of these, `d` to decline (you saw it but answer nothing), `s` or Enter to skip, `q` (or end of input) to quit. Each answer is recorded with `via=cli`: a pick writes curator labels (the pick, and implicit negatives for the other offered candidates), none of these an anchor-positive row plus a negative per candidate, and a decline only an override row (DESIGN D21, A2). The pick's link becomes `accepted`, ready for `apply` in M3. A curator's answer settles the group: a different second answer is refused (the same one again changes nothing). The answers can also be given as arguments; every one is checked (a pending group, an offered candidate, one answer per group) before any is recorded: ```bash uv run mesa-clm review --run-id --pick =PATO:0000040 --pick =none --decline uv run mesa-clm feedback --group-id --action pick --option-key PATO:0000040 uv run mesa-clm feedback --group-id --action reject # none of these ``` Typed at a terminal these are curator answers too. **Run without a terminal** (from a script, a pipe or an agent's shell) they are recorded exactly like a plain tool call: `via=tool`, `agent_pick` labels at weight 0 that never enter a fit, links accepted by `agent`; the verb says so on stderr, and the groups stay pending so a curator's answer can replace the agent's (DESIGN A2). Group ids come from `explain` (`pending_groups`, and `group_id` per group); `review` takes a unique prefix within the run, `feedback` a unique prefix among your runs' groups, and `--action pick` needs `--option-key` (`none` for none of these). ### Export and prune ```bash uv run mesa-clm provenance export --run-id --out /tmp/mesa-clm-quickstart/export uv run mesa-clm provenance prune --dry-run ``` The export is one Parquet file per run table plus a `manifest.json` with each file's sha256 and row count, owner-only like the sidecar (0700, files 0600); the run is marked exported only after the copy is written and verified. `provenance import ` commits it into another sidecar. `prune` deletes only terminal runs (applied, exported, every written link recorded in the history) and abandoned runs past the TTL, so a freshly decided run stays. ## On the serving host, with CLM The same commands with `--provider clm` (the default) talk to the encoder on `127.0.0.1:8090` and clm-serve on `127.0.0.1:8700` ([Serving](../deploy/serving.md)). The keys `serve keys --init` wrote (`~/.mesa/clm/secrets/clm.key`, `encoder.key`) are read by default; check the stack first: ```bash uv run mesa-clm doctor --serve # binds, the 401 matrix, models, goldens, long input, parity, drift MESA_CLM_OLS__FIXTURES=replay MESA_CLM_OLS__FIXTURES_DIR=tests/fixtures/ols-srer \ uv run mesa-clm annotate --card tests/fixtures/cards-srer/DP1.00004.001.BP_30min.md \ --tier zero_shot --out run.json ``` The live example uses a **non-bench** card (plan §9's smoke card, with its recorded OLS responses): until the pre-registered M2 cells existed (`bench/results/2026-10-03/`), no live annotate run looked at the seven bench cards (DESIGN, "G1 freeze"), and they stay the bench's held-out cards. For other cards, live OLS is used with `ols.fixtures` `auto` or `record`. `--tier zero_shot` asks CLM's released head (`clm.model`, default `clm-latest`) and records level `zero_shot`, calibration `uncalibrated`: `p_fit = σ(s_c)` with `s_c` the log-odds of a candidate against the fixed anchor (DESIGN D2). The summary adds the serving lock the fingerprint came from (`~/.mesa/clm/serving.lock.json`, or the checkout's `serving/serving.lock.json`) and the pre-flight's answer. The fingerprint lines now describe the real stack: `encoder_fp` hashes the encoder recipe in that lock (model, revision, dtype, last-token pooling, normalisation, `max_len`, left truncation, prefix caching, route and batch invariance; c3b3d5e1a283 on sparky-1, DESIGN A3), `clm_model_fp` the served head and the CLM commit, and `serving_lock_sha` the lock itself. A calibration artifact is applied only under the `encoder_fp` and `clm_model_fp` it was fitted with and only to its own `question_key`, and a bench cell is cited only when its whole fingerprint and `question_key` equal the live ones (DESIGN D5, D8, K4). Before the first question `annotate` runs a pre-flight: clm-serve's `/health`, then, with the keys, its model list and the encoder's (model, window and route against the lock), then the running encoder container against the lock's recipe (a check docker cannot answer is noted as "not verified"). A missing or rejected key, a model clm-serve does not serve or an encoder that is not the lock's stops it with exit 2 at any CLM tier (`--tier ols_rank` skips the pre-flight). When clm-serve does not answer, `annotate` refuses with exit 1 and says why. Run `--tier ols_rank` (the OLS top-1 of every candidate group, proposed-only, never auto; DESIGN D28) to decide the candidate groups without it (the column questions Q1, Q2 and Q7 still try CLM and are recorded as unavailable, audit-only under the default closed-choice rules, so the run says `degraded`; under those rules every column keeps its aspects, while under `--closed-choice clm` columns without a planner aspect get no groups), or set `decider.ols_rank_fallback: true` (`MESA_CLM_DECIDER__OLS_RANK_FALLBACK=true`) to let tier `auto` degrade to `ols_rank` on its own; an explicit CLM tier such as `zero_shot` always refuses. Review, feedback and export work the same way against either provider's runs. ---8<--- https://idss-mesa.github.io/mesa-clm/concepts/decision-model/ --- title: "Decision model" description: "How mesa-clm asks CLM: one rank per candidate group with a fixed abstain anchor, set-independent scores, the Q1-Q8 pipeline, contexts that end with the target, framings and the two keys, what the M2 framing experiment changed (F9 for column.ontology_fits; term.fits proposals by ols_rank under K1), and what drives each step since amendment A6 (the closed choices Q1, Q2, Q7 by deterministic rules, CLM's answers to them audit-only) and A8 (the aspect fallback for a column the lookup has not seen, by its dtype and unit, never taxon)." type: Guide tags: - concepts - decisions - clm - framings generated: by: "claude/opus-5.5" at: "2026-10-04T19:42:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: research resource: "https://github.com/idss-mesa/mesa-clm/blob/main/RESEARCH.md" title: "mesa-clm verified facts (RESEARCH.md)" author: "team:idss-mesa" - id: clm resource: "https://github.com/Contrastive-LM/CLM/tree/bb42c6c5bf914fd449bed2f6ca65be80602cb1f7" title: "Contrastive-LM/CLM at bb42c6c5 (schema.py, engine.py, server.py)" author: "org:Contrastive-LM" status: draft stale_after: "2026-12-31T00:00:00Z" --- # Decision model CLM scores candidate texts against a state: a frozen Qwen3-8B last-token encoder, two 512-d projection heads, and a softmax over `scale · cosine` **within each question's candidate set** (RESEARCH.md, text contract). There is no abstain option and the probabilities are relative to the set, so mesa-clm never asks "does this term fit?" one candidate at a time. Instead (DESIGN D2): * every fit question is **one `/v1/systemone` Choice** whose criteria are `{: candidate_text, "__none__": anchor_text}`; * the score of a candidate is `s_c = ln p_c − ln p_anchor = (scale/T)(cos_c − cos_anchor)`, which does not depend on which other candidates were offered; * `p_fit = σ(s_c)` at zero shot and `σ(a·s_c + b)` once calibrated; the winner is the largest `s_c`, and the anchor winning is an abstain (`anchor_won`). Score questions are never used (upstream #3: state-independent answers). Noul-per-candidate, the shape mesa-anyjev used, survives only as the control arm F1 of the framing experiment (DESIGN D3). Closed questions (aspect, annotate, value kind) are ordinary Choices without an anchor, and `confidence = max(probs)` is computed locally (DESIGN D7). Requests always use temperature 1; calibration is client-side. ## Pipeline (milestone M1; defaults since amendment A1) Every context view ends with the target, because last-token pooling weights the tail (DESIGN D23). Until amendment A1 every task was asked with F7, the state-only context. A1 (2026-10-03) records the registered framing experiment X1 (`bench/results/2026-10-03/x1.json`): * `column.ontology_fits` (Q3) is asked with **F9** on `clm-latest`, the query-shaped context "NEON dataset {title}. Column {name}: {description} ({unit}). {aspect} ontology term:"; its decisions are keyed by F9's `question_key` (`c95785008b523fd0`); * `term.fits` had no qualifying framing on either model (**K1**): its groups (Q4, Q5, Q6) are decided by `ols_rank` by default (the OLS top-1 as `proposed`, no probabilities, never `auto`; DESIGN D28), Q4b is not asked for them because it ranks by `p_fit`, and CLM is asked about `term.fits` only in an audit run (`annotate --ols-rank-tasks none`); `term.fits` keeps F7 as its framing for those audit records; * the closed choices (Q1, Q2, Q7) keep F7: no pre-registered rule covers them. Amendment **A7** (2026-10-05, after the registered M4 run) adds the production rule for a promoted probe: a task in `decider.ols_rank_tasks` is decided by `ols_rank` *unless the provider resolves a promoted probe for its active framing* (`CURRENT.json`), in which case the probe decides it at level `probe`, proposed-only. For `term.fits` (K2(b), the version-1 `pair512.v1` probe promoted on the serving host) that means: Q4, Q5 and Q6 are the probe's calibrated ranks there (`p_fit` per candidate, `probs` their odds against the anchor, never `auto`), Q4b is asked again for those groups (D24 amended back, since the record carries `p_fit`), the run names the task under `probe_tasks` and `ols_rank_tasks` lists only what `ols_rank` actually decided. A host without the promoted artifact keeps K1 exactly as above. `column.ontology_fits` (K2(c)) keeps its zero-shot F9 proposals; the closed choices keep A6's rules. The numbers behind A1 are in RESEARCH.md, "M2 results (registered run)", and on [Learning and bench](learning-and-bench.md). ## The closed choices by rule (amendment A6) The same registered run measured CLM's zero-shot answers to the closed choices below the majority class of their items: `column.annotate` accuracy 0.357 against 0.643, `column.aspect` 0.050 against 0.300, `avu.value_kind` 0.324 against 0.478 (`bench/results/2026-10-03/tiers.json`, cells `neon_annotate.zero_shot.F7`, `neon_aspect.zero_shot.F7`, `neon_value_kind.zero_shot.F7`). No pre-registered rule covers those tasks, and having seen the cells the user decided (2026-10-04) that they are answered by deterministic rules by default. Amendment A6 records that as a product-safety change of serving behaviour: it makes no scientific claim and touches neither the frozen pre-registration nor any cell. `decider.closed_choice` selects it (`rules`, the default; `clm` keeps the M2 behaviour for audits and tests; `annotate --closed-choice`). Under `rules` each step is driven by: | Step | What decides | Recorded as | |---|---|---| | Q1 | a column is annotated iff it is not an identifier, whatever the planner says (its `annotate=False` stays in the run's plan and decides nothing; an identifier stays out even with its `annotate=True`) | a `rule` record answering `Yes`, reason `a6_not_identifier`; identifiers are `No` rules as before | | Q2 | the planner's aspect hint, then the top two aspects of the M0 lookup (below), de-duplicated, `other` excluded: up to three; when that is empty, the fallback below | one `rule` record per aspect, reason `a6_aspect_hint`, `a6_aspect_lookup` or `a6_aspect_fallback`; the column's Q3 groups carry `search_json.a6` (the source of each aspect, the lookup's counts, the fallback's record: `rule: "a8"`, its `reason`, the prior order, the order considered, what was kept) | | Q2 fallback (amendment A8, 2026-10-05) | for a column the lookup has not seen: a **numeric** column (the card's dtype is `real`, `integer`, `unsigned integer`, …) **or a column with a unit** gets `measurement` first, then `unit` when it has a unit, else the next aspect of the lookup's training prior (most labels first; aspects without labels after, in registry order) that is neither `taxon` nor `other`; a **string** column keeps the prior order with `taxon` removed. In both cases `other` is skipped, so is any aspect with no ontology in play and `unit` for a column without a unit, and the first two are kept; `taxon` never comes from the fallback (the hint and the lookup still give it). No CLM answer is read, so it works with `column.ontology_fits` decided by `ols_rank` or clm-serve down | `rule` records as above (reason `a6_aspect_fallback`); `search_json.a6.fallback` carries `rule: "a8"` and `reason` `unit`, `numeric` or `string`; Q3 then runs on the kept aspects like any other; a column is `no_aspect` only when no aspect has an ontology in play | | Q7 | the deterministic pre-rule first; where it leaves the kind open, "the term label" | a `rule` record, reason `a6_value_kind_label`, under the proposal's group | | Q3–Q6, Q4b, Q8 | unchanged (F9 for Q3, asked once per chosen aspect but `unit`; `ols_rank` for `term.fits` under K1) | as before | The **M0 lookup** is the no-model control the bench reports beside every cell: it counts how often each aspect labels a column of the same name on the other cards. Its items are frozen: the 60 `column.aspect` items of the M0 bench task on the registered labels snapshot (`bench/snapshots/2026-09-29.parquet`), the ones behind the lookup's 0.550 on the aspect cell above, shipped in the package as `aspect_lookup.json` with its sha256 pinned in the code (`scripts/freeze_aspect_lookup.py` writes it; a test rebuilds it from the snapshot). Every host reads the same table and no sidecar is read, so the same card gets the same aspects everywhere. At annotate time the items of the card being annotated are left out, as the bench's leave-one-card-out lookup leaves them out; the two most frequent labels of the column's name win, a tie going to the label of the alphabetically first card. A name no other card carries contributes nothing and the fallback decides. A run's `labels_sha256` names the snapshot. Two points are the implementation's reading of the decision, which the user confirmed on 2026-10-04: an unseen name goes to the fallback, and the fallback's order and its cap of two. **Amendment A8 (2026-10-05) changes the fallback only.** Under A6 the fallback took the first two aspects of the lookup's prior order, and that prior comes from the bench's bird and beetle tables: on seven non-bench SRER runs (A7's appended note) it gave the `term.fits` column groups `method` 53, `taxon` 44 and `measurement` 1 times, 25 of the 44 `taxon` to numeric or unit-bearing columns (`archiveMass` in grams searched NCBITaxon for `gram` and proposed twelve organisms). The user's decision: the fallback reads the card's column grammar instead. A numeric column (dtype `real`, `integer`, `unsigned integer`, …) or a column with a unit gets `measurement` first, then `unit` when it has a unit, else the next aspect of the prior that is neither `taxon` nor `other`; a string column keeps the prior order with `taxon` removed; the cap of two, the in-play filter and "`unit` only for a column with a unit" stay. `taxon` never comes from the fallback; it still comes from the planner's hint or the lookup, which are unchanged, as is every seen column. A fallback column's Q3 groups record `search_json.a6.fallback` with `rule: "a8"` and `reason` (`unit`, `numeric` or `string`), so a run shows which rule produced its aspects; the audit-only CLM records are untouched. On the fixture cards (bench cards, most columns seen) the unseen numeric or unit-bearing columns move from `method, taxon` to `measurement, unit` (or `measurement, method` without a unit) and the unseen string columns from `method, taxon` to `method, environment` or `method, measurement`, by card. **CLM still answers Q1, Q2 and Q7**, in the same requests as before (a column the planner excluded, which M2 never asked about, gets no audit question), and every such record is **audit-only**: stored with outcome `abstain` and reason `audit_only_a6` whatever the policy says, its probabilities kept as served. It decides nothing, makes no link and no label; `explain` lists it as a decision with that marker, and review, the pending groups and feedback never offer it (they offer a group's deciding record, which is never one). A run's summary and `--out` JSON give the mode (`closed_choice`) and the count (`n_audit_only`). Q1's rule and Q7's fallback answer the majority class of the cells above (`Yes`; "the term label"), which describes them; it is not a measurement of the rules on new cards. ## The pipeline steps | Step | Task | Shape | Context view | Candidates | |---|---|---|---|---| | Plan | (the planner) | — | — | which ontologies, columns and queries; hints only | | Q1 | `column.annotate` | choice K=2; by default a rule, CLM audit-only (A6) | `{card_header, column}` | `ANNOTATE_OPTIONS`; identifiers are a rule | | Q2 | `column.aspect` | choice K=8; by default hint, lookup, else the fallback by dtype and unit, never `taxon` (A6, A8), CLM audit-only | same text as Q1 | `ASPECT_OPTIONS`; under `clm`: top-1 if proposed, else top-2 | | Q3 | `column.ontology_fits` | rank_fit 12 + anchor | F9 (A1): `NEON dataset {title}. Column {name}: {description} ({unit}). {aspect} ontology term:` | registry `option_text`, masked by aspect after scoring | | S | candidates | OLS | — | `search_candidates` ≤12, fixed `unit_candidate` | | Q4 | `term.fits` | rank_fit ≤12 + anchor; by default `ols_rank` (K1, A1), the promoted probe where `CURRENT.json` holds one (A7) | `target_state = {card_header, scope, aspect, column|site}` | `"{label}: {description[:300]}"` | | Q4b | `term.fits` (specificity) | rank_fit; not asked for an `ols_rank` group (A1), asked for a probe group (A7) | same | {parent, ≤10 children, anchor}; a child wins at `p_fit +0.10`, proposed-only (DESIGN D24) | | Q5 / Q6 | `term.fits` | rank_fit; by default `ols_rank` (K1, A1), the promoted probe where `CURRENT.json` holds one (A7) | `{card_header, site}` / `{card_header}` | ENVO biome descendants / NCBITaxon | | Q7 | `avu.value_kind` | choice K=4; by default the pre-rule, else "the term label", CLM audit-only (A6) | `value_kind_state` | `VALUE_KINDS`, deterministic pre-rules first | | Q8 | rule | — | — | exact-triple dedup, cap 25 by `p_fit` (DESIGN D25) | Questions sharing a context go in one request: Q1 and Q2 for a column share one, and every candidate group of one target shares one. Q3 ranks all twelve registry ontologies plus the anchor and masks the answer afterwards by the column's aspect and by the ontologies the plan put in play; the two best in-play ontologies are kept. Q6 keeps a second taxon only when it out-ranks the anchor, and at most as `proposed`. Q8 drops (exact duplicates, over the cap, an AVU that cannot be built) reject their groups and are listed with their reason among the abstentions. While a task is uncalibrated, steps prune by top-k only; when CLM is down or a tier is killed, the degraded method `ols_rank` proposes the OLS top-1 per group as `proposed`, never `auto` (DESIGN D28); `decider.tier: ols_rank` selects it for every candidate group, and `decider.ols_rank_tasks` per task: `[term.fits]` by default (K1, DESIGN A1), `[]` (or `annotate --ols-rank-tasks none`) for an audit run that asks CLM about `term.fits` too. Under `ols_rank` the second taxon of Q6 is not kept (only the top-1 is proposed), and where Q4b would have refined a proposed winner with OLS children the group records `specificity: {asked: false, reason: no_p_fit_ols_rank}` and the proposal's rationale says so. A run is marked `degraded` only when CLM did not answer or the tier is `ols_rank`, not for the tasks `ols_rank` decides by design, nor for a task a promoted probe decides instead (A7: at tier `auto` or `probe` the provider's `resolve_tier` for the task's active framing is `probe`, the probe decides at level `probe`, Q4b is asked, and the run's `probe_tasks` names it; `--tier ols_rank` overrides the probe). Each CLM question is stored as one `decisions` row with one `decision_options` row per candidate and one for the anchor (`s_c`, `p_fit`, rank, masked), and each candidate group as a `decision_groups` row ([Provenance](provenance.md)). The groups a reviewer is asked about are the `term.fits` groups that are proposed, escalated or anchor-won, or that only an agent has answered, and that no curator has settled; a parent that a specificity child replaced is asked through the refinement group, which offers the parent too. A curator's answer is final in M1, an agent's is replaced by a curator's (DESIGN A2). ## Rendering, anchors and the token guard `render.context(state, framing)` projects the builder-ordered state through the view and calls the vendored `to_text` (prose, never JSON). Candidate texts are stable per CURIE so CLM's action cache hits. The anchors are fixed strings in `registry.ANCHORS`: for terms "None of these terms is the right concept for this target.", for ontologies "None of these ontologies has a suitable term for this target." Raw cards are never sent: measured states are at most 1,165 tokens (2,272 synthetic worst case), the encoder runs at `--max-model-len 4096`, and a client-side guard abstains with `truncated=true` above `max_len − 16` (RESEARCH.md, token lengths). ## Two keys `task_key = sha256(json{kind, text, options, scale, centers})[:16]` over the original question texts is mesa-anyjev's lock key (term.fits `0ccc8d141ffd30ff`) and identifies labels together with `(target_sha256, option_key, label_source)`. `question_key` hashes the framing (context view and template, instructions, candidate template, anchor text, options, mask rule, render version, `schema_sha256`) and keys decisions, features and artifacts (DESIGN D1). The target identity includes the aspect the target was asked under, so a label on (column, CURIE, aspect) does not carry over to the same column and CURIE under another aspect; this is intended. `framings.lock.json` pins both keys and each task's `active_framing`; `mesa-clm framings --check` fails CI on drift. Framings in the experiment grid: F1 (noul control), F4 (Choice + anchor with a task sentence), F7 (state-only target context), F9 (a query-shaped sentence ending in "ontology term:"). A1 moved `column.ontology_fits`' active framing from F7 to F9, which rotated the lock's `lock_sha` and no `question_key` (whether a framing is active is not part of its key). F9's context names the product and the column, not the table, so the same column in two tables of one product gets the same context and the same answer. ---8<--- https://idss-mesa.github.io/mesa-clm/concepts/learning-and-bench/ --- title: "Learning and bench" description: "Where mesa-clm's labels come from and how they are identified and frozen, the feature cache, the tier fitters, leave-one-card-out with nested selection, rule R, the lookup baseline every cell must beat, the pre-registered experiments X1-X4 with the AnyJev baseline numbers, how M2's analysis plan runs X1, the tier cells and X2, the registered M2 results (term.fits K1; F9 for column.ontology_fits), and how M4's analysis plan runs the probe tier (X3), K2, the teacher ablation (X4) and the artifacts, committed before any M4 result exists." type: Guide tags: - concepts - learning - bench - labels - calibration generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: research resource: "https://github.com/idss-mesa/mesa-clm/blob/main/RESEARCH.md" title: "mesa-clm verified facts (RESEARCH.md)" author: "team:idss-mesa" - id: anyjev-bench resource: "https://github.com/idss-mesa/mesa-anyjev/blob/main/bench/results/2026-09-25/Qwen__Qwen3-8B.hf.json" title: "mesa-anyjev local bench results, 2026-09-25 (Qwen/Qwen3-8B, raw/L0/L1/L2, leave-one-card-out)" author: "team:idss-mesa" - id: m0-baselines resource: "https://github.com/idss-mesa/mesa-clm/blob/main/bench/results/2026-09-29/baselines.json" title: "mesa-clm M0 no-model controls (lookup_prob, novel-key, leave-one-product-out), 2026-09-29" author: "team:idss-mesa" - id: m0-mde resource: "https://github.com/idss-mesa/mesa-clm/blob/main/bench/results/2026-09-29/mde.json" title: "mesa-clm M0 minimum detectable effect under rule R, 2026-09-29" author: "team:idss-mesa" - id: anyjev-l2-items resource: "https://github.com/idss-mesa/mesa-clm/blob/main/bench/baselines/anyjev_l2_2026-09-29.json" title: "mesa-anyjev per-item held-out L2 predictions (X2 baseline), 2026-09-29" author: "team:idss-mesa" - id: features-build resource: "https://github.com/idss-mesa/mesa-clm/blob/main/bench/results/2026-10-01/features_build.json" title: "mesa-clm feature store build under encoder_fp c3b3d5e1a283, 2026-10-01" author: "team:idss-mesa" - id: m2-plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/m2-analysis-plan.md" title: "mesa-clm M2 analysis plan (pre-run): X1, the zero_shot and calibrated tiers, X2" author: "team:idss-mesa" - id: m2-results resource: "https://github.com/idss-mesa/mesa-clm/tree/main/bench/results/2026-10-03" title: "mesa-clm M2 registered run, 2026-10-03 (x1.json, tiers.json, x2.json, table.md)" author: "team:idss-mesa" - id: m4-plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/m4-analysis-plan.md" title: "mesa-clm M4 analysis plan (pre-run): X3 the probe tier, K2, X4, artifacts and promotion, the citation test, audits" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Learning and bench ## Labels A label is identified by `(task_key, target_sha256, option_key, label_source)` (DESIGN D1), so rotating a framing never orphans it; `option_key` is empty for closed choices. Each carries a weight and the flags `fold_eligible`, `bench_card`, `product_code` and `leak_group`: | Source | Weight | Fold-eligible | Producer | |---|---|---|---| | `curator` / `curator_implicit` | 1.0 / 0.7 | yes, except on bench cards | a pick in the MRTR elicitation or the CLI at an interactive terminal (`review`, `review --pick`, `feedback`), or a ticked neon `review.md` (DESIGN D21, A2) | | `agent_pick` | 0 | no | a plain `mesa_clm_feedback` tool call, the same CLI verbs run without a terminal, and mesa-anyjev curator rows imported without `--trust-curator`; recorded, never learned from | | `consensus_all` / `_majority` / `_negative` | 0.8 / 0.6 / 0.5 | yes | `labels ingest-neon-eval`: a term proposed by every, by at least two, or by a single one of the four agentic models in neon-avu-eval | | `teacher` / `teacher_implicit` | 0.5 / 0.3 | **no** | `labels ingest-teacher` (M4): accepted items of neon-ducklake's Opus-validated generic curation, in-registry and aspect-mapped only, Yes only, one row per table card of the product that carries the column, leak group = product (DESIGN D19; `teacher_implicit` would weight the unpicked candidates of replicate proposal files, of which the corpus has none) | | `gold` | 1.0 | yes | reserved; no hand-verified rows exist yet | The silver is *agreement between models*, not truth, and Opus is both a silver labeler and the teacher, which is why teacher labels never reach a test fold and X4 ablates them. Weights are `sample_weight` in every fitter, including LDA and ridge (DESIGN D20). The bench never reads the live label table: `labels snapshot` writes a frozen Parquet whose `labels_sha256` every cell and manifest records, and curator labels on bench cards are excluded from pre-registered cells (DESIGN D30). The bench cards are a fixed list (the seven neon-avu-eval tables), and the bench drops such rows *before* it picks the highest-weight label of each target, so a curator answer can neither change a pre-registered item's label nor remove the item. M0 ships `labels ingest-neon-eval|import-anyjev|snapshot|stats`; the fixture ingestion yields 934 rows (term.fits 285: 86 Yes / 199 No), and the 303 valid (card, CURIE) pairs of `validated.json` become 285 rows because five GAZ CURIEs come back from EBI OLS as root terms (18 pairs, listed in `terms_missing`; RESEARCH.md). ## The feature cache (milestone M1) Every text X1 and X2 embed is cached once per encoder fingerprint, at `~/.mesa/clm/features//features.duckdb` (owner-only; `learn/features.py`, DESIGN D5): the text with its exact token count, the L2-normalised vector as **float32** with the cosine of its float16 copy (the export's gate is 0.9999), the serving lock it was embedded under, and the 512-d projections of the pinned head with the head they came from. The store records the serving lock's vector recipe (image digest, `vllm serve` arguments, environment, truncation cap) when it is created and refuses another `encoder_fp`, dimension, head, format or vector recipe. `features build --snapshot` checks the running encoder container against the lock and renders the texts from a frozen snapshot without reading a label: the F1 control (the mesa-anyjev per-candidate state with the task question), the F4, F7 and F9 rank_fit requests (one per target, over its labelled candidates and the anchor) and the PR #13 replica specs `joint4096@S1` (the per-candidate state with the question appended) and `@S1ns` (without it), each state put back in the builders' key order first, since the snapshot's sorted-key JSON is identity only. `features export-npz` writes CLM's `TextCache` file for `finetune.py --embed-cache` (M7; the only place vectors are float16), and `learn/offline.py` scores rank_fit and noul questions from the cached float32 vectors with clm-serve's maths (X1 scores offline). The scores reproduce clm-serve only as closely as the vectors do: from float16 vectors the pre-registered cross-check (≤ 1e-4 in probability against `/v1/systemone`, 200 groups) failed at 1.31e-3 and 3.59e-3 (`bench/results/2026-10-01/features_build.json#/rerun/crosscheck`), from float32 vectors it passes at 5.2e-6 (`clm-latest`) and 7.47e-5 (`clm-raw`), and `/v1/rank` agrees exactly (`bench/results/2026-10-01/x1_crosscheck.json`; `scripts/x1_crosscheck.py`). The live build of the 2026-09-29 snapshot under `encoder_fp` c3b3d5e1a283 holds 1,563 distinct texts from 5,018 manifest rows (1,400 state side, 163 action side), none over the window, 620,336 encoder tokens, built in 195.2 s one text per request, with a float16 round-trip minimum cosine of 0.9999999 (`bench/results/2026-10-01/features_build.json`); rebuilt with float32 vectors it took 223.7 s, and every float16 cast of a new vector equals the first build's bit for bit (`bench/results/2026-10-01/features_build_m1c.json`). On the same texts rendered the pipeline's way, the label-free collapse diagnostic gives a mean pairwise cosine between different term.fits contexts of 0.831 raw and 0.677 after the head with the state alone (F7), and 0.993 and 0.965 with the question appended (`bench/results/2026-10-01/collapse_spike.json`; report-only, RESEARCH.md). ## Tiers and fitters (milestones M2, M4, M7) | Tier | rank_fit | choice | Artifact | |---|---|---|---| | `zero_shot` | `σ(s_c)` from `clm-latest` or `clm-raw` | softmax | none | | `calibrated` | weighted Platt on `s_c` (`a < 0` flags `inverted`) | temperature (K>2), Platt on the logit difference (K=2) | `calibrators.json` | | `probe` (M4) | weighted logistic regression, LDA or ridge on `lowdim.v1`, `pair512.v1`, `pair4096.v1`, `joint4096@S1` or `joint4096@S1ns`; spec, fitter and hyperparameters by grouped inner leave-one-card-out, then a weighted out-of-fold Platt on the logit difference | the same fitters on `choice.state.v1` or `choice.raw.v1`; an out-of-fold temperature at K > 2 (Platt at K = 2) | `probes/.json` | | `head` (M7) | per-candidate two-way rows through CLM's `finetune.py` in the serve venv, re-scored with `HeadPair`, then Platt | closed options | `heads/mesa---v.pt` | Artifacts live under `~/.mesa/clm/artifacts////v/`, immutable, with a strict loader that refuses fingerprint mismatches; `CURRENT.json` beside the versions says which version and tier each task serves, and only what it promotes is served. `learn fit` writes a version and never promotes; `learn promote` puts one task's artifact into `CURRENT.json` only when it cites a qualifying pre-registered nested cell, K2 judged that tier `a` or `b`, and, when the task already serves one, the new cell beats the current on NLL under rule R and is within 0.01 on accuracy; a head is promoted only if it beats the probe (DESIGN D18, M7). Serving never fits (DESIGN D15). The M4 reading is below and on [Serving](serving.md). ## Leave-one-card-out, nested selection, rule R Folds are one per card over the fold-eligible cards; each needs 30 training and 5 held-out labels per class, else it is skipped and reported; predictions are pooled, never fold-averaged. Every choice of framing, model, anchor, feature spec or hyperparameter is re-made inside each outer fold by grouped inner cross-validation on the six training cards (`selection: "nested"`, DESIGN D27); a choice made on all seven cards is `exploratory: true` and cannot be cited. Teacher rows of the held-out product never train that fold; a property test proves it. **Rule R** ("A beats B on m"): the one-sided 95% lower bound of a card-cluster paired bootstrap of the difference (resample held-out cards, B=2000, seed 0) is above zero **and** A beats B on at least ⌈0.8·m_c⌉ of the held-out cards with at least 10 evaluable items. Effect floors are always paired with a confidence-interval condition. `bench mde` simulates the minimum detectable effect at the realised n and is committed with the pre-registration. ## The lookup baseline A no-model lookup that copies the label of the same (scope, column, CURIE) from the other cards already scores leave-one-card-out accuracy 0.772 on `term.fits` and 0.800 on `column.ontology_fits`, above AnyJev L2's 0.765 on `term.fits` (reproduced by `mesa-clm bench baselines`: `bench/results/2026-09-29/baselines.json`, cells `neon_term_fits.baseline.lookup_prob` and `neon_ontology_fits.baseline.lookup_prob`; leave-one-product-out 0.723 / 0.721; ties between training cards go to the alphabetically first card, RESEARCH.md). So every citable cell must report `lookup_prob` (Laplace-smoothed key frequency over the training cards, falling back to the training prior on unseen keys), the novel-key subset (159 items for term.fits, 99 for ontology_fits) and leave-one-product-out, and **`beats_lookup_novel`** — novel-key AUROC cluster lower bound above 0.5 and novel-key NLL beating `lookup_prob` under rule R — gates every `auto` threshold (DESIGN D8). ## Pre-registered experiments (frozen at G1; full text in DESIGN.md) * **X1 framing A/B**: {F1, F4, F7, F9} × {`clm-latest`, `clm-raw`} × {term.fits, ontology_fits}, scored offline from the feature cache with shuffle and candidate-only controls; a fixed decision rule picks the production framing A1 (M2). The rule's sixth step, an anchor variant chosen by NLL, was withdrawn before the freeze: no variant text was written down before the live stack had been looked at on a bench card, so X1 runs with the registry anchors only (DESIGN, "G1 freeze" and the implementation note "The X1 anchor variant"). * **X2 baselines**: majority, `lookup_prob`, novel-key, leave-one-product-out, the PR #13 logistic-regression replica, and per-item AnyJev L2 predictions (dumped in M1, below), which make the K2(a) comparison paired. * **X3 tier sweep**: zero-shot and calibrated on A1; probe specs and fitters; the head (M7). * **X4 teacher ablation**: off vs (0.5/0.3) vs (0.3/0.1), scored on silver and silver-minus-Opus; with few teacher rows in the bench products' registry the expected effect is stated in advance as about null (D19's "13 usable items" described the SRER generics of 2026-09-29 and is superseded by the corpus M4 reads, below). Kill and pivot criteria K0–K4 are fixed with them: no state signal makes a task's CLM tiers audit-only and its proposals `ols_rank`; a task earns auto-eligibility only by beating the lookup on novel keys and matching AnyJev L2 in a paired test with ECE at most 0.08. ## Milestone M2: the analysis plan (pre-run) `design/m2-analysis-plan.md` reads every frozen rule M2 runs as one deterministic algorithm, names each alternative reading with the reason it was rejected (the more conservative one wins), and lists every constant; it and its code were committed and pushed **before** the first run on the snapshot's labels, so the commit shows every choice preceded the results (DESIGN, "Implementation notes (M2)", with the pre-run disclosure of every label-free look). After the first run it changes only by amendment, with the affected cells marked exploratory. **Inputs.** Only the registered snapshot `bench/snapshots/2026-09-29.parquet`: `bench framing`, `bench run` and `bench x2` refuse any other file by its sha256 and its label content, never write a snapshot, load its rows into a scratch label store (the per-host sidecar is never read) and check every task's items, class counts, items per card and `min_weight` against the counts M0 published, before any statistic. Every run records its configuration; anything but the registered one (both X1 tasks, F1/F4/F7/F9 on `clm-latest` and `clm-raw` with every one of the 16 arms scored, the full run and the nesting, B = 2000, seed 0, α = 0.05, 200 shuffle draws; the framings lock of G1 and each model's fingerprint under the serving lock of G1; for X2 the registered AnyJev dump) is written with every cell `pre_registered: false`, `exploratory: true`, and no verb takes an option for B, the seed or α. The producers check this themselves, so a library call under another lock, fingerprint or dump is unregistered too. ### How X1 decides Each arm (a framing on a model) scores the same items offline from the feature cache: `s = scale·(zs·zc − zs·za)` for F4, F7 and F9, the noul logit difference for the F1 control. **Rule (1)** qualifies an F4/F7/F9 arm when the AUROC of `s` has a card-cluster lower bound above 0.5 and is at least 0.60, and its ΔAUROC against the **within-card state shuffle** passes rule R: the shuffle gives every target the context of another target of its own card, the comparator is the mean AUROC of 200 seeded derangements, and both rule R conditions are computed on that difference (the drafts' AUROC of an averaged score was biased against every arm and was replaced before any run). If nothing qualifies on either model the outcome is **K1** (the task's CLM tiers become audit-only, proposals use `ols_rank`, M4 goes probe-first). Otherwise **rule (2)** ranks the qualified arms of `clm-latest` (of `clm-raw` when `clm-latest` has none) by the pooled NLL of leave-one-card-out Platt (weighted, 30/5 guards, no fit on fewer than 100 items): an F7 or F9 winner stands; an F4 winner yields to a more cacheable qualified arm it does not beat under rule R, and between F7 and F9 the lower NLL wins only if it beats the other under rule R, else the one with fewer encoder tokens per target, then F7. **Rule (3)** keeps `clm-latest` unless `clm-raw` beats it on NLL at that framing; **rule (4)** only recommends an amendment reopening D3 when F1 beats every eligible arm, never adopts it; rule (6) is withdrawn. The learned candidate-only probe (the PR #13 recipe on the candidate vectors), the mean-context score, the collapse diagnostic, calls and tokens per target and the p50 latency of a label-free timing run are reported, never read by a rule. `bench framing --decide --from x1.json` replays every decision from the JSON (each rule R verdict against its own numbers and the run's bootstrap settings, the arm records, cells and fold choices against the traces, each cell's metrics against its own per-item predictions) and recomputes the decisions, the arm records, the `p_loco` column, the cells' predictions and the probe's statistics from `x1_items.parquet`; the arm cells' lookup controls and `beats_lookup_novel` need the items' states and are report-only. "Cluster-LB" is the one-sided 95% bound of the card bootstrap, so every interval `[lower, upper]` the reports print is a 90% interval, and they say so. The timing run asks each drawn target under both models back to back, alternating which goes first, and flags each ask that sent a text the run had not sent before (clm-serve's embedder cache is shared by both models). ### Nested selection For each held-out card the whole decision is made again on the other six cards only (their shuffles, their folds, their bootstraps); `fold_choices` records each fold's arm. A fold whose inner outcome is K1 or undecidable chooses no arm and is skipped in both tiers. The full-data choice is the production choice A1 (an amendment records it); a citable cell needs at least 5 of 7 folds to agree with A1 on framing **and** model. ### The tier cells and X2 `bench run --tiers zero_shot,calibrated --loco` writes `tiers.json`, the one producer of the citable-form `..` cells: fold *c* is scored (and at `calibrated` fitted) with fold *c*'s own arm, X1's outcome taken only from a registered `x1.json` that replays, recomputes and names the same labels, framings lock and model fingerprints; each fold's `fold_choices` entry keeps X1's pointer to its inner trace (`x1_trace`) and the file's note names `x1.json` by sha256. `zero_shot` is `σ(s_c)` or CLM's softmax; `calibrated` is weighted Platt with hard targets on `s_c` or the logit difference, temperature (T in [1e-4, 1e4]) at K > 2, with the unweighted fit reported beside it. `…@full` (A1 in every fold) is exploratory; without an A1 the default F7@`clm-latest` is reported for audit only; the closed choices are F7@`clm-latest` (not citable in M2) with `@clm-raw` reported. Every cell carries the frozen fields, the lookup controls on its own folds, `beats_lookup_novel` with both of its conditions and the reason when it fails, and its per-item predictions. `bench x2` writes the M0 controls (with a note on whether they equal the published M0 cells), the PR #13 replica (unweighted, float32 vectors) and AnyJev L2 joined by D1 identity; X2 gates nothing. ## Milestone M2: the registered results (2026-10-03) The run protocol (plan §14) ran once on the serving host, each step once, after the plan and its code were pushed: the label-free timing run, `bench framing --decide`, the replay, `bench run`, `bench x2`, `bench table`. Every output was committed as produced under `bench/results/2026-10-03/` (`x1_latency.json`, `x1.json`, `x1_items.parquet`, `x1.md`, `tiers.json`, `tiers.md`, `x2.json`, `x2.md`, `table.md`); the run is the registered one (`x1.json#/x1/registered`), and `bench framing --decide --from` replays and recomputes it from the files. DESIGN.md records the outcome as amendment A1 and RESEARCH.md ("M2 results") holds every number with its JSON pointer; the main ones follow. Intervals are the pair of one-sided 95% card bootstrap bounds (a 90% interval); silver labels are agreement between models, not truth. **X1** (`x1.json#/x1/tasks//arms/`; AUROC of the raw score, rule (1) needs a lower bound above 0.5, AUROC at least 0.60 and a ΔAUROC over the within-card shuffle that passes rule R): | arm | term.fits AUROC | rule (1) | ontology_fits AUROC | rule (1) | ontology_fits LOCO-Platt NLL | |---|---|---|---|---|---| | F4@clm-latest | 0.497 [0.406, 0.572] | fails | 0.611 [0.529, 0.677] | qualifies | 0.666 | | F4@clm-raw | 0.458 [0.413, 0.505] | fails | 0.501 [0.399, 0.614] | fails | 0.693 | | F7@clm-latest | 0.511 [0.482, 0.544] | fails | 0.693 [0.611, 0.762] | qualifies | 0.633 | | F7@clm-raw | 0.494 [0.428, 0.549] | fails | 0.592 [0.546, 0.637] | fails | 0.688 | | F9@clm-latest | 0.557 [0.512, 0.596] | fails | 0.751 [0.697, 0.805] | qualifies | 0.602 | | F9@clm-raw | 0.539 [0.495, 0.592] | fails | 0.745 [0.700, 0.804] | qualifies | 0.618 | * **term.fits: K1.** No arm qualifies on either model (every one is under the 0.60 floor), and every nested fold's inner outcome is K1 too (`x1.json#/x1/tasks/neon_term_fits/decision`, `nested/fold_choices`). As the pre-registered K1 says, its zero_shot and calibrated tiers are audit-only, its proposals use `ols_rank`, and M4 goes probe-first. * **column.ontology_fits: F9 on `clm-latest`.** Rule (2) ranks the qualified `clm-latest` arms by NLL (F9 lowest), rule (3) keeps `clm-latest` (`clm-raw` does not beat it at F9 under rule R), rule (4) does not fire (no D3 amendment), and all 7 nested folds choose F9@`clm-latest` (`x1.json#/x1/tasks/neon_ontology_fits/decision`, `a1`, `nested/fold_choices`). * The candidate-only probe (report-only, the PR #13 recipe on the candidate vectors alone) reaches AUROC 0.808 [0.765, 0.858] on term.fits and 0.816 [0.758, 0.873] on ontology_fits (`x1.json#/x1/tasks//candidate_probe`). **The tier cells** (`tiers.json`). The citable-form nested cells of column.ontology_fits (`neon_ontology_fits..F9`, 7 of 7 folds agreeing with A1): zero_shot accuracy 0.489, NLL 2.624, ECE 0.464, AUROC 0.751 [0.697, 0.805]; calibrated accuracy 0.642, NLL 0.602, ECE 0.123, AUROC 0.732 [0.673, 0.802]. Neither has `beats_lookup_novel`: on the 99 novel-key items the AUROC lower bound passes (0.597 and 0.584) but the NLL comparison with `lookup_prob` (NLL 0.653) does not pass rule R (zero shot NLL 2.846; calibrated NLL 0.594, the bootstrap lower bound of the difference −0.046), and neither cell has a Clopper–Pearson threshold at 5% or 10% risk (`baselines/beats_detail`, `metrics/threshold_cp`). The term.fits audit cells (F7@`clm-latest`, not pre-registered under K1): zero_shot accuracy 0.495, AUROC 0.511; calibrated accuracy 0.698 (majority 0.698), AUROC 0.457. The closed choices (F7@`clm-latest`) score below their majority rates at zero shot: column.annotate 0.357 against 0.643, column.aspect 0.050 against 0.300, avu.value_kind 0.324 against 0.478 (calibrated 0.324); the calibrated cells of annotate and aspect are empty because no fold trains on 100 items. After seeing these cells the user decided that serving answers the closed choices by deterministic rules and keeps CLM's answers to them for audit only (amendment A6, 2026-10-04; see [Decision model](decision-model.md)). That is a product-safety change, not a result: no pre-registered rule covers these tasks, no cell changes or is re-read, and the bench never counts the audit-only records (it reads label snapshots only). The aspect rule's lookup is M0's lookup over the registered snapshot's 60 `column.aspect` items, frozen into the package (`aspect_lookup.json`, rebuilt from the snapshot by a test); a run leaves out the annotated card's own items, so a leave-one-card-out end-to-end bench stays leave-one-card-out. **X2** (`x2.json`, baselines that gate nothing): | cell | acc | AUROC | NLL | ECE | beats_lookup_novel | |---|---|---|---|---|---| | `neon_term_fits.baseline.pr13@S1` | 0.723 | 0.709 [0.643, 0.771] | 1.460 | 0.215 | false | | `neon_term_fits.baseline.pr13@S1ns` | 0.747 | 0.786 [0.738, 0.839] | 1.019 | 0.184 | false | | `neon_term_fits.baseline.anyjev_l2` | 0.765 | 0.782 [0.743, 0.833] | 0.499 | 0.058 | true | | `neon_ontology_fits.baseline.pr13@S1` | 0.821 | 0.884 [0.842, 0.927] | 0.791 | 0.131 | false | | `neon_ontology_fits.baseline.pr13@S1ns` | 0.821 | 0.905 [0.869, 0.941] | 0.568 | 0.137 | false | | `neon_ontology_fits.baseline.anyjev_l2` | 0.837 | 0.908 [0.884, 0.940] | 0.375 | 0.078 | true | The recomputed no-model controls equal M0's cells field for field (`x2.json#/notes/2`), and the AnyJev L2 cells join all 285 and 190 items. Two independent recomputations after the run agree with every number they recomputed (RESEARCH.md, which also names what the repository reproduces itself: the replay, and X1's decisions under 200 other bootstrap seeds). What A1 changes in the pipeline is on [Decision model](decision-model.md): Q3 asks F9, term.fits groups are `ols_rank` by default. ## Milestone M4: the analysis plan (pre-run) `design/m4-analysis-plan.md` reads every frozen rule M4 runs (X3's probe tier, K2, X4, the citation test, artifacts and promotion, the production audit) the way the M2 plan read X1: one deterministic algorithm per rule, every alternative reading named with the reason it was rejected (the more conservative one wins: the one that admits less, cites less or promotes less), every constant in its Appendix B and held to the code by `tests/unit/test_m4_plan_constants.py`. It and its code are committed and pushed **before the first M4 run on the snapshot's labels**; until then the code ran on synthetic data only and nothing combined a model output with a silver label. This section says what the verbs do as the plan reads them; the registered run and its outcome are under "M4 results" at the end of it. After the first run the plan changes only by amendment, with the affected cells marked exploratory; the amendment that records K2's verdicts, X4's decision and the promotions (A7) is the planned consequence of the run, not such a change. **Inputs and the M4 registration.** The snapshot is M2's, unchanged (`bench/snapshots/2026-09-29.parquet`, read through M2's refusals: both hashes, the published counts, never written); the folds, guards and weights are M2's. The feature store is the registered encoder's under the serving lock of G1, holding every registered text under F4, F7, F9, F1 and the X2 joint specs; X3 reads from it only, X4 adds the teacher items' texts (built label-free before the run). The M4 registration (`bench.registered.REGISTERED_M4`) adds to M2's, which it never repeats: the framings lock of A1 (M2's registration keeps G1's so its replay still holds) with the active framing per task (F9 for `column.ontology_fits`, F7 elsewhere), the X3 grid (the specs per shape, each spec's model, the fitters with their hyperparameter values in declared order, the inner criterion, the floors), the committed `tiers.json` and `x2.json` K2 reads by sha256 (other bytes are refused outright), the K2 constants, X4's arms, and the teacher inputs, filled from the label-free ingest run before the pre-run commit (plan §12.2; DESIGN "Implementation notes (M4)", item 6): the corpus content hash `d90387928bed…` as read at neon-ducklake commit `b1fa52a8d3ff…`, the teacher snapshot `bench/snapshots/2026-10-04-teacher.parquet` (sha256 `397f98d4b28c…`, content `deb0dc46e17b…`) and the silver-minus-Opus snapshot `bench/snapshots/2026-10-04-minus-opus.parquet` (sha256 `2cd529ffa439…`, content `d8e26a0c7ac3…`); no pin is a placeholder. Every producer applies it itself: `bench x3`, `bench k2` and `bench x4` write a run on other labels, another lock, other fingerprints, another grid, another active framing, a subset of tasks or other bootstrap settings with every cell `pre_registered: false`, `exploratory: true` and the deviations in the file's first note, whatever the caller says; `learn fit` computes the same lock, fingerprint and grid deviations and **refuses** on any (exit 1, nothing written), since an artifact is what production serves and an unregistered one has no cell to cite; a pinned input whose bytes differ is refused everywhere. The verbs expose no option for B, the seed, alpha, the grid, the framings or the models. ### The probe tier Three readings settle X3's shape. The **framing is not an axis**: a task's probe is fitted and served on the texts of its active framing after A1, since which framing a task asks is X1's decision and a probe chosen on another framing's texts could not be served without a lock rotation. **A spec belongs to one model**: a spec that reads any head quantity is a `clm-latest` probe, one that reads raw vectors only is a `clm-raw` probe, and a served probe lives in the artifact bundle of its spec's model. **The floors are per fit**: 40 training items for every probe fit, outer and inner, and 100 out-of-fold items for the pool the probe's calibrator is fitted on; a fold below either is skipped with the reason recorded. **Specs** (`learn.probe.SPECS`, in declared order; `zs`, `zc` the 512-d `clm-latest` projections, `xs`, `xc` the raw L2-normalised 4096-d vectors, `s_latest` and `s_raw` the zero-shot `s_c` under each model, `⊕` concatenation, `⊙` the elementwise product): | spec | shape | model | formula | |---|---|---|---| | `lowdim.v1` | rank_fit | clm-latest | `[s_latest, s_raw]` | | `pair512.v1` | rank_fit | clm-latest | `zs⊙zc ⊕ |zs−zc| ⊕ [s_latest]` | | `pair4096.v1` | rank_fit | clm-raw | `xs⊙xc ⊕ [s_raw]` | | `joint4096@S1` / `@S1ns` | rank_fit | clm-raw | the raw vector of the X2 joint context text, with / without the task question | | `choice.state.v1` | choice | clm-latest | `zs ⊕` the K zero-shot option logits under clm-latest | | `choice.raw.v1` | choice | clm-raw | `xs ⊕` the K option logits under clm-raw | A rank_fit spec has one row per labelled (target, candidate) pair, a choice spec one per labelled target; the anchor text is read only to form `s_c`. The formulas live in one place (`probe.rank_fit_features`, `probe.choice_features`) for the bench and for serving, and the builder's zero-shot logits equal the tier cells' scores. **Fitters** (`learn.linear`): weighted L2 logistic regression (binary at K = 2, the symmetric multinomial form above), weighted shrinkage LDA (toward the scaled identity, the Ledoit–Wolf target) and weighted ridge on one-hot targets, in numpy float64, the label weights as sample weights (DESIGN D20: an integer weight equals that many copies of a row). Every data term is a **weighted mean** with the penalty `λ/2 ‖coef‖²` on the standardized features and never on an intercept (the convention of the M2 Platt fit; the sum form was rejected because it would make a 4097-d fit at the smallest λ nearly unpenalised and dependent on the scale of the weights). Features are standardized with the training set's weighted moments (std floored at 1e-8); a thin-SVD reduction to the row span makes a wide fit exact and cheap. Grids in declared order, which is the tie order: logreg λ ∈ {1e-2, 1e-1, 1, 10}; lda γ ∈ {0.1, 0.5, 0.9}; ridge λ ∈ {1e-1, 1, 10}; fitters `logreg, lda, ridge`. Newton's method with Armijo halving; a fit that does not converge is used as it is and flagged `converged: false`, never refitted or skipped (the M2 calibrators' rule). LDA with a class absent from a training set is refused and that configuration is recorded unfittable on that fold. **The nested inner selection** (`probe.inner_select`, DESIGN D27). For an outer fold (held-out card *c*, training cards *T*) the inner folds are the grouped leave-one-card-out over the cards of *T*; nothing in the inner loop reads an item outside *T*. Each inner fold applies the 30/5 guard and the probe floor of 40 to the task's items only (teacher rows count toward neither). Every configuration of the grid (spec × fitter × hyperparameter, in declared order) is fitted on every passing inner fold and applied to the inner held-out card; the out-of-fold predictions are pooled and the criterion is the **pooled OOF NLL of the uncalibrated probe probabilities, unweighted over the items** (the quantity the cell is judged on; the weights are sample weights of the fits). The lowest wins; a tie goes to the first in declared order. A configuration unfittable on any passing inner fold is not selectable on that outer fold; no selectable configuration, or no passing inner fold, skips the outer fold with the reason. **The OOF calibrator and the outer fold** (`probe.nested_probe`). After the outer guard and floor, fewer than 100 pooled OOF items of the winner skip the fold (`below_floor n < 100 OOF items (probe calibrator)`): no probe calibrator is ever fitted on fewer. Otherwise the calibrator is fitted **weighted** on the winner's pooled OOF predictions: at K = 2 a Platt on the OOF logit difference (`a < 0` flagged `inverted` and kept), at K > 2 a temperature on the OOF log-probabilities (a bound flagged and kept); the cell's `calibration` is its kind. The winner is refitted on all of *T*, applied to card *c*, the calibrator applied, and the held-out predictions pooled in item order, never averaged; `ProbeArtifact.predict` on a fold's fit equals the pooled held-out probabilities bit for bit. Stated in advance from the published counts (`bench/results/2026-09-29/baselines.json#per_fold_n`): `column.annotate` (98 items) and `column.aspect` (60) can never pool 100 OOF items, so their probe cells have no evaluated fold and `metrics: null`, with the uncalibrated probe reported in their diagnostics only; with per-card counts of 13, 11, 9, 9, 7, 6 and 5, `column.aspect`'s inner training sets also fall to 36 or 38 items on the six inner folds where the 13-item card and an 11- or 9-item card are both held out, which the probe floor of 40 skips. `avu.value_kind`, `term.fits` and `column.ontology_fits` clear the 40 floor on every outer and inner training set outright, and the 100 OOF floor on every outer fold only if the inner 30/5 guards pass (the per-card class counts are not published, so that half is not stated in advance). Under A6 the closed choices are decided by rules, so none of this changes production. **Teacher rows** (`probe.TeacherRows`, DESIGN D19) are added to every training set, outer and inner, except the rows whose `leak_group` equals the held-out card's product; they are never in a test index, never counted by a guard or floor, and every fold records `n_teacher`. In X3 there are none; X4 adds them. ### The X3 cells (`bench x3`) Four cells per task, every one through the same cell builder as the M2 cells (`cells.assemble_cell`: the identity fields, counts, metrics, lookup controls, `beats_lookup_novel`, `threshold_cp` and the per-item predictions): the **nested cell** `.probe.` (the whole grid, `selection: "nested"`, the only citable form), `@latest` and `@raw` (the same procedure on the specs of one model; pre-registered, never citable because a variant; what K2's clm-raw clause compares) and `@full` (one configuration chosen by the inner LOCO over all seven cards, evaluated in every outer fold with that fold's own calibrator and refit; `selection: "full"`, `exploratory: true`). The nested cell's identity (`feature_spec`, `model`, `fingerprint.clm_model_fp`) is the **full-data** configuration's, the one production would serve, as A1's arm is the identity of the M2 nested cells; `fold_choices` records each outer fold's own configuration (spec, fitter, hyper, model, inner NLL, the calibrator record, `n_teacher`, `converged`, `evaluated` or the skip reason) and `diagnostics.fold_agreement_with_full` how many folds chose the served one. A nested cell whose folds chose specs of both models is one cell, each item scored by its fold's own spec. Every spec is servable (both models are served); a task whose full-data selection chooses nothing is `servable: false`. Report-only diagnostics carry every configuration's inner NLL per fold, the uncalibrated held-out and pooled metrics, the refit's convergence, each spec's `mean_state_cos`, calls, tokens and milliseconds per decision in M2's units. **What can be cited.** Only the nested cell, and only when the citation test passes ([Tiers and policy](tiers-and-policy.md)); the closed choices' probe cells cannot have `beats_lookup_novel`, each for its own reason (`column.aspect` and `avu.value_kind` have no AUROC at K > 2; `column.annotate`, K = 2, has one, but its lookup control is `insufficient_clusters` under the frozen minimum-detectable-effect statement, one card having at least 10 novel-key items, and its probe cell has no evaluated fold under the 100 OOF floor), so no closed-choice probe cell can be cited in M4, stated in advance. `term.fits` can be cited for a numeric `auto` only through a promoted probe, since its calibrated tier is K1's audit-only. ### K2 (`bench k2`) K2 judges each task's **best servable tier on nested cells**. The candidates are the task's citable-form nested cells: `calibrated` from the committed `tiers.json` (only `column.ontology_fits` has one; `term.fits`' K1 audit cells and the closed choices' fixed F7 arms are listed with `eligible: false` and the reason) and `probe` from `x3.json`; a candidate is eligible only when its own cell is `pre_registered: true`, nested, servable, not exploratory and pools items. The best tier is the eligible candidate with the lowest pooled NLL (a tie goes to `calibrated`, the lower rank); whether the probe beats the calibrated tier under rule R is recorded beside it, because promotion needs it and K2 does not. On the best cell, with every number recorded: * **(a) auto-eligible**: `beats_lookup_novel` ∧ non-inferiority to AnyJev L2 on the full item set ∧ ECE ≤ 0.08 with cluster upper bound ≤ 0.12. The AnyJev side is `x2.json`'s per-item cell joined by identity; "the full set" is read strictly (the tier must pool every item of the task, counted from its `task_counts` or the registered count and failing closed when it has neither, and every one must match, so a tier that skipped a fold fails here); non-inferiority is two conditions, Δacc's card-cluster paired bootstrap lower bound above −0.02 **and** the card-sign condition, which is **rule R's sign test, verbatim and without a margin**: on at least ⌈0.8·m_c⌉ of the m_c cards with at least 10 items the per-card Δacc is above 0, and fewer than 4 such cards fails. The plan names and rejects the margin-shifted per-card test (Δacc above −0.02 per card) as the permissive reading; it is reported beside the gate (`card_sign_margin_report`, computed in integers), never gated on. Stated in advance: the literal test asks the tier to beat AnyJev L2 on most cards, so (a) is demanding, and a tier that is non-inferior on the cluster bound but not better per card is (b) at best; a numeric `auto` stays null in 0.1.0 whatever the verdict; * **(b) proposer-only**: `beats_lookup_novel` alone; * **(c)** otherwise, "no eligible candidate" included. A closed choice is (c) by construction (see "What can be cited" above for each one's reason). Strict inequalities are strict. **The clm-raw clause** (`head_adds_nothing`, rank_fit tasks): on the `@latest` and `@raw` cells, `@latest` does **not** beat `@raw` on NLL under rule R and `@raw` is non-inferior to `@latest` on accuracy within 0.01; recorded, with no production change in the run (the consequences are amendment A7's). `k2.json` holds the inputs with their sha256, the constants, the candidates, the comparison, the best tier and its cite, every condition and the verdict with its reason; `k2.md` is one row per task, and `bench table` lists the verdicts beside the cells of the other files. ### X4 and the teacher corpus (`labels ingest-teacher`, `bench x4`) **The corpus** (`/curation/generic/.validated.json`), ingested label-free on 2026-10-05 (01:44–01:46Z, before the pre-run commit; the report is transcribed in DESIGN "Implementation notes (M4)", item 6) at neon-ducklake commit `b1fa52a8d3ff…`, corpus hash `d90387928bed…`: 55 files, 389 `accepted` items, every file's `model` `claude-opus-5-5`, no `human_accepted` list. DESIGN D19 as read: items with status `accepted` or `human_accepted`; a file whose `model`, or whose replicate proposal file's `model`, starts with `mesa-clm` is refused (none was). The ingest found 6 replicate proposal files under `sites/SRER/curation/proposals`, read each for its `model` only, and wrote 0 `teacher_implicit` rows: it synthesizes no row from a proposal's unpicked candidates, so X4's `teacher_implicit` weights weight nothing in this run. Drops are counted by reason, and the ingest dropped 103 `out_of_registry` (a CURIE prefix that is not a registry ontology), 101 `no_column` (a dataset-level item), 22 `unmapped_aspect` (`process`), 17 `collapsed_identity`, 11 `unresolved_column` (no table card of the product carries the column), 0 `ontology_mismatch` and 0 `term_missing` (OLS has no usable record). **Target resolution**: a column resolves to **every** table card of the product (`sites/SRER/cards/anyjev/..md`) whose column set contains it, one row per card, the rows sharing `leak_group` = the product code; no dataset-scope state is synthesized for an item without a resolvable column (the plan had left that resolution to M4; this is the conservative answer); 231 (item, card) resolutions, and `DP1.10092.001` has no card. Rows are Yes only: `term.fits` for (column state, CURIE) with the candidate as OLS records it, and `column.ontology_fits` for (column state, ontology) when the ontology is aspect-allowed (otherwise the ontology row is skipped and counted `ontology_not_aspect_allowed` outside the drops, since the `term.fits` row is still written: 5 such); 435 rows inserted, 231 `term.fits` and 204 `column.ontology_fits`; every row `teacher` at 0.5, `fold_eligible=false`, `bench_card=false`, origin `teacher:`. The OLS records of the corpus's in-registry CURIEs were recorded once from live EMBL-EBI OLS4 into `tests/fixtures/ols-teacher/` (110 `get_term` responses; `scripts/record_ols_teacher.py`), so the ingest replays. `labels snapshot` then wrote `bench/snapshots/2026-10-04-teacher.parquet` (1,369 labels), whose silver rows are byte-identical to the registered snapshot (the X4 producer checks the content digest of its non-teacher rows); `features build --snapshot --tasks term.fits,column.ontology_fits --framings F7,F9` embeds the teacher texts and has not run yet. **The silver-minus-Opus subset.** The committed snapshot does not carry the model set behind a consensus row, so the subset comes from a label-free rebuild of the silver from `tests/fixtures/neon-avu-eval` with Opus's runs removed (`labels ingest-neon-eval --exclude-models claude-opus-5-5` into a separate store, then `labels snapshot --out bench/snapshots/2026-10-04-minus-opus.parquet`, 679 labels, committed and pinned with the pre-run commit). The surviving items are the registered items whose identity the rebuilt task carries **with the same label** (a weight change survives, a flipped label or a vanished identity does not); the scoring is the same predictions on that subset. **The arms.** Three runs of the X3 nested procedure on **identical outer folds**: off, (0.5, 0.3) and (0.3, 0.1) for the (`teacher`, `teacher_implicit`) weights, the teacher rows entering every training set as sample weights except the held-out card's product (both bench products have a corpus file, so the rule fires on every fold), never a test item (`teacher_in_test: false`, asserted). Cells `.probe.@teacher-off|-0.5|-0.3` and their `-minus-opus` twins, every one a variant, pre-registered and `exploratory: true`, never citable; their identity is the off arm's full-data choice. **Decision**: keep teacher labels in production fits iff `on ≻ off` on **novel-key NLL** under rule R for **both** scorings, for the (0.5, 0.3) arm; the (0.3, 0.1) arm is reported; fewer than two novel-key cards counts as not passing. The record is in every X4 cell's diagnostics and the file's notes. ### `bench e2e --loco` (planned, second wave) The end-to-end measure is report-only and writes no cell: per held-out card, consensus-all recall (the fraction of the card's `consensus_all` Yes `term.fits` CURIEs the run proposes, against AnyJev's static recall of 0.25) and anchor-abstain precision (the fraction of the run's anchor-won groups whose candidates include no consensus-all Yes), pooled with the card-cluster bootstrap bounds. Its measurement half is in `bench/e2e.py`; the fold provider that serves a fold's nested probe or calibrator from the store behind the decision-provider protocol is **not in the pre-run commit**: `bench e2e --loco` exits with a usage error that says so, and the measure ships by amendment with its own disclosure. ### The run protocol (plan §12) Before the commit nothing combines a model output with a real label and no M4 verb runs on the registered snapshot, the live feature store or the sidecar; the one step that reads labels, the teacher inputs (`labels ingest-teacher`, `labels snapshot` for the teacher snapshot, the rebuild without Opus and its snapshot), was run label-free with respect to model outputs on 2026-10-05 before the commit and is disclosed above, its pins written into `REGISTERED_M4` and committed with the plan. Then, once each, on the serving host: `features build` for the teacher texts → `bench x3 --date ` → `bench k2 --date ` → `bench x4 --date ` → `bench table`; every output committed as produced, in one commit, before any of it is written into prose (`--force` replaces only a failed or unregistered attempt, and the replacement is disclosed). Then `learn fit --date ` (the full-data probes and calibrators, one version per served model, exported to `bench/results//artifacts_v/` and committed; refused outright on any deviation from the registration), promotion decided by K2's verdicts and recorded in DESIGN amendment A7 with X4's decision, `learn promote` once per promoted task after A7, and the production audit (`annotate` on at least five non-bench SRER cards under the promoted tiers, `audit sample --n 100 --min-cards 5`, the curator's `audit review`, `audit record`). A numeric `auto` stays null in 0.1.0 whatever K2 says. Determinism: the fitters have no randomness, ties go to the first configuration in declared order, every bootstrap uses B = 2000 and seed 0, and two runs of a producer on the same inputs are byte-identical (tested on synthetic worlds); a discrete outcome that flips under another platform's last-bit differences is recorded as a discrepancy, never silently re-derived. ### M4 results (2026-10-04; DESIGN A7) The run protocol ran once on the serving host and its outputs are committed as produced under `bench/results/2026-10-04/` (`x3.json`, `k2.json`, `x4.json`, their `.md`, `table.md`, `artifacts_v1/`); DESIGN A7 records the consequences and RESEARCH.md ("M4 results") every number. **`term.fits`: K2(b), the probe is promoted.** Its best servable tier is the nested probe cell `x3.json#neon_term_fits.probe.F7` (`pair512.v1` on `clm-latest`, logreg λ 1, Platt): accuracy 0.754, NLL 0.485, ECE 0.079, AUROC 0.804 [0.749, 0.864]; `beats_lookup_novel` true (novel-key AUROC lower bound 0.753; NLL ≻ `lookup_prob` under rule R with lower bound 0.057); 6 of 7 folds chose the served configuration. K2(a) fails on its other three conditions (Δacc against AnyJev L2 −0.011 with cluster lower bound −0.053, the card-sign test 4 of 7 with 6 needed, ECE's cluster upper bound 0.129 > 0.12), so the verdict is (b), proposer-only: artifact version 1's `term.fits` probe (`a686a06aab14497a`) is promoted on the serving host, and a task `decider.ols_rank_tasks` names is now decided by a promoted probe where the provider resolves one ([Tiers and policy](tiers-and-policy.md)). **`column.ontology_fits`: K2(c), nothing promoted.** The probe (`x3.json#neon_ontology_fits.probe.F9`: accuracy 0.821, NLL 0.404, ECE 0.061, AUROC 0.892 [0.855, 0.933]) beats the calibrated F9 cell on NLL under rule R but `beats_lookup_novel` is false (the novel-key NLL bootstrap bound passes at 0.047, the card sign test fails; K2 also fails non-inferiority, Δacc −0.016 with lower bound −0.053, 2 of 7 cards, ECE's upper bound 0.131); production keeps A1's zero-shot F9 proposals, and probe investment for the task pauses until ≥ 200 curator labels or CLM-35B. **The closed choices: K2(c) by construction** (nothing pools under the calibrator floor; `avu.value_kind`'s probe cell scores accuracy 0.655, NLL 0.859 against the majority 0.478 and the lookup 0.680); A6's rules stand. **X4: teacher labels are not kept.** `on ≻ off` on novel-key NLL fails for both scorings at (0.5, 0.3): `term.fits` Δ +0.006 (lower bound −0.062) on silver and +0.035 (−0.037) on silver-minus-Opus; `column.ontology_fits` −0.106 (−0.166) and −0.114 (`insufficient_clusters` on the 66 surviving novel-key items); the (0.3, 0.1) arm gives `term.fits` +0.035 (−0.008) / +0.047 (−0.013) and `column.ontology_fits` −0.070 (−0.126) / −0.102. Production fits use the registered snapshot only. **CLM's head adds signal**: `@latest` ≻ `@raw` on NLL under rule R for both rank_fit tasks (lower bounds 0.012 and 0.026). No numeric `auto` exists (every probe cell's `threshold_cp` is null at both risks; 0.1.0 ships proposed-only), and the production audit on the promoted `term.fits` probe is deferred, not run (DESIGN A7's appended note; the sample of 100 probe decisions over seven non-bench cards is kept). ## Baseline numbers From mesa-anyjev's `bench/results/2026-09-25/Qwen__Qwen3-8B.hf.json` (Qwen/Qwen3-8B bf16, leave-one-card-out over 7 cards): `neon_term_fits.L2` accuracy 0.765, ECE 0.058, coverage at 5% risk 0.088 (n 285, 199 negatives); `neon_ontology_fits.L2` accuracy 0.837, ECE 0.078, coverage at 5% risk 0.547 (n 190, 114 negatives). The per-item dump of those predictions, `bench/baselines/anyjev_l2_2026-09-29.json` (run under mesa-anyjev's interpreter in the M1-A GPU window; summary `bench/baselines/anyjev_l2_2026-09-29.md`), reproduces both cells and all 14 per-fold cells exactly, and each of its 285 and 190 items pairs with one row of `bench/snapshots/2026-09-29.parquet` on the D1 identity with the same label and card, so mesa-clm's cells can be compared item by item, card by card (K2(a), M4). mesa-clm reports ECE, coverage at risk and AURC with tie-invariant versions of those metrics (DESIGN D33): tied confidences share their group's mean correctness, so a cell no longer depends on how a platform's sort orders ties. On tie-free probabilities such as AnyJev L2's the values are identical, so the numbers above stay directly comparable. The first mesa-clm cells are the M0 no-model controls in `bench/results/2026-09-29/baselines.json` (five `.baseline.lookup_prob` cells, snapshot `bench/snapshots/2026-09-29.parquet`): `lookup_acc` 0.772 (term.fits, n 285), 0.800 (ontology_fits, n 190), 0.796 (annotate, n 98), 0.550 (aspect, n 60), 0.680 (value_kind, n 278); leave-one-product-out 0.723 / 0.721 / 0.724 / 0.350 / 0.543; novel-key subsets of 159 / 99 / 39 / 28 / 80 items. `bench/results/2026-09-29/mde.json` (200 simulated datasets per grid point, B=2000, seed 0) puts the minimum detectable effect under rule R at AUROC 0.625 on term.fits (0.675 on its novel keys), 0.650 on ontology_fits (0.750 on novel keys, with four counting cards) and 0.700 on annotate, whose novel-key population has one counting card and therefore cannot pass rule R at any effect. The model cells of milestone M2 (X1, the tier cells, X2) are above, each named by its results file. ---8<--- https://idss-mesa.github.io/mesa-clm/concepts/provenance/ --- title: "Provenance" description: "The mesa_clm sidecar: a per-host DuckDB opened under a flock, its tables and fingerprints, the migrate, export, import and prune verbs, the direct/spool/none history backends and the lock set, source tags, and revert." type: Reference tags: - concepts - provenance - ducklake - history generated: by: "claude/fable-5.1" at: "2026-10-01T18:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: research resource: "https://github.com/idss-mesa/mesa-clm/blob/main/RESEARCH.md" title: "mesa-clm verified facts (RESEARCH.md)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Provenance Decision provenance is a sidecar owned by mesa-clm: schema `mesa_clm` in a DuckDB file per host at `~/.mesa/clm/provenance.duckdb`, **opened per operation under `flock(~/.mesa/clm/locks/provenance.lock)`**, with a run's rows buffered and committed in one transaction (DESIGN D11). The file, its `.wal`, the `locks/` directory and the lock file are owner-only (0600/0700) whatever the umask: the sidecar holds owners and curator labels, and the CLI's trust boundary is the account that owns it (DESIGN A2). Postgres is an optional dialect with the same CHECK constraints; a parity test compares both DDLs. It is never a column on mesa-ducklake's `avu_changes` (the 13-column Parquet layout is a hard contract) and never a table in schema `mesa`. Tables (`migrations/0001_mesa_clm.sql`, milestone M1): `runs` (owner, fingerprints, lock shas, `labels_sha256`, history backend and waiver, counters, `exported_at`, `terminal_at`), `decisions` (method, shape, level, calibration, probs, `raw_probs`, confidence, `clm_confidence`, `s_c`, `p_fit`, `anchor_index`, artifact version, the two keys, the fingerprints, context sha and token count, outcome and reason), `decision_options` (rank, `s_c`, `p_fit`, `action_sha256`), `decision_groups` (the ranking over a candidate group), `avu_links` (`write_status ∈ {proposed, accepted, dry_run, writing, written, spooled, reverted, mirror_failed, local_only}`, `accepted_by ∈ {policy, human, agent}`, spool batch and snapshot ids), `human_overrides` (`via ∈ {elicitation, cli, tool}` and what was offered), `labels` (identity `(task_key, target_sha256, option_key, label_source)`, product code, leak group, `fold_eligible`, `bench_card`), `audits`, `clm_calls`, `schema_versions`. DuckDB (1.5.5 and 2.0.0) rejects `UNIQUE NULLS NOT DISTINCT`, so nullable key columns are `NOT NULL DEFAULT ''` sentinels. A rank_fit question is one CLM Choice over a candidate group, so it is one `decisions` row (the answered candidate's `s_c` and `p_fit` on the row) with one `decision_options` row per candidate and one for the anchor, plus a `decision_groups` row with the OLS search log, the top `p_fit`, the group margin and whether the anchor won. Every CLM request of a run is a `clm_calls` row (latency, input tokens, status), and a run that fails is still committed with status `failed` so the post-mortem has its rows. Writes buffer the whole run and commit it in one transaction; the DuckDB store passes each table's rows as one JSON parameter per chunk (DuckDB 1.5.6 paid a failed `pandas` import per bound value otherwise, 2.0.0 no longer does; see [Architecture](../develop/architecture.md)). Decisions are never updated; only a link's write status and snapshot id, and a run's status, change. Corrections are new rows. Every AVU written by mesa-clm carries a mesa-ducklake `source` of the form `mesa-clm::` (`mesa-clm:apply:auto|human|agent`, `mesa-clm:revert:human`), so `get_history` shows what mesa-clm wrote without a join. ## History backends (milestone M3) `MESA_CLM_HISTORY__BACKEND=direct|spool|none|auto` (DESIGN D12): * **spool** (the plugin's only mode): a `mesa-spool/1` batch (Parquet with neon-ducklake's column set, a manifest with sha256, row count and sizes verified by read-back) under `//`; links become `spooled`. A recorder (`mesa-clm history record`, a timer on the catalog host) folds batches into one mesa-ducklake snapshot per project, de-duplicates by `sha1(path, a, v, u, op, ts)`, moves batches to `spool-done/` or `spool-quarantine/`, and `provenance reconcile` then fills `snapshot_id`. * **direct** (CLI only): takes the whole lock set through `fcntl.flock`, the same call neon-ducklake uses (`$MESA_HOME/locks/mesa-catalog.lock`, plus `/work/locks/mesa-tag.lock` when configured), refuses if a `/proc` scan finds another holder (falls back to spool), records one snapshot per (run, project) with a note listing the paths, never an empty `record_changes` (DESIGN D13), and closes. mesa-mcp's own DuckLake singleton never closes, which is why the plugin never writes through it. * **none**: only with `profile.allow_history_none` or `--allow-no-history`; the run records a `history_waiver_actor`. Upstream, the plan proposes the lock and the spool recorder to mesa-ducklake and the per-write client to mesa-mcp (plan §7.3); until then mesa-clm's recorder is interim with the identical format. ## Schema, export, import, prune (milestone M1) ```bash mesa-clm provenance migrate [--dsn DSN] # create or upgrade the mesa_clm schema mesa-clm provenance export --run-id R --out DIR # DIR//
.parquet + manifest.json mesa-clm provenance import DIR/ # commit an exported run into this sidecar mesa-clm provenance prune [--ttl-days N] [--dry-run] # delete terminal and long-abandoned runs' rows ``` `migrate` runs the DuckDB bootstrap (`CREATE … IF NOT EXISTS`) or applies the packaged Postgres migrations (`pg` extra); `mesa-clm doctor` reports the schema version without creating anything but the lock file (`sidecar schema`). `export` stages the run's rows through an in-memory DuckDB carrying the sidecar DDL (so the Parquet columns are the schema's types and the CHECKs re-validate every row), with the new `exported_at` on the copy's run row, writes one file per table read back and hashed, writes `manifest.json` last, verifies the whole directory as an importer would, and only then stamps the store's run row with the same `exported_at`: a failed export (an unwritable or non-directory `--out`, a full disk) leaves the run unmarked, so `prune` never takes it for exported. The export is owner-only (the run directory 0700, files 0600). `import` verifies every file's sha256 and row count against the manifest and never overwrites a run the store already holds. `prune` deletes local rows only for **terminal** runs (applied, exported, every `written` or `spooled` link with a snapshot id, no group escalated to a human) or abandoned ones past `MESA_CLM_PROVENANCE__TTL_DAYS` (DESIGN D29); `--dry-run` lists what would go and deletes nothing. Labels and audits are never pruned (DESIGN D30). ## Project export, retry, revert (milestone M3, planned) Once `apply` writes, the export lands in `/.mesa/clm/runs//` (never under `.mesa/ducklake/`) and is re-exported after reconcile (`export --push`). `history retry --run-id R` closes the crash window between an iRODS write and the link update. `mesa-clm revert --run-id R` deletes exactly the written triples with the stored unit, records `op=delete`, and marks links `reverted` (DESIGN D31). ---8<--- https://idss-mesa.github.io/mesa-clm/concepts/serving/ --- title: "Serving" description: "The mesa-clm serving stack of milestone M1: a batch-invariant vLLM pooling container serving Qwen3-8B behind a bearer guard and a patched clm-serve on loopback with keys, the carried CLM patches, fingerprints and the serving lock, what the doctor probes, the GPU budget, the in-process fallback encoder, and the learned artifacts of M4 (versions, CURRENT.json, learn fit and promote, publish and pull, the probe served without clm-serve)." type: Guide tags: - concepts - serving - vllm - clm - deploy generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: research resource: "https://github.com/idss-mesa/mesa-clm/blob/main/RESEARCH.md" title: "mesa-clm verified facts (RESEARCH.md)" author: "team:idss-mesa" - id: clm resource: "https://github.com/Contrastive-LM/CLM/tree/bb42c6c5bf914fd449bed2f6ca65be80602cb1f7" title: "Contrastive-LM/CLM at bb42c6c5 (server.py, embedder.py, heads.py)" author: "org:Contrastive-LM" status: draft stale_after: "2026-12-31T00:00:00Z" --- # Serving Milestone M1 (track A) brings the stack up on the serving host (sparky-1); the runbook is [Serving](../deploy/serving.md). The core never imports torch: it talks to two loopback HTTP services (DESIGN D16), and the serve-venv side lives under `serving/` and `deploy/` in the repository and never imports `mesa_clm`. `mesa-clm annotate --provider clm` uses both ([Install](../getting-started/install.md)). ## Topology | Process | Port | What | Unit | |---|---|---|---| | Encoder | `127.0.0.1:8090` (a socket unit) | `vllm/vllm-openai` v0.27.1 (pinned by digest) running `Qwen/Qwen3-8B` at the pinned revision with `--runner pooling --dtype bfloat16 --max-model-len 4096 --max-num-seqs 8 --no-enable-prefix-caching --gpu-memory-utilization 0.20 --kv-cache-memory-bytes 4831838208 --enforce-eager`, vLLM's batch-invariant kernels (`VLLM_BATCH_INVARIANT=1`, DESIGN A3), the bearer guard `--middleware vllm_auth.require_api_key` mounted read-only and `--disable-fastapi-docs` (DESIGN A4), usage reporting off, offline HF cache mounted read-only, `VLLM_API_KEY` from an env file; the container has **no network** and serves on the unix socket `~/.mesa/clm/run/encoder.sock`, which `mesa-clm-encoder-proxy.socket` exposes on 127.0.0.1:8090 through `mesa-clm-encoder-proxy` (`serving/encoder_proxy.py`: this account's connections only, to a socket of this account only, never through a symlink, at most 4,096 connections, sandboxed; DESIGN A5) | `mesa-clm-encoder.service` (user unit, `sg docker`), which requires the proxy socket (a port it cannot bind stops the encoder and clm-serve from starting) and starts the headroom timer | | clm-serve | `127.0.0.1:8700` | CLM `bb42c6c5` with patches 0001–0006 in its own venv (`~/.mesa/clm/serve/.venv`, uv CPython 3.11, torch CPU, **no vllm**), `--device cpu --action-cache 512MiB --max-tokens 4095 --no-download --no-ui`, the pinned head `CLM_v0.1-8B.pt` and promoted heads from `heads/served/` | `mesa-clm-serve.service` (`Requires=` the encoder) | Both bind loopback only and require bearer keys; the encoder answers nothing but `/health` without its key, unknown paths included (DESIGN A4: vLLM's own key check covers four path prefixes, and in M1-A `/pooling`, `/invocations`, `/score`, `/rerank`, `/detokenize`, `/tokenize`, `/metrics` and `/version` answered without a key, `bench/results/2026-09-29/serving_m1.json`). Under DESIGN A4 the container sat on the docker bridge, where its port, and seven sockets of the engine process that no key covers (the rendezvous store and six collective sockets), were reachable from any local account (`bench/results/2026-10-01/serving_m1b.json`, `encoder_netns.json`); since DESIGN A5 the container has no network at all, the API is a unix socket in an owner-only directory, and the key is the control on the one loopback port that reaches it (`serving_m1c.json`); members of the host's `docker` group are root-equivalent and outside that control (DESIGN A5, residual risks: `docker inspect` shows the encoder key). clm-serve's `/health` (which lists the head names) and its FastAPI schema pages answer without a key. Every client truncates its inputs to 4,095 tokens from the left (`max_len - 1`): vLLM 0.27.1 never completes an input of exactly 4,096 tokens (DESIGN A4). `mesa-clm serve keys --init` writes the raw 0600 key files `~/.mesa/clm/secrets/{clm,encoder}.key` (missing ones only; idempotent) and derives the units' env files (`clm.env` with `CLM_API_KEY`, `CLM_EMB_API_KEY` and `CLM_EMB_CACHE_SIZE`; `encoder.env` with `VLLM_API_KEY`); `--rotate` replaces both keys and prints the `systemctl --user restart mesa-clm-encoder.service mesa-clm-serve.service` command to run, since the running units keep the old keys until restarted. Neither ever prints a key; the core reads those two files by default (or `MESA_CLM_CLM__API_KEY_FILE` and `MESA_CLM_ENCODER__API_KEY_FILE` when set). `mesa-clm serve units` prints the rendered user units (the default rendering is committed under `deploy/systemd/`); installing and enabling them is a user action. The core refuses a non-loopback URL unless `MESA_CLM_CLM__ALLOW_REMOTE=1` **and** the scheme is https; DE VMs reach the stack through an `ssh -L` forward or a GPU VM of their own (0.1.0 annotate runs on the serving host). A timer runs the headroom check every 5 minutes (`MemAvailable` at least 8 GiB; the encoder needs 32 GiB to start); the spool recorder's timer arrives with the history backends in M3. Heads on CPU (DESIGN D17): the two heads are 18.9M parameters, and the encoder gets the whole 0.20 GPU share (about 24.3 GiB on the 121.7 GiB unified-memory GB10). Without a pin vLLM sized its KV cache at each start to fill the share (25,153 MiB by `nvidia-smi`, `serving_m1b.json`); DESIGN A5 pins it to the 4.5 GiB that 8 sequences of 4,096 tokens need, and the encoder now measures 19,609 MiB by `nvidia-smi` and 21.45 GiB by the `MemAvailable` difference (`bench/results/2026-10-01/serving_m1c.json`). The encoder is started at most three times an hour, manual starts included, so a recipe that fails after its model load does not reload it on the shared GPU every few minutes. A loopback port is shared by every account on the host and free while the units are down, so every mesa-clm client that sends a key (the serving pair's clients, the planner gateway client, the probe scripts) first checks that the socket holding the port belongs to this account and refuses another's, and the encoder's proxy relays only connections whose client socket is this account's (DESIGN A5). ## Patches carried None touches the vendored `schema.py` or `client.py`; their sha256 are pinned in `serving/serving.lock.json` (RESEARCH.md, issues and pull requests). | Patch | Upstream | Change | |---|---|---| | 0001 | PR #6 | `truncation_side: "left"` on every embedding request (vLLM ≥0.18 honours it; pooling truncates from the right by default and would drop the tail) | | 0002 | PR #11 | loopback default; refuse an exposed unkeyed server | | 0003 | PR #10 | `torch.load(..., weights_only=True)` | | 0004 | PR #23 | vector-arena slot leak on concurrent misses | | 0005 | local | Embedder reads `CLM_EMB_API_KEY` and `CLM_EMB_CACHE_SIZE` (the upstream host LRU is 200,000 vectors, about 3.3 GB) | | 0006 | local | constant-time API-key comparison | ## Fingerprints and the lock `encoder_fp = sha256{model, revision, dtype, pooling: "LAST", normalize, max_len, truncation_side: "left", prefix_caching, route[, batch_invariance]}[:12]`, `clm_model_fp`, `schema_sha256` and `serving_lock_sha` are stamped on every decision, feature row, artifact and bench cell and must match exactly (DESIGN D5): CLM heads are encoder-locked, the announced CLM-35B may change the encoder, prefix caching is off until golden-vector parity with it on has been recorded, and a vector's batch was found to move it (DESIGN A3: `batch_invariance` is `kernels` for the vLLM route, `encoder_fp` **c3b3d5e1a283**, and `serial` for the fallback at batch 1, b171b1ba4536; it is hashed only when not `none`). `serving/serving.lock.json` pins the CLM commit, the patches and their sha256, the head (repository, revision, file, size, sha256), the encoder recipe, the image digest and the container `recipe` (the whole `vllm serve` argument list, the non-secret environment, the bearer guard with its sha256 and read-only mount, the 4,095-token cap); it is self-verifying (`lock_sha` over its content, `encoder_fp` over its encoder block). The live provider stamps every record with the fingerprint of the lock the host runs (the installed copy `~/.mesa/clm/serving.lock.json`, else the checkout's) and refuses to start on a lock that does not verify, whose `schema_sha256` is not the vendored `schema.py`, or, when both exist, an installed copy that differs from the checkout's (re-run the bootstrap). Its pre-flight then checks the keys, the served models and the encoder's model, window and route (`owned_by`: `vllm` for the image, `mesa-clm-fallback` for the fallback) against the lock. An artifact or bench cell under another fingerprint is refused until the task is re-benched (K4). ## What the doctor checks `mesa-clm serve lock --check` (and the doctor's `serving lock` line, whenever `~/.mesa/clm` exists) compares the lock with the host: the patch files in the checkout, the installed lock copy, the serve clone (commit, applied patch series, `schema.py`), the serve venv's `clm.schema`, the head file (size and sha256), the installed bearer guard (owner-only, its sha256), the pinned image and the running encoder container (image, arguments, the locked environment values read through a `docker inspect` template that never asks for the key, the guard's read-only mount, the network mode and the socket directory; through `sg docker` when the session lacks the docker group). Absent pieces are skipped unless `--require-live`; present and different is a failure. The same container check runs before `features build` stores a vector and before an annotate run: the encoder's `/v1/models` reads the same for every container of the image, whatever its kernels or flags, so a container that departs from the lock is refused there too, and a check docker could not answer is reported as "not verified". `mesa-clm doctor --serve` (the light half automatic when both units are active) adds the live probes. Every URL first passes the clients' loopback rule and is printed redacted. Then: the **binds** of both ports (`ss -ltne`: loopback only, sockets of this account, and while the socket unit is active the encoder's port in the user manager's cgroup); the **encoder socket** (`~/.mesa/clm/run` holds nothing but a socket of this account, never a symlink); the **units** (what systemd loaded is the checkout's rendering, and the running proxy has the rendered command line and its sandbox); the **encoder network**: the container's own namespace read from `/proc//net`, which `ss` cannot see, where a listener on a non-loopback address next to an interface besides `lo` fails (DESIGN A5); the headroom timer active (a warning otherwise); `/health` 200 on both without a key; the **401 matrix**: without a key, every route vLLM registers on the encoder (17 besides `/health`) and an unknown path, and clm-serve's `/v1/models`, `/v1/systemone` and `/v1/rank`, must answer 401; the authenticated model lists (`qwen3-8b` with the lock's model, window and route on the encoder, `clm-latest` and `clm-raw` on clm-serve), so a key that differs from the unit's shows up as a 401; and one golden `/v1/systemone` question whose answer must cover every key with probabilities above 0 summing to 1. Under `--serve` (or serve mode without `--quick`) the slow probes follow: the **encoder goldens** (`encoder_golden_.npz`: each text one per request bitwise equal to the reference, the texts as one batch within 1 − 1e-6 of one by one), the **long-input probe** (a text over the window completes, truncated to 4,095 tokens, with cosine ≥ 0.9999 against the vector of its last 4,095 token ids), the **systemone parity** (the golden question recomputed on the local route, encoder plus the pinned head's numpy export, within 1e-4 of clm-serve for `clm-latest` and `clm-raw`) and the **upstream drift** probes, a warning only (the CLM README quickstart against issue #15 with the unrounded differences, the tides rank against the model card). `host`, `gpu_budget` and `permissions` report `MemAvailable`, any active CARC vLLM backend and group or other bits on mesa-clm's files, and `feature store` the store of the live `encoder_fp` (its format and the vector recipe it was built under against the live lock's). On the DESIGN A5 recipe the doctor is green with one warning, the quickstart urgency of DESIGN A3 (`bench/results/2026-10-01/doctor_serve_m1c.json`). ## Fallback encoder `serving/fallback_serve.py` loads `Qwen/Qwen3-8B` bf16 with transformers (left truncation, `last_hidden_state` at the last token, L2-normalised; one sequence per forward pass, so no padding), runs an in-process `Engine(embedder=CudaEncoder)` on :8700 and a second server exposing `/v1/embeddings`, `/tokenize`, `/v1/models` and `/health` on :8090 behind the same rule as the container (the key on every route but `/health`). `route: transformers` and `batch_invariance: serial` enter `encoder_fp`. Plan §6.6's sequential parity run (minimum cosine ≥0.999, mean ≥0.9999 against the vLLM route) failed at batch 8 in M1-A (min 0.998975, `bench/results/2026-09-29/fallback_parity.json`) and passes its two cosine gates at batch 1 on the A3/A4 recipe (min 0.999260, mean 0.999919, `bench/results/2026-10-01/fallback_parity.json`; the vectors are unchanged under A5); the third condition, probe agreement ≥99%, has nothing to measure before a probe is promoted (M4's run protocol), and the routes' `/v1/systemone` answers still differ by a few hundredths, so nothing may be shared between the routes yet. Artifacts stay keyed by `encoder_fp`, which differs between them. The server refuses `--batch` other than 1, which its fingerprint does not name. The fallback never runs alongside the vLLM container. If the GPU share is unavailable (the co-tenant plan for this host sums to 0.83), the headroom check fails, the doctor reports `gpu_budget`, both units stop and the tools return `decider_unavailable`; the bench is unaffected because features are cached. ## Learned artifacts (milestone M4, pre-run) The learned tiers reach production only as artifacts (`artifacts.py`; plan §5.5; DESIGN D15, D18): serving never fits, and nothing below has run on real labels yet ([Learning and bench](learning-and-bench.md), "Milestone M4"). **Layout.** `////v/{manifest.json, calibrators.json, probes/.json}` and `CURRENT.json` at `/`, `lock8` the first 8 hex characters of the framings lock sha. One bundle per `clm_model_fp`: a probe lives under its spec's model (`clm-latest` for `lowdim.v1`, `pair512.v1`, `choice.state.v1`; `clm-raw` for `pair4096.v1`, `joint4096@S1`, `joint4096@S1ns`, `choice.raw.v1`) and is served by the provider of that model, so an artifact's `(question_key, encoder_fp, clm_model_fp)` equals the record's (plan §4.6). A version is written to a temporary sibling directory and renamed into place, which fails onto an existing directory: an existing `v` is never rewritten, by `learn fit`, `publish` or `pull`; the next version is `max + 1`. Files 0600, directories 0700. The manifest (`mesa-clm/artifacts/1`) records the version, when it was written, the fingerprints, the full framings lock sha, the labels snapshot (both hashes), one entry per question key (task, framing, tier `calibrated` or `probe`, file, spec, fitter, hyper, the fitted calibrator, `n_train`, the `cite` and the cited cell's identity with the count of evaluated folds that chose this configuration; no metric is copied) and the sha256 of every file. The strict load re-hashes every listed file (a mismatch or an unlisted file is refused, strict or not: tampering is never relaxed), requires the manifest's fingerprints to be the layout's and the live lock's (K4) and its framings lock the layout's, and every entry's `question_key` to be its task's **active** framing's today (a rotated template or a changed active framing makes a key stale); `artifacts.strict: false` drops the mismatched or stale entries with a warning noted on the run, never silently. **`CURRENT.json`** (`mesa-clm/artifacts-current/1`) holds per task `{version, tier, question_key, promoted_at, cite}`. The provider's bundle is the union of the promoted entries over their versions (a promotion table may span versions; each record's `artifact_version` is its entry's), and only promoted entries are served: an unpromoted calibrator or probe of the same version is `TierUnavailable` at an explicit tier and `zero_shot` at `auto`. The live provider loads `CURRENT.json` under `////`; a promoted probe whose spec reads head quantities needs the pinned head's export (`heads/npz/.npz` with the lock's `source_sha256`, as the doctor loads it), and the live feature store, when it exists, is read as a vector cache and never written. A mismatch refuses (K4) unless `artifacts.strict` is false; promoted artifacts filed under another framings lock than the live one (another `` directory with a `CURRENT.json`, none under the live lock) are refused the same way, not served as `zero_shot`; without a `CURRENT.json` the provider serves `zero_shot`. How the probe path decides, and what its records carry, is on [Tiers and policy](tiers-and-policy.md). **`learn fit`** (serving host only) reads the registered snapshot through the M2 refusals and the feature store of the serving lock, applies the M4 registration (the framings lock, the fingerprints and the probe grid; `--tiers` defaults to the pinned `tiers.json`, `--x3` to the date's `x3.json`) and **refuses** on any deviation (exit 1, nothing written; the manifest of a written version records `registered: true`, the registration's identity and `tasks_fitted`, since a `--tasks` subset is allowed), and writes, per task, the full-data probe (the configuration the inner leave-one-card-out over all seven cards chooses, the fit on all items, the calibrator from the seven-card out-of-fold predictions; written to its spec's model's layout; no probe for a task whose out-of-fold pool is below 100 items or that has no selectable configuration) and the calibrated tier's calibrator on every item of the task's A1 arm (the active framing on `clm-latest`; not for the tasks `decider.ols_rank_tasks` names, which have no A1 arm under K1): one new version per served model that received an artifact, each entry citing `bench/results//x3.json#.probe.` or `tiers.json#.calibrated.` when that nested cell exists in the file (else `cite: null`, which promotion refuses: by construction the calibrated entries of the closed choices and of `term.fits` have no nested calibrated cell in the pinned `tiers.json`, and the verb prints one line per such entry saying so, not an error), and a copy of the manifest and probes exported to `bench/results//artifacts_v//`. It never touches `CURRENT.json`. **`learn promote`** applies the four promotion rules of [Tiers and policy](tiers-and-policy.md) and writes `CURRENT.json`, nothing when a rule fails. **`artifacts publish --to DIR`** copies `v` to `////v/` and verifies the copy against the manifest; **`artifacts pull --from DIR --version N`** copies a version into a temporary sibling, re-hashes every file (`--no-verify` skips it; the strict load refuses a tampered version later anyway) and places nothing on a mismatch. `CURRENT.json` is never pulled: promotion is a local decision. Local paths only in M4 (an ssh or iRODS mount counts); the iRODS transport of plan §5.5 is planned with M3's `irods_io`. **The doctor's `artifacts` check** (after `feature store`): `CURRENT.json` parses, each promoted version's manifest loads with the live lock's fingerprints and the code's framings lock and holds the promoted entry, and each promotion's cite names a results file under `policy.results_root` that holds the cell; promoted artifacts of other locks are a warning, no artifacts or nothing promoted is ok, and the check is skipped where no serving lock verifies. Nothing is re-hashed there (the provider does that when it loads); the artifacts tree joins the `permissions` targets. ---8<--- https://idss-mesa.github.io/mesa-clm/concepts/tiers-and-policy/ --- title: "Tiers and policy" description: "What level and calibration promise on a mesa-clm decision, the record invariants, how a tier is chosen and how the probe tier is served without clm-serve (M4), the rules that turn a decision into auto, proposed or abstain with a cited bench cell (the citation test as implemented, the audit demotion), promotion and the production audits, and what drives each step of a run today (ols_rank for term.fits under K1; the closed choices by rule under amendment A6, the aspect fallback by dtype and unit under A8)." type: Guide tags: - concepts - calibration - policy generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/plan-2026-09-28.md" title: "mesa-clm implementation plan (v1.1, 2026-09-28)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Tiers and policy Every stored decision carries two fields (DESIGN D6): * `level`: the tier that produced the probability. `zero_shot` (CLM's released head, or `clm-raw`), `calibrated` (Platt or temperature fitted on labels), `probe` (a local linear model over a feature spec built from the frozen 4096-d vectors and the pinned head's 512-d projections, served without clm-serve; M4), `head` (a fine-tuned CLM head served by clm-serve; M7), or `none` for anything that is not a CLM decision: a rule, a planner hint, the `ols_rank` fallback, a Claude second opinion, an unavailable decider. * `calibration`: how the probabilities were mapped: `uncalibrated`, `platt`, `temperature`, or `none`. `probs` is null exactly when calibration is `none`; nothing is ever one-hot. `LEVEL_RANK = {none: -1, zero_shot: 0, calibrated: 1, probe: 2, head: 2}`. The `_honest` check refuses a record that breaks the invariants: `zero_shot ⇒ uncalibrated`; `calibrated|probe|head ⇒ platt|temperature`; rank_fit records carry `anchor_index` and a `p_fit` per option; `confidence == max(probs)`; a level above `zero_shot` names an `artifact_version` whose `(question_key, encoder_fp, clm_model_fp)` match the record; an anchor win or a truncated context is an abstain and builds no AVU; `ols_rank` records have null probs and are never `auto`; every record carries `task_key, question_key, framing_id, encoder_fp, clm_model_fp, schema_sha256, state_sha256, target_sha256, context_sha256, context_tokens` (plan §4.6); from M4, `feature_spec` names the spec a record's numbers came from and is set exactly when the level is `probe` or `head` (a rule of the record validator, not of the DDL). The other invariants are CHECK constraints in the sidecar. ## Choosing a tier `decider.tier` (`MESA_CLM_DECIDER__TIER`, or `annotate --tier`) asks for a tier: `auto` (the best tier the provider can serve for each question key, in this order: `probe` when `CURRENT.json` promotes a probe for it, else `calibrated` when it promotes a servable calibrator, else `zero_shot`), an explicit `zero_shot`, `calibrated`, `probe` or `head` (refused before any request, exit 1, unless the provider can serve it for every task that `ols_rank` does not decide; `head` arrives with M7), or `ols_rank`: every candidate group (`term.fits`, `column.ontology_fits`) is decided by the degraded method, the OLS top-1 as `proposed` with no probabilities (DESIGN D28), while the closed choices (annotate, aspect, value kind) are still asked. The pipeline also falls back to `ols_rank` per group when a CLM answer is unavailable or the context was truncated, and the run is marked `degraded`. Under the closed-choice rules (below) a column's aspects never depend on CLM, so under `ols_rank` (or with clm-serve down) every column keeps its aspects and its column-to-ontology groups are `ols_rank` too. `decider.ols_rank_tasks` (`MESA_CLM_DECIDER__OLS_RANK_TASKS`, or `annotate --ols-rank-tasks`) names the candidate-group tasks that `ols_rank` decides whatever the tier. Its shipped default is `[term.fits]`: the pre-registered framing experiment found no qualifying framing for `term.fits` on either model, so its kill criterion K1 ("no state signal") makes that task's zero_shot and calibrated tiers audit-only, with `ols_rank` proposals until a probe is promoted (DESIGN A1; `bench/results/2026-10-03/x1.json`). Those groups get no probabilities and no specificity refinement (it ranks by `p_fit`; the group records that it was not asked), and the run is not marked `degraded` for them. An audit run asks CLM about `term.fits` anyway: `--ols-rank-tasks none` or `decider.ols_rank_tasks: []`; its `term.fits` decisions are `zero_shot`, never `auto`. `column.ontology_fits` is asked with its A1 framing (F9). **A promoted probe lifts a task out of that set (DESIGN A7, 2026-10-05).** A task `decider.ols_rank_tasks` names is decided by `ols_rank` *unless the provider resolves a promoted probe for the task's active framing* (`CURRENT.json` promotes one for that exact `question_key`) and the tier is `auto` or `probe`: then the probe decides it at level `probe` (the calibrator's kind, `feature_spec` and `artifact_version` on every record; proposed-only, since every `auto` threshold is null and no probe cell has a `threshold_cp`), the specificity refinement is asked again for those groups (a probe record carries `p_fit`; D24 amended back), the run lists the task under `probe_tasks` instead of `ols_rank_tasks` (which names only what `ols_rank` actually decided), and the run is not `degraded`. The shipped default `[term.fits]` is unchanged: a host without the promoted artifact proposes by `ols_rank` as before, and CLM's zero-shot `term.fits` answers stay audit-only (an explicit `--tier zero_shot` or `calibrated` keeps K1). `--tier ols_rank` still sends every candidate group to `ols_rank`, and `decider.ols_rank_fallback` is unchanged: the encoder down under a promoted probe gives `unavailable` records, which fall back to `ols_rank` per group and mark the run `degraded`. The registered M4 run promoted the version-1 `term.fits` probe (K2(b); `bench/results/2026-10-04/x3.json#neon_term_fits.probe.F7`) on the serving host, so there Q4–Q6 are decided by that probe; `column.ontology_fits` keeps its zero-shot F9 proposals (K2(c), nothing promoted) and the closed choices keep A6's rules. `decider.closed_choice` (`MESA_CLM_DECIDER__CLOSED_CHOICE`, or `annotate --closed-choice`) says who answers the closed choices. Its shipped default is `rules` (DESIGN A6): M2's registered tier run measured CLM's zero-shot answers below the majority class on all three (`bench/results/2026-10-03/tiers.json`: `column.annotate` 0.357 against 0.643, `column.aspect` 0.050 against 0.300, `avu.value_kind` 0.324 against 0.478), no pre-registered rule covers them, and the user chose deterministic fallbacks after seeing that, as a product-safety change that makes no scientific claim. `clm` keeps the M2 behaviour for audits and tests. What drives each step of a run with the shipped defaults: | Step | Driven by | Level of the deciding record | |---|---|---| | Q1 annotate | rule: every non-identifier column, whatever the planner says | `none` (`rule`) | | Q2 aspect | the planner's hint, then the top two of the M0 lookup over the packaged table frozen from the registered labels snapshot (the card held out), up to three; else the fallback (A8): a numeric or unit-bearing column `measurement` then `unit` or the prior's next non-`taxon` aspect, a string column the lookup's prior order without `taxon`, two kept (`unit` only for a column with a unit); no CLM answer read | `none` (`rule`) | | Q3 ontology | CLM, F9 (A1), asked for each chosen aspect but `unit`; top two in-play ontologies kept whatever the outcome (D28) | `zero_shot` | | Q4–Q6 terms | `ols_rank`, the OLS top-1 (K1, A1); on a host whose `CURRENT.json` promotes the `term.fits` probe, that probe (A7) | `none` (`ols_rank`), or `probe` | | Q4b specificity | not asked for an `ols_rank` group (A1); asked for a probe group (A7, D24) | — or `probe` | | Q7 value kind | the pre-rule, else "the term label" | `none` (`rule`) | | Q8 keep | the rule: dedup, cap 25 (D25) | — | Under `rules` CLM's answers to Q1, Q2 and Q7 are still requested in the same calls and stored, but **audit-only**: outcome `abstain`, reason `audit_only_a6`, whatever the verdict below says (the verdict is still computed, so a misconfigured threshold still fails the run). They never decide anything, never become a link or a label, and are never offered for review; `outcomes` counts them under `abstain` and `n_audit_only` counts them alone. When `annotate --provider clm` finds clm-serve not answering before it starts, tier `auto` runs `ols_rank` for the whole card only if `decider.ols_rank_fallback` is `true` (`MESA_CLM_DECIDER__OLS_RANK_FALLBACK`); otherwise, and always for an explicit CLM tier, the command refuses (exit 1), as the plugin tool will with `decider_unavailable`. A serving pair that answers but cannot be used as configured (a missing or rejected key, an unserved `clm.model`, an encoder that is not the serving lock's) is never degraded: the command stops (exit 2), and a request clm-serve refuses mid-run (401, 403, 404) fails the run instead of turning its groups into `ols_rank` proposals. Either way nothing is ever `auto` without a calibrated, cited tier. ### The probe tier served (milestone M4) A promoted probe is served by the provider of its spec's model (`clm-latest` for `lowdim.v1`, `pair512.v1` and `choice.state.v1`; `clm-raw` for `pair4096.v1`, `joint4096@S1`, `joint4096@S1ns` and `choice.raw.v1`), read from `CURRENT.json` under that model's artifacts directory ([Serving](serving.md)); only what the promotion table names is served, so an unpromoted calibrator or probe of the same version is `TierUnavailable` at an explicit `--tier` and `zero_shot` at `auto`, and without a `CURRENT.json` the provider serves `zero_shot`. On the probe path the state text (what `context_sha256` hashes) and the option texts (anchor last) go to the encoder through a read-only vector cache (an in-memory LRU of 2,048 texts, then the live feature store when one exists, never written), the pinned head's numpy export projects them when the spec reads head quantities, the spec features are built with the bench's own formulas (`learn.probe.rank_fit_features` / `choice_features`), and the probe's `predict` gives the calibrated probabilities. **clm-serve is never asked on this path**: the encoder call is reported to `clm_calls` as `/v1/embeddings` with the tokens charged, the encoder down gives `unavailable` records, and a 401, 403 or 404 or a port held by another account refuses the run, exactly clm-serve's rules. The joint specs embed the X1 control framing's per-candidate state rendered with the request's group size. The record: `level = probe`, `calibration` the probe calibrator's kind (`platt` at K = 2, `temperature` above), `raw_probs` the zero-shot softmax over the same vectors under the served model (what clm-serve would answer), `s_c` its log-ratios with the anchor at 0, `p_fit` the probe's calibrated Yes probability per option, `probs = softmax(logit(p_fit))` over the candidates with the anchor's logit at 0 (the mirror of the calibrated tier's `rank_fit`, so each candidate's odds against the anchor are exactly its `p_fit`; `p_fit` clipped at 1e-12 from 0 and 1); the anchor's own row is the features of a candidate whose vector is the anchor's, the probe analogue of Platt's `σ(b)`, and its `p_fit` never enters `probs`. `confidence = max(probs)`, `clm_confidence` is null (no CLM field exists), `feature_spec` the spec, `artifact_version` the probe's version and `artifact` its reference; the aspect mask and the token guard apply as for every tier. A closed choice's `probs` are the probe's row. ## Outcomes `outcome(record, thresholds, profile)` (`policy_defaults.yaml`, `mesa_clm.policy`) reads `p_fit` for rank_fit questions and `confidence` for choices: 0. a `rule` record keeps its rule outcome; an `ols_rank` record is `proposed` if its OLS rank is within `ols_rank_top` (default 1), else `abstain`; 1. **abstain** if probs are null, the answer index is negative, the context was truncated, the anchor won, or every option is masked; 2. **auto** only if the task's `auto` threshold is set, the level is at or above both the task's `min_level` and the profile's `min_level_write`, the calibration is one the profile allows, the statistic clears `auto`, the margin clears `margin`, and the cited cell is valid and fingerprint-matched (below); under a profile with `auto_requires_audit` (`prod`) it also needs a passing `audits` row for the record's `(task_key, artifact_version)`, read from the sidecar (M4): without one the verdict is **proposed** with reason `audit_required`, the one demotion reason a proposed row records, and a record without an `artifact_version` has no audit; a check that raises fails closed; 3. **proposed** if the statistic clears `propose`; 4. **abstain** otherwise. A group margin can only demote an auto. What a run stores is the verdict except where the pipeline settles a record itself: a moot record or a keep-rule drop is stored `rejected` (M1), and an audit-only closed-choice record `abstain` with `audit_only_a6` (DESIGN A6). `apply` is M3's; the pipeline records the audit blocker now. Profiles: `prod` (`min_level_write: calibrated`, `auto_calibrations: [platt, temperature]`, `auto_requires_audit: true`, `allow_history_none: false`) and `dev` (`min_level_write: zero_shot`, `allow_auto_write: false`, `allow_history_none: true`). The shipped defaults are proposed-only: `auto: null` everywhere, and `zero_shot` never auto-writes. ## Citations A numeric `auto` must cite `bench/results//.json#..` (DESIGN D8). From M4 the citation test is `policy.CellCitationValidator`, `Policy.load`'s default validator (`RefuseAllCitations` stays for callers that want it; `tests/unit/test_policy_citations.py` negates every field once). The cite resolves under `policy.results_root` (default the checkout root when `mesa_clm` runs from a `src/` checkout, else `~/.mesa/clm/results`), and the committed snapshots are the sha256 of every `/bench/snapshots/*.parquet`, hashed, never opened for their labels. The checks, in order, the first failure being the `cite_refused` reason: the cite is well-formed; the file exists and loads; the cell exists and is the record's task's; the cell's **tier equals the record's level** (the frozen "tier rank at or above the level" read at its most conservative: a probe cell's threshold is never applied to a calibrated record, whose `p_fit` came from another model, nor the reverse); leave-one-card-out; pre-registered; `selection: "nested"`; not exploratory; servable; at least 5 folds; no teacher row in a test fold; `masked` equal to the record's framing's masking; `labels_sha256` a committed snapshot's; at least 30 negatives (rank_fit) or 30 non-modal items (choice); `question_key`, `encoder_fp`, `clm_model_fp` and `schema_sha256` equal to the record's; the cell's fingerprint equal to the live one, `serving_lock_sha` included (the pipeline binds the provider's fingerprint; unbound, every cite is refused, since `serving_lock_sha` is not on a record); `fold_choices` agreeing with the served configuration in at least 5 evaluated folds (a calibrated cell: the fold's framing and model are the cell's; a probe cell: the fold's model is the record's and its spec the record's `feature_spec`; a skipped fold never agrees); `beats_lookup_novel` true; and `auto ≥ threshold_cp[risk]`, the smallest threshold whose pooled held-out items (at least 30) have a one-sided 95% Clopper–Pearson error bound within the risk (`None` refuses). `min_weight` has one source, the policy file, and the bench reads it too (DESIGN D9). The shipped defaults are still `auto: null` everywhere, so no cite is read in a default run; no M4 cell exists yet. ## Promotion and the audits (milestone M4) **Promotion** (`learn promote --version N --task T [--tier probe|calibrated]`) is the only way an artifact reaches production (serving never fits, DESIGN D15). It requires (i) the version entry's cite to name a cell of that task and tier that is leave-one-card-out, pre-registered, `selection: "nested"` and not exploratory, whose `question_key`, fingerprints and `labels_sha256` equal the manifest's; (ii) `k2.json`'s verdict for that tier to be `a` or `b` (the verdict is read only when the task's `best` tier is this tier: K2 judges the best servable tier only, so another tier has no verdict and is refused, there is no per-tier verdict, and `c` is refused; K2's (a) is demanding, since its card-sign condition is rule R's literal sign test against AnyJev L2, but (b) suffices here); (iii) when the task already serves a promoted artifact, the new cell to beat the current one on NLL under rule R and to be non-inferior on accuracy within 0.01, both on the two cells' pooled items joined by identity (a partial join is refused); (iv) no head before M7. Nothing is written when a rule fails; a pass writes `CURRENT.json`. `learn fit` never promotes. After the registered M4 run (DESIGN A7) one promotion exists: `learn promote --version 1 --task term.fits --tier probe` on the serving host (K2(b) for `term.fits`), which is what makes the `term.fits` groups probe-decided there (above); `column.ontology_fits` (K2(c)) and the closed choices promote nothing. **Audits** (plan §4.7, §8). `audit sample` draws from the actor's annotate runs on **non-bench** cards (a bench card, or a card with silver labels in the store, refuses the whole sample: a curator label on a pre-registered item is never minted here) every decision with a distribution (rules, planners and unavailable records excluded; `ols_rank` proposals included) in three strata of equal shares: `would_be_auto` (the policy statistic, `p_fit` of the answer for a rank_fit or `confidence` for a choice, at or above the task's cited cell's `threshold_cp[risk]` when the policy cites one, else at or above the top decile of the task's statistics in the pool), `proposed` and `anchor_abstain`; each stratum sorted by id and permuted with seed 0; the sample must span at least `--min-cards` cards (defaults 100 and 5). By default the pool is the decisions that carry an `artifact_version`, the promoted artifacts' decisions (on the serving host after DESIGN A7: the `term.fits` probe's), because only those can feed an `audits` row; the top-decile rule is computed per task over that pool alone, so an unpromoted tier's statistic (a zero-shot `p_fit` is σ(s_c), uncalibrated, and saturates near 1, 1.000 for every zero-shot `column.ontology_fits` decision of the first real review) sets no would-be-auto cut. `audit sample --all-tiers` adds the `zero_shot` and `ols_rank` decisions for the report-only precision, each task with its own decile. The file holds ids, task keys, strata, the statistic, the card names, the sampling mode (`artifact_only: true|false`) and the checklist, no card content; a file without the field reads as artifact-only. `audit review` needs a terminal, like `review` (its answers are curator labels, DESIGN A2). Before an item's candidates it shows what a curator needs to judge it, from the sidecar alone: the scope and target (the column name, the site code with its name, domain and habitat, or the dataset), the column's description, dtype and unit (the stored `state_json`'s `column` block), the aspect and ontology the group searched and the OLS queries it sent (the group's `search_json`; the unit-table lookup and a D24 refinement are named as such), for `column.ontology_fits` the aspect and that the candidates are ontologies of the registry, not terms, and the tier marked plainly: `probe/clm v1 (platt)` for a promoted artifact's decision, `zero_shot/clm (uncalibrated: p_fit is σ(s_c), saturates near 1)` for a zero-shot rank_fit, `ols_rank (degraded: OLS rank order, no p_fit)` for K1's fallback. The answers are unchanged: a rank_fit decision's answered CURIE gets `Yes` (correct) or `No` (incorrect), a correct closed choice gets its answer, an incorrect closed choice, an anchor answer or an abstain mints no label (no true class is named); every row is `curator` at weight 1.0, `fold_eligible=false`, `bench_card=false`, origin `audit:`. `audit record` writes one `audits` row per `(task_key, artifact_version)` among the reviewed would-be-auto decisions with `n`, `n_cards`, `n_errors`, `cp95_upper` (the one-sided 95% Clopper–Pearson bound on the error rate), the task's `risk` and `passed = n ≥ 50 ∧ n_cards ≥ 3 ∧ cp95_upper ≤ 2 × risk`, enforced by the row model itself; decisions that apply no artifact (`zero_shot`, `ols_rank`) get no row, since an audit is of an artifact version, and a sample drawn with `--all-tiers` says how many reviewed items had none (`reviewed_without_artifact`, the `report_only` line). The proposed-precision interval is printed per stratum, report-only. The production audit of plan §8 (at least five non-bench SRER cards under the promoted tiers) is part of the M4 run protocol and is **deferred, not run** (DESIGN A7's appended note: the curator cannot review by hand and D21 admits no other source of curator labels, so no `audits` row exists and every `auto` stays null); its first review pass (2026-10-05) found the two defects this paragraph now describes the fix of (the review showed no context; the default sample included unpromoted tiers). ---8<--- https://idss-mesa.github.io/mesa-clm/develop/architecture/ --- title: "Architecture" description: "The mesa-clm modules and which milestone delivers each, the annotate and apply phases, the MCP tools, and the boundaries with CLM, mesa-mcp, mesa-ducklake and neon-ducklake." type: Reference tags: - develop - architecture generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/plan-2026-09-28.md" title: "mesa-clm implementation plan (v1.1, 2026-09-28)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Architecture Two phases (DESIGN D10): `annotate` decides, proposes and records (no writes); `apply` writes the accepted AVUs to iRODS through mesa-mcp's shared helpers in atomic batches and records history through a backend (DESIGN D12). Decisions are written to the sidecar before any iRODS write, and `revert` undoes exactly what `apply` wrote (DESIGN D31). Layers: the CLM clients (`clm/http.py` for `/v1/systemone`, `/v1/rank`, `/v1/models`, `/health`; `clm/encoder.py` for `/v1/embeddings` with the token guard; `clm/headproj.py`, a numpy re-implementation of the head for local probes; `clm/fingerprint.py`, the D5 bundle and the serving lock; `clm/fake.py`, a deterministic hashed n-gram fake with a collapse knob) below the providers (`providers/base.py`: `DecisionRecord` with level, calibration and fingerprints and its `_honest` invariants; `providers/tiered.py`: the tiered provider that resolves a tier per `question_key`, the fake provider and the degraded `ols_rank` records; `providers/claude_provider.py`: the recorded second opinion; `providers/live.py`: the live provider, which from M4 loads the promoted artifacts of `CURRENT.json` and serves a promoted probe locally through the encoder, the pinned head's export and `learn/probe.py`'s spec formulas, never clm-serve) below the pipeline (`pipeline.py`, `Annotator.annotate`, Q1–Q8), the policy (`policy.py`, every outcome; from M4 the citation test `CellCitationValidator` over `policy.results_root` and the `audit_required` blocker), the artifacts (`artifacts.py`: versions, manifests, `CURRENT.json`, promotion, publish, pull), the audits (`audit.py`) and the sidecar (`provenance/`). `service.py` puts one provider, planner, OLS layer, policy and store behind the decider lock for the CLI and, from M3, the MCP tools. The planner is a separate role that only proposes. `mesa_mcp.ols` provides the OLS client and the canonical AVU transform; `mesa_ducklake.DuckLakeClient` records snapshots (M3); the vendored `clm/schema.py` is reached only through `render.py` (DESIGN D4). **The live provider** (`providers/live.py`). `clm_provider(cfg)` builds what `annotate --provider clm` decides with: a `TieredProvider` over `ClmHttpClient` (the `clm` section: loopback URL, key from the configured secrets source, by default `~/.mesa/clm/secrets/clm.key`) with `EncoderClient` (the `encoder` section) as the token guard's counter, stamped with the fingerprint of the serving lock the host runs (`~/.mesa/clm/serving.lock.json`, the copy the bootstrap installed, else the checkout's `serving/serving.lock.json`) under the served head `clm.model`. It refuses (K4) a lock that does not verify, a lock whose `schema_sha256` is not the vendored `schema.py`, and an installed lock that differs from the checkout's; only `clm-latest` and `clm-raw` are servable until promoted heads arrive (M7). `preflight(stack, cfg)` runs before any question: clm-serve's `/health` (unguarded on loopback, 5 s, no retry), which tells an unreachable clm-serve from one whose encoder is down, then with the keys clm-serve's model list and the encoder's, checked against the lock (`encoder_problems`: served name, `root`, `max_model_len`, `owned_by` against the route). The CLI turns an unanswered pre-flight into a refusal or, with `decider.ols_rank_fallback`, the degraded `ols_rank` method (DESIGN D28), and a key, model or encoder problem into exit 2. During the run a 401, 403 or 404 from `/v1/systemone` raises `DeciderRefused` (the run is recorded `failed`); transport errors, timeouts and 5xx fall back per group. **Sidecar writes** (`provenance/store.py`). A run's rows are buffered in a `RunBuffer` and committed in one transaction under the flock (DESIGN D11). DuckDB 1.5.6 (not 2.0.0; DESIGN A9) tries `import pandas` twice for every Python value it binds when pandas is not installed (the failed import is not cached; RESEARCH.md, "mesa-ducklake"), so a commit that binds one parameter per value spends most of its time in failed imports; multi-row `VALUES` statements bind just as many values. `bulk_insert` therefore binds one value per chunk of up to 1,000 rows, the rows as a JSON array unpacked in SQL by `from_json_strict` (a failed cast is an error, never a silent NULL): the data never enters the SQL text, which carries only checked column names and type names from a fixed set, and JSON and timestamp columns travel as text cast by the INSERT. A chunk JSON cannot carry exactly (a non-finite float, a value of another type) goes through `executemany` unchanged, so the rows and every error are what the per-row path produced (`tests/unit/test_provenance_bulk_insert.py` compares the two table by table). `set_link_status` updates chunks of ids with `link_id IN (…)` for the same reason. **Owner-only state** (`perms.py`). Whatever the process umask, everything mesa-clm creates for its state is owner-only: missing directories are created 0700 component by component and files 0600, every write tightens the sidecar's existing `locks/` directory, lock file, DuckDB file and `.wal` (DuckDB creates the last two with the umask's mode) while a read changes no existing mode, and the label store, the feature store and its npz export, run exports, `annotate --out` and the serving keys' parents follow the same rule. Directories the user made are never chmod-ed. **Curator answers** (`service.py`, `cli.py`; DESIGN A2). `record_human_pick(via=)` mints curator labels only for `via` `elicitation` (MRTR, M3) or `cli`, and the CLI passes `cli` only when stdin is an interactive terminal; without one `review --pick/--decline` and `feedback` pass `tool` (`agent_pick`, weight 0). A curator's answer settles a group (a different second answer raises `AlreadyAnswered`); an agent's leaves it pending and is replaced by a curator's, whose accepted link displaces the agent's. `check_answer` runs every check without writing, so `review` records a batch all or nothing. ## Modules by milestone | Milestone | Modules | |---|---| | M0 | `config.py`, `secrets.py`; `cards.py`, `states.py`, `registry.py`; `tasks.py`, `identity.py`; `policy_defaults.py` + `policy_defaults.yaml`; `ols.py`, `avu.py`, `ols_closure.py`; `planner/`; `provenance/labels.py`; `learn/labels.py`; `bench/_metrics.py` (vendored), `bench/{stats,results,baselines,mde,metrics}.py`, `bench/tasks/`; `health.py` (pins, versions, plugin API, policy, stores); `mcp_tools/` (entry-point stub); `cli.py` (`labels`, `bench`, `doctor`); `_vendor/clm/` | | M1 | `framings.py`, `render.py`, `framings.lock.json`; `vocab.py`; `perms.py`; `clm/{http,encoder,headproj,fingerprint,fake}.py`; `providers/{base,tiered,claude_provider,live}.py`; `pipeline.py`; `policy.py`; `provenance/{models,store,store_postgres,migrate,export}.py` and `migrations/0001_mesa_clm.sql`; `service.py`; `serving.py` (keys, units with the encoder's loopback socket proxy, the serving lock with its container recipe, its verification, the container's network namespace); `learn/features.py` (the feature store with float32 vectors and the lock's vector recipe, the X1/X2 manifest, the TextCache export) and `learn/offline.py` (offline scoring from cached vectors); `health.py` M1 checks (framings lock, schema sha256, sidecar schema, feature store, permissions, serving lock, host, `gpu_budget`, the serving reachability line and the serve-mode probes: the binds' owners, the encoder socket, the units against the rendering, the encoder network namespace, the headroom timer, the 401 matrix, goldens, long input, systemone parity, drift); `cli.py` M1 verbs (`framings`, `annotate`, `explain`, `review`, `feedback`, `provenance migrate\|export\|import\|prune`, `serve keys\|units\|lock`, `features build\|export-npz\|project\|stats`, `doctor --serve`); `serving/` (with the encoder's bearer guard `vllm_auth.py`, the route probe `vllm_routes.py` and the encoder's endpoint proxy `encoder_proxy.py`), `deploy/` (the serve-venv side, never importing `mesa_clm`); `net.py`'s port-owner check (keyed clients never send a key to another account's loopback socket); `scripts/` M1-A probes and records | | M2 | `bench/{framing,cells,x2,registered,run}.py` (X1, the tier cells, X2, the registration, the verbs), `learn/calibrate.py` (weighted Platt, temperature); after the registered run, amendment A1: `framings.ACTIVE` (F9 for `column.ontology_fits`) and `decider.ols_rank_tasks` (`term.fits` decided by `ols_rank`, K1); amendment A6: `closed_choice.py`, `aspect_lookup.json` and `decider.closed_choice` (the closed choices by rule, CLM's answers audit-only; the aspect lookup reuses `bench.baselines.Lookup` over a table frozen from the registered snapshot by `scripts/freeze_aspect_lookup.py`) | | M3 | `apply.py`, `revert.py`, `irods_io.py`, `history/`; the five `mesa_clm_*` tools in `mcp_tools/` | | M4 (pre-run) | `learn/linear.py` (the weighted fitters: L2 logistic regression, shrinkage LDA, ridge; the SVD reduction; the grids), `learn/probe.py` (the specs, `FeatureBuilder`, the nested inner selection, the OOF calibrator, `TeacherRows`, `ProbeArtifact`, `full_probe`), `learn/teacher.py` (the D19 ingest and the corpus pin), `learn/labels.py` teacher rows and `surviving_identities`; `bench/x3.py`, `bench/k2.py`, `bench/x4.py` (the producers), `bench/e2e.py` (the measurement half; the fold provider is planned, second wave), `bench/registered.py` `REGISTERED_M4` and `bench/run.py`'s M4 verbs; `artifacts.py` (versions, the manifest, `CURRENT.json`, `fit_version`, `promote`, `publish`, `pull`); `audit.py` (`audit sample\|review\|record`); `policy.py` `CellCitationValidator`, `StoreAuditCheck`, `default_results_root`; `providers/tiered.py`'s probe path (`ServedProbe`, `VectorCache`, the spec formulas' serving side) and `providers/live.py`'s artifact loading; `providers/base.py` `FEATURE_SPEC_LEVELS`; `provenance/models.py` `AuditRow`'s pass rule; `health.py`'s `artifacts` check; `config.py` `policy.results_root`; `cli.py` (`labels ingest-teacher`, `bench x3\|k2\|x4\|e2e`, `learn fit\|promote`, `artifacts publish\|pull`, `audit sample\|review\|record`); `scripts/record_ols_teacher.py` and `tests/fixtures/ols-teacher/`. The analysis plan is `design/m4-analysis-plan.md`; nothing here has run on real labels yet | | M6 | `adapters/neon.py` | | M7 | `learn/finetune.py`, `serving/finetune_preflight.py`, `serving/rescore_head.py` | Deferred to M8: DataCite questions, the chooser for mesa-mcp's own picker, dense retrieval over pre-embedded registry ontologies, `mesa_clm_rank`. ## Service (milestone M1) and tools (milestone M3) `service.py` holds the collaborators (provider, planner, OLS layer, policy, store) behind a decider lock (`DeciderBusy` when it stays taken) and owns the human-feedback path (`record_human_pick(via=)`), the candidate read-back for elicitations and the run-owner checks (DESIGN D21). The CLI verbs `annotate`, `explain`, `review` and `feedback` build on it now; the five tools build on it in M3: | Tool | Phase | What it does | |---|---|---| | `mesa_clm_annotate` | decide | Runs the pipeline on a card (`card_text` or an iRODS path checked by `assert_allowed`; local paths are CLI-only), records every decision and proposal, returns proposals with `p_fit`, level, calibration and the fingerprint; writes nothing. | | `mesa_clm_apply` | write | Writes accepted AVUs to an iRODS path (`dry_run=true` by default); `accept="proposed"` asks one elicitation per open group first with an ids-only state (DESIGN D26); anonymous callers are refused; history is spooled. | | `mesa_clm_explain` | read | A run's decisions, top options per group, links and pending groups; the owner's runs only. | | `mesa_clm_feedback` | curate | Pick, reject or decline on a group; recorded as `agent_pick` (weight 0) unless it came through an elicitation (DESIGN D21, A2). | | `mesa_clm_health` | ops | `doctor --quick`: locks, vendored shas, transport, stores, fingerprint. | Tools register through `register_tool(..., meta={"io.mesa/surface": "clm"})` with 2020-12 schemas; handlers run service calls in `asyncio.to_thread`. ## The neon-ducklake adapter (0.2.0, milestone M6) `mesa-clm neon curate --site S --neon-root R --mode replace|verify` reads the site's table cards, runs the pipeline with the neon profile (no `uo`/`gaz`/`ncbitaxon`, aspects through `NEON_ASPECT_MAP`) and writes `sites//curation/proposals/.rep1.json` (proposed ∪ auto) and `.rep2.json` (auto only) with neon's record fields, so an unchanged `neon-ducklake site validate` evaluates them. It works in an isolated CLM root by default, never writes iRODS or history, and refuses to overwrite non-CLM replicates without backing them up. ---8<--- https://idss-mesa.github.io/mesa-clm/develop/testing/ --- title: "Testing" description: "How to run the hermetic mesa-clm test suite, what the fake CLM transport, the recorded OLS fixtures and the offline doctor cover, the vendored-file and parity checks, the M1 tests, the M2 and M4 bench tests on synthetic labels only (and the plan-constants tests), the tests of amendment A1 after the registered run, and the opt-in live, engine, GPU, Postgres, end-to-end and neon tiers." type: Guide tags: - develop - testing generated: by: "claude/fable-5.1" at: "2026-10-04T23:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/plan-2026-09-28.md" title: "mesa-clm implementation plan (v1.1, 2026-09-28)" author: "team:idss-mesa" - id: m2-plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/m2-analysis-plan.md" title: "mesa-clm M2 analysis plan (pre-run)" author: "team:idss-mesa" - id: m4-plan resource: "https://github.com/idss-mesa/mesa-clm/blob/main/design/m4-analysis-plan.md" title: "mesa-clm M4 analysis plan (pre-run)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # Testing ```bash uv run pytest -q # hermetic: fake CLM transport, OLS fixtures, DuckDB under tmp_path uv run ruff check src tests scripts && uv run ruff format --check src tests scripts uv run mypy --strict src sha256sum -c vendored.sha256 # vendored files are byte-identical to upstream uv run mesa-clm framings --check # framing keys match framings.lock.json (CI runs it) uv run mesa-clm doctor --quick # pins, versions, plugin API, policy, stores (no hashing) uv run mesa-clm annotate --card tests/fixtures/cards/DP1.10003.001.brd_countdata.md --provider fake --out /tmp/run.json MESA_CLM_ENGINE=1 uv run pytest -q -m engine # the live stack: doctor --serve and a zero-shot annotate ``` Unit tests never touch the network or a GPU, and they never read the sibling mesa-anyjev checkout: parity data (`tests/fixtures/anyjev_parity.json`: states, `state_sha256`, task keys and AVUs) are committed fixtures. The seven neon-avu-eval cards, 1,884 recorded EMBL-EBI OLS4 responses (777 from mesa-anyjev, 15 for the unit table, 1,092 for the fixture closure recorded once with `scripts/record_ols_closure.py`), the 110 `get_term` responses of the teacher corpus's in-registry CURIEs under `tests/fixtures/ols-teacher/` (recorded once with `scripts/record_ols_teacher.py`, M4) and `results/validated.json` live under `tests/fixtures/`. Opt-in tiers are excluded by default (`addopts` in `pyproject.toml`) and selected with a marker and an environment variable: | Marker | Variable | Needs | |---|---|---| | `live` | `MESA_CLM_LIVE=1` | the real EMBL-EBI OLS API; only for recording fixtures and the closure check | | `engine` | `MESA_CLM_ENGINE=1` | the real encoder on :8090 and clm-serve on :8700 with keys from the configuration or the default `~/.mesa/clm/secrets/{clm,encoder}.key` and the local docker daemon (`tests/engine/test_doctor_live.py`: `doctor --serve` green and a zero-shot annotate of the non-bench SRER card `tests/fixtures/cards-srer/DP1.00004.001.BP_30min.md`, OLS replayed from `tests/fixtures/ols-srer/`, with the container check, the live fingerprint and `clm_calls` rows; `tests/engine/test_offline_parity.py`: offline scores from float32 vectors in a scratch feature store against `/v1/systemone` and `/v1/rank`, within plan §5.6's 1e-4) | | `gpu`, `serve` | `MESA_CLM_GPU=1` | reserved: no test carries these markers yet. The serve side's tests (the patched `create_app`, the fallback app with a stub encoder, the vLLM bearer guard and route probe) live in `serving/tests/` and run CPU-only, as the serving CI runs them, with the patched clone's source on the path: `MESA_CLM_CLM_SRC=~/.mesa/clm/serve/CLM/src uvx --with fastapi --with httpx --with numpy --with requests --with uvicorn --with pytest-asyncio pytest -q -p no:cacheprovider serving/tests` | | `requires_postgres` | `MESA_CLM_TEST_PG_DSN=postgresql://…` | a Postgres 16 (docker) for the sidecar dialect parity | | `e2e` | `MESA_CLM_E2E=1` | the real `mesa-mcp --transport stdio` and the `e2e` extra | | `neon` | `MESA_CLM_NEON_ROOT=` | a neon-ducklake root for the adapter | ## The fake CLM (milestone M1) `tests/fakes/clm_transport.py` is an `httpx.MockTransport` serving `/v1/systemone`, `/v1/rank`, `/v1/models`, `/health`, `/v1/embeddings` (texts or token-id lists) and `/tokenize`, the encoder side behind the same rule as the real bearer guard (DESIGN A4: every path but `/health` answers 401 without the key, unknown paths included) and with a settable `owned_by` and `root` so a test can impersonate the in-process fallback. It scores with the vendored `build_pairs` and `answer_from_logits` over hashed n-gram vectors and has a `collapse` knob to reproduce upstream #15; OLS is replayed from the fixture closure, and a replay miss names the missing query. Its request bodies are checked against the vendored CLM client's `question_to_dict` output, so the wire shape stays the upstream one. ## The doctor offline The doctor's host and serving checks go through `mesa_clm.health.ServeProbes` (the serving home, the httpx transport, the command runner for `ss`, `systemctl`, git and docker, and the meminfo file, the directories searched for encoder goldens). An autouse fixture in `tests/conftest.py` replaces `health.default_probes` with `ServeProbes.offline()`: no serving home, every connection refused, every command missing, no meminfo, no goldens. It also points `serving.DEFAULT_HOME` at an empty per-test path, so neither the installed serving lock nor the default key files under `~/.mesa/clm/secrets` reach a test (the `engine` tests keep the real home). The hermetic suite therefore never probes a port, runs `systemctl` or reads a key, whatever host it runs on; `tests/unit/test_health_serving.py` injects its own probes (the fake CLM transport, scripted `ss -ltne` and `systemctl` output, a meminfo file, a scratch run directory with a real unix socket) to drive every serving check, and `tests/engine/test_doctor_live.py` passes the real `ServeProbes()`. The same fixture points `net.PROC_NET` at an empty path, so the keyed clients' port-owner check reads no listener of the host; `tests/unit/test_listener_owner.py` drives it with fixture `/proc/net/tcp` and `tcp6` files (another account's socket on 8090 or 8700 is refused before the key is sent, the pre-flight exits 2, a refusal mid-run fails the run, a retry asks again, the planner gateway and the probe scripts' raw clients ask too) and the check of each new connection against real loopback listeners of the test's own account (the kernel's answer for the server end before and after the accept, over IPv4, IPv6 and dual stack; another account's answer substituted, a port taken after the `/proc` check gets no byte), and `serving/tests/test_encoder_proxy.py` the encoder's endpoint proxy (the kernel's answer for the owner of a real loopback client, another account's connection closed without reaching the encoder, a symlinked or foreign socket refused, a swap after the check, the relay with a late answer after a half-close and a one-way stream, the connection limit, the idle timeout, the throttled refusal logs, the backlog kept from the socket unit). `tests/unit/test_health_serving.py` also drives `serving units` with unit files under `tmp_path`, a scripted `systemctl --user show` and a fake `/proc/` (the old units, a stale unsandboxed proxy, a pending `daemon-reload`). ## The M2 bench tests (pre-run) The M2 analysis code was written, reviewed and tested **before** the first run on the snapshot's labels (`design/m2-analysis-plan.md` §14), so its tests run on synthetic labels only: generated cards and labels with planted signal, fake feature stores, a random head exported under the lock's sha, and a stand-in registration (`mesa_clm.bench.registered.REGISTERED` monkeypatched with the synthetic snapshot's hashes and counts). No test combines a silver label with a model output. What they read from the committed snapshot is label-free: its identity and state columns (the M2 CLI world and the timing script's requests), its label-content digest against the published one (`test_bench_registered`), and, in the manifest tests, rows whose every label-bearing column was replaced first. - `test_framing_x1`: weighted Platt; the 30/5 guards and the floor of 100 at its boundary; the shuffle's seeded derangements, its mean-AUROC rule R against brute force over all 200 draws and its null calibration (the drafts' comparator was biased); rules (1)–(5) one by one, rule (2)'s literal reading and the F7/F9 tie; nesting and K1 folds, a fold's choice blind to its held-out card; the registration (every run parameter is a deviation, any deviation writes every cell unregistered, registered labels must give the published counts, another framings lock or model fingerprint is a deviation, an item table that is not the configured grid is refused, a file without a configured task or arm is refused); the replay's checks (each edit of a verdict, its bootstrap settings, a cell's identity field, metrics, counts, novel-key block or diagnostics, an arm record's AUROC, shuffle verdict or NLL, `a1`, `fold_choices`, `skipped_folds`, a nested trace or the record's shape is refused) and the recompute from `x1_items.parquet` (an edited sensitivity or mean-context record, `p_loco`, item, label or shuffle draw is refused); the settings at every call site (each nested fold equals `decide` on an evidence built with the literal registered settings, the intervals and rule R the statistics' own at seed 0, the shuffle draws an independent rejection sampler and golden draws); the floor, the guards and the tokens per target inside a nested fold, and an inner fold that pools nothing; the mean-AUROC rule R's card eligibility and ties; the report-only controls' values; the learned candidate-only probe equal to scikit-learn fold by fold, blind to weights and held-out labels. - `test_cells`: arm scores equal the offline scorer's; zero shot is `σ(s_c)`; the calibrated tier recovers a planted Platt or temperature; a held-out card never sees its own labels; each fold is scored by its own fold's arm, exactly; a guarded fold without an arm is accounted for in both tiers; `beats_lookup_novel` fails when either of its two conditions fails (its rule R at seed 0); the label weights change the fit and the unweighted sensitivity ignores them; a tier run off the registration (labels, settings, a fingerprint, the framings lock, a subset of tiers) is unregistered; on cards interleaved in the bench's identity order every item's prediction, the NLL, the sensitivity block and the raw-score AUROC equal a computation keyed by identity (rank_fit, K = 2, K > 2); `n_saturated` and annotate's raw-score AUROC by value; X1's trace pointer kept in `fold_choices`, a colliding selector key refused. - `test_x2` (the replica equals scikit-learn, unweighted, training rows only, also on interleaved cards; the AnyJev join; another or no dump, no replica or another fingerprint unregistered; probabilities outside [0, 1] refused, a card without a prediction skipped), `test_calibrate`, `test_features_choice` (the closed-choice manifest; a request whose keys are not the closed options refused), `test_x1_latency_script` (every drawn target's requests asked once per model in the alternating order, the `first` and `new_text` flags, the sha256 draw order, a request that does not render the manifest refused, no key written, every answer discarded), `test_bench_registered` (the registration against the published files and the committed locks, by digest and count). - `test_bench_m2_cli`: `bench framing`, `--decide --from`, `bench run`, `bench x2` and `bench table` end to end on the synthetic world: the registered run and its replay, partial runs written unregistered, another or a missing snapshot refused (none written), the published counts and the scratch store checked, results never overwritten without `--force`, a tampered or foreign `x1.json` refused (an items file edited behind the replay too: `bench run` recomputes), `tiers.json`'s fold pointers resolving into `x1.json`, another AnyJev dump, a timing file about other labels or another serving lock and a store of another vector recipe refused, an unregistered run's own replay, X2's controls equal to what `bench baselines` publishes. - `test_m2_plan_constants`: parses the plan's Appendix B and §1.3 and fails when a value is not the one the code applies or a name in the "where" column does not exist. Before the commit the suite was also checked by mutation (in `/tmp` copies, never the working tree): every property above was shown to fail on code with the corresponding bug (for example rule (2)'s drafts' reading, a fixed arm in the nested cell, a calibrator fitted on the held-out card, either half of `beats_lookup_novel` removed, a single shuffle draw, an unchecked deviation). A second review round mutated the code again and found paths no test guarded (the realignment of fold-pooled predictions, the seeds and settings inside the nesting, the inner-fold floor, the timing run's request order, several refusals); each fix above came with a test that fails on the reverted code or the reviewers' mutant. ## After the registered run (DESIGN A1) The registered M2 run is committed (`bench/results/2026-10-03/`) and amendment A1 records its outcome; these tests hold the code to it: - `test_bench_registered` replays and recomputes the committed `x1.json` from its own files (no feature store, no label store) under the rotated framings lock, and checks that the registration keeps G1's lock, which is today's framings with every task's active framing F7. - `test_framings`: the active framings are A1's (F9 for `column.ontology_fits`, F7 elsewhere) and the rotation moved no `question_key`. - `test_k1_default` (the fake provider): under the shipped defaults every `term.fits` decision and proposal is `ols_rank` (no probabilities, proposed, never auto), no D24 refinement is asked and the groups that would have had one record it, the run is not `degraded`, Q3 is asked with F9 (its `question_key` and context hash), an audit run (`decider.ols_rank_tasks: []` or `--ols-rank-tasks none`) asks CLM about `term.fits` again, and the CLI prints and writes the tasks `ols_rank` decided. - `test_a6_closed_choice` (DESIGN A6, the fake provider): by default no CLM answer drives Q1, Q2 or Q7 (two runs whose closed-choice answers a test double pulls in opposite directions decide the same records, groups, links and proposals, which the same skews change under `closed_choice: clm`; two runs whose Q3 answers it pulls apart keep the same aspects); the rule records and the audit-only records (`abstain`, `audit_only_a6`) carry their markers and never make a link or a label; Q1 annotates every non-identifier column whatever the planner says; the packaged aspect lookup table rebuilds byte for byte from the registered snapshot, its sha256 is pinned and checked, and for every leave-one-card-out fold the lookup built from it is M0's (it reads the snapshot's 60 `column.aspect` labels, which M0's lookup cell already read); the hint and the lookup's top two are not capped, with M0's tie rule and the annotated card held out; the fallback (DESIGN A8) gives an unseen numeric or unit-bearing column `measurement` then `unit` or the prior's next non-`taxon` aspect and a string column the lookup's prior without `taxon`, keeps two, never offers `taxon` or `unit` to a column without a unit, records `rule: "a8"` and its reason in `search_json.a6.fallback`, leaves a planner hint of `taxon` and every seen column unchanged, needs no CLM answer (`ols_rank`, CLM down) and asks only the aspects with an ontology the plan puts in play, the planner's ontology still appended; a sidecar file without the schema; `clm` mode is the M2 behaviour; all seven fixture cards annotate in both modes under the shipped decider with at most three Q3 questions per column; explain, the pending groups, the offered candidates and feedback never offer an audit record; the CLI's `--closed-choice` and `MESA_CLM_DECIDER__CLOSED_CHOICE`. `scripts/freeze_aspect_lookup.py --check` compares the packaged table with one rebuilt from the snapshot. The pipeline helpers (`tests/fakes/pipeline.py` `config()`) are audit configurations (`decider.ols_rank_tasks: []`), so `test_pipeline_fake`, `test_service` and the review tests keep exercising CLM's `term.fits` path (specificity, the second opinion, runner-ups); `shipped_config()` gives the shipped defaults. Both keep the shipped `decider.closed_choice` (`rules`, DESIGN A6); `test_pipeline_fake` runs all seven cards under both modes, M2's assertions on Q1, Q2 and Q7 in `clm` mode. The synthetic M2 registrations stand in the checkout's framings lock. ## The M4 tests (pre-run) The M4 code (`design/m4-analysis-plan.md`) is tested before any M4 verb runs on the snapshot's labels, so **every M4 test is synthetic only**: generated labels with planted signal, fake feature sources and feature-store worlds with planted vectors, a probe fitted on random features under the fake stack's fingerprint, synthetic corpora and table cards, a stand-in registration with a small grid, a results root under `tmp_path` and a snapshot file that exists only to be hashed. No test combines a silver label with a model output, reads a committed results file as data, or touches the live feature store or the sidecar. `tests/fakes/m4.py` holds the shared fixtures (a synthetic probe artifact, planted items and `fold_choices`, a cell with every frozen field, a results file, a snapshot file to hash, a `k2.json` shaped like the producer's). - `test_linear`: each fitter reaches scikit-learn's optimum for the same objective (binary and multinomial logreg, shrinkage LDA against the `lsqr` form and the direct full-space formula when d > n, ridge against its normal equations); the SVD reduction is exact; weights are sample weights (an integer weight equals repeated rows); the training moments and the std floor; a constant column gets a zero coefficient; a fit at the iteration cap is used as it is and flagged; refusals; JSON round trip and determinism; the grids and constants are the declared ones. - `test_probe`: every spec matrix is its formula over the vectors `score_arm` reads and the builder's zero-shot logits equal the tier cells' scores; the nested selection recovers the planted spec in every fold, ties go to the first configuration, the criterion is the pooled OOF NLL; the weights change the fit; teacher rows never reach a test fold, are dropped for the held-out product (outer and inner) and change the fit; two runs are byte-identical; the 30/5 guards, the 40 floor, the inner floors and the 100 OOF calibrator floor skip folds with the stated reasons; an unfittable configuration is recorded and never chosen; `ProbeArtifact.predict` equals the bench's held-out probabilities; the full-data artifact. - `test_x3`, `test_k2`, `test_x4`: the four probe cells with every frozen field, the identity as the full-data choice and `fold_agreement_with_full`, the `@latest`/`@raw` restriction, `@full` fixed, a planted signal passing `beats_lookup_novel`, the registration (another grid, other labels, a task subset stamp every cell exploratory; a stand-in makes the run registered); K2's candidates and best tier, every condition with its numbers, the verdicts a, b and c, a closed choice c by construction, a tier that does not pool the full set, a missing AnyJev cell, the clm-raw clause, the files and the `bench table` rows; X4's three arms on identical folds, the on-arm fits changed by teacher rows that never reach a test fold, the silver-minus-Opus cells on the surviving subset, the decision record, the unpinned-input rule. - `test_teacher`: every drop reason on a synthetic corpus, the resolution to every card of the product that carries the column, Yes-only rows for both tasks, the aspect-allowed rule, the row flags, a `mesa-clm` model refused, the corpus pin, the rows read back as `TeacherRows`, the survivor rule; one label-free closure check of `tests/fixtures/ols-teacher` runs only when the real corpus is present. - `test_bench_m4_cli`: `bench x3|k2|x4|e2e`, `bench table` over the new files and `labels ingest-teacher` end to end on `test_bench_m2_cli`'s synthetic world plus a synthetic corpus: registered runs and refusals, `x3.json` required by K2, the pinned inputs refusing other bytes, `bench e2e` saying it is second-wave work, a teacher snapshot whose silver rows differ refused. - `test_artifacts`: the layout and manifest, the cited cell's identity equal to the bench cell's, immutability and owner-only modes, the strict load's refusals (tampering, another fingerprint, another framings lock, a stale question key), `CURRENT.json` and the bundle it gives the provider, promotion's four rules, `learn fit`'s writer with an injected fitter, the export copy, publish and pull with a tampered pull refused. - `test_probe_provider`: a promoted synthetic probe served over the fake stack (the fake encoder embeds, the fake head projects), honest records (`level='probe'`, the calibrator's kind, `feature_spec`, `artifact_version`, the artifact reference, `raw_probs` the zero-shot parity distribution, `s_c`, `probs` the mirror of the calibrated tier over `logit(p_fit)`), closed choices, an unpromoted probe `TierUnavailable`, K4 refusing another stack, the encoder down and a rejected key, the vector cache reading the store and never writing it, a pipeline run storing `feature_spec` rows. - `test_policy_citations`: a qualifying synthetic cell lets a passing record `auto`, and every field of the citation test, negated once, refuses it with a reason naming the field; the audit blocker (`audit_required`), `Policy.load`'s default validator and the pipeline's binding of the live fingerprint. - `test_audit`: sampling refuses a bench card, stratifies by outcome from a seeded draw spanning enough cards, the file holds ids only, a verdict mints curator labels outside every fold, the `audits` rows follow the pass rule (none for decisions that apply no artifact), and `audit sample|review|record` run end to end with the review at a terminal only, over fake-provider runs on synthetic non-bench copies of the fixture card. - `test_m4_plan_constants`: Appendix B of the M4 plan against the code (the K2 constants, the artifact and audit formats, the grids and floors, the citation test's numbers, the serving constants, the registration's pins: the filled teacher corpus hash, the neon-ducklake commit and the two snapshots' file hashes, recomputed from the committed bytes without opening a label). `test_health`, `test_policy`, `test_tiered_provider` and `test_cli` are adjusted for M4 (the doctor's `artifacts` check among the expected lines, `feature_spec` on the probe and head records the policy tests build and the audit blocker in their verdicts, the probe tier's `TierUnavailable` message). ## Key tests Vendored hashes; `test_anyjev_parity` (state shas, task keys and AVUs equal mesa-anyjev's); `test_policy_min_weight_counts` (class counts at the policy `min_weight` equal the published cells); `test_unit_lookup` (defect (a), including kilometer's UO id against a recorded `get_term`); `test_ols_fixture_closure` (0 missing queries); `test_cli` (the M0 verbs end to end on the fixtures: ingest, stats, snapshot, baselines and MDE stamped with the snapshot's `labels_sha256`, exit codes); `test_health` (every doctor check, each failure path forced, no secret in a report line); `test_mcp_tools` (the `clm` entry point loads under `load_plugins` and registers nothing). From M1: `test_framings` (framing keys and the lock), `test_honest` (at least 12 rejected records), `test_context_ends_with_target`, `test_delta_recovery` (`s_c` set-invariant), `test_pipeline_fake` (7 cards end to end, including `decider.tier: ols_rank` from the configuration), `test_ols_rank_proposes_never_auto`, `test_provenance_ddl`, `test_sidecar_flock`, `test_service`, `test_feedback_agent_pick` (the `via` rules and one answer per group: a curator's is final, an agent's is replaced by a curator's) and `test_run_owner_checks`; `test_cli_m1` (every M1 verb through `main()`: `framings --check` drift and `--update-lock`, `annotate` with the fake provider and with `--provider clm` over the fake transport, the unreachable-clm-serve rule and the `ols_rank_fallback` degradation, replay misses committed as `failed` runs, `explain` by prefix and owner, `review` and `feedback` with `sys.stdin.isatty` monkeypatched both ways (curator labels at a terminal, `agent_pick` and the stderr notice without one, DESIGN A2), pending-only and once-per-call answers validated before anything is recorded, the Postgres actor rule, `provenance migrate|export|import|prune --dry-run` and their error paths, `serve keys` never printing a key, `serve units`, `serve lock --check` without touching docker); `test_live_provider` (a lock with another schema or an installed lock unlike the checkout's refused, the keyed pre-flight refusing a missing or rejected key, an unserved model and an encoder of another route, root or window, a mid-run 401 failing the run, failed calls counted); `test_health_serving` (framings drift, the schema contract, sidecar schema versions on DuckDB and Postgres, the serving lock on a serving home, the host and GPU budget checks, permissions, the default key files, URLs refused by the loopback rule and printed redacted, and serve mode against the fake stack: loopback binds, the 401 matrix, health, model lists checked against the lock, the golden call, encoder goldens bitwise, the long-input probe, systemone parity with an exported head, the drift warning, missing and rejected keys, unreachable as fail or warn); `test_perms` (owner-only modes under umask 002 for the sidecar, the label store, run exports, the feature store and its npz, the serving keys' parents and `annotate --out`); `test_config` (YAML errors that never echo the file, the default key files); `test_features` and `test_offline` (the manifest rebuilt from the fixture cards in builder order, the store's refusals, the TextCache format, offline scores equal to the fake's `/v1/systemone`); `test_provenance_bulk_insert` (the JSON bulk insert writes exactly the rows the per-row path wrote on real fake runs, hostile strings stay data, failed casts raise, non-finite floats fall back to `executemany`, and seven fake runs commit within a loose time bound); the encoder's `tokenizer_json` from the configuration in `test_clm_encoder`. From M2: the bench tests and the A1 tests above. From M3: `test_apply_anonymous_rejected`, `test_apply_crash_retry`, `test_revert`, `test_history_spool_recorder` (two VMs, dedup, quarantine), `test_mcp_conformance`. From M4 (pre-run): the tests above (`test_linear`, `test_probe`, `test_x3`, `test_k2`, `test_x4`, `test_teacher`, `test_bench_m4_cli`, `test_artifacts`, `test_probe_provider`, `test_policy_citations`, `test_audit`, `test_m4_plan_constants`). Coverage must stay at or above 80% (`fail_under`). ---8<--- https://idss-mesa.github.io/mesa-clm/about/ai-agents/ --- title: "AI agents" description: "How AI agents should read this documentation bundle: llms.txt, the markdown mirror, trust markers, and where the decisions and facts live." type: Guide tags: - about - agents - okf generated: by: "claude/fable-5.1" at: "2026-09-29T00:00:00Z" sources: - id: design resource: "https://github.com/idss-mesa/mesa-clm/blob/main/DESIGN.md" title: "mesa-clm decisions register (DESIGN.md)" author: "team:idss-mesa" - id: research resource: "https://github.com/idss-mesa/mesa-clm/blob/main/RESEARCH.md" title: "mesa-clm verified facts (RESEARCH.md)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # AI agents Start from [`llms.txt`](../llms.txt) (an outline with descriptions) or [`llms-full.txt`](../llms-full.txt) (the whole corpus). Any page URL plus `index.md` returns that page's Markdown source. Pages without a `verified:` key are unverified (OKF v0.2 §5.3); `status: draft` pages need review; pages that describe a future milestone say so. For decisions and facts, prefer `DESIGN.md` (append-only register, pre-registered experiments and amendments) and `RESEARCH.md` (every fact with its source and `stale_after`) in the repository; for behaviour, run `mesa-clm` and read its provenance sidecar. Never cite a number that does not name its results JSON. ---8<--- https://idss-mesa.github.io/mesa-clm/about/license/ --- title: "License" description: "mesa-clm is MIT licensed by the Regents of the University of New Mexico; Contrastive LM, Qwen3-8B and the vendored AnyJev metrics are Apache-2.0; NEON data are CC BY 4.0." type: Policy tags: - about - license generated: by: "claude/fable-5.1" at: "2026-09-29T00:00:00Z" sources: - id: third-party resource: "https://github.com/idss-mesa/mesa-clm/blob/main/THIRD_PARTY.md" title: "mesa-clm third-party code and data (THIRD_PARTY.md)" author: "team:idss-mesa" status: draft stale_after: "2027-03-31T00:00:00Z" --- # License mesa-clm is released under the MIT License, Copyright (c) 2026 The Regents of the University of New Mexico. Contrastive LM (CLM) is Apache-2.0 software; its `schema.py` and `LICENSE` are vendored byte-identical, its `client.py` only as a test oracle, and four of its open pull requests are carried as serving patches, all with attribution in `THIRD_PARTY.md`. CLM reimplements the TypeSafe wire format and is not affiliated with TypeSafe AI or Jev. The CLM head and the Qwen/Qwen3-8B encoder are Apache-2.0 and are downloaded at serving bootstrap, never committed. AnyJev's `bench/metrics.py` (Apache-2.0) is vendored byte-identical; `anyjev` itself is not a dependency. NEON metadata in the fixtures and the bench are CC BY 4.0; OLS fixture terms are under the OBO Foundry ontologies' own licenses. See `THIRD_PARTY.md` for every third-party component and its hash. ---8<--- https://idss-mesa.github.io/mesa-clm/log/ # Directory Update Log ## 2026-10-23 * **Update**: for DESIGN amendment A9 (DuckDB 2.0; mesa-mcp and mesa-ducklake 0.2.0). [Install](getting-started/install.md): the doctor checks duckdb against the 2.x window. [Provenance](concepts/provenance.md) and [Architecture](develop/architecture.md): DuckDB 2.0.0 still rejects `UNIQUE NULLS NOT DISTINCT` and no longer probes `import pandas` per bound value; `bulk_insert` is kept. `llms.txt` and `llms-full.txt` regenerated. ## 2026-10-05 * **Update**: for DESIGN amendment A8 (the user's decision of 2026-10-05, amending A6's aspect fallback only, after A7's note that on seven non-bench SRER runs the prior-ordered fallback gave `taxon` to 25 numeric or unit-bearing columns). [Decision model](concepts/decision-model.md): the Q2 fallback row and a new A8 paragraph (a numeric column or a column with a unit gets `measurement` first, then `unit` when it has a unit, else the prior's next aspect that is neither `taxon` nor `other`; a string column keeps the prior order with `taxon` removed; two kept; `taxon` never from the fallback, still from the hint or the lookup; `search_json.a6.fallback` carries `rule: "a8"` and the reason `unit`, `numeric` or `string`; what moved on the fixture cards). [Tiers and policy](concepts/tiers-and-policy.md), [Quickstart](getting-started/quickstart.md), [Configuration](getting-started/configuration.md) and [Testing](develop/testing.md): the fallback's one-line descriptions and the A8 tests. `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Tiers and policy](concepts/tiers-and-policy.md) and [Learning and bench](concepts/learning-and-bench.md) record that the M4 production audit is deferred, not run (DESIGN A7's appended note: the curator cannot review by hand; no `audits` row; every `auto` null; the sample and the seven live runs kept); `llms-full.txt` regenerated. * **Update**: after the first real curator review pass of the production audit (the curator could not judge correctness from what `audit review` showed, and the sample held unpromoted decisions). [Tiers and policy](concepts/tiers-and-policy.md), the audits paragraph: `audit sample` draws by default only decisions that carry an `artifact_version` (the promoted artifacts' decisions, the only ones that can feed an `audits` row), the would-be-auto decile is computed per task over that pool alone (a zero-shot `p_fit` is σ(s_c) and saturates near 1, so the unpromoted `column.ontology_fits` decisions set no cut), `--all-tiers` restores the whole pool for the report-only precision, the file records `artifact_only`; `audit review` shows, before the candidates, the target (scope and column name, site or dataset), the column's description, dtype and unit, the aspect and ontology the group searched and its OLS queries, for `column.ontology_fits` that the candidates are ontologies, and the tier marked plainly; `audit record` says how many reviewed items had no artifact under `--all-tiers`. [Install](getting-started/install.md): the three `audit` rows of the verb table. `llms.txt` and `llms-full.txt` regenerated. * **Update**: for DESIGN amendment A7 (the consequences of the registered M4 run, `bench/results/2026-10-04/`): a task `decider.ols_rank_tasks` names is decided by `ols_rank` unless the provider resolves a promoted probe for its active framing, in which case the probe decides it at level `probe` (proposed-only, every `auto` null), D24's specificity refinement is asked again for those groups, the run names the task under `probe_tasks` and `ols_rank_tasks` lists only what `ols_rank` actually decided; `--tier ols_rank` still sends every candidate group to `ols_rank`, `decider.ols_rank_fallback` is unchanged, and a host without the promoted artifact keeps K1. [Tiers and policy](concepts/tiers-and-policy.md): the rule, the shipped-defaults table and the one promotion that exists (`learn promote --version 1 --task term.fits --tier probe`, K2(b)). [Decision model](concepts/decision-model.md): Q4–Q6 and Q4b under a promoted probe, `degraded` unchanged. [Install](getting-started/install.md): what `learn promote` changes for `term.fits` at tier `auto`. [Learning and bench](concepts/learning-and-bench.md) gains "M4 results (2026-10-04; DESIGN A7)" with the numbers A7 quotes from `x3.json`, `k2.json` and `x4.json` (`term.fits` K2(b), the probe promoted; `column.ontology_fits` K2(c), nothing promoted; the closed choices K2(c) by construction; X4 keeps no teacher labels; CLM's head adds signal; no numeric `auto`). `llms.txt` and `llms-full.txt` regenerated. ## 2026-10-04 * **Update**: after the M4 pre-run reviews, still before any result. [Learning and bench](concepts/learning-and-bench.md): the M4 registration's teacher pins are filled (the corpus hash at its neon-ducklake commit, the teacher and silver-minus-Opus snapshots with both hashes) from the label-free ingest run before the commit, whose real counts replace the placeholders (55 files, 389 items, 6 replicate proposal files read for their model and 0 implicit rows, the drops per reason, 5 ontology rows skipped outside the drops, 231 resolutions, 435 rows inserted); K2's card-sign condition is rule R's literal sign test without a margin, the margin-shifted per-card test named, rejected and reported only; a K2 candidate must itself be pre-registered and the full-set count fails closed; the closed choices' reasons for having no `beats_lookup_novel` are given one by one (`column.annotate` has an AUROC); the floors stated in advance are qualified with the published per-card counts; `learn fit` refuses a deviation from the registration instead of writing unregistered; the run protocol says the teacher step is done and disclosed. [Tiers and policy](concepts/tiers-and-policy.md): promotion reads K2's verdict only for the task's best tier (no per-tier verdict) and (b) suffices. [Serving](concepts/serving.md) and [Install](getting-started/install.md): `learn fit`'s pinned defaults, its refusal and the `cite: null` entries it names. [Testing](develop/testing.md): `test_m4_plan_constants` holds the filled pins. `llms.txt` and `llms-full.txt` regenerated. * **Update**: for milestone M4's pre-run commit (`design/m4-analysis-plan.md` and its code, written before any M4 result; no number is reported). [Learning and bench](concepts/learning-and-bench.md) gains "Milestone M4: the analysis plan (pre-run)": the inputs and the M4 registration (A1's framings lock, the X3 grid, the pinned `tiers.json` and `x2.json`, the K2 constants, X4's arms, the teacher pins filled after the label-free ingest; every producer applies it itself), the probe tier (the three readings, the seven specs and their models, the weighted fitters with the weighted-mean penalty convention, the grids in tie order, the nested inner selection on the pooled unweighted OOF NLL, the out-of-fold calibrator, the floors of 40 and 100 and what they imply in advance for the closed choices, the teacher rows), the four X3 cells and what can be cited, K2's three verdicts and the clm-raw clause, X4 and the teacher corpus as D19 is read (the 55 files and 389 accepted items, target resolution to every table card of the product, no implicit rows, the silver-minus-Opus rebuild, the arms and the decision), `bench e2e` marked planned (second wave), and the run protocol; the tier table and the X4 bullet are updated. [Tiers and policy](concepts/tiers-and-policy.md) documents the `feature_spec` invariant, tier `auto`'s resolution order and the `--tier probe` rule, the probe tier served (the vector cache, the head export, the spec formulas, clm-serve never asked, the record's fields and the anchor's row), the `audit_required` demotion under `auto_requires_audit`, the citation test as implemented (`CellCitationValidator`, `policy.results_root`, the checks in order, tier equal to level, the live fingerprint bound by the pipeline, fold agreement for probe cells), the four promotion rules and the audits (`audit sample|review|record`, the strata, the labels a verdict mints, the pass rule). [Serving](concepts/serving.md) gains "Learned artifacts": the layout, immutability, the manifest and the strict load, `CURRENT.json` and what the live provider serves, `learn fit`, `learn promote`, `artifacts publish|pull` (local paths; the iRODS transport planned) and the doctor's `artifacts` check; the [Serving runbook](deploy/serving.md) layout table gains the artifacts tree and moves head promotion to M7. [Install](getting-started/install.md) lists the new verbs (`labels ingest-teacher`, `bench x3|k2|x4`, `bench e2e` planned, `learn fit|promote`, `artifacts publish|pull`, `audit sample|review|record`, with the M2 bench verbs beside them), says they take `--provenance`/`--actor` after the verb, that the exit codes are unchanged, how an unservable explicit tier is refused, and adds the doctor's `artifacts` row; [Configuration](getting-started/configuration.md) documents `policy.results_root`, `artifacts.dir` and `artifacts.strict` as now read; [Architecture](develop/architecture.md) moves the M4 modules into an M4 (pre-run) row and names the artifact, audit and probe-path layers; [Testing](develop/testing.md) gains "The M4 tests (pre-run)" (the synthetic-only rule, `tests/fakes/m4.py`, every new test file, the 110 OLS teacher fixtures, `test_m4_plan_constants`) and replaces the planned M4 test names with the real ones; the home page status names M4's pre-run phase. `llms.txt` and `llms-full.txt` regenerated. * **Update**: the user confirmed amendment A6's two readings (a column name no other card carries goes to the fallback; the fallback's order and its cap of two). [Decision model](concepts/decision-model.md) and DESIGN A6 say so. * **Update**: for amendment A6 (the user's decision after M2's results: the closed choices answered by deterministic rules, CLM's answers to them kept for audit only; product safety, not a scientific claim). [Decision model](concepts/decision-model.md) gains "The closed choices by rule (amendment A6)": the three `tiers.json` cells it follows from, what decides Q1 (every non-identifier column, whatever the planner says), Q2 (the planner's hint and the top two of the M0 lookup over the table frozen from the registered snapshot, the card held out; else the first two aspects in the lookup's prior order, never `unit` without a unit, no CLM answer read) and Q7, how each is recorded, the two readings left for the user to confirm, and the audit-only marker (`abstain`, `audit_only_a6`); the step table says what drives each step. [Tiers and policy](concepts/tiers-and-policy.md) documents `decider.closed_choice`, what drives each step of a run with the shipped defaults, and where a stored outcome is not the verdict. [Learning and bench](concepts/learning-and-bench.md) notes, after the closed-choice cells, that A6 changes serving and no cell, and that its lookup is M0's over the frozen snapshot items. [Configuration](getting-started/configuration.md), [Install](getting-started/install.md) and [Quickstart](getting-started/quickstart.md) document `decider.closed_choice` and `annotate --closed-choice`, the summary line and the `closed_choice` and `n_audit_only` keys of the `--out` JSON; [Testing](develop/testing.md) and [Architecture](develop/architecture.md) the A6 tests, `closed_choice.py`, `aspect_lookup.json` and `scripts/freeze_aspect_lookup.py`; the home page status mentions A6. `llms.txt` and `llms-full.txt` regenerated. ## 2026-10-03 * **Update**: after the registered M2 run, [Learning and bench](concepts/learning-and-bench.md) gains "Milestone M2: the registered results (2026-10-03)": X1 per arm on both tasks (`term.fits` K1, no arm qualifying; `column.ontology_fits` F9 on `clm-latest`, chosen in 7 of 7 nested folds), the candidate-only probe, the nested `column.ontology_fits` cells and the `term.fits` audit cells, the closed choices against their majority rates, and X2, every number naming its file under `bench/results/2026-10-03/` (the independent recomputations agree with every number they recomputed). [Decision model](concepts/decision-model.md) describes amendment A1: Q3 asked with F9, `term.fits` groups decided by `ols_rank` by default with Q4b not asked for them, `--ols-rank-tasks none` for an audit run, and the lock rotation that moved no `question_key`. [Tiers and policy](concepts/tiers-and-policy.md), [Configuration](getting-started/configuration.md), [Install](getting-started/install.md) and [Quickstart](getting-started/quickstart.md) document `decider.ols_rank_tasks` and `annotate --ols-rank-tasks` (the quickstart's fake run reaches the `term.fits` steps and Q4b only with `--ols-rank-tasks none`); [Testing](develop/testing.md) and [Architecture](develop/architecture.md) the A1 tests and the M2 modules; the home page status moves to M2. `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Learning and bench](concepts/learning-and-bench.md) and [Testing](develop/testing.md) for the second pre-run review of the M2 analysis plan: the registration also pins the framings lock, each model's fingerprint and X2's dump, and a run is registered only on the grid it evaluated; `--decide --from` holds every reported number to its trace and the items file (and names what it cannot replay); `bench run` recomputes X1 first; the reported AUROC intervals are labelled as the 90% intervals they are; the timing run alternates which model it asks first. The testing page lists the new tests and the second mutation round. `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Learning and bench](concepts/learning-and-bench.md) gains "Milestone M2: the analysis plan (pre-run)" from `design/m2-analysis-plan.md`, committed before any M2 result: the registered snapshot and configuration (anything else written unregistered), how X1 decides (rule (1) with the within-card shuffle against the mean AUROC of 200 seeded derangements, K1, rule (2) read literally, rules (3) and (4), the report-only controls, the replay and recompute from the files), nested selection, the zero_shot and calibrated cells (`tiers.json`, the one producer of citable cells), X2, and the planned results files (none exist yet). [Testing](develop/testing.md) describes the M2 bench tests on synthetic labels only, what they read from the snapshot (identity and state columns, the label digest), `test_m2_plan_constants` and the mutation checks run before the commit. `llms.txt` and `llms-full.txt` regenerated. ## 2026-10-01 * **Update**: [Serving runbook](deploy/serving.md) and [Serving](concepts/serving.md) for the third pre-merge revision of DESIGN A5: every keyed client also checks each new connection, once it is made and before a byte is sent, by asking the kernel which account holds its server end (a port taken between the `/proc` check and the connect gets nothing), and the `docker` group is named as a residual risk (root-equivalent without an authorization plugin or user-namespace remapping: `docker inspect` shows the encoder key). [Testing](develop/testing.md) describes the new connection-check tests. `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Serving runbook](deploy/serving.md), [Serving](concepts/serving.md) and [Install](getting-started/install.md) for the second pre-merge revision of DESIGN A5: the encoder's proxy relays only this account's connections (the kernel names the client socket's owner) and runs sandboxed without namespaces, logs each kind of refusal at most once per 10 s, and the doctor's new `serving units` check compares the loaded units and the running proxy with the checkout's rendering; every keyed client named (the planner gateway client and the probe scripts check the port's owner too); `endpoint_checks.py --foreign` and the `serving_m1e` record; new troubleshooting rows (another account's connection, the AppArmor denial of a namespaced proxy, `serving units`). [Quickstart](getting-started/quickstart.md): no live **annotate** run uses a bench card before the M2 cells. `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Serving runbook](deploy/serving.md) and [Serving](concepts/serving.md) for the pre-merge revision of DESIGN A5: the encoder unit requires its socket unit (a port another account holds stops the encoder and clm-serve from starting), the endpoint proxy is `mesa-clm-encoder-proxy` (`serving/encoder_proxy.py`: never through a symlink, at most 4,096 connections, idle ones closed) instead of `systemd-socket-proxyd`, keyed clients refuse another account's socket, and the doctor checks the listeners' owners and the run directory; the start limit counts manual starts (`reset-failed` before a manual restart, also after `serve keys --rotate`); keys stay off command lines and screens (`grep -rlF -f` to look for a leak); new troubleshooting rows. [Install](getting-started/install.md) and [Testing](develop/testing.md) describe the new checks and tests; [Configuration](getting-started/configuration.md) says why `config.yaml.example` keeps the key settings commented out; `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Serving](concepts/serving.md) and the [Serving runbook](deploy/serving.md) for DESIGN A5: the encoder container has no network and serves on a unix socket that the new socket unit `mesa-clm-encoder-proxy.socket` exposes on 127.0.0.1:8090 through `systemd-socket-proxyd`; the KV cache is pinned to 4.5 GiB (the encoder now measures 19,609 MiB by `nvidia-smi`, 21.45 GiB of `MemAvailable`); the encoder unit starts the socket and the headroom timer and is started at most three times an hour; the doctor reads the container's network namespace, warns on a stopped headroom timer and checks the feature store; the runbook adds the six-unit install, `reset-failed`, the removal of the socket units, the draft of the CARC allocation request (not sent) and the fallback's refusal of a batched encoder. The fallback's parity run is described as passing its two cosine gates, with the probe gate still pending. * **Update**: [Learning and bench](concepts/learning-and-bench.md): the feature cache keeps float32 vectors (float16 only in the export), records the serving lock's vector recipe, and X1's cross-check passes from it (`bench/results/2026-10-01/x1_crosscheck.json`; from float16 it failed); bench-card membership is fixed and curator rows on bench cards are dropped before a target's label is chosen; X1's anchor-variant rule is withdrawn before G1. [Install](getting-started/install.md) adds the doctor's `feature store`, `encoder network` and `headroom timer` checks; [Testing](develop/testing.md) the engine tests on the non-bench SRER card and the offline-parity test, and the real command for the serve-side tests (`serving/tests`); `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Serving](concepts/serving.md) and the [Serving runbook](deploy/serving.md) for DESIGN A3 and A4: the encoder runs vLLM's batch-invariant kernels (`encoder_fp` c3b3d5e1a283; the fallback at batch 1, b171b1ba4536), answers nothing but `/health` without its key (the bearer guard `serving/vllm_auth.py`; the "open by design on loopback" wording for `/tokenize` and `/metrics` is withdrawn), clients truncate at 4,095 tokens, and the lock carries the container recipe; the fallback's parity run passes at batch 1. Both pages now describe the doctor's full serve-mode probes (the 401 matrix over every encoder route, encoder goldens, the long-input probe, the systemone parity against the local route, the drift warning) and the live provider's refusals and keyed pre-flight, and say the keys under `~/.mesa/clm/secrets` are read by default. * **Update**: [Install](getting-started/install.md) and [Quickstart](getting-started/quickstart.md) for DESIGN A2: curator labels need an interactive terminal; `review --pick/--decline` and `feedback` run without one are recorded as an agent's answers (`via=tool`, `agent_pick` at weight 0) with a notice on stderr; a curator's answer settles a group, an agent's stays pending; `feedback` takes group-id prefixes and needs `--option-key` for a pick; `labels import-anyjev --trust-curator`. Also the `features` verbs, the default key files, the keyed pre-flight, owner-only files, the export stamped last, YAML errors that never quote the file, and which verbs take `--provenance`/`--actor` after the verb (not `doctor`, `framings`, `serve`, `features`). The quickstart no longer says "four hashes" for artifacts: an artifact is checked against `encoder_fp` and `clm_model_fp` and its `question_key`, a bench cell against the whole fingerprint. * **Update**: [Configuration](getting-started/configuration.md) documents the default key files and how to turn them off; [Provenance](concepts/provenance.md) the owner-only sidecar and the export stamped only after a verified copy; [Decision model](concepts/decision-model.md) and [Tiers and policy](concepts/tiers-and-policy.md) the pending rule and the refusals that are never degraded. * **Update**: [Learning and bench](concepts/learning-and-bench.md) gains the feature cache (the store, the X1/X2 manifest in builder order, the TextCache export, offline scoring, the live build under c3b3d5e1a283 from `bench/results/2026-10-01/features_build.json`, the collapse diagnostic on the pipeline's rendering) and the AnyJev L2 per-item dump that reproduces the committed cells and pairs with the snapshot. * **Update**: [Architecture](develop/architecture.md) moves `learn/features.py` and `learn/offline.py` to the M1 row and adds `perms.py`, the live provider's pre-flight and refusals and the curator-answer rules; [Testing](develop/testing.md) adds the guarded fake encoder, the per-test serving home of the autouse fixture, `test_live_provider`, `test_perms` and the new doctor, config and CLI tests; `llms.txt` and `llms-full.txt` regenerated. ## 2026-09-29 * **Creation**: [Quickstart](getting-started/quickstart.md) for milestone M1: annotate a fixture card offline with `--provider fake` and the recorded OLS fixtures, read the summary, `explain`, `review` (interactive and `--pick`/`--decline`), `feedback`, `provenance export`, then the same on the serving host with `--provider clm` (key files, `doctor --serve`, `--tier zero_shot`, the fingerprint lines, the unreachable-clm-serve rule); added to the Getting started nav and index. * **Update**: [Install](getting-started/install.md) documents the M1 command line (`framings`, `annotate`, `explain`, `review`, `feedback`, `provenance migrate|export|import|prune`, `serve keys|units|lock`, `doctor --serve`), owners, the providers and the `decider.ols_rank_fallback` rule, the doctor's M1 checks and serve mode, and the key-file and `MESA_CLM_ENCODER__TOKENIZER_JSON` settings; [Configuration](getting-started/configuration.md) gains `decider.tier: ols_rank`, `decider.ols_rank_fallback` and `encoder.tokenizer_json`; the home page status moves to M1. * **Update**: [Serving runbook](deploy/serving.md) uses the `mesa-clm serve keys --init|--rotate`, `serve units` and `serve lock --check` verbs and describes what `doctor --serve` checks (and that the golden-vector and tail probes are M1 track A measurements, not doctor checks). * **Update**: [Architecture](develop/architecture.md) marks the M1 modules as existing (`providers/live.py`, the sidecar's JSON bulk insert, `service.py` behind the CLI) and keeps `learn/features.py` planned; [Testing](develop/testing.md) adds `framings --check` and the fake annotate to the commands, the offline doctor fixture, `test_cli_m1`, `test_health_serving`, `test_provenance_bulk_insert` and the `engine` test `tests/engine/test_doctor_live.py`. * **Update**: [Decision model](concepts/decision-model.md) (the pipeline as built: shared requests, Q3 masking, the second taxon, keep-rule drops, decision storage, pending groups, the aspect in the target identity), [Tiers and policy](concepts/tiers-and-policy.md) (choosing a tier, `ols_rank` and the fallback rule), [Provenance](concepts/provenance.md) (decision storage, `migrate`, `export`, `import`, `prune --dry-run`; project export, retry and revert stay M3) and [Serving](concepts/serving.md) (keys, units, the lock and what the doctor checks); `llms.txt` and `llms-full.txt` regenerated. * **Creation**: [Serving runbook](deploy/serving.md) for milestone M1 track A: bootstrap, keys (init and rotate), installing the systemd user units without enabling them, start and stop order, health checks, the GPU budget next to CARC, the fallback encoder, rollback and removal. * **Update**: [Learning and bench](concepts/learning-and-bench.md) notes that ECE, coverage-at-risk and AURC are tie-invariant (DESIGN D33) and that the baselines cell was regenerated. * **Update**: [Testing](develop/testing.md) counts the 1,884 OLS fixtures (five `get_term` responses recorded for the compound units `UNIT_TABLE` now names exactly: meter per second, watt per square meter, milligram per kilogram, square meter, cubic meter); `llms.txt` and `llms-full.txt` regenerated. * **Update**: [Install](getting-started/install.md) gains the M0 command line (`doctor`, `labels ingest-neon-eval|import-anyjev|snapshot|stats`, `bench baselines|mde`, the global options, exit codes and the bench sequence); [Testing](develop/testing.md) adds `mesa-clm doctor --quick`, the 1,879 OLS fixtures and `test_cli`, `test_health`, `test_mcp_tools`; [Architecture](develop/architecture.md) moves the modules that landed in M0 (`tasks`, `identity`, `policy_defaults`, `ols_closure`, `provenance/labels`, `bench/{stats,results}`, `bench/tasks`, `health`, the `mcp_tools` stub) into the M0 row; [Learning and bench](concepts/learning-and-bench.md) cites the reproduced lookup controls and the minimum detectable effect from `bench/results/2026-09-29/`. * **Creation**: the documentation bundle for milestone M0: [Getting started](getting-started/index.md) ([Install](getting-started/install.md), [Configuration](getting-started/configuration.md)), [Concepts](concepts/index.md) ([Decision model](concepts/decision-model.md), [Tiers and policy](concepts/tiers-and-policy.md), [Provenance](concepts/provenance.md), [Learning and bench](concepts/learning-and-bench.md), [Serving](concepts/serving.md)), [Develop](develop/index.md) ([Architecture](develop/architecture.md), [Testing](develop/testing.md)) and [About](about/index.md) ([AI agents](about/ai-agents.md), [License](about/license.md)). Pages describe the plan (`design/plan-2026-09-28.md`) and mark future-milestone features as planned.