# judge-semif

> SemIf provider for the judge hub (judge-semif::evaluate, judge-semif::models::list, judge-semif::cancel) — a frozen open LLM (Qwen3.5-4B GGUF) downloaded from the Hugging Face Hub and run in-process through llama.cpp, answering from the next-token logits of the option letters; picks Metal (macOS), Vulkan (Linux, when a driver is present) or the CPU automatically; no API key or external service.

| field | value |
|-------|-------|
| version | 0.2.4 |
| type | binary |
| license | Apache-2.0 |
| repo | https://github.com/iii-hq/workers |
| supported_targets | x86_64-apple-darwin, aarch64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu |
| author | iii |

## installation

```sh
iii trigger compose::add worker=judge-semif@0.2.4
```

## configuration

```yaml
- context_tokens: 16384
  max_request_bytes: 8388608
  max_timeout_ms: 300000
  model: qwen3.5-4b
  parallel_questions: 8
  threads: 8
```

## dependencies

- `configuration` @ `latest`

## readme

# judge-semif

[SemIf](https://github.com/TheoLeeCJ/SemIf) provider for the [`judge`](../judge/)
hub, running **inside the worker**: no API key, no Python, no llama-server.
SemIf reads runtime-defined decisions from a frozen open LLM: one forward pass,
a softmax over the next-token logits of the option letters `A`–`P`, no decoding.
Its published Qwen3.5-4B baseline agrees with Jev's own references on 0.845 of
TypeSafe's public subset (Jev 0.883). This worker runs the same prompt through
llama.cpp (`crates/llama-native`, the engine every local judge provider
shares) on the CPU, on Metal (macOS) or on Vulkan (Linux x86_64: AMD, NVIDIA
and Intel GPUs), picked automatically at start.

## Hardware selection

- **macOS**: Metal is linked in; Apple Silicon GPUs run the model.
- **Linux x86_64**: llama.cpp's backends are modules loaded at start from the
  binary's directory (`GGML_BACKEND_DL`). The Vulkan module loads wherever a
  Vulkan loader and driver exist (`libvulkan.so.1`); without them it is
  skipped and the CPU runs the model, so the same package works on GPU
  desktops, servers and containers. The CPU module is picked for the host
  (AVX2, AVX-512, AMX variants). The package ships `libllama`, `libggml`,
  `libggml-base`, the CPU variants and the Vulkan module (≈71 MB) beside the
  binary, which finds them through its `$ORIGIN` runpath.
- **Linux aarch64**: CPU, statically linked.

`gpu_layers: 0` keeps the model on the CPU even when a GPU is present. The
chosen device is logged at start as `selected inference device`.

## Install

```bash
iii trigger compose::add worker=judge-semif
```

The functions register at start; the model loads on demand. While SemIf is
the judge hub's **default provider** (`provider: semif` under **Settings →
Workers → judge**) it loads at once and stays loaded. Otherwise the first call
that names `"provider": "semif"` (or comes from a session that picked it)
loads it, and it is released (VRAM included) after 10 minutes without calls.
A call that cannot wait for the load answers `deadline` while the load goes on
for the next one. The first load downloads the pinned GGUF
(`qwen3.5-4b`: `bartowski/Qwen_Qwen3.5-4B-GGUF` Q4_K_M, 3.0 GB) into the
hf-hub cache (`$HF_HOME`, default `~/.cache/huggingface`). To keep it loaded
while another provider is the default, turn on **Keep every local provider
loaded** (`preload_all`) in the judge settings. A hub build that does not
expose `judge::configuration-id` keeps the model loaded from the start.
Air-gapped installs set `III_SEMIF_GGUF` to a local GGUF file.

Make it the hub's default, then call the hub:

