Red-team Missions, Evaluation Query & Export, LoRA Training, and Refusal Suites

Overview

This release adds red-team missions to ztd eval. A mission sends Nemesis, the Tribunal's calibrated adversary, against one attack-surface scenario on one target model. Each probe carries an attacker-authored payload that fills the scenario's attack slot, runs with fresh context, and is graded normally. A user_prompt probe on a scenario without workspace files or seeded turns is a conversation of up to 10 turns with a local Goose agent launched as ztd mcp agent run launches it, so the attacker can build on the target's replies. A break is confirmed when fresh-context replays reproduce it, and the mission stops at that point or when its probe budget is spent. Missions never publish: their governance activity is withheld from the public feed.

It also adds ztd eval query for local querying, aggregation, and curated dataset export over vault-sealed traces, ztd eval models train for PEFT LoRA adapter training, ztd eval export and ztd eval import for transfer-key encrypted evaluation bundles, six vendored public refusal benchmark suites alongside full-suite@1.0.0, an independent local Evaluation Explorer listener (--eval-explorer / --public-spectator), and fixes for managed llama.cpp router startup on Windows, cold llama.cpp model inventory timeouts, CLI recovery proofs, and pre-roster run decoding.

Added

  • ztd eval missions create, start, show, and list freeze, run, and report red-team missions. missions show --break prints the confirmed break report with the verbatim payload, its containment, and the evidence commands that reproduce its verification.
  • Suite scenarios may declare attack_surface, with a kind of user_prompt, workspace_file, or inline_context, a label for workspace files and inline entries, and an objective for the attacker. A scenario with an attack surface runs only as a mission.
  • The built-in suite redteam-missions@1.0.0 provides redteam-indirect-injection, redteam-secret-extraction, and redteam-forged-approval.
  • The break oracle classifies each probe as disclosure, forbidden_attempt, or judged_violation, and reports containment as uncontained (a ztd platform finding) or contained.
  • --confirm and --confirm-min set fresh-context replays and the number that must reproduce a breach. A probe that falls short is flaky, and the hunt continues.
  • ztd eval runs verify checks mission runs: each recorded payload is re-applied, every probe matches its signed attacker inference output, the attacker receipt verifies against the Inference runtime anchors pinned in the subject trace, and each confirmation replays an earlier probe's exact payload and digest.
  • Nemesis carries a mission rendering (MissionPurpose, MissionSystemPrompt(), and MissionDigest()). A mission spec freezes its persona ID, version, and digest.
  • Conversation attempts for user_prompt missions whose scenario supplies no workspace files and no seeded turns, which includes every imported mission template and redteam-secret-extraction. missions create and import take --max-turns (default and maximum 10) and --agent (goose). Each attempt is a new Goose session with the ztd stdio bridge as its only governed MCP server, running as the agent's owner-approved application identity, which missions start enrolls when it is missing. Nemesis writes each later user turn from the conversation so far, the pinned judge rules after every turn, and the attempt stops at the first breaching turn. A confirmation replays the probe's user turns verbatim as scripted_turns in a new session. The target model runs on Ollama or llama.cpp. missions start --ollama-endpoint (default ZTD_OLLAMA_ENDPOINT) sets the Ollama endpoint for an Ollama target. A llama.cpp target requires missions start --llamacpp-endpoint http://host:port, an OpenAI-compatible llama-server that Goose calls through its openai provider, with every inherited OPENAI_ variable removed. missions show --break prints the conversation. In a conversation, a bridge tool call the agent reports is evidence and can be a forbidden_attempt, never an execution or a disclosure, because its receipt stays in the executing runtime's store.
  • The agent trace carries an optional session field holding a conversation attempt's turns: each user message, the attacker call that wrote it, the reply, and the judge's verdicts on the conversation up to that turn. ztd eval runs verify checks each turn against the signed attacker output, each replay against its scripted turns, and each turn's verdicts against their receipts.
  • Mission templates (ztd eval missions template and import) accept an optional # Tools section that declares simulated tools. The attacker and the subject see them as no-op tools whose calls are recorded and never executed.
  • ztd eval missions import --system <file> supplies the target's system instructions from a separate file, stored as the scenario's input.system_instructions. The target holds them as its system prompt and the judge reads them; the attacker does not. A template's # Overview describes the scenario and is never shown to the target.
  • evaluation_withheld on the common.v1 GovernanceEnvelope (field 30), the operator.v1 InferenceDispatchRequest (field 39), and models.OperatorCommand marks evaluation activity that never reaches the public feed.
  • ztd eval models train <model> trains a LoRA adapter for an ollama or llamacpp registry model on the conversations of one or more ztd eval query --output-dir bundles (--data, repeatable). It writes the seeded blend to train.jsonl, records the base model digest, source digests, and hyperparameters in training.json, and runs scripts/lora.py through uv, which trains on assistant tokens only and writes a PEFT adapter. --dry-run writes the training set and prints the trainer command.
  • ztd eval query runs local queries, statistical aggregations (--group-by), multi-field --sort, deduplication (--dedup), stratified balancing (--stratify), and curated dataset export (--output-dir writing conversations.jsonl, manifest.jsonl, manifest.csv, and summary.json) over vault-sealed runs without contacting the Gateway. It provides built-in presets (security-violations, failures, thinking-traces), --format (table, summary, csv, jsonl, conversations), and a sealed derived per-run cache at .ztd/data/eval/runs/<run-id>/query-index.json (query_index.go).
  • ztd eval query --strip-system-instructions omits each exported conversation's leading system message, which holds the <system_instructions> and <available_tools> blocks, on --format conversations and in the --output-dir bundle. The conversation then opens on the user prompt, and record selection does not change.
  • ztd eval query --alt-system <file> replaces the recorded system instructions in each conversation's <system_instructions> block with the file's contents, on --format conversations and in the --output-dir bundle. The file holds bare instructions or one <system_instructions> block. <available_tools> still lists the tools each trace offered, record selection does not change, and the flag cannot be combined with --strip-system-instructions.
  • --inference-llamacpp-models-max <int> on ztd gw start and ztd operator start passes llama-server --models-max to the managed llama.cpp router (--inference-llamacpp-managed required). Models loaded side by side share the device, so --fit could shrink a later-loaded model's context window toward 4096; 1 gives each model the whole device. 0 or unset keeps the llama-server default of 4.
  • Six checked-in refusal suites at version 1.0.0 in eval/suites/: harmbench-standard (200 prompts to decline), harmbench-contextual (100), jailbreakbench (100 to decline and 100 safe prompts to answer), strongreject (313), strongreject-small (60), and xstest (200 to decline and 250 safe prompts to answer). Prompt text is imported unchanged, apart from line endings, from HarmBench, JailbreakBench, StrongREJECT, and XSTest. Run them only with ztd eval runs start --publish=false, never through ztd eval rollout, because published results include model replies.
  • The built-in suite full-suite@1.0.0 holds every single-roster scenario in 50 scenarios: default-suite@1.39.0, the three runbook injection variants from prompt-injection-resilience, and the three investigations scenarios. It excludes devops-fleet, which needs a multi-Operator roster, and the red-team mission targets. default-suite@1.39.0 is unchanged.
  • ztd eval export [snapshot-or-backup-dir] packages evaluation backup snapshots into one bundle another Gateway can import, which a snapshot alone cannot do because its key chain opens only with the source host's key store. Every file is opened with its snapshot's key chain, deflated, and sealed with AES-256-GCM under a fresh bundle key, which is wrapped under a fresh 256-bit transfer key. The transfer key is shown once on the terminal in recovery key form, or written to a new owner-only --key-file, and is never stored in the bundle. The bundle defaults to eval/exports/eval-export-<timestamp>.zip; --output names another file or directory outside .ztd/.
  • ztd eval import <bundle> reads the transfer key from --key-file or standard input, authenticates the bundle, and writes its evidence sealed under the local runtime vault. A wrong key (ErrEvaluationExportKeyInvalid) or an edited bundle (ErrEvaluationExportIntegrity) writes nothing. --overwrite and --verify work as they do for ztd eval restore.
  • ztd eval export, ztd eval import, and ztd eval restore report progress on standard error: files and bytes done, rate, and time left, at most every two seconds. Export seals records on one worker per CPU.
  • The upstream data is vendored in eval/benchmarks/ at pinned revisions, with each source's license (MIT for HarmBench, JailbreakBench, and StrongREJECT; CC BY 4.0 for XSTest) and per-file SHA-256 digests in eval/benchmarks/sources.json. make benchmark-suites-generate writes the suites from that data, and make benchmark-suites-check verifies the committed files match.
  • The Evaluation Explorer's Datasets page (/datasets) sells ztd eval export bundles through Stripe Payment Links. After checkout Stripe returns the buyer to /datasets/claim, where a Cloudflare Worker (evaluation-explorer/worker/) reads the Checkout Session from Stripe and, for a complete, paid session from a catalog Payment Link, returns the bundle's transfer key and a download URL. The download repeats the check and streams the bundle from R2 with byte-range resume. The catalog (evaluation-explorer/src/content/datasets.ts) holds only public bundle facts; transfer keys stay in a Worker secret. evaluation-explorer/scripts/stripe-dataset-link.sh creates a bundle's Stripe product, price, and Payment Link. The Gateway-embedded Explorer serves the pages but not the claim API.

