From e79a3d94c29d61674e9fd926bd5a39b865c22b2a Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:02:36 +0900 Subject: [PATCH 01/18] test(api): read a run's installed MCP config back through inspect The guard launches one declared server through candler run and reads the run back through inspect, as JSON and as text. It fails on this commit: inspect shows only a catalog that says servers: []. Co-Authored-By: Claude Sonnet 5.5 --- .../tests/it/guard_catalog_snapshot.rs | 85 ------------------- .../tests/it/guard_inspect_mcp_config.rs | 72 ++++++++++++++++ crates/candler/tests/it/main.rs | 2 +- crates/candler/tests/it/support/cli_run.rs | 4 + 4 files changed, 77 insertions(+), 86 deletions(-) delete mode 100644 crates/candler/tests/it/guard_catalog_snapshot.rs create mode 100644 crates/candler/tests/it/guard_inspect_mcp_config.rs diff --git a/crates/candler/tests/it/guard_catalog_snapshot.rs b/crates/candler/tests/it/guard_catalog_snapshot.rs deleted file mode 100644 index a2806b67..00000000 --- a/crates/candler/tests/it/guard_catalog_snapshot.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! Guards the tool-catalog snapshot of a run the real runner sealed: the digest the cell records -//! in `snapshots` resolves to a stored blob, and `candler inspect` shows the catalog the run ran -//! with. -#![cfg(test)] -#![cfg(unix)] - -use crate::support::cli_run::world; -use crate::support::seam::finish; - -use std::fs; -use std::process::Command; - -use candler_core::store::Store; -use candler_schemas::primitives::Digest; -use serde_json::Value; - -/// Guards: a sealed run stores the catalog it ran with — the manifest's catalog digest names a -/// blob whose bytes hash to it, and `inspect` of the run directory, as JSON and as text, shows the -/// catalog the fake image printed. -/// -/// Oracle: the digest is the sha256 of the blob's bytes, computed by `Digest::of_bytes`; the -/// provider name is the literal the fixture's fake `docker run` prints. -/// -/// Bite: skip the snapshot's `put_blob` at the seal (the blob read turns red, and `inspect` shows -/// `catalog not stored`). -#[test] -fn a_sealed_run_stores_the_catalog_it_ran_with_and_inspect_shows_it() { - let world = world(); - let launched = world.launch(); - finish(&world, &launched); - world.assert_sealed(1); - - let runs = world.store().join("runs"); - let run_dir = fs::read_dir(&runs) - .unwrap() - .flatten() - .map(|entry| entry.path()) - .find(|path| path.join("run.done").is_file()) - .expect("a sealed run"); - let manifest: Value = - serde_json::from_slice(&fs::read(run_dir.join("manifest.json")).unwrap()).unwrap(); - let digest: Digest = manifest["comparable"]["snapshots"] - .as_array() - .unwrap() - .iter() - .find(|entry| entry["kind"] == "catalog") - .expect("the cell records a catalog digest")["digest"] - .as_str() - .unwrap() - .parse() - .unwrap(); - - let store = Store::open(&world.store()).expect("the store opens"); - let bytes = fs::read(store.blob_path(&digest)).expect("the catalog digest resolves to a blob"); - assert_eq!( - Digest::of_bytes(&bytes), - digest, - "the blob holds the hashed bytes" - ); - - let inspect = |extra: &[&str]| { - let out = Command::new(env!("CARGO_BIN_EXE_candler")) - .arg("inspect") - .arg(&run_dir) - .args(extra) - .current_dir(&world.work) - .env_clear() - .output() - .unwrap(); - assert!(out.status.success(), "inspect exits 0: {out:?}"); - String::from_utf8(out.stdout).unwrap() - }; - let record: Value = serde_json::from_str(&inspect(&[])).unwrap(); - assert_eq!(record["catalog"]["provider"], "candler-image@1", "{record}"); - assert_eq!( - record["catalog"]["servers"], - serde_json::json!([]), - "{record}" - ); - let text = inspect(&["--format", "text"]); - assert!( - text.lines().any(|line| line == "catalog candler-image@1"), - "the text shows the catalog:\n{text}" - ); -} diff --git a/crates/candler/tests/it/guard_inspect_mcp_config.rs b/crates/candler/tests/it/guard_inspect_mcp_config.rs new file mode 100644 index 00000000..18a547aa --- /dev/null +++ b/crates/candler/tests/it/guard_inspect_mcp_config.rs @@ -0,0 +1,72 @@ +//! Guards the MCP configuration `candler inspect` shows for a run the real runner sealed: the +//! resolved `mcp.*` values the cell digest hashes. +#![cfg(test)] +#![cfg(unix)] + +use crate::support::cli_run::world; +use crate::support::seam::finish; + +use std::fs; +use std::process::Command; + +use serde_json::Value; + +/// Guards: a run launched with one declared MCP server is read back through `inspect`, as JSON and +/// as text, and the declared server is among the shown `mcp.*` values. +/// +/// Oracle: the server name and command are the literals the test passes to `candler run --set`. +/// +/// Bite: leave the `mcp.*` values out of what `inspect` shows (the `mcp` member of the record and +/// the text lines both lose the server). +#[test] +fn inspect_shows_the_mcp_server_a_run_was_launched_with() { + let world = world(); + let launched = world.launch_with(&[ + "--set", + "mcp.servers.fs.command=mcp-fs", + "--set", + "mcp.servers.fs.args=[\"data\"]", + ]); + finish(&world, &launched); + world.assert_sealed(1); + + let runs = world.store().join("runs"); + let run_dir = fs::read_dir(&runs) + .unwrap() + .flatten() + .map(|entry| entry.path()) + .find(|path| path.join("run.done").is_file()) + .expect("a sealed run"); + let inspect = |extra: &[&str]| { + let out = Command::new(env!("CARGO_BIN_EXE_candler")) + .arg("inspect") + .arg(&run_dir) + .args(extra) + .current_dir(&world.work) + .env_clear() + .output() + .unwrap(); + assert!(out.status.success(), "inspect exits 0: {out:?}"); + String::from_utf8(out.stdout).unwrap() + }; + + let record: Value = serde_json::from_str(&inspect(&[])).unwrap(); + let shown = record["mcp"] + .as_object() + .unwrap_or_else(|| panic!("the record shows the mcp values: {record}")); + let server = shown + .iter() + .find(|(path, _)| path.starts_with("mcp.servers.fs")) + .unwrap_or_else(|| panic!("the declared server is shown: {record}")); + assert!( + server.1.to_string().contains("mcp-fs"), + "the shown value is the declared command: {record}" + ); + + let text = inspect(&["--format", "text"]); + assert!( + text.lines() + .any(|line| line.starts_with("mcp.servers.fs") && line.contains("mcp-fs")), + "the text shows the declared server:\n{text}" + ); +} diff --git a/crates/candler/tests/it/main.rs b/crates/candler/tests/it/main.rs index 34aa1253..fab5294a 100644 --- a/crates/candler/tests/it/main.rs +++ b/crates/candler/tests/it/main.rs @@ -49,7 +49,6 @@ mod commands { mod contract_pages; mod guard_analyze; mod guard_analyze_golden; -mod guard_catalog_snapshot; mod guard_cli; mod guard_cli_e2e; mod guard_cli_evaluate; @@ -67,6 +66,7 @@ mod guard_ground_truth_cli; mod guard_ingest; mod guard_input_seam; mod guard_inspect; +mod guard_inspect_mcp_config; mod guard_mcp_origin; mod guard_registry; mod guard_run_context_files; diff --git a/crates/candler/tests/it/support/cli_run.rs b/crates/candler/tests/it/support/cli_run.rs index f589faaf..e6d082e0 100644 --- a/crates/candler/tests/it/support/cli_run.rs +++ b/crates/candler/tests/it/support/cli_run.rs @@ -161,6 +161,10 @@ exec) esac ;; logs) ;; +inspect) + # The start probe of a declared MCP server asks whether the container is still running. + echo true + ;; run) if case " $* " in *" --version "*) true;; *) false;; esac; then echo "2.1.311 (Claude Code)" From 1984a32cb7fd8cb8b844c382fc51ba2eac0b5d12 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:05:03 +0900 Subject: [PATCH 02/18] feat(schemas)!: drop the catalog snapshot and show MCP in inspect Removes tool-catalog-snapshot/1 and its generated schema. inspect-run no longer carries catalog; it carries mcp, the resolved mcp.* values by path. A cell leaves comparable.snapshots out of its record and its hash when it lists none, so a cell without snapshots hashes under a new digest; a cell that lists them hashes as before. BREAKING CHANGE: catalog-snapshot.schema.json and inspect-run's catalog are removed, inspect-run requires mcp, and a cell without snapshots has a new digest. Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-schemas/schema/README.md | 1 - .../schema/catalog-snapshot.schema.json | 170 - .../schema/inspect-run.schema.json | 9 +- .../schema/run-manifest.schema.json | 6 +- crates/candler-schemas/src/catalog.rs | 984 ---- crates/candler-schemas/src/execution.rs | 11 +- crates/candler-schemas/src/generate.rs | 9 +- crates/candler-schemas/src/inspect.rs | 7 +- crates/candler-schemas/src/lib.rs | 3 +- crates/candler-schemas/src/primitives.rs | 2 +- crates/candler-schemas/src/refusal.rs | 3 +- crates/candler-schemas/src/refusal_impls.rs | 53 - .../tests/fixtures/spec/LICENSE | 216 - .../tests/fixtures/spec/README.md | 51 - .../fixtures/spec/mcp-2026-07-28.schema.json | 3963 ----------------- .../tools/docs-execute-sql-x-mcp-header.json | 22 - .../tools/docs-get-weather-with-icons.json | 26 - .../tools/docs-list-users-array-output.json | 31 - .../tests/fixtures/spec/tools/full.json | 85 - .../tools/tool-with-array-output-schema.json | 30 - .../tool-with-composition-input-schema.json | 28 - .../with-default-2020-12-input-schema.json | 12 - .../with-explicit-draft-07-input-schema.json | 13 - .../spec/tools/with-no-parameters.json | 8 - ...-output-schema-for-structured-content.json | 33 - .../tests/fixtures/upstream/README.md | 75 - .../fixtures/upstream/bio_opentrons.json | 919 ---- .../tests/fixtures/upstream/rikyu_mcp.json | 2709 ----------- .../tests/it/catalog_fixtures.rs | 522 --- .../tests/it/catalog_properties.rs | 745 ---- .../tests/it/guard_cell_digest.rs | 59 +- .../tests/it/guard_execution_wire.rs | 1 - .../candler-schemas/tests/it/guard_refusal.rs | 8 +- .../tests/it/guard_wire_shapes.rs | 138 +- crates/candler-schemas/tests/it/main.rs | 2 - 35 files changed, 36 insertions(+), 10918 deletions(-) delete mode 100644 crates/candler-schemas/schema/catalog-snapshot.schema.json delete mode 100644 crates/candler-schemas/src/catalog.rs delete mode 100644 crates/candler-schemas/tests/fixtures/spec/LICENSE delete mode 100644 crates/candler-schemas/tests/fixtures/spec/README.md delete mode 100644 crates/candler-schemas/tests/fixtures/spec/mcp-2026-07-28.schema.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/docs-execute-sql-x-mcp-header.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/docs-get-weather-with-icons.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/docs-list-users-array-output.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/full.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/tool-with-array-output-schema.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/tool-with-composition-input-schema.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/with-default-2020-12-input-schema.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/with-explicit-draft-07-input-schema.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/with-no-parameters.json delete mode 100644 crates/candler-schemas/tests/fixtures/spec/tools/with-output-schema-for-structured-content.json delete mode 100644 crates/candler-schemas/tests/fixtures/upstream/README.md delete mode 100644 crates/candler-schemas/tests/fixtures/upstream/bio_opentrons.json delete mode 100644 crates/candler-schemas/tests/fixtures/upstream/rikyu_mcp.json delete mode 100644 crates/candler-schemas/tests/it/catalog_fixtures.rs delete mode 100644 crates/candler-schemas/tests/it/catalog_properties.rs diff --git a/crates/candler-schemas/schema/README.md b/crates/candler-schemas/schema/README.md index b999df50..4c415e14 100644 --- a/crates/candler-schemas/schema/README.md +++ b/crates/candler-schemas/schema/README.md @@ -23,7 +23,6 @@ or file, or a message of the evaluator protocol. | File | Root type | Wire tag | R01 section | |---|---|---|---| | `analysis-report.schema.json` | `AnalysisReport` | `analysis-report/1` | Analysis statistics | -| `catalog-snapshot.schema.json` | `CatalogSnapshot` | `tool-catalog-snapshot/1` | Wire schema: tool-catalog snapshot | | `child-record.schema.json` | `ChildRecord` | `child-record/1` | Process supervision | | `container-record.schema.json` | `ContainerRecord` | `container-record/1` | Process supervision (job dir) | | `evaluator-describe-result.schema.json` | `DescribeResult` | none; `protocol` is `{major, minor}` | Evaluator protocol (`describe` result) | diff --git a/crates/candler-schemas/schema/catalog-snapshot.schema.json b/crates/candler-schemas/schema/catalog-snapshot.schema.json deleted file mode 100644 index fa96eebe..00000000 --- a/crates/candler-schemas/schema/catalog-snapshot.schema.json +++ /dev/null @@ -1,170 +0,0 @@ -{ - "$defs": { - "CatalogServer": { - "additionalProperties": false, - "description": "One MCP server of a run and the tools it offered.", - "properties": { - "name": { - "description": "The name of the server: at least one character, and unique among the servers of its snapshot.", - "minLength": 1, - "type": "string" - }, - "source_digest": { - "$ref": "#/$defs/Digest", - "description": "The digest of the server's source file." - }, - "source_path": { - "$ref": "#/$defs/RelPath", - "description": "The path of the server's source file: a POSIX path relative to the project root." - }, - "tools": { - "$comment": "Tool names are unique within the array, compared byte for byte (case-sensitive, without Unicode normalisation); JSON Schema cannot state this, and the Rust reader refuses a repeated name.", - "description": "The tools the server offered, with names unique among them.", - "items": { - "$ref": "#/$defs/Tool" - }, - "type": "array" - }, - "transport": { - "$ref": "#/$defs/Transport", - "description": "How a client reaches the server." - } - }, - "required": [ - "name", - "source_path", - "source_digest", - "transport", - "tools" - ], - "type": "object" - }, - "Digest": { - "description": "A content digest: `sha256:` followed by 64 lowercase hex digits.", - "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])", - "type": "string" - }, - "NameToken": { - "description": "A catalog provider reference, `name@token`, split at the last `@`: the name is non-empty and holds neither `@` nor white space, and the token matches `[0-9A-Za-z.+-]+`.", - "pattern": "^[^@\\t\\n\\v\\f\\r\\x20\\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+@[0-9A-Za-z.+-]+(?![\\s\\S])", - "type": "string" - }, - "RelPath": { - "description": "A run-relative POSIX path: non-empty, with no leading `/`, no empty segment, no `.` or `..` segment, no NUL and no `\\`.", - "pattern": "^(?!\\.\\.?(?:/|(?![\\s\\S])))[^/\\\\\\x00]+(?:/(?!\\.\\.?(?:/|(?![\\s\\S])))[^/\\\\\\x00]+)*(?![\\s\\S])", - "type": "string" - }, - "Timestamp": { - "$comment": "The pattern states the lexical form; a date or time that names no instant, such as month 13, and a fraction of more than nine digits are refused by the parser.", - "description": "An RFC 3339 timestamp with an uppercase `T` and an explicit offset, `Z` or `±HH:MM`.", - "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]+)?(?:Z|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])(?![\\s\\S])", - "type": "string" - }, - "Tool": { - "additionalProperties": true, - "description": "A tool in MCP `tools/list` shape: the named keys of the MCP `Tool` definition, and every other key as the server gave it.", - "properties": { - "annotations": { - "additionalProperties": true, - "description": "Hints about the behaviour of the tool: an open object whose keys are kept as given.", - "type": "object" - }, - "description": { - "description": "A human-readable description of the tool.", - "type": "string" - }, - "inputSchema": { - "additionalProperties": true, - "description": "The JSON Schema object that describes the arguments of the tool. Its `type` is not required to be `object`.", - "type": "object" - }, - "name": { - "description": "The name of the tool, as the server gave it: at least one character, and unique among the tools of its server.", - "minLength": 1, - "type": "string" - }, - "outputSchema": { - "additionalProperties": true, - "description": "The JSON Schema object that describes the structured output of the tool.", - "type": "object" - }, - "title": { - "description": "A human-readable title of the tool.", - "type": "string" - } - }, - "required": [ - "name", - "inputSchema" - ], - "type": "object" - }, - "Transport": { - "description": "How a client reaches an MCP server.", - "oneOf": [ - { - "const": "stdio", - "description": "The server runs as a subprocess and is spoken to over its standard input and output.", - "type": "string" - }, - { - "const": "http", - "description": "The server is reached over streamable HTTP.", - "type": "string" - }, - { - "const": "sse", - "description": "The server is reached over server-sent events.", - "type": "string" - } - ] - } - }, - "$id": "urn:candler:schemas:catalog-snapshot", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, - "description": "What the MCP servers targeted by a run offered: for each server, its tools in the shape of an MCP `tools/list` result.", - "properties": { - "captured_at": { - "$ref": "#/$defs/Timestamp", - "description": "When the snapshot was captured." - }, - "environment": { - "additionalProperties": { - "type": "string" - }, - "description": "The versions the capture depended on, as an object from a name to its version text.", - "type": "object" - }, - "ext": { - "additionalProperties": true, - "description": "Provider-specific data: an open JSON object that Candler does not interpret.", - "type": "object" - }, - "provider": { - "$ref": "#/$defs/NameToken", - "description": "The catalog provider that captured the snapshot, as `name@token`." - }, - "schema": { - "const": "tool-catalog-snapshot/1", - "description": "The version marker of the document: always `tool-catalog-snapshot/1`.", - "type": "string" - }, - "servers": { - "$comment": "Server names are unique within the array, compared byte for byte (case-sensitive, without Unicode normalisation); JSON Schema cannot state this, and the Rust reader refuses a repeated name.", - "description": "The servers the run targeted, each with the tools it offered, with names unique among them.", - "items": { - "$ref": "#/$defs/CatalogServer" - }, - "type": "array" - } - }, - "required": [ - "schema", - "captured_at", - "provider", - "servers" - ], - "title": "CatalogSnapshot", - "type": "object" -} diff --git a/crates/candler-schemas/schema/inspect-run.schema.json b/crates/candler-schemas/schema/inspect-run.schema.json index f64027c2..98273ae2 100644 --- a/crates/candler-schemas/schema/inspect-run.schema.json +++ b/crates/candler-schemas/schema/inspect-run.schema.json @@ -40,9 +40,6 @@ "additionalProperties": false, "description": "One run: whether it is sealed, what it was read from, the provenance and the other values it\nmeasured, and its outcomes with their evidence.", "properties": { - "catalog": { - "description": "The tool catalog the run ran with, as the run stored it: the canonical form of the\nsnapshot without `captured_at`. Absent when the run has no stored snapshot." - }, "ended_at": { "description": "When the run ended." }, @@ -61,6 +58,11 @@ "job": { "description": "The job that made the run." }, + "mcp": { + "additionalProperties": true, + "description": "The resolved `mcp.*` values the cell hashes, by path: the MCP configuration the run was\ninstalled with.", + "type": "object" + }, "measured": { "additionalProperties": true, "description": "The other measured values, by path.", @@ -99,6 +101,7 @@ "schema", "run", "sealed", + "mcp", "provenance", "measured", "outcomes" diff --git a/crates/candler-schemas/schema/run-manifest.schema.json b/crates/candler-schemas/schema/run-manifest.schema.json index 88de542b..966eabac 100644 --- a/crates/candler-schemas/schema/run-manifest.schema.json +++ b/crates/candler-schemas/schema/run-manifest.schema.json @@ -26,7 +26,8 @@ }, "snapshots": { "$comment": "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not.", - "description": "The digests of the catalog snapshots, sorted by kind and digest.", + "default": [], + "description": "The digests of the catalog snapshots, sorted by kind and digest. A cell without catalog\nsnapshots leaves the list out, and the hash leaves it out too.", "items": { "$ref": "#/$defs/DigestRef" }, @@ -49,7 +50,6 @@ "values", "harness", "treatment", - "snapshots", "inputs", "environments" ], @@ -385,7 +385,7 @@ "type": "string" }, "NameToken": { - "description": "A catalog provider reference, `name@token`, split at the last `@`: the name is non-empty and holds neither `@` nor white space, and the token matches `[0-9A-Za-z.+-]+`.", + "description": "A name and a version token, `name@token`, split at the last `@`: the name is non-empty and holds neither `@` nor white space, and the token matches `[0-9A-Za-z.+-]+`.", "pattern": "^[^@\\t\\n\\v\\f\\r\\x20\\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+@[0-9A-Za-z.+-]+(?![\\s\\S])", "type": "string" }, diff --git a/crates/candler-schemas/src/catalog.rs b/crates/candler-schemas/src/catalog.rs deleted file mode 100644 index e8b31061..00000000 --- a/crates/candler-schemas/src/catalog.rs +++ /dev/null @@ -1,984 +0,0 @@ -//! The tool-catalog snapshot: the tools the MCP servers of a run offered, in the shape of MCP -//! `tools/list` results. -//! -//! A [`Tool`] keeps every key its server gave it: the named keys of the MCP `Tool` definition are -//! typed, and any other key is held as given. The document is read through -//! [`CatalogSnapshot`], which refuses any other version marker than [`SCHEMA_TAG`] and refuses an -//! explicit `null` for an optional field. Inside `inputSchema`, `outputSchema`, `annotations`, -//! `ext` and the extra keys of a tool, `null` is ordinary JSON data and is kept. -//! -//! Server names are non-empty and unique within a snapshot, and tool names are non-empty and unique -//! within a server. Names are compared byte for byte: they are case-sensitive and are not -//! Unicode-normalised. The schema states that names are non-empty; uniqueness is enforced when a -//! snapshot is built or read. -//! -//! The reader keeps every key of a tool, `ext` and `environment`, and every value, with these -//! exceptions. Keys not defined for a snapshot or a server are dropped. Of repeated keys the last -//! is kept. Object keys are sorted, so the order in which they were written is not kept. A number -//! is held as `i64`, `u64` or `f64`: an integer beyond both becomes a float, a decimal beyond -//! `f64` precision is rounded, and a number whose magnitude is above the range of `f64` is -//! refused. Text nested deeper than about 120 levels is refused by the text readers. - -use std::borrow::Cow; -use std::collections::BTreeMap; - -use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema}; -use serde::de::Error as _; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use serde_json::{Map, Value}; - -use crate::canonical::{CanonicalError, to_jcs}; -use crate::distinct::first_repeat; -use crate::map_only::MapOnly; -use crate::primitives::{Digest, NameToken, RelPath, Timestamp, object_only}; - -/// The version marker every snapshot carries in its `schema` field. -pub const SCHEMA_TAG: &str = "tool-catalog-snapshot/1"; - -/// The keys of a [`Tool`] that are fields rather than extra keys. -const NAMED_TOOL_KEYS: [&str; 6] = [ - "name", - "title", - "description", - "inputSchema", - "outputSchema", - "annotations", -]; - -/// Why a snapshot or one of its members could not be built or read. -#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] -#[non_exhaustive] -pub enum CatalogError { - /// A `schema` field that is not [`SCHEMA_TAG`]. - #[error("schema tag differs from `{SCHEMA_TAG}` (got {value:?})")] - SchemaTag { - /// The text the field held. - value: String, - }, - /// A builder that was asked to build before a required field was set. - #[error("snapshot field is missing (`{field}` was not set)")] - MissingField { - /// The name of the field. - field: &'static str, - }, - /// An extra key of a tool that is the name of one of its fields. - #[error("tool extra key names a field of the tool (got {key:?})")] - ReservedKey { - /// The key. - key: String, - }, - /// An optional field that was written as `null` instead of being omitted. - #[error("optional field is null (an absent field is omitted)")] - Null, - /// A server or tool name that is empty. - #[error("{owner} name is empty (names have at least one character)")] - EmptyName { - /// What the name belongs to: `server` or `tool`. - owner: &'static str, - }, - /// A server or tool name that another member of the same scope already has. - #[error("{owner} name is repeated within a {scope} (got {name:?})")] - DuplicateName { - /// What the name belongs to: `server` or `tool`. - owner: &'static str, - /// What the names are unique within: `snapshot` or `server`. - scope: &'static str, - /// The repeated name. - name: String, - }, -} - -/// Refuses an empty name. -fn non_empty(name: String, owner: &'static str) -> Result { - if name.is_empty() { - Err(CatalogError::EmptyName { owner }) - } else { - Ok(name) - } -} - -fn distinct_tools(tools: &[Tool]) -> Result<(), CatalogError> { - match first_repeat(tools.iter().map(Tool::name)) { - Some(name) => Err(CatalogError::DuplicateName { - owner: "tool", - scope: "server", - name: String::from(name), - }), - None => Ok(()), - } -} - -fn distinct_servers(servers: &[CatalogServer]) -> Result<(), CatalogError> { - match first_repeat(servers.iter().map(CatalogServer::name)) { - Some(name) => Err(CatalogError::DuplicateName { - owner: "server", - scope: "snapshot", - name: String::from(name), - }), - None => Ok(()), - } -} - -/// Reads a tool name, refusing an empty one. -fn tool_name<'de, D: Deserializer<'de>>(deserializer: D) -> Result { - non_empty(String::deserialize(deserializer)?, "tool").map_err(D::Error::custom) -} - -/// Reads a server name, refusing an empty one. -fn server_name<'de, D: Deserializer<'de>>(deserializer: D) -> Result { - non_empty(String::deserialize(deserializer)?, "server").map_err(D::Error::custom) -} - -/// Reads the tools of a server, refusing a repeated name. -fn distinct_tools_of<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { - let tools = Vec::::deserialize(deserializer)?; - distinct_tools(&tools).map_err(D::Error::custom)?; - Ok(tools) -} - -/// Reads an optional field, refusing an explicit `null`. -/// -/// Used with `#[serde(default)]`, so that an absent field is `None` and a present one is `Some`. -fn present<'de, D, T>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, - T: Deserialize<'de>, -{ - match Option::::deserialize(deserializer)? { - Some(value) => Ok(Some(value)), - None => Err(D::Error::custom(CatalogError::Null)), - } -} - -/// The constant `schema` field of a snapshot. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -struct SchemaTag; - -impl Serialize for SchemaTag { - fn serialize(&self, serializer: S) -> Result { - serializer.serialize_str(SCHEMA_TAG) - } -} - -impl JsonSchema for SchemaTag { - fn schema_name() -> Cow<'static, str> { - "SchemaTag".into() - } - - fn inline_schema() -> bool { - true - } - - fn json_schema(_generator: &mut SchemaGenerator) -> Schema { - json_schema!({ - "type": "string", - "const": SCHEMA_TAG, - }) - } -} - -/// How a client reaches an MCP server. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] -#[serde(rename_all = "lowercase")] -#[non_exhaustive] -pub enum Transport { - /// The server runs as a subprocess and is spoken to over its standard input and output. - Stdio, - /// The server is reached over streamable HTTP. - Http, - /// The server is reached over server-sent events. - Sse, -} - -/// A tool in MCP `tools/list` shape: the named keys of the MCP `Tool` definition, and every other key as the server gave it. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] -#[serde(rename_all = "camelCase")] -#[schemars(extend("additionalProperties" = true))] -#[non_exhaustive] -pub struct Tool { - /// The name of the tool, as the server gave it: at least one character, and unique among the tools of its server. - #[serde(deserialize_with = "tool_name")] - #[schemars(length(min = 1))] - name: String, - /// A human-readable title of the tool. - #[serde( - default, - deserialize_with = "present", - skip_serializing_if = "Option::is_none" - )] - title: Option, - /// A human-readable description of the tool. - #[serde( - default, - deserialize_with = "present", - skip_serializing_if = "Option::is_none" - )] - description: Option, - /// The JSON Schema object that describes the arguments of the tool. Its `type` is not required to be `object`. - input_schema: Map, - /// The JSON Schema object that describes the structured output of the tool. - #[serde( - default, - deserialize_with = "present", - skip_serializing_if = "Option::is_none" - )] - output_schema: Option>, - /// Hints about the behaviour of the tool: an open object whose keys are kept as given. - #[serde( - default, - deserialize_with = "present", - skip_serializing_if = "Option::is_none" - )] - annotations: Option>, - // Every key that is not named above, as given. - #[serde(flatten)] - extra: Map, -} - -impl Tool { - /// Builds a tool with the two keys MCP requires. - /// - /// # Errors - /// Returns [`CatalogError::EmptyName`] if `name` is empty. - pub fn new(name: String, input_schema: Map) -> Result { - Ok(Self { - name: non_empty(name, "tool")?, - title: None, - description: None, - input_schema, - output_schema: None, - annotations: None, - extra: Map::new(), - }) - } - - /// Sets the human-readable title. - #[must_use] - pub fn with_title(mut self, title: String) -> Self { - self.title = Some(title); - self - } - - /// Sets the human-readable description. - #[must_use] - pub fn with_description(mut self, description: String) -> Self { - self.description = Some(description); - self - } - - /// Sets the JSON Schema object of the structured output. - #[must_use] - pub fn with_output_schema(mut self, output_schema: Map) -> Self { - self.output_schema = Some(output_schema); - self - } - - /// Sets the annotations. - #[must_use] - pub fn with_annotations(mut self, annotations: Map) -> Self { - self.annotations = Some(annotations); - self - } - - /// Adds a key the tool keeps as given, replacing an earlier value of the same key. - /// - /// # Errors - /// Returns [`CatalogError::ReservedKey`] if `key` is the name of a field of the tool. - pub fn with_extra(mut self, key: String, value: Value) -> Result { - // BORROW: explicit .as_str() to match the key against the field names - if NAMED_TOOL_KEYS.contains(&key.as_str()) { - return Err(CatalogError::ReservedKey { key }); - } - self.extra.insert(key, value); - Ok(self) - } - - /// The name of the tool. - #[must_use] - pub const fn name<'a>(&'a self) -> &'a str { - // BORROW: explicit .as_str() instead of Deref coercion - self.name.as_str() - } - - /// The human-readable title, if the server gave one. - #[must_use] - pub fn title<'a>(&'a self) -> Option<&'a str> { - // BORROW: explicit .as_deref() instead of Deref coercion - self.title.as_deref() - } - - /// The human-readable description, if the server gave one. - #[must_use] - pub fn description<'a>(&'a self) -> Option<&'a str> { - // BORROW: explicit .as_deref() instead of Deref coercion - self.description.as_deref() - } - - /// The JSON Schema object that describes the arguments. - #[must_use] - pub const fn input_schema<'a>(&'a self) -> &'a Map { - &self.input_schema - } - - /// The JSON Schema object that describes the structured output, if the server gave one. - #[must_use] - pub const fn output_schema<'a>(&'a self) -> Option<&'a Map> { - self.output_schema.as_ref() - } - - /// The annotations, if the server gave any. - #[must_use] - pub const fn annotations<'a>(&'a self) -> Option<&'a Map> { - self.annotations.as_ref() - } - - /// The keys that are not fields of the tool, as the server gave them. - #[must_use] - pub const fn extra<'a>(&'a self) -> &'a Map { - &self.extra - } -} - -/// One MCP server of a run and the tools it offered. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] -#[serde(remote = "Self")] -#[schemars(deny_unknown_fields)] -#[non_exhaustive] -pub struct CatalogServer { - /// The name of the server: at least one character, and unique among the servers of its snapshot. - #[serde(deserialize_with = "server_name")] - #[schemars(length(min = 1))] - name: String, - /// The path of the server's source file: a POSIX path relative to the project root. - source_path: RelPath, - /// The digest of the server's source file. - source_digest: Digest, - /// How a client reaches the server. - transport: Transport, - /// The tools the server offered, with names unique among them. - #[serde(deserialize_with = "distinct_tools_of")] - #[schemars(extend( - "$comment" = "Tool names are unique within the array, compared byte for byte (case-sensitive, without Unicode normalisation); JSON Schema cannot state this, and the Rust reader refuses a repeated name." - ))] - tools: Vec, -} - -object_only!(CatalogServer); - -impl CatalogServer { - /// Builds a server entry. - /// - /// # Errors - /// Returns [`CatalogError::EmptyName`] if `name` is empty. - /// Returns [`CatalogError::DuplicateName`] if two of the tools have the same name. - pub fn new( - name: String, - source_path: RelPath, - source_digest: Digest, - transport: Transport, - tools: Vec, - ) -> Result { - distinct_tools(&tools)?; - Ok(Self { - name: non_empty(name, "server")?, - source_path, - source_digest, - transport, - tools, - }) - } - - /// The name of the server. - #[must_use] - pub const fn name<'a>(&'a self) -> &'a str { - // BORROW: explicit .as_str() instead of Deref coercion - self.name.as_str() - } - - /// The path of the server's source file. - #[must_use] - pub const fn source_path<'a>(&'a self) -> &'a RelPath { - &self.source_path - } - - /// The digest of the server's source file. - #[must_use] - pub const fn source_digest<'a>(&'a self) -> &'a Digest { - &self.source_digest - } - - /// How a client reaches the server. - #[must_use] - pub const fn transport(&self) -> Transport { - self.transport - } - - /// The tools the server offered. - #[must_use] - pub const fn tools<'a>(&'a self) -> &'a [Tool] { - // BORROW: explicit .as_slice() instead of Deref coercion - self.tools.as_slice() - } -} - -/// What the MCP servers targeted by a run offered: for each server, its tools in the shape of an MCP `tools/list` result. -#[derive(Debug, Clone, PartialEq, Serialize, JsonSchema)] -#[schemars(deny_unknown_fields)] -#[non_exhaustive] -pub struct CatalogSnapshot { - /// The version marker of the document: always `tool-catalog-snapshot/1`. - schema: SchemaTag, - /// When the snapshot was captured. - captured_at: Timestamp, - /// The catalog provider that captured the snapshot, as `name@token`. - provider: NameToken, - /// The versions the capture depended on, as an object from a name to its version text. - #[serde(skip_serializing_if = "Option::is_none")] - environment: Option>, - /// Provider-specific data: an open JSON object that Candler does not interpret. - #[serde(skip_serializing_if = "Option::is_none")] - ext: Option>, - /// The servers the run targeted, each with the tools it offered, with names unique among them. - #[schemars(extend( - "$comment" = "Server names are unique within the array, compared byte for byte (case-sensitive, without Unicode normalisation); JSON Schema cannot state this, and the Rust reader refuses a repeated name." - ))] - servers: Vec, -} - -impl CatalogSnapshot { - /// Starts a snapshot; `captured_at` and `provider` must be set before it builds. - #[must_use] - pub fn builder() -> CatalogSnapshotBuilder { - CatalogSnapshotBuilder::default() - } - - /// When the snapshot was captured. - #[must_use] - pub const fn captured_at<'a>(&'a self) -> &'a Timestamp { - &self.captured_at - } - - /// The catalog provider that captured the snapshot. - #[must_use] - pub const fn provider<'a>(&'a self) -> &'a NameToken { - &self.provider - } - - /// The versions the capture depended on, if any were recorded. - #[must_use] - pub const fn environment<'a>(&'a self) -> Option<&'a BTreeMap> { - self.environment.as_ref() - } - - /// The provider-specific data, if the provider wrote any. - #[must_use] - pub const fn ext<'a>(&'a self) -> Option<&'a Map> { - self.ext.as_ref() - } - - /// The servers the run targeted. - #[must_use] - pub const fn servers<'a>(&'a self) -> &'a [CatalogServer] { - // BORROW: explicit .as_slice() instead of Deref coercion - self.servers.as_slice() - } - - /// The content of the snapshot as RFC 8785 text, without `captured_at`, so that a capture - /// time never splits a cell. These are the bytes [`CatalogSnapshot::content_digest`] hashes. - /// - /// # Errors - /// Returns the [`CanonicalError`] of [`to_jcs`] if the snapshot has no canonical form, which an - /// integer outside ±(2^53 − 1) in `ext` causes: the snapshot reader does not check numbers. - pub fn content_text(&self) -> Result { - let mut json = serde_json::to_value(self).map_err(|e| CanonicalError::Syntax { - detail: e.to_string(), - })?; - if let Value::Object(fields) = &mut json { - fields.remove("captured_at"); - } - to_jcs(&json) - } - - /// The digest of the snapshot's content: `sha256` of [`CatalogSnapshot::content_text`]. - /// - /// # Errors - /// Returns the [`CanonicalError`] of [`CatalogSnapshot::content_text`]. - pub fn content_digest(&self) -> Result { - // BORROW: explicit .as_bytes() of the canonical text, the bytes the digest hashes - Ok(Digest::of_bytes(self.content_text()?.as_bytes())) - } -} - -/// The fields of a snapshot as written, before the version marker is checked. -#[derive(Deserialize)] -struct CatalogSnapshotWire { - schema: String, - captured_at: Timestamp, - provider: NameToken, - #[serde(default, deserialize_with = "present")] - environment: Option>, - #[serde(default, deserialize_with = "present")] - ext: Option>, - servers: Vec, -} - -impl TryFrom for CatalogSnapshot { - type Error = CatalogError; - - fn try_from(wire: CatalogSnapshotWire) -> Result { - // BORROW: explicit .as_str() to compare with the tag - if wire.schema.as_str() != SCHEMA_TAG { - return Err(CatalogError::SchemaTag { value: wire.schema }); - } - distinct_servers(&wire.servers)?; - Ok(Self { - schema: SchemaTag, - captured_at: wire.captured_at, - provider: wire.provider, - environment: wire.environment, - ext: wire.ext, - servers: wire.servers, - }) - } -} - -impl<'de> Deserialize<'de> for CatalogSnapshot { - fn deserialize>(deserializer: D) -> Result { - let MapOnly(wire) = MapOnly::::deserialize(deserializer)?; - Self::try_from(wire).map_err(D::Error::custom) - } -} - -/// Builds a [`CatalogSnapshot`]. -#[derive(Debug, Clone, Default)] -#[non_exhaustive] -pub struct CatalogSnapshotBuilder { - captured_at: Option, - provider: Option, - environment: Option>, - ext: Option>, - servers: Vec, -} - -impl CatalogSnapshotBuilder { - /// Sets when the snapshot was captured. - #[must_use] - pub fn captured_at(mut self, captured_at: Timestamp) -> Self { - self.captured_at = Some(captured_at); - self - } - - /// Sets the catalog provider. - #[must_use] - pub fn provider(mut self, provider: NameToken) -> Self { - self.provider = Some(provider); - self - } - - /// Sets the versions the capture depended on. - #[must_use] - pub fn environment(mut self, environment: BTreeMap) -> Self { - self.environment = Some(environment); - self - } - - /// Sets the provider-specific data. - #[must_use] - pub fn ext(mut self, ext: Map) -> Self { - self.ext = Some(ext); - self - } - - /// Appends a server. - #[must_use] - pub fn server(mut self, server: CatalogServer) -> Self { - self.servers.push(server); - self - } - - /// Builds the snapshot. - /// - /// # Errors - /// Returns [`CatalogError::MissingField`] if `captured_at` or `provider` was not set. - /// Returns [`CatalogError::DuplicateName`] if two of the servers have the same name. - pub fn build(self) -> Result { - let captured_at = self.captured_at.ok_or(CatalogError::MissingField { - field: "captured_at", - })?; - let provider = self - .provider - .ok_or(CatalogError::MissingField { field: "provider" })?; - distinct_servers(&self.servers)?; - Ok(CatalogSnapshot { - schema: SchemaTag, - captured_at, - provider, - environment: self.environment, - ext: self.ext, - servers: self.servers, - }) - } -} - -#[cfg(test)] -mod tests { - use serde_json::json; - - use super::*; - - fn tool_value() -> Value { - json!({ - "name": "t", - "title": "T", - "description": "d", - "inputSchema": {"type": "object"}, - "outputSchema": {"type": "object"}, - "annotations": {"readOnlyHint": true}, - "icons": [], - "_meta": {"k": null}, - }) - } - - fn tool(name: &str) -> Tool { - Tool::new(String::from(name), Map::new()).expect("a tool with a name") - } - - fn server(name: &str, tools: Vec) -> Result { - CatalogServer::new( - String::from(name), - "a/b.py".parse().expect("path"), - Digest::from_hex(&"ab".repeat(32)).expect("digest"), - Transport::Stdio, - tools, - ) - } - - fn snapshot_value() -> Value { - json!({ - "schema": SCHEMA_TAG, - "captured_at": "2026-10-28T01:09:04+00:00", - "provider": "p/q@1", - "servers": [{ - "name": "s", - "source_path": "a/b.py", - "source_digest": format!("sha256:{}", "ab".repeat(32)), - "transport": "stdio", - "tools": [tool_value()], - }], - }) - } - - /// Guards: R01 §Wire encodings — a tool, a server and a snapshot are objects and never a list - /// of their values, at each level. Oracle: the object form of each is read first, then the - /// list of its values is refused. Bite: dropping `object_only!` or `MapOnly` turns the - /// server and snapshot rows red. - #[test] - fn a_struct_written_as_a_list_is_refused_at_each_level() { - // The values of `value` in the order `fields` names them, an absent field being `{}`; a - // derived reader that took a list would take it in this order. - fn listed(value: &Value, fields: &[&str]) -> Value { - Value::Array( - fields - .iter() - .map(|field| value.get(*field).cloned().unwrap_or_else(|| json!({}))) - .collect(), - ) - } - const SERVER: [&str; 5] = ["name", "source_path", "source_digest", "transport", "tools"]; - const SNAPSHOT: [&str; 6] = [ - "schema", - "captured_at", - "provider", - "environment", - "ext", - "servers", - ]; - - let tool = tool_value(); - serde_json::from_value::(tool.clone()).expect("a tool object reads"); - assert!( - serde_json::from_value::(Value::Array( - tool.as_object() - .expect("an object") - .values() - .cloned() - .collect() - )) - .is_err(), - "a tool as a list" - ); - - let snapshot = snapshot_value(); - let server_object = snapshot["servers"][0].clone(); - serde_json::from_value::(server_object.clone()) - .expect("a server object reads"); - assert!( - serde_json::from_value::(listed(&server_object, &SERVER)).is_err(), - "a server as a list" - ); - - serde_json::from_value::(snapshot.clone()) - .expect("a snapshot object reads"); - assert!( - serde_json::from_value::(listed(&snapshot, &SNAPSHOT)).is_err(), - "a snapshot as a list" - ); - - let mut nested = snapshot; - nested["servers"][0] = listed(&server_object, &SERVER); - assert!( - serde_json::from_value::(nested).is_err(), - "a server written as a list inside a snapshot" - ); - - let probe = json!([ - "tool-catalog-snapshot/1", - "2026-01-01T00:00:00Z", - "p@1", - {}, - {}, - [] - ]); - assert!( - serde_json::from_value::(probe).is_err(), - "the probe snapshot as a list" - ); - } - - #[test] - fn named_keys_are_exactly_the_fields_a_full_tool_writes() { - let tool: Tool = serde_json::from_value(tool_value()).expect("a full tool reads"); - let written = serde_json::to_value(&tool).expect("a tool writes"); - let mut named: Vec<&str> = written - .as_object() - .expect("a tool is an object") - .keys() - // BORROW: explicit .as_str() to compare with the named keys - .map(String::as_str) - .filter(|key| !tool.extra().contains_key(*key)) - .collect(); - named.sort_unstable(); - let mut expected = NAMED_TOOL_KEYS.to_vec(); - expected.sort_unstable(); - assert_eq!(named, expected); - assert_eq!(tool.extra().len(), 2); - } - - #[test] - fn a_tool_keeps_null_inside_its_values_and_extra_keys() { - let value = json!({ - "name": "t", - "inputSchema": {"default": null, "properties": {"a": {"enum": [null, 1]}}}, - "annotations": {"title": null}, - "outputSchema": {"const": null}, - "x": null, - }); - let tool: Tool = serde_json::from_value(value.clone()).expect("null is data here"); - assert_eq!(serde_json::to_value(&tool).expect("writes"), value); - assert_eq!(tool.extra().get("x"), Some(&Value::Null)); - } - - #[test] - fn a_tool_refuses_null_for_its_optional_fields() { - for key in ["title", "description", "outputSchema", "annotations"] { - let mut value = tool_value(); - value[key] = Value::Null; - let error = serde_json::from_value::(value).expect_err(key); - assert!( - error.to_string().contains("optional field is null"), - "{key}" - ); - } - } - - #[test] - fn a_tool_without_its_required_keys_is_refused() { - for key in ["name", "inputSchema"] { - let mut value = tool_value(); - value.as_object_mut().expect("object").remove(key); - assert!(serde_json::from_value::(value).is_err(), "{key}"); - } - let mut value = tool_value(); - value["inputSchema"] = json!("object"); - assert!(serde_json::from_value::(value).is_err()); - } - - #[test] - fn an_extra_key_cannot_take_the_name_of_a_field() { - for key in NAMED_TOOL_KEYS { - let result = tool("t").with_extra(String::from(key), json!(1)); - assert_eq!( - result.expect_err(key), - CatalogError::ReservedKey { - key: String::from(key) - } - ); - } - let tool = tool("t") - .with_extra(String::from("icons"), json!([])) - .expect("icons is an extra key"); - assert_eq!(tool.extra().len(), 1); - } - - #[test] - fn a_snapshot_refuses_a_foreign_tag_and_null_optionals() { - let snapshot: CatalogSnapshot = - serde_json::from_value(snapshot_value()).expect("a snapshot reads"); - assert_eq!(snapshot.servers().len(), 1); - - let mut value = snapshot_value(); - value["schema"] = json!("tool-catalog-snapshot/0"); - let error = serde_json::from_value::(value).expect_err("tag"); - assert!(error.to_string().contains("schema tag differs")); - - for key in ["environment", "ext"] { - let mut value = snapshot_value(); - value[key] = Value::Null; - let error = serde_json::from_value::(value).expect_err(key); - assert!( - error.to_string().contains("optional field is null"), - "{key}" - ); - } - } - - #[test] - fn the_builder_requires_the_capture_time_and_the_provider() { - let timestamp: Timestamp = "2026-10-28T01:09:04Z".parse().expect("timestamp"); - let provider: NameToken = "p@1".parse().expect("provider"); - assert_eq!( - CatalogSnapshot::builder() - .provider(provider.clone()) - .build() - .expect_err("no time"), - CatalogError::MissingField { - field: "captured_at" - } - ); - assert_eq!( - CatalogSnapshot::builder() - .captured_at(timestamp.clone()) - .build() - .expect_err("no provider"), - CatalogError::MissingField { field: "provider" } - ); - let built = CatalogSnapshot::builder() - .captured_at(timestamp) - .provider(provider) - .build() - .expect("minimal snapshot builds"); - assert_eq!(built.servers(), []); - assert_eq!( - serde_json::to_value(&built).expect("writes"), - json!({ - "schema": SCHEMA_TAG, - "captured_at": "2026-10-28T01:09:04Z", - "provider": "p@1", - "servers": [], - }) - ); - } - - #[test] - fn names_are_non_empty_and_unique_within_their_scope() { - assert_eq!( - Tool::new(String::new(), Map::new()).expect_err("empty tool name"), - CatalogError::EmptyName { owner: "tool" } - ); - assert_eq!( - server("", Vec::new()).expect_err("empty server name"), - CatalogError::EmptyName { owner: "server" } - ); - assert_eq!( - server("s", vec![tool("a"), tool("b"), tool("a")]).expect_err("repeated tool"), - CatalogError::DuplicateName { - owner: "tool", - scope: "server", - name: String::from("a") - } - ); - let timestamp: Timestamp = "2026-10-28T01:09:04Z".parse().expect("timestamp"); - let provider: NameToken = "p@1".parse().expect("provider"); - let repeated = CatalogSnapshot::builder() - .captured_at(timestamp) - .provider(provider) - .server(server("s", vec![tool("a")]).expect("server")) - .server(server("s", vec![tool("b")]).expect("server")) - .build() - .expect_err("repeated server"); - assert_eq!( - repeated, - CatalogError::DuplicateName { - owner: "server", - scope: "snapshot", - name: String::from("s") - } - ); - // The same name in different scopes is allowed. - server("s", vec![tool("a")]).expect("tool names repeat across servers"); - } - - #[test] - fn the_reader_refuses_empty_and_repeated_names() { - let mut empty_tool = tool_value(); - empty_tool["name"] = json!(""); - assert!(serde_json::from_value::(empty_tool).is_err()); - - let mut value = snapshot_value(); - value["servers"][0]["name"] = json!(""); - let error = serde_json::from_value::(value).expect_err("empty server"); - assert!(error.to_string().contains("server name is empty")); - - let mut value = snapshot_value(); - value["servers"][0]["tools"] = json!([tool_value(), tool_value()]); - let error = serde_json::from_value::(value).expect_err("repeated tool"); - assert!(error.to_string().contains("tool name is repeated")); - - let mut value = snapshot_value(); - let first = value["servers"][0].clone(); - value["servers"] = json!([first.clone(), first]); - let error = serde_json::from_value::(value).expect_err("repeated server"); - assert!(error.to_string().contains("server name is repeated")); - } - - #[test] - fn every_error_has_its_wording() { - let cases = [ - ( - CatalogError::SchemaTag { - value: String::from("x/1"), - }, - r#"schema tag differs from `tool-catalog-snapshot/1` (got "x/1")"#, - ), - ( - CatalogError::MissingField { field: "provider" }, - "snapshot field is missing (`provider` was not set)", - ), - ( - CatalogError::ReservedKey { - key: String::from("name"), - }, - r#"tool extra key names a field of the tool (got "name")"#, - ), - ( - CatalogError::Null, - "optional field is null (an absent field is omitted)", - ), - ( - CatalogError::EmptyName { owner: "server" }, - "server name is empty (names have at least one character)", - ), - ( - CatalogError::DuplicateName { - owner: "tool", - scope: "server", - name: String::from("a"), - }, - r#"tool name is repeated within a server (got "a")"#, - ), - ]; - for (error, text) in cases { - assert_eq!(error.to_string(), text); - } - } -} diff --git a/crates/candler-schemas/src/execution.rs b/crates/candler-schemas/src/execution.rs index 42eaeee5..cb1d8165 100644 --- a/crates/candler-schemas/src/execution.rs +++ b/crates/candler-schemas/src/execution.rs @@ -1883,11 +1883,17 @@ struct ComparableBody<'a> { values: &'a [ResolvedValue], harness: &'a HarnessIdentity, treatment: &'a TreatmentRef, + #[serde(skip_serializing_if = "no_digests")] snapshots: &'a [DigestRef], inputs: &'a [DigestRef], environments: &'a [EnvironmentRef], } +/// Reports whether `list` holds no digest: an empty list is left out of the hash and of the record. +fn no_digests(list: &&[DigestRef]) -> bool { + list.is_empty() +} + /// Checks that `items` rise strictly by `key`: an equal neighbour is a duplicate, a lower one is out of order. fn check_ascending<'a, T, K: Ord>( list: &'static str, @@ -1934,7 +1940,9 @@ struct RawComparable { harness: HarnessIdentity, /// The treatment the run applied. treatment: TreatmentRef, - /// The digests of the catalog snapshots, sorted by kind and digest. + /// The digests of the catalog snapshots, sorted by kind and digest. A cell without catalog + /// snapshots leaves the list out, and the hash leaves it out too. + #[serde(default)] #[schemars(extend( "$comment" = "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not." ))] @@ -1975,6 +1983,7 @@ pub struct Comparable { values: Vec, harness: HarnessIdentity, treatment: TreatmentRef, + #[serde(skip_serializing_if = "Vec::is_empty")] snapshots: Vec, inputs: Vec, environments: Vec, diff --git a/crates/candler-schemas/src/generate.rs b/crates/candler-schemas/src/generate.rs index 67fccd2c..a004297c 100644 --- a/crates/candler-schemas/src/generate.rs +++ b/crates/candler-schemas/src/generate.rs @@ -15,8 +15,6 @@ use schemars::transform::{Transform, transform_subschemas}; use schemars::{JsonSchema, Schema}; use serde_json::{Map, Value, json}; -use crate::catalog::CatalogSnapshot; - /// The extension every generated schema file carries. const FILE_SUFFIX: &str = ".schema.json"; @@ -62,10 +60,9 @@ impl GeneratedSchema { #[must_use] pub fn generated_schemas() -> Vec { let modules = [ - vec![ - GeneratedSchema::of::("catalog-snapshot"), - GeneratedSchema::of::("outcome-record"), - ], + vec![GeneratedSchema::of::( + "outcome-record", + )], crate::values::roots(), crate::canonical::roots(), crate::container::roots(), diff --git a/crates/candler-schemas/src/inspect.rs b/crates/candler-schemas/src/inspect.rs index 2cc356bc..a33c1949 100644 --- a/crates/candler-schemas/src/inspect.rs +++ b/crates/candler-schemas/src/inspect.rs @@ -70,10 +70,9 @@ pub struct InspectRun { /// What the run was imported from, for an imported run. #[serde(default, skip_serializing_if = "Option::is_none")] pub import: Option, - /// The tool catalog the run ran with, as the run stored it: the canonical form of the - /// snapshot without `captured_at`. Absent when the run has no stored snapshot. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub catalog: Option, + /// The resolved `mcp.*` values the cell hashes, by path: the MCP configuration the run was + /// installed with. + pub mcp: BTreeMap, /// The measured values under `provenance.`, by path. pub provenance: BTreeMap, /// The other measured values, by path. diff --git a/crates/candler-schemas/src/lib.rs b/crates/candler-schemas/src/lib.rs index d5a44266..29aaf6dd 100644 --- a/crates/candler-schemas/src/lib.rs +++ b/crates/candler-schemas/src/lib.rs @@ -1,6 +1,6 @@ //! Candler wire schemas: the string formats every record shares in [`primitives`], the analysis //! report in [`analysis`], the outcome -//! record in [`outcome`], the tool-catalog snapshot in [`catalog`], resolved values in [`values`], +//! record in [`outcome`], resolved values in [`values`], //! canonical JSON in [`canonical`], process records in [`process`], container records in //! [`container`], raw frames in [`raw`], the normalised trace in [`trace`], execution records in //! [`execution`], the MCP servers in [`servers`], evaluator protocol records in [`evaluation`], stable refusal codes in [`refusal`], and in [`generate`] the JSON Schema @@ -14,7 +14,6 @@ pub mod analysis; pub mod canonical; -pub mod catalog; pub mod container; pub mod distinct; pub mod evaluation; diff --git a/crates/candler-schemas/src/primitives.rs b/crates/candler-schemas/src/primitives.rs index 93cbe780..601cbf3a 100644 --- a/crates/candler-schemas/src/primitives.rs +++ b/crates/candler-schemas/src/primitives.rs @@ -736,7 +736,7 @@ impl FromStr for NameVersion { } text_type!(NameToken { - description: "A catalog provider reference, `name@token`, split at the last `@`: the name is non-empty and holds neither `@` nor white space, and the token matches `[0-9A-Za-z.+-]+`.", + description: "A name and a version token, `name@token`, split at the last `@`: the name is non-empty and holds neither `@` nor white space, and the token matches `[0-9A-Za-z.+-]+`.", pattern: NAME_TOKEN_PATTERN, fields: { name: String, version: String }, }); diff --git a/crates/candler-schemas/src/refusal.rs b/crates/candler-schemas/src/refusal.rs index 118c9cd7..b6a781e2 100644 --- a/crates/candler-schemas/src/refusal.rs +++ b/crates/candler-schemas/src/refusal.rs @@ -418,13 +418,12 @@ macro_rules! refusal_table { /// The rows of every refusal of this crate, in the order of the types. #[must_use] pub fn catalog() -> Vec { - let tables: [&'static [CatalogRow]; 9] = [ + let tables: [&'static [CatalogRow]; 8] = [ ::rows(), ::rows(), ::rows(), ::rows(), ::rows(), - ::rows(), ::rows(), ::rows(), ::rows(), diff --git a/crates/candler-schemas/src/refusal_impls.rs b/crates/candler-schemas/src/refusal_impls.rs index 4b5eb29c..884d5b6c 100644 --- a/crates/candler-schemas/src/refusal_impls.rs +++ b/crates/candler-schemas/src/refusal_impls.rs @@ -7,7 +7,6 @@ //! checks the two against each other. use crate::canonical::CanonicalError; -use crate::catalog::CatalogError; use crate::evaluation::{EvaluationError, VersionMismatch}; use crate::execution::ExecutionError; use crate::outcome::OutcomeError; @@ -639,55 +638,3 @@ fn non_root(path: &str) -> Option { Some(path.to_owned()) } } - -/// A wrong tag sits in the `schema` field; the other faults name no place. -fn catalog_path(error: &CatalogError) -> Option { - match error { - CatalogError::SchemaTag { .. } => Some(pointer_of(["schema"])), - CatalogError::MissingField { .. } - | CatalogError::ReservedKey { .. } - | CatalogError::Null - | CatalogError::EmptyName { .. } - | CatalogError::DuplicateName { .. } => None, - } -} - -refusal_table! { - CatalogError, path = catalog_path; - SchemaTag { .. } => row( - "catalog.schema_tag_mismatch", - Side::Environment, - "The tool catalog an image prints carries another `schema` marker than `tool-catalog-snapshot/1`.", - "`/schema`", - ), - MissingField { .. } => row( - "catalog.field_unset", - Side::Candler, - "A builder of a catalog snapshot was asked to build before a required field was set.", - "-", - ), - ReservedKey { .. } => row( - "catalog.extra_key_reserved", - Side::Candler, - "An extra key of a tool is the name of one of the tool's fields.", - "-", - ), - Null { .. } => row( - "catalog.field_null", - Side::Candler, - "An optional field of a catalog was written as null instead of being omitted.", - "-", - ), - EmptyName { .. } => row( - "catalog.name_empty", - Side::Environment, - "A server or tool name in the catalog an image prints is empty.", - "-", - ), - DuplicateName { .. } => row( - "catalog.name_repeated", - Side::Environment, - "A server or tool name in the catalog an image prints is repeated within its scope.", - "-", - ), -} diff --git a/crates/candler-schemas/tests/fixtures/spec/LICENSE b/crates/candler-schemas/tests/fixtures/spec/LICENSE deleted file mode 100644 index 4a939857..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/LICENSE +++ /dev/null @@ -1,216 +0,0 @@ -The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0. - -Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License. - -No rights beyond those granted by the applicable original license are conveyed for such contributions. - ---- - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to the Licensor for inclusion in the Work by the copyright - owner or by an individual or Legal Entity authorized to submit on behalf - of the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - ---- - -MIT License - -Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - ---- - -Creative Commons Attribution 4.0 International (CC-BY-4.0) - -Documentation in this project (excluding specifications) is licensed under -CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for -the full license text. diff --git a/crates/candler-schemas/tests/fixtures/spec/README.md b/crates/candler-schemas/tests/fixtures/spec/README.md deleted file mode 100644 index 0f6e529b..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# MCP specification fixtures - -The `Tool` definition of the latest published MCP specification, and tool objects the specification -gives as examples. They are inputs to the catalog snapshot tests: every tool here is a valid MCP tool -object, so a snapshot schema that rejects one is too strict. - -## Provenance - -| | | -|---|---| -| Repository | `modelcontextprotocol/modelcontextprotocol` (GitHub) | -| Commit | `ccaf9102ec5eb656eab50ca8333ef49dcd259c26` (`main`, 2026-10-27T17:10:04Z) | -| Version | `2026-07-28`, the latest dated version under `schema/` that is not `draft` | -| Fetched with | `gh api -H 'Accept: application/vnd.github.raw+json' 'repos/modelcontextprotocol/modelcontextprotocol/contents/?ref=ccaf9102ec5eb656eab50ca8333ef49dcd259c26'` | -| Licence | `LICENSE` of the repository, vendored here. The project is moving from MIT to Apache-2.0: new code and specification contributions are Apache-2.0, documentation outside the specification is CC-BY-4.0, and contributions without relicensing consent stay MIT. | - -## Files - -| File | Source path at the commit | Blob | Size | -|---|---|---|---:| -| `mcp-2026-07-28.schema.json` | `schema/2026-07-28/schema.json` | `213c58f6d9a1c2ce6ad055afe90bbdb095a29ee8` | 181,474 B | -| `LICENSE` | `LICENSE` | `4a93985763241755401a10678395303de4e720ba` | 12,227 B | - -`mcp-2026-07-28.schema.json` is JSON Schema 2020-12. Its `$defs.Tool` has the properties `_meta`, -`annotations`, `description`, `icons`, `inputSchema`, `name`, `outputSchema` and `title`; `inputSchema` -and `name` are required. `inputSchema` and `outputSchema` are open objects: `outputSchema` may -be any JSON Schema, an array schema included. - -## `tools/` - -One file per distinct tool example in the specification. Files taken from the schema examples are -byte for byte; files taken from the documentation are the JSON block of the page, re-indented with -two spaces. - -| File | Origin | Blob of the source file | -|---|---|---| -| `tool-with-array-output-schema.json` | `schema/2026-07-28/examples/Tool/tool-with-array-output-schema.json` | `8c7edec6237a12b1c76fb3af13c9430212840306` | -| `tool-with-composition-input-schema.json` | `schema/2026-07-28/examples/Tool/tool-with-composition-input-schema.json` | `7c7253af9f356759cff39c8f9746dfa16c212a8b` | -| `with-default-2020-12-input-schema.json` | `schema/2026-07-28/examples/Tool/with-default-2020-12-input-schema.json` | `d79a00eeaa7cca70a61a9606148ec5ee433d2512` | -| `with-explicit-draft-07-input-schema.json` | `schema/2026-07-28/examples/Tool/with-explicit-draft-07-input-schema.json` | `698d95b86549291e0acde11955f64e60b6e7eb71` | -| `with-no-parameters.json` | `schema/2026-07-28/examples/Tool/with-no-parameters.json` | `04a3a4e956385db9a7a0533f97351dc1f2a14d20` | -| `with-output-schema-for-structured-content.json` | `schema/2026-07-28/examples/Tool/with-output-schema-for-structured-content.json` | `a1469834247527890c22f3e23ec3015ca44910b8` | -| `docs-get-weather-with-icons.json` | `docs/specification/2026-07-28/server/tools.mdx`, the `tools/list` response (also in `examples/ListToolsResult/`) | `449020f54a6582122607b4869129bec5f1035f37` | -| `docs-execute-sql-x-mcp-header.json` | `tools.mdx`, "Example tool definition with `x-mcp-header`" | same | -| `docs-list-users-array-output.json` | `tools.mdx`, "Example tool with array output schema" (the schema example of the same name carries property descriptions; this one does not) | same | -| `full.json` | Written from `$defs.Tool`: every property of `Tool`, every property of `ToolAnnotations` and of `Icon`, and a `_meta` with two valid keys | none | - -The other tool blocks of `tools.mdx` (`get_weather_data`, `calculate_sum` twice, `get_current_time`) -equal the schema examples above and are not repeated. - -Check: `for f in tools/*.json; do jq -e .name "$f" >/dev/null || exit 1; done`. diff --git a/crates/candler-schemas/tests/fixtures/spec/mcp-2026-07-28.schema.json b/crates/candler-schemas/tests/fixtures/spec/mcp-2026-07-28.schema.json deleted file mode 100644 index 213c58f6..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/mcp-2026-07-28.schema.json +++ /dev/null @@ -1,3963 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$defs": { - "Annotations": { - "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", - "properties": { - "audience": { - "description": "Describes who the intended audience of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).", - "items": { - "$ref": "#/$defs/Role" - }, - "type": "array" - }, - "lastModified": { - "description": "The moment the resource was last modified, as an ISO 8601 formatted string.\n\nShould be an ISO 8601 formatted string (e.g., \"2025-01-12T15:00:58Z\").\n\nExamples: last activity timestamp in an open file, timestamp when the resource\nwas attached, etc.", - "type": "string" - }, - "priority": { - "description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.", - "maximum": 1, - "minimum": 0, - "type": "number" - } - }, - "type": "object" - }, - "AudioContent": { - "description": "Audio provided to or from an LLM.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "data": { - "description": "The base64-encoded audio data.", - "format": "byte", - "type": "string" - }, - "mimeType": { - "description": "The MIME type of the audio. Different providers may support different audio types.", - "type": "string" - }, - "type": { - "const": "audio", - "type": "string" - } - }, - "required": [ - "data", - "mimeType", - "type" - ], - "type": "object" - }, - "BaseMetadata": { - "description": "Base interface for metadata with name (identifier) and title (display name) properties.", - "properties": { - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "BlobResourceContents": { - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "blob": { - "description": "A base64-encoded string representing the binary data of the item.", - "format": "byte", - "type": "string" - }, - "mimeType": { - "description": "The MIME type of this resource, if known.", - "type": "string" - }, - "uri": { - "description": "The URI of this resource.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "blob", - "uri" - ], - "type": "object" - }, - "BooleanSchema": { - "properties": { - "default": { - "type": "boolean" - }, - "description": { - "type": "string" - }, - "title": { - "type": "string" - }, - "type": { - "const": "boolean", - "type": "string" - } - }, - "required": [ - "type" - ], - "type": "object" - }, - "CacheableResult": { - "description": "A result that supports a time-to-live (TTL) hint for client-side caching.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "resultType", - "ttlMs" - ], - "type": "object" - }, - "CallToolRequest": { - "description": "Used by the client to invoke a tool provided by the server.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "tools/call", - "type": "string" - }, - "params": { - "$ref": "#/$defs/CallToolRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "CallToolRequestParams": { - "description": "Parameters for a `tools/call` request.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "arguments": { - "additionalProperties": {}, - "description": "Arguments to use for the tool call.", - "type": "object" - }, - "inputResponses": { - "$ref": "#/$defs/InputResponses" - }, - "name": { - "description": "The name of the tool.", - "type": "string" - }, - "requestState": { - "type": "string" - } - }, - "required": [ - "_meta", - "name" - ], - "type": "object" - }, - "CallToolResult": { - "description": "The result returned by the server for a {@link CallToolRequesttools/call} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "content": { - "description": "A list of content objects that represent the unstructured result of the tool call.", - "items": { - "$ref": "#/$defs/ContentBlock" - }, - "type": "array" - }, - "isError": { - "description": "Whether the tool call ended in an error.\n\nIf not set, this is assumed to be false (the call was successful).\n\nAny errors that originate from the tool SHOULD be reported inside the result\nobject, with `isError` set to true, _not_ as an MCP protocol-level error\nresponse. Otherwise, the LLM would not be able to see that an error occurred\nand self-correct.\n\nHowever, any errors in _finding_ the tool, an error indicating that the\nserver does not support tool calls, or any other exceptional conditions,\nshould be reported as an MCP error response.", - "type": "boolean" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "structuredContent": { - "description": "An optional JSON value that represents the structured result of the tool call.\n\nThis can be any JSON value (object, array, string, number, boolean, or null)\nthat conforms to the tool's outputSchema if one is defined." - } - }, - "required": [ - "content", - "resultType" - ], - "type": "object" - }, - "CallToolResultResponse": { - "description": "A successful response from the server for a {@link CallToolRequesttools/call} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "anyOf": [ - { - "$ref": "#/$defs/InputRequiredResult" - }, - { - "$ref": "#/$defs/CallToolResult" - } - ] - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "CancelledNotification": { - "description": "This notification is sent by the client to indicate that it is cancelling a request it previously issued.\n\nOn stdio, the server also sends this notification, solely to terminate a {@link SubscriptionsListenRequestsubscriptions/listen} stream: it references the ID of the `subscriptions/listen` request that opened the stream. Servers MUST NOT use this notification to cancel any other request.\n\nThe request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.\n\nThis notification indicates that the result will be unused, so any associated processing SHOULD cease.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/cancelled", - "type": "string" - }, - "params": { - "$ref": "#/$defs/CancelledNotificationParams" - } - }, - "required": [ - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "CancelledNotificationParams": { - "description": "Parameters for a `notifications/cancelled` notification.", - "properties": { - "_meta": { - "$ref": "#/$defs/NotificationMetaObject" - }, - "reason": { - "description": "An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.", - "type": "string" - }, - "requestId": { - "$ref": "#/$defs/RequestId", - "description": "The ID of the request to cancel.\n\nThis MUST correspond to the ID of a request the client previously issued." - } - }, - "required": [ - "requestId" - ], - "type": "object" - }, - "ClientCapabilities": { - "description": "Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.", - "properties": { - "elicitation": { - "description": "Present if the client supports elicitation from the server.", - "properties": { - "form": { - "$ref": "#/$defs/JSONObject" - }, - "url": { - "$ref": "#/$defs/JSONObject" - } - }, - "type": "object" - }, - "experimental": { - "additionalProperties": { - "$ref": "#/$defs/JSONObject" - }, - "description": "Experimental, non-standard capabilities that the client supports.", - "type": "object" - }, - "extensions": { - "additionalProperties": { - "$ref": "#/$defs/JSONObject" - }, - "description": "Optional MCP extensions that the client supports. Keys are extension identifiers\n(e.g., \"io.modelcontextprotocol/oauth-client-credentials\"), and values are\nper-extension settings objects. An empty object indicates support with no settings.\n\nKeys MUST follow the {@link MetaObject`_meta` key naming rules}, with a\nmandatory prefix.", - "type": "object" - }, - "roots": { - "description": "Present if the client supports listing roots.", - "properties": {}, - "type": "object" - }, - "sampling": { - "description": "Present if the client supports sampling from an LLM.", - "properties": { - "context": { - "$ref": "#/$defs/JSONObject", - "description": "Whether the client supports context inclusion via `includeContext` parameter.\nIf not declared, servers SHOULD only use `includeContext: \"none\"` (or omit it)." - }, - "tools": { - "$ref": "#/$defs/JSONObject", - "description": "Whether the client supports tool use via `tools` and `toolChoice` parameters." - } - }, - "type": "object" - } - }, - "type": "object" - }, - "ClientNotification": { - "description": "This notification is sent by the client to indicate that it is cancelling a request it previously issued.\n\nOn stdio, the server also sends this notification, solely to terminate a {@link SubscriptionsListenRequestsubscriptions/listen} stream: it references the ID of the `subscriptions/listen` request that opened the stream. Servers MUST NOT use this notification to cancel any other request.\n\nThe request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.\n\nThis notification indicates that the result will be unused, so any associated processing SHOULD cease.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/cancelled", - "type": "string" - }, - "params": { - "$ref": "#/$defs/CancelledNotificationParams" - } - }, - "required": [ - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ClientRequest": { - "anyOf": [ - { - "$ref": "#/$defs/DiscoverRequest" - }, - { - "$ref": "#/$defs/ListResourcesRequest" - }, - { - "$ref": "#/$defs/ListResourceTemplatesRequest" - }, - { - "$ref": "#/$defs/ReadResourceRequest" - }, - { - "$ref": "#/$defs/SubscriptionsListenRequest" - }, - { - "$ref": "#/$defs/ListPromptsRequest" - }, - { - "$ref": "#/$defs/GetPromptRequest" - }, - { - "$ref": "#/$defs/ListToolsRequest" - }, - { - "$ref": "#/$defs/CallToolRequest" - }, - { - "$ref": "#/$defs/CompleteRequest" - } - ] - }, - "ClientResult": { - "$ref": "#/$defs/Result", - "description": "Common result fields." - }, - "CompleteRequest": { - "description": "A request from the client to the server, to ask for completion options.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "completion/complete", - "type": "string" - }, - "params": { - "$ref": "#/$defs/CompleteRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "CompleteRequestParams": { - "description": "Parameters for a `completion/complete` request.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "argument": { - "description": "The argument's information", - "properties": { - "name": { - "description": "The name of the argument", - "type": "string" - }, - "value": { - "description": "The value of the argument to use for completion matching.", - "type": "string" - } - }, - "required": [ - "name", - "value" - ], - "type": "object" - }, - "context": { - "description": "Additional, optional context for completions", - "properties": { - "arguments": { - "additionalProperties": { - "type": "string" - }, - "description": "Previously-resolved variables in a URI template or prompt.", - "type": "object" - } - }, - "type": "object" - }, - "ref": { - "anyOf": [ - { - "$ref": "#/$defs/PromptReference" - }, - { - "$ref": "#/$defs/ResourceTemplateReference" - } - ] - } - }, - "required": [ - "_meta", - "argument", - "ref" - ], - "type": "object" - }, - "CompleteResult": { - "description": "The result returned by the server for a {@link CompleteRequestcompletion/complete} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "completion": { - "properties": { - "hasMore": { - "description": "Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.", - "type": "boolean" - }, - "total": { - "description": "The total number of completion options available. This can exceed the number of values actually sent in the response.", - "type": "integer" - }, - "values": { - "description": "An array of completion values. Must not exceed 100 items.", - "items": { - "type": "string" - }, - "maxItems": 100, - "type": "array" - } - }, - "required": [ - "values" - ], - "type": "object" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - } - }, - "required": [ - "completion", - "resultType" - ], - "type": "object" - }, - "CompleteResultResponse": { - "description": "A successful response from the server for a {@link CompleteRequestcompletion/complete} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/CompleteResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "ContentBlock": { - "anyOf": [ - { - "$ref": "#/$defs/TextContent" - }, - { - "$ref": "#/$defs/ImageContent" - }, - { - "$ref": "#/$defs/AudioContent" - }, - { - "$ref": "#/$defs/ResourceLink" - }, - { - "$ref": "#/$defs/EmbeddedResource" - } - ] - }, - "CreateMessageRequest": { - "description": "A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.", - "properties": { - "method": { - "const": "sampling/createMessage", - "type": "string" - }, - "params": { - "$ref": "#/$defs/CreateMessageRequestParams" - } - }, - "required": [ - "method", - "params" - ], - "type": "object" - }, - "CreateMessageRequestParams": { - "description": "Parameters for a `sampling/createMessage` request.", - "properties": { - "includeContext": { - "description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.\nThe client MAY ignore this request.\n\nDefault is `\"none\"`. The values `\"thisServer\"` and `\"allServers\"` are deprecated (SEP-2596): servers SHOULD\nomit this field or use `\"none\"`, and SHOULD only use the deprecated values if the client declares\n{@link ClientCapabilities.sampling.context}.", - "enum": [ - "allServers", - "none", - "thisServer" - ], - "type": "string" - }, - "maxTokens": { - "description": "The requested maximum number of tokens to sample (to prevent runaway completions).\n\nThe client MAY choose to sample fewer tokens than the requested maximum.", - "type": "integer" - }, - "messages": { - "items": { - "$ref": "#/$defs/SamplingMessage" - }, - "type": "array" - }, - "metadata": { - "$ref": "#/$defs/JSONObject", - "description": "Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific." - }, - "modelPreferences": { - "$ref": "#/$defs/ModelPreferences", - "description": "The server's preferences for which model to select. The client MAY ignore these preferences." - }, - "stopSequences": { - "items": { - "type": "string" - }, - "type": "array" - }, - "systemPrompt": { - "description": "An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.", - "type": "string" - }, - "temperature": { - "type": "number" - }, - "toolChoice": { - "$ref": "#/$defs/ToolChoice", - "description": "Controls how the model uses tools.\nThe client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared.\nDefault is `{ mode: \"auto\" }`." - }, - "tools": { - "description": "Tools that the model may use during generation.\nThe client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared.", - "items": { - "$ref": "#/$defs/Tool" - }, - "type": "array" - } - }, - "required": [ - "maxTokens", - "messages" - ], - "type": "object" - }, - "CreateMessageResult": { - "description": "The result returned by the client for a {@link CreateMessageRequestsampling/createMessage} request.\nThe client should inform the user before returning the sampled message, to allow them\nto inspect the response (human in the loop) and decide whether to allow the server to see it.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "content": { - "anyOf": [ - { - "$ref": "#/$defs/TextContent" - }, - { - "$ref": "#/$defs/ImageContent" - }, - { - "$ref": "#/$defs/AudioContent" - }, - { - "$ref": "#/$defs/ToolUseContent" - }, - { - "$ref": "#/$defs/ToolResultContent" - }, - { - "items": { - "$ref": "#/$defs/SamplingMessageContentBlock" - }, - "type": "array" - } - ] - }, - "model": { - "description": "The name of the model that generated the message.", - "type": "string" - }, - "role": { - "$ref": "#/$defs/Role" - }, - "stopReason": { - "description": "The reason why sampling stopped, if known.\n\nStandard values:\n- `\"endTurn\"`: Natural end of the assistant's turn\n- `\"stopSequence\"`: A stop sequence was encountered\n- `\"maxTokens\"`: Maximum token limit was reached\n- `\"toolUse\"`: The model wants to use one or more tools\n\nThis field is an open string to allow for provider-specific stop reasons.", - "type": "string" - } - }, - "required": [ - "content", - "model", - "role" - ], - "type": "object" - }, - "Cursor": { - "description": "An opaque token used to represent a cursor for pagination.", - "type": "string" - }, - "DiscoverRequest": { - "description": "A request from the client asking the server to advertise its supported\nprotocol versions, capabilities, and other metadata. Servers **MUST**\nimplement `server/discover`. Clients **MAY** call it but are not required\nto — version negotiation can also happen inline via per-request `_meta`.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "server/discover", - "type": "string" - }, - "params": { - "$ref": "#/$defs/RequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "DiscoverResult": { - "description": "The result returned by the server for a {@link DiscoverRequestserver/discover} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "capabilities": { - "$ref": "#/$defs/ServerCapabilities", - "description": "The capabilities of the server." - }, - "instructions": { - "description": "Natural-language guidance describing the server and its features.\n\nThis can be used by clients to improve an LLM's understanding of\navailable tools (e.g., by including it in a system prompt). It should\nfocus on information that helps the model use the server effectively\nand should not duplicate information already in tool descriptions.", - "type": "string" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "supportedVersions": { - "description": "MCP Protocol Versions this server supports. The client should choose a\nversion from this list for use in subsequent requests.", - "items": { - "type": "string" - }, - "type": "array" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "capabilities", - "resultType", - "supportedVersions", - "ttlMs" - ], - "type": "object" - }, - "DiscoverResultResponse": { - "description": "A successful response from the server for a {@link DiscoverRequestserver/discover} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/DiscoverResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "ElicitRequest": { - "description": "A request from the server to elicit additional information from the user via the client.", - "properties": { - "method": { - "const": "elicitation/create", - "type": "string" - }, - "params": { - "$ref": "#/$defs/ElicitRequestParams" - } - }, - "required": [ - "method", - "params" - ], - "type": "object" - }, - "ElicitRequestFormParams": { - "description": "The parameters for a request to elicit non-sensitive information from the user via a form in the client.", - "properties": { - "message": { - "description": "The message to present to the user describing what information is being requested.", - "type": "string" - }, - "mode": { - "const": "form", - "description": "The elicitation mode.", - "type": "string" - }, - "requestedSchema": { - "description": "A restricted subset of JSON Schema.\nOnly top-level properties are allowed, without nesting.", - "properties": { - "$schema": { - "type": "string" - }, - "properties": { - "additionalProperties": { - "$ref": "#/$defs/PrimitiveSchemaDefinition" - }, - "type": "object" - }, - "required": { - "items": { - "type": "string" - }, - "type": "array" - }, - "type": { - "const": "object", - "type": "string" - } - }, - "required": [ - "properties", - "type" - ], - "type": "object" - } - }, - "required": [ - "message", - "requestedSchema" - ], - "type": "object" - }, - "ElicitRequestParams": { - "anyOf": [ - { - "$ref": "#/$defs/ElicitRequestFormParams" - }, - { - "$ref": "#/$defs/ElicitRequestURLParams" - } - ], - "description": "The parameters for a request to elicit additional information from the user via the client." - }, - "ElicitRequestURLParams": { - "description": "The parameters for a request to elicit information from the user via a URL in the client.", - "properties": { - "message": { - "description": "The message to present to the user explaining why the interaction is needed.", - "type": "string" - }, - "mode": { - "const": "url", - "description": "The elicitation mode.", - "type": "string" - }, - "url": { - "description": "The URL that the user should navigate to.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "message", - "mode", - "url" - ], - "type": "object" - }, - "ElicitResult": { - "description": "The result returned by the client for an {@link ElicitRequestelicitation/create} request.", - "properties": { - "action": { - "description": "The user action in response to the elicitation.\n- `\"accept\"`: User submitted the form/confirmed the action\n- `\"decline\"`: User explicitly declined the action\n- `\"cancel\"`: User dismissed without making an explicit choice", - "enum": [ - "accept", - "cancel", - "decline" - ], - "type": "string" - }, - "content": { - "additionalProperties": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": [ - "string", - "integer", - "boolean" - ] - } - ] - }, - "description": "The submitted form data, only present when action is `\"accept\"` and mode was `\"form\"`.\nContains values matching the requested schema.\nOmitted for out-of-band mode responses.", - "type": "object" - } - }, - "required": [ - "action" - ], - "type": "object" - }, - "EmbeddedResource": { - "description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit\nof the LLM and/or the user.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "resource": { - "anyOf": [ - { - "$ref": "#/$defs/TextResourceContents" - }, - { - "$ref": "#/$defs/BlobResourceContents" - } - ] - }, - "type": { - "const": "resource", - "type": "string" - } - }, - "required": [ - "resource", - "type" - ], - "type": "object" - }, - "EmptyResult": { - "$ref": "#/$defs/Result", - "description": "Common result fields." - }, - "EnumSchema": { - "anyOf": [ - { - "$ref": "#/$defs/UntitledSingleSelectEnumSchema" - }, - { - "$ref": "#/$defs/TitledSingleSelectEnumSchema" - }, - { - "$ref": "#/$defs/UntitledMultiSelectEnumSchema" - }, - { - "$ref": "#/$defs/TitledMultiSelectEnumSchema" - }, - { - "$ref": "#/$defs/LegacyTitledEnumSchema" - } - ] - }, - "Error": { - "properties": { - "code": { - "description": "The error type that occurred.", - "type": "integer" - }, - "data": { - "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." - }, - "message": { - "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - } - }, - "required": [ - "code", - "message" - ], - "type": "object" - }, - "GetPromptRequest": { - "description": "Used by the client to get a prompt provided by the server.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "prompts/get", - "type": "string" - }, - "params": { - "$ref": "#/$defs/GetPromptRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "GetPromptRequestParams": { - "description": "Parameters for a `prompts/get` request.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "arguments": { - "additionalProperties": { - "type": "string" - }, - "description": "Arguments to use for templating the prompt.", - "type": "object" - }, - "inputResponses": { - "$ref": "#/$defs/InputResponses" - }, - "name": { - "description": "The name of the prompt or prompt template.", - "type": "string" - }, - "requestState": { - "type": "string" - } - }, - "required": [ - "_meta", - "name" - ], - "type": "object" - }, - "GetPromptResult": { - "description": "The result returned by the server for a {@link GetPromptRequestprompts/get} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "description": { - "description": "An optional description for the prompt.", - "type": "string" - }, - "messages": { - "items": { - "$ref": "#/$defs/PromptMessage" - }, - "type": "array" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - } - }, - "required": [ - "messages", - "resultType" - ], - "type": "object" - }, - "GetPromptResultResponse": { - "description": "A successful response from the server for a {@link GetPromptRequestprompts/get} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "anyOf": [ - { - "$ref": "#/$defs/InputRequiredResult" - }, - { - "$ref": "#/$defs/GetPromptResult" - } - ] - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "HeaderMismatchError": { - "description": "Returned when a server rejects a request because the values in the HTTP\nheaders do not match the corresponding values in the request body, or\nbecause required headers are missing or malformed. For HTTP, the response\nstatus code MUST be `400 Bad Request`.", - "properties": { - "error": { - "allOf": [ - { - "$ref": "#/$defs/Error" - }, - { - "properties": { - "code": { - "const": -32020, - "type": "integer" - } - }, - "required": [ - "code" - ], - "type": "object" - } - ] - }, - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - } - }, - "required": [ - "error", - "jsonrpc" - ], - "type": "object" - }, - "Icon": { - "description": "An optionally-sized icon that can be displayed in a user interface.", - "properties": { - "mimeType": { - "description": "Optional MIME type override if the source MIME type is missing or generic.\nFor example: `\"image/png\"`, `\"image/jpeg\"`, or `\"image/svg+xml\"`.", - "type": "string" - }, - "sizes": { - "description": "Optional array of strings that specify sizes at which the icon can be used.\nEach string should be in WxH format (e.g., `\"48x48\"`, `\"96x96\"`) or `\"any\"` for scalable formats like SVG.\n\nIf not provided, the client should assume that the icon can be used at any size.", - "items": { - "type": "string" - }, - "type": "array" - }, - "src": { - "description": "A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a\n`data:` URI with Base64-encoded image data.\n\nConsumers SHOULD take steps to ensure URLs serving icons are from the\nsame domain as the client/server or a trusted domain.\n\nConsumers SHOULD take appropriate precautions when consuming SVGs as they can contain\nexecutable JavaScript.", - "format": "uri", - "type": "string" - }, - "theme": { - "description": "Optional specifier for the theme this icon is designed for. `\"light\"` indicates\nthe icon is designed to be used with a light background, and `\"dark\"` indicates\nthe icon is designed to be used with a dark background.\n\nIf not provided, the client should assume the icon can be used with any theme.", - "enum": [ - "dark", - "light" - ], - "type": "string" - } - }, - "required": [ - "src" - ], - "type": "object" - }, - "Icons": { - "description": "Base interface to add `icons` property.", - "properties": { - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - } - }, - "type": "object" - }, - "ImageContent": { - "description": "An image provided to or from an LLM.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "data": { - "description": "The base64-encoded image data.", - "format": "byte", - "type": "string" - }, - "mimeType": { - "description": "The MIME type of the image. Different providers may support different image types.", - "type": "string" - }, - "type": { - "const": "image", - "type": "string" - } - }, - "required": [ - "data", - "mimeType", - "type" - ], - "type": "object" - }, - "Implementation": { - "description": "Describes the MCP implementation.", - "properties": { - "description": { - "description": "An optional human-readable description of what this implementation does.\n\nThis can be used by clients or servers to provide context about their purpose\nand capabilities. For example, a server might describe the types of resources\nor tools it provides, while a client might describe its intended use case.", - "type": "string" - }, - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - }, - "version": { - "description": "The version of this implementation.", - "type": "string" - }, - "websiteUrl": { - "description": "An optional URL of the website for this implementation.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "name", - "version" - ], - "type": "object" - }, - "InputRequest": { - "anyOf": [ - { - "$ref": "#/$defs/CreateMessageRequest" - }, - { - "$ref": "#/$defs/ListRootsRequest" - }, - { - "$ref": "#/$defs/ElicitRequest" - } - ] - }, - "InputRequests": { - "additionalProperties": { - "$ref": "#/$defs/InputRequest" - }, - "description": "A map of server-initiated requests that the client must fulfill.\nKeys are server-assigned identifiers; values are the request objects.", - "type": "object" - }, - "InputRequiredResult": { - "description": "An InputRequiredResult sent by the server to indicate that additional input is needed\nbefore the request can be completed.\n\nAt least one of `inputRequests` or `requestState` MUST be present.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "inputRequests": { - "$ref": "#/$defs/InputRequests" - }, - "requestState": { - "type": "string" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - } - }, - "required": [ - "resultType" - ], - "type": "object" - }, - "InputResponse": { - "anyOf": [ - { - "$ref": "#/$defs/CreateMessageResult" - }, - { - "$ref": "#/$defs/ListRootsResult" - }, - { - "$ref": "#/$defs/ElicitResult" - } - ] - }, - "InputResponseRequestParams": { - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "inputResponses": { - "$ref": "#/$defs/InputResponses" - }, - "requestState": { - "type": "string" - } - }, - "required": [ - "_meta" - ], - "type": "object" - }, - "InputResponses": { - "additionalProperties": { - "$ref": "#/$defs/InputResponse" - }, - "description": "A map of client responses to server-initiated requests.\nKeys correspond to the keys in the {@link InputRequests} map;\nvalues are the client's result for each request.", - "type": "object" - }, - "InternalError": { - "description": "A JSON-RPC error indicating that an internal error occurred on the receiver. This error is returned when the receiver encounters an unexpected condition that prevents it from fulfilling the request.", - "properties": { - "code": { - "const": -32603, - "description": "The error type that occurred.", - "type": "integer" - }, - "data": { - "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." - }, - "message": { - "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - } - }, - "required": [ - "code", - "message" - ], - "type": "object" - }, - "InvalidParamsError": { - "description": "A JSON-RPC error indicating that the method parameters are invalid or malformed.\n\nIn MCP, this error is returned in various contexts when request parameters fail validation:\n\n- **Tools**: Unknown tool name or invalid tool arguments\n- **Prompts**: Unknown prompt name or missing required arguments\n- **Pagination**: Invalid or expired cursor values\n- **Logging**: Invalid log level\n- **Elicitation**: Server requests an elicitation mode not declared in client capabilities\n- **Sampling**: Missing tool result or tool results mixed with other content", - "properties": { - "code": { - "const": -32602, - "description": "The error type that occurred.", - "type": "integer" - }, - "data": { - "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." - }, - "message": { - "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - } - }, - "required": [ - "code", - "message" - ], - "type": "object" - }, - "InvalidRequestError": { - "description": "A JSON-RPC error indicating that the request is not a valid request object. This error is returned when the message structure does not conform to the JSON-RPC 2.0 specification requirements for a request (e.g., missing required fields like `jsonrpc` or `method`, or using invalid types for these fields).", - "properties": { - "code": { - "const": -32600, - "description": "The error type that occurred.", - "type": "integer" - }, - "data": { - "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." - }, - "message": { - "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - } - }, - "required": [ - "code", - "message" - ], - "type": "object" - }, - "JSONArray": { - "items": { - "$ref": "#/$defs/JSONValue" - }, - "type": "array" - }, - "JSONObject": { - "additionalProperties": { - "$ref": "#/$defs/JSONValue" - }, - "type": "object" - }, - "JSONRPCErrorResponse": { - "description": "A response to a request that indicates an error occurred.", - "properties": { - "error": { - "$ref": "#/$defs/Error" - }, - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - } - }, - "required": [ - "error", - "jsonrpc" - ], - "type": "object" - }, - "JSONRPCMessage": { - "anyOf": [ - { - "$ref": "#/$defs/JSONRPCRequest" - }, - { - "$ref": "#/$defs/JSONRPCNotification" - }, - { - "$ref": "#/$defs/JSONRPCResultResponse" - }, - { - "$ref": "#/$defs/JSONRPCErrorResponse" - } - ], - "description": "Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent." - }, - "JSONRPCNotification": { - "description": "A notification which does not expect a response.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "type": "string" - }, - "params": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "jsonrpc", - "method" - ], - "type": "object" - }, - "JSONRPCRequest": { - "description": "A request that expects a response.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "type": "string" - }, - "params": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "id", - "jsonrpc", - "method" - ], - "type": "object" - }, - "JSONRPCResponse": { - "anyOf": [ - { - "$ref": "#/$defs/JSONRPCResultResponse" - }, - { - "$ref": "#/$defs/JSONRPCErrorResponse" - } - ], - "description": "A response to a request, containing either the result or error." - }, - "JSONRPCResultResponse": { - "description": "A successful (non-error) response to a request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/Result" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "JSONValue": { - "anyOf": [ - { - "$ref": "#/$defs/JSONObject" - }, - { - "items": { - "$ref": "#/$defs/JSONValue" - }, - "type": "array" - }, - { - "type": [ - "string", - "integer", - "boolean" - ] - } - ] - }, - "LegacyTitledEnumSchema": { - "description": "Use {@link TitledSingleSelectEnumSchema} instead.\nThis interface will be removed in a future version.", - "properties": { - "default": { - "type": "string" - }, - "description": { - "type": "string" - }, - "enum": { - "items": { - "type": "string" - }, - "type": "array" - }, - "enumNames": { - "description": "(Legacy) Display names for enum values.\nNon-standard according to JSON schema 2020-12.", - "items": { - "type": "string" - }, - "type": "array" - }, - "title": { - "type": "string" - }, - "type": { - "const": "string", - "type": "string" - } - }, - "required": [ - "enum", - "type" - ], - "type": "object" - }, - "ListPromptsRequest": { - "description": "Sent from the client to request a list of prompts and prompt templates the server has.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "prompts/list", - "type": "string" - }, - "params": { - "$ref": "#/$defs/PaginatedRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ListPromptsResult": { - "description": "The result returned by the server for a {@link ListPromptsRequestprompts/list} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "nextCursor": { - "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", - "type": "string" - }, - "prompts": { - "items": { - "$ref": "#/$defs/Prompt" - }, - "type": "array" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "prompts", - "resultType", - "ttlMs" - ], - "type": "object" - }, - "ListPromptsResultResponse": { - "description": "A successful response from the server for a {@link ListPromptsRequestprompts/list} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/ListPromptsResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "ListResourceTemplatesRequest": { - "description": "Sent from the client to request a list of resource templates the server has.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "resources/templates/list", - "type": "string" - }, - "params": { - "$ref": "#/$defs/PaginatedRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ListResourceTemplatesResult": { - "description": "The result returned by the server for a {@link ListResourceTemplatesRequestresources/templates/list} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "nextCursor": { - "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", - "type": "string" - }, - "resourceTemplates": { - "items": { - "$ref": "#/$defs/ResourceTemplate" - }, - "type": "array" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "resourceTemplates", - "resultType", - "ttlMs" - ], - "type": "object" - }, - "ListResourceTemplatesResultResponse": { - "description": "A successful response from the server for a {@link ListResourceTemplatesRequestresources/templates/list} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/ListResourceTemplatesResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "ListResourcesRequest": { - "description": "Sent from the client to request a list of resources the server has.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "resources/list", - "type": "string" - }, - "params": { - "$ref": "#/$defs/PaginatedRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ListResourcesResult": { - "description": "The result returned by the server for a {@link ListResourcesRequestresources/list} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "nextCursor": { - "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", - "type": "string" - }, - "resources": { - "items": { - "$ref": "#/$defs/Resource" - }, - "type": "array" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "resources", - "resultType", - "ttlMs" - ], - "type": "object" - }, - "ListResourcesResultResponse": { - "description": "A successful response from the server for a {@link ListResourcesRequestresources/list} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/ListResourcesResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "ListRootsRequest": { - "description": "Sent from the server to request a list of root URIs from the client. Roots allow\nservers to ask for specific directories or files to operate on. A common example\nfor roots is providing a set of repositories or directories a server should operate\non.\n\nThis request is typically used when the server needs to understand the file system\nstructure or access specific locations that the client has permission to read from.", - "properties": { - "method": { - "const": "roots/list", - "type": "string" - }, - "params": { - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - } - }, - "type": "object" - } - }, - "required": [ - "method" - ], - "type": "object" - }, - "ListRootsResult": { - "description": "The result returned by the client for a {@link ListRootsRequestroots/list} request.\nThis result contains an array of {@link Root} objects, each representing a root directory\nor file that the server can operate on.", - "properties": { - "roots": { - "items": { - "$ref": "#/$defs/Root" - }, - "type": "array" - } - }, - "required": [ - "roots" - ], - "type": "object" - }, - "ListToolsRequest": { - "description": "Sent from the client to request a list of tools the server has.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "tools/list", - "type": "string" - }, - "params": { - "$ref": "#/$defs/PaginatedRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ListToolsResult": { - "description": "The result returned by the server for a {@link ListToolsRequesttools/list} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "nextCursor": { - "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", - "type": "string" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "tools": { - "items": { - "$ref": "#/$defs/Tool" - }, - "type": "array" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "resultType", - "tools", - "ttlMs" - ], - "type": "object" - }, - "ListToolsResultResponse": { - "description": "A successful response from the server for a {@link ListToolsRequesttools/list} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/ListToolsResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "LoggingLevel": { - "description": "The severity of a log message.\n\nThese map to syslog message severities, as specified in RFC-5424:\nhttps://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1", - "enum": [ - "alert", - "critical", - "debug", - "emergency", - "error", - "info", - "notice", - "warning" - ], - "type": "string" - }, - "LoggingMessageNotification": { - "description": "JSONRPCNotification of a log message passed from server to client. The client opts in by setting `\"io.modelcontextprotocol/logLevel\"` in a request's `_meta`.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/message", - "type": "string" - }, - "params": { - "$ref": "#/$defs/LoggingMessageNotificationParams" - } - }, - "required": [ - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "LoggingMessageNotificationParams": { - "description": "Parameters for a `notifications/message` notification.", - "properties": { - "_meta": { - "$ref": "#/$defs/NotificationMetaObject" - }, - "data": { - "description": "The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here." - }, - "level": { - "$ref": "#/$defs/LoggingLevel", - "description": "The severity of this log message." - }, - "logger": { - "description": "An optional name of the logger issuing this message.", - "type": "string" - } - }, - "required": [ - "data", - "level" - ], - "type": "object" - }, - "MetaObject": { - "description": "Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions.\n\nCertain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions.\n\nValid keys have two segments:\n\n**Prefix:**\n- Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`).\n- Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`).\n- Implementations SHOULD use reverse DNS notation (e.g., `com.example/` rather than `example.com/`).\n- Any prefix where the second label is `modelcontextprotocol` or `mcp` is **reserved** for MCP use. For example: `io.modelcontextprotocol/`, `dev.mcp/`, `org.modelcontextprotocol.api/`, and `com.mcp.tools/` are all reserved. However, `com.example.mcp/` is NOT reserved, as the second label is `example`.\n\n**Name:**\n- Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`).\n- Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`).", - "type": "object" - }, - "MethodNotFoundError": { - "description": "A JSON-RPC error indicating that the requested method does not exist or is not available.\n\nIn MCP, a server returns this error when a client invokes a method the server does not implement — either a genuinely unknown method, or one gated behind a server capability the server did not advertise (e.g., calling `prompts/list` when the `prompts` capability was not advertised).\n\nA request that requires a client capability the client did not declare is signalled instead by {@link MissingRequiredClientCapabilityError} (`-32021`).", - "properties": { - "code": { - "const": -32601, - "description": "The error type that occurred.", - "type": "integer" - }, - "data": { - "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." - }, - "message": { - "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - } - }, - "required": [ - "code", - "message" - ], - "type": "object" - }, - "MissingRequiredClientCapabilityError": { - "description": "Returned when processing a request requires a capability the client did not\ndeclare in `clientCapabilities`. For HTTP, the response status code MUST be\n`400 Bad Request`.", - "properties": { - "error": { - "allOf": [ - { - "$ref": "#/$defs/Error" - }, - { - "properties": { - "code": { - "const": -32021, - "type": "integer" - }, - "data": { - "properties": { - "requiredCapabilities": { - "$ref": "#/$defs/ClientCapabilities", - "description": "The capabilities the server requires from the client to process this request." - } - }, - "required": [ - "requiredCapabilities" - ], - "type": "object" - } - }, - "required": [ - "code", - "data" - ], - "type": "object" - } - ] - }, - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - } - }, - "required": [ - "error", - "jsonrpc" - ], - "type": "object" - }, - "ModelHint": { - "description": "Hints to use for model selection.\n\nKeys not declared here are currently left unspecified by the spec and are up\nto the client to interpret.", - "properties": { - "name": { - "description": "A hint for a model name.\n\nThe client SHOULD treat this as a substring of a model name; for example:\n - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`\n - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.\n - `claude` should match any Claude model\n\nThe client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example:\n - `gemini-1.5-flash` could match `claude-3-haiku-20240307`", - "type": "string" - } - }, - "type": "object" - }, - "ModelPreferences": { - "description": "The server's preferences for model selection, requested of the client during sampling.\n\nBecause LLMs can vary along multiple dimensions, choosing the \"best\" model is\nrarely straightforward. Different models excel in different areas—some are\nfaster but less capable, others are more capable but more expensive, and so\non. This interface allows servers to express their priorities across multiple\ndimensions to help clients make an appropriate selection for their use case.\n\nThese preferences are always advisory. The client MAY ignore them. It is also\nup to the client to decide how to interpret these preferences and how to\nbalance them against other considerations.", - "properties": { - "costPriority": { - "description": "How much to prioritize cost when selecting a model. A value of 0 means cost\nis not important, while a value of 1 means cost is the most important\nfactor.", - "maximum": 1, - "minimum": 0, - "type": "number" - }, - "hints": { - "description": "Optional hints to use for model selection.\n\nIf multiple hints are specified, the client MUST evaluate them in order\n(such that the first match is taken).\n\nThe client SHOULD prioritize these hints over the numeric priorities, but\nMAY still use the priorities to select from ambiguous matches.", - "items": { - "$ref": "#/$defs/ModelHint" - }, - "type": "array" - }, - "intelligencePriority": { - "description": "How much to prioritize intelligence and capabilities when selecting a\nmodel. A value of 0 means intelligence is not important, while a value of 1\nmeans intelligence is the most important factor.", - "maximum": 1, - "minimum": 0, - "type": "number" - }, - "speedPriority": { - "description": "How much to prioritize sampling speed (latency) when selecting a model. A\nvalue of 0 means speed is not important, while a value of 1 means speed is\nthe most important factor.", - "maximum": 1, - "minimum": 0, - "type": "number" - } - }, - "type": "object" - }, - "MultiSelectEnumSchema": { - "anyOf": [ - { - "$ref": "#/$defs/UntitledMultiSelectEnumSchema" - }, - { - "$ref": "#/$defs/TitledMultiSelectEnumSchema" - } - ] - }, - "Notification": { - "properties": { - "method": { - "type": "string" - }, - "params": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "method" - ], - "type": "object" - }, - "NotificationMetaObject": { - "description": "Extends {@link MetaObject} with additional notification-specific fields. All key naming rules from `MetaObject` apply.", - "properties": { - "io.modelcontextprotocol/subscriptionId": { - "$ref": "#/$defs/RequestId", - "description": "Identifies the subscription stream a notification was delivered on. The\nserver MUST include this key on every notification delivered via a\n{@link SubscriptionsListenRequestsubscriptions/listen} stream, so the\nclient can correlate the notification with the originating subscription.\nThe key is absent on notifications not delivered via a subscription\nstream (e.g. progress notifications for an in-flight request), which is\nwhy it is optional here.\n\nThe value is the JSON-RPC ID of the `subscriptions/listen` request that\nopened the stream." - } - }, - "type": "object" - }, - "NotificationParams": { - "description": "Common params for any notification.", - "properties": { - "_meta": { - "$ref": "#/$defs/NotificationMetaObject" - } - }, - "type": "object" - }, - "NumberSchema": { - "properties": { - "default": { - "type": "number" - }, - "description": { - "type": "string" - }, - "maximum": { - "type": "number" - }, - "minimum": { - "type": "number" - }, - "title": { - "type": "string" - }, - "type": { - "enum": [ - "integer", - "number" - ], - "type": "string" - } - }, - "required": [ - "type" - ], - "type": "object" - }, - "PaginatedRequest": { - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "type": "string" - }, - "params": { - "$ref": "#/$defs/PaginatedRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "PaginatedRequestParams": { - "description": "Common params for paginated requests.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "cursor": { - "description": "An opaque token representing the current pagination position.\nIf provided, the server should return results starting after this cursor.", - "type": "string" - } - }, - "required": [ - "_meta" - ], - "type": "object" - }, - "PaginatedResult": { - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "nextCursor": { - "description": "An opaque token representing the pagination position after the last returned result.\nIf present, there may be more results available.", - "type": "string" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - } - }, - "required": [ - "resultType" - ], - "type": "object" - }, - "ParseError": { - "description": "A JSON-RPC error indicating that invalid JSON was received by the server. This error is returned when the server cannot parse the JSON text of a message.", - "properties": { - "code": { - "const": -32700, - "description": "The error type that occurred.", - "type": "integer" - }, - "data": { - "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)." - }, - "message": { - "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - } - }, - "required": [ - "code", - "message" - ], - "type": "object" - }, - "PrimitiveSchemaDefinition": { - "anyOf": [ - { - "$ref": "#/$defs/StringSchema" - }, - { - "$ref": "#/$defs/NumberSchema" - }, - { - "$ref": "#/$defs/BooleanSchema" - }, - { - "$ref": "#/$defs/UntitledSingleSelectEnumSchema" - }, - { - "$ref": "#/$defs/TitledSingleSelectEnumSchema" - }, - { - "$ref": "#/$defs/UntitledMultiSelectEnumSchema" - }, - { - "$ref": "#/$defs/TitledMultiSelectEnumSchema" - }, - { - "$ref": "#/$defs/LegacyTitledEnumSchema" - } - ], - "description": "Restricted schema definitions that only allow primitive types\nwithout nested objects or arrays." - }, - "ProgressNotification": { - "description": "An out-of-band notification used to inform the receiver of a progress update for a long-running request.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/progress", - "type": "string" - }, - "params": { - "$ref": "#/$defs/ProgressNotificationParams" - } - }, - "required": [ - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ProgressNotificationParams": { - "description": "Parameters for a {@link ProgressNotificationnotifications/progress} notification.", - "properties": { - "_meta": { - "$ref": "#/$defs/NotificationMetaObject" - }, - "message": { - "description": "An optional message describing the current progress.", - "type": "string" - }, - "progress": { - "description": "The progress thus far. This should increase every time progress is made, even if the total is unknown.", - "type": "number" - }, - "progressToken": { - "$ref": "#/$defs/ProgressToken", - "description": "The progress token which was given in the initial request, used to associate this notification with the request that is proceeding." - }, - "total": { - "description": "Total number of items to process (or total progress required), if known.", - "type": "number" - } - }, - "required": [ - "progress", - "progressToken" - ], - "type": "object" - }, - "ProgressToken": { - "description": "A progress token, used to associate progress notifications with the original request.", - "type": [ - "string", - "integer" - ] - }, - "Prompt": { - "description": "A prompt or prompt template that the server offers.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "arguments": { - "description": "A list of arguments to use for templating the prompt.", - "items": { - "$ref": "#/$defs/PromptArgument" - }, - "type": "array" - }, - "description": { - "description": "An optional description of what this prompt provides", - "type": "string" - }, - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "PromptArgument": { - "description": "Describes an argument that a prompt can accept.", - "properties": { - "description": { - "description": "A human-readable description of the argument.", - "type": "string" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "required": { - "description": "Whether this argument must be provided.", - "type": "boolean" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "PromptListChangedNotification": { - "description": "An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This is only delivered on a {@link SubscriptionsListenRequestsubscriptions/listen} stream when the client requested it via the `promptsListChanged` filter field.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/prompts/list_changed", - "type": "string" - }, - "params": { - "$ref": "#/$defs/NotificationParams" - } - }, - "required": [ - "jsonrpc", - "method" - ], - "type": "object" - }, - "PromptMessage": { - "description": "Describes a message returned as part of a prompt.\n\nThis is similar to {@link SamplingMessage}, but also supports the embedding of\nresources from the MCP server.", - "properties": { - "content": { - "$ref": "#/$defs/ContentBlock" - }, - "role": { - "$ref": "#/$defs/Role" - } - }, - "required": [ - "content", - "role" - ], - "type": "object" - }, - "PromptReference": { - "description": "Identifies a prompt.", - "properties": { - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - }, - "type": { - "const": "ref/prompt", - "type": "string" - } - }, - "required": [ - "name", - "type" - ], - "type": "object" - }, - "ReadResourceRequest": { - "description": "Sent from the client to the server, to read a specific resource URI.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "resources/read", - "type": "string" - }, - "params": { - "$ref": "#/$defs/ReadResourceRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ReadResourceRequestParams": { - "description": "Parameters for a `resources/read` request.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "inputResponses": { - "$ref": "#/$defs/InputResponses" - }, - "requestState": { - "type": "string" - }, - "uri": { - "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "_meta", - "uri" - ], - "type": "object" - }, - "ReadResourceResult": { - "description": "The result returned by the server for a {@link ReadResourceRequestresources/read} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "cacheScope": { - "description": "Indicates the intended scope of the cached response, analogous to HTTP\n`Cache-Control: public` vs `Cache-Control: private`.\n\n- `\"public\"`: The response does not contain user-specific data. Any\n client or intermediary (e.g., shared gateway, caching proxy) MAY cache\n the response and serve it across authorization contexts.\n- `\"private\"`: The response MAY be cached and reused only within the\n same authorization context. Caches MUST NOT be shared across\n authorization contexts (e.g., a different access token requires a\n different cache).", - "enum": [ - "private", - "public" - ], - "type": "string" - }, - "contents": { - "items": { - "anyOf": [ - { - "$ref": "#/$defs/TextResourceContents" - }, - { - "$ref": "#/$defs/BlobResourceContents" - } - ] - }, - "type": "array" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - }, - "ttlMs": { - "description": "A hint from the server indicating how long (in milliseconds) the\nclient MAY cache this response before re-fetching. Semantics are\nanalogous to HTTP Cache-Control max-age.\n\n- If 0, The response SHOULD be considered immediately stale,\n The client MAY re-fetch every time the result is needed.\n- If positive, the client SHOULD consider the result fresh for this many\n milliseconds after receiving the response.", - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "cacheScope", - "contents", - "resultType", - "ttlMs" - ], - "type": "object" - }, - "ReadResourceResultResponse": { - "description": "A successful response from the server for a {@link ReadResourceRequestresources/read} request.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "anyOf": [ - { - "$ref": "#/$defs/InputRequiredResult" - }, - { - "$ref": "#/$defs/ReadResourceResult" - } - ] - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "Request": { - "properties": { - "method": { - "type": "string" - }, - "params": { - "additionalProperties": {}, - "type": "object" - } - }, - "required": [ - "method" - ], - "type": "object" - }, - "RequestId": { - "description": "A uniquely identifying ID for a request in JSON-RPC.", - "type": [ - "string", - "integer" - ] - }, - "RequestMetaObject": { - "description": "Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply.", - "properties": { - "io.modelcontextprotocol/clientCapabilities": { - "$ref": "#/$defs/ClientCapabilities", - "description": "The client's capabilities for this specific request. Required.\n\nCapabilities are declared per-request rather than once at initialization;\nan empty object means the client supports no optional capabilities.\nServers MUST NOT infer capabilities from prior requests." - }, - "io.modelcontextprotocol/clientInfo": { - "$ref": "#/$defs/Implementation", - "description": "Identifies the client software making the request. Clients SHOULD\ninclude this field on every request unless specifically configured not\nto do so.\n\nThe {@link Implementation} schema requires `name` and `version`; other\nfields are optional.\n\nThe value is self-reported by the client and is not verified by the\nprotocol. It is intended for display, logging, and debugging. Servers\nSHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for\nsecurity decisions." - }, - "io.modelcontextprotocol/logLevel": { - "$ref": "#/$defs/LoggingLevel", - "description": "The desired log level for this request. Optional.\n\nIf absent, the server MUST NOT send any {@link LoggingMessageNotificationnotifications/message}\nnotifications for this request. The client opts in to log messages by\nexplicitly setting a level. Replaces the former `logging/setLevel` RPC." - }, - "io.modelcontextprotocol/protocolVersion": { - "description": "The MCP Protocol Version being used for this request. Required.\n\nFor the HTTP transport, this value MUST match the `MCP-Protocol-Version`\nheader; otherwise the server MUST return a `400 Bad Request`. If the\nserver does not support the requested version, it MUST return an\n{@link UnsupportedProtocolVersionError}.", - "type": "string" - }, - "progressToken": { - "$ref": "#/$defs/ProgressToken", - "description": "If specified, the caller is requesting out-of-band progress notifications for this request (as represented by {@link ProgressNotificationnotifications/progress}). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications." - } - }, - "required": [ - "io.modelcontextprotocol/clientCapabilities", - "io.modelcontextprotocol/protocolVersion" - ], - "type": "object" - }, - "RequestParams": { - "description": "Common params for any request.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - } - }, - "required": [ - "_meta" - ], - "type": "object" - }, - "Resource": { - "description": "A known resource that the server is capable of reading.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "description": { - "description": "A description of what this resource represents.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.", - "type": "string" - }, - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - }, - "mimeType": { - "description": "The MIME type of this resource, if known.", - "type": "string" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "size": { - "description": "The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.\n\nThis can be used by Hosts to display file sizes and estimate context window usage.", - "type": "integer" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - }, - "uri": { - "description": "The URI of this resource.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "name", - "uri" - ], - "type": "object" - }, - "ResourceContents": { - "description": "The contents of a specific resource or sub-resource.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "mimeType": { - "description": "The MIME type of this resource, if known.", - "type": "string" - }, - "uri": { - "description": "The URI of this resource.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "uri" - ], - "type": "object" - }, - "ResourceLink": { - "description": "A resource that the server is capable of reading, included in a prompt or tool call result.\n\nNote: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequestresources/list} requests.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "description": { - "description": "A description of what this resource represents.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.", - "type": "string" - }, - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - }, - "mimeType": { - "description": "The MIME type of this resource, if known.", - "type": "string" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "size": { - "description": "The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.\n\nThis can be used by Hosts to display file sizes and estimate context window usage.", - "type": "integer" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - }, - "type": { - "const": "resource_link", - "type": "string" - }, - "uri": { - "description": "The URI of this resource.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "name", - "type", - "uri" - ], - "type": "object" - }, - "ResourceListChangedNotification": { - "description": "An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This is only delivered on a {@link SubscriptionsListenRequestsubscriptions/listen} stream when the client requested it via the `resourcesListChanged` filter field.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/resources/list_changed", - "type": "string" - }, - "params": { - "$ref": "#/$defs/NotificationParams" - } - }, - "required": [ - "jsonrpc", - "method" - ], - "type": "object" - }, - "ResourceRequestParams": { - "description": "Common params for resource-related requests.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "uri": { - "description": "The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "_meta", - "uri" - ], - "type": "object" - }, - "ResourceTemplate": { - "description": "A template description for resources available on the server.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "description": { - "description": "A description of what this template is for.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.", - "type": "string" - }, - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - }, - "mimeType": { - "description": "The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.", - "type": "string" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - }, - "uriTemplate": { - "description": "A URI template (according to RFC 6570) that can be used to construct resource URIs.", - "format": "uri-template", - "type": "string" - } - }, - "required": [ - "name", - "uriTemplate" - ], - "type": "object" - }, - "ResourceTemplateReference": { - "description": "A reference to a resource or resource template definition.", - "properties": { - "type": { - "const": "ref/resource", - "type": "string" - }, - "uri": { - "description": "The URI or URI template of the resource.", - "format": "uri-template", - "type": "string" - } - }, - "required": [ - "type", - "uri" - ], - "type": "object" - }, - "ResourceUpdatedNotification": { - "description": "A notification from the server to the client, informing it that a resource has changed and may need to be read again. This is only sent for resources the client opted in to via the `resourceSubscriptions` field of a {@link SubscriptionsListenRequestsubscriptions/listen} request.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/resources/updated", - "type": "string" - }, - "params": { - "$ref": "#/$defs/ResourceUpdatedNotificationParams" - } - }, - "required": [ - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "ResourceUpdatedNotificationParams": { - "description": "Parameters for a `notifications/resources/updated` notification.", - "properties": { - "_meta": { - "$ref": "#/$defs/NotificationMetaObject" - }, - "uri": { - "description": "The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "uri" - ], - "type": "object" - }, - "Result": { - "additionalProperties": {}, - "description": "Common result fields.", - "properties": { - "_meta": { - "$ref": "#/$defs/ResultMetaObject" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - } - }, - "required": [ - "resultType" - ], - "type": "object" - }, - "ResultMetaObject": { - "description": "Extends {@link MetaObject} with additional result-specific fields. All key naming rules from `MetaObject` apply.", - "properties": { - "io.modelcontextprotocol/serverInfo": { - "$ref": "#/$defs/Implementation", - "description": "Identifies the server software producing the response. Servers SHOULD\ninclude this field on every response unless specifically configured not\nto do so.\n\nThe {@link Implementation} schema requires `name` and `version`; other\nfields are optional.\n\nThe value is self-reported by the server and is not verified by the\nprotocol. It is intended for display, logging, and debugging. Clients\nSHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for\nsecurity decisions." - } - }, - "type": "object" - }, - "ResultType": { - "description": "Indicates the type of a {@link Result} object, allowing the client to\ndetermine how to parse the response.\n\ncomplete - the request completed successfully and the result contains the final content.\ninput_required - the request requires additional input and the result contains an {@link InputRequiredResult} object with instructions for the client to provide additional input before retrying the original request.", - "type": "string" - }, - "Role": { - "description": "The sender or recipient of messages and data in a conversation.", - "enum": [ - "assistant", - "user" - ], - "type": "string" - }, - "Root": { - "description": "Represents a root directory or file that the server can operate on.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "name": { - "description": "An optional name for the root. This can be used to provide a human-readable\nidentifier for the root, which may be useful for display purposes or for\nreferencing the root in other parts of the application.", - "type": "string" - }, - "uri": { - "description": "The URI identifying the root. This *must* start with `file://` for now.\nThis restriction may be relaxed in future versions of the protocol to allow\nother URI schemes.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "uri" - ], - "type": "object" - }, - "SamplingMessage": { - "description": "Describes a message issued to or received from an LLM API.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "content": { - "anyOf": [ - { - "$ref": "#/$defs/TextContent" - }, - { - "$ref": "#/$defs/ImageContent" - }, - { - "$ref": "#/$defs/AudioContent" - }, - { - "$ref": "#/$defs/ToolUseContent" - }, - { - "$ref": "#/$defs/ToolResultContent" - }, - { - "items": { - "$ref": "#/$defs/SamplingMessageContentBlock" - }, - "type": "array" - } - ] - }, - "role": { - "$ref": "#/$defs/Role" - } - }, - "required": [ - "content", - "role" - ], - "type": "object" - }, - "SamplingMessageContentBlock": { - "anyOf": [ - { - "$ref": "#/$defs/TextContent" - }, - { - "$ref": "#/$defs/ImageContent" - }, - { - "$ref": "#/$defs/AudioContent" - }, - { - "$ref": "#/$defs/ToolUseContent" - }, - { - "$ref": "#/$defs/ToolResultContent" - } - ] - }, - "ServerCapabilities": { - "description": "Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.", - "properties": { - "completions": { - "$ref": "#/$defs/JSONObject", - "description": "Present if the server supports argument autocompletion suggestions." - }, - "experimental": { - "additionalProperties": { - "$ref": "#/$defs/JSONObject" - }, - "description": "Experimental, non-standard capabilities that the server supports.", - "type": "object" - }, - "extensions": { - "additionalProperties": { - "$ref": "#/$defs/JSONObject" - }, - "description": "Optional MCP extensions that the server supports. Keys are extension identifiers\n(e.g., \"io.modelcontextprotocol/tasks\"), and values are per-extension settings\nobjects. An empty object indicates support with no settings.\n\nKeys MUST follow the {@link MetaObject`_meta` key naming rules}, with a\nmandatory prefix.", - "type": "object" - }, - "logging": { - "$ref": "#/$defs/JSONObject", - "description": "Present if the server supports sending log messages to the client." - }, - "prompts": { - "description": "Present if the server offers any prompt templates.", - "properties": { - "listChanged": { - "description": "Whether this server supports notifications for changes to the prompt list.", - "type": "boolean" - } - }, - "type": "object" - }, - "resources": { - "description": "Present if the server offers any resources to read.", - "properties": { - "listChanged": { - "description": "Whether this server supports notifications for changes to the resource list.", - "type": "boolean" - }, - "subscribe": { - "description": "Whether this server supports subscribing to resource updates.", - "type": "boolean" - } - }, - "type": "object" - }, - "tools": { - "description": "Present if the server offers any tools to call.", - "properties": { - "listChanged": { - "description": "Whether this server supports notifications for changes to the tool list.", - "type": "boolean" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "ServerNotification": { - "anyOf": [ - { - "$ref": "#/$defs/CancelledNotification" - }, - { - "$ref": "#/$defs/ProgressNotification" - }, - { - "$ref": "#/$defs/ResourceListChangedNotification" - }, - { - "$ref": "#/$defs/SubscriptionsAcknowledgedNotification" - }, - { - "$ref": "#/$defs/ResourceUpdatedNotification" - }, - { - "$ref": "#/$defs/PromptListChangedNotification" - }, - { - "$ref": "#/$defs/ToolListChangedNotification" - }, - { - "$ref": "#/$defs/LoggingMessageNotification" - } - ] - }, - "ServerResult": { - "anyOf": [ - { - "$ref": "#/$defs/Result" - }, - { - "$ref": "#/$defs/InputRequiredResult" - }, - { - "$ref": "#/$defs/DiscoverResult" - }, - { - "$ref": "#/$defs/ListResourcesResult" - }, - { - "$ref": "#/$defs/ListResourceTemplatesResult" - }, - { - "$ref": "#/$defs/ReadResourceResult" - }, - { - "$ref": "#/$defs/SubscriptionsListenResult" - }, - { - "$ref": "#/$defs/ListPromptsResult" - }, - { - "$ref": "#/$defs/GetPromptResult" - }, - { - "$ref": "#/$defs/ListToolsResult" - }, - { - "$ref": "#/$defs/CallToolResult" - }, - { - "$ref": "#/$defs/CompleteResult" - } - ] - }, - "SingleSelectEnumSchema": { - "anyOf": [ - { - "$ref": "#/$defs/UntitledSingleSelectEnumSchema" - }, - { - "$ref": "#/$defs/TitledSingleSelectEnumSchema" - } - ] - }, - "StringSchema": { - "properties": { - "default": { - "type": "string" - }, - "description": { - "type": "string" - }, - "format": { - "enum": [ - "date", - "date-time", - "email", - "uri" - ], - "type": "string" - }, - "maxLength": { - "type": "integer" - }, - "minLength": { - "type": "integer" - }, - "title": { - "type": "string" - }, - "type": { - "const": "string", - "type": "string" - } - }, - "required": [ - "type" - ], - "type": "object" - }, - "SubscriptionFilter": { - "description": "The set of notification types a client may opt in to on a\n{@link SubscriptionsListenRequestsubscriptions/listen} request.\n\nEach notification type is **opt-in**; the server **MUST NOT** send\nnotification types the client has not explicitly requested here.", - "properties": { - "promptsListChanged": { - "description": "If true, receive {@link PromptListChangedNotificationnotifications/prompts/list_changed}.", - "type": "boolean" - }, - "resourceSubscriptions": { - "description": "Subscribe to {@link ResourceUpdatedNotificationnotifications/resources/updated} for these resource URIs.\nReplaces the former `resources/subscribe` RPC.", - "items": { - "type": "string" - }, - "type": "array" - }, - "resourcesListChanged": { - "description": "If true, receive {@link ResourceListChangedNotificationnotifications/resources/list_changed}.", - "type": "boolean" - }, - "toolsListChanged": { - "description": "If true, receive {@link ToolListChangedNotificationnotifications/tools/list_changed}.", - "type": "boolean" - } - }, - "type": "object" - }, - "SubscriptionsAcknowledgedNotification": { - "description": "Sent by the server to acknowledge that a\n{@link SubscriptionsListenRequestsubscriptions/listen} subscription has been\nestablished and to report which notification types it agreed to honor.\n\nThis notification MUST be the first message the server sends carrying the\nsubscription's ID in `io.modelcontextprotocol/subscriptionId`. The server MUST\nNOT send any notification on the subscription before acknowledging it. On\nstdio, where every subscription shares one channel, this ordering is defined\nper subscription ID and not per channel: messages belonging to other\nsubscriptions MAY be interleaved before it.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/subscriptions/acknowledged", - "type": "string" - }, - "params": { - "$ref": "#/$defs/SubscriptionsAcknowledgedNotificationParams" - } - }, - "required": [ - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "SubscriptionsAcknowledgedNotificationParams": { - "description": "Parameters for a {@link SubscriptionsAcknowledgedNotificationnotifications/subscriptions/acknowledged} notification.", - "properties": { - "_meta": { - "$ref": "#/$defs/NotificationMetaObject" - }, - "notifications": { - "$ref": "#/$defs/SubscriptionFilter", - "description": "The subset of requested notification types the server agreed to honor.\nOnly includes notification types the server actually supports; if the\nclient requested an unsupported type (e.g., `promptsListChanged` when\nthe server has no prompts), it is omitted from this set." - } - }, - "required": [ - "notifications" - ], - "type": "object" - }, - "SubscriptionsListenRequest": { - "description": "Sent from the client to open a long-lived channel for receiving notifications\noutside the context of a specific request. Replaces the previous HTTP GET\nendpoint and ensures consistent behavior between HTTP and STDIO.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "subscriptions/listen", - "type": "string" - }, - "params": { - "$ref": "#/$defs/SubscriptionsListenRequestParams" - } - }, - "required": [ - "id", - "jsonrpc", - "method", - "params" - ], - "type": "object" - }, - "SubscriptionsListenRequestParams": { - "description": "Parameters for a {@link SubscriptionsListenRequestsubscriptions/listen} request.", - "properties": { - "_meta": { - "$ref": "#/$defs/RequestMetaObject" - }, - "notifications": { - "$ref": "#/$defs/SubscriptionFilter", - "description": "The notifications the client opts in to on this stream. The server\n**MUST NOT** send notification types the client has not explicitly\nrequested." - } - }, - "required": [ - "_meta", - "notifications" - ], - "type": "object" - }, - "SubscriptionsListenResult": { - "description": "The response to a {@link SubscriptionsListenRequestsubscriptions/listen}\nrequest, signalling that the subscription has ended gracefully (for example,\nduring server shutdown). Because the listen stream is long-lived, this result\nis sent only when the server tears the subscription down; an abrupt transport\nclose carries no response. The result body is otherwise empty.", - "properties": { - "_meta": { - "$ref": "#/$defs/SubscriptionsListenResultMetaObject" - }, - "resultType": { - "description": "Indicates the type of the result, which allows the client to determine\nhow to parse the result object.\n\nServers implementing this protocol version MUST include this field.\nFor backward compatibility, when a client receives a result from a\nserver implementing an earlier protocol version (which does not include\n`resultType`), the client MUST treat the absent field as `\"complete\"`.", - "type": "string" - } - }, - "required": [ - "_meta", - "resultType" - ], - "type": "object" - }, - "SubscriptionsListenResultMetaObject": { - "description": "Extends {@link ResultMetaObject} with the subscription-stream identifier carried by a\n{@link SubscriptionsListenResult}. All key naming rules from `MetaObject` apply.", - "properties": { - "io.modelcontextprotocol/serverInfo": { - "$ref": "#/$defs/Implementation", - "description": "Identifies the server software producing the response. Servers SHOULD\ninclude this field on every response unless specifically configured not\nto do so.\n\nThe {@link Implementation} schema requires `name` and `version`; other\nfields are optional.\n\nThe value is self-reported by the server and is not verified by the\nprotocol. It is intended for display, logging, and debugging. Clients\nSHOULD NOT use it to change their behavior, and SHOULD NOT rely on it for\nsecurity decisions." - }, - "io.modelcontextprotocol/subscriptionId": { - "$ref": "#/$defs/RequestId", - "description": "Identifies the subscription stream this response closes, so the client can\ncorrelate it with the originating subscription — mirroring the same key on\nthe stream's notifications. The value is the JSON-RPC ID of the\n`subscriptions/listen` request that opened the stream (and equals this\nresponse's `id`)." - } - }, - "required": [ - "io.modelcontextprotocol/subscriptionId" - ], - "type": "object" - }, - "SubscriptionsListenResultResponse": { - "description": "A successful response from the server for a {@link SubscriptionsListenRequestsubscriptions/listen}\nrequest, sent when the server tears the subscription down gracefully.", - "properties": { - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "result": { - "$ref": "#/$defs/SubscriptionsListenResult" - } - }, - "required": [ - "id", - "jsonrpc", - "result" - ], - "type": "object" - }, - "TextContent": { - "description": "Text provided to or from an LLM.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/Annotations", - "description": "Optional annotations for the client." - }, - "text": { - "description": "The text content of the message.", - "type": "string" - }, - "type": { - "const": "text", - "type": "string" - } - }, - "required": [ - "text", - "type" - ], - "type": "object" - }, - "TextResourceContents": { - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "mimeType": { - "description": "The MIME type of this resource, if known.", - "type": "string" - }, - "text": { - "description": "The text of the item. This must only be set if the item can actually be represented as text (not binary data).", - "type": "string" - }, - "uri": { - "description": "The URI of this resource.", - "format": "uri", - "type": "string" - } - }, - "required": [ - "text", - "uri" - ], - "type": "object" - }, - "TitledMultiSelectEnumSchema": { - "description": "Schema for multiple-selection enumeration with display titles for each option.", - "properties": { - "default": { - "description": "Optional default value.", - "items": { - "type": "string" - }, - "type": "array" - }, - "description": { - "description": "Optional description for the enum field.", - "type": "string" - }, - "items": { - "description": "Schema for array items with enum options and display labels.", - "properties": { - "anyOf": { - "description": "Array of enum options with values and display labels.", - "items": { - "properties": { - "const": { - "description": "The constant enum value.", - "type": "string" - }, - "title": { - "description": "Display title for this option.", - "type": "string" - } - }, - "required": [ - "const", - "title" - ], - "type": "object" - }, - "type": "array" - } - }, - "required": [ - "anyOf" - ], - "type": "object" - }, - "maxItems": { - "description": "Maximum number of items to select.", - "type": "integer" - }, - "minItems": { - "description": "Minimum number of items to select.", - "type": "integer" - }, - "title": { - "description": "Optional title for the enum field.", - "type": "string" - }, - "type": { - "const": "array", - "type": "string" - } - }, - "required": [ - "items", - "type" - ], - "type": "object" - }, - "TitledSingleSelectEnumSchema": { - "description": "Schema for single-selection enumeration with display titles for each option.", - "properties": { - "default": { - "description": "Optional default value.", - "type": "string" - }, - "description": { - "description": "Optional description for the enum field.", - "type": "string" - }, - "oneOf": { - "description": "Array of enum options with values and display labels.", - "items": { - "properties": { - "const": { - "description": "The enum value.", - "type": "string" - }, - "title": { - "description": "Display label for this option.", - "type": "string" - } - }, - "required": [ - "const", - "title" - ], - "type": "object" - }, - "type": "array" - }, - "title": { - "description": "Optional title for the enum field.", - "type": "string" - }, - "type": { - "const": "string", - "type": "string" - } - }, - "required": [ - "oneOf", - "type" - ], - "type": "object" - }, - "Tool": { - "description": "Definition for a tool the client can call.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject" - }, - "annotations": { - "$ref": "#/$defs/ToolAnnotations", - "description": "Optional additional tool information.\n\nDisplay name precedence order is: `title`, `annotations.title`, then `name`." - }, - "description": { - "description": "A human-readable description of the tool.\n\nThis can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a \"hint\" to the model.", - "type": "string" - }, - "icons": { - "description": "Optional set of sized icons that the client can display in a user interface.\n\nClients that support rendering icons MUST support at least the following MIME types:\n- `image/png` - PNG images (safe, universal compatibility)\n- `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)\n\nClients that support rendering icons SHOULD also support:\n- `image/svg+xml` - SVG images (scalable but requires security precautions)\n- `image/webp` - WebP images (modern, efficient format)", - "items": { - "$ref": "#/$defs/Icon" - }, - "type": "array" - }, - "inputSchema": { - "additionalProperties": {}, - "description": "A JSON Schema object defining the expected parameters for the tool.\n\nTool arguments are always JSON objects, so `type: \"object\"` is required at the root.\nBeyond that, any JSON Schema 2020-12 keyword may appear alongside `type` — including\ncomposition keywords (`oneOf`, `anyOf`, `allOf`, `not`), conditional keywords\n(`if`/`then`/`else`), reference keywords (`$ref`, `$defs`, `$anchor`), and any other\nstandard validation or annotation keywords.\n\nProperty schemas may carry an `x-mcp-header` annotation to mirror the\nargument value into an HTTP header on the Streamable HTTP transport. See\nthe Streamable HTTP transport specification for the validity and\nextraction rules.\n\nDefaults to JSON Schema 2020-12 when no explicit `$schema` is provided.", - "properties": { - "$schema": { - "type": "string" - }, - "type": { - "const": "object", - "type": "string" - } - }, - "required": [ - "type" - ], - "type": "object" - }, - "name": { - "description": "Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present).", - "type": "string" - }, - "outputSchema": { - "additionalProperties": {}, - "description": "An optional JSON Schema object defining the structure of the tool's output returned in\nthe structuredContent field of a {@link CallToolResult}. This can be any valid JSON Schema 2020-12.\n\nDefaults to JSON Schema 2020-12 when no explicit `$schema` is provided.", - "properties": { - "$schema": { - "type": "string" - } - }, - "type": "object" - }, - "title": { - "description": "Intended for UI and end-user contexts — optimized to be human-readable and easily understood,\neven by those unfamiliar with domain-specific terminology.\n\nIf not provided, the name should be used for display (except for {@link Tool},\nwhere `annotations.title` should be given precedence over using `name`,\nif present).", - "type": "string" - } - }, - "required": [ - "inputSchema", - "name" - ], - "type": "object" - }, - "ToolAnnotations": { - "description": "Additional properties describing a {@link Tool} to clients.\n\nNOTE: all properties in `ToolAnnotations` are **hints**.\nThey are not guaranteed to provide a faithful description of\ntool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on `ToolAnnotations`\nreceived from untrusted servers.", - "properties": { - "destructiveHint": { - "description": "If true, the tool may perform destructive updates to its environment.\nIf false, the tool performs only additive updates.\n\n(This property is meaningful only when `readOnlyHint == false`)\n\nDefault: true", - "type": "boolean" - }, - "idempotentHint": { - "description": "If true, calling the tool repeatedly with the same arguments\nwill have no additional effect on its environment.\n\n(This property is meaningful only when `readOnlyHint == false`)\n\nDefault: false", - "type": "boolean" - }, - "openWorldHint": { - "description": "If true, this tool may interact with an \"open world\" of external\nentities. If false, the tool's domain of interaction is closed.\nFor example, the world of a web search tool is open, whereas that\nof a memory tool is not.\n\nDefault: true", - "type": "boolean" - }, - "readOnlyHint": { - "description": "If true, the tool does not modify its environment.\n\nDefault: false", - "type": "boolean" - }, - "title": { - "description": "A human-readable title for the tool.", - "type": "string" - } - }, - "type": "object" - }, - "ToolChoice": { - "description": "Controls tool selection behavior for sampling requests.", - "properties": { - "mode": { - "description": "Controls the tool use ability of the model:\n- `\"auto\"`: Model decides whether to use tools (default)\n- `\"required\"`: Model MUST use at least one tool before completing\n- `\"none\"`: Model MUST NOT use any tools", - "enum": [ - "auto", - "none", - "required" - ], - "type": "string" - } - }, - "type": "object" - }, - "ToolListChangedNotification": { - "description": "An optional notification from the server to the client, informing it that the list of tools it offers has changed. This is only delivered on a {@link SubscriptionsListenRequestsubscriptions/listen} stream when the client requested it via the `toolsListChanged` filter field.", - "properties": { - "jsonrpc": { - "const": "2.0", - "type": "string" - }, - "method": { - "const": "notifications/tools/list_changed", - "type": "string" - }, - "params": { - "$ref": "#/$defs/NotificationParams" - } - }, - "required": [ - "jsonrpc", - "method" - ], - "type": "object" - }, - "ToolResultContent": { - "description": "The result of a tool use, provided by the user back to the assistant.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject", - "description": "Optional metadata about the tool result. Clients SHOULD preserve this field when\nincluding tool results in subsequent sampling requests to enable caching optimizations." - }, - "content": { - "description": "The unstructured result content of the tool use.\n\nThis has the same format as {@link CallToolResult.content} and can include text, images,\naudio, resource links, and embedded resources.", - "items": { - "$ref": "#/$defs/ContentBlock" - }, - "type": "array" - }, - "isError": { - "description": "Whether the tool use resulted in an error.\n\nIf true, the content typically describes the error that occurred.\nDefault: false", - "type": "boolean" - }, - "structuredContent": { - "description": "An optional structured result value.\n\nThis can be any JSON value (object, array, string, number, boolean, or null).\nIf the tool defined an {@link Tool.outputSchema}, this SHOULD conform to that schema." - }, - "toolUseId": { - "description": "The ID of the tool use this result corresponds to.\n\nThis MUST match the ID from a previous {@link ToolUseContent}.", - "type": "string" - }, - "type": { - "const": "tool_result", - "type": "string" - } - }, - "required": [ - "content", - "toolUseId", - "type" - ], - "type": "object" - }, - "ToolUseContent": { - "description": "A request from the assistant to call a tool.", - "properties": { - "_meta": { - "$ref": "#/$defs/MetaObject", - "description": "Optional metadata about the tool use. Clients SHOULD preserve this field when\nincluding tool uses in subsequent sampling requests to enable caching optimizations." - }, - "id": { - "description": "A unique identifier for this tool use.\n\nThis ID is used to match tool results to their corresponding tool uses.", - "type": "string" - }, - "input": { - "additionalProperties": {}, - "description": "The arguments to pass to the tool, conforming to the tool's input schema.", - "type": "object" - }, - "name": { - "description": "The name of the tool to call.", - "type": "string" - }, - "type": { - "const": "tool_use", - "type": "string" - } - }, - "required": [ - "id", - "input", - "name", - "type" - ], - "type": "object" - }, - "UnsupportedProtocolVersionError": { - "description": "Returned when the request's protocol version is unknown to the server or\nunsupported (e.g., a known experimental or draft version the server has\nchosen not to implement). For HTTP, the response status code MUST be\n`400 Bad Request`.", - "properties": { - "error": { - "allOf": [ - { - "$ref": "#/$defs/Error" - }, - { - "properties": { - "code": { - "const": -32022, - "type": "integer" - }, - "data": { - "properties": { - "requested": { - "description": "The protocol version that was requested by the client.", - "type": "string" - }, - "supported": { - "description": "Protocol versions the server supports. The client should choose a\nmutually supported version from this list and retry.", - "items": { - "type": "string" - }, - "type": "array" - } - }, - "required": [ - "requested", - "supported" - ], - "type": "object" - } - }, - "required": [ - "code", - "data" - ], - "type": "object" - } - ] - }, - "id": { - "$ref": "#/$defs/RequestId" - }, - "jsonrpc": { - "const": "2.0", - "type": "string" - } - }, - "required": [ - "error", - "jsonrpc" - ], - "type": "object" - }, - "UntitledMultiSelectEnumSchema": { - "description": "Schema for multiple-selection enumeration without display titles for options.", - "properties": { - "default": { - "description": "Optional default value.", - "items": { - "type": "string" - }, - "type": "array" - }, - "description": { - "description": "Optional description for the enum field.", - "type": "string" - }, - "items": { - "description": "Schema for the array items.", - "properties": { - "enum": { - "description": "Array of enum values to choose from.", - "items": { - "type": "string" - }, - "type": "array" - }, - "type": { - "const": "string", - "type": "string" - } - }, - "required": [ - "enum", - "type" - ], - "type": "object" - }, - "maxItems": { - "description": "Maximum number of items to select.", - "type": "integer" - }, - "minItems": { - "description": "Minimum number of items to select.", - "type": "integer" - }, - "title": { - "description": "Optional title for the enum field.", - "type": "string" - }, - "type": { - "const": "array", - "type": "string" - } - }, - "required": [ - "items", - "type" - ], - "type": "object" - }, - "UntitledSingleSelectEnumSchema": { - "description": "Schema for single-selection enumeration without display titles for options.", - "properties": { - "default": { - "description": "Optional default value.", - "type": "string" - }, - "description": { - "description": "Optional description for the enum field.", - "type": "string" - }, - "enum": { - "description": "Array of enum values to choose from.", - "items": { - "type": "string" - }, - "type": "array" - }, - "title": { - "description": "Optional title for the enum field.", - "type": "string" - }, - "type": { - "const": "string", - "type": "string" - } - }, - "required": [ - "enum", - "type" - ], - "type": "object" - } - } -} - diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/docs-execute-sql-x-mcp-header.json b/crates/candler-schemas/tests/fixtures/spec/tools/docs-execute-sql-x-mcp-header.json deleted file mode 100644 index 00f74067..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/docs-execute-sql-x-mcp-header.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "execute_sql", - "description": "Execute SQL on Google Cloud Spanner", - "inputSchema": { - "type": "object", - "properties": { - "region": { - "type": "string", - "description": "The region to execute the query in", - "x-mcp-header": "Region" - }, - "query": { - "type": "string", - "description": "The SQL query to execute" - } - }, - "required": [ - "region", - "query" - ] - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/docs-get-weather-with-icons.json b/crates/candler-schemas/tests/fixtures/spec/tools/docs-get-weather-with-icons.json deleted file mode 100644 index cc8d19d1..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/docs-get-weather-with-icons.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "get_weather", - "title": "Weather Information Provider", - "description": "Get current weather information for a location", - "inputSchema": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "City name or zip code" - } - }, - "required": [ - "location" - ] - }, - "icons": [ - { - "src": "https://example.com/weather-icon.png", - "mimeType": "image/png", - "sizes": [ - "48x48" - ] - } - ] -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/docs-list-users-array-output.json b/crates/candler-schemas/tests/fixtures/spec/tools/docs-list-users-array-output.json deleted file mode 100644 index 559fd6d8..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/docs-list-users-array-output.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "list_users", - "title": "User List", - "description": "Returns a list of all users", - "inputSchema": { - "type": "object", - "properties": {} - }, - "outputSchema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "email": { - "type": "string" - } - }, - "required": [ - "id", - "name", - "email" - ] - } - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/full.json b/crates/candler-schemas/tests/fixtures/spec/tools/full.json deleted file mode 100644 index 6be94f8c..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/full.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "name": "search_documents", - "title": "Document Search", - "description": "Search the document index and return the best matches", - "inputSchema": { - "type": "object", - "properties": { - "query": { - "type": "string", - "description": "Search text" - }, - "limit": { - "type": "integer", - "minimum": 1, - "maximum": 50, - "default": 10 - } - }, - "required": [ - "query" - ] - }, - "outputSchema": { - "type": "object", - "properties": { - "hits": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "score": { - "type": "number" - } - }, - "required": [ - "id", - "score" - ] - } - }, - "total": { - "type": "integer" - } - }, - "required": [ - "hits", - "total" - ] - }, - "annotations": { - "title": "Search documents", - "readOnlyHint": true, - "destructiveHint": false, - "idempotentHint": true, - "openWorldHint": false - }, - "icons": [ - { - "src": "https://example.com/search-light.png", - "mimeType": "image/png", - "sizes": [ - "48x48", - "96x96" - ], - "theme": "light" - }, - { - "src": "https://example.com/search-dark.svg", - "mimeType": "image/svg+xml", - "sizes": [ - "any" - ], - "theme": "dark" - } - ], - "_meta": { - "com.example/index": "documents-v2", - "com.example/cost": { - "credits": 1 - } - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/tool-with-array-output-schema.json b/crates/candler-schemas/tests/fixtures/spec/tools/tool-with-array-output-schema.json deleted file mode 100644 index 8c7edec6..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/tool-with-array-output-schema.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "list_users", - "title": "User List", - "description": "Returns a list of all users", - "inputSchema": { - "type": "object", - "properties": {} - }, - "outputSchema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "User ID" - }, - "name": { - "type": "string", - "description": "User name" - }, - "email": { - "type": "string", - "description": "User email" - } - }, - "required": ["id", "name", "email"] - } - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/tool-with-composition-input-schema.json b/crates/candler-schemas/tests/fixtures/spec/tools/tool-with-composition-input-schema.json deleted file mode 100644 index 7c7253af..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/tool-with-composition-input-schema.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "find_resource", - "title": "Resource Finder", - "description": "Find a resource by ID or name", - "inputSchema": { - "type": "object", - "oneOf": [ - { - "properties": { - "id": { - "type": "string", - "description": "Resource ID" - } - }, - "required": ["id"] - }, - { - "properties": { - "name": { - "type": "string", - "description": "Resource name" - } - }, - "required": ["name"] - } - ] - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/with-default-2020-12-input-schema.json b/crates/candler-schemas/tests/fixtures/spec/tools/with-default-2020-12-input-schema.json deleted file mode 100644 index d79a00ee..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/with-default-2020-12-input-schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "calculate_sum", - "description": "Add two numbers", - "inputSchema": { - "type": "object", - "properties": { - "a": { "type": "number" }, - "b": { "type": "number" } - }, - "required": ["a", "b"] - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/with-explicit-draft-07-input-schema.json b/crates/candler-schemas/tests/fixtures/spec/tools/with-explicit-draft-07-input-schema.json deleted file mode 100644 index 698d95b8..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/with-explicit-draft-07-input-schema.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "calculate_sum", - "description": "Add two numbers", - "inputSchema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "a": { "type": "number" }, - "b": { "type": "number" } - }, - "required": ["a", "b"] - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/with-no-parameters.json b/crates/candler-schemas/tests/fixtures/spec/tools/with-no-parameters.json deleted file mode 100644 index 04a3a4e9..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/with-no-parameters.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "get_current_time", - "description": "Returns the current server time", - "inputSchema": { - "type": "object", - "additionalProperties": false - } -} diff --git a/crates/candler-schemas/tests/fixtures/spec/tools/with-output-schema-for-structured-content.json b/crates/candler-schemas/tests/fixtures/spec/tools/with-output-schema-for-structured-content.json deleted file mode 100644 index a1469834..00000000 --- a/crates/candler-schemas/tests/fixtures/spec/tools/with-output-schema-for-structured-content.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "get_weather_data", - "title": "Weather Data Retriever", - "description": "Get current weather data for a location", - "inputSchema": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "City name or zip code" - } - }, - "required": ["location"] - }, - "outputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Temperature in celsius" - }, - "conditions": { - "type": "string", - "description": "Weather conditions description" - }, - "humidity": { - "type": "number", - "description": "Humidity percentage" - } - }, - "required": ["temperature", "conditions", "humidity"] - } -} diff --git a/crates/candler-schemas/tests/fixtures/upstream/README.md b/crates/candler-schemas/tests/fixtures/upstream/README.md deleted file mode 100644 index 8d8e43b3..00000000 --- a/crates/candler-schemas/tests/fixtures/upstream/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Upstream catalog snapshots - -Two tool-catalog snapshots captured from real MCP servers, in HTN's `tool-catalog-snapshot/0` -shape (`servers_dir` and `stubbed_modules` at the top level). They are inputs to the catalog tests, -which convert them to the `/1` shape in the test; the files themselves are verbatim. - -Source repository: `mcp-python-ingestion` (`/Users/hacker/Documents/src/External/PCfVW/mcp-python-ingestion`), -licence Apache-2.0. - -## `rikyu_mcp.json` - -| | | -|---|---| -| Tag | `htn-creator-eval@0.4.2` | -| Commit | `28be2c158fbc6ee786a789242c2d8fd47bfde9a8` | -| Path | `.claude/skills/htn-creator-workspace/infrastructure/htn_creator_eval/catalogs/rikyu_mcp.json` | -| Blob | `c3a1206abf4507cab53cd3f41ff6ffa4967e1757` | -| SHA-256 | `8e331d938505087e34839ba8d8d0b596032041af2dd1710315684c8d39f5b438` | -| Servers | `rikyu-hpc` (26 tools), `rikyu-docs` (3 tools) | -| Captured | `2026-10-28T01:09:04+00:00`, python 3.12.12, hpc-agent-core 0.5.0, mcp 2.0.0, pydantic 2.13.4 | - -Copied byte for byte (`git show 'htn-creator-eval@0.4.2:'`). Server sources, at the same -commit, under `.claude/skills/htn-creator-workspace/servers/rikyu_mcp/`: - -| Source | Blob | Digest recorded in the snapshot | -|---|---|---| -| `hpc_server.py` | `60baf22df5deaaf46e18ac7febe6a964ebce3727` | `sha256:b2af8a23ff6f5ceef36217b7727bf515fbf345472d81e1872bbed43b57e55b4b` | -| `docs_server.py` | `0b75ec4fb499ebe98d95d70aa5285c8f367a9d1d` | `sha256:527acd8f431571903257dd51578b2a21bf8bb27b20d274e6fdfe82169968d638` | - -The capture command is in the docstring of the capture script (below). - -## `bio_opentrons.json` - -| | | -|---|---| -| Servers | `gripper-server` (1 tool), `liquid-server` (10), `module-server` (19), `movement-server` (6) | -| Server sources | `.claude/skills/htn-creator-workspace/servers/bio-opentrons/` at tag `htn-creator-eval@0.4.2` (`28be2c158fbc6ee786a789242c2d8fd47bfde9a8`) | -| Captured | `2026-10-28T15:10:36+00:00`, python 3.12.12, mcp 1.28.1, pydantic 2.13.4 | -| SHA-256 | `e049a47a610a69b8d407af169f7467fa3d5a5dfb2b999de4d0f8e8be0f0db35f` | -| Capture script | branch `feat/htn-eval-capture-lowlevel-servers`, commit `93ded966e710a6342efc66973c1af4fad48002a7` of `mcp-python-ingestion` (unpushed, not landed) | - -The four servers use the low-level `mcp.server.Server` with `@app.list_tools()`, which needs mcp 1.x: -mcp 2.0.0's `Server` has no `list_tools`. mcp 1.28.1 and pydantic 2.13.4 are the versions the -repository's `infrastructure/uv.lock` pins and the golden regrade's `PROVENANCE.json` records. The -script at the tag awaits `server.list_tools()` and cannot read these servers; the commit above makes -it call the registered `tools/list` handler of a low-level server, and its output for the rikyu -servers is unchanged. Server sources, under the path above: - -| Source | Digest recorded in the snapshot | -|---|---| -| `gripper_server.py` | `sha256:13b8472ce71cc074dfa02bcc12d4af3b4a4915eb55f5c18c1c8b604da6d53ade` | -| `liquid_server.py` | `sha256:a58d9c9abf64429005f79ba06142c1be939c8a18f0438ed764d123a31c90d99c` | -| `module_server.py` | `sha256:62f0ea336fc5a196d5180fbecea65f1b59d01723553c334febf1113c977730df` | -| `movement_server.py` | `sha256:47a2f81337dedb6ebe31a811db55cfb339a41857a3357c3842d57ce88b2493cb` | - -Command, from the root of a `mcp-python-ingestion` worktree at that commit, with `` the path of -this file: - -``` -uv run --isolated --no-project --python 3.12 \ - --with 'mcp==1.28.1' --with 'pydantic==2.13.4' \ - python -I .claude/skills/htn-creator-workspace/infrastructure/scripts/capture_catalog_snapshot.py \ - --servers-dir .claude/skills/htn-creator-workspace/servers/bio-opentrons \ - --server bio-opentrons.gripper_server:app --server bio-opentrons.liquid_server:app \ - --server bio-opentrons.module_server:app --server bio-opentrons.movement_server:app \ - --pin mcp --pin pydantic \ - --out -``` - -## Capture script - -`.claude/skills/htn-creator-workspace/infrastructure/scripts/capture_catalog_snapshot.py`, blob -`a7f07f1886301c788143b7f7b1d75ffb072dc963` at tag `htn-creator-eval@0.4.2`. It keeps `name`, -`description`, `inputSchema` and `outputSchema` of each tool and sorts tools by name. The bio-opentrons -tools carry no other field. diff --git a/crates/candler-schemas/tests/fixtures/upstream/bio_opentrons.json b/crates/candler-schemas/tests/fixtures/upstream/bio_opentrons.json deleted file mode 100644 index c1a9b84f..00000000 --- a/crates/candler-schemas/tests/fixtures/upstream/bio_opentrons.json +++ /dev/null @@ -1,919 +0,0 @@ -{ - "schema": "tool-catalog-snapshot/0", - "captured_at": "2026-10-28T15:10:36+00:00", - "provider": "htn-creator-eval/scripts/capture_catalog_snapshot.py@1", - "environment": { - "python": "3.12.12", - "mcp": "1.28.1", - "pydantic": "2.13.4" - }, - "servers_dir": ".claude/skills/htn-creator-workspace/servers/bio-opentrons", - "stubbed_modules": [], - "servers": [ - { - "name": "gripper-server", - "source_path": ".claude/skills/htn-creator-workspace/servers/bio-opentrons/gripper_server.py", - "source_digest": "sha256:13b8472ce71cc074dfa02bcc12d4af3b4a4915eb55f5c18c1c8b604da6d53ade", - "transport": "stdio", - "tools": [ - { - "name": "move_labware", - "description": "Move labware using the gripper from one location to another", - "inputSchema": { - "type": "object", - "properties": { - "labware_name": { - "type": "string", - "description": "Name/ID of the labware to move" - }, - "destination": { - "type": "string", - "description": "Destination slot (e.g., 'A1', 'B2', 'heater_shaker')" - }, - "use_gripper": { - "type": "boolean", - "description": "Whether to use gripper (true) or manual movement (false)", - "default": true - } - }, - "required": [ - "labware_name", - "destination" - ] - } - } - ] - }, - { - "name": "liquid-server", - "source_path": ".claude/skills/htn-creator-workspace/servers/bio-opentrons/liquid_server.py", - "source_digest": "sha256:a58d9c9abf64429005f79ba06142c1be939c8a18f0438ed764d123a31c90d99c", - "transport": "stdio", - "tools": [ - { - "name": "air_gap", - "description": "Create an air gap in the tip to prevent dripping. Corresponds to GTPyhop action: a_air_gap(state, pipette, volume)", - "inputSchema": { - "type": "object", - "properties": { - "pipette": { - "type": "string", - "description": "Pipette identifier (e.g., 'pip96', 'left', 'right')" - }, - "volume": { - "type": "number", - "description": "Air gap volume in \u00b5L", - "minimum": 1, - "maximum": 1000 - } - }, - "required": [ - "pipette", - "volume" - ] - } - }, - { - "name": "aspirate", - "description": "Aspirate liquid from a well into the pipette. Simulates Opentrons Flex pipette aspiration operation. Supports location parameter for precise Z-axis positioning (top/bottom/center). Corresponds to GTPyhop action: a_aspirate(state, mount, volume, labware_slot, well)", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount ('left' or 'right')", - "enum": [ - "left", - "right" - ] - }, - "volume": { - "type": "number", - "description": "Volume to aspirate in \u00b5L (1-1000)", - "minimum": 1, - "maximum": 1000 - }, - "labware_slot": { - "type": "string", - "description": "Deck slot containing the labware (e.g., 'A1', 'B2', 'D3') - backward compatible", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Well to aspirate from (e.g., 'A1', 'B6', 'H12') - backward compatible", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - }, - "location": { - "type": "object", - "description": "Well location with optional Z-axis positioning (Opentrons API v2 compatible)", - "properties": { - "labware_slot": { - "type": "string", - "description": "Deck slot containing the labware", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Well identifier", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - }, - "position_type": { - "type": "string", - "description": "Z-axis position (top/bottom/center) - maps to Well.top()/bottom()/center()", - "enum": [ - "top", - "bottom", - "center" - ], - "default": "bottom" - }, - "z_offset": { - "type": "number", - "description": "Z-axis offset in mm (positive = up, negative = down)", - "default": 0 - } - }, - "required": [ - "labware_slot", - "well" - ] - }, - "rate": { - "type": "number", - "description": "Flow rate multiplier (1.0 = default speed)", - "minimum": 0.1, - "maximum": 10.0, - "default": 1.0 - } - }, - "required": [ - "mount", - "volume" - ] - } - }, - { - "name": "blow_out", - "description": "Blow out any remaining liquid from the pipette tip. Ensures complete liquid transfer by expelling residual volume. Corresponds to GTPyhop action: a_blow_out(state, mount)", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount to blow out from ('left' or 'right')", - "enum": [ - "left", - "right" - ] - } - }, - "required": [ - "mount" - ] - } - }, - { - "name": "dispense", - "description": "Dispense liquid from the pipette into a well. Simulates Opentrons Flex pipette dispensing operation. Supports location parameter for precise Z-axis positioning (top/bottom/center). Corresponds to GTPyhop action: a_dispense(state, mount, volume, labware_slot, well)", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount ('left' or 'right')", - "enum": [ - "left", - "right" - ] - }, - "volume": { - "type": "number", - "description": "Volume to dispense in \u00b5L (1-1000)", - "minimum": 1, - "maximum": 1000 - }, - "labware_slot": { - "type": "string", - "description": "Deck slot containing the labware (e.g., 'A1', 'B2', 'D3') - backward compatible", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Well to dispense into (e.g., 'A1', 'B6', 'H12') - backward compatible", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - }, - "location": { - "type": "object", - "description": "Well location with optional Z-axis positioning (Opentrons API v2 compatible)", - "properties": { - "labware_slot": { - "type": "string", - "description": "Deck slot containing the labware", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Well identifier", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - }, - "position_type": { - "type": "string", - "description": "Z-axis position (top/bottom/center) - maps to Well.top()/bottom()/center()", - "enum": [ - "top", - "bottom", - "center" - ], - "default": "bottom" - }, - "z_offset": { - "type": "number", - "description": "Z-axis offset in mm (positive = up, negative = down)", - "default": 0 - } - }, - "required": [ - "labware_slot", - "well" - ] - }, - "rate": { - "type": "number", - "description": "Flow rate multiplier (1.0 = default speed)", - "minimum": 0.1, - "maximum": 10.0, - "default": 1.0 - } - }, - "required": [ - "mount", - "volume" - ] - } - }, - { - "name": "home", - "description": "Home the pipette to its starting position. Corresponds to GTPyhop action: a_home(state, pipette)", - "inputSchema": { - "type": "object", - "properties": { - "pipette": { - "type": "string", - "description": "Pipette identifier (e.g., 'pip96', 'left', 'right')" - } - }, - "required": [ - "pipette" - ] - } - }, - { - "name": "load_labware", - "description": "Register labware as loaded at a deck slot in liquid-server's own state (independent of movement-server's copy - see module docstring). Required before aspirate/dispense/mix will accept operations at that slot.", - "inputSchema": { - "type": "object", - "properties": { - "slot": { - "type": "string", - "description": "Deck slot position (e.g., 'A1', 'B2', 'D3')", - "pattern": "^[A-Da-d][1-3]$" - }, - "labware_type": { - "type": "string", - "description": "Type of labware (e.g., 'nest_96_wellplate_200ul_flat')" - } - }, - "required": [ - "slot", - "labware_type" - ] - } - }, - { - "name": "mix", - "description": "Mix contents of a well by repeated aspiration and dispensing. Simulates Opentrons Flex mixing operation for homogenization. Corresponds to GTPyhop action: a_mix(state, mount, repetitions, volume, labware_slot, well)", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount ('left' or 'right')", - "enum": [ - "left", - "right" - ] - }, - "repetitions": { - "type": "integer", - "description": "Number of mix cycles (1-50)", - "minimum": 1, - "maximum": 50 - }, - "volume": { - "type": "number", - "description": "Volume to mix in \u00b5L (1-1000)", - "minimum": 1, - "maximum": 1000 - }, - "labware_slot": { - "type": "string", - "description": "Deck slot containing the labware (e.g., 'A1', 'B2', 'D3')", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Well to mix (e.g., 'A1', 'B6', 'H12')", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - } - }, - "required": [ - "mount", - "repetitions", - "volume", - "labware_slot", - "well" - ] - } - }, - { - "name": "pick_up_tip", - "description": "Pick up a tip from the specified rack for liquid handling operations. Corresponds to GTPyhop action: a_pick_up_tip(state, pipette, tip_rack)", - "inputSchema": { - "type": "object", - "properties": { - "pipette": { - "type": "string", - "description": "Pipette identifier (e.g., 'pip96', 'left', 'right')" - }, - "tip_rack": { - "type": "string", - "description": "Tip rack identifier (e.g., 'tips', 'tips1')" - } - }, - "required": [ - "pipette", - "tip_rack" - ] - } - }, - { - "name": "return_tip", - "description": "Return the current tip to the rack or trash. Corresponds to GTPyhop action: a_return_tip(state, pipette)", - "inputSchema": { - "type": "object", - "properties": { - "pipette": { - "type": "string", - "description": "Pipette identifier (e.g., 'pip96', 'left', 'right')" - } - }, - "required": [ - "pipette" - ] - } - }, - { - "name": "set_flow_rate", - "description": "Set pipette flow rates for liquid handling operations. Corresponds to GTPyhop action: a_set_flow_rate(state, pipette, aspirate_rate, dispense_rate)", - "inputSchema": { - "type": "object", - "properties": { - "pipette": { - "type": "string", - "description": "Pipette identifier (e.g., 'pip96', 'left', 'right')" - }, - "aspirate_rate": { - "type": "number", - "description": "Aspiration flow rate in \u00b5L/s", - "minimum": 0.1, - "maximum": 1000 - }, - "dispense_rate": { - "type": "number", - "description": "Dispense flow rate in \u00b5L/s", - "minimum": 0.1, - "maximum": 1000 - } - }, - "required": [ - "pipette", - "aspirate_rate", - "dispense_rate" - ] - } - } - ] - }, - { - "name": "module-server", - "source_path": ".claude/skills/htn-creator-workspace/servers/bio-opentrons/module_server.py", - "source_digest": "sha256:62f0ea336fc5a196d5180fbecea65f1b59d01723553c334febf1113c977730df", - "transport": "stdio", - "tools": [ - { - "name": "close_labware_latch", - "description": "Close heater-shaker labware latch before shaking. REQUIRED before starting shake operations. Corresponds to Opentrons API: heater_shaker.close_labware_latch()", - "inputSchema": { - "type": "object", - "properties": { - "module_slot": { - "type": "string", - "description": "Slot where heater-shaker is located (e.g., 'D1')" - } - }, - "required": [] - } - }, - { - "name": "close_thermocycler_lid", - "description": "Close the thermocycler lid for thermal cycling. Required before running temperature profiles. Corresponds to GTPyhop action: a_close_thermocycler_lid", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "deactivate_heater_shaker", - "description": "Deactivate the heater-shaker module. Stops both heating and shaking. Corresponds to GTPyhop action: a_deactivate_heater_shaker", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "deactivate_thermocycler", - "description": "Deactivate the thermocycler after completing thermal cycling. Stops heating and returns to ambient temperature. Corresponds to GTPyhop action: a_deactivate_thermocycler", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "delay", - "description": "Delay execution for specified duration (omega_hdq domain). Corresponds to GTPyhop action: a_delay", - "inputSchema": { - "type": "object", - "properties": { - "seconds": { - "type": "number", - "description": "Delay duration in seconds", - "minimum": 0 - }, - "message": { - "type": "string", - "description": "Optional message describing the delay purpose" - } - }, - "required": [ - "seconds" - ] - } - }, - { - "name": "execute_profile", - "description": "Execute a PCR thermocycler profile for specified number of cycles. Lid must be closed and thermocycler must be active. Uses steps array with temperature/hold_time per Opentrons API v2. Corresponds to GTPyhop action: a_execute_thermocycler_profile", - "inputSchema": { - "type": "object", - "properties": { - "steps": { - "type": "array", - "description": "Array of temperature steps for the profile", - "items": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Target temperature in \u00b0C", - "minimum": 4, - "maximum": 99 - }, - "hold_time_seconds": { - "type": "number", - "description": "Hold time in seconds", - "minimum": 0 - }, - "hold_time_minutes": { - "type": "number", - "description": "Hold time in minutes", - "minimum": 0 - } - }, - "required": [ - "temperature" - ] - } - }, - "repetitions": { - "type": "integer", - "description": "Number of times to repeat the profile (1-99)", - "minimum": 1, - "maximum": 99, - "default": 1 - }, - "block_max_volume": { - "type": "number", - "description": "Maximum volume in wells (\u00b5L) for temperature accuracy", - "minimum": 0, - "maximum": 100 - }, - "profile_name": { - "type": "string", - "description": "Profile name (backward compatible, ignored if steps provided)" - }, - "num_cycles": { - "type": "integer", - "description": "Alias for repetitions (backward compatible)", - "minimum": 1, - "maximum": 99 - } - }, - "required": [ - "steps" - ] - } - }, - { - "name": "hs_close_latch", - "description": "Close heater-shaker latch (omega_hdq domain). Corresponds to GTPyhop action: a_hs_close_latch", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "hs_deactivate_shaker", - "description": "Deactivate heater-shaker (omega_hdq domain). Corresponds to GTPyhop action: a_hs_deactivate_shaker", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "hs_open_latch", - "description": "Open heater-shaker latch (omega_hdq domain). Corresponds to GTPyhop action: a_hs_open_latch", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "hs_set_shake_speed", - "description": "Set heater-shaker shake speed (omega_hdq domain). Corresponds to GTPyhop action: a_hs_set_shake_speed", - "inputSchema": { - "type": "object", - "properties": { - "rpm": { - "type": "integer", - "description": "Shaking speed in RPM (0-3000)", - "minimum": 0, - "maximum": 3000 - } - }, - "required": [ - "rpm" - ] - } - }, - { - "name": "hs_set_temperature", - "description": "Set heater-shaker temperature (omega_hdq domain). Corresponds to GTPyhop action: a_hs_set_temperature", - "inputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Target temperature in \u00b0C (4-95)", - "minimum": 4, - "maximum": 95 - } - }, - "required": [ - "temperature" - ] - } - }, - { - "name": "open_labware_latch", - "description": "Open heater-shaker labware latch for loading/unloading plates. SAFETY: Shaking must be stopped before opening latch. Corresponds to Opentrons API: heater_shaker.open_labware_latch()", - "inputSchema": { - "type": "object", - "properties": { - "module_slot": { - "type": "string", - "description": "Slot where heater-shaker is located (e.g., 'D1')" - } - }, - "required": [] - } - }, - { - "name": "open_thermocycler_lid", - "description": "Open the thermocycler lid to allow plate access. Required before loading or retrieving plates. Corresponds to GTPyhop action: a_open_thermocycler_lid", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "set_and_wait_for_shake_speed", - "description": "Set heater-shaker shake speed and wait until target speed is reached. Blocks until operation complete. Latch must be closed. Corresponds to Opentrons API: heater_shaker.set_and_wait_for_shake_speed(rpm)", - "inputSchema": { - "type": "object", - "properties": { - "rpm": { - "type": "integer", - "description": "Target shaking speed in RPM (0-3000)", - "minimum": 0, - "maximum": 3000 - } - }, - "required": [ - "rpm" - ] - } - }, - { - "name": "set_and_wait_for_temperature", - "description": "Set module temperature and wait until target temperature is reached. Blocks until operation complete. Works with heater-shaker and temp module. Corresponds to Opentrons API: module.set_temperature() with wait", - "inputSchema": { - "type": "object", - "properties": { - "celsius": { - "type": "number", - "description": "Target temperature in \u00b0C (4-95 for heater-shaker)", - "minimum": 4, - "maximum": 95 - }, - "module_type": { - "type": "string", - "description": "Module type: 'heater_shaker' or 'temperature'", - "enum": [ - "heater_shaker", - "temperature" - ], - "default": "heater_shaker" - } - }, - "required": [ - "celsius" - ] - } - }, - { - "name": "set_block_temperature", - "description": "Set thermocycler block to a specific temperature with hold time. Lid must be closed. Temperature range: 4-99\u00b0C. Supports hold_time_seconds and hold_time_minutes per Opentrons API v2. Corresponds to GTPyhop action: a_set_thermocycler_temperature", - "inputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Target temperature in \u00b0C (4-99)", - "minimum": 4, - "maximum": 99 - }, - "hold_time": { - "type": "integer", - "description": "Hold time in seconds (0 = indefinite) - backward compatible", - "minimum": 0 - }, - "hold_time_seconds": { - "type": "number", - "description": "Hold time in seconds (Opentrons API v2 compatible)", - "minimum": 0 - }, - "hold_time_minutes": { - "type": "number", - "description": "Hold time in minutes (Opentrons API v2 compatible)", - "minimum": 0 - }, - "block_max_volume": { - "type": "number", - "description": "Maximum volume in wells (\u00b5L) for temperature accuracy optimization", - "minimum": 0, - "maximum": 100 - } - }, - "required": [ - "temperature" - ] - } - }, - { - "name": "set_heater_shaker", - "description": "Set heater-shaker module temperature and shaking speed. Temperature range: 4-95\u00b0C, Speed range: 0-3000 RPM. Corresponds to GTPyhop action: a_set_heater_shaker", - "inputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Target temperature in \u00b0C (4-95)", - "minimum": 4, - "maximum": 95 - }, - "speed": { - "type": "integer", - "description": "Shaking speed in RPM (0-3000)", - "minimum": 0, - "maximum": 3000 - } - }, - "required": [ - "temperature", - "speed" - ] - } - }, - { - "name": "set_temperature", - "description": "Set temperature module to target temperature. Useful for keeping reagents cold during protocols. Corresponds to GTPyhop action: a_set_temperature_module", - "inputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Target temperature in \u00b0C (4-99)", - "minimum": 4, - "maximum": 99 - } - }, - "required": [ - "temperature" - ] - } - }, - { - "name": "temp_set_temperature", - "description": "Set temperature module temperature (omega_hdq domain). Alias for set_temperature. Corresponds to GTPyhop action: a_temp_set_temperature", - "inputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Target temperature in \u00b0C (4-99)", - "minimum": 4, - "maximum": 99 - } - }, - "required": [ - "temperature" - ] - } - } - ] - }, - { - "name": "movement-server", - "source_path": ".claude/skills/htn-creator-workspace/servers/bio-opentrons/movement_server.py", - "source_digest": "sha256:47a2f81337dedb6ebe31a811db55cfb339a41857a3357c3842d57ce88b2493cb", - "transport": "stdio", - "tools": [ - { - "name": "drop_tip", - "description": "Drop the current tip from the pipette into the trash. Pipette must have a tip attached. Corresponds to GTPyhop action: a_drop_tip", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount ('left' or 'right')", - "enum": [ - "left", - "right" - ] - } - }, - "required": [ - "mount" - ] - } - }, - { - "name": "initialize_all", - "description": "Initialize/home the Opentrons Flex movement system before any deck or pipette operations. Mirrors the real robot's startup homing sequence. Corresponds to GTPyhop action: a_initialize_servers", - "inputSchema": { - "type": "object", - "properties": {}, - "required": [] - } - }, - { - "name": "load_labware", - "description": "Load labware onto the Opentrons Flex deck at a specified slot. Slots use format A1-D3 (4 rows \u00d7 3 columns). Corresponds to GTPyhop action: a_load_labware", - "inputSchema": { - "type": "object", - "properties": { - "slot": { - "type": "string", - "description": "Deck slot position (e.g., 'A1', 'B2', 'D3')", - "pattern": "^[A-Da-d][1-3]$" - }, - "labware_type": { - "type": "string", - "description": "Type of labware (e.g., 'nest_96_wellplate_200ul_flat')" - } - }, - "required": [ - "slot", - "labware_type" - ] - } - }, - { - "name": "load_pipette", - "description": "Load a pipette onto the specified mount of the Opentrons Flex. Mount can be 'left' or 'right'. Corresponds to GTPyhop action: a_load_pipette", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount position ('left' or 'right')", - "enum": [ - "left", - "right" - ] - }, - "pipette_type": { - "type": "string", - "description": "Pipette type (e.g., 'flex_1channel_1000', 'flex_8channel_1000')" - } - }, - "required": [ - "mount", - "pipette_type" - ] - } - }, - { - "name": "move_to_well", - "description": "Move pipette to a specific well position in a labware. Labware must be loaded at the specified slot. Corresponds to GTPyhop action: a_move_to_well", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount ('left' or 'right')", - "enum": [ - "left", - "right" - ] - }, - "labware_slot": { - "type": "string", - "description": "Deck slot containing the labware", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Well identifier (e.g., 'A1', 'B6', 'H12')", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - } - }, - "required": [ - "mount", - "labware_slot", - "well" - ] - } - }, - { - "name": "pick_up_tip", - "description": "Pick up a tip from the specified tiprack slot. Pipette must be loaded and not already have a tip. If well is not specified, automatically picks up the next available tip. Corresponds to GTPyhop action: a_pick_up_tip", - "inputSchema": { - "type": "object", - "properties": { - "mount": { - "type": "string", - "description": "Pipette mount ('left' or 'right')", - "enum": [ - "left", - "right" - ] - }, - "tiprack_slot": { - "type": "string", - "description": "Deck slot containing the tiprack (e.g., 'C1')", - "pattern": "^[A-Da-d][1-3]$" - }, - "well": { - "type": "string", - "description": "Specific tip well to pick up (e.g., 'A1', 'B6'). Optional - if not specified, auto-increments to next available tip.", - "pattern": "^[A-Ha-h](1[0-2]|[1-9])$" - } - }, - "required": [ - "mount", - "tiprack_slot" - ] - } - } - ] - } - ] -} diff --git a/crates/candler-schemas/tests/fixtures/upstream/rikyu_mcp.json b/crates/candler-schemas/tests/fixtures/upstream/rikyu_mcp.json deleted file mode 100644 index c3a1206a..00000000 --- a/crates/candler-schemas/tests/fixtures/upstream/rikyu_mcp.json +++ /dev/null @@ -1,2709 +0,0 @@ -{ - "schema": "tool-catalog-snapshot/0", - "captured_at": "2026-10-28T01:09:04+00:00", - "provider": "htn-creator-eval/scripts/capture_catalog_snapshot.py@1", - "environment": { - "python": "3.12.12", - "hpc-agent-core": "0.5.0", - "mcp": "2.0.0", - "pydantic": "2.13.4" - }, - "servers_dir": ".claude/skills/htn-creator-workspace/servers/rikyu_mcp", - "stubbed_modules": [ - "hpc_agent_core.compute", - "hpc_agent_core.compute.slurm", - "hpc_agent_core.middleware", - "hpc_agent_core.rag", - "hpc_agent_core.rag.store", - "hpc_agent_core.serving" - ], - "servers": [ - { - "name": "rikyu-hpc", - "source_path": ".claude/skills/htn-creator-workspace/servers/rikyu_mcp/hpc_server.py", - "source_digest": "sha256:b2af8a23ff6f5ceef36217b7727bf515fbf345472d81e1872bbed43b57e55b4b", - "transport": "stdio", - "tools": [ - { - "name": "cancel_job", - "description": "Cancel a queued or running job via scancel. (IRI: DELETE /compute/job/{job_id})", - "inputSchema": { - "properties": { - "job_id": { - "title": "Job Id", - "type": "string" - } - }, - "required": [ - "job_id" - ], - "title": "cancel_jobArguments", - "type": "object" - }, - "outputSchema": { - "$defs": { - "Container": { - "description": "Container specification (IRI Container); executed via singularity exec.\n\nimage must be a path to a .sif file (absolute or using $HOME) or a\ndocker:// URI. GPU passthrough is added automatically by the rendering\nbackend when the job requests GPUs (vendor-specific flag chosen by that\nmachine's config, e.g. --nv vs --rocm). launcher (e.g. 'srun') is placed\noutside singularity exec so MPI works.", - "properties": { - "image": { - "description": "Singularity image path or URI (e.g. docker://ubuntu:22.04)", - "title": "Image", - "type": "string" - }, - "volume_mounts": { - "items": { - "$ref": "#/$defs/VolumeMount" - }, - "title": "Volume Mounts", - "type": "array" - } - }, - "required": [ - "image" - ], - "title": "Container", - "type": "object" - }, - "Job": { - "description": "IRI Job: identifier + current status + originating spec.", - "properties": { - "id": { - "title": "Id", - "type": "string" - }, - "status": { - "anyOf": [ - { - "$ref": "#/$defs/JobStatus" - }, - { - "type": "null" - } - ], - "default": null - }, - "job_spec": { - "anyOf": [ - { - "$ref": "#/$defs/JobSpec" - }, - { - "type": "null" - } - ], - "default": null - } - }, - "required": [ - "id" - ], - "title": "Job", - "type": "object" - }, - "JobAttributes": { - "description": "Scheduler attributes (IRI/PSI/J JobAttributes subset).\n\nqueue_name has no cross-machine default \u2014 each machine's tool layer\nshould supply its own default_partition (from that machine's config)\nwhen a JobSpec omits one.", - "properties": { - "duration": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "string" - } - ], - "default": 3600, - "description": "Wall time as integer seconds or HH:MM:SS / D-HH:MM:SS string", - "title": "Duration" - }, - "queue_name": { - "default": "", - "description": "Scheduler partition/queue; machine-specific default applied by the tool layer if omitted", - "title": "Queue Name", - "type": "string" - }, - "account": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Account/project to charge", - "title": "Account" - }, - "reservation_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler reservation name (--reservation)", - "title": "Reservation Id" - }, - "custom_attributes": { - "additionalProperties": { - "type": "string" - }, - "title": "Custom Attributes", - "type": "object" - }, - "scheduler": { - "anyOf": [ - { - "$ref": "#/$defs/Scheduler" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Override which SchedulerBackend handles this job, on a machine with more than one; None means the machine's tool layer decides (e.g. from queue_name)" - }, - "parallel_env": { - "default": "smp", - "description": "Grid Engine parallel environment (-pe); ignored by Slurm backends", - "title": "Parallel Env", - "type": "string" - } - }, - "title": "JobAttributes", - "type": "object" - }, - "JobSpec": { - "description": "Job specification (IRI/PSI/J JobSpec subset).\n\nexecutable plus arguments form the command run inside the batch script;\nexecutable may be a shell line (e.g. 'module load foo && srun ./app').\nlauncher, if set, is prepended to executable (e.g. 'srun').\npre_launch / post_launch are script lines inserted before / after.\nIf container is set, the command is wrapped in 'singularity exec'.", - "properties": { - "name": { - "default": "agent-job", - "title": "Name", - "type": "string" - }, - "executable": { - "title": "Executable", - "type": "string" - }, - "arguments": { - "items": { - "type": "string" - }, - "title": "Arguments", - "type": "array" - }, - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Working directory for the job", - "title": "Directory" - }, - "environment": { - "additionalProperties": { - "type": "string" - }, - "title": "Environment", - "type": "object" - }, - "inherit_environment": { - "default": true, - "description": "Inherit submission environment variables", - "title": "Inherit Environment", - "type": "boolean" - }, - "stdin_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Path to use as stdin (--input)", - "title": "Stdin Path" - }, - "stdout_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stdout Path" - }, - "stderr_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stderr Path" - }, - "resources": { - "$ref": "#/$defs/ResourceSpec" - }, - "attributes": { - "$ref": "#/$defs/JobAttributes" - }, - "pre_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert before executable", - "title": "Pre Launch" - }, - "post_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert after executable", - "title": "Post Launch" - }, - "launcher": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Launcher prefix, e.g. 'srun' or 'mpirun -np 4'", - "title": "Launcher" - }, - "container": { - "anyOf": [ - { - "$ref": "#/$defs/Container" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Run inside a Singularity container" - } - }, - "required": [ - "executable" - ], - "title": "JobSpec", - "type": "object" - }, - "JobState": { - "description": "Normalized job states (IRI/PSI-J), mapped from scheduler-native states.", - "enum": [ - "new", - "queued", - "held", - "active", - "completed", - "failed", - "canceled", - "unknown" - ], - "title": "JobState", - "type": "string" - }, - "JobStatus": { - "description": "IRI-compliant job status (state + time + message + exit_code + meta_data).\n\nScheduler-specific detail (native_state, partition, nodes, workdir,\nelapsed, start/end times, queue reason) is carried in meta_data.", - "properties": { - "state": { - "$ref": "#/$defs/JobState" - }, - "time": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Epoch seconds: end_time if finished, start_time if running", - "title": "Time" - }, - "message": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Human-readable status (queue reason, error, etc.)", - "title": "Message" - }, - "exit_code": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exit Code" - }, - "meta_data": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler-specific fields: native_state, partition, nodes, workdir, elapsed, etc.", - "title": "Meta Data" - } - }, - "required": [ - "state" - ], - "title": "JobStatus", - "type": "object" - }, - "ResourceSpec": { - "description": "Resources for a job (PSI/J ResourceSpec + a GPU extension).\n\ngpus is a total-for-the-job GPU count extension (not in upstream PSI/J);\ngpu_cores_per_process is the PSI/J standard equivalent. If both are set,\ngpus takes precedence. How gpus maps to a scheduler flag (--gpus,\n--gres=gpu:N, --gpus-per-node) and whether node_count is derived from it\nor must be set explicitly is a per-machine SchedulerBackend concern \u2014\nsee that machine's compute/ module and config.", - "properties": { - "node_count": { - "default": 1, - "title": "Node Count", - "type": "integer" - }, - "process_count": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Total processes (alternative to processes_per_node \u00d7 node_count)", - "title": "Process Count" - }, - "processes_per_node": { - "default": 1, - "title": "Processes Per Node", - "type": "integer" - }, - "cpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Cpu Cores Per Process" - }, - "gpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "PSI/J standard GPU field; prefer gpus where a machine supports it", - "title": "Gpu Cores Per Process" - }, - "gpus": { - "default": 0, - "description": "Total GPUs requested for the job (machine-specific extension); 0 means no GPU request", - "title": "Gpus", - "type": "integer" - }, - "exclusive_node_use": { - "default": false, - "description": "Request exclusive node allocation (--exclusive)", - "title": "Exclusive Node Use", - "type": "boolean" - }, - "memory": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Memory per node in bytes (maps to --mem)", - "title": "Memory" - } - }, - "title": "ResourceSpec", - "type": "object" - }, - "Scheduler": { - "description": "Target batch scheduler for a job submission \u2014 only meaningful on a\nmachine that composes more than one SchedulerBackend (e.g. a cluster\nwith both a Slurm partition and a Grid Engine partition). Single-scheduler\nmachines can ignore this field entirely.", - "enum": [ - "slurm", - "gridengine" - ], - "title": "Scheduler", - "type": "string" - }, - "VolumeMount": { - "description": "A host path mounted into a container (IRI VolumeMount).", - "properties": { - "source": { - "description": "Host path to mount", - "title": "Source", - "type": "string" - }, - "target": { - "description": "Path inside the container", - "title": "Target", - "type": "string" - }, - "read_only": { - "default": true, - "description": "Mount as read-only", - "title": "Read Only", - "type": "boolean" - } - }, - "required": [ - "source", - "target" - ], - "title": "VolumeMount", - "type": "object" - } - }, - "properties": { - "result": { - "anyOf": [ - { - "$ref": "#/$defs/Job" - }, - { - "type": "string" - } - ], - "title": "Result" - } - }, - "required": [ - "result" - ], - "title": "cancel_jobOutput", - "type": "object" - } - }, - { - "name": "fs_checksum", - "description": "SHA-256 checksum of a remote file. (IRI: GET /filesystem/checksum)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - } - }, - "required": [ - "path" - ], - "title": "fs_checksumArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_checksumOutput", - "type": "object" - } - }, - { - "name": "fs_chmod", - "description": "Change a file/directory's permissions, e.g. mode=\"755\". (IRI: POST /filesystem/chmod)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - }, - "mode": { - "title": "Mode", - "type": "string" - } - }, - "required": [ - "path", - "mode" - ], - "title": "fs_chmodArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_chmodOutput", - "type": "object" - } - }, - { - "name": "fs_chown", - "description": "Change a file/directory's owner (and optionally group, as\n \"user:group\"). Most users can only chown within their own group's\n permissions \u2014 Slurm/Lustre still enforces the actual ACL. (IRI: POST /filesystem/chown)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - }, - "owner": { - "title": "Owner", - "type": "string" - } - }, - "required": [ - "path", - "owner" - ], - "title": "fs_chownArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_chownOutput", - "type": "object" - } - }, - { - "name": "fs_compress", - "description": "Create a tar archive from one or more remote paths. (IRI: POST /filesystem/compress)", - "inputSchema": { - "$defs": { - "CompressionType": { - "description": "Compression format for fs_compress / fs_extract (IRI CompressionType).", - "enum": [ - "none", - "bzip2", - "gzip", - "xz" - ], - "title": "CompressionType", - "type": "string" - } - }, - "properties": { - "paths": { - "items": { - "type": "string" - }, - "title": "Paths", - "type": "array" - }, - "archive_path": { - "title": "Archive Path", - "type": "string" - }, - "compression": { - "$ref": "#/$defs/CompressionType", - "default": "gzip" - } - }, - "required": [ - "paths", - "archive_path" - ], - "title": "fs_compressArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_compressOutput", - "type": "object" - } - }, - { - "name": "fs_cp", - "description": "Copy a file or (with recursive=True) a directory tree on the\n cluster. (IRI: POST /filesystem/cp)", - "inputSchema": { - "properties": { - "source": { - "title": "Source", - "type": "string" - }, - "dest": { - "title": "Dest", - "type": "string" - }, - "recursive": { - "default": false, - "title": "Recursive", - "type": "boolean" - } - }, - "required": [ - "source", - "dest" - ], - "title": "fs_cpArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_cpOutput", - "type": "object" - } - }, - { - "name": "fs_download", - "description": "Download a file from RIKYU via rsync (falling back to scp), with a\n SHA-256 verification of the transfer. (IRI: GET /filesystem/download)", - "inputSchema": { - "properties": { - "remote_path": { - "title": "Remote Path", - "type": "string" - }, - "local_path": { - "title": "Local Path", - "type": "string" - } - }, - "required": [ - "remote_path", - "local_path" - ], - "title": "fs_downloadArguments", - "type": "object" - } - }, - { - "name": "fs_extract", - "description": "Extract an archive on the cluster into dest_dir (created if needed).\n Compression format is auto-detected by tar. (IRI: POST /filesystem/extract)", - "inputSchema": { - "properties": { - "archive_path": { - "title": "Archive Path", - "type": "string" - }, - "dest_dir": { - "default": ".", - "title": "Dest Dir", - "type": "string" - } - }, - "required": [ - "archive_path" - ], - "title": "fs_extractArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_extractOutput", - "type": "object" - } - }, - { - "name": "fs_head", - "description": "Read the first N lines of a file. (IRI: GET /filesystem/head)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - }, - "lines": { - "default": 20, - "title": "Lines", - "type": "integer" - } - }, - "required": [ - "path" - ], - "title": "fs_headArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_headOutput", - "type": "object" - } - }, - { - "name": "fs_ls", - "description": "List a directory's contents (long form). (IRI: GET /filesystem/ls)", - "inputSchema": { - "properties": { - "path": { - "default": ".", - "title": "Path", - "type": "string" - } - }, - "title": "fs_lsArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_lsOutput", - "type": "object" - } - }, - { - "name": "fs_mkdir", - "description": "Create a directory, including parents as needed. (IRI: POST /filesystem/mkdir)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - } - }, - "required": [ - "path" - ], - "title": "fs_mkdirArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_mkdirOutput", - "type": "object" - } - }, - { - "name": "fs_mv", - "description": "Move or rename a file/directory on the cluster. (IRI: POST /filesystem/mv)", - "inputSchema": { - "properties": { - "source": { - "title": "Source", - "type": "string" - }, - "dest": { - "title": "Dest", - "type": "string" - } - }, - "required": [ - "source", - "dest" - ], - "title": "fs_mvArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_mvOutput", - "type": "object" - } - }, - { - "name": "fs_stat", - "description": "File/directory metadata: size, permissions, timestamps, owner. (IRI: GET /filesystem/stat)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - } - }, - "required": [ - "path" - ], - "title": "fs_statArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_statOutput", - "type": "object" - } - }, - { - "name": "fs_symlink", - "description": "Create a symbolic link at link_name pointing to target. (IRI: POST /filesystem/symlink)", - "inputSchema": { - "properties": { - "target": { - "title": "Target", - "type": "string" - }, - "link_name": { - "title": "Link Name", - "type": "string" - } - }, - "required": [ - "target", - "link_name" - ], - "title": "fs_symlinkArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_symlinkOutput", - "type": "object" - } - }, - { - "name": "fs_tail", - "description": "Read the last N lines of a file \u2014 useful for checking a running\n job's stdout/stderr. (IRI: GET /filesystem/tail)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - }, - "lines": { - "default": 20, - "title": "Lines", - "type": "integer" - } - }, - "required": [ - "path" - ], - "title": "fs_tailArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_tailOutput", - "type": "object" - } - }, - { - "name": "fs_upload", - "description": "Upload a local file to RIKYU via rsync (falling back to scp), with a\n SHA-256 verification of the transfer. (IRI: POST /filesystem/upload)", - "inputSchema": { - "properties": { - "local_path": { - "title": "Local Path", - "type": "string" - }, - "remote_path": { - "title": "Remote Path", - "type": "string" - } - }, - "required": [ - "local_path", - "remote_path" - ], - "title": "fs_uploadArguments", - "type": "object" - } - }, - { - "name": "fs_view", - "description": "Read a whole text file's contents. (IRI: GET /filesystem/view)", - "inputSchema": { - "properties": { - "path": { - "title": "Path", - "type": "string" - } - }, - "required": [ - "path" - ], - "title": "fs_viewArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "fs_viewOutput", - "type": "object" - } - }, - { - "name": "get_drained_nodes", - "description": "Nodes currently drained/down and why, via sinfo -R (extension \u2014 not\n an IRI endpoint, but directly useful for \"why won't my job start\").", - "inputSchema": { - "properties": {}, - "title": "get_drained_nodesArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "items": { - "additionalProperties": true, - "type": "object" - }, - "title": "Result", - "type": "array" - } - }, - "required": [ - "result" - ], - "title": "get_drained_nodesOutput", - "type": "object" - } - }, - { - "name": "get_facility", - "description": "Static RIKYU facility facts: the gpu partition, the GPU-count ->\n node/CPU/memory table, storage tiers, modules, and Spack. (IRI: GET /facility)", - "inputSchema": { - "properties": {}, - "title": "get_facilityArguments", - "type": "object" - } - }, - { - "name": "get_job_status", - "description": "Status of a single job. (IRI: GET /compute/job/{job_id})", - "inputSchema": { - "properties": { - "job_id": { - "title": "Job Id", - "type": "string" - } - }, - "required": [ - "job_id" - ], - "title": "get_job_statusArguments", - "type": "object" - }, - "outputSchema": { - "$defs": { - "Container": { - "description": "Container specification (IRI Container); executed via singularity exec.\n\nimage must be a path to a .sif file (absolute or using $HOME) or a\ndocker:// URI. GPU passthrough is added automatically by the rendering\nbackend when the job requests GPUs (vendor-specific flag chosen by that\nmachine's config, e.g. --nv vs --rocm). launcher (e.g. 'srun') is placed\noutside singularity exec so MPI works.", - "properties": { - "image": { - "description": "Singularity image path or URI (e.g. docker://ubuntu:22.04)", - "title": "Image", - "type": "string" - }, - "volume_mounts": { - "items": { - "$ref": "#/$defs/VolumeMount" - }, - "title": "Volume Mounts", - "type": "array" - } - }, - "required": [ - "image" - ], - "title": "Container", - "type": "object" - }, - "JobAttributes": { - "description": "Scheduler attributes (IRI/PSI/J JobAttributes subset).\n\nqueue_name has no cross-machine default \u2014 each machine's tool layer\nshould supply its own default_partition (from that machine's config)\nwhen a JobSpec omits one.", - "properties": { - "duration": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "string" - } - ], - "default": 3600, - "description": "Wall time as integer seconds or HH:MM:SS / D-HH:MM:SS string", - "title": "Duration" - }, - "queue_name": { - "default": "", - "description": "Scheduler partition/queue; machine-specific default applied by the tool layer if omitted", - "title": "Queue Name", - "type": "string" - }, - "account": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Account/project to charge", - "title": "Account" - }, - "reservation_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler reservation name (--reservation)", - "title": "Reservation Id" - }, - "custom_attributes": { - "additionalProperties": { - "type": "string" - }, - "title": "Custom Attributes", - "type": "object" - }, - "scheduler": { - "anyOf": [ - { - "$ref": "#/$defs/Scheduler" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Override which SchedulerBackend handles this job, on a machine with more than one; None means the machine's tool layer decides (e.g. from queue_name)" - }, - "parallel_env": { - "default": "smp", - "description": "Grid Engine parallel environment (-pe); ignored by Slurm backends", - "title": "Parallel Env", - "type": "string" - } - }, - "title": "JobAttributes", - "type": "object" - }, - "JobSpec": { - "description": "Job specification (IRI/PSI/J JobSpec subset).\n\nexecutable plus arguments form the command run inside the batch script;\nexecutable may be a shell line (e.g. 'module load foo && srun ./app').\nlauncher, if set, is prepended to executable (e.g. 'srun').\npre_launch / post_launch are script lines inserted before / after.\nIf container is set, the command is wrapped in 'singularity exec'.", - "properties": { - "name": { - "default": "agent-job", - "title": "Name", - "type": "string" - }, - "executable": { - "title": "Executable", - "type": "string" - }, - "arguments": { - "items": { - "type": "string" - }, - "title": "Arguments", - "type": "array" - }, - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Working directory for the job", - "title": "Directory" - }, - "environment": { - "additionalProperties": { - "type": "string" - }, - "title": "Environment", - "type": "object" - }, - "inherit_environment": { - "default": true, - "description": "Inherit submission environment variables", - "title": "Inherit Environment", - "type": "boolean" - }, - "stdin_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Path to use as stdin (--input)", - "title": "Stdin Path" - }, - "stdout_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stdout Path" - }, - "stderr_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stderr Path" - }, - "resources": { - "$ref": "#/$defs/ResourceSpec" - }, - "attributes": { - "$ref": "#/$defs/JobAttributes" - }, - "pre_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert before executable", - "title": "Pre Launch" - }, - "post_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert after executable", - "title": "Post Launch" - }, - "launcher": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Launcher prefix, e.g. 'srun' or 'mpirun -np 4'", - "title": "Launcher" - }, - "container": { - "anyOf": [ - { - "$ref": "#/$defs/Container" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Run inside a Singularity container" - } - }, - "required": [ - "executable" - ], - "title": "JobSpec", - "type": "object" - }, - "JobState": { - "description": "Normalized job states (IRI/PSI-J), mapped from scheduler-native states.", - "enum": [ - "new", - "queued", - "held", - "active", - "completed", - "failed", - "canceled", - "unknown" - ], - "title": "JobState", - "type": "string" - }, - "JobStatus": { - "description": "IRI-compliant job status (state + time + message + exit_code + meta_data).\n\nScheduler-specific detail (native_state, partition, nodes, workdir,\nelapsed, start/end times, queue reason) is carried in meta_data.", - "properties": { - "state": { - "$ref": "#/$defs/JobState" - }, - "time": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Epoch seconds: end_time if finished, start_time if running", - "title": "Time" - }, - "message": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Human-readable status (queue reason, error, etc.)", - "title": "Message" - }, - "exit_code": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exit Code" - }, - "meta_data": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler-specific fields: native_state, partition, nodes, workdir, elapsed, etc.", - "title": "Meta Data" - } - }, - "required": [ - "state" - ], - "title": "JobStatus", - "type": "object" - }, - "ResourceSpec": { - "description": "Resources for a job (PSI/J ResourceSpec + a GPU extension).\n\ngpus is a total-for-the-job GPU count extension (not in upstream PSI/J);\ngpu_cores_per_process is the PSI/J standard equivalent. If both are set,\ngpus takes precedence. How gpus maps to a scheduler flag (--gpus,\n--gres=gpu:N, --gpus-per-node) and whether node_count is derived from it\nor must be set explicitly is a per-machine SchedulerBackend concern \u2014\nsee that machine's compute/ module and config.", - "properties": { - "node_count": { - "default": 1, - "title": "Node Count", - "type": "integer" - }, - "process_count": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Total processes (alternative to processes_per_node \u00d7 node_count)", - "title": "Process Count" - }, - "processes_per_node": { - "default": 1, - "title": "Processes Per Node", - "type": "integer" - }, - "cpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Cpu Cores Per Process" - }, - "gpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "PSI/J standard GPU field; prefer gpus where a machine supports it", - "title": "Gpu Cores Per Process" - }, - "gpus": { - "default": 0, - "description": "Total GPUs requested for the job (machine-specific extension); 0 means no GPU request", - "title": "Gpus", - "type": "integer" - }, - "exclusive_node_use": { - "default": false, - "description": "Request exclusive node allocation (--exclusive)", - "title": "Exclusive Node Use", - "type": "boolean" - }, - "memory": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Memory per node in bytes (maps to --mem)", - "title": "Memory" - } - }, - "title": "ResourceSpec", - "type": "object" - }, - "Scheduler": { - "description": "Target batch scheduler for a job submission \u2014 only meaningful on a\nmachine that composes more than one SchedulerBackend (e.g. a cluster\nwith both a Slurm partition and a Grid Engine partition). Single-scheduler\nmachines can ignore this field entirely.", - "enum": [ - "slurm", - "gridengine" - ], - "title": "Scheduler", - "type": "string" - }, - "VolumeMount": { - "description": "A host path mounted into a container (IRI VolumeMount).", - "properties": { - "source": { - "description": "Host path to mount", - "title": "Source", - "type": "string" - }, - "target": { - "description": "Path inside the container", - "title": "Target", - "type": "string" - }, - "read_only": { - "default": true, - "description": "Mount as read-only", - "title": "Read Only", - "type": "boolean" - } - }, - "required": [ - "source", - "target" - ], - "title": "VolumeMount", - "type": "object" - } - }, - "description": "IRI Job: identifier + current status + originating spec.", - "properties": { - "id": { - "title": "Id", - "type": "string" - }, - "status": { - "anyOf": [ - { - "$ref": "#/$defs/JobStatus" - }, - { - "type": "null" - } - ], - "default": null - }, - "job_spec": { - "anyOf": [ - { - "$ref": "#/$defs/JobSpec" - }, - { - "type": "null" - } - ], - "default": null - } - }, - "required": [ - "id" - ], - "title": "Job", - "type": "object" - } - }, - { - "name": "get_job_statuses", - "description": "Status of several jobs, or \u2014 if job_ids is empty \u2014 every job the\n current user has touched in roughly the last two days (RIKYU has Slurm\n accounting, so this includes finished jobs, not just the live queue).\n (IRI: GET /compute/jobs)", - "inputSchema": { - "properties": { - "job_ids": { - "items": { - "type": "string" - }, - "title": "Job Ids", - "type": "array" - } - }, - "required": [ - "job_ids" - ], - "title": "get_job_statusesArguments", - "type": "object" - }, - "outputSchema": { - "$defs": { - "Container": { - "description": "Container specification (IRI Container); executed via singularity exec.\n\nimage must be a path to a .sif file (absolute or using $HOME) or a\ndocker:// URI. GPU passthrough is added automatically by the rendering\nbackend when the job requests GPUs (vendor-specific flag chosen by that\nmachine's config, e.g. --nv vs --rocm). launcher (e.g. 'srun') is placed\noutside singularity exec so MPI works.", - "properties": { - "image": { - "description": "Singularity image path or URI (e.g. docker://ubuntu:22.04)", - "title": "Image", - "type": "string" - }, - "volume_mounts": { - "items": { - "$ref": "#/$defs/VolumeMount" - }, - "title": "Volume Mounts", - "type": "array" - } - }, - "required": [ - "image" - ], - "title": "Container", - "type": "object" - }, - "Job": { - "description": "IRI Job: identifier + current status + originating spec.", - "properties": { - "id": { - "title": "Id", - "type": "string" - }, - "status": { - "anyOf": [ - { - "$ref": "#/$defs/JobStatus" - }, - { - "type": "null" - } - ], - "default": null - }, - "job_spec": { - "anyOf": [ - { - "$ref": "#/$defs/JobSpec" - }, - { - "type": "null" - } - ], - "default": null - } - }, - "required": [ - "id" - ], - "title": "Job", - "type": "object" - }, - "JobAttributes": { - "description": "Scheduler attributes (IRI/PSI/J JobAttributes subset).\n\nqueue_name has no cross-machine default \u2014 each machine's tool layer\nshould supply its own default_partition (from that machine's config)\nwhen a JobSpec omits one.", - "properties": { - "duration": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "string" - } - ], - "default": 3600, - "description": "Wall time as integer seconds or HH:MM:SS / D-HH:MM:SS string", - "title": "Duration" - }, - "queue_name": { - "default": "", - "description": "Scheduler partition/queue; machine-specific default applied by the tool layer if omitted", - "title": "Queue Name", - "type": "string" - }, - "account": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Account/project to charge", - "title": "Account" - }, - "reservation_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler reservation name (--reservation)", - "title": "Reservation Id" - }, - "custom_attributes": { - "additionalProperties": { - "type": "string" - }, - "title": "Custom Attributes", - "type": "object" - }, - "scheduler": { - "anyOf": [ - { - "$ref": "#/$defs/Scheduler" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Override which SchedulerBackend handles this job, on a machine with more than one; None means the machine's tool layer decides (e.g. from queue_name)" - }, - "parallel_env": { - "default": "smp", - "description": "Grid Engine parallel environment (-pe); ignored by Slurm backends", - "title": "Parallel Env", - "type": "string" - } - }, - "title": "JobAttributes", - "type": "object" - }, - "JobSpec": { - "description": "Job specification (IRI/PSI/J JobSpec subset).\n\nexecutable plus arguments form the command run inside the batch script;\nexecutable may be a shell line (e.g. 'module load foo && srun ./app').\nlauncher, if set, is prepended to executable (e.g. 'srun').\npre_launch / post_launch are script lines inserted before / after.\nIf container is set, the command is wrapped in 'singularity exec'.", - "properties": { - "name": { - "default": "agent-job", - "title": "Name", - "type": "string" - }, - "executable": { - "title": "Executable", - "type": "string" - }, - "arguments": { - "items": { - "type": "string" - }, - "title": "Arguments", - "type": "array" - }, - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Working directory for the job", - "title": "Directory" - }, - "environment": { - "additionalProperties": { - "type": "string" - }, - "title": "Environment", - "type": "object" - }, - "inherit_environment": { - "default": true, - "description": "Inherit submission environment variables", - "title": "Inherit Environment", - "type": "boolean" - }, - "stdin_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Path to use as stdin (--input)", - "title": "Stdin Path" - }, - "stdout_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stdout Path" - }, - "stderr_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stderr Path" - }, - "resources": { - "$ref": "#/$defs/ResourceSpec" - }, - "attributes": { - "$ref": "#/$defs/JobAttributes" - }, - "pre_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert before executable", - "title": "Pre Launch" - }, - "post_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert after executable", - "title": "Post Launch" - }, - "launcher": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Launcher prefix, e.g. 'srun' or 'mpirun -np 4'", - "title": "Launcher" - }, - "container": { - "anyOf": [ - { - "$ref": "#/$defs/Container" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Run inside a Singularity container" - } - }, - "required": [ - "executable" - ], - "title": "JobSpec", - "type": "object" - }, - "JobState": { - "description": "Normalized job states (IRI/PSI-J), mapped from scheduler-native states.", - "enum": [ - "new", - "queued", - "held", - "active", - "completed", - "failed", - "canceled", - "unknown" - ], - "title": "JobState", - "type": "string" - }, - "JobStatus": { - "description": "IRI-compliant job status (state + time + message + exit_code + meta_data).\n\nScheduler-specific detail (native_state, partition, nodes, workdir,\nelapsed, start/end times, queue reason) is carried in meta_data.", - "properties": { - "state": { - "$ref": "#/$defs/JobState" - }, - "time": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Epoch seconds: end_time if finished, start_time if running", - "title": "Time" - }, - "message": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Human-readable status (queue reason, error, etc.)", - "title": "Message" - }, - "exit_code": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Exit Code" - }, - "meta_data": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler-specific fields: native_state, partition, nodes, workdir, elapsed, etc.", - "title": "Meta Data" - } - }, - "required": [ - "state" - ], - "title": "JobStatus", - "type": "object" - }, - "ResourceSpec": { - "description": "Resources for a job (PSI/J ResourceSpec + a GPU extension).\n\ngpus is a total-for-the-job GPU count extension (not in upstream PSI/J);\ngpu_cores_per_process is the PSI/J standard equivalent. If both are set,\ngpus takes precedence. How gpus maps to a scheduler flag (--gpus,\n--gres=gpu:N, --gpus-per-node) and whether node_count is derived from it\nor must be set explicitly is a per-machine SchedulerBackend concern \u2014\nsee that machine's compute/ module and config.", - "properties": { - "node_count": { - "default": 1, - "title": "Node Count", - "type": "integer" - }, - "process_count": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Total processes (alternative to processes_per_node \u00d7 node_count)", - "title": "Process Count" - }, - "processes_per_node": { - "default": 1, - "title": "Processes Per Node", - "type": "integer" - }, - "cpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Cpu Cores Per Process" - }, - "gpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "PSI/J standard GPU field; prefer gpus where a machine supports it", - "title": "Gpu Cores Per Process" - }, - "gpus": { - "default": 0, - "description": "Total GPUs requested for the job (machine-specific extension); 0 means no GPU request", - "title": "Gpus", - "type": "integer" - }, - "exclusive_node_use": { - "default": false, - "description": "Request exclusive node allocation (--exclusive)", - "title": "Exclusive Node Use", - "type": "boolean" - }, - "memory": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Memory per node in bytes (maps to --mem)", - "title": "Memory" - } - }, - "title": "ResourceSpec", - "type": "object" - }, - "Scheduler": { - "description": "Target batch scheduler for a job submission \u2014 only meaningful on a\nmachine that composes more than one SchedulerBackend (e.g. a cluster\nwith both a Slurm partition and a Grid Engine partition). Single-scheduler\nmachines can ignore this field entirely.", - "enum": [ - "slurm", - "gridengine" - ], - "title": "Scheduler", - "type": "string" - }, - "VolumeMount": { - "description": "A host path mounted into a container (IRI VolumeMount).", - "properties": { - "source": { - "description": "Host path to mount", - "title": "Source", - "type": "string" - }, - "target": { - "description": "Path inside the container", - "title": "Target", - "type": "string" - }, - "read_only": { - "default": true, - "description": "Mount as read-only", - "title": "Read Only", - "type": "boolean" - } - }, - "required": [ - "source", - "target" - ], - "title": "VolumeMount", - "type": "object" - } - }, - "properties": { - "result": { - "items": { - "$ref": "#/$defs/Job" - }, - "title": "Result", - "type": "array" - } - }, - "required": [ - "result" - ], - "title": "get_job_statusesOutput", - "type": "object" - } - }, - { - "name": "get_resource", - "description": "Live occupancy for one named partition. (IRI: GET /resources/{name})", - "inputSchema": { - "properties": { - "name": { - "title": "Name", - "type": "string" - } - }, - "required": [ - "name" - ], - "title": "get_resourceArguments", - "type": "object" - } - }, - { - "name": "get_resources", - "description": "Live occupancy for RIKYU's compute partitions (\"resources\" in IRI\n terms) via sinfo \u2014 allocated/idle/other/total node counts, i.e. \"will a\n job start soon\". RIKYU has exactly one partition, \"gpu\", covering all\n 400 nodes, but the occupancy numbers themselves change constantly, so\n this is a live query (hpc_agent_core's SlurmBackend.get_live_resources),\n not the static rikyu_config.json get_facility reads from.\n (IRI: GET /resources)\n ", - "inputSchema": { - "properties": {}, - "title": "get_resourcesArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "items": { - "additionalProperties": true, - "type": "object" - }, - "title": "Result", - "type": "array" - } - }, - "required": [ - "result" - ], - "title": "get_resourcesOutput", - "type": "object" - } - }, - { - "name": "run_command_on_cluster", - "description": "Run an arbitrary shell command on the login node (extension \u2014 not an\n IRI endpoint). Before calling this, show the user the exact command (or\n script) and a one-line explanation of what it does, then call it \u2014 skip\n the preview only if the user explicitly asked to just run something. Do\n not run heavy computation on the login node \u2014 submit a job instead.\n ", - "inputSchema": { - "properties": { - "command": { - "title": "Command", - "type": "string" - } - }, - "required": [ - "command" - ], - "title": "run_command_on_clusterArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "run_command_on_clusterOutput", - "type": "object" - } - }, - { - "name": "submit_job", - "description": "Submit a job to RIKYU's Slurm scheduler. Show the user the spec\n before submitting unless they asked to just run it (mirrors\n run_command_on_cluster's rule below). If spec.attributes.queue_name is\n left blank, it defaults to RIKYU's only partition, \"gpu\". (IRI: POST /compute/job)\n ", - "inputSchema": { - "$defs": { - "Container": { - "description": "Container specification (IRI Container); executed via singularity exec.\n\nimage must be a path to a .sif file (absolute or using $HOME) or a\ndocker:// URI. GPU passthrough is added automatically by the rendering\nbackend when the job requests GPUs (vendor-specific flag chosen by that\nmachine's config, e.g. --nv vs --rocm). launcher (e.g. 'srun') is placed\noutside singularity exec so MPI works.", - "properties": { - "image": { - "description": "Singularity image path or URI (e.g. docker://ubuntu:22.04)", - "title": "Image", - "type": "string" - }, - "volume_mounts": { - "items": { - "$ref": "#/$defs/VolumeMount" - }, - "title": "Volume Mounts", - "type": "array" - } - }, - "required": [ - "image" - ], - "title": "Container", - "type": "object" - }, - "JobAttributes": { - "description": "Scheduler attributes (IRI/PSI/J JobAttributes subset).\n\nqueue_name has no cross-machine default \u2014 each machine's tool layer\nshould supply its own default_partition (from that machine's config)\nwhen a JobSpec omits one.", - "properties": { - "duration": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "string" - } - ], - "default": 3600, - "description": "Wall time as integer seconds or HH:MM:SS / D-HH:MM:SS string", - "title": "Duration" - }, - "queue_name": { - "default": "", - "description": "Scheduler partition/queue; machine-specific default applied by the tool layer if omitted", - "title": "Queue Name", - "type": "string" - }, - "account": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Account/project to charge", - "title": "Account" - }, - "reservation_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Scheduler reservation name (--reservation)", - "title": "Reservation Id" - }, - "custom_attributes": { - "additionalProperties": { - "type": "string" - }, - "title": "Custom Attributes", - "type": "object" - }, - "scheduler": { - "anyOf": [ - { - "$ref": "#/$defs/Scheduler" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Override which SchedulerBackend handles this job, on a machine with more than one; None means the machine's tool layer decides (e.g. from queue_name)" - }, - "parallel_env": { - "default": "smp", - "description": "Grid Engine parallel environment (-pe); ignored by Slurm backends", - "title": "Parallel Env", - "type": "string" - } - }, - "title": "JobAttributes", - "type": "object" - }, - "JobSpec": { - "description": "Job specification (IRI/PSI/J JobSpec subset).\n\nexecutable plus arguments form the command run inside the batch script;\nexecutable may be a shell line (e.g. 'module load foo && srun ./app').\nlauncher, if set, is prepended to executable (e.g. 'srun').\npre_launch / post_launch are script lines inserted before / after.\nIf container is set, the command is wrapped in 'singularity exec'.", - "properties": { - "name": { - "default": "agent-job", - "title": "Name", - "type": "string" - }, - "executable": { - "title": "Executable", - "type": "string" - }, - "arguments": { - "items": { - "type": "string" - }, - "title": "Arguments", - "type": "array" - }, - "directory": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Working directory for the job", - "title": "Directory" - }, - "environment": { - "additionalProperties": { - "type": "string" - }, - "title": "Environment", - "type": "object" - }, - "inherit_environment": { - "default": true, - "description": "Inherit submission environment variables", - "title": "Inherit Environment", - "type": "boolean" - }, - "stdin_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Path to use as stdin (--input)", - "title": "Stdin Path" - }, - "stdout_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stdout Path" - }, - "stderr_path": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Stderr Path" - }, - "resources": { - "$ref": "#/$defs/ResourceSpec" - }, - "attributes": { - "$ref": "#/$defs/JobAttributes" - }, - "pre_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert before executable", - "title": "Pre Launch" - }, - "post_launch": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Script lines to insert after executable", - "title": "Post Launch" - }, - "launcher": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Launcher prefix, e.g. 'srun' or 'mpirun -np 4'", - "title": "Launcher" - }, - "container": { - "anyOf": [ - { - "$ref": "#/$defs/Container" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Run inside a Singularity container" - } - }, - "required": [ - "executable" - ], - "title": "JobSpec", - "type": "object" - }, - "ResourceSpec": { - "description": "Resources for a job (PSI/J ResourceSpec + a GPU extension).\n\ngpus is a total-for-the-job GPU count extension (not in upstream PSI/J);\ngpu_cores_per_process is the PSI/J standard equivalent. If both are set,\ngpus takes precedence. How gpus maps to a scheduler flag (--gpus,\n--gres=gpu:N, --gpus-per-node) and whether node_count is derived from it\nor must be set explicitly is a per-machine SchedulerBackend concern \u2014\nsee that machine's compute/ module and config.", - "properties": { - "node_count": { - "default": 1, - "title": "Node Count", - "type": "integer" - }, - "process_count": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Total processes (alternative to processes_per_node \u00d7 node_count)", - "title": "Process Count" - }, - "processes_per_node": { - "default": 1, - "title": "Processes Per Node", - "type": "integer" - }, - "cpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Cpu Cores Per Process" - }, - "gpu_cores_per_process": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "PSI/J standard GPU field; prefer gpus where a machine supports it", - "title": "Gpu Cores Per Process" - }, - "gpus": { - "default": 0, - "description": "Total GPUs requested for the job (machine-specific extension); 0 means no GPU request", - "title": "Gpus", - "type": "integer" - }, - "exclusive_node_use": { - "default": false, - "description": "Request exclusive node allocation (--exclusive)", - "title": "Exclusive Node Use", - "type": "boolean" - }, - "memory": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Memory per node in bytes (maps to --mem)", - "title": "Memory" - } - }, - "title": "ResourceSpec", - "type": "object" - }, - "Scheduler": { - "description": "Target batch scheduler for a job submission \u2014 only meaningful on a\nmachine that composes more than one SchedulerBackend (e.g. a cluster\nwith both a Slurm partition and a Grid Engine partition). Single-scheduler\nmachines can ignore this field entirely.", - "enum": [ - "slurm", - "gridengine" - ], - "title": "Scheduler", - "type": "string" - }, - "VolumeMount": { - "description": "A host path mounted into a container (IRI VolumeMount).", - "properties": { - "source": { - "description": "Host path to mount", - "title": "Source", - "type": "string" - }, - "target": { - "description": "Path inside the container", - "title": "Target", - "type": "string" - }, - "read_only": { - "default": true, - "description": "Mount as read-only", - "title": "Read Only", - "type": "boolean" - } - }, - "required": [ - "source", - "target" - ], - "title": "VolumeMount", - "type": "object" - } - }, - "properties": { - "spec": { - "$ref": "#/$defs/JobSpec" - } - }, - "required": [ - "spec" - ], - "title": "submit_jobArguments", - "type": "object" - } - }, - { - "name": "update_job", - "description": "Modify an already-submitted job's Slurm attributes via `scontrol\n update`, e.g. {\"TimeLimit\": \"02:00:00\"} to extend the wall time. Only\n affects jobs still queued or running, and is subject to Slurm's own\n permission rules (some fields can only be lowered, not raised, by a\n non-admin). (IRI: PUT /compute/job/{job_id})\n ", - "inputSchema": { - "properties": { - "job_id": { - "title": "Job Id", - "type": "string" - }, - "updates": { - "additionalProperties": { - "type": "string" - }, - "title": "Updates", - "type": "object" - } - }, - "required": [ - "job_id", - "updates" - ], - "title": "update_jobArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "update_jobOutput", - "type": "object" - } - } - ] - }, - { - "name": "rikyu-docs", - "source_path": ".claude/skills/htn-creator-workspace/servers/rikyu_mcp/docs_server.py", - "source_digest": "sha256:527acd8f431571903257dd51578b2a21bf8bb27b20d274e6fdfe82169968d638", - "transport": "stdio", - "tools": [ - { - "name": "list_doc_sections", - "description": "List every section of the bundled guide (table of contents).", - "inputSchema": { - "properties": {}, - "title": "list_doc_sectionsArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "list_doc_sectionsOutput", - "type": "object" - } - }, - { - "name": "read_doc_section", - "description": "Read one guide section in full by its breadcrumb.\n\n Args:\n breadcrumb: Section path as shown by list_doc_sections or\n search_docs, e.g. 'Running jobs'. Partial matches work.\n ", - "inputSchema": { - "properties": { - "breadcrumb": { - "title": "Breadcrumb", - "type": "string" - } - }, - "required": [ - "breadcrumb" - ], - "title": "read_doc_sectionArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "read_doc_sectionOutput", - "type": "object" - } - }, - { - "name": "search_docs", - "description": "Search the machine's bundled documentation guide.\n\n Always call this first before answering any machine-specific\n question \u2014 job submission, modules, storage, login procedure, or\n any other cluster-specific detail. Do not rely on prior knowledge or\n the orientation facts embedded in skills \u2014 those are fallback aids,\n not authoritative.\n\n If a result carries no \"Source:\" line, that's deliberate (see this\n server's module docstring) \u2014 do not invent or guess a URL to send\n the user to.\n\n If this tool errors or returns no results, fall back to the inline\n facts in the active skill and note that docs were unavailable.\n\n When results begin with `[search_method: bm25]`, inform the user\n that keyword search was used because the embedding server could not\n be reached. Results may miss semantically relevant sections that\n don't share exact keywords with the query.\n\n Args:\n query: Natural-language question or keywords.\n top_k: Number of sections to return.\n ", - "inputSchema": { - "properties": { - "query": { - "title": "Query", - "type": "string" - }, - "top_k": { - "default": 4, - "title": "Top K", - "type": "integer" - } - }, - "required": [ - "query" - ], - "title": "search_docsArguments", - "type": "object" - }, - "outputSchema": { - "properties": { - "result": { - "title": "Result", - "type": "string" - } - }, - "required": [ - "result" - ], - "title": "search_docsOutput", - "type": "object" - } - } - ] - } - ] -} diff --git a/crates/candler-schemas/tests/it/catalog_fixtures.rs b/crates/candler-schemas/tests/it/catalog_fixtures.rs deleted file mode 100644 index 7e7eaed2..00000000 --- a/crates/candler-schemas/tests/it/catalog_fixtures.rs +++ /dev/null @@ -1,522 +0,0 @@ -//! The tool-catalog snapshot against the MCP specification and two catalogs captured from real -//! servers. -//! -//! The specification fixtures are tool objects the MCP `Tool` definition accepts; the snapshot -//! must accept them and keep every key. The real catalogs carry `servers_dir` and -//! `stubbed_modules` at the top level and the tag `tool-catalog-snapshot/0`; these tests rewrite -//! the tag to `SCHEMA_TAG` and move the two keys under `ext`, then check the result. - -// Marks the file as test code, so that clippy's test allowances reach its helpers. -#![cfg(test)] - -use std::fs; -use std::path::{Path, PathBuf}; -use std::slice; -use std::sync::LazyLock; - -use candler_schemas::catalog::{CatalogSnapshot, SCHEMA_TAG, Tool}; -use jsonschema::Validator; -use proptest::prelude::*; -use serde_json::{Map, Value, json}; - -fn manifest_path(parts: &[&str]) -> PathBuf { - let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path.extend(parts); - path -} - -fn read_json(path: &Path) -> Value { - let text = fs::read_to_string(path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); - serde_json::from_str(&text).unwrap_or_else(|e| panic!("{}: {e}", path.display())) -} - -/// The snapshot schema as committed. -static SNAPSHOT_SCHEMA: LazyLock = - LazyLock::new(|| read_json(&manifest_path(&["schema", "catalog-snapshot.schema.json"]))); - -static SNAPSHOT: LazyLock = LazyLock::new(|| { - jsonschema::validator_for(&SNAPSHOT_SCHEMA).expect("the snapshot schema compiles") -}); - -/// The `Tool` definition inside the snapshot schema. -static OUR_TOOL: LazyLock = LazyLock::new(|| { - let schema = json!({ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$ref": "#/$defs/Tool", - "$defs": SNAPSHOT_SCHEMA["$defs"].clone(), - }); - jsonschema::validator_for(&schema).expect("the Tool definition compiles") -}); - -/// The `Tool` definition of the MCP specification, validated by the vendored schema file. -static MCP_TOOL: LazyLock = LazyLock::new(|| { - let mut schema = read_json(&manifest_path(&[ - "tests", - "fixtures", - "spec", - "mcp-2026-07-28.schema.json", - ])); - schema["$ref"] = json!("#/$defs/Tool"); - jsonschema::validator_for(&schema).expect("the MCP schema compiles") -}); - -/// A snapshot of one server around `tools`. -fn wrap(tools: &[Value]) -> Value { - json!({ - "schema": SCHEMA_TAG, - "captured_at": "2026-10-28T01:09:04+00:00", - "provider": "capture@1", - "servers": [{ - "name": "server", - "source_path": "servers/server.py", - "source_digest": format!("sha256:{}", "cd".repeat(32)), - "transport": "stdio", - "tools": tools, - }], - }) -} - -// ---- the MCP specification ------------------------------------------------------------------ - -fn spec_tools() -> Vec<(String, Value)> { - let dir = manifest_path(&["tests", "fixtures", "spec", "tools"]); - let mut files: Vec = fs::read_dir(&dir) - .expect("the spec tool directory is readable") - .map(|entry| entry.expect("a directory entry").path()) - .filter(|path| path.extension().is_some_and(|ext| ext == "json")) - .collect(); - files.sort(); - files - .iter() - .map(|path| { - let name = path - .file_name() - // BORROW: .into_owned() makes the owned file name the pair holds - .map(|name| name.to_string_lossy().into_owned()) - .unwrap_or_default(); - (name, read_json(path)) - }) - .collect() -} - -#[test] -fn catalog_spec_tools_are_valid_mcp_tools() { - let tools = spec_tools(); - assert_eq!(tools.len(), 10); - for (name, tool) in &tools { - assert!(MCP_TOOL.is_valid(tool), "MCP rejects {name}"); - } -} - -#[test] -fn catalog_spec_tools_validate_and_round_trip_inside_a_snapshot() { - for (name, tool) in spec_tools() { - let snapshot = wrap(slice::from_ref(&tool)); - assert!(SNAPSHOT.is_valid(&snapshot), "the schema rejects {name}"); - assert!( - OUR_TOOL.is_valid(&tool), - "the Tool definition rejects {name}" - ); - - let read: CatalogSnapshot = - serde_json::from_value(snapshot.clone()).unwrap_or_else(|e| panic!("{name}: {e}")); - assert_eq!( - serde_json::to_value(&read).expect("writes"), - snapshot, - "{name}" - ); - - let alone: Tool = serde_json::from_value(tool.clone()).expect("a tool reads"); - assert_eq!( - serde_json::to_value(&alone).expect("writes"), - tool, - "{name}" - ); - } -} - -#[test] -fn catalog_full_spec_tool_keeps_icons_and_meta_as_extra_keys() { - let full = spec_tools() - .into_iter() - .find(|(name, _)| name == "full.json") - .map(|(_, tool)| tool) - .expect("full.json is among the spec tools"); - let tool: Tool = serde_json::from_value(full.clone()).expect("reads"); - assert_eq!(tool.title(), Some("Document Search")); - assert!(tool.output_schema().is_some()); - assert_eq!(tool.annotations().map(Map::len), Some(5)); - // BORROW: explicit .as_str() to compare the keys with literals - let mut extra: Vec<&str> = tool.extra().keys().map(String::as_str).collect(); - extra.sort_unstable(); - assert_eq!(extra, ["_meta", "icons"]); - assert_eq!(tool.extra().get("icons"), full.get("icons")); -} - -/// Where the snapshot's `Tool` and the MCP `Tool` agree, where the snapshot accepts more (it records -/// what a server offered) and where it accepts less (an empty name). -/// -/// Each row: the tool, whether MCP accepts it, whether the snapshot accepts it. The schema and -/// the Rust reader agree on every row. -#[test] -fn catalog_tool_verdicts_of_mcp_and_the_snapshot() { - let object = json!({"type": "object"}); - let rows: Vec<(&str, Value, bool, bool)> = vec![ - ( - "required keys only", - json!({"name": "t", "inputSchema": object}), - true, - true, - ), - ( - "empty name", - json!({"name": "", "inputSchema": object}), - true, - false, - ), - ( - "an unknown key", - json!({"name": "t", "inputSchema": object, "x-y": [1]}), - true, - true, - ), - ( - "an unknown key of null", - json!({"name": "t", "inputSchema": object, "x": null}), - true, - true, - ), - ( - "an array output schema", - json!({"name": "t", "inputSchema": object, "outputSchema": {"type": "array"}}), - true, - true, - ), - ( - "an annotation of an unknown key", - json!({"name": "t", "inputSchema": object, "annotations": {"mine": null}}), - true, - true, - ), - ("no input schema", json!({"name": "t"}), false, false), - ("no name", json!({"inputSchema": object}), false, false), - ( - "a string input schema", - json!({"name": "t", "inputSchema": "object"}), - false, - false, - ), - ( - "a numeric title", - json!({"name": "t", "inputSchema": object, "title": 5}), - false, - false, - ), - ( - "a null description", - json!({"name": "t", "inputSchema": object, "description": null}), - false, - false, - ), - ( - "a null output schema", - json!({"name": "t", "inputSchema": object, "outputSchema": null}), - false, - false, - ), - ( - "a null annotations", - json!({"name": "t", "inputSchema": object, "annotations": null}), - false, - false, - ), - ( - "an input schema without a type", - json!({"name": "t", "inputSchema": {}}), - false, - true, - ), - ( - "an input schema of another type", - json!({"name": "t", "inputSchema": {"type": "string"}}), - false, - true, - ), - ( - "a mistyped annotation hint", - json!({"name": "t", "inputSchema": object, "annotations": {"readOnlyHint": "yes"}}), - false, - true, - ), - ( - "icons that are not an array", - json!({"name": "t", "inputSchema": object, "icons": "x"}), - false, - true, - ), - ( - "an icon without a source", - json!({"name": "t", "inputSchema": object, "icons": [{}]}), - false, - true, - ), - ( - "a meta that is not an object", - json!({"name": "t", "inputSchema": object, "_meta": 5}), - false, - true, - ), - ]; - for (what, tool, mcp, ours) in rows { - assert_eq!(MCP_TOOL.is_valid(&tool), mcp, "MCP, {what}"); - assert_eq!(OUR_TOOL.is_valid(&tool), ours, "the schema, {what}"); - assert_eq!( - serde_json::from_value::(tool.clone()).is_ok(), - ours, - "the reader, {what}" - ); - let snapshot = wrap(slice::from_ref(&tool)); - assert_eq!(SNAPSHOT.is_valid(&snapshot), ours, "the snapshot, {what}"); - assert_eq!( - serde_json::from_value::(snapshot).is_ok(), - ours, - "the snapshot reader, {what}" - ); - } -} - -fn arb_json() -> impl Strategy { - let leaf = prop_oneof![ - Just(Value::Null), - any::().prop_map(Value::Bool), - any::().prop_map(Value::from), - "\\PC{0,8}".prop_map(Value::String), - ]; - leaf.prop_recursive(2, 12, 3, |inner| { - prop_oneof![ - prop::collection::vec(inner.clone(), 0..3).prop_map(Value::Array), - prop::collection::btree_map("\\PC{0,5}", inner, 0..3) - .prop_map(|map| Value::Object(map.into_iter().collect())), - ] - }) -} - -/// A tool of the MCP `Tool` definition with every optional key drawn independently. -fn arb_mcp_tool() -> impl Strategy { - let icon = ( - "https://example\\.com/[a-z]{1,8}\\.png", - proptest::option::of("image/[a-z]{3,4}"), - proptest::option::of(prop::collection::vec("[0-9]{2}x[0-9]{2}|any", 0..3)), - proptest::option::of(prop_oneof![Just("dark"), Just("light")]), - ) - .prop_map(|(src, mime, sizes, theme)| { - let mut icon = json!({"src": src}); - if let Some(mime) = mime { - icon["mimeType"] = json!(mime); - } - if let Some(sizes) = sizes { - icon["sizes"] = json!(sizes); - } - if let Some(theme) = theme { - icon["theme"] = json!(theme); - } - icon - }); - let hints = ( - proptest::option::of(any::()), - proptest::option::of(any::()), - proptest::option::of(any::()), - proptest::option::of(any::()), - proptest::option::of("\\PC{0,8}"), - ) - .prop_map(|(read_only, destructive, idempotent, open_world, title)| { - let mut hints = Map::new(); - for (key, flag) in [ - ("readOnlyHint", read_only), - ("destructiveHint", destructive), - ("idempotentHint", idempotent), - ("openWorldHint", open_world), - ] { - if let Some(flag) = flag { - hints.insert(String::from(key), json!(flag)); - } - } - if let Some(title) = title { - hints.insert(String::from("title"), json!(title)); - } - Value::Object(hints) - }); - ( - "\\PC{1,8}", - proptest::option::of("\\PC{0,8}"), - proptest::option::of("\\PC{0,8}"), - prop::collection::btree_map("\\PC{0,5}", arb_json(), 0..3), - proptest::option::of(prop::collection::btree_map("\\PC{0,5}", arb_json(), 0..3)), - proptest::option::of(hints), - proptest::option::of(prop::collection::vec(icon, 0..3)), - proptest::option::of(prop::collection::btree_map("\\PC{0,5}", arb_json(), 0..3)), - ) - .prop_map( - |(name, title, description, input, output, annotations, icons, meta)| { - let mut input: Map = input.into_iter().collect(); - input.insert(String::from("type"), json!("object")); - let mut tool = json!({"name": name, "inputSchema": input}); - if let Some(title) = title { - tool["title"] = json!(title); - } - if let Some(description) = description { - tool["description"] = json!(description); - } - if let Some(output) = output { - tool["outputSchema"] = Value::Object(output.into_iter().collect()); - } - if let Some(annotations) = annotations { - tool["annotations"] = annotations; - } - if let Some(icons) = icons { - tool["icons"] = json!(icons); - } - if let Some(meta) = meta { - tool["_meta"] = Value::Object(meta.into_iter().collect()); - } - tool - }, - ) -} - -proptest! { - #![proptest_config(ProptestConfig::with_cases(128))] - - /// The snapshot narrows MCP only by requiring a non-empty name: any other tool the MCP `Tool` - /// definition accepts is accepted by the schema and the reader and is written back unchanged. - #[test] - fn catalog_accepts_every_tool_mcp_accepts(tool in arb_mcp_tool()) { - prop_assert!(MCP_TOOL.is_valid(&tool), "the generator makes MCP tools: {tool:#}"); - let snapshot = wrap(slice::from_ref(&tool)); - prop_assert!(SNAPSHOT.is_valid(&snapshot), "{snapshot:#}"); - let read: CatalogSnapshot = serde_json::from_str(&serde_json::to_string(&snapshot)?)?; - prop_assert_eq!(serde_json::to_value(&read)?, snapshot); - } -} - -// ---- real catalogs -------------------------------------------------------------------------- - -/// The text of a captured catalog. -fn catalog_text(name: &str) -> String { - let path = manifest_path(&["tests", "fixtures", "upstream", name]); - fs::read_to_string(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display())) -} - -/// A captured catalog as JSON. -fn catalog(name: &str) -> Value { - serde_json::from_str(&catalog_text(name)).expect("a captured catalog is JSON") -} - -/// Rewrites a captured catalog to the shape of `SCHEMA_TAG`: sets the tag and moves -/// `servers_dir` and `stubbed_modules` under `ext`. -fn rewrite(mut snapshot: Value) -> Value { - let object = snapshot.as_object_mut().expect("a snapshot is an object"); - assert_eq!( - object.get("schema"), - Some(&json!("tool-catalog-snapshot/0")), - "the catalog carries the `/0` tag" - ); - object.insert(String::from("schema"), json!(SCHEMA_TAG)); - let mut ext = Map::new(); - for key in ["servers_dir", "stubbed_modules"] { - let value = object - .remove(key) - .unwrap_or_else(|| panic!("the catalog has {key}")); - ext.insert(String::from(key), value); - } - object.insert(String::from("ext"), Value::Object(ext)); - snapshot -} - -fn tool_counts(snapshot: &Value) -> Vec { - snapshot["servers"] - .as_array() - .expect("servers is an array") - .iter() - .map(|server| server["tools"].as_array().map_or(0, Vec::len)) - .collect() -} - -fn assert_catalog_round_trips(file: &str, counts: &[usize]) { - let captured = catalog(file); - let rewritten = rewrite(captured.clone()); - assert_eq!(tool_counts(&rewritten), counts, "{file}"); - - assert!(SNAPSHOT.is_valid(&rewritten), "the schema rejects {file}"); - let snapshot: CatalogSnapshot = - serde_json::from_value(rewritten.clone()).unwrap_or_else(|e| panic!("{file}: {e}")); - assert_eq!( - serde_json::to_value(&snapshot).expect("writes"), - rewritten, - "{file} does not round-trip" - ); - // The same snapshot read from text, pretty-printed and compact. - for text in [ - serde_json::to_string_pretty(&rewritten).expect("writes"), - serde_json::to_string(&rewritten).expect("writes"), - ] { - let from_text: CatalogSnapshot = - serde_json::from_str(&text).unwrap_or_else(|e| panic!("{file}: {e}")); - assert_eq!(from_text, snapshot, "{file} reads differently from text"); - } - assert_eq!(snapshot.servers().len(), counts.len()); - let read_counts: Vec = snapshot.servers().iter().map(|s| s.tools().len()).collect(); - assert_eq!(read_counts, counts); - let ext = snapshot.ext().expect("the rewrite writes ext"); - assert_eq!(ext.get("servers_dir"), captured.get("servers_dir")); - assert_eq!(ext.get("stubbed_modules"), captured.get("stubbed_modules")); - - // The catalog as captured carries the `/0` tag and top-level keys the schema does not allow. - assert!( - !SNAPSHOT.is_valid(&captured), - "the schema accepts the `/0` catalog {file}" - ); - assert!( - serde_json::from_value::(captured.clone()).is_err(), - "Rust accepts the `/0` catalog {file}" - ); - assert!(serde_json::from_str::(&catalog_text(file)).is_err()); - - // The tag and the moved keys are each checked on their own. - let mut tag_only = captured; - tag_only["schema"] = json!(SCHEMA_TAG); - assert!( - !SNAPSHOT.is_valid(&tag_only), - "the schema accepts the top-level keys of {file}" - ); - let mut moved_only = rewritten; - moved_only["schema"] = json!("tool-catalog-snapshot/0"); - assert!(!SNAPSHOT.is_valid(&moved_only)); - assert!(serde_json::from_value::(moved_only).is_err()); -} - -#[test] -fn catalog_rikyu_snapshot_validates_and_round_trips() { - assert_catalog_round_trips("rikyu_mcp.json", &[26, 3]); - let total: usize = tool_counts(&catalog("rikyu_mcp.json")).iter().sum(); - assert_eq!(total, 29); -} - -#[test] -fn catalog_bio_opentrons_snapshot_validates_and_round_trips() { - assert_catalog_round_trips("bio_opentrons.json", &[1, 10, 19, 6]); -} - -/// The reader ignores the top-level keys it does not know: `servers_dir` and `stubbed_modules` -/// under the tag `SCHEMA_TAG` are read and not written back, and only the schema refuses them. -#[test] -fn catalog_unknown_top_level_keys_are_dropped_by_the_reader() { - let mut tag_only = catalog("bio_opentrons.json"); - tag_only["schema"] = json!(SCHEMA_TAG); - assert!(!SNAPSHOT.is_valid(&tag_only)); - let snapshot: CatalogSnapshot = serde_json::from_value(tag_only).expect("reads"); - assert!(snapshot.ext().is_none()); - let written = serde_json::to_value(&snapshot).expect("writes"); - assert!(written.get("servers_dir").is_none()); - assert!(written.get("stubbed_modules").is_none()); -} diff --git a/crates/candler-schemas/tests/it/catalog_properties.rs b/crates/candler-schemas/tests/it/catalog_properties.rs deleted file mode 100644 index 7eb4227c..00000000 --- a/crates/candler-schemas/tests/it/catalog_properties.rs +++ /dev/null @@ -1,745 +0,0 @@ -//! Properties of the tool-catalog snapshot: generated snapshots are valid by the committed schema -//! and by the Rust reader, and round-trip without loss; each rule the format states is refused by -//! both. The cases where the schema and the Rust reader differ are pinned at the end. - -// Marks the file as test code, so that clippy's test allowances reach its helpers. -#![cfg(test)] - -use std::collections::{BTreeMap, BTreeSet}; -use std::fs; -use std::path::{Path, PathBuf}; -use std::sync::LazyLock; - -use candler_schemas::catalog::{CatalogServer, CatalogSnapshot, SCHEMA_TAG, Tool, Transport}; -use candler_schemas::primitives::{Digest, NameToken, RelPath, Timestamp}; -use jsonschema::Validator; -use proptest::prelude::*; -use serde_json::{Map, Value, json}; - -const NAMED_TOOL_KEYS: [&str; 6] = [ - "name", - "title", - "description", - "inputSchema", - "outputSchema", - "annotations", -]; - -const TRANSPORTS: [(&str, Transport); 3] = [ - ("stdio", Transport::Stdio), - ("http", Transport::Http), - ("sse", Transport::Sse), -]; - -fn schema_path() -> PathBuf { - Path::new(env!("CARGO_MANIFEST_DIR")) - .join("schema") - .join("catalog-snapshot.schema.json") -} - -fn read_schema() -> Value { - let text = fs::read_to_string(schema_path()).expect("the committed schema is readable"); - serde_json::from_str(&text).expect("the committed schema is JSON") -} - -static SCHEMA: LazyLock = LazyLock::new(|| { - jsonschema::validator_for(&read_schema()).expect("the committed schema compiles") -}); - -// ---- generated snapshots -------------------------------------------------------------------- - -/// Any JSON value: `null`, booleans, integers, finite floats (zeros of both signs and subnormals -/// included), strings, arrays and objects. -fn arb_json() -> impl Strategy { - let leaf = prop_oneof![ - Just(Value::Null), - any::().prop_map(Value::Bool), - any::().prop_map(Value::from), - any::().prop_map(Value::from), - (prop::num::f64::NORMAL | prop::num::f64::SUBNORMAL | prop::num::f64::ZERO) - .prop_filter_map("finite", |f| { - serde_json::Number::from_f64(f).map(Value::Number) - }), - Just(Value::from(-0.0_f64)), - Just(Value::from(0.0_f64)), - "\\PC{0,8}".prop_map(Value::String), - ]; - leaf.prop_recursive(3, 24, 4, |inner| { - prop_oneof![ - prop::collection::vec(inner.clone(), 0..4).prop_map(Value::Array), - prop::collection::btree_map("\\PC{0,6}", inner, 0..4) - .prop_map(|map| Value::Object(map.into_iter().collect())), - ] - }) -} - -fn arb_object() -> impl Strategy> { - prop::collection::btree_map("\\PC{0,6}", arb_json(), 0..4) - .prop_map(|map| map.into_iter().collect()) -} - -/// Objects whose keys are none of the named keys of a tool. -fn arb_extras() -> impl Strategy> { - let key = "\\PC{0,6}".prop_filter("a named key", |key| { - !NAMED_TOOL_KEYS.iter().any(|named| named == key) - }); - prop::collection::btree_map(key, arb_json(), 0..4).prop_map(|map| map.into_iter().collect()) -} - -#[derive(Debug, Clone)] -struct ToolParts { - name: String, - title: Option, - description: Option, - input_schema: Map, - output_schema: Option>, - annotations: Option>, - extra: Map, -} - -impl ToolParts { - /// The JSON the parts stand for, assembled without the library. - fn value(&self) -> Value { - let mut tool = self.extra.clone(); - tool.insert(String::from("name"), Value::String(self.name.clone())); - tool.insert( - String::from("inputSchema"), - Value::Object(self.input_schema.clone()), - ); - for (key, text) in [("title", &self.title), ("description", &self.description)] { - if let Some(text) = text { - tool.insert(String::from(key), Value::String(text.clone())); - } - } - for (key, object) in [ - ("outputSchema", &self.output_schema), - ("annotations", &self.annotations), - ] { - if let Some(object) = object { - tool.insert(String::from(key), Value::Object(object.clone())); - } - } - Value::Object(tool) - } - - /// The tool the parts stand for, built through the library. - fn built(&self) -> Tool { - let mut tool = Tool::new(self.name.clone(), self.input_schema.clone()) - .expect("generated tool names are not empty"); - if let Some(title) = &self.title { - tool = tool.with_title(title.clone()); - } - if let Some(description) = &self.description { - tool = tool.with_description(description.clone()); - } - if let Some(output_schema) = &self.output_schema { - tool = tool.with_output_schema(output_schema.clone()); - } - if let Some(annotations) = &self.annotations { - tool = tool.with_annotations(annotations.clone()); - } - for (key, value) in &self.extra { - tool = tool - .with_extra(key.clone(), value.clone()) - .expect("generated extra keys are not named keys"); - } - tool - } -} - -/// The items whose key has not occurred before, in order. -fn distinct_by(items: Vec, key: impl Fn(&T) -> String) -> Vec { - let mut seen = BTreeSet::new(); - items - .into_iter() - .filter(|item| seen.insert(key(item))) - .collect() -} - -fn arb_tool() -> impl Strategy { - ( - "\\PC{1,8}", - proptest::option::of("\\PC{0,8}"), - proptest::option::of("\\PC{0,8}"), - arb_object(), - proptest::option::of(arb_object()), - proptest::option::of(arb_object()), - arb_extras(), - ) - .prop_map( - |(name, title, description, input_schema, output_schema, annotations, extra)| { - ToolParts { - name, - title, - description, - input_schema, - output_schema, - annotations, - extra, - } - }, - ) -} - -#[derive(Debug, Clone)] -struct ServerParts { - name: String, - source_path: String, - source_digest: String, - transport: (&'static str, Transport), - tools: Vec, -} - -impl ServerParts { - fn value(&self) -> Value { - json!({ - "name": self.name, - "source_path": self.source_path, - "source_digest": self.source_digest, - "transport": self.transport.0, - "tools": self.tools.iter().map(ToolParts::value).collect::>(), - }) - } - - fn built(&self) -> CatalogServer { - CatalogServer::new( - self.name.clone(), - self.source_path - .parse::() - .expect("generated paths are valid"), - self.source_digest - .parse::() - .expect("generated digests are valid"), - self.transport.1, - self.tools.iter().map(ToolParts::built).collect(), - ) - .expect("generated server and tool names are valid") - } -} - -fn arb_server(min_tools: usize) -> impl Strategy { - ( - "\\PC{1,8}", - "[A-Za-z0-9_-][A-Za-z0-9._-]{0,6}(/[A-Za-z0-9_-][A-Za-z0-9._-]{0,6}){0,3}", - "[0-9a-f]{64}".prop_map(|hex| format!("sha256:{hex}")), - prop::sample::select(TRANSPORTS.to_vec()), - prop::collection::vec(arb_tool(), min_tools..4), - ) - .prop_map( - |(name, source_path, source_digest, transport, tools)| ServerParts { - name, - source_path, - source_digest, - transport, - tools: distinct_by(tools, |tool| tool.name.clone()), - }, - ) -} - -#[derive(Debug, Clone)] -struct SnapshotParts { - captured_at: String, - provider: String, - environment: Option>, - ext: Option>, - servers: Vec, -} - -impl SnapshotParts { - fn value(&self) -> Value { - let mut snapshot = json!({ - "schema": SCHEMA_TAG, - "captured_at": self.captured_at, - "provider": self.provider, - "servers": self.servers.iter().map(ServerParts::value).collect::>(), - }); - if let Some(environment) = &self.environment { - snapshot["environment"] = json!(environment); - } - if let Some(ext) = &self.ext { - snapshot["ext"] = Value::Object(ext.clone()); - } - snapshot - } - - fn built(&self) -> CatalogSnapshot { - let mut builder = CatalogSnapshot::builder() - .captured_at( - self.captured_at - .parse::() - .expect("generated timestamps are valid"), - ) - .provider( - self.provider - .parse::() - .expect("generated providers are valid"), - ); - if let Some(environment) = &self.environment { - builder = builder.environment(environment.clone()); - } - if let Some(ext) = &self.ext { - builder = builder.ext(ext.clone()); - } - for server in &self.servers { - builder = builder.server(server.built()); - } - builder.build().expect("both required fields are set") - } -} - -fn arb_timestamp() -> impl Strategy { - let offset = prop_oneof![ - Just(String::from("Z")), - (any::(), 0u32..24, 0u32..60).prop_map(|(negative, hours, minutes)| { - let sign = if negative { '-' } else { '+' }; - format!("{sign}{hours:02}:{minutes:02}") - }), - ]; - ( - (1970u32..2100, 1u32..=12, 1u32..=28), - (0u32..24, 0u32..60, 0u32..60), - proptest::option::of("[0-9]{1,9}"), - offset, - ) - .prop_map( - |((year, month, day), (hour, minute, second), fraction, offset)| { - let date = format!("{year:04}-{month:02}-{day:02}"); - let time = format!("{hour:02}:{minute:02}:{second:02}"); - let fraction = fraction - .map(|digits| format!(".{digits}")) - .unwrap_or_default(); - format!("{date}T{time}{fraction}{offset}") - }, - ) -} - -fn arb_snapshot(min_servers: usize, min_tools: usize) -> impl Strategy { - ( - arb_timestamp(), - "[A-Za-z0-9_./-]{1,12}@[0-9A-Za-z.+-]{1,8}", - proptest::option::of(prop::collection::btree_map("\\PC{0,6}", "\\PC{0,6}", 0..4)), - proptest::option::of(arb_object()), - prop::collection::vec(arb_server(min_tools), min_servers..3), - ) - .prop_map( - |(captured_at, provider, environment, ext, servers)| SnapshotParts { - captured_at, - provider, - environment, - ext, - servers: distinct_by(servers, |server| server.name.clone()), - }, - ) -} - -proptest! { - #![proptest_config(ProptestConfig::with_cases(128))] - - /// JSON of any shape the format allows is valid by the schema, is read by Rust and is written - /// back as the same value, through text. - #[test] - fn catalog_snapshot_json_with_arbitrary_extra_keys_is_valid_and_round_trips( - parts in arb_snapshot(0, 0), - ) { - let value = parts.value(); - prop_assert!(SCHEMA.is_valid(&value), "the schema rejects {value:#}"); - let text = serde_json::to_string(&value)?; - let snapshot: CatalogSnapshot = serde_json::from_str(&text)?; - prop_assert_eq!(serde_json::to_value(&snapshot)?, value); - // The text is the same too, so a float keeps its sign and its digits. - prop_assert_eq!(serde_json::to_string(&serde_json::to_value(&snapshot)?)?, text); - } - - /// A snapshot built through the builders writes the same JSON, which the schema accepts and - /// Rust reads back as an equal snapshot. - #[test] - fn catalog_snapshot_built_through_the_builders_writes_valid_json_and_reads_back_equal( - parts in arb_snapshot(0, 0), - ) { - let built = parts.built(); - let written = serde_json::to_value(&built)?; - prop_assert_eq!(&written, &parts.value()); - prop_assert!(SCHEMA.is_valid(&written)); - let again: CatalogSnapshot = serde_json::from_str(&serde_json::to_string(&built)?)?; - prop_assert_eq!(again, built); - } -} - -// ---- one mutation per rule ------------------------------------------------------------------ - -/// Both the schema and the Rust reader refuse `value`. -fn assert_rejected(value: &Value) -> Result<(), TestCaseError> { - prop_assert!(!SCHEMA.is_valid(value), "the schema accepts {value:#}"); - prop_assert!( - serde_json::from_value::(value.clone()).is_err(), - "Rust accepts {value:#}" - ); - Ok(()) -} - -/// The value at `pointer`, which every snapshot of `arb_snapshot(1, 1)` has. -fn at<'a>(value: &'a mut Value, pointer: &str) -> &'a mut Value { - value - .pointer_mut(pointer) - .expect("a snapshot of one server and one tool has this path") -} - -fn set(value: &mut Value, pointer: &str, key: &str, replacement: Value) { - if let Some(object) = at(value, pointer).as_object_mut() { - object.insert(String::from(key), replacement); - } -} - -fn remove(value: &mut Value, pointer: &str, key: &str) { - if let Some(object) = at(value, pointer).as_object_mut() { - object.remove(key); - } -} - -const TOOL: &str = "/servers/0/tools/0"; -const SERVER: &str = "/servers/0"; - -fn arb_non_object() -> impl Strategy { - prop_oneof![ - Just(Value::Null), - any::().prop_map(Value::Bool), - any::().prop_map(Value::from), - "\\PC{0,8}".prop_map(Value::String), - prop::collection::vec(arb_json(), 0..3).prop_map(Value::Array), - ] -} - -fn arb_bad_digest() -> impl Strategy { - prop_oneof![ - "[0-9a-f]{64}", - "[0-9a-f]{64}".prop_map(|hex| format!("md5:{hex}")), - "[A-F]{64}".prop_map(|hex| format!("sha256:{hex}")), - "[0-9a-f]{0,63}".prop_map(|hex| format!("sha256:{hex}")), - "[0-9a-f]{65,70}".prop_map(|hex| format!("sha256:{hex}")), - ] -} - -fn arb_bad_source_path() -> impl Strategy { - prop_oneof![ - "/[a-z]{1,5}(/[a-z]{1,5}){0,2}", - "[a-z]{1,4}/\\.\\./[a-z]{1,4}", - Just(String::new()), - "[a-z]{1,4}\\\\[a-z]{1,4}", - "[a-z]{1,4}//[a-z]{1,4}", - ] -} - -fn arb_unknown_transport() -> impl Strategy { - "[a-zA-Z]{1,8}".prop_filter("a known transport", |text| { - !TRANSPORTS.iter().any(|(known, _)| known == text) - }) -} - -/// A field the format names, with the object that holds it, as a pointer and a key. -const NULLABLE: [(&str, &str); 6] = [ - ("", "environment"), - ("", "ext"), - (TOOL, "title"), - (TOOL, "description"), - (TOOL, "outputSchema"), - (TOOL, "annotations"), -]; - -const REQUIRED: [(&str, &str); 11] = [ - ("", "schema"), - ("", "captured_at"), - ("", "provider"), - ("", "servers"), - (SERVER, "name"), - (SERVER, "source_path"), - (SERVER, "source_digest"), - (SERVER, "transport"), - (SERVER, "tools"), - (TOOL, "name"), - (TOOL, "inputSchema"), -]; - -proptest! { - #![proptest_config(ProptestConfig::with_cases(64))] - - #[test] - fn catalog_snapshot_without_input_schema_is_rejected(parts in arb_snapshot(1, 1)) { - let mut value = parts.value(); - remove(&mut value, TOOL, "inputSchema"); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_with_a_non_object_input_schema_is_rejected( - parts in arb_snapshot(1, 1), - bad in arb_non_object(), - ) { - let mut value = parts.value(); - set(&mut value, TOOL, "inputSchema", bad); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_with_a_bad_digest_is_rejected( - parts in arb_snapshot(1, 1), - bad in arb_bad_digest(), - ) { - let mut value = parts.value(); - set(&mut value, SERVER, "source_digest", Value::String(bad)); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_with_a_bad_source_path_is_rejected( - parts in arb_snapshot(1, 1), - bad in arb_bad_source_path(), - ) { - let mut value = parts.value(); - set(&mut value, SERVER, "source_path", Value::String(bad)); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_with_an_unknown_transport_is_rejected( - parts in arb_snapshot(1, 1), - bad in arb_unknown_transport(), - ) { - let mut value = parts.value(); - set(&mut value, SERVER, "transport", Value::String(bad)); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_with_a_null_optional_field_is_rejected( - parts in arb_snapshot(1, 1), - (pointer, key) in prop::sample::select(NULLABLE.to_vec()), - ) { - let mut value = parts.value(); - set(&mut value, pointer, key, Value::Null); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_without_a_required_field_is_rejected( - parts in arb_snapshot(1, 1), - (pointer, key) in prop::sample::select(REQUIRED.to_vec()), - ) { - let mut value = parts.value(); - remove(&mut value, pointer, key); - assert_rejected(&value)?; - } - - #[test] - fn catalog_snapshot_with_another_schema_tag_is_rejected( - parts in arb_snapshot(0, 0), - bad in "[a-z/0-9-]{0,30}".prop_filter("the tag", |text| text != SCHEMA_TAG), - ) { - let mut value = parts.value(); - set(&mut value, "", "schema", Value::String(bad)); - assert_rejected(&value)?; - } - - /// `null` is data inside the open objects of a tool and of the snapshot, so it never makes a - /// snapshot invalid there. - #[test] - fn catalog_snapshot_keeps_null_inside_open_objects(parts in arb_snapshot(1, 1)) { - let mut value = parts.value(); - for (pointer, key) in [ - (TOOL, "inputSchema"), - (TOOL, "outputSchema"), - (TOOL, "annotations"), - ("", "ext"), - ] { - set(&mut value, pointer, key, json!({"nested": null, "list": [null]})); - } - set(&mut value, TOOL, "extra", Value::Null); - prop_assert!(SCHEMA.is_valid(&value)); - let snapshot: CatalogSnapshot = serde_json::from_value(value.clone())?; - prop_assert_eq!(serde_json::to_value(&snapshot)?, value); - } -} - -// ---- where the schema and the Rust reader differ -------------------------------------------- - -fn minimal() -> Value { - json!({ - "schema": SCHEMA_TAG, - "captured_at": "2026-10-28T01:09:04+00:00", - "provider": "capture@1", - "servers": [{ - "name": "s", - "source_path": "servers/s.py", - "source_digest": format!("sha256:{}", "ab".repeat(32)), - "transport": "stdio", - "tools": [{"name": "t", "inputSchema": {"type": "object"}}], - }], - }) -} - -/// The schemas of the snapshot and of a server are strict: they list what a writer emits. The -/// reader ignores a field it does not know, so the field is not written back. -#[test] -fn catalog_unknown_fields_fail_the_schema_and_are_dropped_by_the_reader() { - for (pointer, key) in [("", "servers_dir"), (SERVER, "mode")] { - let mut value = minimal(); - set(&mut value, pointer, key, json!("x")); - assert!(!SCHEMA.is_valid(&value), "{key}"); - let snapshot: CatalogSnapshot = serde_json::from_value(value.clone()).expect("reads"); - assert_eq!(serde_json::to_value(&snapshot).expect("writes"), minimal()); - } -} - -/// The schema states the lexical form of a timestamp; the parser also refuses a date or time -/// that names no instant. -#[test] -fn catalog_timestamp_with_no_instant_passes_the_schema_and_fails_the_reader() { - for text in [ - "2026-13-01T00:00:00Z", - "2026-02-30T00:00:00Z", - "2026-01-01T24:00:00Z", - ] { - let mut value = minimal(); - set(&mut value, "", "captured_at", json!(text)); - assert!(SCHEMA.is_valid(&value), "{text}"); - assert!( - serde_json::from_value::(value).is_err(), - "{text}" - ); - } -} - -/// A repeated key of the JSON text is refused when it names a field of a tool and the last value -/// wins when it is an extra key. -#[test] -fn catalog_repeated_keys_are_refused_for_fields_and_overwritten_for_extra_keys() { - let field = r#"{"name": "a", "name": "b", "inputSchema": {}}"#; - assert!(serde_json::from_str::(field).is_err()); - let extra = r#"{"name": "a", "inputSchema": {}, "x": 1, "x": 2}"#; - let tool: Tool = serde_json::from_str(extra).expect("reads"); - assert_eq!(tool.extra().get("x"), Some(&json!(2))); -} - -/// Names are non-empty by the schema and by the reader. -#[test] -fn catalog_empty_names_fail_the_schema_and_the_reader() { - for pointer in [SERVER, TOOL] { - let mut value = minimal(); - set(&mut value, pointer, "name", json!("")); - assert!(!SCHEMA.is_valid(&value), "{pointer}"); - assert!( - serde_json::from_value::(value).is_err(), - "{pointer}" - ); - } -} - -/// Uniqueness of names is not expressible in JSON Schema: the schema accepts a repeated name, the -/// reader refuses it, and the schema says so in a `$comment`. -#[test] -fn catalog_repeated_names_pass_the_schema_and_fail_the_reader() { - let mut tools = minimal(); - let tool = tools - .pointer("/servers/0/tools/0") - .cloned() - .expect("a tool"); - set(&mut tools, SERVER, "tools", json!([tool.clone(), tool])); - let mut servers = minimal(); - let server = servers.pointer(SERVER).cloned().expect("a server"); - set(&mut servers, "", "servers", json!([server.clone(), server])); - for (what, value) in [("tools", tools), ("servers", servers)] { - assert!(SCHEMA.is_valid(&value), "{what}"); - let error = serde_json::from_value::(value).expect_err(what); - assert!(error.to_string().contains("is repeated within a"), "{what}"); - } - - let schema = read_schema(); - for pointer in [ - "/properties/servers/$comment", - "/$defs/CatalogServer/properties/tools/$comment", - ] { - let comment = schema.pointer(pointer).and_then(Value::as_str); - assert!( - comment.is_some_and(|text| text.contains("JSON Schema cannot state this")), - "{pointer}" - ); - } -} - -/// The environment maps names to text: any other value is refused by both. -#[test] -fn catalog_environment_with_a_non_string_value_is_rejected() { - let mut value = minimal(); - set(&mut value, "", "environment", json!({"python": "3.12"})); - assert!(SCHEMA.is_valid(&value)); - assert!(serde_json::from_value::(value).is_ok()); - for bad in [ - json!(3), - json!(null), - json!(true), - json!(["3"]), - json!({"a": 1}), - ] { - let mut value = minimal(); - set(&mut value, "", "environment", json!({"python": bad})); - assert!(!SCHEMA.is_valid(&value), "{bad}"); - assert!( - serde_json::from_value::(value).is_err(), - "{bad}" - ); - } - for bad in [json!(["python"]), json!("python"), json!(3)] { - let mut value = minimal(); - set(&mut value, "", "environment", bad.clone()); - assert!(!SCHEMA.is_valid(&value), "{bad}"); - assert!( - serde_json::from_value::(value).is_err(), - "{bad}" - ); - } -} - -/// An object nested `depth` levels deep: `{"a": {"a": … {} …}}`. -fn nested(depth: usize) -> Map { - let mut inner = Map::new(); - for _ in 0..depth { - let mut outer = Map::new(); - outer.insert(String::from("a"), Value::Object(inner)); - inner = outer; - } - inner -} - -/// A document nested deeper than the reader's limit is written but not read back. The limit is -/// 128 levels of the whole document, so the depth left for an `inputSchema` is below that. -#[test] -fn catalog_deeply_nested_documents_are_written_and_refused_on_reading() { - let snapshot_with = |depth: usize| { - let tool = Tool::new(String::from("t"), nested(depth)).expect("a tool"); - let server = CatalogServer::new( - String::from("s"), - "a.py".parse::().expect("path"), - Digest::from_hex(&"ab".repeat(32)).expect("digest"), - Transport::Stdio, - vec![tool], - ) - .expect("a server"); - CatalogSnapshot::builder() - .captured_at("2026-10-28T01:09:04Z".parse().expect("timestamp")) - .provider("p@1".parse().expect("provider")) - .server(server) - .build() - .expect("a snapshot") - }; - - let shallow = snapshot_with(50); - let text = serde_json::to_string(&shallow).expect("writes"); - assert_eq!( - serde_json::from_str::(&text).expect("reads"), - shallow - ); - - let deep = snapshot_with(200); - let text = serde_json::to_string(&deep).expect("writes without a limit"); - let error = serde_json::from_str::(&text).expect_err("refused on reading"); - assert!(error.to_string().contains("recursion limit"), "{error}"); -} diff --git a/crates/candler-schemas/tests/it/guard_cell_digest.rs b/crates/candler-schemas/tests/it/guard_cell_digest.rs index 995002ab..5d7ff708 100644 --- a/crates/candler-schemas/tests/it/guard_cell_digest.rs +++ b/crates/candler-schemas/tests/it/guard_cell_digest.rs @@ -7,7 +7,6 @@ use std::collections::BTreeSet; use std::path::Path; use std::str::FromStr; -use candler_schemas::catalog::CatalogSnapshot; use candler_schemas::execution::{ Comparable, Deviation, DigestRef, EnvironmentRef, GitCommit, HarnessIdentity, ImportRecord, Integrity, RunManifest, SecretPresence, TreatmentRef, @@ -71,7 +70,9 @@ fn parts(text: &str) -> Parts { values: field(&doc, "values"), harness: field(&doc, "harness"), treatment: field(&doc, "treatment"), - snapshots: field(&doc, "snapshots"), + snapshots: doc + .get("snapshots") + .map_or_else(Vec::new, |_| field(&doc, "snapshots")), inputs: field(&doc, "inputs"), environments: field(&doc, "environments"), } @@ -304,7 +305,7 @@ fn every_manifest_path_is_classified_and_hashed_parts_move_the_digest() { #[test] fn digests_equal_the_oracle() { let all = vectors(); - assert_eq!(all.len(), 6, "three corpus cells and three invented ones"); + assert_eq!(all.len(), 7, "three corpus cells and four invented ones"); for vector in &all { // BORROW: explicit .as_str() instead of Deref coercion let read: Comparable = serde_json::from_str(vector.comparable.as_str()).expect("reads"); @@ -751,58 +752,6 @@ fn reserved_roots_fill_the_typed_fields_and_absolute_paths_are_refused() { assert!(Comparable::from_resolved(&resolved_values[..2]).is_err()); } -#[derive(Deserialize)] -struct CatalogFile { - vector: Vec, -} - -#[derive(Deserialize)] -struct CatalogVector { - document_a: String, - document_b: String, - document_c: String, - digest_ab: String, - digest_c: String, -} - -/// Guards: Cond 1 — the digest of a catalog snapshot equals the independent one and does not change when only `captured_at` does, so a capture time never splits a cell. Oracle: `catalog_content_digest.toml` (Python `rfc8785`; A and B differ only in `captured_at`, C in a tool description). -#[test] -fn catalog_content_digest_ignores_the_capture_time() { - // BORROW: explicit .as_str() instead of Deref coercion - let file: CatalogFile = - toml::from_str(oracle("catalog_content_digest.toml").as_str()).expect("toml"); - let vector = file.vector.first().expect("a vector"); - // BORROW: explicit .as_str() instead of Deref coercion - let read = |text: &str| serde_json::from_str::(text).expect("snapshot"); - // BORROW: explicit .as_str() instead of Deref coercion - let a = read(vector.document_a.as_str()); - // BORROW: explicit .as_str() instead of Deref coercion - let b = read(vector.document_b.as_str()); - // BORROW: explicit .as_str() instead of Deref coercion - let c = read(vector.document_c.as_str()); - assert_ne!( - a.captured_at(), - b.captured_at(), - "the captures differ in time" - ); - assert_eq!( - // BORROW: explicit .as_str() instead of Deref coercion - a.content_digest().expect("digest").as_str(), - vector.digest_ab - ); - assert_eq!( - // BORROW: explicit .as_str() instead of Deref coercion - b.content_digest().expect("digest").as_str(), - vector.digest_ab - ); - assert_eq!( - // BORROW: explicit .as_str() instead of Deref coercion - c.content_digest().expect("digest").as_str(), - vector.digest_c - ); - assert_ne!(vector.digest_ab, vector.digest_c); -} - /// Guards: Wire rule — an import record keeps the legacy integrity block it was given as a JSON value and reads it back, and `null` is refused where the record is read; the three reader causes are invalid reasons by their snake-case names. Oracle: README §Gotchas wire rules ("`null` is never written"), with the expected texts written by hand. #[test] fn import_record_round_trips_its_legacy_integrity_and_reasons_are_named() { diff --git a/crates/candler-schemas/tests/it/guard_execution_wire.rs b/crates/candler-schemas/tests/it/guard_execution_wire.rs index e00de776..8350a4a8 100644 --- a/crates/candler-schemas/tests/it/guard_execution_wire.rs +++ b/crates/candler-schemas/tests/it/guard_execution_wire.rs @@ -153,7 +153,6 @@ fn comparable() -> Value { "values": [{"path": "plan.a", "value": 1}], "harness": {"name": "h", "version": "1.0.0"}, "treatment": {"name": "t"}, - "snapshots": [], "inputs": [], "environments": [] }) diff --git a/crates/candler-schemas/tests/it/guard_refusal.rs b/crates/candler-schemas/tests/it/guard_refusal.rs index 9e3ecd1c..caeaa246 100644 --- a/crates/candler-schemas/tests/it/guard_refusal.rs +++ b/crates/candler-schemas/tests/it/guard_refusal.rs @@ -155,7 +155,7 @@ fn c1_the_record_of_an_error_carries_its_code_side_path_and_message() { /// The hand list of the codes whose side is `candler`: errors only Candler can raise. No other row /// may be `candler`; an author's error is never blamed on Candler (A5). -const INTERNAL_CODES: [&str; 24] = [ +const INTERNAL_CODES: [&str; 21] = [ "manifest.git_commit_invalid", "manifest.field_unset", "manifest.list_unsorted", @@ -177,20 +177,16 @@ const INTERNAL_CODES: [&str; 24] = [ "format.job_id_invalid", "format.boot_id_invalid", "format.container_id_invalid", - "catalog.field_unset", - "catalog.extra_key_reserved", - "catalog.field_null", ]; /// The variants of each error type the registry covers, counted by hand from the enums: each /// variant has a row, and the wrapping ones are marked as delegating. -const VARIANT_COUNTS: [(&str, usize); 9] = [ +const VARIANT_COUNTS: [(&str, usize); 8] = [ ("ExecutionError", 26), ("EvaluationError", 14), ("OutcomeError", 16), ("FormatError", 19), ("CanonicalError", 5), - ("CatalogError", 6), ("ValuesError", 2), ("SchemaTagError", 1), ("VersionMismatch", 1), diff --git a/crates/candler-schemas/tests/it/guard_wire_shapes.rs b/crates/candler-schemas/tests/it/guard_wire_shapes.rs index de979fd9..85970fb7 100644 --- a/crates/candler-schemas/tests/it/guard_wire_shapes.rs +++ b/crates/candler-schemas/tests/it/guard_wire_shapes.rs @@ -2,17 +2,16 @@ //! The tagged enums of the wire are read from objects and from nothing else. use std::fs; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::str::FromStr; -use candler_schemas::catalog::{CatalogSnapshot, SCHEMA_TAG}; use candler_schemas::evaluation::PluginManifest; use candler_schemas::primitives::NameToken; use candler_schemas::process::{ExitStatus, ProcessStart}; use candler_schemas::refusal::Refusal; use candler_schemas::values::ValueSource; use serde::de::DeserializeOwned; -use serde_json::{Map, Value, json}; +use serde_json::json; fn read(text: &str) -> Result { serde_json::from_str(text) @@ -68,139 +67,6 @@ fn tagged_enums_refuse_the_list_form_and_accept_the_object_form() { ); } -fn fixture_path(parts: &[&str]) -> PathBuf { - let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path.extend(["tests", "fixtures"]); - path.extend(parts); - path -} - -fn json_files(dir: &Path) -> Vec { - let mut files: Vec = fs::read_dir(dir) - .unwrap_or_else(|e| panic!("{}: {e}", dir.display())) - .map(|entry| entry.expect("a directory entry").path()) - .filter(|path| path.extension().is_some_and(|ext| ext == "json")) - .collect(); - files.sort(); - files -} - -fn read_json(path: &Path) -> Value { - let text = fs::read_to_string(path).unwrap_or_else(|e| panic!("{}: {e}", path.display())); - serde_json::from_str(&text).unwrap_or_else(|e| panic!("{}: {e}", path.display())) -} - -/// Every valid catalog snapshot the fixtures hold: the two captured catalogs, rewritten to the -/// current tag with their two extra top-level keys under `ext`, and one snapshot around each -/// MCP specification tool. -fn catalog_snapshot_fixtures() -> Vec<(String, Value)> { - let mut snapshots = Vec::new(); - for path in json_files(&fixture_path(&["upstream"])) { - let mut snapshot = read_json(&path); - let object = snapshot.as_object_mut().expect("a catalog is an object"); - object.insert(String::from("schema"), json!(SCHEMA_TAG)); - let mut ext = Map::new(); - for key in ["servers_dir", "stubbed_modules"] { - ext.insert( - String::from(key), - object.remove(key).expect("a captured key"), - ); - } - object.insert(String::from("ext"), Value::Object(ext)); - snapshots.push((path.display().to_string(), snapshot)); - } - for path in json_files(&fixture_path(&["spec", "tools"])) { - let snapshot = json!({ - "schema": SCHEMA_TAG, - "captured_at": "2026-10-28T01:09:04+00:00", - "provider": "capture@1", - "servers": [{ - "name": "server", - "source_path": "servers/server.py", - "source_digest": format!("sha256:{}", "cd".repeat(32)), - "transport": "stdio", - "tools": [read_json(&path)], - }], - }); - snapshots.push((path.display().to_string(), snapshot)); - } - snapshots -} - -/// JSON pointers to every struct of the catalog wire in `snapshot`: the snapshot, each server -/// and each tool. -fn catalog_struct_pointers(snapshot: &Value) -> Vec { - let mut pointers = vec![String::new()]; - let servers = snapshot["servers"].as_array().expect("servers is a list"); - for (s, server) in servers.iter().enumerate() { - pointers.push(format!("/servers/{s}")); - let tools = server["tools"].as_array().expect("tools is a list"); - for t in 0..tools.len() { - pointers.push(format!("/servers/{s}/tools/{t}")); - } - } - pointers -} - -/// Guards: R01 §Wire encodings, for the catalog wire only (snapshot, server, tool) — a struct is -/// never written as a list of its values. Oracle: every committed valid catalog snapshot reads; -/// with any one of its snapshot, server or tool objects replaced by the list of that object's -/// values, the reader refuses it; the counts of fixtures and of objects tried are above zero. -/// Bite: removing `object_only!` from `CatalogServer` or `MapOnly` from the snapshot reader turns -/// this test red, because the lists are written in the order of the struct's fields. -#[test] -fn catalog_wire_structs_are_refused_as_lists_in_every_fixture() { - let fixtures = catalog_snapshot_fixtures(); - assert!(!fixtures.is_empty(), "no catalog fixture was found"); - let mut tried = 0_usize; - for (name, snapshot) in &fixtures { - serde_json::from_value::(snapshot.clone()) - .unwrap_or_else(|e| panic!("{name} is a valid snapshot: {e}")); - for pointer in catalog_struct_pointers(snapshot) { - let mut mutated = snapshot.clone(); - let node = mutated - .pointer_mut(&pointer) - .expect("the pointer leads to an object"); - // A derived reader that took a list would take the values in the order of the - // struct's fields, an absent optional field being `{}`; a tool has a flattened - // remainder, so any order is a list of its values. - let fields: &[&str] = match pointer.matches('/').count() { - 0 => &[ - "schema", - "captured_at", - "provider", - "environment", - "ext", - "servers", - ], - 2 => &["name", "source_path", "source_digest", "transport", "tools"], - // EXPLICIT: any other depth is a tool, whose flattened extra keys give it no fixed - // field order - _ => &[], - }; - let list: Vec = if fields.is_empty() { - node.as_object() - .expect("an object") - .values() - .cloned() - .collect() - } else { - fields - .iter() - .map(|field| node.get(*field).cloned().unwrap_or_else(|| json!({}))) - .collect() - }; - *node = Value::Array(list); - assert!( - serde_json::from_value::(mutated).is_err(), - "{name}: the object at '{pointer}' written as a list was read" - ); - tried += 1; - } - } - assert!(tried > 0, "no object was tried"); -} - /// Guards: Run manifest — a derived source may record the location its step read; without one it writes no `from`, and an explicit `null` is refused. Oracle: the three wire texts written by hand. #[test] fn derived_source_carries_an_optional_location() { diff --git a/crates/candler-schemas/tests/it/main.rs b/crates/candler-schemas/tests/it/main.rs index 0a6be1e1..d6b513c9 100644 --- a/crates/candler-schemas/tests/it/main.rs +++ b/crates/candler-schemas/tests/it/main.rs @@ -1,8 +1,6 @@ //! The integration tests of this crate, one binary: one module per former test file. #![cfg(test)] -mod catalog_fixtures; -mod catalog_properties; mod guard_cell_digest; mod guard_context_digest; mod guard_evaluator_protocol; From a1bbdbbe20f0446b6d5efe1feba6af02e4752124 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:17:37 +0900 Subject: [PATCH 03/18] refactor(runner): remove the constant catalog producer, show MCP config Deletes the constant catalog program, its capture, the resolve-time catalog step, the provider seam, the fake docker's constant and the blob plumbing that carried the catalog text to the seal. inspect shows the resolved mcp.* values from the cell. The cell digest oracle gains vectors for cells without snapshots; the vectors that list them stay for stores that hold such manifests. The refusal codes only the removed code emitted leave codes.toml, and the contract pages are regenerated. The README purpose paragraph and AGENTS.md name the tool census. Co-Authored-By: Claude Sonnet 5.5 --- AGENTS.md | 4 +- README.md | 2 +- .../m5b/stats/surface/integrity/README.md | 2 +- __roadmap__/m3-lean-cli/refusal_scope.tsv | 2 - .../src/isolation/container/run.rs | 24 +- crates/candler-core/src/isolation/control.rs | 2 +- .../src/jobs/orchestrate/session.rs | 8 - crates/candler-core/src/refusal.rs | 2 - crates/candler-core/src/resolve/preflight.rs | 12 - .../candler-core/src/resolve/steps/catalog.rs | 90 ----- crates/candler-core/src/resolve/steps/mod.rs | 16 +- .../src/runner/evidence/catalog.rs | 312 ------------------ .../candler-core/src/runner/evidence/mod.rs | 3 +- crates/candler-core/src/runner/exec/cell.rs | 11 - crates/candler-core/src/runner/exec/mod.rs | 4 - crates/candler-core/src/runner/refusal.rs | 53 +-- crates/candler-core/src/store/run.rs | 8 - .../it/guard_container_e2e/control_e2e.rs | 13 +- .../tests/it/guard_container_run.rs | 31 +- .../tests/it/guard_egress_setting.rs | 4 +- .../candler-core/tests/it/guard_run_plan.rs | 8 +- .../vectors/catalog_content_digest.toml | 42 --- .../tests/oracle/vectors/cell_digest.toml | 18 +- .../tests/oracle/vectors/gen_vectors.py | 117 +++---- crates/candler/src/commands/inspect.rs | 52 ++- crates/candler/src/commands/preflight.rs | 27 +- .../tests/it/guard_inspect_mcp_config.rs | 16 +- crates/candler/tests/it/support/cli_run.rs | 6 +- .../it/support/contract_pages/refusals.rs | 3 +- docs/contract/codes.toml | 60 ---- docs/contract/index.md | 6 - 31 files changed, 112 insertions(+), 846 deletions(-) delete mode 100644 crates/candler-core/src/resolve/steps/catalog.rs delete mode 100644 crates/candler-core/src/runner/evidence/catalog.rs delete mode 100644 crates/candler-core/tests/oracle/vectors/catalog_content_digest.toml diff --git a/AGENTS.md b/AGENTS.md index 897c15c1..1ed63df7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,9 +5,9 @@ document an agent writes here. Humans follow them too. ## What sane work means in Candler -The README promises provenance, per-run tool-catalog snapshots, and grading of artifacts "already on +The README promises provenance, per-run tool census, and grading of artifacts "already on disk". Those promises hold only if each kind of state Candler stores (a sealed run, its outputs, an -outcome, a catalog snapshot) has one producer, and that producer is Candler's own code. A test that +outcome, a tool census) has one producer, and that producer is Candler's own code. A test that needs such a state asks Candler to make it, under a scripted agent if it must; it does not assemble the state by hand, because a second producer can only agree with the first by luck. Where Candler leans on something it does not own (a container daemon, a harness binary, a model), a stand-in is diff --git a/README.md b/README.md index 83d9467e..53f7552f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A domain-agnostic core for evaluating LLM-based agents. Candler has two equal ha operation API: - **Execution:** run agents under controlled conditions (experiment matrix, runners, isolation, - per-run tool-catalog snapshots, provenance). + per-run tool census, provenance). - **Evaluation:** grade traces and artifacts, fresh or already on disk, through pluggable evaluators that emit one outcome record format. diff --git a/__roadmap__/candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/README.md b/__roadmap__/candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/README.md index ec395d8d..26ee49d8 100644 --- a/__roadmap__/candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/README.md +++ b/__roadmap__/candler-v1/contracts/parity/alignment/surfaces/isolation/m5b/stats/surface/integrity/README.md @@ -4,7 +4,7 @@ Depth 9. M6c Integrity, one level below M6b and above M7, added by amendment A12 as the architecture diet and renamed by amendment A13. The diet's first half (`__roadmap__/diet/`) fixed S1, B1 and three silent acceptances and culled the suite; it landed as PR #57. Those were instances. The rest of M6c removes their causes, as planned in `__reports__/diet/04-architecture_cycle_plan_v2.md`: Candler state with a second producer in tests and fakes (D1), milestones cut by file and gated by counts (D3), an `AGENTS.md` read as a checklist (D4), and inputs with several readers (D5). Its build is the campaign `__roadmap__/integrity/`, on `feat/integrity`. ## Goal -The README's promises of provenance, per-run tool-catalog snapshots, grading "already on disk" and thin surfaces over one API hold by construction: each kind of stored state has one producer, each consumer input has one reader, and an outside consumer's pass on the after tip finds no friction whose cause is D1 to D5. +The README's promises of provenance, per-run tool census, grading "already on disk" and thin surfaces over one API hold by construction: each kind of stored state has one producer, each consumer input has one reader, and an outside consumer's pass on the after tip finds no friction whose cause is D1 to D5. ## Pre-conditions - [x] `../m6b_surface_consolidation.md` is `done` (PR #56) diff --git a/__roadmap__/m3-lean-cli/refusal_scope.tsv b/__roadmap__/m3-lean-cli/refusal_scope.tsv index c0eb8e73..1945dff6 100644 --- a/__roadmap__/m3-lean-cli/refusal_scope.tsv +++ b/__roadmap__/m3-lean-cli/refusal_scope.tsv @@ -29,7 +29,6 @@ candler_core::manifest::compare::VerdictError crates/candler-core/src/manifest/c candler_core::resolve::config::ConfigError crates/candler-core/src/resolve/config.rs 6 yes config resolve refusal_core unreadable/invalid config, unknown key, misplaced key, wrong type, relative cwd candler_core::resolve::preflight::PreflightError crates/candler-core/src/resolve/preflight.rs 1 yes environment resolve refusal_core single detail variant: a preflight step failed (missing dir, binary) candler_core::resolve::preflight::ResolveError crates/candler-core/src/resolve/preflight.rs 6 mixed config resolve refusal_core author-facing: path not UTF-8, Value, Format; internal: step registered twice, derive conflicts -candler_core::runner::evidence::catalog::CatalogError crates/candler-core/src/runner/evidence/catalog.rs 6 mixed environment runner refusal_core author-facing: catalog command failed/timed out/printed none; internal: absolute path, no digest, Unavailable candler_core::runner::evidence::census::CensusError crates/candler-core/src/runner/evidence/census.rs 3 mixed environment runner refusal_core author-facing: NoInit/missing key when Claude Code ran unusably; internal: Value candler_core::runner::evidence::tree::EvidenceError crates/candler-core/src/runner/evidence/tree.rs 2 no candler internal refusal_core outputs of a run held to tree invariants; internal candler_core::runner::exec::cell::ExecError crates/candler-core/src/runner/exec/cell.rs 5 mixed environment runner refusal_core wrapper: transparent IsolationError, StoreError, DriverError, SuperviseError, ExecutionError; no own text but Manifest @@ -42,7 +41,6 @@ candler_harness::driver::DriverError crates/candler-harness/src/driver.rs 5 mixe candler_harness::reader::ReaderError crates/candler-harness/src/reader.rs 3 no candler internal refusal_core frame reader failures on Candler-fed frames candler_harness::spec::CommandSpecError crates/candler-harness/src/spec.rs 3 no candler internal refusal_core command builder invariants candler_schemas::canonical::CanonicalError crates/candler-schemas/src/canonical.rs 5 yes experiment schemas contract_wire non-finite number, integer beyond 2^53-1, repeated key, bad JSON in experiment/suite values -candler_schemas::catalog::CatalogError crates/candler-schemas/src/catalog.rs 6 mixed plugin schemas contract_wire author-facing: schema tag, repeated/empty names (catalog command output); internal: missing field, extra key, null candler_schemas::container::ContainerError crates/candler-schemas/src/container.rs 1 no candler internal contract_wire builder missing-field only candler_schemas::evaluation::EvaluationError crates/candler-schemas/src/evaluation.rs 9 mixed suite schemas contract_wire author-facing: unreadable/non-JSON document, empty list, repeated id, unknown dependency, cycle; internal: missing field candler_schemas::evaluation::VersionMismatch crates/candler-schemas/src/evaluation.rs 1 yes plugin schemas contract_wire struct; evaluator protocol version incompatible with Candler diff --git a/crates/candler-core/src/isolation/container/run.rs b/crates/candler-core/src/isolation/container/run.rs index 5daca6ff..0c90e247 100644 --- a/crates/candler-core/src/isolation/container/run.rs +++ b/crates/candler-core/src/isolation/container/run.rs @@ -6,7 +6,6 @@ //! credentials, are refused rather than overridden. use std::sync::Arc; -use std::time::Duration; use candler_harness::spec::{CommandSpec, EnvEntry, EnvValue}; use candler_schemas::primitives::{ContainerId, Marker, RunKey}; @@ -15,12 +14,11 @@ use url::Url; use super::expiry::{ceil_secs, wrap_expiry}; use super::mounts::{MountError, MountRoots, mounts}; use crate::isolation::RunOutputs; -use crate::isolation::control::ControlSpec; use crate::isolation::docker::{AttachedRun, PROGRAM}; use crate::isolation::driver::DockerDriver; use crate::isolation::hardening::{HardLimits, Role, hardening}; use crate::isolation::layout::{EXPIRY_MARGIN, LABEL_JOB, LABEL_ROLE, LABEL_RUN}; -use crate::isolation::model::{ContainerPlan, ImageId, Limits, UserSpec}; +use crate::isolation::model::{ContainerPlan, UserSpec}; use crate::supervise::hook::StopHook; use crate::supervise::spawn::SpawnRequest; @@ -206,26 +204,6 @@ pub fn create_argv(plan: &ContainerPlan, cmd: &CommandSpec) -> Result Result { - let wrapped = wrap_expiry(cmd, ceil_secs(wall)).map_err(|source| RunArgvError::Command { - detail: source.to_string(), - })?; - // A control container has no gateway: it reserves no name. - Ok(ControlSpec::new(&image.0, HardLimits::sized(limits)) - .env(env_pairs(wrapped.env_overlay(), &[])?) - .command(wrapped.argv().to_vec())) // BORROW: the spec owns its words -} - /// The names the plan reserves for the wrapper: the driver's gateway variables, none when the /// plan names no gateway. fn reserved_names<'a>(plan: &'a ContainerPlan) -> &'a [String] { diff --git a/crates/candler-core/src/isolation/control.rs b/crates/candler-core/src/isolation/control.rs index c850e090..38a9bd3e 100644 --- a/crates/candler-core/src/isolation/control.rs +++ b/crates/candler-core/src/isolation/control.rs @@ -1,5 +1,5 @@ //! The one builder of a control container: a throwaway container Candler runs to read or prepare -//! something, such as a version probe, a package probe, a lock compile, a catalog capture, a +//! something, such as a version probe, a package probe, a lock compile, a //! collect of a run's sessions or the fake model. //! //! A [`ControlSpec`] is every control container's flags in one place: it removes itself, wears the diff --git a/crates/candler-core/src/jobs/orchestrate/session.rs b/crates/candler-core/src/jobs/orchestrate/session.rs index 1c9b245d..9e18a705 100644 --- a/crates/candler-core/src/jobs/orchestrate/session.rs +++ b/crates/candler-core/src/jobs/orchestrate/session.rs @@ -590,14 +590,6 @@ pub fn cells_of( ) // BORROW: the cell owns the evaluator-only inputs .with_evaluation_inputs(spec.evaluation_inputs.clone()) - // BORROW: the cell owns the blob texts its level's steps reported - .with_blobs( - level - .preflight - .iter() - .flat_map(|report| report.blobs.iter().cloned()) - .collect(), - ) // BORROW: the cell owns the package readings of its image .with_packages( image_of(comparable) diff --git a/crates/candler-core/src/refusal.rs b/crates/candler-core/src/refusal.rs index f63d4764..af190b54 100644 --- a/crates/candler-core/src/refusal.rs +++ b/crates/candler-core/src/refusal.rs @@ -328,7 +328,6 @@ fn coded<'e>(error: &'e (dyn Error + 'static)) -> Option<&'e dyn Refusal> { /// The coded type of the schemas crate that `error` is, or `None`. fn schemas_coded<'e>(error: &'e (dyn Error + 'static)) -> Option<&'e dyn Refusal> { use candler_schemas::canonical::CanonicalError; - use candler_schemas::catalog::CatalogError; use candler_schemas::evaluation::{EvaluationError, VersionMismatch}; use candler_schemas::execution::ExecutionError; use candler_schemas::outcome::OutcomeError; @@ -351,7 +350,6 @@ fn schemas_coded<'e>(error: &'e (dyn Error + 'static)) -> Option<&'e dyn Refusal .downcast_ref::() .map(as_refusal) .or_else(|| error.downcast_ref::().map(as_refusal)) - .or_else(|| error.downcast_ref::().map(as_refusal)) .or_else(|| error.downcast_ref::().map(as_refusal)) } diff --git a/crates/candler-core/src/resolve/preflight.rs b/crates/candler-core/src/resolve/preflight.rs index 19ea5724..5adf6153 100644 --- a/crates/candler-core/src/resolve/preflight.rs +++ b/crates/candler-core/src/resolve/preflight.rs @@ -53,10 +53,6 @@ pub struct StepReport { /// The location each derived value was read from, by path, for the values that have one. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub origins: Vec<(FieldPath, String)>, - /// The texts the runner stores as blobs when it seals a run of the cell: evidence that is no - /// part of any cell value, so no digest of a cell reads it. - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub blobs: Vec, /// The checks the step ran. pub checks: Vec, } @@ -69,7 +65,6 @@ impl StepReport { step, derived: Vec::new(), origins: Vec::new(), - blobs: Vec::new(), checks: Vec::new(), } } @@ -91,13 +86,6 @@ impl StepReport { self } - /// Adds a text the runner stores as a blob when it seals a run. - #[must_use] - pub fn blob(mut self, text: String) -> Self { - self.blobs.push(text); - self - } - /// Adds a check result. #[must_use] pub fn check(mut self, check: CheckResult) -> Self { diff --git a/crates/candler-core/src/resolve/steps/catalog.rs b/crates/candler-core/src/resolve/steps/catalog.rs deleted file mode 100644 index c3f84ec1..00000000 --- a/crates/candler-core/src/resolve/steps/catalog.rs +++ /dev/null @@ -1,90 +0,0 @@ -//! The catalog step: the commands the agent can run in the image, as the cell configures it. -//! -//! The cell holds only the digest of the catalog, in `snapshots`. The catalog itself travels in -//! the step's report as a blob text, which the runner stores when it seals a run. - -use std::str::FromStr; -use std::sync::Arc; - -use candler_harness::spec::Cell; -use candler_schemas::execution::DigestRef; -use candler_schemas::primitives::{FieldPath, FormatError, Name, NameToken}; -use candler_schemas::values::JsonValue; -use futures::future::BoxFuture; - -use crate::isolation::model::{ImageId, ImageRef}; -use crate::resolve::preflight::{PreflightError, PreflightStep, ResolveContext, StepReport}; -use crate::runner::evidence::catalog::{CatalogProvider, catalog_digest, catalog_text}; -use candler_schemas::execution::paths; - -fn failed(detail: String) -> PreflightError { - PreflightError::Failed { detail } -} - -fn path_of(text: &str) -> Result { - FieldPath::from_str(text).map_err(|e| failed(e.to_string())) -} - -/// Derives `snapshots`: the digest of the catalog of the image the cell runs in. -pub struct CatalogStep { - name: NameToken, - // TRAIT_OBJECT: the provider lists commands in the image, or is a fake in tests - catalog: Arc, -} - -impl CatalogStep { - /// A step that captures the catalog through `catalog`. - /// - /// # Errors - /// [`FormatError`] when the step name is not a name token. - // TRAIT_OBJECT: the provider lists commands in the image, or is a fake in tests - pub fn new(catalog: Arc) -> Result { - Ok(Self { - name: NameToken::from_str("catalog@1")?, - catalog, - }) - } -} - -impl PreflightStep for CatalogStep { - fn name<'a>(&'a self) -> &'a NameToken { - &self.name - } - - fn run( - &self, - ctx: Arc, - ) -> BoxFuture<'static, Result> { - // BORROW: `Arc::clone` moves a share of the provider into the future - let provider = Arc::clone(&self.catalog); - // BORROW: `.clone()` moves the step name into the future - let step = self.name.clone(); - Box::pin(async move { - let image_path = path_of(paths::ISOLATION_IMAGE)?; - let id = ctx - .get(&image_path) - // BORROW: `.as_str()` borrows the text of the JSON string - .and_then(|value| value.as_value().as_str()) - .ok_or_else(|| failed(format!("`{}` has no image id", paths::ISOLATION_IMAGE)))?; - let image = ImageRef { - id: ImageId(id.to_owned()), // BORROW: owned id for the image reference - harness_version: None, - }; - let catalog = provider - .capture(&image, &Cell::new(&ctx.values)) - .await - .map_err(|e| failed(e.to_string()))?; - let digest = catalog_digest(&catalog).map_err(|e| failed(e.to_string()))?; - let text = catalog_text(&catalog).map_err(|e| failed(e.to_string()))?; - let kind = Name::from_str("catalog").map_err(|e| failed(e.to_string()))?; - let entry = serde_json::to_value([DigestRef::new(kind, digest)]) - .map_err(|e| failed(e.to_string()))?; - Ok(StepReport::new(step) - .derive( - path_of(paths::SNAPSHOTS)?, - JsonValue::new(entry).map_err(|e| failed(e.to_string()))?, - ) - .blob(text)) - }) - } -} diff --git a/crates/candler-core/src/resolve/steps/mod.rs b/crates/candler-core/src/resolve/steps/mod.rs index f75acea9..dc8794e8 100644 --- a/crates/candler-core/src/resolve/steps/mod.rs +++ b/crates/candler-core/src/resolve/steps/mod.rs @@ -1,7 +1,5 @@ -//! The preflight steps that resolve the identity of the harness and the treatment, the image and -//! the command catalog. +//! The preflight steps that resolve the identity of the harness and the treatment and the image. -pub mod catalog; pub mod egress; pub mod env; pub mod gateway; @@ -14,7 +12,6 @@ pub mod session; use std::sync::Arc; -use self::catalog::CatalogStep; use self::egress::EgressStep; use self::identity::{HarnessIdentityStep, TreatmentIdentityStep}; use self::image::ImageIdStep; @@ -22,20 +19,16 @@ use self::plugin_environment::PluginEnvironmentStep; use self::session::SessionModeStep; use super::preflight::{ResolveError, Resolver}; use crate::isolation::image::ImageService; -use crate::runner::evidence::catalog::CatalogProvider; use crate::supervise::Supervisor; use candler_harness::skills::SkillTree; -/// What the image, harness, treatment and catalog steps need from the outside. +/// What the image, harness and treatment steps need from the outside. pub struct M2bServices { /// The supervisor that runs the version probes. pub supervisor: Arc, // TRAIT_OBJECT: the service is docker, or a fake in tests /// Provides the image. pub images: Arc, - // TRAIT_OBJECT: the provider lists commands in the image, or is a fake in tests - /// Captures the command catalog. - pub catalog: Arc, /// The harness versions the driver supports. pub harness_supported: semver::VersionReq, /// Whether the harness's driver runs sessions. @@ -48,8 +41,7 @@ pub struct M2bServices { /// the treatment first (its pinned commit is where requirement sources are read), then the plug-in /// environment (it supplies the image step's values), then the ground truth (a gate: an image /// that would hold evaluator-only bytes is never built), then the image, -/// then the harness (it reads the image), then the catalog, then the session mode, then the egress -/// allowlist. +/// then the harness (it reads the image), then the session mode, then the egress allowlist. /// /// Each step clones the services it holds, so `services` stays with the caller. /// @@ -69,7 +61,6 @@ pub fn register_m2b_steps( services.harness_supported.clone(), // BORROW: the step owns its requirement )?; let treatment = TreatmentIdentityStep::new(Arc::clone(&services.supervisor), services.skills)?; - let catalog = CatalogStep::new(Arc::clone(&services.catalog))?; let session = SessionModeStep::new(services.session_capable)?; let plugin_environment = PluginEnvironmentStep::new()?; let egress = EgressStep::new()?; @@ -79,7 +70,6 @@ pub fn register_m2b_steps( .register(Box::new(ground_truth))? // TRAIT_OBJECT: steps of different types are registered side by side .register(Box::new(image))? // TRAIT_OBJECT: steps of different types are registered side by side .register(Box::new(harness))? // TRAIT_OBJECT: steps of different types are registered side by side - .register(Box::new(catalog))? // TRAIT_OBJECT: steps of different types are registered side by side .register(Box::new(session))? // TRAIT_OBJECT: steps of different types are registered side by side .register(Box::new(egress)) // TRAIT_OBJECT: steps of different types are registered side by side } diff --git a/crates/candler-core/src/runner/evidence/catalog.rs b/crates/candler-core/src/runner/evidence/catalog.rs deleted file mode 100644 index d6f97bb0..00000000 --- a/crates/candler-core/src/runner/evidence/catalog.rs +++ /dev/null @@ -1,312 +0,0 @@ -//! The command catalog of an image: which commands the agent can run. - -use std::path::PathBuf; -use std::sync::Arc; -use std::sync::atomic::{AtomicU64, Ordering}; -use std::time::Duration; - -use candler_harness::spec::{Cell, CommandSpec}; -use candler_schemas::catalog::CatalogSnapshot; -use candler_schemas::primitives::Digest; -use candler_schemas::process::ExitStatus; -use futures::future::BoxFuture; - -use crate::isolation::container::run::catalog_spec; -use crate::isolation::control::ControlSpec; -use crate::isolation::docker::{ClientEnv, DockerCli}; -use crate::isolation::layout; -use crate::isolation::model::{ImageRef, Limits}; -use crate::supervise::Supervisor; -use crate::supervise::stop::{Captured, Ended}; - -/// The exit code of coreutils `timeout` when the command it runs overran. -const TIMEOUT_EXIT: i32 = 124; - -/// How long past the command's own time the docker client may run before the supervisor ends it. -const CLIENT_GRACE: Duration = Duration::from_secs(30); - -/// The most bytes of a catalog that are read. -const OUTPUT_LIMIT: usize = 8 * 1024 * 1024; - -/// The process limit of a control container. -const CONTROL_PIDS: u32 = 64; - -/// The memory limit of a control container. -const CONTROL_MEMORY: &str = "512m"; - -/// The cpu limit of a control container. -const CONTROL_CPUS: f64 = 1.0; - -/// Numbers the record directories of catalog captures within one process. -static CONTROL_CALLS: AtomicU64 = AtomicU64::new(0); - -/// The catalog of one image and cell. -pub type Catalog = CatalogSnapshot; - -/// Why a catalog could not be captured. -#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] -#[non_exhaustive] -pub enum CatalogError { - /// Capture is not available. - #[error("catalog capture is not available: {detail}")] - Unavailable { - /// Which call. - detail: String, - }, - /// The command failed: it exited non-zero or a signal ended it. - #[error("the catalog command failed: {status:?}")] - Command { - /// How the command ended. - status: ExitStatus, - }, - /// The command overran its time. - #[error("the catalog command overran its time")] - Timeout, - /// The command's output is not a catalog. - #[error("the catalog command printed no catalog: {detail}")] - Parse { - /// What is wrong with the output. - detail: String, - }, - /// The catalog holds a path from the host or the image's file system. - #[error("the catalog holds an absolute path: {path}")] - AbsolutePath { - /// The text that holds it. - path: String, - }, - /// The catalog has no canonical form. - #[error("the catalog has no digest: {detail}")] - Digest { - /// Why. - detail: String, - }, -} - -/// The command that lists the catalog inside the image, and the time it gets. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct CatalogCommand { - /// The program and its arguments, run inside the container. - pub argv: Vec, - /// The time the command gets; it is also the inner `timeout`. - pub timeout: Duration, -} - -impl CatalogCommand { - /// A command with the time it gets. - #[must_use] - pub const fn new(argv: Vec, timeout: Duration) -> Self { - Self { argv, timeout } - } -} - -/// Captures the catalog. -pub trait CatalogProvider: Send + Sync { - /// The catalog of `image` as `cell` configures it. - /// - /// # Errors - /// [`CatalogError`] when the image cannot be listed. - fn capture<'a>( - &'a self, - image: &'a ImageRef, - cell: &'a Cell<'_>, - ) -> BoxFuture<'a, Result>; -} - -/// The digest of a catalog. -/// -/// # Errors -/// [`CatalogError::Digest`] when the catalog cannot be digested. -pub fn catalog_digest(catalog: &Catalog) -> Result { - catalog - .content_digest() - .map_err(|error| CatalogError::Digest { - // BORROW: .to_string() gives the error its own text - detail: error.to_string(), - }) -} - -/// The text of a catalog that [`catalog_digest`] hashes. -/// -/// # Errors -/// [`CatalogError::Digest`] when the catalog cannot be written canonically. -pub fn catalog_text(catalog: &Catalog) -> Result { - catalog - .content_text() - .map_err(|error| CatalogError::Digest { - // BORROW: .to_string() gives the error its own text - detail: error.to_string(), - }) -} - -/// The catalog a finished command printed. -/// -/// # Errors -/// [`CatalogError::Timeout`] for a deadline or exit 124, [`CatalogError::Command`] for another -/// non-zero exit or a signal, and [`CatalogError::Parse`] for output that is not a catalog. -pub fn interpret(captured: &Captured) -> Result { - let status = captured.exit.status; - if captured.exit.ended == Ended::Deadline - || matches!(status, ExitStatus::Code { code: TIMEOUT_EXIT }) - { - return Err(CatalogError::Timeout); - } - if !matches!(status, ExitStatus::Code { code: 0 }) { - return Err(CatalogError::Command { status }); - } - let catalog = serde_json::from_slice::(captured.stdout.as_slice()) // BORROW: explicit .as_slice() - .map_err(|error| CatalogError::Parse { - // BORROW: .to_string() gives the error its own text - detail: error.to_string(), - })?; - refuse_absolute_paths(&catalog)?; - Ok(catalog) -} - -/// Whether `token` is an absolute path: a slash, then a segment, and either another slash or the -/// whole text. -fn is_absolute_path(token: &str, whole: bool) -> bool { - let Some(rest) = token.strip_prefix('/') else { - return false; - }; - let Some(first) = rest.chars().next() else { - return false; - }; - if first == '/' || first.is_whitespace() { - return false; - } - whole || rest.contains('/') -} - -/// The first absolute path in the strings of `value`, if any. -fn find_absolute(value: &serde_json::Value) -> Option { - match value { - serde_json::Value::String(text) => { - let whole = !text.contains(char::is_whitespace); - // BORROW: .to_owned() keeps the offending text in the error - text.split_whitespace() - .find(|token| is_absolute_path(token, whole)) - .map(str::to_owned) - } - serde_json::Value::Array(items) => items.iter().find_map(find_absolute), - serde_json::Value::Object(fields) => fields.values().find_map(find_absolute), - serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_) => None, - } -} - -/// Refuses a catalog that holds an absolute path in any of its strings. -/// -/// # Errors -/// [`CatalogError::AbsolutePath`] with the first such text, and [`CatalogError::Digest`] when the -/// catalog cannot be read back as JSON. -pub fn refuse_absolute_paths(catalog: &Catalog) -> Result<(), CatalogError> { - let json = serde_json::to_value(catalog).map_err(|error| CatalogError::Digest { - // BORROW: .to_string() gives the error its own text - detail: error.to_string(), - })?; - match find_absolute(&json) { - Some(path) => Err(CatalogError::AbsolutePath { path }), - None => Ok(()), - } -} - -/// The provider that lists the commands inside the image. -pub struct CommandCatalogProvider { - supervisor: Arc, - cli: DockerCli, - env: ClientEnv, - store_root: PathBuf, - command: CatalogCommand, -} - -impl CommandCatalogProvider { - /// A provider that runs `command` in control containers through the docker client `cli`; - /// each call keeps its record dir under `/control`. - #[must_use] - pub const fn new( - supervisor: Arc, - cli: DockerCli, - env: ClientEnv, - store_root: PathBuf, - command: CatalogCommand, - ) -> Self { - Self { - supervisor, - cli, - env, - store_root, - command, - } - } - - /// The command the provider runs. - #[must_use] - pub const fn command<'a>(&'a self) -> &'a CatalogCommand { - &self.command - } - - /// The control container of the capture. - fn spec(&self, image: &ImageRef) -> Result { - let unavailable = |detail: String| CatalogError::Unavailable { detail }; - let spec = CommandSpec::builder() - // BORROW: .clone() gives the spec its own argv - .argv(self.command.argv.clone()) - .build() - .map_err(|error| unavailable(error.to_string()))?; - let limits = Limits { - pids_limit: CONTROL_PIDS, - // BORROW: .to_owned() gives the limits their own text - memory: CONTROL_MEMORY.to_owned(), - cpus: CONTROL_CPUS, - }; - catalog_spec(&image.id, &limits, self.command.timeout, &spec) - .map_err(|error| unavailable(error.to_string())) - } - - /// Runs the control container with its record dir `records`. - async fn run(&self, image: &ImageRef, records: PathBuf) -> Result { - let unavailable = |detail: String| CatalogError::Unavailable { detail }; - let cli = DockerCli::with_binary( - Arc::clone(&self.supervisor), - self.cli.binary().to_path_buf(), // BORROW: the client owns its binary path - self.env.clone(), // BORROW: the client owns its environment - records, - ); - let captured = cli - .control( - &self.spec(image)?, - self.command.timeout + CLIENT_GRACE, - OUTPUT_LIMIT, - ) - .await - .map_err(|error| unavailable(format!("the command cannot run: {error}")))?; - interpret(&captured) - } - - async fn capture_one(&self, image: &ImageRef) -> Result { - let records = layout::control_dir(&self.store_root).join(format!( - "{}-{}", - std::process::id(), - CONTROL_CALLS.fetch_add(1, Ordering::Relaxed) - )); - tokio::fs::create_dir_all(&records) - .await - .map_err(|error| CatalogError::Unavailable { - detail: format!("cannot create the record dir: {error}"), - })?; - // BORROW: .clone() keeps the record dir for its removal - let outcome = self.run(image, records.clone()).await; - // The record dir is this call's own and holds only this call's record. - let _ = tokio::fs::remove_dir_all(&records).await; - outcome - } -} - -impl CatalogProvider for CommandCatalogProvider { - fn capture<'a>( - &'a self, - image: &'a ImageRef, - _cell: &'a Cell<'_>, - ) -> BoxFuture<'a, Result> { - Box::pin(self.capture_one(image)) - } -} diff --git a/crates/candler-core/src/runner/evidence/mod.rs b/crates/candler-core/src/runner/evidence/mod.rs index 2452d5d6..e76552e3 100644 --- a/crates/candler-core/src/runner/evidence/mod.rs +++ b/crates/candler-core/src/runner/evidence/mod.rs @@ -1,7 +1,6 @@ -//! The evidence a run leaves: its catalog, its census, the leak check, its session measures and +//! The evidence a run leaves: its census, the leak check, its session measures and //! its tree. -pub mod catalog; pub mod census; pub mod leak; mod measure; diff --git a/crates/candler-core/src/runner/exec/cell.rs b/crates/candler-core/src/runner/exec/cell.rs index dccac3a9..6105ed4c 100644 --- a/crates/candler-core/src/runner/exec/cell.rs +++ b/crates/candler-core/src/runner/exec/cell.rs @@ -39,9 +39,6 @@ pub struct CellRun { /// The evaluator-only inputs the cell declares, as `{kind, digest}`: the manifest lists them, /// and no run is given their content. pub evaluation_inputs: Vec, - /// The texts stored as blobs when a run of the cell is sealed: the canonical catalog snapshot - /// each `snapshots` digest names. - pub blobs: Vec, /// The record of the session controls the cell's runs rely on; none for a cell that is not a /// session. pub control: Option, @@ -69,7 +66,6 @@ impl CellRun { inputs, packages: PackageReadings::new(), evaluation_inputs: Vec::new(), - blobs: Vec::new(), control: None, } } @@ -88,13 +84,6 @@ impl CellRun { self } - /// The record with the texts its runs store as blobs when they seal. - #[must_use] - pub fn with_blobs(mut self, blobs: Vec) -> Self { - self.blobs = blobs; - self - } - /// The record with the readings of the named packages in its env image. #[must_use] pub fn with_packages(mut self, packages: PackageReadings) -> Self { diff --git a/crates/candler-core/src/runner/exec/mod.rs b/crates/candler-core/src/runner/exec/mod.rs index a07ab66b..80cf4d71 100644 --- a/crates/candler-core/src/runner/exec/mod.rs +++ b/crates/candler-core/src/runner/exec/mod.rs @@ -930,11 +930,7 @@ async fn drive( // The seal syncs every file and directory it writes, so it runs off the async workers. let tree = evidence.tree; let outputs_root = workspace_dir.clone(); // BORROW: the seal task owns its copy of the root - let blobs = cell.blobs.clone(); // BORROW: the seal task owns its copy of the blob texts tokio::task::spawn_blocking(move || { - for text in &blobs { - writer.blob(text.as_bytes())?; // BORROW: the store hashes and writes the text's bytes - } seal_run(writer, &outputs_root, &last, &tree, &raw_files, &trace) }) .await diff --git a/crates/candler-core/src/runner/refusal.rs b/crates/candler-core/src/runner/refusal.rs index e8d33f56..0923de57 100644 --- a/crates/candler-core/src/runner/refusal.rs +++ b/crates/candler-core/src/runner/refusal.rs @@ -8,7 +8,6 @@ use std::error::Error; use crate::refusal::wrapper_table; -use crate::runner::evidence::catalog::CatalogError; use crate::runner::evidence::census::CensusError; use crate::runner::evidence::tree::EvidenceError; use crate::runner::exec::cell::ExecError; @@ -130,46 +129,6 @@ wrapper_table! { Supervise (inner) => delegate(inner, Side::Environment), } -refusal_table! { - CatalogError, path = no_path; - Unavailable { .. } => row( - "candler.internal", - Side::Candler, - "Catalog capture is not wired in this build.", - "-", - ), - Command { .. } => row( - "runner.catalog_command_failed", - Side::Environment, - "The command that prints the tool catalog exited non-zero or was ended by a signal.", - "-", - ), - Timeout { .. } => row( - "runner.catalog_timeout", - Side::Environment, - "The command that prints the tool catalog overran its time.", - "-", - ), - Parse { .. } => row( - "runner.catalog_unreadable", - Side::Environment, - "The output of the catalog command is not a tool catalog.", - "-", - ), - AbsolutePath { .. } => row( - "candler.internal", - Side::Candler, - "The catalog holds a path from the host or the image's file system.", - "-", - ), - Digest { .. } => row( - "candler.internal", - Side::Candler, - "The catalog has no canonical form.", - "-", - ), -} - refusal_table! { CensusError, path = no_path; NoInit { .. } => row( @@ -211,10 +170,9 @@ refusal_table! { /// The rows of every coded error of this module, in the order of the types. #[must_use] pub(crate) fn catalog() -> Vec { - let tables: [&'static [CatalogRow]; 5] = [ + let tables: [&'static [CatalogRow]; 4] = [ ::rows(), ::rows(), - ::rows(), ::rows(), ::rows(), ]; @@ -276,14 +234,9 @@ pub(crate) fn coded<'e>(error: &'e (dyn Error + 'static)) -> Option<&'e dyn Refu .map(exec_answer) .or_else(|| { error - .downcast_ref::() + .downcast_ref::() .map(as_refusal) - .or_else(|| { - error - .downcast_ref::() - .map(as_refusal) - .or_else(|| error.downcast_ref::().map(as_refusal)) - }) + .or_else(|| error.downcast_ref::().map(as_refusal)) }) }) } diff --git a/crates/candler-core/src/store/run.rs b/crates/candler-core/src/store/run.rs index eca0c132..c399b2c9 100644 --- a/crates/candler-core/src/store/run.rs +++ b/crates/candler-core/src/store/run.rs @@ -163,14 +163,6 @@ impl RunWriter { self.sync_run_dir() } - /// Stores `bytes` as a blob under their own digest, which the run's manifest already names. - /// - /// # Errors - /// Returns [`StoreError::Io`] when a write fails. - pub fn blob(&self, bytes: &[u8]) -> Result<(), StoreError> { - self.store.put_blob(bytes, None).map(|_| ()) - } - /// Stores the bytes of the output file at `path` as the blob of `sha256`, the digest its /// tree entry names. /// diff --git a/crates/candler-core/tests/it/guard_container_e2e/control_e2e.rs b/crates/candler-core/tests/it/guard_container_e2e/control_e2e.rs index 0132f10b..0fbc4bfc 100644 --- a/crates/candler-core/tests/it/guard_container_e2e/control_e2e.rs +++ b/crates/candler-core/tests/it/guard_container_e2e/control_e2e.rs @@ -5,7 +5,6 @@ use std::time::Duration; use candler_core::isolation::container::exec::collect_spec; use candler_core::isolation::container::mounts::{MountMode, MountSpec}; -use candler_core::isolation::container::run::catalog_spec; use candler_core::isolation::control::outcome; use candler_core::isolation::docker::{ClientEnv, DockerCli}; use candler_core::isolation::driver::DockerDriver as _; @@ -42,7 +41,7 @@ fn command(argv: &[&str]) -> CommandSpec { } /// Guards: R01 §Process supervision (control containers) — each kind of control container the -/// core builds, the harness version probe, the package probe, the catalog capture and the collect +/// core builds, the harness version probe, the package probe and the collect /// of a run's files, runs on the real agent base image, built through `DockerImageService::base`, /// reads what its caller put there, and gets a home the read-only root leaves writable. /// Oracle: the image's own `candler.cc_version` label as docker reports it, the distribution @@ -140,21 +139,11 @@ async fn control_each_kind_runs_on_the_real_base() { "the distribution that provides `pip`" ); - // The catalog capture, over the limits its caller gives. let limits = Limits { pids_limit: 64, memory: String::from("512m"), cpus: 1.0, }; - let spec = catalog_spec( - &base.id, - &limits, - Duration::from_secs(20), - &command(&["sh", "-c", "echo catalog-ran"]), - ) - .expect("a catalog spec"); - let printed = outcome_of(cli.control(&spec, deadline, 4096).await).expect("the capture ran"); - assert_eq!(String::from_utf8_lossy(&printed).trim(), "catalog-ran"); // The collect reads what the run's mounts hold, as the engine's user. let project = scratch.path().join("project"); diff --git a/crates/candler-core/tests/it/guard_container_run.rs b/crates/candler-core/tests/it/guard_container_run.rs index f2072b03..3ff4e095 100644 --- a/crates/candler-core/tests/it/guard_container_run.rs +++ b/crates/candler-core/tests/it/guard_container_run.rs @@ -8,9 +8,7 @@ use std::time::Duration; use candler_core::isolation::container::exec::collect_spec; use candler_core::isolation::container::mounts::{MountMode, MountSpec}; -use candler_core::isolation::container::run::{ - RunArgvError, build_start_request, catalog_spec, create_argv, -}; +use candler_core::isolation::container::run::{RunArgvError, build_start_request, create_argv}; use candler_core::isolation::control::ControlSpec; use candler_core::isolation::docker::{Call, ClientEnv, DockerCli}; use candler_core::isolation::driver::DockerDriver as _; @@ -158,7 +156,7 @@ fn plan_under(root: &std::path::Path) -> ContainerPlan { planned } -/// The six control kinds, each built the way its caller builds it. +/// The five control kinds, each built the way its caller builds it. fn kinds(root: &std::path::Path) -> Vec { let image = ImageRef { id: ImageId(String::from("sha256:abc")), @@ -166,11 +164,6 @@ fn kinds(root: &std::path::Path) -> Vec { }; let env = [(String::from("HOME"), String::from("/tmp/home"))]; let probe = vec![String::from("claude"), String::from("--version")]; - let limits = Limits { - pids_limit: 64, - memory: String::from("512m"), - cpus: 1.0, - }; let args = |spec: ControlSpec| spec.args(); vec![ Kind { @@ -211,24 +204,6 @@ fn kinds(root: &std::path::Path) -> Vec { cpus: None, detached: false, }, - Kind { - name: "catalog capture", - args: args( - catalog_spec( - &image.id, - &limits, - Duration::from_secs(5), - &command(Vec::new()), - ) - .expect("a catalog spec"), - ), - network: Some("none"), - tmpfs: &["/tmp:rw,noexec,nosuid,size=256m"], - pids: "64", - memory: "512m", - cpus: Some("1"), - detached: false, - }, Kind { name: "collect", args: args( @@ -262,7 +237,7 @@ fn kinds(root: &std::path::Path) -> Vec { /// Guards: R01 §Process supervision (control containers) — every control container removes /// itself, wears `candler.role=control` and no job label, has a read-only root, no capabilities /// and no new privileges, and keeps its own network and limits: the probes 64 pids and 256m, the -/// compile 256 pids and 2g on the bridge, the catalog and the collect their caller's limits with a +/// compile 256 pids and 2g on the bridge, the collect its caller's limits with a /// cpu cap, and the fake model no network flag. /// Oracle: the flags of each kind's argv at 18142ec, typed here by hand. /// Bite: a flag dropped from the shared builder (`--cap-drop`, `--read-only`, the label, `--rm`), diff --git a/crates/candler-core/tests/it/guard_egress_setting.rs b/crates/candler-core/tests/it/guard_egress_setting.rs index 9fa0220c..772e7f67 100644 --- a/crates/candler-core/tests/it/guard_egress_setting.rs +++ b/crates/candler-core/tests/it/guard_egress_setting.rs @@ -484,10 +484,10 @@ fn egress_of(values: &[(String, Value)]) -> Option { /// The digest of the cell whose egress is `["a.org:443", "pypi.org:443"]`. const LISTED_DIGEST: &str = - "sha256:9a1cd9a1ee0c360c0dde88f8b50418136d40a56c301bd0a6a39110787ec5a33f"; + "sha256:7170d82c4a0f432e5dc8cd1af3cec9add7d9ed6b47af5b2b3aa37b0229cccdb8"; /// The digest of the cell of the plain experiment (no egress value). -const BASE_DIGEST: &str = "sha256:ea0e539ae84ca8476df9f8f73b3dbbb90ef2c7f173a4f636fb5e752b785254cf"; +const BASE_DIGEST: &str = "sha256:1dfb579fae92eccda7769a2dae62bea2e444db760a33cea1db92867e7bd05129"; /// Guards: R06 D3 — a cell with no egress value keeps its digest, and an empty list is an absent /// value (no allowlist, no proxy), so it digests as one. diff --git a/crates/candler-core/tests/it/guard_run_plan.rs b/crates/candler-core/tests/it/guard_run_plan.rs index 5616e5bf..7bf33d9f 100644 --- a/crates/candler-core/tests/it/guard_run_plan.rs +++ b/crates/candler-core/tests/it/guard_run_plan.rs @@ -903,16 +903,16 @@ fn t3_one_level_plans_the_old_bytes() { .iter() .map(|plan| (plan.cell.to_string(), plan.key.replicate())) .collect(); - let m1 = "sha256:c8c025d07f891ace920b103b2dd93ae78cdbe49fbf4269085554aa79d72dfab2"; - let m2 = "sha256:528ad7c2a0587eda8c5fbeee1760c89687f211a181a125f7dfc74b7be074c13a"; - let expected: Vec<(String, u32)> = [(m1, 1), (m2, 1), (m1, 2), (m2, 2)] + let m1 = "sha256:f935f4852108458ddbd26c7be1f5b38d9ae390e47b2b2330052bd92b049c43ec"; + let m2 = "sha256:94d7583eabfaa4cd6116ed137aacbea7c81de62a87e951e0b3d58104c0f34aa8"; + let expected: Vec<(String, u32)> = [(m1, 1), (m2, 1), (m2, 2), (m1, 2)] .into_iter() .map(|(cell, replicate)| (cell.to_owned(), replicate)) .collect(); assert_eq!( (out.experiment.to_string(), planned), ( - "sha256:2a0b3bf188be1e42e471095c7973dfaa390f5d0288cbb6733f15ac6ce4e670e7".to_owned(), + "sha256:a0d95d80aa505e22bdeb3a8c5123b0ddb0d85bc6fa000f016b8e053399a1cf06".to_owned(), expected ) ); diff --git a/crates/candler-core/tests/oracle/vectors/catalog_content_digest.toml b/crates/candler-core/tests/oracle/vectors/catalog_content_digest.toml deleted file mode 100644 index 2a50b3d0..00000000 --- a/crates/candler-core/tests/oracle/vectors/catalog_content_digest.toml +++ /dev/null @@ -1,42 +0,0 @@ -# catalog_content_digest.toml: catalog snapshot content digests (R01 §Wire schema: tool-catalog snapshot). -# Generated by tests/oracle/vectors/gen_vectors.py (python, `uv run --with rfc8785`), -# rfc8785 0.1.4. Do not edit: run the generator and commit the result. -# JSON values are carried as JSON text; every digest is sha256 of the RFC 8785 form. -# Spellings that R01 leaves open are marked ASSUMED, as in gen_vectors.py: -# 1. Imported cells (`cell_digest.toml`, the three mini-corpus cells; rules of -# legacy_mapping.md Step 2 item 3): `comparable.values` holds each JSON leaf of -# `experiment.json` under `plan.*` (without `plan.out_dir`), `provenance.*` and -# `resolved_skill_version`, as a dotted path, a `null` leaf without `value`; the root -# `schema_version` is left out. `harness` is `{name: "claude-code", version: }` without `driver`. `treatment` is `{name, tag}` split from -# `/plan/skill_version` (`htn-creator@v0.2.3`). `snapshots` is one `{kind: "catalog", digest: -# "sha256:" + PROVENANCE.json /catalog/sha256}`. `inputs` is `timing.json` `copied_inputs[]` -# as `{kind: , digest: "sha256:" + }` (`relpath` is dropped; the copies of a -# cell must agree). `environments` is empty. -# 2. `NameVersion` is the string `name@version` wherever it appears in a JSON value -# (`harness.driver`, `environments[].plugin`, catalog `provider`). -# 3. A digest inside a JSON value is the string `sha256:<64 hex>` (`artifacts[].sha256`, -# `snapshots[].digest`, `inputs[].digest`, `lock_digest`, `source_digest`). -# 4. `applies_to` keeps its written order; only `depends_on` is sorted. -# 5. The run key path form is `-r-a` with the cell hex the 64 bare hex digits of -# the cell digest and `m` = 1 for an import. -# 6. "The three mini-corpus runs" of `request_id.toml` are the three real runs (run-6, run-17, -# run-12); a contaminated run gets no request, and the two valid synthetic runs are left out. -# 7. "The first 74 bits of the hash" read the sha256 as a big-endian integer: `rand_a` is bits -# 0..12 and `rand_b` bits 12..74, counted from the most significant bit. -# 8. `regraded_at.finished` has no fraction, so the 48-bit time is its whole seconds times 1000. -# 9. Sorting by `path`, `(kind, digest)` and `(plugin, lock_digest)` is by Unicode code point -# (the order of UTF-8 bytes); the vectors keep their sort keys ASCII. -# 10. The `cell` key of a vector is the mini-corpus cell directory name, or `invented-`. - - -# `document_a` and `document_b` differ only in `captured_at` and share `digest_ab`; -# `document_c` differs in one tool description and has `digest_c`. Each digest is over the -# RFC 8785 form of the document without `captured_at`. - -[[vector]] -document_a = "{\"schema\":\"tool-catalog-snapshot/1\",\"captured_at\":\"2026-10-01T00:00:00Z\",\"provider\":\"rikyu-catalog@0.1.0\",\"environment\":{\"python\":\"3.12.4\",\"mcp\":\"1.9.0\"},\"servers\":[{\"name\":\"rikyu\",\"source_path\":\"servers/rikyu_mcp\",\"source_digest\":\"sha256:b36f116705db6e420b3a4d90a22ec24341c16083e36338220f499aaac341d9e2\",\"transport\":\"stdio\",\"tools\":[{\"name\":\"submit_job\",\"description\":\"Submit a batch job.\",\"inputSchema\":{\"type\":\"object\",\"properties\":{\"script\":{\"type\":\"string\"},\"nodes\":{\"type\":\"integer\"}},\"required\":[\"script\"]},\"annotations\":{\"readOnlyHint\":false}},{\"name\":\"get_job_status\",\"description\":\"Report a job's state.\",\"inputSchema\":{\"type\":\"object\",\"properties\":{\"job_id\":{\"type\":\"string\"}}},\"title\":\"Job status\"}]}]}" -document_b = "{\"schema\":\"tool-catalog-snapshot/1\",\"captured_at\":\"2026-10-28T12:34:56+09:00\",\"provider\":\"rikyu-catalog@0.1.0\",\"environment\":{\"python\":\"3.12.4\",\"mcp\":\"1.9.0\"},\"servers\":[{\"name\":\"rikyu\",\"source_path\":\"servers/rikyu_mcp\",\"source_digest\":\"sha256:b36f116705db6e420b3a4d90a22ec24341c16083e36338220f499aaac341d9e2\",\"transport\":\"stdio\",\"tools\":[{\"name\":\"submit_job\",\"description\":\"Submit a batch job.\",\"inputSchema\":{\"type\":\"object\",\"properties\":{\"script\":{\"type\":\"string\"},\"nodes\":{\"type\":\"integer\"}},\"required\":[\"script\"]},\"annotations\":{\"readOnlyHint\":false}},{\"name\":\"get_job_status\",\"description\":\"Report a job's state.\",\"inputSchema\":{\"type\":\"object\",\"properties\":{\"job_id\":{\"type\":\"string\"}}},\"title\":\"Job status\"}]}]}" -document_c = "{\"schema\":\"tool-catalog-snapshot/1\",\"captured_at\":\"2026-10-01T00:00:00Z\",\"provider\":\"rikyu-catalog@0.1.0\",\"environment\":{\"python\":\"3.12.4\",\"mcp\":\"1.9.0\"},\"servers\":[{\"name\":\"rikyu\",\"source_path\":\"servers/rikyu_mcp\",\"source_digest\":\"sha256:b36f116705db6e420b3a4d90a22ec24341c16083e36338220f499aaac341d9e2\",\"transport\":\"stdio\",\"tools\":[{\"name\":\"submit_job\",\"description\":\"Submit a batch job.\",\"inputSchema\":{\"type\":\"object\",\"properties\":{\"script\":{\"type\":\"string\"},\"nodes\":{\"type\":\"integer\"}},\"required\":[\"script\"]},\"annotations\":{\"readOnlyHint\":false}},{\"name\":\"get_job_status\",\"description\":\"Report the state of a job.\",\"inputSchema\":{\"type\":\"object\",\"properties\":{\"job_id\":{\"type\":\"string\"}}},\"title\":\"Job status\"}]}]}" -digest_ab = "sha256:b55154910fbe9fe54e0b8333367a9ff3d1a168bb27d070826e3e87e02efe4d3f" -digest_c = "sha256:ac392343adc17e8add50c9d7da2506f86fc5786455d5dba89973a9e85e2e32f9" diff --git a/crates/candler-core/tests/oracle/vectors/cell_digest.toml b/crates/candler-core/tests/oracle/vectors/cell_digest.toml index 62a41296..9610a891 100644 --- a/crates/candler-core/tests/oracle/vectors/cell_digest.toml +++ b/crates/candler-core/tests/oracle/vectors/cell_digest.toml @@ -28,6 +28,10 @@ # 9. Sorting by `path`, `(kind, digest)` and `(plugin, lock_digest)` is by Unicode code point # (the order of UTF-8 bytes); the vectors keep their sort keys ASCII. # 10. The `cell` key of a vector is the mini-corpus cell directory name, or `invented-`. +# A cell that lists `snapshots` is hashed with the list; a cell without catalog snapshots +# is hashed without the key (`invented-1`, `invented-4`). The vectors that list `snapshots` +# stay: the maintainer's own stores (golden and HTN runs) hold manifests of that shape, and +# their cell digests must still verify. Do not prune them as dead. # `comparable` is sorted and unique; `shuffled` has the same content with every list in @@ -60,9 +64,9 @@ outside_twin = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"ex [[vector]] cell = "invented-1" -comparable = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"snapshots\":[],\"inputs\":[],\"environments\":[]}" -digest = "sha256:4a5670ce3ee6403bb679546e49d2a573852868941bfe26cf81725a926ab6435d" -shuffled = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"snapshots\":[],\"inputs\":[],\"environments\":[]}" +comparable = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"inputs\":[],\"environments\":[]}" +digest = "sha256:6457b5734cd352b35a3ae1b5a1f446c7eb700b2450a5ba46ee738696eb3917b5" +shuffled = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"inputs\":[],\"environments\":[]}" outside = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"experiment_file\"}}],\"secrets\":[{\"name\":\"ANTHROPIC_API_KEY\",\"present\":true}],\"measured\":[{\"path\":\"run.exit\",\"value\":{\"code\":0},\"source\":{\"kind\":\"core_default\"}}],\"started_at\":\"2026-08-06T03:59:40Z\",\"ended_at\":\"2026-08-06T04:10:00Z\",\"host\":\"host-a-4\"}" outside_twin = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"explicit_argument\"}},{\"path\":\"plan.runs\",\"source\":{\"kind\":\"user_config\"}}],\"secrets\":[],\"measured\":[],\"started_at\":\"2027-01-02T10:00:00+09:00\",\"ended_at\":\"2027-01-02T11:30:15.250+09:00\",\"host\":\"other-host-4\"}" @@ -81,3 +85,11 @@ digest = "sha256:c70cb4f61e13566626e33e737c05c1570068174ee7cd0c420006f41483f1da0 shuffled = "{\"values\":[{\"path\":\"plan.base_url\"},{\"path\":\"plan.small_float\",\"value\":1e-07},{\"path\":\"plan.empty_text\",\"value\":\"\"},{\"path\":\"plan.list\",\"value\":[true,null,1.5,\"x\",{\"k\":[]}]},{\"path\":\"plan.config\",\"value\":\"with_skill\"},{\"path\":\"plan.big_float\",\"value\":1e+21},{\"path\":\"plan.tenth\",\"value\":0.1},{\"path\":\"plan.whole_float\",\"value\":100.0},{\"path\":\"plan.escapes\",\"value\":\"quote \\\" backslash \\\\ bell \\u0007 newline \\n tab \\t slash /\"}],\"harness\":{\"name\":\"claude-code\",\"version\":\"2.2.0-rc.1+build.5\"},\"treatment\":{\"name\":\"skill-c\",\"commit\":\"fedcba9876543210fedcba9876543210fedcba98\"},\"snapshots\":[{\"kind\":\"tool-catalog\",\"digest\":\"sha256:7779b5757ec40665a4d841352991164cf1eb89b33949b1bdad633b216ca4d9d3\"}],\"inputs\":[],\"environments\":[{\"plugin\":\"htn-creator-eval@0.4.2\",\"lock_digest\":\"sha256:16e3e848411f9748bb5c8ec006bd137b4881a57e47faca06683f6fd69c561b1b\"}]}" outside = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"experiment_file\"}}],\"secrets\":[{\"name\":\"ANTHROPIC_API_KEY\",\"present\":true}],\"measured\":[{\"path\":\"run.exit\",\"value\":{\"code\":0},\"source\":{\"kind\":\"core_default\"}}],\"started_at\":\"2026-08-06T03:59:40Z\",\"ended_at\":\"2026-08-06T04:10:00Z\",\"host\":\"host-a-6\"}" outside_twin = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"explicit_argument\"}},{\"path\":\"plan.runs\",\"source\":{\"kind\":\"user_config\"}}],\"secrets\":[],\"measured\":[],\"started_at\":\"2027-01-02T10:00:00+09:00\",\"ended_at\":\"2027-01-02T11:30:15.250+09:00\",\"host\":\"other-host-6\"}" + +[[vector]] +cell = "invented-4" +comparable = "{\"values\":[{\"path\":\"budget.per_run.max_cost_usd\",\"value\":1.5},{\"path\":\"budget.per_run.wall_s\",\"value\":600},{\"path\":\"isolation.network\",\"value\":false},{\"path\":\"plan.max_int\",\"value\":9007199254740991},{\"path\":\"plan.min_int\",\"value\":-9007199254740991},{\"path\":\"plan.model\",\"value\":\"model-\\u00e9\\u00e8\"},{\"path\":\"plan.negative_zero\",\"value\":-0.0},{\"path\":\"plan.nested\",\"value\":{\"\\ud83d\\ude00\":1,\"\\u20ac\":2,\"b\":[3,2,1],\"A\":{\"z\":null}}}],\"harness\":{\"name\":\"claude-code\",\"version\":\"2.1.220\",\"driver\":\"headless@0.3.0\"},\"treatment\":{\"name\":\"skill-b\",\"tag\":\"v1.2.0\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\"},\"inputs\":[{\"kind\":\"domain\",\"digest\":\"sha256:06d968ff9f1401e4a642561c62168380284160ca68d2efc3ac74ee2101d52121\"},{\"kind\":\"prompt\",\"digest\":\"sha256:7ed65932e8020d4d9f9f6a3685dd16ea62b9bd0477726edcf734750de827e343\"}],\"environments\":[{\"plugin\":\"another-eval@1.0.0\",\"lock_digest\":\"sha256:80be0631f286fe7e12719ab399568f969c31d98f4bf6321666f58cc15e21ba4f\"},{\"plugin\":\"htn-creator-eval@0.4.2\",\"lock_digest\":\"sha256:5ca54ae935ebe6a895ac8f31606e4db256628778d35f562ff44ee0aba658c349\"}]}" +digest = "sha256:91d798487a05112c80a75e68f970890d0df5fd7e40f5f67288385dfcaf5ffdd9" +shuffled = "{\"values\":[{\"path\":\"plan.negative_zero\",\"value\":-0.0},{\"path\":\"plan.nested\",\"value\":{\"\\ud83d\\ude00\":1,\"\\u20ac\":2,\"b\":[3,2,1],\"A\":{\"z\":null}}},{\"path\":\"budget.per_run.max_cost_usd\",\"value\":1.5},{\"path\":\"plan.min_int\",\"value\":-9007199254740991},{\"path\":\"plan.max_int\",\"value\":9007199254740991},{\"path\":\"plan.model\",\"value\":\"model-\\u00e9\\u00e8\"},{\"path\":\"isolation.network\",\"value\":false},{\"path\":\"budget.per_run.wall_s\",\"value\":600}],\"harness\":{\"name\":\"claude-code\",\"version\":\"2.1.220\",\"driver\":\"headless@0.3.0\"},\"treatment\":{\"name\":\"skill-b\",\"tag\":\"v1.2.0\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\"},\"inputs\":[{\"kind\":\"prompt\",\"digest\":\"sha256:7ed65932e8020d4d9f9f6a3685dd16ea62b9bd0477726edcf734750de827e343\"},{\"kind\":\"domain\",\"digest\":\"sha256:06d968ff9f1401e4a642561c62168380284160ca68d2efc3ac74ee2101d52121\"}],\"environments\":[{\"plugin\":\"htn-creator-eval@0.4.2\",\"lock_digest\":\"sha256:5ca54ae935ebe6a895ac8f31606e4db256628778d35f562ff44ee0aba658c349\"},{\"plugin\":\"another-eval@1.0.0\",\"lock_digest\":\"sha256:80be0631f286fe7e12719ab399568f969c31d98f4bf6321666f58cc15e21ba4f\"}]}" +outside = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"experiment_file\"}}],\"secrets\":[{\"name\":\"ANTHROPIC_API_KEY\",\"present\":true}],\"measured\":[{\"path\":\"run.exit\",\"value\":{\"code\":0},\"source\":{\"kind\":\"core_default\"}}],\"started_at\":\"2026-08-06T03:59:40Z\",\"ended_at\":\"2026-08-06T04:10:00Z\",\"host\":\"host-a-7\"}" +outside_twin = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"explicit_argument\"}},{\"path\":\"plan.runs\",\"source\":{\"kind\":\"user_config\"}}],\"secrets\":[],\"measured\":[],\"started_at\":\"2027-01-02T10:00:00+09:00\",\"ended_at\":\"2027-01-02T11:30:15.250+09:00\",\"host\":\"other-host-7\"}" diff --git a/crates/candler-core/tests/oracle/vectors/gen_vectors.py b/crates/candler-core/tests/oracle/vectors/gen_vectors.py index 571e0563..0e997f53 100644 --- a/crates/candler-core/tests/oracle/vectors/gen_vectors.py +++ b/crates/candler-core/tests/oracle/vectors/gen_vectors.py @@ -1,10 +1,10 @@ """Generate the digest and identity vectors, with a second engine, from R01's text. - uv run --with rfc8785 python gen_vectors.py # write the six TOML files here + uv run --with rfc8785 python gen_vectors.py # write the five TOML files here uv run --with rfc8785 python gen_vectors.py --check # regenerate in memory and compare Every digest is `sha256` of the RFC 8785 form (python `rfc8785`) of a JSON value built here from -R01 (§Run manifest, §Digests of a request, §Wire schema: tool-catalog snapshot, §Golden corpus). +R01 (§Run manifest, §Digests of a request, §Golden corpus). No Candler code runs. JSON values travel inside the TOML files as JSON text, so number tokens and key order reach the Rust test exactly as written. @@ -82,7 +82,6 @@ "cell_digest.toml", "context_digest.toml", "suite_entry_digest.toml", - "catalog_content_digest.toml", "request_id.toml", "context_digest_runs.toml", ) @@ -149,7 +148,8 @@ def sort_comparable(c): """R01: values by path, the other lists by their fields in order.""" c = json.loads(jtext(c)) c["values"].sort(key=lambda v: v["path"]) - c["snapshots"].sort(key=lambda r: (r["kind"], r["digest"])) + if "snapshots" in c: + c["snapshots"].sort(key=lambda r: (r["kind"], r["digest"])) c["inputs"].sort(key=lambda r: (r["kind"], r["digest"])) c["environments"].sort(key=lambda r: (r["plugin"], r["lock_digest"])) return c @@ -164,13 +164,16 @@ def comparable(values, harness, treatment, snapshots, inputs, environments): "inputs": inputs, "environments": environments, } + if not snapshots: + del unsorted["snapshots"] return sort_comparable(unsorted) def shuffled(c, seed): out = json.loads(jtext(c)) for i, key in enumerate(("values", "snapshots", "inputs", "environments")): - out[key] = reordered(out[key], seed * 10 + i) + if key in out: + out[key] = reordered(out[key], seed * 10 + i) return out @@ -280,7 +283,20 @@ def invented_cells(): [], [{"plugin": "htn-creator-eval@0.4.2", "lock_digest": hexd("lock-c")}], ) - return [("invented-1", one), ("invented-2", two), ("invented-3", three)] + four = comparable( + two["values"], + two["harness"], + two["treatment"], + [], + two["inputs"], + two["environments"], + ) + return [ + ("invented-1", one), + ("invented-2", two), + ("invented-3", three), + ("invented-4", four), + ] def outside_hash(n, variant): @@ -311,7 +327,16 @@ def outside_hash(n, variant): def cell_vectors(): cells = [(name, mini_cell(name)) for name in CELLS] + invented_cells() - out = [header("cell_digest.toml", "cell digest vectors (R01 §Run manifest, §Golden corpus).")] + out = [ + header( + "cell_digest.toml", + "cell digest vectors (R01 §Run manifest, §Golden corpus).", + "A cell that lists `snapshots` is hashed with the list; a cell without catalog snapshots\n" + "is hashed without the key (`invented-1`, `invented-4`). The vectors that list `snapshots`\n" + "stay: the maintainer's own stores (golden and HTN runs) hold manifests of that shape, and\n" + "their cell digests must still verify. Do not prune them as dead.", + ) + ] out.append( "# `comparable` is sorted and unique; `shuffled` has the same content with every list in\n" "# another order (the builder sorts it); `outside` and `outside_twin` are two different\n" @@ -531,68 +556,6 @@ def suite_vectors(): return "\n".join(out), entries -# ---------------------------------------------------------------- catalog - - -def catalog(captured_at, tool_two_description): - return { - "schema": "tool-catalog-snapshot/1", - "captured_at": captured_at, - "provider": "rikyu-catalog@0.1.0", - "environment": {"python": "3.12.4", "mcp": "1.9.0"}, - "servers": [ - { - "name": "rikyu", - "source_path": "servers/rikyu_mcp", - "source_digest": hexd("rikyu-source"), - "transport": "stdio", - "tools": [ - { - "name": "submit_job", - "description": "Submit a batch job.", - "inputSchema": { - "type": "object", - "properties": {"script": {"type": "string"}, "nodes": {"type": "integer"}}, - "required": ["script"], - }, - "annotations": {"readOnlyHint": False}, - }, - { - "name": "get_job_status", - "description": tool_two_description, - "inputSchema": {"type": "object", "properties": {"job_id": {"type": "string"}}}, - "title": "Job status", - }, - ], - } - ], - } - - -def catalog_vectors(): - a = catalog("2026-10-01T00:00:00Z", "Report a job's state.") - b = catalog("2026-10-28T12:34:56+09:00", "Report a job's state.") - c = catalog("2026-10-01T00:00:00Z", "Report the state of a job.") - - def without_time(doc): - return {k: v for k, v in doc.items() if k != "captured_at"} - - out = [header("catalog_content_digest.toml", "catalog snapshot content digests (R01 §Wire schema: tool-catalog snapshot).")] - out.append( - "# `document_a` and `document_b` differ only in `captured_at` and share `digest_ab`;\n" - "# `document_c` differs in one tool description and has `digest_c`. Each digest is over the\n" - "# RFC 8785 form of the document without `captured_at`.\n" - ) - out.append("[[vector]]") - out.append(f"document_a = {toml_str(jtext(a))}") - out.append(f"document_b = {toml_str(jtext(b))}") - out.append(f"document_c = {toml_str(jtext(c))}") - out.append(f"digest_ab = {toml_str(digest_of(without_time(a)))}") - out.append(f"digest_c = {toml_str(digest_of(without_time(c)))}") - out.append("") - return "\n".join(out), (a, b, c, without_time) - - # ---------------------------------------------------------------- request id @@ -644,23 +607,22 @@ def generate(): cells_text, comparables = cell_vectors() context_text, context_cases = context_vectors() suite_text, suite_entries = suite_vectors() - catalog_text, catalog_docs = catalog_vectors() request_text, request_rows = request_vectors(comparables) runs_text, _runs = run_context_vectors() texts = dict( - zip(FILES, (cells_text, context_text, suite_text, catalog_text, request_text, runs_text)) + zip(FILES, (cells_text, context_text, suite_text, request_text, runs_text)) ) - return texts, comparables, context_cases, suite_entries, catalog_docs, request_rows + return texts, comparables, context_cases, suite_entries, request_rows -def invariants(comparables, context_cases, suite_entries, catalog_docs, request_rows): +def invariants(comparables, context_cases, suite_entries, request_rows): """Properties of the vectors themselves, checked independently of the files.""" for name, c in comparables.items(): base = digest_of(c) assert digest_of(sort_comparable(shuffled(c, 7))) == base, name assert digest_of(sort_comparable(shuffled(c, 8))) == base, name for key in ("values", "snapshots", "inputs", "environments"): - if len(c[key]) > 1: + if len(c.get(key, [])) > 1: assert shuffled(c, 7)[key] != c[key] or shuffled(c, 8)[key] != c[key], (name, key) assert len({digest_of(c) for c in comparables.values()}) == len(comparables) for _title, artifacts, snapshots, inputs, metadata in context_cases: @@ -670,9 +632,6 @@ def invariants(comparables, context_cases, suite_entries, catalog_docs, request_ for n, entry in enumerate(suite_entries, start=1): assert digest_of(suite_projection(entry)) == digest_of(suite_projection(twin(entry, n))) assert len({digest_of(suite_projection(e)) for e in suite_entries}) == len(suite_entries) - a, b, c, without_time = catalog_docs - assert digest_of(without_time(a)) == digest_of(without_time(b)) != digest_of(without_time(c)) - assert digest_of(a) != digest_of(b) assert len({r[4] for r in request_rows}) == len(request_rows) for _cell, _n, _path, _hash, rid in request_rows: assert len(rid) == 36 and rid[14] == "7" and rid[19] in "89ab" and rid == rid.lower(), rid @@ -682,8 +641,8 @@ def main(): ap = argparse.ArgumentParser(description=__doc__.split("\n")[0]) ap.add_argument("--check", action="store_true", help="compare with the files on disk") args = ap.parse_args() - texts, comparables, context_cases, suite_entries, catalog_docs, request_rows = generate() - invariants(comparables, context_cases, suite_entries, catalog_docs, request_rows) + texts, comparables, context_cases, suite_entries, request_rows = generate() + invariants(comparables, context_cases, suite_entries, request_rows) for name, text in texts.items(): tomllib.loads(text) if not args.check: diff --git a/crates/candler/src/commands/inspect.rs b/crates/candler/src/commands/inspect.rs index 42cc6678..08ebe535 100644 --- a/crates/candler/src/commands/inspect.rs +++ b/crates/candler/src/commands/inspect.rs @@ -19,7 +19,6 @@ use candler_core::jobs::dir::JobDir; use candler_core::jobs::lost::{JobLiveness, classify}; use candler_core::store::Store; use candler_core::trace::{TranscriptForm, render_transcript}; -use candler_schemas::execution::RunManifest; use candler_schemas::inspect::{ InspectJob, InspectJobRun, InspectJobTag, InspectOutcome, InspectRun, InspectRunTag, Spent, }; @@ -212,17 +211,20 @@ fn outcome_of(record: &OutcomeRecord) -> Result { }) } -/// The catalog the run ran with, read from the blob its `snapshots` digest names; `None` when the -/// run names no catalog or the store holds no blob for it, as a run sealed before snapshots were -/// stored. -fn catalog_of(store: &Store, manifest: &RunManifest) -> Option { - let snapshot = manifest - .comparable() - .snapshots() - .iter() - .find(|entry| entry.kind.as_str() == "catalog")?; // BORROW: explicit .as_str() - let bytes = fs::read(store.blob_path(&snapshot.digest)).ok()?; - serde_json::from_slice(&bytes).ok() +/// The resolved `mcp.*` values of the cell, by path: the MCP configuration the run was installed +/// with. +fn mcp_of(whole: &Value) -> BTreeMap { + whole + .pointer("/comparable/values") + .and_then(Value::as_array) + .into_iter() + .flatten() + .filter_map(|entry| { + let path = entry.get("path").and_then(Value::as_str)?; + let value = entry.get("value")?; + (path == "mcp" || path.starts_with("mcp.")).then(|| (path.to_owned(), value.clone())) // BORROW: the record owns its copy + }) + .collect() } /// The record of the run `key`: whether it is sealed and counts, what it was read from, the @@ -284,7 +286,7 @@ pub fn render_run(store: &Store, key: &RunKey) -> Result { ended_at: field("ended_at"), host: field("host"), import: field("import"), - catalog: catalog_of(store, &manifest), + mcp: mcp_of(&whole), provenance, measured, outcomes, @@ -371,24 +373,12 @@ pub fn render_job(store: &Store, id: &JobId) -> Result { /// The run record as lines: the run, its seal, what it measured and each outcome. fn text_of_run(run: &InspectRun) -> String { let mut lines = vec![format!("run {}", run.run), format!("sealed {}", run.sealed)]; - match &run.catalog { - Some(catalog) => { - let provider = catalog.get("provider").and_then(Value::as_str); - lines.push(format!("catalog {}", provider.unwrap_or_default())); - let servers = catalog.get("servers").and_then(Value::as_array); - for server in servers.into_iter().flatten() { - let name = server.get("name").and_then(Value::as_str); - lines.push(format!("server {}", name.unwrap_or_default())); - let tools = server.get("tools").and_then(Value::as_array); - for tool in tools.into_iter().flatten() { - let name = tool.get("name").and_then(Value::as_str); - lines.push(format!("tool {}", name.unwrap_or_default())); - } - } - } - None => lines.push(String::from("catalog not stored")), - } - for (path, value) in run.provenance.iter().chain(run.measured.iter()) { + for (path, value) in run + .mcp + .iter() + .chain(run.provenance.iter()) + .chain(run.measured.iter()) + { lines.push(format!("{path}\t{value}")); } for outcome in &run.outcomes { diff --git a/crates/candler/src/commands/preflight.rs b/crates/candler/src/commands/preflight.rs index f4158dab..fc206912 100644 --- a/crates/candler/src/commands/preflight.rs +++ b/crates/candler/src/commands/preflight.rs @@ -6,7 +6,6 @@ use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Arc; -use std::time::Duration; use candler_core::isolation::docker::{ClientEnv, DockerCli}; use candler_core::isolation::image::{DockerImageService, ImageAssets}; @@ -17,7 +16,6 @@ use candler_core::resolve::preflight::{ResolveError, Resolver}; use candler_core::resolve::steps::env::EnvRefusal; use candler_core::resolve::steps::ground_truth::{GroundTruth, GroundTruthStep}; use candler_core::resolve::steps::{M2bServices, register_m2b_steps}; -use candler_core::runner::evidence::catalog::{CatalogCommand, CommandCatalogProvider}; use candler_core::runner::plan::{PlanError, experiment_of}; use candler_core::supervise::{EventSink, Supervisor}; use candler_schemas::execution::paths; @@ -35,13 +33,6 @@ use candler_harness::spec::AgentSetting; /// The path of the setting `[treatment] source` replaces; `--set` refuses it by name. const RETIRED_TREATMENT_SOURCE: &str = concat!("request.", "treatment_source"); -/// The time the catalog command gets inside the image. -const CATALOG_TIMEOUT: Duration = Duration::from_secs(60); - -/// The program that prints the catalog of an image that offers no MCP server: a snapshot with no -/// server in it, captured now. -const CATALOG_PROGRAM: &str = "printf '{\"schema\":\"tool-catalog-snapshot/1\",\"captured_at\":\"%s\",\"provider\":\"candler-image@1\",\"servers\":[]}' \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\""; - /// The places the sources of the images are. pub(crate) struct AssetPaths { /// The base and env build contexts and the store root. @@ -93,8 +84,8 @@ pub(crate) fn refused(reason: impl Into) -> CliError { } } -/// The resolver with the preflight steps of the image, the harness, the treatment, the catalog -/// and the ground truth registered; the services say where the harness reads its skills. +/// The resolver with the preflight steps of the image, the harness, the treatment and the ground +/// truth registered; the services say where the harness reads its skills. /// /// # Errors /// [`ResolveError`] when a step name is registered twice or malformed. @@ -394,7 +385,7 @@ pub(crate) fn requested_harness(input: &ResolveInput) -> Result> "$here/docker.log" diff --git a/crates/candler/tests/it/support/contract_pages/refusals.rs b/crates/candler/tests/it/support/contract_pages/refusals.rs index e3f68c95..13b522e0 100644 --- a/crates/candler/tests/it/support/contract_pages/refusals.rs +++ b/crates/candler/tests/it/support/contract_pages/refusals.rs @@ -22,7 +22,7 @@ pub enum Home { /// The surface of a code is the part before its dot. Every surface the catalogue and the helper's /// section hold is named here; a surface that is not named fails the guard with its name. -pub const SURFACES: [(&str, Home); 24] = [ +pub const SURFACES: [(&str, Home); 23] = [ ("plugin", Home::Page("plugin-manifest.md")), ("suite", Home::Page("suite-file.md")), ("protocol", Home::Page("evaluator-protocol.md")), @@ -38,7 +38,6 @@ pub const SURFACES: [(&str, Home); 24] = [ ("candler", Home::Index), ("analysis", Home::Index), ("cli", Home::Index), - ("catalog", Home::Index), ("config", Home::Index), ("evaluation", Home::Index), ("harness", Home::Index), diff --git a/docs/contract/codes.toml b/docs/contract/codes.toml index ef729f60..52f5eab0 100644 --- a/docs/contract/codes.toml +++ b/docs/contract/codes.toml @@ -400,36 +400,6 @@ side = "plugin" enum = "EvaluationError" variant = "ManifestToml" -[schemas."catalog.schema_tag_mismatch"] -side = "environment" -enum = "CatalogError" -variant = "SchemaTag" - -[schemas."catalog.field_unset"] -side = "candler" -enum = "CatalogError" -variant = "MissingField" - -[schemas."catalog.extra_key_reserved"] -side = "candler" -enum = "CatalogError" -variant = "ReservedKey" - -[schemas."catalog.field_null"] -side = "candler" -enum = "CatalogError" -variant = "Null" - -[schemas."catalog.name_empty"] -side = "environment" -enum = "CatalogError" -variant = "EmptyName" - -[schemas."catalog.name_repeated"] -side = "environment" -enum = "CatalogError" -variant = "DuplicateName" - [schemas."experiment.unknown_field"] side = "experiment" enum = "ExecutionError" @@ -556,21 +526,6 @@ side = "experiment" enum = "PlanError" variant = "SettingAsFactor" -[runner."runner.catalog_command_failed"] -side = "environment" -enum = "CatalogError" -variant = "Command" - -[runner."runner.catalog_timeout"] -side = "environment" -enum = "CatalogError" -variant = "Timeout" - -[runner."runner.catalog_unreadable"] -side = "environment" -enum = "CatalogError" -variant = "Parse" - [runner."runner.census_no_init"] side = "environment" enum = "CensusError" @@ -1429,21 +1384,6 @@ enum = "PlanError" variant = "Lock" reason = "a lock that cannot be tried is an operating-system fault, not an input of the author" -[internal."candler_core::runner::evidence::catalog::CatalogError::Unavailable"] -enum = "CatalogError" -variant = "Unavailable" -reason = "an unwired capture port is a fault of the binary, not an input of the author" - -[internal."candler_core::runner::evidence::catalog::CatalogError::AbsolutePath"] -enum = "CatalogError" -variant = "AbsolutePath" -reason = "the catalog is captured by Candler's own command, so an absolute path is Candler's fault" - -[internal."candler_core::runner::evidence::catalog::CatalogError::Digest"] -enum = "CatalogError" -variant = "Digest" -reason = "a catalog with no canonical form is a fault of the capture, not an input of the author" - [internal."candler_core::runner::evidence::census::CensusError::Value"] enum = "CensusError" variant = "Value" diff --git a/docs/contract/index.md b/docs/contract/index.md index 0062124e..6698bc34 100644 --- a/docs/contract/index.md +++ b/docs/contract/index.md @@ -65,9 +65,6 @@ Surfaces that name no page of their own: configuration, resolving, running, isol | `analysis.no_outcomes` | The store holds no outcome record, so there is nothing to analyse; run `evaluate` first. | - | environment | | `analysis.no_stored_trace` | The run given to `inspect --transcript` has no stored normalised trace, or the target is a job, which holds none. | - | config | | `analysis.unknown_evaluator` | The evaluator, or the version, named has no outcome in the store. | - | config | -| `catalog.name_empty` | A server or tool name in the catalog an image prints is empty. | - | environment | -| `catalog.name_repeated` | A server or tool name in the catalog an image prints is repeated within its scope. | - | environment | -| `catalog.schema_tag_mismatch` | The tool catalog an image prints carries another `schema` marker than `tool-catalog-snapshot/1`. | `/schema` | environment | | `cli.usage_invalid` | The command line is not one the parser accepts: an unknown option, a missing argument, or a value such as a `--set` without `=`. | - | config | | `config.ambiguous_run` | More than one run of the store has a key that starts with the prefix given to `inspect`. | - | config | | `config.cwd_not_absolute` | The working directory is not an absolute path, so no ancestor can be searched for a configuration. | - | config | @@ -195,9 +192,6 @@ Surfaces that name no page of their own: configuration, resolving, running, isol | `resolve.preflight_failed` | At least one preflight step failed; every step ran and the message lists the failures. | - | environment | | `resolve.preflight_step_failed` | A preflight step failed before it could report, for example a missing directory or program. | - | environment | | `resolve.value_invalid` | A value of the resolution has the wrong form for what it names, such as a name with a space. | - | config | -| `runner.catalog_command_failed` | The command that prints the tool catalog exited non-zero or was ended by a signal. | - | environment | -| `runner.catalog_timeout` | The command that prints the tool catalog overran its time. | - | environment | -| `runner.catalog_unreadable` | The output of the catalog command is not a tool catalog. | - | environment | | `runner.census_malformed` | The tool inventory lacks a list the census needs, or the list holds an entry of the wrong kind. | - | environment | | `runner.census_no_init` | The harness reported no tool inventory, so it did not run usably. | - | environment | | `runner.experiment_locked` | Another supervisor holds the experiment, or a job that owns an unfinished attempt is alive. | - | environment | From 5b70b9689c1980c1c5becfb2bcf7a1ed835e5792 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:18:25 +0900 Subject: [PATCH 04/18] reports(api): close the snapshot removal Co-Authored-By: Claude Sonnet 5.5 --- __reports__/diet/leaves/snapshot_out_v0.md | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 __reports__/diet/leaves/snapshot_out_v0.md diff --git a/__reports__/diet/leaves/snapshot_out_v0.md b/__reports__/diet/leaves/snapshot_out_v0.md new file mode 100644 index 00000000..9008a7c2 --- /dev/null +++ b/__reports__/diet/leaves/snapshot_out_v0.md @@ -0,0 +1,57 @@ +# Snapshot out (P12): leaf report + +Base `7d497545` (`origin/feat/integrity`). Tip: see the commit table. Branch `leaf/l3-snapshot-out`, build slot `l3-2`. + +## Commits + +| Commit | Subject | +|---|---| +| `e8b07a32` | `test(api): read a run's installed MCP config back through inspect` | +| `4988b245` | `feat(schemas)!: drop the catalog snapshot and show MCP in inspect` | +| `cc7f12c8` | `refactor(runner): remove the constant catalog producer, show MCP config` (the roadmap's line is 88 characters; the commit hook allows 72) | + +The schemas commit touches only `crates/candler-schemas/`, as CI's Commit messages job requires. It is a major bump on the schema line (a record valid before is invalid: `catalog-snapshot.schema.json` leaves, `inspect-run` loses `catalog` and requires `mcp`), so it carries `!` and a `BREAKING CHANGE:` footer (CONTRIBUTING §Schema line). + +**The workspace does not build at the schemas commit alone.** `candler-core` and `candler` still name `CatalogSnapshot`, `InspectRun.catalog` and `CatalogError` there, and `candler-schemas`'s own `guard_refusal` reads `docs/contract/codes.toml` and the oracle vectors, which live outside the crate and change in the next commit. The step-2 commit restores a green workspace. The step-1 guard test fails by design on its own commit. + +## Gates + +| Gate | Verdict | Evidence | +|---|---|---| +| Guard on `candler run` -> `inspect`, one declared server, JSON and text | PASS | `inspect_shows_the_mcp_server_a_run_was_launched_with` launches `candler run --set mcp.servers.fs.command=mcp-fs --set 'mcp.servers.fs.args=["data"]'` through the fake docker, reads the sealed run back, and finds `mcp.servers.fs.command = "mcp-fs"` and `mcp.servers.fs.args = ["data"]` in `record["mcp"]` and the same two lines in the text form. On the base commit (`e8b07a32`): FAIL, `the record shows the mcp values: {"catalog":{"provider":"candler-image@1","schema":"tool-catalog-snapshot/1","servers":[]},...}`. | +| `CATALOG_PROGRAM`, `CatalogCommand`, `CommandCatalogProvider`, `CatalogStep`, the fake docker's constant, the provider seam | PASS | All deleted: `runner/evidence/catalog.rs`, `resolve/steps/catalog.rs`, the constant in `commands/preflight.rs`, the `printf` branch of the fake `docker run`, `M2bServices.catalog`, `catalog_spec` and its two control-kind rows. `CatalogProvider` had one implementor besides test fakes, so the seam went with it. The plumbing that only carried the catalog text to the seal went too: `StepReport.blobs`/`blob()`, `CellRun.blobs`/`with_blobs()`, `RunWriter::blob`. | +| `comparable` carries no catalog snapshot; new digest version vectors; old vectors verify | DEVIATION | `comparable.snapshots` is still a field of `Comparable`, optional: a cell that lists none leaves the key out of its record and of its hash, so every cell Candler makes now hashes under the new digest. The field stays because it is the one place the digest of a manifest that lists snapshots (the 240 golden runs, imported HTN runs) is read from: dropping it would make those manifests unreadable (`deny_unknown_fields`) and their digests unverifiable. New vectors: `invented-1` (regenerated, no `snapshots`) and `invented-4` (new, no `snapshots`) in `cell_digest.toml`; the three corpus cells and `invented-2`/`-3` keep `snapshots` and their old digests (`digests_equal_the_oracle`, 7 vectors, PASS). The generator and the vector header say why the old vectors stay. The lead decides whether to take the field out later, after the maintainer's stores are re-imported. | +| `inspect` callers gate (htn-creator-eval@0.5.3) | PASS | Supplied by the lead, not re-run: all 279 `.py`/`.sh` files under the HTN and candler paths were searched for `candler ... inspect`, `"inspect"`, `["catalog"]` and `.get("catalog")`. The one hit, `infrastructure/htn_creator_eval/cli.py:1053`, forwards to the HTN's own trace profiler, not to `candler inspect`. `candler-plugin/` has no `inspect` or `catalog` reference. `_catalog_snapshot.py` reads the HTN's own committed `catalogs/*.json`. No reader of `InspectRun.catalog`, so it was dropped. | +| `InspectRun.catalog` and `catalog_of` gone; an old sealed run still reads | PASS | Both deleted. `inspect` reads the manifest only; the stored blob is left in the store and not shown, and no shim reads it. The old manifests read through `RunManifest` (unchanged `snapshots` reader), covered by the golden and import guards in the workspace run. | +| `tool-catalog-snapshot/1` gone | PASS | `candler-schemas/src/catalog.rs`, `schema/catalog-snapshot.schema.json`, `tests/it/catalog_fixtures.rs`, `catalog_properties.rs`, the `tests/fixtures/{spec,upstream}` fixtures, the catalog test in `guard_wire_shapes.rs` and `guard_cell_digest.rs`, and `catalog_content_digest.toml` with its generator section. The plan lists `catalog_content_digest.toml` among vectors that stay; the leaf says vectors only `/1` uses go. Only the deleted digest test read it, so it went. | +| README, AGENTS.md, live candler-v1 M6c Goal | PASS | `per-run tool census` in `README.md:7`, `AGENTS.md:8`, and `__roadmap__/candler-v1/.../integrity/README.md:7`; `AGENTS.md` names "a tool census" among the stored states. No page under `docs/` quoted the phrase. Done leaves and reports keep their words. | +| Refusal codes only the removed code emitted | PASS | `catalog.*` (6 schemas codes), `runner.catalog_command_failed`, `runner.catalog_timeout`, `runner.catalog_unreadable`, and the three `[internal]` rows of the core `CatalogError`; `docs/contract/codes.toml` and `index.md` regenerated (`CANDLER_BLESS_CONTRACT=1`); the `catalog` surface left `SURFACES`; the two `CatalogError` rows left `__roadmap__/m3-lean-cli/refusal_scope.tsv`, which `guard_refusal_codes` reads as its oracle. | +| `cargo fmt --check`, clippy `-D warnings`, `cargo doc -D warnings` | PASS | exit 0 for each on the tip. | +| `cargo nextest run --workspace` | PASS | `Summary [161.761s] 729 tests run: 729 passed (6 slow), 31 skipped`. The 31 skipped are the Docker-gated `container-e2e` tests, which the lead reads from the PR's CI. The first run on the tip failed five (the guard, three pinned-digest tests, and the refusal-scope oracle); each is fixed in the step-2 commit (see Pins retaken). | +| `container-e2e` green on the PR | BLOCKED | Read from the PR's CI by the lead. | +| Step 3 scratch bite | PASS | On a scratch branch from the step-2 tip, `inspect.rs` shows `mcp: BTreeMap::new()`; the guard FAILS: `assertion left == right failed: the declared command is shown: {... "outcomes":[] ...}` at `guard_inspect_mcp_config.rs:57`. Scratch worktree, branch and target dir removed. The fresh verifier is the lead's. | + +## Pins retaken + +Four tests pinned digests of cells built by the real planner (`guard_egress_setting`: `LISTED_DIGEST`, `BASE_DIGEST`; `guard_run_plan::t3_one_level_plans_the_old_bytes`: both cells, the experiment digest, and the replicate order, which the planner derives from the digests). Those cells hashed an empty `snapshots` list before; they hash without it now, so the pins moved. They were re-taken from the producer's output, which is the new digest version's meaning, not a drift. + +## What it leaves + +**How it is developed.** The guard was run on the base first and failed for the stated reason after two false starts of the test itself (an absolute path in `--set` that the resolver refuses, and a fake docker with no top-level `inspect`, which the start probe of a declared stdio server calls). No Docker, no live model, one build slot (`l3-2`), no scratch worktree kept. The Python generator reran under `uv run --with rfc8785` and changed only `cell_digest.toml`. + +**What it leaves in the code.** One producer of the MCP record: the resolved `mcp.*` values, written by resolve and read by `inspect` from `comparable.values`. The constant catalog, its capture, its resolve step, its seam, the blob plumbing that carried its text, its schema, its fixtures, its refusal codes and its inspect surface are deleted in the same change. The one thing kept without a producer is the optional `comparable.snapshots` read of manifests that list it (gate row above); the importer still writes it for imported legacy runs, which is the field's only live writer. + +**How it is consumed.** The experimenter's `inspect` shows `mcp.*` by path, in the JSON record (`mcp`) and as `pathvalue` lines in text. A run with no MCP server shows an empty `mcp`. The record no longer shows a tool catalog Candler did not observe. `inspect-run.schema.json` changes (`catalog` out, `mcp` required), which is the compatibility item below. + +## Not covered + +- **HTN-side follow-up for the lead to hand on:** htn-creator-eval@0.5.3 keeps grading, but its one test that validates against Candler's `catalog-snapshot.schema.json` now skips. The schema file has to move into the HTN repository (the `/1` marker stays the HTN's own). Nothing in the HTN repo was touched. +- Step 3's fresh verifier, and the PR's `container-e2e`: the lead's. +- `__design__/architecture.md` still describes the tool-catalog snapshot and catalog providers (§Wire schema: tool-catalog snapshot and several mentions). The leaf lists no design deliverable, so it was left; it is stale against the code. +- The optional `comparable.snapshots` field (see the deviation) and the importer's write of it. + +## Compatibility for consumers + +- `inspect-run/1` consumers: `catalog` is gone and `mcp` (object, path to value) is required. +- `run-manifest/1`: a manifest without `comparable.snapshots` is now valid, and its cell digest differs from the digest the same cell had with `"snapshots": []`. Run keys of new runs therefore differ from old ones for the same experiment. +- The schema line takes a major bump (minor while `0.y.z`). From 194be9e45de9843a4fda57c652fb1499ca596eed Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:28:39 +0900 Subject: [PATCH 05/18] fix(schemas): keep an absent snapshots list apart from an empty one comparable.snapshots is optional: a cell without the key hashes without it, and a cell that carries it, even as an empty list, is written and hashed as before. No existing manifest's digest moves, so the version marker stays run-manifest/1. Co-Authored-By: Claude Sonnet 5.5 --- .../schema/run-manifest.schema.json | 7 +-- crates/candler-schemas/src/execution.rs | 62 ++++++++++--------- .../tests/it/guard_cell_digest.rs | 34 +++++----- 3 files changed, 51 insertions(+), 52 deletions(-) diff --git a/crates/candler-schemas/schema/run-manifest.schema.json b/crates/candler-schemas/schema/run-manifest.schema.json index 966eabac..ba1f6d34 100644 --- a/crates/candler-schemas/schema/run-manifest.schema.json +++ b/crates/candler-schemas/schema/run-manifest.schema.json @@ -2,7 +2,7 @@ "$defs": { "Comparable": { "additionalProperties": false, - "description": "What the cell digest hashes: every resolved value, the harness, the treatment, the catalog snapshots, the inputs and the plug-in environments of a run, each list sorted and without duplicates.", + "description": "What the cell digest hashes: every resolved value, the harness, the treatment, the catalog digests an imported run recorded, the inputs and the plug-in environments of a run, each list sorted and without duplicates.", "properties": { "environments": { "$comment": "Sorted by the text of the plug-in then the lock digest in code point order, without a repeated entry; the Rust reader refuses a list that is not.", @@ -26,8 +26,7 @@ }, "snapshots": { "$comment": "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not.", - "default": [], - "description": "The digests of the catalog snapshots, sorted by kind and digest. A cell without catalog\nsnapshots leaves the list out, and the hash leaves it out too.", + "description": "The digests of the catalog snapshots an imported run recorded, sorted by kind and digest.\nOnly the importer writes it. A cell without the key hashes without it; a cell with the key,\neven an empty list, hashes with it.", "items": { "$ref": "#/$defs/DigestRef" }, @@ -98,7 +97,7 @@ }, "DigestRef": { "additionalProperties": false, - "description": "A digest and the kind of thing it identifies: a catalog snapshot or an input.", + "description": "A digest and the kind of thing it identifies: a catalog an imported run recorded, or an input.", "properties": { "digest": { "$ref": "#/$defs/Digest", diff --git a/crates/candler-schemas/src/execution.rs b/crates/candler-schemas/src/execution.rs index cb1d8165..dd8e41b7 100644 --- a/crates/candler-schemas/src/execution.rs +++ b/crates/candler-schemas/src/execution.rs @@ -1819,7 +1819,7 @@ impl HarnessIdentity { } } -/// A digest and the kind of thing it identifies: a catalog snapshot or an input. +/// A digest and the kind of thing it identifies: a catalog an imported run recorded, or an input. #[derive( Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, JsonSchema, )] @@ -1883,17 +1883,12 @@ struct ComparableBody<'a> { values: &'a [ResolvedValue], harness: &'a HarnessIdentity, treatment: &'a TreatmentRef, - #[serde(skip_serializing_if = "no_digests")] - snapshots: &'a [DigestRef], + #[serde(skip_serializing_if = "Option::is_none")] + snapshots: Option<&'a [DigestRef]>, inputs: &'a [DigestRef], environments: &'a [EnvironmentRef], } -/// Reports whether `list` holds no digest: an empty list is left out of the hash and of the record. -fn no_digests(list: &&[DigestRef]) -> bool { - list.is_empty() -} - /// Checks that `items` rise strictly by `key`: an equal neighbour is a duplicate, a lower one is out of order. fn check_ascending<'a, T, K: Ord>( list: &'static str, @@ -1927,7 +1922,7 @@ fn environment_order(first: &EnvironmentRef, second: &EnvironmentRef) -> std::cm .then_with(|| first.lock_digest.cmp(&second.lock_digest)) } -/// What the cell digest hashes: every resolved value, the harness, the treatment, the catalog snapshots, the inputs and the plug-in environments of a run, each list sorted and without duplicates. +/// What the cell digest hashes: every resolved value, the harness, the treatment, the catalog digests an imported run recorded, the inputs and the plug-in environments of a run, each list sorted and without duplicates. #[derive(Deserialize, JsonSchema)] #[schemars(deny_unknown_fields, rename = "Comparable")] struct RawComparable { @@ -1940,13 +1935,14 @@ struct RawComparable { harness: HarnessIdentity, /// The treatment the run applied. treatment: TreatmentRef, - /// The digests of the catalog snapshots, sorted by kind and digest. A cell without catalog - /// snapshots leaves the list out, and the hash leaves it out too. - #[serde(default)] + /// The digests of the catalog snapshots an imported run recorded, sorted by kind and digest. + /// Only the importer writes it. A cell without the key hashes without it; a cell with the key, + /// even an empty list, hashes with it. + #[serde(default, deserialize_with = "present")] #[schemars(extend( "$comment" = "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not." ))] - snapshots: Vec, + snapshots: Option>, /// The digests of the inputs, sorted by kind and digest. #[schemars(extend( "$comment" = "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not." @@ -1975,7 +1971,7 @@ impl TryFrom> for Comparable { } } -/// What the cell digest hashes: every resolved value, the harness, the treatment, the catalog snapshots, the inputs and the plug-in environments of a run, each list sorted and without duplicates. +/// What the cell digest hashes: every resolved value, the harness, the treatment, the catalog digests an imported run recorded, the inputs and the plug-in environments of a run, each list sorted and without duplicates. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(try_from = "MapOnly")] #[non_exhaustive] @@ -1983,8 +1979,8 @@ pub struct Comparable { values: Vec, harness: HarnessIdentity, treatment: TreatmentRef, - #[serde(skip_serializing_if = "Vec::is_empty")] - snapshots: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + snapshots: Option>, inputs: Vec, environments: Vec, #[serde(skip)] @@ -2004,7 +2000,7 @@ impl Comparable { values: Vec, harness: HarnessIdentity, treatment: TreatmentRef, - snapshots: Vec, + snapshots: Option>, inputs: Vec, environments: Vec, ) -> Result { @@ -2016,12 +2012,14 @@ impl Comparable { ResolvedValue::path, |value| value.path().to_string(), )?; - for (list, items) in [("snapshots", &snapshots), ("inputs", &inputs)] { + for (list, items) in [ + ("snapshots", snapshots.as_deref().unwrap_or_default()), + ("inputs", inputs.as_slice()), + ] { check_ascending( list, "kind and digest", - // BORROW: explicit .as_slice() instead of Deref coercion - items.as_slice(), + items, |entry| (entry.kind.as_str(), entry.digest.as_str()), |entry| entry.digest.to_string(), )?; @@ -2039,7 +2037,8 @@ impl Comparable { values: values.as_slice(), harness: &harness, treatment: &treatment, - snapshots: snapshots.as_slice(), + // BORROW: explicit .as_deref() instead of Deref coercion + snapshots: snapshots.as_deref(), // BORROW: explicit .as_slice() instead of Deref coercion inputs: inputs.as_slice(), // BORROW: explicit .as_slice() instead of Deref coercion @@ -2191,11 +2190,11 @@ impl Comparable { &self.treatment } - /// The catalog snapshot digests, sorted. + /// The catalog digests an imported run recorded, sorted. #[must_use] pub fn snapshots<'a>(&'a self) -> &'a [DigestRef] { - // BORROW: explicit .as_slice() instead of Deref coercion - self.snapshots.as_slice() + // BORROW: explicit .as_deref() instead of Deref coercion + self.snapshots.as_deref().unwrap_or_default() } /// The input digests, sorted. @@ -2248,7 +2247,7 @@ pub struct ComparableBuilder { values: Vec, harness: Option, treatment: Option, - snapshots: Vec, + snapshots: Option>, inputs: Vec, environments: Vec, } @@ -2275,10 +2274,11 @@ impl ComparableBuilder { self } - /// Adds a catalog snapshot digest. + /// Sets the catalog digests an imported run recorded, even when the list is empty; a cell + /// without this call carries no `snapshots` key. #[must_use] - pub fn snapshot(mut self, snapshot: DigestRef) -> Self { - self.snapshots.push(snapshot); + pub fn snapshots(mut self, snapshots: Vec) -> Self { + self.snapshots = Some(snapshots); self } @@ -2307,7 +2307,7 @@ impl ComparableBuilder { "treatment" => self.treatment = Some(serde_json::from_value(json).map_err(malformed)?), "snapshots" => { // The list is read as written; `build` sorts and refuses a duplicate. - self.snapshots = serde_json::from_value(json).map_err(malformed)?; + self.snapshots = Some(serde_json::from_value(json).map_err(malformed)?); } "inputs" => self.inputs = serde_json::from_value(json).map_err(malformed)?, "environments" => { @@ -2342,7 +2342,9 @@ impl ComparableBuilder { let harness = harness.ok_or(ExecutionError::MissingField { field: "harness" })?; let treatment = treatment.ok_or(ExecutionError::MissingField { field: "treatment" })?; values.sort_by(|a, b| a.path().cmp(b.path())); - snapshots.sort(); + if let Some(list) = snapshots.as_mut() { + list.sort(); + } inputs.sort(); environments.sort_by(environment_order); Comparable::assemble(values, harness, treatment, snapshots, inputs, environments) diff --git a/crates/candler-schemas/tests/it/guard_cell_digest.rs b/crates/candler-schemas/tests/it/guard_cell_digest.rs index 5d7ff708..d1acd597 100644 --- a/crates/candler-schemas/tests/it/guard_cell_digest.rs +++ b/crates/candler-schemas/tests/it/guard_cell_digest.rs @@ -54,7 +54,7 @@ struct Parts { values: Vec, harness: HarnessIdentity, treatment: TreatmentRef, - snapshots: Vec, + snapshots: Option>, inputs: Vec, environments: Vec, } @@ -70,9 +70,7 @@ fn parts(text: &str) -> Parts { values: field(&doc, "values"), harness: field(&doc, "harness"), treatment: field(&doc, "treatment"), - snapshots: doc - .get("snapshots") - .map_or_else(Vec::new, |_| field(&doc, "snapshots")), + snapshots: doc.get("snapshots").map(|_| field(&doc, "snapshots")), inputs: field(&doc, "inputs"), environments: field(&doc, "environments"), } @@ -86,8 +84,8 @@ fn rebuild(parts: Parts) -> Comparable { for value in parts.values { builder = builder.value(value); } - for entry in parts.snapshots { - builder = builder.snapshot(entry); + if let Some(list) = parts.snapshots { + builder = builder.snapshots(list); } for entry in parts.inputs { builder = builder.input(entry); @@ -280,10 +278,14 @@ fn every_manifest_path_is_classified_and_hashed_parts_move_the_digest() { cell.harness.name = Name::from_str("another-harness").expect("name"); } "comparable.treatment" => cell.treatment.tag = Some(String::from("changed")), - "comparable.snapshots" => cell.snapshots.push(DigestRef::new( - Name::from_str("catalog").expect("name"), - digest('e'), - )), + "comparable.snapshots" => { + cell.snapshots + .get_or_insert_with(Vec::new) + .push(DigestRef::new( + Name::from_str("catalog").expect("name"), + digest('e'), + )) + } "comparable.inputs" => cell.inputs.push(DigestRef::new( Name::from_str("script").expect("name"), digest('e'), @@ -691,14 +693,10 @@ fn reserved_roots_fill_the_typed_fields_and_absolute_paths_are_refused() { .treatment(treatment) .value(resolved("plan.a", &json!(1))) .value(resolved("plan.b", &json!("relative/dir/file.txt"))) - .snapshot(DigestRef::new( - Name::from_str("catalog").expect("name"), - digest('a'), - )) - .snapshot(DigestRef::new( - Name::from_str("catalog").expect("name"), - digest('b'), - )) + .snapshots(vec![ + DigestRef::new(Name::from_str("catalog").expect("name"), digest('a')), + DigestRef::new(Name::from_str("catalog").expect("name"), digest('b')), + ]) .build() .expect("expected cell"); let built = Comparable::from_resolved(&resolved_values).expect("from resolved"); From 530fee80b5ba8b6bbd75ee26c6d773add6160e75 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:28:39 +0900 Subject: [PATCH 06/18] fix(importer): write an imported cell's snapshots as a list, even empty The importer is the only writer of comparable.snapshots. The oracle vector invented-1 returns to its first body and digest; invented-4 is the shape of a new cell, without the key. Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-core/src/import/manifest.rs | 6 +++++- crates/candler-core/src/import/rules.rs | 3 ++- .../tests/oracle/vectors/cell_digest.toml | 14 +++++++------- .../tests/oracle/vectors/gen_vectors.py | 12 ++++++------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/crates/candler-core/src/import/manifest.rs b/crates/candler-core/src/import/manifest.rs index 6971c06e..2ba7ecca 100644 --- a/crates/candler-core/src/import/manifest.rs +++ b/crates/candler-core/src/import/manifest.rs @@ -308,11 +308,15 @@ fn cell_model( // BORROW: .to_owned() makes the owned tag treatment_ref.tag = Some(treatment.1.to_owned()); builder = builder.treatment(treatment_ref); + // The importer is the only writer of `snapshots`: an imported run's cell digest includes the + // list, empty or not. + let mut snapshots = Vec::new(); for rule in &rules.snapshots { let hex = provenance_text(folder, &rule.pointer)?; // BORROW: .clone() copies the snapshot kind into the cell - builder = builder.snapshot(DigestRef::new(rule.kind.clone(), Digest::from_hex(hex)?)); + snapshots.push(DigestRef::new(rule.kind.clone(), Digest::from_hex(hex)?)); } + builder = builder.snapshots(snapshots); let first_inputs = copied_inputs(first)?; for run in cell.runs.iter().skip(1) { let inputs = copied_inputs(run)?; diff --git a/crates/candler-core/src/import/rules.rs b/crates/candler-core/src/import/rules.rs index bf1976ef..d8710897 100644 --- a/crates/candler-core/src/import/rules.rs +++ b/crates/candler-core/src/import/rules.rs @@ -102,7 +102,8 @@ pub struct ImportRules { pub treatment: TreatmentRule, /// The name of the instrument that graded the folder, whose version and digest come from the folder's pinned evaluator. pub instrument: Name, - /// The snapshots of a cell. + /// The catalog digests of a cell, written into `comparable.snapshots`. The importer is the only + /// writer of that list. pub snapshots: Vec, /// The patterns tried, in order, on the evidence of a `not_measured` row. pub markers: Vec, diff --git a/crates/candler-core/tests/oracle/vectors/cell_digest.toml b/crates/candler-core/tests/oracle/vectors/cell_digest.toml index 9610a891..c268f9e6 100644 --- a/crates/candler-core/tests/oracle/vectors/cell_digest.toml +++ b/crates/candler-core/tests/oracle/vectors/cell_digest.toml @@ -28,10 +28,10 @@ # 9. Sorting by `path`, `(kind, digest)` and `(plugin, lock_digest)` is by Unicode code point # (the order of UTF-8 bytes); the vectors keep their sort keys ASCII. # 10. The `cell` key of a vector is the mini-corpus cell directory name, or `invented-`. -# A cell that lists `snapshots` is hashed with the list; a cell without catalog snapshots -# is hashed without the key (`invented-1`, `invented-4`). The vectors that list `snapshots` -# stay: the maintainer's own stores (golden and HTN runs) hold manifests of that shape, and -# their cell digests must still verify. Do not prune them as dead. +# A cell that carries `snapshots`, empty or not, is hashed with the list; a cell without +# the key is hashed without it (`invented-4`, the shape of every new cell). The vectors that +# carry `snapshots` stay: the maintainer's own stores (golden and HTN runs) hold manifests of +# that shape, and their cell digests must still verify. Do not prune them as dead. # `comparable` is sorted and unique; `shuffled` has the same content with every list in @@ -64,9 +64,9 @@ outside_twin = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"ex [[vector]] cell = "invented-1" -comparable = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"inputs\":[],\"environments\":[]}" -digest = "sha256:6457b5734cd352b35a3ae1b5a1f446c7eb700b2450a5ba46ee738696eb3917b5" -shuffled = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"inputs\":[],\"environments\":[]}" +comparable = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"snapshots\":[],\"inputs\":[],\"environments\":[]}" +digest = "sha256:4a5670ce3ee6403bb679546e49d2a573852868941bfe26cf81725a926ab6435d" +shuffled = "{\"values\":[],\"harness\":{\"name\":\"scripted\",\"version\":\"0.1.0\",\"driver\":\"pty-driver@1.0.0\"},\"treatment\":{\"name\":\"bare-skill\"},\"snapshots\":[],\"inputs\":[],\"environments\":[]}" outside = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"experiment_file\"}}],\"secrets\":[{\"name\":\"ANTHROPIC_API_KEY\",\"present\":true}],\"measured\":[{\"path\":\"run.exit\",\"value\":{\"code\":0},\"source\":{\"kind\":\"core_default\"}}],\"started_at\":\"2026-08-06T03:59:40Z\",\"ended_at\":\"2026-08-06T04:10:00Z\",\"host\":\"host-a-4\"}" outside_twin = "{\"sources\":[{\"path\":\"plan.model\",\"source\":{\"kind\":\"explicit_argument\"}},{\"path\":\"plan.runs\",\"source\":{\"kind\":\"user_config\"}}],\"secrets\":[],\"measured\":[],\"started_at\":\"2027-01-02T10:00:00+09:00\",\"ended_at\":\"2027-01-02T11:30:15.250+09:00\",\"host\":\"other-host-4\"}" diff --git a/crates/candler-core/tests/oracle/vectors/gen_vectors.py b/crates/candler-core/tests/oracle/vectors/gen_vectors.py index 0e997f53..c4100673 100644 --- a/crates/candler-core/tests/oracle/vectors/gen_vectors.py +++ b/crates/candler-core/tests/oracle/vectors/gen_vectors.py @@ -164,7 +164,7 @@ def comparable(values, harness, treatment, snapshots, inputs, environments): "inputs": inputs, "environments": environments, } - if not snapshots: + if snapshots is None: del unsorted["snapshots"] return sort_comparable(unsorted) @@ -287,7 +287,7 @@ def invented_cells(): two["values"], two["harness"], two["treatment"], - [], + None, two["inputs"], two["environments"], ) @@ -331,10 +331,10 @@ def cell_vectors(): header( "cell_digest.toml", "cell digest vectors (R01 §Run manifest, §Golden corpus).", - "A cell that lists `snapshots` is hashed with the list; a cell without catalog snapshots\n" - "is hashed without the key (`invented-1`, `invented-4`). The vectors that list `snapshots`\n" - "stay: the maintainer's own stores (golden and HTN runs) hold manifests of that shape, and\n" - "their cell digests must still verify. Do not prune them as dead.", + "A cell that carries `snapshots`, empty or not, is hashed with the list; a cell without\n" + "the key is hashed without it (`invented-4`, the shape of every new cell). The vectors that\n" + "carry `snapshots` stay: the maintainer's own stores (golden and HTN runs) hold manifests of\n" + "that shape, and their cell digests must still verify. Do not prune them as dead.", ) ] out.append( From c8a361cc428d0c4dae51aca69822a78b0033ce63 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:28:39 +0900 Subject: [PATCH 07/18] test(api): hold a resolved cell to the shape without snapshots Co-Authored-By: Claude Sonnet 5.5 --- .../tests/it/guard_inspect_mcp_config.rs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/crates/candler/tests/it/guard_inspect_mcp_config.rs b/crates/candler/tests/it/guard_inspect_mcp_config.rs index 7a87b122..2c9bf460 100644 --- a/crates/candler/tests/it/guard_inspect_mcp_config.rs +++ b/crates/candler/tests/it/guard_inspect_mcp_config.rs @@ -72,3 +72,42 @@ fn inspect_shows_the_mcp_server_a_run_was_launched_with() { "the text shows the declared server:\n{text}" ); } + +/// Guards: a cell Candler resolves and runs carries no `snapshots` key, and its digest, which +/// names the run, is the digest of the cell written without it. +/// +/// Oracle: the run's key names the cell digest the runner computed; the test recomputes it from +/// the stored `comparable` text with `Digest::of_canonical`, so a key written or hashed but not +/// stored (or the other way round) moves one side only. +/// +/// Bite: have resolve fill `comparable.snapshots` with an empty list (the key appears in the +/// stored cell and the digest changes). +#[test] +fn a_cell_from_resolve_is_stored_and_hashed_without_snapshots() { + let world = world(); + let launched = world.launch(); + finish(&world, &launched); + world.assert_sealed(1); + + let runs = world.store().join("runs"); + let run_dir = fs::read_dir(&runs) + .unwrap() + .flatten() + .map(|entry| entry.path()) + .find(|path| path.join("run.done").is_file()) + .expect("a sealed run"); + let manifest: Value = + serde_json::from_slice(&fs::read(run_dir.join("manifest.json")).unwrap()).unwrap(); + let comparable = manifest["comparable"].as_object().expect("a stored cell"); + assert!( + !comparable.contains_key("snapshots"), + "a new cell carries no snapshots key: {comparable:?}" + ); + let recomputed = candler_schemas::primitives::Digest::of_canonical(&manifest["comparable"]) + .expect("the cell has a canonical form"); + assert_eq!( + manifest["run"]["cell"].as_str(), + Some(recomputed.as_str()), + "the run is keyed by the digest of the cell as stored" + ); +} From f36f6a9af0132d0075a38ecf7aaeac83090eb418 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:28:39 +0900 Subject: [PATCH 08/18] refactor(resolve)!: refuse the snapshots path in an experiment Nothing that makes a new run may set comparable.snapshots, so the path leaves the configuration. An experiment that names it is refused as an unknown path; drop the setting. BREAKING CHANGE: an experiment or --set naming snapshots is refused. Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-core/src/resolve/paths.rs | 13 +++---------- .../candler-core/tests/it/guard_resolve_surface.rs | 4 ---- .../tests/it/guard_settings_out_of_cell.rs | 4 ---- .../candler-core/tests/it/guard_treatment_source.rs | 4 ---- .../candler-core/tests/it/support/harness_facts.rs | 4 ---- docs/contract/configuration-paths.md | 1 - 6 files changed, 3 insertions(+), 27 deletions(-) diff --git a/crates/candler-core/src/resolve/paths.rs b/crates/candler-core/src/resolve/paths.rs index 9079ce0c..e99c909e 100644 --- a/crates/candler-core/src/resolve/paths.rs +++ b/crates/candler-core/src/resolve/paths.rs @@ -13,8 +13,8 @@ use candler_schemas::execution::paths::{ ISOLATION_LIMITS_MEMORY, ISOLATION_LIMITS_PIDS, ISOLATION_NETWORK, ISOLATION_RECORD_PACKAGES, MCP, MODEL_EFFORT, MODEL_ENDPOINT, MODEL_ID, MODEL_TOKEN_SECRET, PERMISSION_MODE, PLUGINS_DIRS, PROMPT_TEMPLATE, PROMPT_VALUES, REQUEST_HARNESS, REQUEST_INPUTS, REQUEST_TREATMENT, - RUNNER_IDLE_S, RUNNER_MODE, SLOTS_COUNT, SLOTS_EVALUATORS, SNAPSHOTS, STORE_ROOT, - TOOLS_ALLOWED, TOOLS_DISALLOWED, TREATMENT, TREATMENT_SOURCE_PREFIX, + RUNNER_IDLE_S, RUNNER_MODE, SLOTS_COUNT, SLOTS_EVALUATORS, STORE_ROOT, TOOLS_ALLOWED, + TOOLS_DISALLOWED, TREATMENT, TREATMENT_SOURCE_PREFIX, }; use candler_schemas::primitives::FieldPath; use candler_schemas::servers::McpServerKind; @@ -152,7 +152,7 @@ const fn key(path: &'static str, kind: Kind, file: ConfigFile, meaning: &'static } /// Every path the configuration surface names. -pub const CONFIGURATION_PATHS: [PathRow; 49] = [ +pub const CONFIGURATION_PATHS: [PathRow; 48] = [ row( MODEL_ID, Kind::Leaf, @@ -444,13 +444,6 @@ pub const CONFIGURATION_PATHS: [PathRow; 49] = [ Reach::Agent(&[AgentSetting::Inputs]), "The inputs table.", ), - row( - SNAPSHOTS, - Kind::Subtree, - Class::Value, - Reach::CandlerOnly, - "The snapshots table.", - ), row( ENVIRONMENTS, Kind::Subtree, diff --git a/crates/candler-core/tests/it/guard_resolve_surface.rs b/crates/candler-core/tests/it/guard_resolve_surface.rs index b460f90b..7c45358c 100644 --- a/crates/candler-core/tests/it/guard_resolve_surface.rs +++ b/crates/candler-core/tests/it/guard_resolve_surface.rs @@ -56,10 +56,6 @@ impl PreflightStep for Roots { "inputs", json!([{"kind": "build_inputs", "digest": digest("inputs")}]), ), - ( - "snapshots", - json!([{"kind": "catalog", "digest": digest("snapshots")}]), - ), ( "environments", json!([{"plugin": "p@1.0.0", "lock_digest": digest("environments")}]), diff --git a/crates/candler-core/tests/it/guard_settings_out_of_cell.rs b/crates/candler-core/tests/it/guard_settings_out_of_cell.rs index 5f3a04e3..417f6ed7 100644 --- a/crates/candler-core/tests/it/guard_settings_out_of_cell.rs +++ b/crates/candler-core/tests/it/guard_settings_out_of_cell.rs @@ -111,10 +111,6 @@ impl PreflightStep for OtherRoots { fp("treatment"), js(json!({"name": "htn", "commit": "1".repeat(40)})), ) - .derive( - fp("snapshots"), - js(json!([{"kind": "catalog", "digest": digest}])), - ) .derive( fp("environments"), js(json!([{"plugin": "p@1.0.0", "lock_digest": digest}])), diff --git a/crates/candler-core/tests/it/guard_treatment_source.rs b/crates/candler-core/tests/it/guard_treatment_source.rs index ec25c013..56925446 100644 --- a/crates/candler-core/tests/it/guard_treatment_source.rs +++ b/crates/candler-core/tests/it/guard_treatment_source.rs @@ -59,10 +59,6 @@ impl PreflightStep for OtherRoots { fp("inputs"), js(json!([{"kind": "build_inputs", "digest": digest}])), ) - .derive( - fp("snapshots"), - js(json!([{"kind": "catalog", "digest": digest}])), - ) .derive( fp("environments"), js(json!([{"plugin": "p@1.0.0", "lock_digest": digest}])), diff --git a/crates/candler-core/tests/it/support/harness_facts.rs b/crates/candler-core/tests/it/support/harness_facts.rs index 3fe9ed19..9ceb02ad 100644 --- a/crates/candler-core/tests/it/support/harness_facts.rs +++ b/crates/candler-core/tests/it/support/harness_facts.rs @@ -526,10 +526,6 @@ impl PreflightStep for OtherRoots { fp("treatment"), js(json!({"name": "htn", "commit": "1".repeat(40)})), ) - .derive( - fp("snapshots"), - js(json!([{"kind": "catalog", "digest": digest}])), - ) .derive( fp("environments"), js(json!([{"plugin": "p@1.0.0", "lock_digest": digest}])), diff --git a/docs/contract/configuration-paths.md b/docs/contract/configuration-paths.md index 3c466107..86b8ce29 100644 --- a/docs/contract/configuration-paths.md +++ b/docs/contract/configuration-paths.md @@ -58,7 +58,6 @@ Core line: `v0.15.0`. | `harness` | the path and every path below it | experiment value | The harness table; the names below belong to the harness. | | `treatment` | the path and every path below it | experiment value | The treatment table. | | `inputs` | the path and every path below it | experiment value | The inputs table. | -| `snapshots` | the path and every path below it | experiment value | The snapshots table. | | `environments` | the path and every path below it | experiment value | The environments table. | | `treatment:` | text that is not a field path | experiment value | The prefix of a value that names a treatment source; the rest is the path. | | `store.root` | the path | configuration key | The store root; a relative path is read from the project root. | From dd9258d2715157549ced9aa86e77d7f5b174900a Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:29:23 +0900 Subject: [PATCH 09/18] docs(readme): state a run's tools by the MCP config, census and trace The README, CONTRIBUTING and the architecture design name a run's tools only by the resolved mcp.* values, the census and the trace; the comparable.snapshots rule is described as the imported old shape. Co-Authored-By: Claude Sonnet 5.5 --- CONTRIBUTING.md | 2 +- README.md | 4 +-- __design__/architecture.md | 62 ++++++++++++++------------------------ 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5019d1f6..fffad7f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ A scope names the topic of the commit, never the action or a layer (`core`, `mis | Area | Scopes | |---|---| | Operation API | `api`, `resolve`, `jobs`, `budgets` | -| Execution | `experiment`, `orchestrator`, `runner`, `isolation`, `injection`, `census`, `catalog` | +| Execution | `experiment`, `orchestrator`, `runner`, `isolation`, `injection`, `census` | | Ingestion | `trace-model`, `adapter-claude-code`, `adapter-opencode` (one `adapter-` per harness), `importer` | | Storage | `run-store`, `manifest`, `outcome-store` | | Evaluation | `evaluation`, `outcome-algebra`, `evaluator-protocol`, `registry`, `evaluator-helper` (the Python package in `python/candler-evaluator`) | diff --git a/README.md b/README.md index 53f7552f..eaae4cd8 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ operation API: evaluators that emit one outcome record format. A library, a lean CLI and an MCP server are thin surfaces over that API. Domain science (for -example the HTN-creator evaluation) plugs in as evaluators, suite specs, fixtures and catalog -providers. The core names no domain. +example the HTN-creator evaluation) plugs in as evaluators, suite specs and fixtures. The core +names no domain. Candler runs and grades LLM-based agents under controlled conditions, and compares the results with statistics that say what they can and cannot support. diff --git a/__design__/architecture.md b/__design__/architecture.md index bcff144f..6c53e9c1 100644 --- a/__design__/architecture.md +++ b/__design__/architecture.md @@ -69,7 +69,6 @@ graph TD subgraph EXE [Execution] ORCH[orchestrator: matrix, run identity, resume, budgets] --> HD{harness driver: Claude Code, OpenCode v2, ...} ORCH --> ISO{isolation: host or container} - ORCH --> CAT[catalog providers: snapshot per run] HD -.describes.-> SUP end subgraph ING [Ingestion] @@ -95,7 +94,7 @@ graph TD MAN[plug-in manifest] --> REG SS[suite file] --> REG EV[evaluator command + pinned checker library + Python helper] -.declared by.-> MAN - FX[fixtures, inputs, catalog providers] --> ORCH + FX[fixtures, inputs] --> ORCH end ``` @@ -106,7 +105,7 @@ graph TD | Operation API | The operation set, argument resolution with the source of every value, jobs, budgets, confirmations | Any domain notion | | Job supervisor | Job identity, the job directory, the event stream, cancellation | What a run or an outcome means | | Process supervisor | Every process Candler starts (agents, evaluators): spawn into its own process group, child records, deadlines, stop escalation, stray sweep, machine-wide slots | Harness or evaluator semantics | -| Execution | Experiment matrix, run identity, resume, isolation, catalog snapshots, artifact collection | What the artifacts mean | +| Execution | Experiment matrix, run identity, resume, isolation, the resolved MCP configuration, artifact collection | What the artifacts mean | | Harness drivers | Harness-specific data: config files, command line, stop action and signal, exit classification, what to collect, version detection | Starting, timing or killing processes | | Ingestion | Trace readers, the normalised trace model, the legacy importer | Judgement | | Run store | Run identity, content-addressed artifacts, the workspace view, manifest, integrity, the invalid-run ledger | Grades | @@ -479,7 +478,7 @@ the gateway, the reader, the trace's gateway signals, collection, input leak, th (`container-record/1`: `{cid, labels {job, run, experiment}, created_at, image_id, role: agent|gateway, spawned_at}`) and the labels `candler.job`, `candler.run`, `candler.experiment` and `candler.role` (`agent` or `gateway`, which the destroy guard reads). A control container - (a version readout, a catalog capture, the image build) is the exception: `--rm`, only the label + (a version readout, the image build) is the exception: `--rm`, only the label `candler.role=control`, and no network except for the image build, which reaches the package index over the default bridge; no sweep meets it and the guard never destroys it. The entrypoint runs under `timeout `, so an orphaned container expires by itself @@ -621,7 +620,7 @@ the gateway, the reader, the trace's gateway signals, collection, input leak, th | `isolation.record_packages` (read from the env image, recorded in `measured[]`, never in the cell) | setting | | `isolation.build.plugin` (`/`: the plug-in agent environment the experiment selects; §Plug-ins) | setting | | `request.harness`, `request.treatment`, `request.inputs`, `model.token_secret` | setting | - | `harness`, `treatment`, `inputs[]`, `snapshots`, `environments` (reserved) | typed root | + | `harness`, `treatment`, `inputs[]`, `snapshots` (an imported run's cell only), `environments` (reserved) | typed root | A CLI path resolves against the caller's cwd, a path in the experiment file against that file's directory (I14). @@ -688,7 +687,7 @@ I3, so event times are reproducible even where the harness emits none. | Classify the exit | Exit status, output tail and the parsed sessions → `ended_by` | Codes, messages, error results | | Collect | Files, or the output of an export command | Home-dir transcripts, stdout, a SQLite store | | Read offline | Parse a trace on disk, no process | Line streams or whole documents; format versions | -| Census | The tool catalog the agent actually had | How to list built-in and MCP tools | +| Census | The tools the agent actually had | How to list built-in and MCP tools | ### Traits (signatures only) @@ -1090,7 +1089,6 @@ erDiagram SESSION ||--o{ EVENT : ordered SESSION ||--o{ SESSION : "spawned (subagents)" RUN ||--o{ ARTIFACT : "left behind" - RUN ||--o{ CATALOG_SNAPSHOT : targeted RUN ||--|| MANIFEST : provenance PLUGIN ||--o{ EVALUATOR_VERSION : provides SUITE ||--o{ EXPECTATION : declares @@ -1130,8 +1128,8 @@ host?, job?, integrity, import?, evaluation_inputs[]?}`. - **`comparable`** `{values[] {path, value?}, harness {name, version, driver?}, treatment, snapshots[], inputs[], environments[]}`: every resolved value by field path (isolation under - `isolation.*`), the harness, the treatment reference (name, tag and commit), the catalog snapshot - and input digests, and the plug-in environment lock digests. A value without `value` was + `isolation.*`), the harness, the treatment reference (name, tag and commit), the input digests, the + plug-in environment lock digests and, for an imported run, the catalog digests it recorded. A value without `value` was `unrecorded`. Every list rises strictly by its key, so it is sorted and holds no duplicate: `values` by path, `snapshots` and `inputs` by kind then digest, `environments` by plug-in then lock digest. A reader refuses a list that does not. @@ -1141,8 +1139,10 @@ host?, job?, integrity, import?, evaluation_inputs[]?}`. it, and a string value that is an absolute path is refused: a file enters a cell as an `inputs[]` digest. The per-run caps are cell values under `budget.per_run.*`; the job caps (every other `budget.*` path) and `replicates` are operational settings, which `resolve` classifies by path. A - snapshot's digest is that of its RFC 8785 form without `captured_at`; an imported snapshot's - digest is the bare sha256 its legacy provenance recorded, which a live snapshot's never equals. + `snapshots` is the imported old shape: an imported run's cell lists the bare sha256 its legacy + provenance recorded, and the cell hashes it with the list, empty or not. A cell Candler makes + carries no `snapshots` key and hashes without it. A run's MCP servers are its resolved `mcp.*` + values. - **The treatment reference** `{name, tag?, commit?}` holds no source. A live run's carries the commit its source resolved to whenever the treatment names a tag or a commit; an imported run's carries none, since the legacy folder records none. @@ -1283,26 +1283,12 @@ the latest complete request wins. Differing outcomes under one key, other than a `instrument_error` or `deadline` replaced by a measured one, are reported as I4 violations. Roles and weights are read from the outcomes, never from today's suite. -### Wire schema: tool-catalog snapshot +### The MCP configuration of a run -What the MCP servers a run targets actually offered, captured per run by a catalog provider. HTN's -Tier D grades a mapping against it, the run manifest records its digest as a comparability field -(I7), and evaluators receive it through `needs.snapshots[]`. - -`schema: "tool-catalog-snapshot/1"`, `captured_at`, `provider@version`, `environment?` (string → -string: versions the capture depended on), `ext?` (opaque, provider-specific), `servers[] {name, -source_path, source_digest, transport (stdio / http / sse), tools[]}`. Tools are in MCP -`tools/list` shape, camelCase kept: `name`, `inputSchema`, `title?`, `description?`, -`outputSchema?`, `annotations?`, and every other key preserved as given. HTN's -`tool-catalog-snapshot/0` is this shape with `servers_dir` and `stubbed_modules` at the top level; -its capture script and loader move them under `ext`. - -Server names are unique within a snapshot and tool names within a server, compared byte for -byte; both are non-empty. A reader keeps every key of a tool, `ext` and `environment`, and every -value, except: keys not defined for a snapshot or a server are dropped; of repeated keys the last -is kept; object keys are sorted; numbers are held as `i64`, `u64` or `f64`, so an integer beyond -the 64-bit range becomes a float, a decimal beyond `f64` precision is rounded and a magnitude -beyond `f64` is refused; and text nested deeper than about 120 levels is refused. +A run's MCP servers are the resolved `mcp.*` values in `comparable.values`, which the cell digest +hashes and `inspect` shows. Candler stores no capture of what a server offered: the tools the +harness had are the census's list, and the calls are in the trace. `tool-catalog-snapshot/1` is +the HTN consumer's own schema, not Candler's. ### Wire encodings @@ -1317,10 +1303,10 @@ The rules every wire type of the `schemas@` line follows. | Unknown fields | Schemas are strict (`additionalProperties: false`): they define what a writer at that version emits. Readers of the records Candler writes ignore unknown fields, so that an older reader reads a newer record. Readers of the three author documents (experiment, suite, plug-in manifest) refuse an unknown field with `.unknown_field` and its pointer (§Refusals). Every reader reads objects only, never a struct written as an array. MCP tool objects, `inputSchema`, `outputSchema` and `ext` are open. | | Run key | `{"cell": "sha256:", "replicate": n, "attempt": m}` in records, both counters from 1. Paths and `CANDLER_RUN` use `-r-a`. | | Digests | `sha256:` + 64 lowercase hex; blob paths use the bare hex. An instrument digest may also be `git:<40 or 64 hex>`, a commit of a clean tree, valid only with `dirty: false`. Digests of JSON values (`suite_entry_digest`, `context_digest`, the cell digest) are taken over RFC 8785 canonical JSON. | -| `name@version` | Split at the last `@`; the name has no `@` or whitespace. Evaluator and instrument versions are SemVer 2.0; a catalog provider's version is a free token `[0-9A-Za-z.+-]+`. | +| `name@version` | Split at the last `@`; the name has no `@` or whitespace. Evaluator and instrument versions are SemVer 2.0; a step name's version is a free token `[0-9A-Za-z.+-]+`. | | Ids, paths, times | `request_id`: UUIDv7, lowercase hyphenated. `expectation_id`: `^[A-Za-z0-9][A-Za-z0-9._-]*$`. Run-relative paths: POSIX, non-empty, no leading `/`, no empty, `.` or `..` segment, no `\`. Timestamps: RFC 3339 with an uppercase `T`, and `Z` or a `±HH:MM` offset, naming a real instant, kept as written. | | Evidence refs | `event:#`: the session id is non-empty, without `#` or white space; `seq` is a decimal without leading zeros (`0` allowed). `path:` optionally followed by `#L` or `#L-`: lines count from 1, `n ≤ m`, and the path holds no `#`. | -| Version marker | A standalone document (the catalog snapshot) carries its `schema` tag. Records that travel inside versioned messages or files (the outcome record) carry none. | +| Version marker | A standalone document (the `inspect` record) carries its `schema` tag. Records that travel inside versioned messages or files (the outcome record) carry none. | | Schema files | JSON Schema 2020-12, generated by `schemars` from the structs, one self-contained file per root in `crates/candler-schemas/schema/.schema.json`, `$id` `urn:candler:schemas:`, no crate version inside. Cross-field rules are `if`/`then` clauses; rules JSON Schema cannot state (`num ≤ den`, the pass and fail weight rules, unique names, 64- and 32-bit integer limits) are enforced in Rust and stated in a `$comment`. Patterns end with `(?![\s\S])` in place of `$`, and spell white space as Unicode's `White_Space` set plus the byte-order mark in place of `\s`: Python's `re`, which Python `jsonschema` uses, lets `$` match before a final newline and gives `\s` a different set, so only this form reads alike under ECMA 262, Rust and Python. The regexes this document writes with `$` (reason codes, ids, field paths) are published in this form. A test refuses any published pattern that uses `$` or `.` outside a character class, or a shorthand class or assertion (`\s`, `\d`, `\w`, `\b`, `\A`, `\Z`, `\p` and their negations) anywhere but in the end anchor, and requires every pattern to end with the anchor except one inside an `if`, such as the prefix `^git:`, which only tells variants apart; the other refusals still apply to it. `///` docs become `description`s, so a doc edit on a wire type is a schema patch. | | Drift check | `tests/schema_drift.rs` compares every root in `generated_schemas()` byte for byte with its committed file; `CANDLER_BLESS_SCHEMAS=1` rewrites them. | | Rust shape | Wire structs are `#[non_exhaustive]`, built through validating builders and deserialised through `try_from` from a JSON object only (never an array), so a record is valid however it was made and a new optional field is a minor in Rust as in the schema. Evolving enums are `#[non_exhaustive]`; `Status` and `Role` are closed. `serde_json` has `float_roundtrip`. JSON text holding an unpaired surrogate escape is refused by the Rust reader. | @@ -1328,7 +1314,7 @@ The rules every wire type of the `schemas@` line follows. ### The `schemas@` line holds -Outcome record · catalog snapshot · raw frames · normalised trace (header, session, event records) +Outcome record · raw frames · normalised trace (header, session, event records) · workspace tree (`run-tree/1`) · child record · evaluator messages (`describe` result, `evaluate` params, notifications, and the request side: method names, `{reported}` and `-32800`) · plug-in manifest · suite file · run manifest · job record, event envelope and event payloads · experiment file. All are generated from `candler-schemas`. @@ -1551,7 +1537,6 @@ request files under the new evaluator version; `diff` compares versions. ### Other interfaces (signatures only) -- `CatalogProvider.snapshot(cell) -> catalog_snapshot` - `Isolation`, one container per run: `plan(cell, workspace) -> ContainerPlan`; `run_request(plan, command, marker, run key, outputs) -> IsolatedRequest` (the spawn request, with the run's stop hook attached, and the handle that reports the end facts); @@ -1653,7 +1638,7 @@ lists it in the index and leaves its file alone. **Reference, done 2026-10-28.** The 240 runs of 2026-08-06 (12 cells: Haiku 4.5, Sonnet 4.6, Sonnet 5 × skill v0.2.3–0.2.6, 20 runs each, rikyu domain), regraded by `htn-creator-eval@0.4.2` -(mcp-python-ingestion `28be2c15`, clean tree) against rikyu's own catalog snapshot. Frozen in +(mcp-python-ingestion `28be2c15`, clean tree) against the HTN's own committed tool catalog for the rikyu domain. Frozen in `agenticai4hpc26-artifact` on branch `regrade/htn-creator-eval-0.4.2`, commit `7efa1b7`, tag `candler-m2a-golden`; the published `main` is untouched. `expectations.jsonl` holds one row per `(run, expectation)`: 10,320 rows. @@ -1705,7 +1690,7 @@ input the legacy importer reconstructed (importer defect) → anything left is a | `comparable.values` | `experiment.json` `plan.*`, `provenance.*`, and the top-level key the import rules name for the version the treatment resolved to (`resolved_skill_version` here) | Each JSON leaf becomes a dotted field path with source `imported{experiment.json}`; a `null` leaf has no value and is `unrecorded`. `plan.out_dir` goes to `import`. | | `comparable.harness` | the harness name the import rules give, and the version at their JSON pointer into the stream's first line (`claude_code_version` here) | Must agree across a cell, else the import is refused | | `comparable.treatment` | `experiment.json`, at the JSON pointer the import rules name | A string written `@`, else the import is refused; it gives the name and tag, and no commit, which the legacy folder does not record | -| `comparable.snapshots[]` | `PROVENANCE.json`, at the JSON pointers the import rules name | One entry per snapshot rule: the rule's kind and the bare sha256 the legacy provenance recorded at its pointer, not the RFC 8785 form a live snapshot's digest is taken over | +| `comparable.snapshots[]` | `PROVENANCE.json`, at the JSON pointers the import rules name | The imported old shape, and only an import writes it: one entry per snapshot rule, with the rule's kind and the bare sha256 the legacy provenance recorded at its pointer | | `comparable.inputs[]` | each run's `timing.json` `copied_inputs[] {role, sha256}` | `role` is the kind; the lists must agree across a cell, else the import is refused | | `comparable.environments[]` | — | Empty: the legacy folder records no plug-in environment | | `measured` | each run's `eval_metadata.json` `provenance.*`, where the cell-level value is `null` | Source `imported{}`; the copies within one run must agree, else the import is refused | @@ -1800,7 +1785,6 @@ turns a plan into a spawn request, then collects and destroys. | SIGCHLD-driven reaping (A3) | Reap children on signal instead of by polling | Less polling, faster exit facts | A measured reap delay or a missed exit | | Long-lived workers | A worker that serves many runs | Start-up cost per run | A measured start-up cost that dominates a run | | Signals error versus census | One ruling for `runner/exec/mod.rs:777`, which reads a signals error as "gateway did not fail" while the census reads it as "not collected" | The two readings can disagree on the same fact | The next change to either reader | -| Catalog capture of input-delivered servers | A mount seam in `catalog_spec` and an inputs-aware provider | The per-run catalog cannot see servers delivered through inputs | An eval that must grade against the run's own captured catalog of input-delivered servers, or an automated snapshot-versus-live check | | URL-path allowlist | An allowlist that admits part of a host, through TLS interception at the proxy | The proxy reads only the SNI, so it cannot tell two paths of one host apart | An eval that must allow part of a host | | Domain fronting | Closing the residual that a listed host behind a shared CDN front is reachable under another name | The SNI rule trusts the name the client presents | A listed host behind a shared CDN front | | Transformed copy of ground truth | Detection of ground truth that was encoded or reformatted before it reached the boundary | Digests of the original miss a transformed copy | A leak that digests missed | @@ -1826,7 +1810,7 @@ turns a plan into a spawn request, then collects and destroys. | One sealing step for importers (B4) | An importer whose trace reader fails seals the run invalid, as raw ingest does | One integrity rule for every import | Eliott's ruling; no external user depends on today's behaviour | | One `Comparable` diff (B10) | One diff for the comparability verdict | Fewer copies | A change to the shape of recorded deviations | | fsync budget and streaming import (B6, B8) | A bounded fsync cost and an import that streams | Crash guards cost time, and a large import peaks in memory | A measured cost or memory peak that hurts | -| Static tool catalog, `as_bytes`, refusal codes, shared outcome vectors (C5, C9, C10–C12) | Small consistency work | Fewer drifting copies | The next change that touches one of them | +| `as_bytes`, refusal codes, shared outcome vectors (C5, C9, C10–C12) | Small consistency work | Fewer drifting copies | The next change that touches one of them | | `lock_split` | `lock_split` reads the plug-in's requirements from the fragment and the experiment's from the resolved value | The two sources can disagree | A plug-in whose fragment and resolved requirements differ | | Paired designs | McNemar for designs that pair runs | Runs are unpaired today (§Analysis statistics) | A design that pairs replicates | | Declared margin | A margin declared in the experiment, read with TOST | "No difference" is never stated today | An experimenter who needs equivalence | @@ -1863,7 +1847,7 @@ The milestones, their order, exit gates and scope are in the meta-roadmap [`__roadmap__/candler-v1/`](../__roadmap__/candler-v1/README.md). Each milestone is planned in detail by its own session, as its own campaign under `__roadmap__/`. -HTN lane: HTN Phase 4.5 reads the catalog snapshot; Phase 7 writes its Tier C logic as library +HTN lane: HTN Phase 4.5 reads its own catalog snapshot; Phase 7 writes its Tier C logic as library functions; after M2a the checker library becomes the plug-in and `eval.json` becomes a suite file (no templates); Phase 8 waits for M5. The reasoning is in `/Users/hacker/Documents/src/External/PCfVW/mcp-python-ingestion/__reports__/candler_core/02-findings_lane_overlap_v0.md`. From bdc0ec5c7c46737853dec616f4c4201404256b01 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:30:08 +0900 Subject: [PATCH 10/18] test(schemas): end the snapshots perturbation with a statement Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-schemas/tests/it/guard_cell_digest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/candler-schemas/tests/it/guard_cell_digest.rs b/crates/candler-schemas/tests/it/guard_cell_digest.rs index d1acd597..70e59278 100644 --- a/crates/candler-schemas/tests/it/guard_cell_digest.rs +++ b/crates/candler-schemas/tests/it/guard_cell_digest.rs @@ -284,7 +284,7 @@ fn every_manifest_path_is_classified_and_hashed_parts_move_the_digest() { .push(DigestRef::new( Name::from_str("catalog").expect("name"), digest('e'), - )) + )); } "comparable.inputs" => cell.inputs.push(DigestRef::new( Name::from_str("script").expect("name"), From 6bb9e6d70f141daaaf86b4af4c1fd53558ab56fa Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:40:45 +0900 Subject: [PATCH 11/18] test(resolve): drop the snapshots path from the recorded cells The recorded comparable cells and the hand-built manifests no longer carry a snapshots key, as a resolved cell has none, and the cells keep the order the planner now gives them. Co-Authored-By: Claude Sonnet 5.5 --- .../comparable/cont_train.json | 98 +++---------------- .../comparable/run_plan_experiment.json | 16 +-- .../comparable/settings_experiment.json | 12 --- .../harness_baseline/comparable/smoke_v2.json | 6 -- .../tests/it/guard_job_orchestrate.rs | 10 +- .../candler-core/tests/it/support/run_plan.rs | 1 - .../tests/it/support/session_rig.rs | 1 - .../tests/oracle/vectors/field_paths.toml | 5 - 8 files changed, 20 insertions(+), 129 deletions(-) diff --git a/crates/candler-core/tests/fixtures/harness_baseline/comparable/cont_train.json b/crates/candler-core/tests/fixtures/harness_baseline/comparable/cont_train.json index f0cab5d0..f4d0abe3 100644 --- a/crates/candler-core/tests/fixtures/harness_baseline/comparable/cont_train.json +++ b/crates/candler-core/tests/fixtures/harness_baseline/comparable/cont_train.json @@ -11,12 +11,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -40,7 +34,7 @@ }, { "path": "plan.model", - "value": "claude-sonnet-4-6" + "value": "claude-haiku-4-5" }, { "path": "plan.prompt_domain_name", @@ -72,12 +66,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -101,7 +89,7 @@ }, { "path": "plan.model", - "value": "claude-haiku-4-5" + "value": "claude-sonnet-5" }, { "path": "plan.prompt_domain_name", @@ -133,12 +121,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -162,7 +144,7 @@ }, { "path": "plan.model", - "value": "claude-sonnet-5" + "value": "claude-haiku-4-5" }, { "path": "plan.prompt_domain_name", @@ -194,12 +176,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -239,7 +215,7 @@ }, { "path": "plan.skill_version", - "value": "htn-creator@0.2.5" + "value": "htn-creator@v0.2.3" } ] }, @@ -255,12 +231,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -284,7 +254,7 @@ }, { "path": "plan.model", - "value": "claude-sonnet-5" + "value": "claude-sonnet-4-6" }, { "path": "plan.prompt_domain_name", @@ -300,7 +270,7 @@ }, { "path": "plan.skill_version", - "value": "htn-creator@0.2.5" + "value": "htn-creator@0.2.4" } ] }, @@ -316,12 +286,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -345,7 +309,7 @@ }, { "path": "plan.model", - "value": "claude-sonnet-4-6" + "value": "claude-sonnet-5" }, { "path": "plan.prompt_domain_name", @@ -361,7 +325,7 @@ }, { "path": "plan.skill_version", - "value": "htn-creator@0.2.4" + "value": "htn-creator@0.2.6" } ] }, @@ -377,12 +341,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -438,12 +396,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -467,7 +419,7 @@ }, { "path": "plan.model", - "value": "claude-sonnet-5" + "value": "claude-sonnet-4-6" }, { "path": "plan.prompt_domain_name", @@ -483,7 +435,7 @@ }, { "path": "plan.skill_version", - "value": "htn-creator@0.2.6" + "value": "htn-creator@0.2.5" } ] }, @@ -499,12 +451,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -560,12 +506,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -589,7 +529,7 @@ }, { "path": "plan.model", - "value": "claude-haiku-4-5" + "value": "claude-sonnet-5" }, { "path": "plan.prompt_domain_name", @@ -621,12 +561,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -666,7 +600,7 @@ }, { "path": "plan.skill_version", - "value": "htn-creator@v0.2.3" + "value": "htn-creator@0.2.4" } ] }, @@ -682,12 +616,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -727,7 +655,7 @@ }, { "path": "plan.skill_version", - "value": "htn-creator@0.2.4" + "value": "htn-creator@0.2.5" } ] } diff --git a/crates/candler-core/tests/fixtures/harness_baseline/comparable/run_plan_experiment.json b/crates/candler-core/tests/fixtures/harness_baseline/comparable/run_plan_experiment.json index f697bebc..8f861d4d 100644 --- a/crates/candler-core/tests/fixtures/harness_baseline/comparable/run_plan_experiment.json +++ b/crates/candler-core/tests/fixtures/harness_baseline/comparable/run_plan_experiment.json @@ -11,12 +11,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -36,7 +30,7 @@ }, { "path": "model.id", - "value": "m2" + "value": "m1" } ] }, @@ -52,12 +46,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -77,7 +65,7 @@ }, { "path": "model.id", - "value": "m1" + "value": "m2" } ] } diff --git a/crates/candler-core/tests/fixtures/harness_baseline/comparable/settings_experiment.json b/crates/candler-core/tests/fixtures/harness_baseline/comparable/settings_experiment.json index a5e615bd..7a36fa8b 100644 --- a/crates/candler-core/tests/fixtures/harness_baseline/comparable/settings_experiment.json +++ b/crates/candler-core/tests/fixtures/harness_baseline/comparable/settings_experiment.json @@ -11,12 +11,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" @@ -64,12 +58,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" diff --git a/crates/candler-core/tests/fixtures/harness_baseline/comparable/smoke_v2.json b/crates/candler-core/tests/fixtures/harness_baseline/comparable/smoke_v2.json index dbc2103b..443a176c 100644 --- a/crates/candler-core/tests/fixtures/harness_baseline/comparable/smoke_v2.json +++ b/crates/candler-core/tests/fixtures/harness_baseline/comparable/smoke_v2.json @@ -11,12 +11,6 @@ "version": "2.1.311" }, "inputs": [], - "snapshots": [ - { - "digest": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "kind": "catalog" - } - ], "treatment": { "commit": "1111111111111111111111111111111111111111", "name": "htn" diff --git a/crates/candler-core/tests/it/guard_job_orchestrate.rs b/crates/candler-core/tests/it/guard_job_orchestrate.rs index bea6ace1..f69dda79 100644 --- a/crates/candler-core/tests/it/guard_job_orchestrate.rs +++ b/crates/candler-core/tests/it/guard_job_orchestrate.rs @@ -443,19 +443,19 @@ fn cells_by_tag( /// Guards: T3 wiring (C3) -- each cell of a two-level job carries its own level's treatment /// checkout and harness, never the first level's. /// Oracle: the checkouts `/src/a` and `/src/b`, the harness versions `2.1.0` and `2.2.0` and the -/// source paths `snapshots` and `environments` written below, one set for each level's tag. +/// source paths `inputs` and `environments` written below, one set for each level's tag. /// Bite: build every cell from the job's primary level. #[test] fn t3_each_cell_runs_its_own_treatment() { let levels = [ - level_of("v1", "/src/a", "2.1.0", "snapshots"), + level_of("v1", "/src/a", "2.1.0", "inputs"), level_of("v2", "/src/b", "2.2.0", "environments"), ]; let cells = cells_by_tag(&two_level_file(&["htn", "other"]), &levels); assert_eq!(cells.len(), 2, "one cell per level"); for (tag, source, version, root, other) in [ - ("v1", "/src/a", "2.1.0", "snapshots", "environments"), - ("v2", "/src/b", "2.2.0", "environments", "snapshots"), + ("v1", "/src/a", "2.1.0", "inputs", "environments"), + ("v2", "/src/b", "2.2.0", "environments", "inputs"), ] { let cell = cells.get(tag).expect("the level's cell"); let held: Vec<&str> = cell @@ -487,7 +487,7 @@ fn t3_each_cell_runs_its_own_treatment() { /// Bite: look the cell's level up among the job's levels and refuse a job that holds none. #[test] fn t3_one_level_job_unchanged() { - let levels = [level_of("v1", "/src/a", "2.1.0", "snapshots")]; + let levels = [level_of("v1", "/src/a", "2.1.0", "inputs")]; let cells = cells_by_tag(&two_level_file(&["htn"]), &levels); assert_eq!(cells.len(), 1, "one level, one cell"); let cell = cells.get("v1").expect("the cell"); diff --git a/crates/candler-core/tests/it/support/run_plan.rs b/crates/candler-core/tests/it/support/run_plan.rs index 03468058..e1253fbf 100644 --- a/crates/candler-core/tests/it/support/run_plan.rs +++ b/crates/candler-core/tests/it/support/run_plan.rs @@ -146,7 +146,6 @@ fn manifest_json(run: &Run<'_>, cell: &str) -> Value { "values": values, "harness": {"name": "claude-code", "version": run.facts.version}, "treatment": treatment(run.facts), - "snapshots": [], "inputs": inputs_json(run.facts), "environments": [], }, diff --git a/crates/candler-core/tests/it/support/session_rig.rs b/crates/candler-core/tests/it/support/session_rig.rs index fa6729d6..e369f799 100644 --- a/crates/candler-core/tests/it/support/session_rig.rs +++ b/crates/candler-core/tests/it/support/session_rig.rs @@ -183,7 +183,6 @@ fn comparable_of(values: &[(String, Value)]) -> Comparable { "values": entries, "harness": {"name": "claude-code", "version": "2.1.311"}, "treatment": {"name": "htn"}, - "snapshots": [], "inputs": [], "environments": [], })) diff --git a/crates/candler-core/tests/oracle/vectors/field_paths.toml b/crates/candler-core/tests/oracle/vectors/field_paths.toml index 910fa639..46b57f4e 100644 --- a/crates/candler-core/tests/oracle/vectors/field_paths.toml +++ b/crates/candler-core/tests/oracle/vectors/field_paths.toml @@ -179,11 +179,6 @@ path = "inputs[]" class = "typed_root" source = "derived digests: server sources and the Dockerfile" -[[path]] -path = "snapshots" -class = "typed_root" -source = "derived: the catalog digest from the CatalogProvider" - [[path]] path = "environments" class = "typed_root" From 1807ccd19bb7ae800de25773cab0c71f908719b5 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:40:45 +0900 Subject: [PATCH 12/18] reports(api): record the second round on the snapshot removal Co-Authored-By: Claude Sonnet 5.5 --- __reports__/diet/leaves/snapshot_out_v0.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/__reports__/diet/leaves/snapshot_out_v0.md b/__reports__/diet/leaves/snapshot_out_v0.md index 9008a7c2..b4a3125f 100644 --- a/__reports__/diet/leaves/snapshot_out_v0.md +++ b/__reports__/diet/leaves/snapshot_out_v0.md @@ -20,14 +20,16 @@ The schemas commit touches only `crates/candler-schemas/`, as CI's Commit messag |---|---|---| | Guard on `candler run` -> `inspect`, one declared server, JSON and text | PASS | `inspect_shows_the_mcp_server_a_run_was_launched_with` launches `candler run --set mcp.servers.fs.command=mcp-fs --set 'mcp.servers.fs.args=["data"]'` through the fake docker, reads the sealed run back, and finds `mcp.servers.fs.command = "mcp-fs"` and `mcp.servers.fs.args = ["data"]` in `record["mcp"]` and the same two lines in the text form. On the base commit (`e8b07a32`): FAIL, `the record shows the mcp values: {"catalog":{"provider":"candler-image@1","schema":"tool-catalog-snapshot/1","servers":[]},...}`. | | `CATALOG_PROGRAM`, `CatalogCommand`, `CommandCatalogProvider`, `CatalogStep`, the fake docker's constant, the provider seam | PASS | All deleted: `runner/evidence/catalog.rs`, `resolve/steps/catalog.rs`, the constant in `commands/preflight.rs`, the `printf` branch of the fake `docker run`, `M2bServices.catalog`, `catalog_spec` and its two control-kind rows. `CatalogProvider` had one implementor besides test fakes, so the seam went with it. The plumbing that only carried the catalog text to the seal went too: `StepReport.blobs`/`blob()`, `CellRun.blobs`/`with_blobs()`, `RunWriter::blob`. | -| `comparable` carries no catalog snapshot; new digest version vectors; old vectors verify | DEVIATION | `comparable.snapshots` is still a field of `Comparable`, optional: a cell that lists none leaves the key out of its record and of its hash, so every cell Candler makes now hashes under the new digest. The field stays because it is the one place the digest of a manifest that lists snapshots (the 240 golden runs, imported HTN runs) is read from: dropping it would make those manifests unreadable (`deny_unknown_fields`) and their digests unverifiable. New vectors: `invented-1` (regenerated, no `snapshots`) and `invented-4` (new, no `snapshots`) in `cell_digest.toml`; the three corpus cells and `invented-2`/`-3` keep `snapshots` and their old digests (`digests_equal_the_oracle`, 7 vectors, PASS). The generator and the vector header say why the old vectors stay. The lead decides whether to take the field out later, after the maintainer's stores are re-imported. | +| `comparable` carries no catalog snapshot; new digest version vectors; old vectors verify | PASS (accepted by the coordinator on the condition that nothing makes new runs set it) | `Comparable.snapshots` is `Option>`: `None` is left out of the record and the hash, and `Some(list)`, empty or not, is written and hashed as before #76. Only the importer sets it (`import/manifest.rs` via `ComparableBuilder::snapshots`), because an imported run's digest included it. Guard: `a_cell_from_resolve_is_stored_and_hashed_without_snapshots` runs `candler run`, reads the stored manifest, finds no `snapshots` key, and recomputes the cell digest with `Digest::of_canonical` to equal the run key. Bite: `build` forced to `Some([])` makes it fail on the key. Oracle: `cell_digest.toml` has 7 vectors; the six that carry `snapshots` (`invented-1` with `[]`, back to its first body and digest) keep their digests, `invented-4` is the key-less shape. No existing manifest's digest moves, so the version marker stays `run-manifest/1` (the digest doc comment requires a new tag only when an existing manifest's digest changes). The experiment path `snapshots` is removed too (row below). | | `inspect` callers gate (htn-creator-eval@0.5.3) | PASS | Supplied by the lead, not re-run: all 279 `.py`/`.sh` files under the HTN and candler paths were searched for `candler ... inspect`, `"inspect"`, `["catalog"]` and `.get("catalog")`. The one hit, `infrastructure/htn_creator_eval/cli.py:1053`, forwards to the HTN's own trace profiler, not to `candler inspect`. `candler-plugin/` has no `inspect` or `catalog` reference. `_catalog_snapshot.py` reads the HTN's own committed `catalogs/*.json`. No reader of `InspectRun.catalog`, so it was dropped. | | `InspectRun.catalog` and `catalog_of` gone; an old sealed run still reads | PASS | Both deleted. `inspect` reads the manifest only; the stored blob is left in the store and not shown, and no shim reads it. The old manifests read through `RunManifest` (unchanged `snapshots` reader), covered by the golden and import guards in the workspace run. | | `tool-catalog-snapshot/1` gone | PASS | `candler-schemas/src/catalog.rs`, `schema/catalog-snapshot.schema.json`, `tests/it/catalog_fixtures.rs`, `catalog_properties.rs`, the `tests/fixtures/{spec,upstream}` fixtures, the catalog test in `guard_wire_shapes.rs` and `guard_cell_digest.rs`, and `catalog_content_digest.toml` with its generator section. The plan lists `catalog_content_digest.toml` among vectors that stay; the leaf says vectors only `/1` uses go. Only the deleted digest test read it, so it went. | -| README, AGENTS.md, live candler-v1 M6c Goal | PASS | `per-run tool census` in `README.md:7`, `AGENTS.md:8`, and `__roadmap__/candler-v1/.../integrity/README.md:7`; `AGENTS.md` names "a tool census" among the stored states. No page under `docs/` quoted the phrase. Done leaves and reports keep their words. | +| README, AGENTS.md, live candler-v1 M6c Goal | PASS | `per-run tool census` in `README.md:7`, `AGENTS.md:8`, and `__roadmap__/candler-v1/.../integrity/README.md:7`; `README.md:12` no longer lists catalog providers, `CONTRIBUTING.md` drops the `catalog` surface, and `__design__/architecture.md` states a run's tools by the resolved `mcp.*` config, the census and the trace, with `comparable.snapshots` described as the imported old shape; `AGENTS.md` names "a tool census" among the stored states. No page under `docs/` quoted the phrase. Done leaves and reports keep their words. | | Refusal codes only the removed code emitted | PASS | `catalog.*` (6 schemas codes), `runner.catalog_command_failed`, `runner.catalog_timeout`, `runner.catalog_unreadable`, and the three `[internal]` rows of the core `CatalogError`; `docs/contract/codes.toml` and `index.md` regenerated (`CANDLER_BLESS_CONTRACT=1`); the `catalog` surface left `SURFACES`; the two `CatalogError` rows left `__roadmap__/m3-lean-cli/refusal_scope.tsv`, which `guard_refusal_codes` reads as its oracle. | | `cargo fmt --check`, clippy `-D warnings`, `cargo doc -D warnings` | PASS | exit 0 for each on the tip. | -| `cargo nextest run --workspace` | PASS | `Summary [161.761s] 729 tests run: 729 passed (6 slow), 31 skipped`. The 31 skipped are the Docker-gated `container-e2e` tests, which the lead reads from the PR's CI. The first run on the tip failed five (the guard, three pinned-digest tests, and the refusal-scope oracle); each is fixed in the step-2 commit (see Pins retaken). | +| Experiment path `snapshots` | PASS | The row left `CONFIGURATION_PATHS` (48 rows) and `configuration-paths.md`, so resolve refuses it as an unknown path; the four tests that derived it no longer do. HTN check at the tag (`git grep snapshots htn-creator-eval@0.5.3 -- *.toml *.json`, excluding reports and catalogs): no experiment sets it. | +| Evaluator-protocol `snapshots` (`needs`, `context`) | BLOCKED, left for the lead | The HTN check passes (no evaluator declares a `snapshots` need; the only hits are two prose lines in its candler-plugin). But the removal is not safe: `python/candler-evaluator/src/candler_evaluator/plugin.py:119` reads `context["snapshots"]` unconditionally and `loop.py:43` writes `"snapshots": []` into needs, so every plug-in on the published helper would break on a missing key; the import grading step fills `context.snapshots` from the imported cell, so the context digests of `context_digest_runs.toml` and of imported outcomes would move; and the three schema files, `field_classes.toml`, the registry/assemble refusals and the contract page all change. Nothing was changed. | +| `cargo nextest run --workspace` | PASS | `Summary [198.378s] 730 tests run: 730 passed (6 slow), 31 skipped` (729 in round 1). The 31 skipped are the Docker-gated `container-e2e` tests, which the lead reads from the PR's CI. The first run on the tip failed five (the guard, three pinned-digest tests, and the refusal-scope oracle); each is fixed in the step-2 commit (see Pins retaken). | | `container-e2e` green on the PR | BLOCKED | Read from the PR's CI by the lead. | | Step 3 scratch bite | PASS | On a scratch branch from the step-2 tip, `inspect.rs` shows `mcp: BTreeMap::new()`; the guard FAILS: `assertion left == right failed: the declared command is shown: {... "outcomes":[] ...}` at `guard_inspect_mcp_config.rs:57`. Scratch worktree, branch and target dir removed. The fresh verifier is the lead's. | @@ -47,11 +49,11 @@ Four tests pinned digests of cells built by the real planner (`guard_egress_sett - **HTN-side follow-up for the lead to hand on:** htn-creator-eval@0.5.3 keeps grading, but its one test that validates against Candler's `catalog-snapshot.schema.json` now skips. The schema file has to move into the HTN repository (the `/1` marker stays the HTN's own). Nothing in the HTN repo was touched. - Step 3's fresh verifier, and the PR's `container-e2e`: the lead's. -- `__design__/architecture.md` still describes the tool-catalog snapshot and catalog providers (§Wire schema: tool-catalog snapshot and several mentions). The leaf lists no design deliverable, so it was left; it is stale against the code. -- The optional `comparable.snapshots` field (see the deviation) and the importer's write of it. +- The evaluator-protocol `needs.snapshots` and `context.snapshots` (row above). +- **HTN-side follow-up (the coordinator takes it on):** move `catalog-snapshot.schema.json` into htn-creator-eval and un-skip its validation test; it belongs to that repository. ## Compatibility for consumers - `inspect-run/1` consumers: `catalog` is gone and `mcp` (object, path to value) is required. -- `run-manifest/1`: a manifest without `comparable.snapshots` is now valid, and its cell digest differs from the digest the same cell had with `"snapshots": []`. Run keys of new runs therefore differ from old ones for the same experiment. -- The schema line takes a major bump (minor while `0.y.z`). +- `run-manifest/1`: old manifests keep their digests, with `snapshots` absent, empty or listed. A cell Candler makes now carries no `snapshots` key, so the run key of a new run differs from the key the same experiment had before #76 (the empty list is no longer hashed, and `codemode` is filled by an earlier leaf). +- The schema line takes a major bump (minor while `0.y.z`); an experiment or `--set` that names `snapshots` is refused as an unknown path. From cba422103cc1e7214f36dd521aa7e25c5f2dcbc5 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:47:11 +0900 Subject: [PATCH 13/18] fix(importer): keep an empty snapshots list in a raw-ingested cell A stream ingested before snapshots became optional was keyed with an empty list. Raw ingest wrote none, so a second ingest found the held run keyed by another cell and refused it as a conflict. Both importers now write the list, as an imported run's cell carries it. Co-Authored-By: Claude Sonnet 5.5 --- crates/candler-core/src/import/raw.rs | 3 +- crates/candler/tests/it/guard_ingest.rs | 50 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/crates/candler-core/src/import/raw.rs b/crates/candler-core/src/import/raw.rs index 206d386a..ec630bae 100644 --- a/crates/candler-core/src/import/raw.rs +++ b/crates/candler-core/src/import/raw.rs @@ -440,7 +440,7 @@ pub fn find_streams(path: &Path, recognise: &Recogniser) -> Result Result { let manifest_error = |detail: String| RawIngestError::Manifest { stream: found.rel.to_string(), @@ -454,6 +454,7 @@ fn comparable_of(found: &Found) -> Result { found.recognised.version.clone(), )) .treatment(TreatmentRef::new(treatment)) + .snapshots(Vec::new()) .build() .map_err(|e| manifest_error(e.to_string())) } diff --git a/crates/candler/tests/it/guard_ingest.rs b/crates/candler/tests/it/guard_ingest.rs index 93d42b04..8ecaf8bc 100644 --- a/crates/candler/tests/it/guard_ingest.rs +++ b/crates/candler/tests/it/guard_ingest.rs @@ -221,6 +221,56 @@ fn i1_each_stream_becomes_one_run() { assert_eq!(seen, expected); } +/// Guards: a raw-ingested cell is keyed as it was before the cell's `snapshots` became optional: +/// it carries an empty list, and its run key names the digest of the cell written with that list. +/// Without it a stream ingested earlier would find its held run keyed by another cell. +/// +/// Oracle: the sha256 of the cell text written by hand, with the sorted keys and `"snapshots":[]`, +/// computed with `Digest::of_bytes`; the harness and treatment members are copied from the stored +/// manifest. +/// +/// Bite: leave `.snapshots(vec![])` out of the raw cell (the key vanishes and the key's cell +/// digest differs). +#[test] +fn i1_a_raw_cell_keeps_the_digest_it_had_with_an_empty_snapshots_list() { + let dir = TempDir::new().expect("a directory"); + let traces = fixture_directory(dir.path()); + let store = Store::init(&dir.path().join("store")).expect("a store"); + ingest_raw(&store, &traces, &recognise, readers().as_ref()).expect("the ingest runs"); + for (name, manifest) in manifests(&dir.path().join("store")) { + let cell = &manifest["comparable"]; + assert_eq!( + cell["snapshots"], + json!([]), + "{name}: the empty list is kept" + ); + let text = format!( + "{{\"environments\":[],\"harness\":{},\"inputs\":[],\"snapshots\":[],\"treatment\":{},\"values\":[]}}", + canonical(&cell["harness"]), + canonical(&cell["treatment"]), + ); + let expected = candler_schemas::primitives::Digest::of_bytes(text.as_bytes()); + assert_eq!( + manifest["run"]["cell"].as_str(), + Some(expected.as_str()), + "{name}: the run key names the old cell digest" + ); + } +} + +/// A JSON object as compact text with its keys in code point order, as the members of a +/// canonical cell are written. +fn canonical(value: &Value) -> String { + let object = value.as_object().expect("an object"); + let mut keys: Vec<&String> = object.keys().collect(); + keys.sort(); + let members: Vec = keys + .iter() + .map(|key| format!("{}:{}", Value::from((*key).as_str()), object[*key])) + .collect(); + format!("{{{}}}", members.join(",")) +} + /// Guards: I1, I17 — no field of a stored manifest or tree, and no source path, starts with `/` or /// holds the temporary directory's text. /// Oracle: the temporary directory's own path, which the test created, and the rule that a stored From 61ca70ef051d04d63502cee385b1685fbbf21ae4 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:47:11 +0900 Subject: [PATCH 14/18] refactor(orchestrator): drop snapshots from the typed roots of a cell An experiment that names snapshots is refused at resolve, as the new guard shows, so no run Candler makes holds a source for that root. Co-Authored-By: Claude Sonnet 5.5 --- .../src/jobs/orchestrate/session.rs | 4 +-- crates/candler/tests/it/guard_cli_refusal.rs | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/candler-core/src/jobs/orchestrate/session.rs b/crates/candler-core/src/jobs/orchestrate/session.rs index 9e18a705..1d44e9d1 100644 --- a/crates/candler-core/src/jobs/orchestrate/session.rs +++ b/crates/candler-core/src/jobs/orchestrate/session.rs @@ -46,11 +46,11 @@ use crate::runner::{JobGateway, Runtime}; use crate::supervise::{EventSink, Supervisor}; use candler_schemas::execution::paths::{ ENVIRONMENTS, HARNESS, INPUTS, ISOLATION_EGRESS, ISOLATION_IMAGE, ISOLATION_RECORD_PACKAGES, - MODEL_ENDPOINT, MODEL_TOKEN_SECRET, REQUEST_TREATMENT, RUNNER_IDLE_S, SNAPSHOTS, TREATMENT, + MODEL_ENDPOINT, MODEL_TOKEN_SECRET, REQUEST_TREATMENT, RUNNER_IDLE_S, TREATMENT, }; /// The roots of a cell that hold typed records; their sources are not value paths. -const TYPED_ROOTS: [&str; 5] = [HARNESS, TREATMENT, SNAPSHOTS, INPUTS, ENVIRONMENTS]; +const TYPED_ROOTS: [&str; 4] = [HARNESS, TREATMENT, INPUTS, ENVIRONMENTS]; /// The tag the gateway's sidecar image is looked up by. pub(super) const SIDECAR_TAG: &str = "candler-gateway:latest"; diff --git a/crates/candler/tests/it/guard_cli_refusal.rs b/crates/candler/tests/it/guard_cli_refusal.rs index aabffae1..329cc9fa 100644 --- a/crates/candler/tests/it/guard_cli_refusal.rs +++ b/crates/candler/tests/it/guard_cli_refusal.rs @@ -904,3 +904,31 @@ fn r2_a_bad_equivalence_file_is_refused_with_its_code() { "{text}" ); } + +/// Guards: an experiment that sets `snapshots` is refused at resolve as an unknown path, as `--set` +/// and as a `[fixed]` value, so no run Candler makes can carry the list. +/// +/// Oracle: the code `experiment.unknown_path` and the path text `snapshots`, written by hand. +/// +/// Bite: put the `snapshots` row back in `CONFIGURATION_PATHS` (the experiment is accepted). +#[test] +fn r3_an_experiment_cannot_set_snapshots() { + let world = cli_run::world(); + let out = world.launch_with(&["--set", "snapshots=[]"]); + let record = record_of(&out); + assert_eq!(record["code"], "experiment.unknown_path", "{record}"); + let message = record["message"].as_str().expect("a message"); + assert!(message.contains("`snapshots`"), "{message}"); + + let world = cli_run::world(); + add_to_fixed(&world, "snapshots = []"); + let record = record_of(&world.launch_with(&[])); + assert_eq!(record["code"], "experiment.unknown_path", "{record}"); + assert!( + record["message"] + .as_str() + .expect("a message") + .contains("`snapshots`"), + "{record}" + ); +} From c62a436ceed1701d6de761552a5794e4d5c34461 Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:47:13 +0900 Subject: [PATCH 15/18] fix(schemas): say who writes snapshots and drop the unused path constant The cell's snapshots key is absent for a run Candler made and present, possibly empty, only for an imported run. The evaluator protocol's needs.snapshots and context.snapshots are always empty for runs Candler makes; they are kept so a released helper and stored grading contexts stay valid, and go once a helper that treats them as optional is out. Co-Authored-By: Claude Sonnet 5.5 --- .../schema/evaluator-describe-result.schema.json | 2 +- .../schema/evaluator-evaluate-params.schema.json | 2 +- .../schema/evaluator-message.schema.json | 4 ++-- .../schema/evaluator-request-side.schema.json | 2 +- .../candler-schemas/schema/run-manifest.schema.json | 4 ++-- crates/candler-schemas/src/evaluation.rs | 8 ++++++-- crates/candler-schemas/src/execution.rs | 11 ++++++----- crates/candler-schemas/src/execution/paths.rs | 4 ---- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/candler-schemas/schema/evaluator-describe-result.schema.json b/crates/candler-schemas/schema/evaluator-describe-result.schema.json index 7fb7de4f..3c82c676 100644 --- a/crates/candler-schemas/schema/evaluator-describe-result.schema.json +++ b/crates/candler-schemas/schema/evaluator-describe-result.schema.json @@ -175,7 +175,7 @@ "type": "array" }, "snapshots": { - "description": "The kinds of snapshot the check reads.", + "description": "The kinds of snapshot the check reads. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released.", "items": { "$ref": "#/$defs/Name" }, diff --git a/crates/candler-schemas/schema/evaluator-evaluate-params.schema.json b/crates/candler-schemas/schema/evaluator-evaluate-params.schema.json index ae786a73..bdc7d3e4 100644 --- a/crates/candler-schemas/schema/evaluator-evaluate-params.schema.json +++ b/crates/candler-schemas/schema/evaluator-evaluate-params.schema.json @@ -658,7 +658,7 @@ "description": "The key of the run." }, "snapshots": { - "description": "The snapshots the run was made against.", + "description": "The snapshots the run was made against. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released.", "items": { "$ref": "#/$defs/ContextRef" }, diff --git a/crates/candler-schemas/schema/evaluator-message.schema.json b/crates/candler-schemas/schema/evaluator-message.schema.json index 37a96551..2c18715e 100644 --- a/crates/candler-schemas/schema/evaluator-message.schema.json +++ b/crates/candler-schemas/schema/evaluator-message.schema.json @@ -525,7 +525,7 @@ "type": "array" }, "snapshots": { - "description": "The kinds of snapshot the check reads.", + "description": "The kinds of snapshot the check reads. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released.", "items": { "$ref": "#/$defs/Name" }, @@ -1207,7 +1207,7 @@ "description": "The key of the run." }, "snapshots": { - "description": "The snapshots the run was made against.", + "description": "The snapshots the run was made against. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released.", "items": { "$ref": "#/$defs/ContextRef" }, diff --git a/crates/candler-schemas/schema/evaluator-request-side.schema.json b/crates/candler-schemas/schema/evaluator-request-side.schema.json index b83f7761..95c070d3 100644 --- a/crates/candler-schemas/schema/evaluator-request-side.schema.json +++ b/crates/candler-schemas/schema/evaluator-request-side.schema.json @@ -780,7 +780,7 @@ "description": "The key of the run." }, "snapshots": { - "description": "The snapshots the run was made against.", + "description": "The snapshots the run was made against. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released.", "items": { "$ref": "#/$defs/ContextRef" }, diff --git a/crates/candler-schemas/schema/run-manifest.schema.json b/crates/candler-schemas/schema/run-manifest.schema.json index ba1f6d34..02704072 100644 --- a/crates/candler-schemas/schema/run-manifest.schema.json +++ b/crates/candler-schemas/schema/run-manifest.schema.json @@ -26,7 +26,7 @@ }, "snapshots": { "$comment": "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not.", - "description": "The digests of the catalog snapshots an imported run recorded, sorted by kind and digest.\nOnly the importer writes it. A cell without the key hashes without it; a cell with the key,\neven an empty list, hashes with it.", + "description": "The digests of the catalog snapshots an imported run recorded, sorted by kind and digest.\nThe key is absent for a run Candler made. It is present, possibly empty, only for an\nimported run: the manifest importer and the raw-stream importer write it, and the cell\nhashes with it when present and without it when absent.", "items": { "$ref": "#/$defs/DigestRef" }, @@ -742,7 +742,7 @@ "type": "array" }, "sources": { - "$comment": "Each path of `comparable.values` has exactly one entry, and each of `harness`, `treatment` and the non-empty lists `snapshots`, `inputs` and `environments` has an entry at the root path or at a path under it; no other path appears and no path repeats. JSON Schema cannot state this, and the Rust reader refuses a list that differs.", + "$comment": "Each path of `comparable.values` has exactly one entry, and each of `harness`, `treatment` and the non-empty lists `snapshots` (present only in an imported run), `inputs` and `environments` has an entry at the root path or at a path under it; no other path appears and no path repeats. JSON Schema cannot state this, and the Rust reader refuses a list that differs.", "description": "Where each value came from: one entry per value, and one or more entries under each typed root the cell holds; never an entry for a setting.", "items": { "$ref": "#/$defs/SourceEntry" diff --git a/crates/candler-schemas/src/evaluation.rs b/crates/candler-schemas/src/evaluation.rs index 5ce0b9e5..609dfe2f 100644 --- a/crates/candler-schemas/src/evaluation.rs +++ b/crates/candler-schemas/src/evaluation.rs @@ -1342,7 +1342,9 @@ pub struct Needs { pub trace: bool, /// Globs, relative to the run, of the artifacts the check reads. pub artifacts: Vec, - /// The kinds of snapshot the check reads. + /// The kinds of snapshot the check reads. Always empty for a run Candler made; the field is + /// kept so a released helper and stored grading contexts stay valid, and it is removed once a + /// helper that treats it as optional is released. pub snapshots: Vec, /// The kinds of input the check reads. pub inputs: Vec, @@ -1611,7 +1613,9 @@ struct RawRunContext { raw: Vec, /// The artifacts of the run. artifacts: Vec, - /// The snapshots the run was made against. + /// The snapshots the run was made against. Always empty for a run Candler made; the field is + /// kept so a released helper and stored grading contexts stay valid, and it is removed once a + /// helper that treats it as optional is released. snapshots: Vec, /// The inputs the run was made from. inputs: Vec, diff --git a/crates/candler-schemas/src/execution.rs b/crates/candler-schemas/src/execution.rs index dd8e41b7..9b4f11bf 100644 --- a/crates/candler-schemas/src/execution.rs +++ b/crates/candler-schemas/src/execution.rs @@ -1936,8 +1936,9 @@ struct RawComparable { /// The treatment the run applied. treatment: TreatmentRef, /// The digests of the catalog snapshots an imported run recorded, sorted by kind and digest. - /// Only the importer writes it. A cell without the key hashes without it; a cell with the key, - /// even an empty list, hashes with it. + /// The key is absent for a run Candler made. It is present, possibly empty, only for an + /// imported run: the manifest importer and the raw-stream importer write it, and the cell + /// hashes with it when present and without it when absent. #[serde(default, deserialize_with = "present")] #[schemars(extend( "$comment" = "Sorted by kind then digest in code point order, without a repeated entry; the Rust reader refuses a list that is not." @@ -2061,8 +2062,8 @@ impl Comparable { /// Builds a cell from resolved values. /// - /// The path `harness` fills the harness, `treatment` the treatment, `snapshots` the snapshot - /// digests, `inputs` the input digests and `environments` the plug-in environments; each + /// The path `harness` fills the harness, `treatment` the treatment, `snapshots` the catalog + /// digests of an imported run (no run Candler makes sets it), `inputs` the input digests and `environments` the plug-in environments; each /// takes one value, read as the typed field reads. Every other path goes to `values`, and a /// path below one of the five roots is refused. A settings path is not a value and never /// reaches this function. @@ -2602,7 +2603,7 @@ struct RawRunManifest { comparable: Comparable, /// Where each value came from: one entry per value, and one or more entries under each typed root the cell holds; never an entry for a setting. #[schemars(extend( - "$comment" = "Each path of `comparable.values` has exactly one entry, and each of `harness`, `treatment` and the non-empty lists `snapshots`, `inputs` and `environments` has an entry at the root path or at a path under it; no other path appears and no path repeats. JSON Schema cannot state this, and the Rust reader refuses a list that differs." + "$comment" = "Each path of `comparable.values` has exactly one entry, and each of `harness`, `treatment` and the non-empty lists `snapshots` (present only in an imported run), `inputs` and `environments` has an entry at the root path or at a path under it; no other path appears and no path repeats. JSON Schema cannot state this, and the Rust reader refuses a list that differs." ))] sources: Vec, /// The secrets the run needed and whether each was present; never their values. diff --git a/crates/candler-schemas/src/execution/paths.rs b/crates/candler-schemas/src/execution/paths.rs index 8d496736..f437663f 100644 --- a/crates/candler-schemas/src/execution/paths.rs +++ b/crates/candler-schemas/src/execution/paths.rs @@ -130,9 +130,6 @@ pub const TREATMENT: &str = "treatment"; /// A typed root, derived: the digests of the server sources and the Dockerfile. pub const INPUTS: &str = "inputs"; -/// A typed root, derived: the catalog digest. -pub const SNAPSHOTS: &str = "snapshots"; - /// A typed root, reserved for plug-in environments: no preflight step of the runner derives it. pub const ENVIRONMENTS: &str = "environments"; @@ -192,7 +189,6 @@ const _: () = { assert!(crate::primitives::is_field_path(SECRETS)); assert!(crate::primitives::is_field_path(TREATMENT)); assert!(crate::primitives::is_field_path(INPUTS)); - assert!(crate::primitives::is_field_path(SNAPSHOTS)); assert!(crate::primitives::is_field_path(ENVIRONMENTS)); assert!(crate::primitives::is_field_path(STORE_ROOT)); assert!(crate::primitives::is_field_path(PLUGINS_DIRS)); From 43c1fa72fc856d4ff5633e9a423a5f2ad84d2c6f Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:47:38 +0900 Subject: [PATCH 16/18] fix(evaluator-helper): read the context's snapshots as optional Co-Authored-By: Claude Sonnet 5.5 --- .../_models/evaluator_describe_result.py | 7 +++-- .../_models/evaluator_evaluate_params.py | 7 +++-- .../_models/evaluator_message.py | 12 +++++-- .../_models/evaluator_request_side.py | 7 +++-- .../src/candler_evaluator/plugin.py | 2 +- .../tests/test_guard_context.py | 31 +++++++++++++++++++ 6 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 python/candler-evaluator/tests/test_guard_context.py diff --git a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_describe_result.py b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_describe_result.py index 445206cc..14143aee 100644 --- a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_describe_result.py +++ b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_describe_result.py @@ -1,6 +1,6 @@ # Generated by scripts/gen_models.py; do not edit. # schema: crates/candler-schemas/schema/evaluator-describe-result.schema.json -# sha256: 944c2b2a1603e7e0d340c4914553db596ee1a5d289c1440dcdb1364f3748c7ad +# sha256: 0e839d32e2e777f818b2f4641e89cb75e4541b0ddc9124592bbb2882b8122829 from __future__ import annotations @@ -103,7 +103,10 @@ class Needs(BaseModel): Field(description="The paths of the metadata fields the check reads."), ] snapshots: Annotated[ - list[Name], Field(description="The kinds of snapshot the check reads.") + list[Name], + Field( + description="The kinds of snapshot the check reads. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released." + ), ] trace: Annotated[ bool, Field(description="Whether the check reads the normalised trace.") diff --git a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_evaluate_params.py b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_evaluate_params.py index 5f951d0b..93968be2 100644 --- a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_evaluate_params.py +++ b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_evaluate_params.py @@ -1,6 +1,6 @@ # Generated by scripts/gen_models.py; do not edit. # schema: crates/candler-schemas/schema/evaluator-evaluate-params.schema.json -# sha256: 74741ff467b74fe48ec1e457317de2866959f8820da61c8a74046a43100a82cd +# sha256: ecc2ca822aec9e321b7acc64ccca9c5598c7decba42595875d939126dfabaca4 from __future__ import annotations @@ -592,7 +592,10 @@ class RunContext(BaseModel): ] run: Annotated[RunKey, Field(description="The key of the run.")] snapshots: Annotated[ - list[ContextRef], Field(description="The snapshots the run was made against.") + list[ContextRef], + Field( + description="The snapshots the run was made against. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released." + ), ] trace: Annotated[ str | None, diff --git a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_message.py b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_message.py index 0f4de727..f7da0485 100644 --- a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_message.py +++ b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_message.py @@ -1,6 +1,6 @@ # Generated by scripts/gen_models.py; do not edit. # schema: crates/candler-schemas/schema/evaluator-message.schema.json -# sha256: 53f9174db72fdd0dd28796f8b124acdbb3d19aeafd165f41f2f414e9420304a5 +# sha256: 068864918640e9ca9e683cb70df83141236e53b60454ee375ba64bc0b340684c from __future__ import annotations @@ -177,7 +177,10 @@ class Needs(BaseModel): Field(description="The paths of the metadata fields the check reads."), ] snapshots: Annotated[ - list[Name], Field(description="The kinds of snapshot the check reads.") + list[Name], + Field( + description="The kinds of snapshot the check reads. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released." + ), ] trace: Annotated[ bool, Field(description="Whether the check reads the normalised trace.") @@ -805,7 +808,10 @@ class RunContext(BaseModel): ] run: Annotated[RunKey, Field(description="The key of the run.")] snapshots: Annotated[ - list[ContextRef], Field(description="The snapshots the run was made against.") + list[ContextRef], + Field( + description="The snapshots the run was made against. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released." + ), ] trace: Annotated[ str | None, diff --git a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_request_side.py b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_request_side.py index acf1bea2..3ae1fbc5 100644 --- a/python/candler-evaluator/src/candler_evaluator/_models/evaluator_request_side.py +++ b/python/candler-evaluator/src/candler_evaluator/_models/evaluator_request_side.py @@ -1,6 +1,6 @@ # Generated by scripts/gen_models.py; do not edit. # schema: crates/candler-schemas/schema/evaluator-request-side.schema.json -# sha256: 1ed95c08d0b1c1aab3d8affbd7db773d21925d4d5046985ca91c4c770b137729 +# sha256: 0f621f5ddac76a745cc1a3946d9a7d55b90e638f93f9ec13a7694771f70b3501 from __future__ import annotations @@ -631,7 +631,10 @@ class RunContext(BaseModel): ] run: Annotated[RunKey, Field(description="The key of the run.")] snapshots: Annotated[ - list[ContextRef], Field(description="The snapshots the run was made against.") + list[ContextRef], + Field( + description="The snapshots the run was made against. Always empty for a run Candler made; the field is\nkept so a released helper and stored grading contexts stay valid, and it is removed once a\nhelper that treats it as optional is released." + ), ] trace: Annotated[ str | None, diff --git a/python/candler-evaluator/src/candler_evaluator/plugin.py b/python/candler-evaluator/src/candler_evaluator/plugin.py index a6e93af2..1225bc09 100644 --- a/python/candler-evaluator/src/candler_evaluator/plugin.py +++ b/python/candler-evaluator/src/candler_evaluator/plugin.py @@ -116,7 +116,7 @@ def from_wire(cls, context: Mapping[str, Any], scratch: str) -> RunContext: raw=tuple(context["raw"]), trace=None if trace is None else Path(trace), artifact_files=files, - snapshots=tuple(context["snapshots"]), + snapshots=tuple(context.get("snapshots", [])), inputs=tuple(context["inputs"]), ) diff --git a/python/candler-evaluator/tests/test_guard_context.py b/python/candler-evaluator/tests/test_guard_context.py new file mode 100644 index 00000000..105e8dd2 --- /dev/null +++ b/python/candler-evaluator/tests/test_guard_context.py @@ -0,0 +1,31 @@ +from candler_evaluator.plugin import RunContext + +CELL = "sha256:" + "ab" * 32 + + +def wire_context(): + return { + "run": {"cell": CELL, "replicate": 1, "attempt": 1}, + "root": "/runs/r1", + "raw": [], + "artifacts": [], + "inputs": [], + "metadata": {}, + } + + +def test_a_context_without_snapshots_is_accepted(): + """Guards: the helper reads `snapshots` as optional, so a context that omits the key builds. + + Oracle: the context is written by hand with every member of the wire but `snapshots`. + Bite: read `context["snapshots"]` again and this raises KeyError. + """ + context = RunContext.from_wire(wire_context(), "/scratch") + assert context.snapshots == () + + +def test_a_context_with_snapshots_keeps_them(): + wire = wire_context() + wire["snapshots"] = [{"kind": "catalog", "path": "/s/c", "digest": CELL}] + context = RunContext.from_wire(wire, "/scratch") + assert [entry["kind"] for entry in context.snapshots] == ["catalog"] From f8fe8980b9505377fdabfd275683947d07f88b5e Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:47:48 +0900 Subject: [PATCH 17/18] docs(readme): say the evaluator snapshots are always empty Co-Authored-By: Claude Sonnet 5.5 --- __design__/architecture.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/__design__/architecture.md b/__design__/architecture.md index 6c53e9c1..95a62328 100644 --- a/__design__/architecture.md +++ b/__design__/architecture.md @@ -1041,6 +1041,10 @@ the evaluators see never enters the isolation, I8); `metadata` (the declared man evaluator runs (host or container) and exist only in requests. `scratch` is the evaluator's; the run store is read-only to it. +`needs.snapshots` and `context.snapshots` are always empty for runs Candler makes. They are kept so +the released helper and stored grading contexts stay valid, and they go once a helper that treats +them as optional is released. + **Digests of a request.** Both are `sha256` over RFC 8785 JSON, so any language recomputes them. - `context_digest` covers the projection `{artifacts: [{path, sha256}], snapshots: [{kind, From 1793b64102fbf9385223d3edb9b1d8842b078d2f Mon Sep 17 00:00:00 2001 From: Eliott Jacopin Date: Wed, 25 Nov 2026 05:47:48 +0900 Subject: [PATCH 18/18] reports(api): record the third round on the snapshot removal Co-Authored-By: Claude Sonnet 5.5 --- __reports__/diet/leaves/snapshot_out_v0.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/__reports__/diet/leaves/snapshot_out_v0.md b/__reports__/diet/leaves/snapshot_out_v0.md index b4a3125f..c3ea9282 100644 --- a/__reports__/diet/leaves/snapshot_out_v0.md +++ b/__reports__/diet/leaves/snapshot_out_v0.md @@ -57,3 +57,11 @@ Four tests pinned digests of cells built by the real planner (`guard_egress_sett - `inspect-run/1` consumers: `catalog` is gone and `mcp` (object, path to value) is required. - `run-manifest/1`: old manifests keep their digests, with `snapshots` absent, empty or listed. A cell Candler makes now carries no `snapshots` key, so the run key of a new run differs from the key the same experiment had before #76 (the empty list is no longer hashed, and `codemode` is filled by an earlier leaf). - The schema line takes a major bump (minor while `0.y.z`); an experiment or `--set` that names `snapshots` is refused as an unknown path. + +## Review (round 3) + +1. **Raw-ingest key.** `import/raw.rs` `comparable_of` now writes `.snapshots(Vec::new())`, as the manifest importer does; the field's doc comment names both importers. Test `i1_a_raw_cell_keeps_the_digest_it_had_with_an_empty_snapshots_list` rebuilds the pre-#76 cell text by hand (sorted keys, `"snapshots":[]`), hashes it with `Digest::of_bytes`, and requires the stored run key to name that digest. On the round-2 tip (before the fix) it FAILED: `the empty list is kept: left Null, right Array []`. On the fixed tip it passes. +2. **Refusal proven.** `r3_an_experiment_cannot_set_snapshots` asserts code `experiment.unknown_path` and the path text for `--set snapshots=[]` and for a `[fixed]` value. `SNAPSHOTS` left `TYPED_ROOTS` and `candler-schemas` `paths.rs` (no importer used the constant; they write the literal path). +3. **Wording.** `execution.rs` (field doc, `from_resolved` doc, the sources `$comment`) and the generated `run-manifest.schema.json` say the key is absent for a run Candler made and present, possibly empty, only for an imported run. +4. **Helper.** `RunContext.from_wire` reads `context.get("snapshots", [])`. `tests/test_guard_context.py::test_a_context_without_snapshots_is_accepted` FAILED before (`KeyError: 'snapshots'`) and passes after; run as CI does (`uv run --frozen pytest -q`: 12 passed; `ruff check`, `ruff format --check` clean). The wire models were regenerated for the new schema descriptions. `loop.py`'s `"snapshots": []` is the helper's `needs` output, which the wire still requires, so it stays. +5. **What the field is now.** The `needs.snapshots` and `context.snapshots` descriptions in `evaluation.rs` (and the four generated evaluator schemas) and the evaluator-protocol section of `__design__/architecture.md` say: always empty for runs Candler makes; kept so the released helper and stored grading contexts stay valid; removed once a helper that treats it as optional is released. No valid record became invalid.