```bash
iii trigger judge::evaluate --timeout-ms 65000 --json '{
  "timeout_ms": 60000, "provider": "semif",
  "evaluations": [{
    "id": "ticket-4411",
    "state": {"subject": "Duplicate charge on invoice #4411",
              "body": "We were billed twice for March. Refund the duplicate today or we cancel."},
    "questions": {
      "department": {"type": "choice", "criteria": {"billing": "invoices, payments, refunds", "technical": "bugs, outages"}},
      "urgency": {"type": "score", "criteria": ["not urgent", "soon", "critical deadline or blocking issue"]},
      "churn_risk": {"type": "noul", "instructions": "Does the user threaten to cancel or leave?"}
    }
  }]
}'
```

## How questions map to SemIf

Each question becomes one SemIf decision: `{"evidence": state, "criterion":
instructions, "options": [...]}` in SemIf's frozen system prompt and Qwen chat
template (thinking disabled), tokenized by the GGUF vocabulary. Token ids match
SemIf's reference tokenizer (`tests/prompt.rs`), and on the CPU the option
probabilities match SemIf's own llama.cpp backend to four decimals.

| Contract | SemIf options | Answer |
|---|---|---|
| `noul` | A = `criteria.true` (or "Yes, the statement holds."), B = `criteria.false` | `noul` = P(A) |
| `choice` | one per criterion, `key: description` | argmax, probabilities, confidence |
| `score` | `level i: <level>` | Σ i·p_i, probabilities, confidence, legend |

`confidence` is TypeSafe's (`judge_contract::confidence`, shared by the local
providers): `(n·p_max − 1) / (n − 1)` for a choice, 1 − the expected distance
from the likeliest level over the levels' mean distance from the middle for a
score. SemIf's probabilities are conditional on the offered options and
uncalibrated. At most
16 options per question. A prompt longer than `context_tokens` answers
`payload_too_large`: SemIf never truncates evidence.

Every question of one evaluation shares its state, and SemIf puts the evidence
first. The worker prefills the prompts' longest common token run once,
snapshots it, restores it into up to `parallel_questions` sequences and decodes
their suffixes together in one batch (SemIf's parallel suffixes). The snapshot
stays in the model's device memory (VRAM on a GPU; about 270 MB for a
6.7k-token prefix, held until the next evaluation replaces it). The prefix is
found on tokens, not re-tokenized text: a state ending in `{}` merges with the
following `}` two tokens back, which SemIf's own `_state_prefix` rejects.
`usage.input_tokens` counts the decoded tokens (the shared prefix once).

## Speed (Qwen3.5-4B Q4_K_M, i9-14900K, RX 6900 XT)

Per request, 16 questions about one state; `parallel_questions` 8 unless noted:

| | incident (541-token state) | directory block (4.6k-token state, 64 functions) |
|---|---|---|
| CPU, 8 threads | 3.8 s (6.9 s with parallel 1) | 6.6 s |
| Vulkan | 0.79 s (1.18 s with parallel 1) | 3.4 s |

Before the token-level prefix, the directory block decoded every question in
full: 75k tokens and 35.8 s on Vulkan, against 6k tokens and 3.4 s now.
Parallel suffixes pay off on short states; long states are dominated by the
one-time prefill. On the same card llama.cpp's ROCm backend measured within
10% of Vulkan either way, so the worker ships Vulkan alone. A single short
decision takes 67–140 ms on the GPU and 1.1–1.4 s on the CPU.

These figures predate llama.cpp b11379 (`crates/llama-native`). Against the
previous build, b11379 takes 0.85 of the time on the CPU (a 1.6k-token request
of 9 questions and a 7.6k-token one of 10, 9 runs each) and the same time on
Vulkan (within 2%).

GPU, reuse and batching change probabilities by up to 0.02 against fresh CPU
scoring, as SemIf documents for its own fast paths.

## Configuration

**Settings → Workers → judge-semif**:

| Field | Default | Applied |
|---|---|---|
| `model` | `qwen3.5-4b` | next start |
| `threads` | min(8, logical cores) | next start |
| `gpu_layers` | all layers when a GPU backend and device exist | next start (`0` = CPU) |
| `context_tokens` | 16384 | next start |
| `parallel_questions` | 8 | next start (`1` = one question per decode) |
| `max_request_bytes` | 8388608 | new calls |
| `max_timeout_ms` | 300000 | new calls |