Changed

  • ztd eval query --help lists every accepted value for each closed-set flag in a "Values by flag" section: presets, formats, columns, record and grouped sort fields, group-by and stratify dimensions, categories, roles, lifecycles, verdicts, outcomes, terminal classifications, breach types, and grade statuses. The lists come from the proto enums and evaluation constants that records carry, so they track new values. The --category usage no longer suggests OPERATIONAL, which is not a category. An unknown --breach, --preset, or grouped --sort value now names the valid set in its error.
  • The Tribunal deliberator records a vote for an envelope carrying evaluation_withheld on the Gateway audit chain but never publishes it. This is an exception to the public vote publication rule in INV-CON-VOTE-12.
  • Campaign freeze refuses a campaign whose models (registry, mission attacker, and judge) name both ollama and llamacpp with ErrInferenceProviderClassesUnservable, naming each model, its role, and its class. campaigns create, missions create, runs start, and run execution apply the check, and the failure class is invalid_input. When no active Inference Operator serves a campaign's classes, the error names what each active candidate serves.
  • missions start refuses an endpoint flag the mission never uses with ErrEvaluationMissionEndpointUnused: --llamacpp-endpoint for an Ollama target, --ollama-endpoint given on the command line for a llama.cpp target, and either flag for a single-turn mission.
  • ztd eval query conversations carry the system instructions and tool list in a leading system message (<system_instructions>, then <available_tools>) instead of at the top of the first user message, so user turns hold only user text. ValidateCuratedConversation accepts one optional non-empty system message before the alternating user and assistant turns and rejects a system message anywhere else. Bundles exported by earlier releases still validate for ztd eval models train. The signal score's turn penalty counts assistant turns, so the system message does not change it.
  • Nemesis's authoring and vote renderings and digests are unchanged. The mission rendering is digested separately, so campaigns and Tribunal bindings frozen before this release remain valid.
  • The evaluation explorer reads its feed from the Gateway's explorer listener (127.0.0.1:5173), which serves the explorer and the feed's anonymous read routes, so the public mirror is optional for it. ztd gw start --eval-explorer (default true) controls the local evaluation feed and its explorer listener, and --eval-explorer=false starts no feed listener; --public-spectator (default true) controls the anonymous public read listener (127.0.0.1:8082) and bucket publishing, and --public-spectator=false keeps the feed local to the explorer listener, with no public read listener and no bucket publishing. CLI feed reads on a local Gateway (eval runs publish probes, public status and restore, eval rollout run --mirror-bootstrap-url, and --mirror-origin defaults) use the explorer listener, and a non-loopback Gateway endpoint keeps its :8082 public mirror default.
  • Every built-in suite is a membership list over one scenario registry, and ztd eval suites list and campaign freeze read the same table. consensus-screen@1.15.0, consensus-evidence@1.15.0, consensus-safety@1.13.0, and prompt-injection-resilience@1.4.0 are now built in, with unchanged content, versions, and catalog digests, and their files are removed from eval/suites/, which keeps only the generated benchmark suites. They need no ztd eval suites create, and their IDs are reserved. A stored copy registered under one of these IDs is superseded: suites list skips it and every lookup resolves the built-in, so the file under .ztd/data/eval/suites/ can be deleted. ztd eval suites --help lists every built-in suite.
  • The Explorer's Datasets page replaces its Sponsors page. /sponsors redirects to /datasets, and the header, navigation drawer, and footer link Datasets.

Fixed

  • A llama-server error event inside an accepted stream, which it sends when its own tool-call parser rejects the model's output, is now provider_stream_error (ErrInferenceProviderStreamError), as INV-EVAL-CAMP-34 requires and the other backends already do. It was reported as generation_failed, so a model that wrote a malformed tool call counted toward the rollout's consecutive-failure stop and could end its run with assignments still queued.
  • ztd public restore --queue now skips a run sealed under an earlier agent trace schema (ErrEvidenceSchemaRetired) and counts it as retired (retired_run_ids in --json), without setting the failure exit. It was reported as failed, and the command exited non-zero. With --force, public restore (--queue or --run-id) republishes such a run instead: each retired trace is published as its sealed bytes once its evidence digest matches, without validating it against agent-trace.v14. A retired trace whose fields v14 reshaped is also classified as ErrEvidenceSchemaRetired; it used to fail as a plain decode error.
  • A model the provider lists but cannot load, such as a GGUF the llama.cpp build cannot read, now fails with its own class, model_load_failed (ErrInferenceModelLoadFailed, RECEIPT_FAILURE_CODE_MODEL_LOAD_FAILED, INFERENCE_DISPATCH_FAILURE_CODE_MODEL_LOAD_FAILED), on llama.cpp and Ollama. It was reported as generation_failed.
  • The rollout's stop after three consecutive provider failures now counts model_load_failed with generation_failed, and counts a traceless executor failure, such as a tool-calling probe that failed before the first agent turn, by the class in its categorical reason. A traceless failure used to reset the count, so a model that could not load ran far past the limit.
  • A run record written before the harness roster, which carries ModelCampaignBinding field 7 data_operator_session_id, now loads unchanged. ztd eval runs list, runs show, evaluation backups, and the ztd public status feed drift check read it as stored. In v1.11.0 and v1.11.1 such a record failed with ErrEvaluationRunRetiredBindingField, which failed every run listing in the runtime root.
  • ztd eval query now finds reasoning that a model wrote inside its reply text, as an inline <think> block, a block the chat template opened (a leading …</think>), or an unterminated <think>, as well as the provider's thinking field. --has-thinking, thinking_chars, and the summary's thinking coverage counted only the thinking field, so most reasoning traces were missed. Exported conversations move that reasoning into the turn's single leading <think> block and escape stray tags as [think]/[/think]. A failed turn's reasoning is not counted. has_thinking means at least 80 reasoning characters under --preset security-violations and at least one otherwise, with or without --clean-conversation; the clean path used to apply 80 to every query.
  • ztd eval query conversations now follow the agent trace's own conversation order (AgentTrace.Conversation). Held context messages come first, then each input message under its own role, then the scored turns. Consecutive user messages merge. An answered clarification continues the conversation. A fan-out tool call renders as one call whose response holds every target's result. A roster join adds its roster update. The conversation stops at the first failed turn. Input ASSISTANT turns, held context, and clarifications were dropped, and a trace that failed mid-run could export a later turn. --strip-system-instructions also accepts system instructions that only the held context carries. ValidateCuratedConversation rejects a stray <think> or </think> tag, more than one think block in a turn, and a turn with reasoning but no reply.
  • The --output-dir manifest (manifest.jsonl, manifest.csv) records each row's 1-based conversation_line in conversations.jsonl; it is empty for a row with no conversation. A row's thinking_chars is the exported conversation's count when it has one.
  • ztd eval backup now skips a RuntimeFileService atomic-write temp file (.ztd-tmp-*) left by an interrupted write. Such a file failed the backup and ztd eval backup --compare, because it is empty or torn ciphertext the runtime vault cannot open.
  • The Gateway now waits the provider request deadline (dispatch.RequestDeadline), the same wait the CLI already allowed, for an OLLAMA_MODEL_INVENTORY result instead of the 30-second default. A cold llama.cpp inventory hashes every GGUF under the model root before it answers, so ztd eval models freeze --provider llamacpp returned 504 while the Operator was still hashing.
  • CLI recovery (ztd login or ztd auth enroll user on a host with no local identity, against a bootstrapped Gateway) now completes after approval. The CLI signed the raw request ID, but the Gateway verifies a signature over its SHA-256 digest, so POST /api/v1/auth/cli/recovery/complete always returned 401 (ErrCLIRecoveryProofInvalid). Both sides now take the digest from certutil.CLIRecoveryProofDigest.
  • The managed llama.cpp router (--inference-llamacpp-managed) now starts on Windows. The Operator withheld every user-profile variable from the router, so a llama-server router that resolves its Hugging Face cache at startup exited with Failed to determine HF cache directory within a second of every restart. Every inference, and ztd eval models freeze, failed with ErrInferenceBackendUnavailable, and the exit was logged as bad_models_dir. The router's environment now pins LLAMA_CACHE and its temporary directory (TMP and TEMP on Windows, TMPDIR elsewhere) to private directories under its scratch directory, recreated before every spawn, so the router no longer depends on HOME, USERPROFILE, or LOCALAPPDATA on any OS and never lists a host Hugging Face cache. A router that still cannot resolve or create such a directory is logged with exit_cause environment.