## Building

llama.cpp b11379 is compiled from source through `crates/llama-native`: its
`build.rs` downloads GitHub's source archive (checked against a pinned
sha256), builds it with cmake and compiles a small C shim against it, with no
bindgen. It needs `curl`, `tar`, `patch`, `cmake` and a C++17 compiler; an
offline build points `III_LLAMA_CPP_TARBALL` at a copy of the archive, checked
the same way. Linux x86_64 builds also need the Vulkan loader headers, the
SPIR-V headers and `glslc` (Ubuntu: `libvulkan-dev spirv-headers glslc`) to
compile the Vulkan module (only the module links `libvulkan`, the binary does
not). The build copies the modules and libraries beside the binary, so
`target/release` has the published layout; the release catalog ships them as
the artifact's `companions`. Windows is not published yet.

For the full API, read the hub's [reference](../judge/reference.md).

## api reference

```json
{
  "functions": [
    {
      "description": "Signal cancellation of an active evaluation owned by the calling worker; the current batch finishes, later batches are skipped. Requires the same worker replica as the original call.",
      "metadata": {
        "internal": true
      },
      "name": "judge-semif::cancel",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "request_id": {
            "maxLength": 128,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "request_id"
        ],
        "title": "CancelRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ErrorCode": {
            "oneOf": [
              {
                "enum": [
                  "invalid_request",
                  "missing_key",
                  "payload_too_large",
                  "deadline",
                  "attempt_timeout",
                  "cancelled",
                  "http",
                  "transport",
                  "invalid_response"
                ],
                "type": "string"
              },
              {
                "description": "The selected `judge-<provider>` worker is not registered on the engine, or (a local provider) its model failed to load.",
                "enum": [
                  "provider_unavailable"
                ],
                "type": "string"
              }
            ]
          }
        },
        "oneOf": [
          {
            "additionalProperties": false,
            "properties": {
              "cancelled": {
                "type": "boolean"
              },
              "status": {
                "enum": [
                  "ok"
                ],
                "type": "string"
              }
            },
            "required": [
              "cancelled",
              "status"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "code": {
                "$ref": "#/definitions/ErrorCode"
              },
              "status": {
                "enum": [
                  "error"
                ],
                "type": "string"
              }
            },
            "required": [
              "code",
              "status"
            ],
            "type": "object"
          }
        ],
        "title": "CancelResponse"
      }
    },
    {
      "description": "Returns this worker instance's effective configuration entry ID, without its value.",
      "metadata": {
        "internal": true
      },
      "name": "judge-semif::configuration-id",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Empty user request. Ignore transport metadata such as `_caller_worker_id`, which the engine adds to routed calls; no payload field selects the entry.",
        "title": "ConfigurationIdentityRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Only the entry ID is exposed; configuration values and secrets stay in the service.",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "ConfigurationIdentityResponse",
        "type": "object"
      }
    },
    {
      "description": "Evaluate Noul, Choice and Score questions against arbitrary JSON state with the SemIf model (a frozen GGUF LLM read at the option letters) running inside this worker. Results are atomic; usage counts decoded prompt tokens. No credentials or endpoints are accepted in the request.",
      "metadata": {
        "internal": true
      },
      "name": "judge-semif::evaluate",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "Content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "items": true,
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "description": "Structured provider descriptions; top-level numbers/bools are not descriptions."
          },
          "Evaluation": {
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "questions": {
                "additionalProperties": {
                  "$ref": "#/definitions/Question"
                },
                "minProperties": 1,
                "type": "object"
              },
              "state": {
                "$ref": "#/definitions/ScoreLevel"
              }
            },
            "required": [
              "id",
              "questions",
              "state"
            ],
            "type": "object"
          },
          "Question": {
            "oneOf": [
              {
                "additionalProperties": false,
                "properties": {
                  "criteria": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "properties": {
                          "false": {
                            "$ref": "#/definitions/Content"
                          },
                          "true": {
                            "$ref": "#/definitions/Content"
                          }
                        },
                        "type": "object"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "instructions": {
                    "allOf": [
                      {
                        "$ref": "#/definitions/Content"
                      }
                    ],
                    "default": null
                  },
                  "type": {
                    "enum": [
                      "noul"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "type": "object"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "criteria": {
                    "additionalProperties": {
                      "$ref": "#/definitions/Content"
                    },
                    "maxProperties": 255,
                    "minProperties": 1,
                    "type": "object"
                  },
                  "instructions": {
                    "allOf": [
                      {
                        "$ref": "#/definitions/Content"
                      }
                    ],
                    "default": null
                  },
                  "type": {
                    "enum": [
                      "choice"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "criteria",
                  "type"
                ],
                "type": "object"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "criteria": {
                    "items": {
                      "$ref": "#/definitions/ScoreLevel"
                    },
                    "maxItems": 10,
                    "minItems": 2,
                    "type": "array"
                  },
                  "instructions": {
                    "allOf": [
                      {
                        "$ref": "#/definitions/Content"
                      }
                    ],
                    "default": null
                  },
                  "type": {
                    "enum": [
                      "score"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "criteria",
                  "type"
                ],
                "type": "object"
              }
            ]
          },
          "RequestOptions": {
            "additionalProperties": false,
            "properties": {
              "attempt_timeout_ms": {
                "description": "Bounds each network attempt separately from the whole-call deadline.",
                "format": "uint64",
                "minimum": 1,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "ScoreLevel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "items": true,
                "type": "array"
              }
            ],
            "description": "Score levels require a description. Unlike instructions, Choice option descriptions and Noul criteria, the provider rejects a null level (HTTP422)."
          }
        },
        "properties": {
          "evaluations": {
            "items": {
              "$ref": "#/definitions/Evaluation"
            },
            "maxItems": 512,
            "minItems": 1,
            "type": "array"
          },
          "expires_at_unix_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "options": {
            "allOf": [
              {
                "$ref": "#/definitions/RequestOptions"
              }
            ],
            "default": {}
          },
          "request_id": {
            "maxLength": 128,
            "minLength": 1,
            "type": [
              "string",
              "null"
            ]
          },
          "timeout_ms": {
            "format": "uint64",
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "evaluations",
          "timeout_ms"
        ],
        "title": "EvaluateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Answer": {
            "oneOf": [
              {
                "additionalProperties": false,
                "properties": {
                  "noul": {
                    "format": "double",
                    "type": "number"
                  },
                  "type": {
                    "enum": [
                      "noul"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "noul",
                  "type"
                ],
                "type": "object"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "choice": {
                    "type": "string"
                  },
                  "confidence": {
                    "format": "double",
                    "type": "number"
                  },
                  "probabilities": {
                    "additionalProperties": {
                      "format": "double",
                      "type": "number"
                    },
                    "type": "object"
                  },
                  "type": {
                    "enum": [
                      "choice"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "choice",
                  "confidence",
                  "probabilities",
                  "type"
                ],
                "type": "object"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "confidence": {
                    "format": "double",
                    "type": "number"
                  },
                  "legend": {
                    "additionalProperties": {
                      "$ref": "#/definitions/ScoreLevel"
                    },
                    "type": "object"
                  },
                  "probabilities": {
                    "additionalProperties": {
                      "format": "double",
                      "type": "number"
                    },
                    "type": "object"
                  },
                  "score": {
                    "format": "double",
                    "type": "number"
                  },
                  "type": {
                    "enum": [
                      "score"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "confidence",
                  "legend",
                  "probabilities",
                  "score",
                  "type"
                ],
                "type": "object"
              }
            ]
          },
          "ErrorCode": {
            "oneOf": [
              {
                "enum": [
                  "invalid_request",
                  "missing_key",
                  "payload_too_large",
                  "deadline",
                  "attempt_timeout",
                  "cancelled",
                  "http",
                  "transport",
                  "invalid_response"
                ],
                "type": "string"
              },
              {
                "description": "The selected `judge-<provider>` worker is not registered on the engine, or (a local provider) its model failed to load.",
                "enum": [
                  "provider_unavailable"
                ],
                "type": "string"
              }
            ]
          },
          "EvaluationResult": {
            "additionalProperties": false,
            "properties": {
              "answers": {
                "additionalProperties": {
                  "$ref": "#/definitions/Answer"
                },
                "type": "object"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Usage"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "answers"
            ],
            "type": "object"
          },
          "ProviderError": {
            "additionalProperties": false,
            "description": "Bounded provider diagnostics, with credentials and supplied header values redacted.",
            "properties": {
              "detail": true,
              "message": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "truncated": {
                "default": false,
                "type": "boolean"
              }
            },
            "type": "object"
          },
          "ScoreLevel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "items": true,
                "type": "array"
              }
            ],
            "description": "Score levels require a description. Unlike instructions, Choice option descriptions and Noul criteria, the provider rejects a null level (HTTP422)."
          },
          "Stats": {
            "additionalProperties": false,
            "description": "Known accepted usage, never a billing estimate. Unreported counters or failure/cancellation make usage_complete false.",
            "properties": {
              "attempts": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "elapsed_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "input_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "output_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "questions": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "requests": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "usage_complete": {
                "type": "boolean"
              }
            },
            "required": [
              "attempts",
              "elapsed_ms",
              "input_tokens",
              "output_tokens",
              "questions",
              "requests",
              "usage_complete"
            ],
            "type": "object"
          },
          "Usage": {
            "additionalProperties": false,
            "description": "Each absent/null counter is unknown, independently of the other counter.",
            "properties": {
              "input_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "output_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "oneOf": [
          {
            "additionalProperties": false,
            "properties": {
              "model": {
                "type": "string"
              },
              "results": {
                "additionalProperties": {
                  "$ref": "#/definitions/EvaluationResult"
                },
                "type": "object"
              },
              "stats": {
                "$ref": "#/definitions/Stats"
              },
              "status": {
                "enum": [
                  "ok"
                ],
                "type": "string"
              }
            },
            "required": [
              "model",
              "results",
              "stats",
              "status"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "code": {
                "$ref": "#/definitions/ErrorCode"
              },
              "http_status": {
                "format": "uint16",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider_error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ProviderError"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "retry_after_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "stats": {
                "$ref": "#/definitions/Stats"
              },
              "status": {
                "enum": [
                  "error"
                ],
                "type": "string"
              }
            },
            "required": [
              "code",
              "stats",
              "status"
            ],
            "type": "object"
          }
        ],
        "title": "EvaluateResponse"
      }
    },
    {
      "description": "Describe the SemIf model, loading it if needed (name, pinned revision, device, context window); performs no inference.",
      "metadata": {
        "internal": true
      },
      "name": "judge-semif::models::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "RequestOptions": {
            "additionalProperties": false,
            "properties": {
              "attempt_timeout_ms": {
                "description": "Bounds each network attempt separately from the whole-call deadline.",
                "format": "uint64",
                "minimum": 1,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "expires_at_unix_ms": {
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "options": {
            "allOf": [
              {
                "$ref": "#/definitions/RequestOptions"
              }
            ],
            "default": {}
          },
          "request_id": {
            "maxLength": 128,
            "minLength": 1,
            "type": [
              "string",
              "null"
            ]
          },
          "timeout_ms": {
            "default": 30000,
            "format": "uint64",
            "minimum": 1,
            "type": "integer"
          }
        },
        "title": "ModelsRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ErrorCode": {
            "oneOf": [
              {
                "enum": [
                  "invalid_request",
                  "missing_key",
                  "payload_too_large",
                  "deadline",
                  "attempt_timeout",
                  "cancelled",
                  "http",
                  "transport",
                  "invalid_response"
                ],
                "type": "string"
              },
              {
                "description": "The selected `judge-<provider>` worker is not registered on the engine, or (a local provider) its model failed to load.",
                "enum": [
                  "provider_unavailable"
                ],
                "type": "string"
              }
            ]
          },
          "ModelCard": {
            "properties": {
              "context_window": {
                "description": "Tokens one evaluation row can hold (question, options and state), when the provider has a fixed window. Callers size their states from it.",
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "description": {
                "type": "string"
              },
              "max_options": {
                "description": "Most options one Choice question (or levels one Score) can offer, when the provider has a fixed limit below the contract's 255. Callers size their option groups from it.",
                "format": "uint32",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "name": {
                "type": "string"
              },
              "release_date": {
                "type": "string"
              }
            },
            "required": [
              "description",
              "name",
              "release_date"
            ],
            "type": "object"
          },
          "ProviderError": {
            "additionalProperties": false,
            "description": "Bounded provider diagnostics, with credentials and supplied header values redacted.",
            "properties": {
              "detail": true,
              "message": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "truncated": {
                "default": false,
                "type": "boolean"
              }
            },
            "type": "object"
          },
          "Stats": {
            "additionalProperties": false,
            "description": "Known accepted usage, never a billing estimate. Unreported counters or failure/cancellation make usage_complete false.",
            "properties": {
              "attempts": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "elapsed_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "input_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "output_tokens": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "questions": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "requests": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "usage_complete": {
                "type": "boolean"
              }
            },
            "required": [
              "attempts",
              "elapsed_ms",
              "input_tokens",
              "output_tokens",
              "questions",
              "requests",
              "usage_complete"
            ],
            "type": "object"
          }
        },
        "oneOf": [
          {
            "additionalProperties": false,
            "properties": {
              "models": {
                "items": {
                  "$ref": "#/definitions/ModelCard"
                },
                "type": "array"
              },
              "stats": {
                "$ref": "#/definitions/Stats"
              },
              "status": {
                "enum": [
                  "ok"
                ],
                "type": "string"
              }
            },
            "required": [
              "models",
              "stats",
              "status"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "code": {
                "$ref": "#/definitions/ErrorCode"
              },
              "http_status": {
                "format": "uint16",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "provider_error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ProviderError"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "retry_after_ms": {
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "stats": {
                "$ref": "#/definitions/Stats"
              },
              "status": {
                "enum": [
                  "error"
                ],
                "type": "string"
              }
            },
            "required": [
              "code",
              "stats",
              "status"
            ],
            "type": "object"
          }
        ],
        "title": "ModelsResponse"
      }
    },
    {
      "description": "Internal: reload SemIf configuration from authoritative storage.",
      "metadata": {
        "internal": true
      },
      "name": "judge-semif::on-config-change",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Trigger payload for `<worker>::on-config-change`. Advisory only: handlers re-fetch the authoritative value and ignore it, so a direct call can never inject config.",
        "properties": {
          "id": {
            "default": null,
            "description": "Configuration id that changed.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "OnConfigChangeEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Ack returned by the internal `<worker>::on-config-change` handler.",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OnConfigChangeResponse",
        "type": "object"
      }
    },
    {
      "description": "Serve the judge-semif worker's injected console UI assets (content function for its console:script / console:style / console:module triggers).",
      "metadata": {
        "internal": true
      },
      "name": "judge-semif::ui-content",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Input of the content function: the console asks for one asset by path.",
        "properties": {
          "path": {
            "description": "The asset path from the trigger config (e.g. `state/page.js`).",
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "UiContentInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Output of the content function.",
        "properties": {
          "content": {
            "description": "The asset source, verbatim.",
            "type": "string"
          },
          "content_type": {
            "description": "MIME type the console should serve the asset with.",
            "type": "string"
          }
        },
        "required": [
          "content",
          "content_type"
        ],
        "title": "UiContentResult",
        "type": "object"
      }
    }
  ],
  "triggers": []
}
```