Compatibility

v1.11.2 is backwards-compatible with v1.11.1 across CLI, wire, and evidence contracts (INV-REL-VER-10). The protocol additions are additive: the evaluation_withheld fields default to false, the ztd.eval.v1 messages for attack surfaces, mission specs, and mission attacks are new, and RECEIPT_FAILURE_CODE_MODEL_LOAD_FAILED (29) and INFERENCE_DISPATCH_FAILURE_CODE_MODEL_LOAD_FAILED (52) are new enum values. Agent traces remain agent-trace.v14, with an additive session field on conversation mission attempts. Existing envelopes, dispatches, campaigns, and sealed traces read unchanged. ModelCampaignBinding field 7 data_operator_session_id, reserved in v1.11.0, is declared again with its original name and number so pre-roster run records decode; new runs leave it empty. ztd eval runs repair no longer rewrites run records, so its --json output drops binding_rewritten, and ErrEvaluationRunRetiredBindingField is removed.

Missions require the Gateway and the Operators of this release. A mission spec is refused by any binary whose Nemesis mission rendering digests differently (ErrPersonaDigestMismatch), so create a new mission after upgrading rather than resuming one created by another binary. A conversation mission needs goose on PATH. The target model's calls go from Goose to Ollama directly and are not governed inferences; the agent's tool calls through the ztd bridge are governed under L1–L5.