From efcf0c21fbae7dcd8ebbf162da5eedcd6c1ab819 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Thu, 26 Nov 2026 20:21:51 +0200 Subject: [PATCH 01/20] feat(analytics): move six analytics reads to project-scoped canonical paths, keeping their operation ids The six project analytics reads (under /api/v1/projects/{project_id}/analytics: summary, pricing-catalog and the four dashboards) take the operation ids they had on their old paths. The six old analytics-path entries are removed from the contract as a reviewed breaking change, acknowledged in the breaking-change allowlist; the backend retires them. Request, query and response schemas are unchanged. Evaluator promotion is not part of this change. Co-Authored-By: Claude Sonnet 5.5 --- ...ject-analytics-canonical-paths.breaking.md | 1 + scripts/breaking_schema_allowlist.json | 57 +++++ tests/test_analytics_endpoint_contracts.py | 34 ++- .../test_project_analytics_canonical_paths.py | 211 ++++++++++++++++++ .../test_sdk_called_routes_are_contracted.py | 10 +- ..._success_envelope_and_response_coverage.py | 2 +- .../analytics/analytics_endpoints.json | 93 ++++++-- 7 files changed, 382 insertions(+), 26 deletions(-) create mode 100644 changelog.d/project-analytics-canonical-paths.breaking.md create mode 100644 tests/test_project_analytics_canonical_paths.py diff --git a/changelog.d/project-analytics-canonical-paths.breaking.md b/changelog.d/project-analytics-canonical-paths.breaking.md new file mode 100644 index 00000000..29fc6620 --- /dev/null +++ b/changelog.d/project-analytics-canonical-paths.breaking.md @@ -0,0 +1 @@ +- **Six project analytics reads move to project-scoped canonical paths (pre-release, acknowledged).** `GET /api/v1/projects/{project_id}/analytics/{summary, pricing-catalog, dashboards/optimization-overview, dashboards/evaluator-quality, dashboards/project-usage, dashboards/observability-summary}` now name the project in the path and keep the operation ids they had on the old `/api/v1/analytics/...` paths, whose entries are removed. Request, query and response schemas are unchanged. The `/api/v1beta/projects/{project_id}/analytics/...` operations are unchanged. diff --git a/scripts/breaking_schema_allowlist.json b/scripts/breaking_schema_allowlist.json index f5a0c785..e30feb91 100644 --- a/scripts/breaking_schema_allowlist.json +++ b/scripts/breaking_schema_allowlist.json @@ -11344,6 +11344,63 @@ "reason": "BREAKING PUBLIC CHANGE (pre-release). The configuration-run operations move to the canonical project paths and the old flat paths are removed: GET/POST /api/v1/configuration-runs/runs/{experiment_run_id}/configurations become GET/POST /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/configuration-runs; GET/PUT/DELETE /api/v1/configuration-runs/{config_run_id} become GET/PUT/DELETE /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}; the status, summary-stats, workflow-metadata and cancel sub-routes move under that same path; PUT .../measures becomes PUT .../measurement and its operation id configuration_run.update_configuration_run_measures becomes configuration_run.update_configuration_run_measurement. Request and response bodies are unchanged; project_id and the opaque references come from the path. Consumers: the Python SDK and the Backend, updated in the same release.", "version": "Unreleased", "pr": "https://github.com/Traigent/TraigentSchema/pull/773" + }, + { + "file": "analytics/analytics_endpoints.json", + "rule": "endpoint_removed", + "findings": [ + { + "pointer": "#/paths//api/v1/analytics/dashboards/evaluator-quality/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "866c40e17965dac7d2e2a9aa00352ea714f70137c5f5f930dc676b8e8f062ed3" + }, + { + "pointer": "#/paths//api/v1/analytics/dashboards/observability-summary/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "9bc5eba22e8d07ae9646bb6f8ca59d40da50919c76886adcdee5aee87d195200" + }, + { + "pointer": "#/paths//api/v1/analytics/dashboards/optimization-overview/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "0bba9078a499a69542fa31dfe6b403b587d225df198d3f8f10f72a244c8e9aa9" + }, + { + "pointer": "#/paths//api/v1/analytics/dashboards/project-usage/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "9903b127744606f04f5b5ae5b4fa073a6e340ea17f611fd7f83bc0a8b2ff6b69" + }, + { + "pointer": "#/paths//api/v1/analytics/pricing-catalog/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "73cc4072147dea36181c7434c10516537d12b03ea3df1a54611fc34415a05421" + }, + { + "pointer": "#/paths//api/v1/analytics/summary/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "25ef9d36aacecf4b878b57383b41e19317f138032ce0ef0eb65ce5aa51c150bd" + } + ], + "reason": "Route moved to its project-scoped canonical path with the same operation id; the backend retires the old path with a closed 404.", + "version": "Unreleased", + "pr": "Traigent/TraigentSchema#TBD" } ] } diff --git a/tests/test_analytics_endpoint_contracts.py b/tests/test_analytics_endpoint_contracts.py index 3ff42259..cd375080 100644 --- a/tests/test_analytics_endpoint_contracts.py +++ b/tests/test_analytics_endpoint_contracts.py @@ -45,10 +45,28 @@ "get_project_export_job": "/export-jobs/{job_id}", } +# The first six reads moved to the project-scoped canonical path on the "analytics" family and +# kept their operation ids; the other five stay under the original mount. +MOVED_TO_PROJECT_PATH = { + "get_project_analytics_summary", + "get_project_pricing_catalog", + "get_project_optimization_overview_dashboard", + "get_project_evaluator_quality_dashboard", + "get_project_usage_dashboard", + "get_project_observability_summary_dashboard", +} +PROJECT_PREFIX = "/api/v1/projects/{project_id}/analytics" + + +def _path(family: str, suffix: str) -> str: + prefix = PROJECT_PREFIX if family == "analytics" and suffix in MOVED_TO_PROJECT_PATH else FAMILIES[family] + return prefix + SUFFIXES[suffix] + + EXPECTED = sorted( - ("get", prefix + url, f"{family}.{suffix}") - for family, prefix in FAMILIES.items() - for suffix, url in SUFFIXES.items() + ("get", _path(family, suffix), f"{family}.{suffix}") + for family in FAMILIES + for suffix in SUFFIXES ) # suffix -> response schema (envelope) stem @@ -107,7 +125,7 @@ def _load(rel: str) -> dict: def _operation(family: str, suffix: str) -> dict: - return CATALOG["paths"][FAMILIES[family] + SUFFIXES[suffix]]["get"] + return CATALOG["paths"][_path(family, suffix)]["get"] def _all_cases(): @@ -162,16 +180,16 @@ def test_path_and_query_parameters_match_the_backend_query_models(family, suffix params = op["parameters"] path_names = {p["name"] for p in params if p["in"] == "path"} expected_path = set(PATH_PARAMS.get(suffix, set())) - if family == "project_analytics": + if "{project_id}" in _path(family, suffix): expected_path.add("project_id") assert path_names == expected_path assert all(p["required"] is True for p in params if p["in"] == "path") - assert ("{project_id}" in FAMILIES[family] + SUFFIXES[suffix]) == ( - family == "project_analytics" + assert ("{project_id}" in _path(family, suffix)) == ( + family == "project_analytics" or suffix in MOVED_TO_PROJECT_PATH and family == "analytics" ) for p in params: if p["in"] == "path": - assert f"{{{p['name']}}}" in FAMILIES[family] + SUFFIXES[suffix] + assert f"{{{p['name']}}}" in _path(family, suffix) queries = {p["name"]: p for p in params if p["in"] == "query"} for name, (lo, hi, default) in BOUNDS.get(suffix, {}).items(): diff --git a/tests/test_project_analytics_canonical_paths.py b/tests/test_project_analytics_canonical_paths.py new file mode 100644 index 00000000..00be2739 --- /dev/null +++ b/tests/test_project_analytics_canonical_paths.py @@ -0,0 +1,211 @@ +# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Traigent-Commercial +# Copyright (c) 2024-2026 Traigent Ltd. Dual-licensed: AGPL-3.0 or commercial. +"""The six project analytics reads sit on project-scoped paths and keep their operation ids.""" + +from __future__ import annotations + +import json + +import pytest + +from traigent_schema.utils import get_schemas_dir + +CATALOG = json.loads( + (get_schemas_dir() / "analytics" / "analytics_endpoints.json").read_text(encoding="utf-8") +) +PATHS = CATALOG["paths"] +PROJECT_SUFFIXES = { + "summary": "get_project_analytics_summary", + "pricing-catalog": "get_project_pricing_catalog", + "dashboards/optimization-overview": "get_project_optimization_overview_dashboard", + "dashboards/evaluator-quality": "get_project_evaluator_quality_dashboard", + "dashboards/project-usage": "get_project_usage_dashboard", + "dashboards/observability-summary": "get_project_observability_summary_dashboard", +} +PROJECT_OPS = [ + ( + f"/api/v1/analytics/{s}", + f"/api/v1/projects/{{project_id}}/analytics/{s}", + "get", + f"analytics.{n}", + ) + for s, n in PROJECT_SUFFIXES.items() +] +ALL_OPS = PROJECT_OPS + + +def _non_path(op: dict) -> list: + return [p for p in op.get("parameters", []) if p["in"] != "path"] + + +def _query(name: str, description: str, maximum: int, default: int) -> dict: + return { + "name": name, + "in": "query", + "required": False, + "description": description, + "schema": {"type": "integer", "minimum": 1, "maximum": maximum, "default": default}, + } + + +DAYS = _query("days", "Look-back window in days.", 3660, 30) +LIMIT = _query("limit", "Maximum number of ranked rows in the dashboard.", 25, 5) +_C = "#/components/responses/" +_ANALYTICS_429 = { + "description": "Too many requests: rate limit exceeded.", + "content": {"application/json": {"schema": {"$ref": "../rate_limit_info_schema.json"}}}, +} + + +def _ok(description: str, schema_ref: str) -> dict: + return { + "description": description, + "content": {"application/json": {"schema": {"$ref": schema_ref}}}, + } + + +def _analytics_responses(ok: dict, *, with_422: bool) -> dict: + out = { + "200": ok, + "401": {"$ref": _C + "AnalyticsUnauthenticated"}, + "403": {"$ref": _C + "AnalyticsForbidden"}, + "404": {"$ref": _C + "AnalyticsProjectNotFound"}, + } + if with_422: + out["422"] = {"$ref": _C + "AnalyticsValidationFailed"} + out["429"] = _ANALYTICS_429 + out["500"] = {"$ref": _C + "AnalyticsInternalError"} + return out + + +_BODY_SUFFIX = ( + " The body is the success envelope {success, message, data} with the payload under data." +) +# Exact non-path parameters, request body and responses of the six reads. +EXPECTED = {} +_P = "/api/v1/projects/{project_id}/analytics/" +EXPECTED[_P + "summary"] = { + "non_path": [DAYS], + "requestBody": None, + "responses": _analytics_responses( + _ok( + "Analytics summary retrieved successfully." + _BODY_SUFFIX, + "./project_analytics_summary_response_schema.json", + ), + with_422=True, + ), +} +EXPECTED[_P + "pricing-catalog"] = { + "non_path": [], + "requestBody": None, + "responses": _analytics_responses( + _ok( + "Pricing catalog retrieved successfully." + _BODY_SUFFIX, + "./project_pricing_catalog_response_schema.json", + ), + with_422=False, + ), +} +for _s, _label, _ref in [ + ( + "optimization-overview", + "Optimization overview dashboard", + "./optimization_overview_dashboard_response_schema.json", + ), + ( + "evaluator-quality", + "Evaluator quality dashboard", + "./project_evaluator_quality_dashboard_response_schema.json", + ), + ("project-usage", "Project usage dashboard", "./project_usage_dashboard_response_schema.json"), + ( + "observability-summary", + "Observability summary dashboard", + "./project_observability_summary_dashboard_response_schema.json", + ), +]: + EXPECTED[f"{_P}dashboards/{_s}"] = { + "non_path": [DAYS, LIMIT], + "requestBody": None, + "responses": _analytics_responses( + _ok(f"{_label} retrieved successfully." + _BODY_SUFFIX, _ref), with_422=True + ), + } + + +@pytest.mark.parametrize("legacy,canonical,method,op_id", ALL_OPS) +def test_canonical_path_exists_with_only_that_method(legacy, canonical, method, op_id): + assert list(PATHS[canonical]) == [method] + assert PATHS[canonical][method]["operationId"] == op_id + + +@pytest.mark.parametrize("legacy,canonical,method,op_id", ALL_OPS) +def test_non_path_parameters_request_body_and_responses_are_exact(legacy, canonical, method, op_id): + op = PATHS[canonical][method] + expected = EXPECTED[canonical] + assert _non_path(op) == expected["non_path"] + assert op.get("requestBody") == expected["requestBody"] + assert op["responses"] == expected["responses"] + assert {p["name"] for p in op["parameters"] if p["in"] == "path"} == {"project_id"} + assert len(op["parameters"]) == len(expected["non_path"]) + 1 + + +def test_expected_table_covers_exactly_the_six_ops(): + assert set(EXPECTED) == {canonical for _, canonical, _, _ in ALL_OPS} + + +@pytest.mark.parametrize("legacy,canonical,method,op_id", ALL_OPS) +def test_project_id_parameter(legacy, canonical, method, op_id): + params = {p["name"]: p for p in PATHS[canonical][method]["parameters"] if p["in"] == "path"} + pid = params["project_id"] + assert pid["required"] is True + assert pid["schema"] == {"type": "string", "minLength": 1, "maxLength": 128} + + +@pytest.mark.parametrize("legacy,canonical,method,op_id", ALL_OPS) +def test_canonical_op_is_not_deprecated_and_has_no_replacement_text( + legacy, canonical, method, op_id +): + op = PATHS[canonical][method] + assert "deprecated" not in op + assert "DEPRECATED" not in op["description"] + assert "requestBody" in op or method == "get" + assert "200" in op["responses"] or "201" in op["responses"] + + +@pytest.mark.parametrize("legacy,canonical,method,op_id", PROJECT_OPS) +def test_project_ops_declare_project_not_found(legacy, canonical, method, op_id): + responses = PATHS[canonical][method]["responses"] + assert responses["404"] == {"$ref": "#/components/responses/AnalyticsProjectNotFound"} + + +@pytest.mark.parametrize("legacy,canonical,method,op_id", ALL_OPS) +def test_legacy_path_is_absent(legacy, canonical, method, op_id): + assert legacy not in PATHS + + +def test_no_legacy_analytics_paths_reappear(): + legacy_exact = {legacy for legacy, _, _, _ in PROJECT_OPS} + for path in PATHS: + assert path not in legacy_exact + + +def test_exactly_these_six_ids_sit_on_the_canonical_paths(): + for _, canonical, method, op_id in ALL_OPS: + assert PATHS[canonical][method]["operationId"] == op_id + assert len(ALL_OPS) == 6 + assert len({op_id for *_, op_id in ALL_OPS}) == 6 + + +def test_operation_ids_are_unique(): + ids = [ + op["operationId"] for item in PATHS.values() for op in item.values() if "operationId" in op + ] + assert len(ids) == len(set(ids)) + + +def test_beta_project_mount_is_untouched(): + for suffix, name in PROJECT_SUFFIXES.items(): + op = PATHS[f"/api/v1beta/projects/{{project_id}}/analytics/{suffix}"]["get"] + assert op["operationId"] == f"project_analytics.{name}" + assert "deprecated" not in op diff --git a/tests/test_sdk_called_routes_are_contracted.py b/tests/test_sdk_called_routes_are_contracted.py index c459db57..2de6ed05 100644 --- a/tests/test_sdk_called_routes_are_contracted.py +++ b/tests/test_sdk_called_routes_are_contracted.py @@ -2,7 +2,7 @@ # Copyright (c) 2024-2026 Traigent Ltd. Dual-licensed: AGPL-3.0 or commercial. """Routes the published SDKs call must be declared in a catalog they validate against. -`GET /api/v1/analytics/dashboards/optimization-overview` is called by the Python +`GET /api/v1/projects/{project_id}/analytics/dashboards/optimization-overview` is called by the Python SDK (`traigent/cloud/analytics_client.py`) and the JS SDK (`src/core-metrics/index.ts`, `src/analytics/analytics-client.ts`), and is served by the backend's `analytics_bp` under `/api/v1`. Only the project-scoped @@ -28,13 +28,13 @@ # (contract, method, concrete path as an SDK sends it) SDK_CALLED_ROUTES = [ - ("backend", "GET", "/api/v1/analytics/dashboards/optimization-overview"), + ("backend", "GET", "/api/v1/projects/p1/analytics/dashboards/optimization-overview"), # Controls: neighbouring analytics routes the same SDK clients call. ("backend", "GET", "/api/v1/analytics/runs/r1/pareto"), ("backend", "GET", "/api/v1/analytics/runs/r1/leaderboard"), ] -V1_OVERVIEW = "/api/v1/analytics/dashboards/optimization-overview" +V1_OVERVIEW = "/api/v1/projects/{project_id}/analytics/dashboards/optimization-overview" V1BETA_OVERVIEW = "/api/v1beta/projects/{project_id}/analytics/dashboards/optimization-overview" @@ -108,7 +108,9 @@ def test_v1_overview_declares_the_query_bounds_the_backend_enforces() -> None: "maximum": 25, "default": 5, } - assert all(not p["required"] for p in parameters.values()) + assert parameters["project_id"]["in"] == "path" + assert parameters["project_id"]["required"] is True + assert all(not p["required"] for name, p in parameters.items() if name != "project_id") def test_v1beta_overview_entry_keeps_its_identity_and_payload() -> None: diff --git a/tests/test_success_envelope_and_response_coverage.py b/tests/test_success_envelope_and_response_coverage.py index f1c189ce..c8be9260 100644 --- a/tests/test_success_envelope_and_response_coverage.py +++ b/tests/test_success_envelope_and_response_coverage.py @@ -381,7 +381,7 @@ def test_example_set_read_responses_nest_pagination_under_data(): # ---- #591 review: the analytics dashboard 200 must describe the WIRE body ---- -_OVERVIEW_V1 = "/api/v1/analytics/dashboards/optimization-overview" +_OVERVIEW_V1 = "/api/v1/projects/{project_id}/analytics/dashboards/optimization-overview" _OVERVIEW_V1BETA = ( "/api/v1beta/projects/{project_id}/analytics/dashboards/optimization-overview" ) diff --git a/traigent_schema/schemas/analytics/analytics_endpoints.json b/traigent_schema/schemas/analytics/analytics_endpoints.json index 453ccc55..5877f09a 100644 --- a/traigent_schema/schemas/analytics/analytics_endpoints.json +++ b/traigent_schema/schemas/analytics/analytics_endpoints.json @@ -1058,12 +1058,23 @@ } } }, - "/api/v1/analytics/summary": { + "/api/v1/projects/{project_id}/analytics/summary": { "get": { "summary": "Get the project analytics summary", - "description": "Aggregate entity counts, status breakdowns, usage and measure summaries for the active project over a look-back window. Read access to experiments and project role viewer or above. The project is resolved in order: credential-bound project, then the X-Project-Id header, then the tenant default.", + "description": "Aggregate entity counts, status breakdowns, usage and measure summaries for the active project over a look-back window. Read access to experiments and project role viewer or above.", "operationId": "analytics.get_project_analytics_summary", "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "Project identifier.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, { "name": "days", "in": "query", @@ -1116,12 +1127,24 @@ } } }, - "/api/v1/analytics/pricing-catalog": { + "/api/v1/projects/{project_id}/analytics/pricing-catalog": { "get": { "summary": "Get the project pricing catalog", - "description": "The static model pricing catalog available to the active project. Takes no query parameters. Read access to experiments and project role viewer or above. The project is resolved in order: credential-bound project, then the X-Project-Id header, then the tenant default.", + "description": "The static model pricing catalog available to the active project. Takes no query parameters. Read access to experiments and project role viewer or above.", "operationId": "analytics.get_project_pricing_catalog", - "parameters": [], + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "Project identifier.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + } + ], "responses": { "200": { "description": "Pricing catalog retrieved successfully. The body is the success envelope {success, message, data} with the payload under data.", @@ -1158,12 +1181,23 @@ } } }, - "/api/v1/analytics/dashboards/optimization-overview": { + "/api/v1/projects/{project_id}/analytics/dashboards/optimization-overview": { "get": { "summary": "Get the optimization overview dashboard", - "description": "Prebuilt optimization overview dashboard for the active project: summary cards, cost source breakdown and the most recent experiments. Read access to experiments and project role viewer or above. The project is resolved in order: credential-bound project, then the X-Project-Id header, then the tenant default.", + "description": "Prebuilt optimization overview dashboard for the active project: summary cards, cost source breakdown and the most recent experiments. Read access to experiments and project role viewer or above.", "operationId": "analytics.get_project_optimization_overview_dashboard", "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "Project identifier.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, { "name": "days", "in": "query", @@ -1228,12 +1262,23 @@ } } }, - "/api/v1/analytics/dashboards/evaluator-quality": { + "/api/v1/projects/{project_id}/analytics/dashboards/evaluator-quality": { "get": { "summary": "Get the evaluator quality dashboard", - "description": "Prebuilt evaluator quality dashboard for the active project. Read access to experiments and project role viewer or above. The project is resolved in order: credential-bound project, then the X-Project-Id header, then the tenant default.", + "description": "Prebuilt evaluator quality dashboard for the active project. Read access to experiments and project role viewer or above.", "operationId": "analytics.get_project_evaluator_quality_dashboard", "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "Project identifier.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, { "name": "days", "in": "query", @@ -1298,12 +1343,23 @@ } } }, - "/api/v1/analytics/dashboards/project-usage": { + "/api/v1/projects/{project_id}/analytics/dashboards/project-usage": { "get": { "summary": "Get the project usage dashboard", - "description": "Prebuilt usage dashboard for the active project. Read access to experiments and project role viewer or above. The project is resolved in order: credential-bound project, then the X-Project-Id header, then the tenant default.", + "description": "Prebuilt usage dashboard for the active project. Read access to experiments and project role viewer or above.", "operationId": "analytics.get_project_usage_dashboard", "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "Project identifier.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, { "name": "days", "in": "query", @@ -1368,12 +1424,23 @@ } } }, - "/api/v1/analytics/dashboards/observability-summary": { + "/api/v1/projects/{project_id}/analytics/dashboards/observability-summary": { "get": { "summary": "Get the observability summary dashboard", - "description": "Observability summary dashboard for the active project, built from trace metadata (identifiers, names, cost and token counts). A read, plus a required durable admission audit record: an API key needs the explicit observability read grant in addition to the ordinary read permission, and the project role must be viewer or above. The project is resolved in order: credential-bound project, then the X-Project-Id header, then the tenant default.", + "description": "Observability summary dashboard for the active project, built from trace metadata (identifiers, names, cost and token counts). A read, plus a required durable admission audit record: an API key needs the explicit observability read grant in addition to the ordinary read permission, and the project role must be viewer or above.", "operationId": "analytics.get_project_observability_summary_dashboard", "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "Project identifier.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, { "name": "days", "in": "query", From cc2af621a7ed73c05da29551494fd3e50a9eb77b Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Thu, 26 Nov 2026 21:01:40 +0200 Subject: [PATCH 02/20] feat(contracts): canonical project paths for datasets and the metric contract Adds canonical /api/v1/projects/{project_id}/... paths for 16 dataset and dataset-version operations, reusing their request, response and error bodies, with the backend operation ids as operationIds; the old unscoped paths are marked deprecated and name their successor. Tenant-level lookups stay unscoped. Adds the metric contract: project-scoped list and create, tenant-library list and create, and get, update (PATCH) and delete by an opaque metric_ref. Write bodies are closed and exclude evaluator fields (422 on violation). The legacy measure list, get, delete and default-provisioning routes are deprecated; the evaluator-capable legacy writes stay until the evaluator contract lands. Spine-Trail: st_1804d64b88c6 Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Opus 5.5 --- tests/test_content_identity_endpoints.py | 17 +- tests/test_datasets_contract.py | 82 ++ tests/test_metric_contract.py | 90 ++ tests/test_rate_limit_429_catalog_coverage.py | 25 + .../datasets/content_identity_endpoints.json | 207 +++++ .../schemas/datasets/datasets_endpoints.json | 849 ++++++++++++++++++ .../schemas/measures/measures_endpoints.json | 516 +++++++++++ .../schemas/measures/metric_schema.json | 118 +++ .../metric_update_request_schema.json | 87 ++ .../measures/metric_write_request_schema.json | 90 ++ 10 files changed, 2080 insertions(+), 1 deletion(-) create mode 100644 tests/test_metric_contract.py create mode 100644 traigent_schema/schemas/measures/metric_schema.json create mode 100644 traigent_schema/schemas/measures/metric_update_request_schema.json create mode 100644 traigent_schema/schemas/measures/metric_write_request_schema.json diff --git a/tests/test_content_identity_endpoints.py b/tests/test_content_identity_endpoints.py index d1ae9ed1..9f5efe42 100644 --- a/tests/test_content_identity_endpoints.py +++ b/tests/test_content_identity_endpoints.py @@ -197,21 +197,36 @@ def test_catalog_is_registered_in_the_backend_contract_root() -> None: assert "./datasets/content_identity_endpoints.json" in files -def test_catalog_declares_exactly_the_four_routes_ahead_of_the_backend() -> None: +def test_catalog_declares_exactly_the_routes_ahead_of_the_backend() -> None: operations = { (path, method): op for path, methods in CATALOG["paths"].items() for method, op in methods.items() } + scoped = "/api/v1/projects/{project_id}/datasets/{dataset_id}" + scoped_identity = (scoped + "/versions/{version_id}/content-identity", "get") + scoped_benchmark = (scoped + "/public-benchmark", "put") assert set(operations) == { (PURPOSE_KEYS, "post"), (IDENTITY, "get"), (BY_ROOT, "get"), (PUBLIC_BENCHMARK, "put"), + scoped_identity, + scoped_benchmark, } for key, op in operations.items(): assert op["x-asserted-against-backend"] is False, key assert op["operationId"], key + # Both forms resolve; the unscoped pair is deprecated and keeps its operationIds. + assert operations[scoped_identity]["operationId"] == "dataset_version.get_dataset_version_content_identity" + assert operations[scoped_benchmark]["operationId"] == "dataset_version.set_dataset_public_benchmark" + assert operations[(IDENTITY, "get")]["operationId"] == "getDatasetVersionContentIdentity" + assert operations[(PUBLIC_BENCHMARK, "put")]["operationId"] == "setDatasetPublicBenchmark" + assert operations[(IDENTITY, "get")]["deprecated"] is True + assert operations[(PUBLIC_BENCHMARK, "put")]["deprecated"] is True + # The tenant routes keep their contracts and are not deprecated. + assert "deprecated" not in operations[(PURPOSE_KEYS, "post")] + assert "deprecated" not in operations[(BY_ROOT, "get")] def test_every_catalog_ref_resolves() -> None: diff --git a/tests/test_datasets_contract.py b/tests/test_datasets_contract.py index 21fbafc2..17244b9b 100644 --- a/tests/test_datasets_contract.py +++ b/tests/test_datasets_contract.py @@ -2,6 +2,8 @@ admits the portal's client fields (#135/#123), score/confidence 0-1 unit (#139).""" import json +import pytest + from traigent_schema import SchemaValidator from traigent_schema.utils import get_schemas_dir @@ -202,3 +204,83 @@ def test_standalone_model_parameters_route_binds_its_own_request_schema(): assert v.validate_request( "/api/v1/model-parameters", "POST", {"agentId": "a1", "modelParameters": []} ) + + +# --------------------------------------------------------------------------- +# Project-scoped dataset paths: additive canonical routes, old routes deprecated +# --------------------------------------------------------------------------- + +_SCOPED = "/api/v1/projects/{project_id}/datasets" +# (method, old suffix == new suffix, canonical operationId) +_SCOPED_OPS = [ + ("get", "", "dataset.get_datasets"), + ("post", "", "dataset.create_dataset"), + ("get", "/{dataset_id}", "dataset.get_dataset"), + ("put", "/{dataset_id}", "dataset.update_dataset"), + ("delete", "/{dataset_id}", "dataset.delete_dataset"), + ("get", "/{dataset_id}/examples", "dataset.get_dataset_examples"), + ("post", "/{dataset_id}/examples", "dataset.add_dataset_examples"), + ("put", "/{dataset_id}/examples/{example_id}", "dataset.update_dataset_example"), + ("delete", "/{dataset_id}/examples/{example_id}", "dataset.delete_dataset_example"), + ("post", "/{dataset_id}/generate-examples", "dataset.generate_dataset_examples"), + ("get", "/{dataset_id}/files", "dataset.get_dataset_files"), + ("post", "/{dataset_id}/files", "dataset.upload_dataset_files"), + ("post", "/{dataset_id}/upload", "dataset.upload_dataset_files_post"), + ("delete", "/{dataset_id}/files/{file_id}", "dataset.delete_dataset_file"), + ( + "get", + "/{dataset_id}/versions/{version_id}/content-identity", + "dataset_version.get_dataset_version_content_identity", + ), + ("put", "/{dataset_id}/public-benchmark", "dataset_version.set_dataset_public_benchmark"), +] +_CONTENT_IDENTITY_SUFFIXES = { + "/{dataset_id}/versions/{version_id}/content-identity", + "/{dataset_id}/public-benchmark", +} +_UNSCOPED_STAYS = [ + "/api/v1/datasets/versions/by-root/{dataset_root}", + "/api/v1/content-identity/purpose-keys", + "/api/v1/example-sets", + "/api/v1/example-sets/{set_id}/examples", +] + + +def _scoped_paths(suffix): + name = "content_identity_endpoints.json" if suffix in _CONTENT_IDENTITY_SUFFIXES else "datasets_endpoints.json" + return _load(name)["paths"] + + +@pytest.mark.parametrize("method,suffix,op_id", _SCOPED_OPS) +def test_scoped_dataset_operation_mirrors_the_unscoped_one(method, suffix, op_id): + import re + + paths = _scoped_paths(suffix) + old = paths["/api/v1/datasets" + suffix][method] + new = paths[_SCOPED + suffix][method] + assert new["operationId"] == op_id + assert new["x-asserted-against-backend"] is False + assert "deprecated" not in new + assert old["deprecated"] is True + assert old["x-deprecated"] == f"Use {method.upper()} {_SCOPED}{suffix}. Removal is unscheduled." + assert old["x-deprecated"].endswith("Removal is unscheduled.") + assert new.get("requestBody") == old.get("requestBody") + assert [p["name"] for p in new["parameters"]] == re.findall(r"\{(\w+)\}", _SCOPED + suffix) + assert all(p["in"] == "path" and p["required"] for p in new["parameters"]) + project = new["parameters"][0] + assert project["schema"] == {"type": "string", "minLength": 1, "maxLength": 128} + assert set(new["responses"]) >= set(old["responses"]) + for status, resp in old["responses"].items(): + if status != "429": + assert new["responses"][status] == resp + + +def test_scoped_dataset_operation_ids_are_distinct_and_unscoped_routes_stay(): + ids = [op_id for _, _, op_id in _SCOPED_OPS] + assert len(ids) == len(set(ids)) == 16 + all_paths = {**_scoped_paths(""), **_scoped_paths("/{dataset_id}/public-benchmark")} + for path in _UNSCOPED_STAYS: + for op in all_paths[path].values(): + assert not op.get("deprecated") + assert not any(path.startswith(_SCOPED + "/generate") or "/archive" in path for path in all_paths) + assert not any("/versions" in p and p.startswith(_SCOPED) and "content-identity" not in p for p in all_paths) diff --git a/tests/test_metric_contract.py b/tests/test_metric_contract.py new file mode 100644 index 00000000..584ef555 --- /dev/null +++ b/tests/test_metric_contract.py @@ -0,0 +1,90 @@ +"""Metric endpoints: canonical paths, ref pattern, closed write bodies, measure deprecations.""" + +import json +import re + +import jsonschema +import pytest + +from traigent_schema.utils import get_schemas_dir + +M = get_schemas_dir() / "measures" +PATHS = json.loads((M / "measures_endpoints.json").read_text(encoding="utf-8"))["paths"] +PROJECT = "/api/v1/projects/{project_id}/metrics" +REF = "/api/v1/metrics/{metric_ref}" +EVALUATOR_FIELDS = ("evaluation_method", "criteria", "python_packages", "measure_parameters") + + +def _schema(name): + return json.loads((M / name).read_text(encoding="utf-8")) + + +def test_metric_operations_and_ids(): + got = { + (path, method): op["operationId"] + for path, item in PATHS.items() + if "metrics" in path + for method, op in item.items() + } + assert got == { + (PROJECT, "get"): "metric.list_project_metrics", + (PROJECT, "post"): "metric.create_project_metric", + ("/api/v1/metrics", "get"): "metric.list_library_metrics", + ("/api/v1/metrics", "post"): "metric.create_library_metric", + (REF, "get"): "metric.get_metric", + (REF, "patch"): "metric.update_metric", + (REF, "delete"): "metric.delete_metric", + } + assert "put" not in PATHS[REF] + assert all(op["x-asserted-against-backend"] is False for p in PATHS if "metrics" in p for op in PATHS[p].values()) + + +def test_metric_ref_pattern_matches_the_resolver(): + for op in PATHS[REF].values(): + (param,) = op["parameters"] + assert param["schema"]["pattern"] == "^metric_[0-9a-f]{32}$" + pattern = _schema("metric_schema.json")["properties"]["metric_ref"]["pattern"] + assert re.match(pattern, "metric_" + "a1" * 16) + assert not re.match(pattern, "metric_" + "A1" * 16) + assert not re.match(pattern, "accuracy") + + +@pytest.mark.parametrize("name", ["metric_write_request_schema.json", "metric_update_request_schema.json"]) +@pytest.mark.parametrize("field", EVALUATOR_FIELDS) +def test_write_bodies_reject_evaluator_fields(name, field): + schema = _schema(name) + assert schema["additionalProperties"] is False + assert not set(EVALUATOR_FIELDS) & set(schema["properties"]) + body = {"label": "L", "measure_type": "accuracy", field: []} + errors = list(jsonschema.Draft7Validator({k: v for k, v in schema.items() if k != "$schema"}).iter_errors(body)) + assert errors, field + + +def test_write_bodies_require_what_they_must(): + assert _schema("metric_write_request_schema.json")["required"] == ["label", "measure_type"] + assert _schema("metric_update_request_schema.json")["minProperties"] == 1 + + +def test_every_metric_write_declares_a_422_and_reads_carry_no_evaluator_fields(): + for path, method in [(PROJECT, "post"), ("/api/v1/metrics", "post"), (REF, "patch")]: + assert "422" in PATHS[path][method]["responses"] + assert not set(EVALUATOR_FIELDS) & set(_schema("metric_schema.json")["properties"]) + + +def test_measure_deprecations(): + dep = { + (p, m): op["x-deprecated"] + for p, item in PATHS.items() + if "measures" in p + for m, op in item.items() + if op.get("deprecated") is True + } + assert set(dep) == { + ("/api/v1/measures/default", "post"), + ("/api/v1/measures", "get"), + ("/api/v1/measures/{measure_id}", "get"), + ("/api/v1/measures/{measure_id}", "delete"), + } + # The evaluator-capable legacy writes are kept until the evaluator cutover. + assert "deprecated" not in PATHS["/api/v1/measures"]["post"] + assert "deprecated" not in PATHS["/api/v1/measures/{measure_id}"]["put"] diff --git a/tests/test_rate_limit_429_catalog_coverage.py b/tests/test_rate_limit_429_catalog_coverage.py index a3522c93..37ef354c 100644 --- a/tests/test_rate_limit_429_catalog_coverage.py +++ b/tests/test_rate_limit_429_catalog_coverage.py @@ -94,6 +94,24 @@ ("execution/execution_endpoints.json", "get", "/api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments"), } +# Project-scoped dataset operations whose 429 is one of several bodies (rate limit, quota, legacy +# limiter, shared provider limiter). Declared as an ``anyOf`` of exactly these refs. +_RL = "../rate_limit_info_schema.json" +_QUOTA = "../billing/quota_exceeded_error_schema.json" +ANYOF_429 = { + ("datasets/datasets_endpoints.json", "post", "/api/v1/projects/{project_id}/datasets"): [_RL, _QUOTA], + ( + "datasets/datasets_endpoints.json", + "post", + "/api/v1/projects/{project_id}/datasets/{dataset_id}/generate-examples", + ): [ + _RL, + _QUOTA, + "../auth/auth_rate_limit_response_schema.json", + "../analytics/evaluator_promotion_rate_limit_schema.json", + ], +} + # The v1 envelope, plus the v2 observability API's own error envelope (pre-existing on # POST /api/v2/observability/events; that API family uses one error schema for every 4xx). CANONICAL_429_ENVELOPES = { @@ -162,6 +180,13 @@ def test_fixed_catalogs_429_points_at_the_canonical_rate_limit_envelope(rel: str if (rel, method, path) in PROBLEM_JSON_429: assert op["responses"]["429"] == {"$ref": "#/components/responses/GroupsRateLimited"} continue + if (rel, method, path) in ANYOF_429: + schema = op["responses"]["429"]["content"]["application/json"]["schema"] + assert [s["$ref"] for s in schema["anyOf"]] == ANYOF_429[(rel, method, path)] + assert set(schema) == {"anyOf"} + for r in ANYOF_429[(rel, method, path)]: + assert (SCHEMAS / posixpath.normpath(posixpath.join(posixpath.dirname(rel), r))).is_file() + continue ref = op["responses"]["429"]["content"]["application/json"]["schema"]["$ref"] resolved = posixpath.normpath(posixpath.join(posixpath.dirname(rel), ref)) assert resolved in CANONICAL_429_ENVELOPES, f"{rel} {method} {path}: {ref}" diff --git a/traigent_schema/schemas/datasets/content_identity_endpoints.json b/traigent_schema/schemas/datasets/content_identity_endpoints.json index fefc61da..82f3bd52 100644 --- a/traigent_schema/schemas/datasets/content_identity_endpoints.json +++ b/traigent_schema/schemas/datasets/content_identity_endpoints.json @@ -95,6 +95,8 @@ "/api/v1/datasets/{dataset_id}/versions/{version_id}/content-identity": { "get": { "summary": "Get a hosted dataset version's server-computed content identity", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/projects/{project_id}/datasets/{dataset_id}/versions/{version_id}/content-identity. Removal is unscheduled.", "description": "TraigentBackend src/routes/dataset_version_routes.py get_dataset_version_content_identity. Read access to the dataset (project viewer) through the owner-scoped parent load. Returns the identity under the tenant's ACTIVE key (root, counts, members_ref and the per-example map), re-verified on every read; or status unavailable with a reason. The version object (DatasetVersionV1) is unchanged.", "operationId": "getDatasetVersionContentIdentity", "x-asserted-against-backend": false, @@ -145,6 +147,8 @@ "/api/v1/datasets/{dataset_id}/public-benchmark": { "put": { "summary": "Set or clear the dataset's public-benchmark opt-in (ruling D3)", + "deprecated": true, + "x-deprecated": "Use PUT /api/v1/projects/{project_id}/datasets/{dataset_id}/public-benchmark. Removal is unscheduled.", "description": "TraigentBackend src/routes/dataset_version_routes.py set_dataset_public_benchmark. Requires dataset write access and project editor role, THEN tenant owner/admin (or platform admin) membership; API-key principals are refused even when the key's owner is a tenant admin. A refusal is audited (ACCESS_DENIED, reason tenant_admin_required); a change is audited (DATASET_PUBLIC_BENCHMARK_CHANGED) and not applied if the audit write fails. The Backend also emits the flag as public_benchmark on the dataset read (Benchmark.to_dict); dataset_schema.json is closed and does not declare it yet -- adding it is a separately acknowledged contract change (breaking_schema_check classifies it property_added on a closed schema).", "operationId": "setDatasetPublicBenchmark", "x-asserted-against-backend": false, @@ -168,6 +172,209 @@ "500": {"description": "The change or its audit record could not be written; nothing was applied.", "content": {"application/json": {"schema": {"$ref": "../error_envelope_schema.json"}}}} } } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/versions/{version_id}/content-identity": { + "get": { + "operationId": "dataset_version.get_dataset_version_content_identity", + "summary": "Get a hosted dataset version's server-computed content identity", + "description": "Project-scoped form of GET /api/v1/datasets/{dataset_id}/versions/{version_id}/content-identity. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "x-wrap-status": "wrapped", + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "version_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "The version's content identity (status available) or why there is none (status unavailable). An integrity failure is status unavailable, reason stored_identity_mismatch, never a 5xx with a partial identity.", + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_version_content_identity_response_schema.json" + } + } + } + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Dataset read access or project viewer role denied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Dataset not found in the caller's owner scope, or the version is not a version of that dataset.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/public-benchmark": { + "put": { + "operationId": "dataset_version.set_dataset_public_benchmark", + "summary": "Set or clear the dataset's public-benchmark opt-in (ruling D3)", + "description": "Project-scoped form of PUT /api/v1/datasets/{dataset_id}/public-benchmark. Same request, response and error bodies. Requires dataset write access and the project editor role, then tenant owner or admin membership; API-key principals are refused.", + "x-asserted-against-backend": false, + "x-wrap-status": "wrapped", + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_public_benchmark_request_schema.json" + } + } + } + }, + "responses": { + "200": { + "description": "The flag after the change.", + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_public_benchmark_response_schema.json" + } + } + } + }, + "400": { + "description": "public_benchmark missing or not a boolean.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Dataset write access or project editor role denied, or the caller is not a tenant owner/admin (error_code FORBIDDEN), or the principal is an API key.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Dataset not found in the caller's owner scope.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + }, + "500": { + "description": "The change or its audit record could not be written; nothing was applied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + } + } + } } } } diff --git a/traigent_schema/schemas/datasets/datasets_endpoints.json b/traigent_schema/schemas/datasets/datasets_endpoints.json index 73613e85..341902b0 100644 --- a/traigent_schema/schemas/datasets/datasets_endpoints.json +++ b/traigent_schema/schemas/datasets/datasets_endpoints.json @@ -9,6 +9,8 @@ "/api/v1/datasets": { "get": { "summary": "List datasets", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/projects/{project_id}/datasets. Removal is unscheduled.", "responses": { "200": { "description": "Datasets retrieved successfully" @@ -27,6 +29,8 @@ }, "post": { "summary": "Create dataset", + "deprecated": true, + "x-deprecated": "Use POST /api/v1/projects/{project_id}/datasets. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -47,6 +51,8 @@ "/api/v1/datasets/{dataset_id}": { "get": { "summary": "Get dataset", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/projects/{project_id}/datasets/{dataset_id}. Removal is unscheduled.", "responses": { "200": { "description": "Dataset retrieved successfully", @@ -72,6 +78,8 @@ }, "put": { "summary": "Update dataset", + "deprecated": true, + "x-deprecated": "Use PUT /api/v1/projects/{project_id}/datasets/{dataset_id}. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -100,6 +108,8 @@ }, "delete": { "summary": "Delete dataset", + "deprecated": true, + "x-deprecated": "Use DELETE /api/v1/projects/{project_id}/datasets/{dataset_id}. Removal is unscheduled.", "responses": { "204": { "description": "Dataset deleted successfully" @@ -120,6 +130,8 @@ "/api/v1/datasets/{dataset_id}/examples": { "get": { "summary": "List examples in a dataset", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/projects/{project_id}/datasets/{dataset_id}/examples. Removal is unscheduled.", "responses": { "200": { "description": "Dataset examples retrieved successfully" @@ -138,6 +150,8 @@ }, "post": { "summary": "Add example to a dataset", + "deprecated": true, + "x-deprecated": "Use POST /api/v1/projects/{project_id}/datasets/{dataset_id}/examples. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -281,6 +295,8 @@ "/api/v1/datasets/{dataset_id}/upload": { "post": { "summary": "Upload examples into a dataset", + "deprecated": true, + "x-deprecated": "Use POST /api/v1/projects/{project_id}/datasets/{dataset_id}/upload. Removal is unscheduled.", "responses": { "200": { "description": "Dataset examples uploaded successfully" @@ -301,6 +317,8 @@ "/api/v1/datasets/{dataset_id}/examples/{example_id}": { "delete": { "summary": "Delete example from a dataset", + "deprecated": true, + "x-deprecated": "Use DELETE /api/v1/projects/{project_id}/datasets/{dataset_id}/examples/{example_id}. Removal is unscheduled.", "responses": { "204": { "description": "Dataset example deleted successfully" @@ -319,6 +337,8 @@ }, "put": { "summary": "Update a dataset example", + "deprecated": true, + "x-deprecated": "Use PUT /api/v1/projects/{project_id}/datasets/{dataset_id}/examples/{example_id}. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -376,6 +396,8 @@ "/api/v1/datasets/{dataset_id}/generate-examples": { "post": { "summary": "Generate examples for a dataset (async)", + "deprecated": true, + "x-deprecated": "Use POST /api/v1/projects/{project_id}/datasets/{dataset_id}/generate-examples. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -433,6 +455,8 @@ "/api/v1/datasets/{dataset_id}/files": { "get": { "summary": "List dataset files", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/projects/{project_id}/datasets/{dataset_id}/files. Removal is unscheduled.", "responses": { "200": { "description": "Dataset files.", @@ -468,6 +492,8 @@ }, "post": { "summary": "Add a file to a dataset", + "deprecated": true, + "x-deprecated": "Use POST /api/v1/projects/{project_id}/datasets/{dataset_id}/files. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -527,6 +553,829 @@ "/api/v1/datasets/{dataset_id}/files/{file_id}": { "delete": { "summary": "Delete a dataset file", + "deprecated": true, + "x-deprecated": "Use DELETE /api/v1/projects/{project_id}/datasets/{dataset_id}/files/{file_id}. Removal is unscheduled.", + "responses": { + "200": { + "description": "File deleted." + }, + "404": { + "description": "File not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets": { + "get": { + "operationId": "dataset.get_datasets", + "summary": "List datasets", + "description": "Project-scoped form of GET /api/v1/datasets. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + } + ], + "responses": { + "200": { + "description": "Datasets retrieved successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "post": { + "operationId": "dataset.create_dataset", + "summary": "Create dataset", + "description": "Project-scoped form of POST /api/v1/datasets. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_create_request_schema.json" + } + } + } + }, + "responses": { + "201": { + "description": "Dataset created successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "../rate_limit_info_schema.json" + }, + { + "$ref": "../billing/quota_exceeded_error_schema.json" + } + ] + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}": { + "get": { + "operationId": "dataset.get_dataset", + "summary": "Get dataset", + "description": "Project-scoped form of GET /api/v1/datasets/{dataset_id}. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Dataset retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_detail_response_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "put": { + "operationId": "dataset.update_dataset", + "summary": "Update dataset", + "description": "Project-scoped form of PUT /api/v1/datasets/{dataset_id}. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_update_request_schema.json" + } + } + } + }, + "responses": { + "200": { + "description": "Dataset updated successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "delete": { + "operationId": "dataset.delete_dataset", + "summary": "Delete dataset", + "description": "Project-scoped form of DELETE /api/v1/datasets/{dataset_id}. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "204": { + "description": "Dataset deleted successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/examples": { + "get": { + "operationId": "dataset.get_dataset_examples", + "summary": "List examples in a dataset", + "description": "Project-scoped form of GET /api/v1/datasets/{dataset_id}/examples. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Dataset examples retrieved successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "post": { + "operationId": "dataset.add_dataset_examples", + "summary": "Add example to a dataset", + "description": "Project-scoped form of POST /api/v1/datasets/{dataset_id}/examples. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + }, + "responses": { + "201": { + "description": "Dataset example created successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/examples/{example_id}": { + "put": { + "operationId": "dataset.update_dataset_example", + "summary": "Update a dataset example", + "description": "Project-scoped form of PUT /api/v1/datasets/{dataset_id}/examples/{example_id}. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "example_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./evaluation_set_schema.json#/definitions/EvaluationSetExample" + } + } + } + }, + "responses": { + "200": { + "description": "Example updated.", + "content": { + "application/json": { + "schema": { + "$ref": "./evaluation_set_schema.json#/definitions/EvaluationSetExample" + } + } + } + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Example not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "delete": { + "operationId": "dataset.delete_dataset_example", + "summary": "Delete example from a dataset", + "description": "Project-scoped form of DELETE /api/v1/datasets/{dataset_id}/examples/{example_id}. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "example_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "204": { + "description": "Dataset example deleted successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/generate-examples": { + "post": { + "operationId": "dataset.generate_dataset_examples", + "summary": "Generate examples for a dataset (async)", + "description": "Project-scoped form of POST /api/v1/datasets/{dataset_id}/generate-examples. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_generate_examples_request_schema.json" + } + } + } + }, + "responses": { + "202": { + "description": "Generation job accepted.", + "content": { + "application/json": { + "schema": { + "$ref": "./generation_job_response_schema.json" + } + } + } + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Dataset not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "../rate_limit_info_schema.json" + }, + { + "$ref": "../billing/quota_exceeded_error_schema.json" + }, + { + "$ref": "../auth/auth_rate_limit_response_schema.json" + }, + { + "$ref": "../analytics/evaluator_promotion_rate_limit_schema.json" + } + ] + } + } + } + }, + "500": { + "description": "Internal server error.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/files": { + "get": { + "operationId": "dataset.get_dataset_files", + "summary": "List dataset files", + "description": "Project-scoped form of GET /api/v1/datasets/{dataset_id}/files. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Dataset files.", + "content": { + "application/json": { + "schema": { + "$ref": "./dataset_files_response_schema.json" + } + } + } + }, + "404": { + "description": "Dataset not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "post": { + "operationId": "dataset.upload_dataset_files", + "summary": "Add a file to a dataset", + "description": "Project-scoped form of POST /api/v1/datasets/{dataset_id}/files. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": true, + "description": "File metadata / upload payload." + } + } + } + }, + "responses": { + "201": { + "description": "File added.", + "content": { + "application/json": { + "schema": { + "$ref": "./evaluation_set_schema.json#/definitions/EvaluationSetFile" + } + } + } + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Dataset not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/upload": { + "post": { + "operationId": "dataset.upload_dataset_files_post", + "summary": "Upload examples into a dataset", + "description": "Project-scoped form of POST /api/v1/datasets/{dataset_id}/upload. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], + "responses": { + "200": { + "description": "Dataset examples uploaded successfully" + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/datasets/{dataset_id}/files/{file_id}": { + "delete": { + "operationId": "dataset.delete_dataset_file", + "summary": "Delete a dataset file", + "description": "Project-scoped form of DELETE /api/v1/datasets/{dataset_id}/files/{file_id}. Same request, response and error bodies. The server binds project_id from the URL and checks that the dataset belongs to that project.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "dataset_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + }, + { + "name": "file_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1 + } + } + ], "responses": { "200": { "description": "File deleted." diff --git a/traigent_schema/schemas/measures/measures_endpoints.json b/traigent_schema/schemas/measures/measures_endpoints.json index 7dbbe20a..6f034250 100644 --- a/traigent_schema/schemas/measures/measures_endpoints.json +++ b/traigent_schema/schemas/measures/measures_endpoints.json @@ -9,6 +9,8 @@ "/api/v1/measures/default": { "post": { "summary": "Create a default measure", + "deprecated": true, + "x-deprecated": "Retired; there is no public replacement. Removal is unscheduled.", "requestBody": { "required": true, "content": { @@ -40,6 +42,8 @@ "/api/v1/measures": { "get": { "summary": "List measures", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/projects/{project_id}/metrics or GET /api/v1/metrics. Removal is unscheduled.", "parameters": [ { "name": "has_evaluator", @@ -97,6 +101,8 @@ "/api/v1/measures/{measure_id}": { "get": { "summary": "Get measure", + "deprecated": true, + "x-deprecated": "Use GET /api/v1/metrics/{metric_ref}. Removal is unscheduled.", "responses": { "200": { "description": "Measure retrieved successfully", @@ -150,6 +156,8 @@ }, "delete": { "summary": "Delete measure", + "deprecated": true, + "x-deprecated": "Use DELETE /api/v1/metrics/{metric_ref}. Removal is unscheduled.", "responses": { "204": { "description": "Measure deleted successfully" @@ -166,6 +174,514 @@ } } } + }, + "/api/v1/projects/{project_id}/metrics": { + "get": { + "operationId": "metric.list_project_metrics", + "summary": "List the project's metrics", + "description": "Lists the metrics visible in the project: project-owned, tenant-shared and built-in. Each item carries its scope.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + } + ], + "responses": { + "200": { + "description": "Metrics retrieved successfully" + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Project viewer role denied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Project not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "post": { + "operationId": "metric.create_project_metric", + "summary": "Create a project-owned metric", + "description": "Creates a metric owned by the project. Requires the project editor role.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./metric_write_request_schema.json" + } + } + } + }, + "responses": { + "201": { + "description": "Metric created successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./metric_schema.json" + } + } + } + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Project editor role denied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Project not found.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "422": { + "description": "Validation failed (error_code validation_failed). A write that carries evaluation_method, criteria, python_packages, measure_parameters or any other undeclared field is refused; the body names no keys or values.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/metrics": { + "get": { + "operationId": "metric.list_library_metrics", + "summary": "List the tenant metric library", + "description": "Lists the tenant-shared and built-in metrics.", + "x-asserted-against-backend": false, + "responses": { + "200": { + "description": "Metrics retrieved successfully" + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Access denied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "post": { + "operationId": "metric.create_library_metric", + "summary": "Create a tenant-shared metric", + "description": "Creates a metric in the tenant library. Requires tenant-library authority (tenant admin).", + "x-asserted-against-backend": false, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./metric_write_request_schema.json" + } + } + } + }, + "responses": { + "201": { + "description": "Metric created successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./metric_schema.json" + } + } + } + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Tenant-library authority required.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "422": { + "description": "Validation failed (error_code validation_failed). A write that carries evaluation_method, criteria, python_packages, measure_parameters or any other undeclared field is refused; the body names no keys or values.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } + }, + "/api/v1/metrics/{metric_ref}": { + "get": { + "operationId": "metric.get_metric", + "summary": "Get a metric", + "description": "The metric_ref is resolved tenant-wide to one row, then authorized on that row. A metric the caller cannot see is answered exactly like a missing one.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "metric_ref", + "in": "path", + "required": true, + "schema": { + "type": "string", + "pattern": "^metric_[0-9a-f]{32}$" + } + } + ], + "responses": { + "200": { + "description": "Metric retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./metric_schema.json" + } + } + } + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Metric not found, or not visible to the caller (the two are indistinguishable).", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "patch": { + "operationId": "metric.update_metric", + "summary": "Update a metric", + "description": "Partial update. Project-owned metrics require the project editor role; tenant-shared metrics require tenant-library authority; built-in metrics are read-only.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "metric_ref", + "in": "path", + "required": true, + "schema": { + "type": "string", + "pattern": "^metric_[0-9a-f]{32}$" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "./metric_update_request_schema.json" + } + } + } + }, + "responses": { + "200": { + "description": "Metric updated successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./metric_schema.json" + } + } + } + }, + "400": { + "description": "Bad request.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Write authority on the metric denied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Metric not found, or not visible to the caller (the two are indistinguishable).", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "422": { + "description": "Validation failed (error_code validation_failed). A write that carries evaluation_method, criteria, python_packages, measure_parameters or any other undeclared field is refused; the body names no keys or values.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, + "delete": { + "operationId": "metric.delete_metric", + "summary": "Delete a metric", + "description": "Same authority as update. Built-in metrics cannot be deleted.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "metric_ref", + "in": "path", + "required": true, + "schema": { + "type": "string", + "pattern": "^metric_[0-9a-f]{32}$" + } + } + ], + "responses": { + "204": { + "description": "Metric deleted successfully" + }, + "401": { + "description": "Unauthenticated.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "403": { + "description": "Write authority on the metric denied.", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "404": { + "description": "Metric not found, or not visible to the caller (the two are indistinguishable).", + "content": { + "application/json": { + "schema": { + "$ref": "../error_envelope_schema.json" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + } } } } diff --git a/traigent_schema/schemas/measures/metric_schema.json b/traigent_schema/schemas/measures/metric_schema.json new file mode 100644 index 00000000..02743446 --- /dev/null +++ b/traigent_schema/schemas/measures/metric_schema.json @@ -0,0 +1,118 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/measures/metric_schema.json", + "title": "Metric", + "description": "A metric definition as returned by the metric endpoints. It reuses the measure definition vocabulary and carries no evaluator fields (evaluation_method, criteria, python_packages, measure_parameters). Two owners' metrics with the same label, and a built-in with that label, are three distinct rows with three distinct metric_ref values.", + "type": "object", + "required": [ + "metric_ref", + "scope", + "label", + "measure_type" + ], + "additionalProperties": false, + "properties": { + "metric_ref": { + "type": "string", + "pattern": "^metric_[0-9a-f]{32}$", + "description": "Opaque reference to exactly one metric row. Never a bare name or id.", + "x-identifier": true + }, + "scope": { + "type": "string", + "enum": [ + "project", + "tenant", + "built_in" + ], + "description": "project: owned by one project. tenant: shared through the tenant library. built_in: shipped by the platform, read-only." + }, + "project_id": { + "type": [ + "string", + "null" + ], + "description": "Owning project for scope project; null otherwise." + }, + "version": { + "type": "string", + "pattern": "^\\d+\\.\\d+\\.\\d+$" + }, + "label": { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "measure_type": { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "description": { + "type": "string", + "maxLength": 5000 + }, + "category": { + "type": "string", + "maxLength": 255 + }, + "value_type": { + "type": "string", + "maxLength": 255 + }, + "categories": { + "type": "array", + "items": { + "type": "string", + "maxLength": 255 + }, + "maxItems": 1000 + }, + "target_aspect": { + "$ref": "./measure_schema.json#/definitions/TargetAspect" + }, + "metric_type": { + "$ref": "./measure_schema.json#/definitions/MetricType" + }, + "output_type": { + "$ref": "./measure_schema.json#/definitions/MetricOutputType" + }, + "target_types": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/TargetType" + } + }, + "allowed_score_sources": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/AllowedScoreSource" + } + }, + "agent_types": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/AgentType" + }, + "minItems": 1 + }, + "domain_min": { + "type": [ + "number", + "null" + ] + }, + "domain_max": { + "type": [ + "number", + "null" + ] + }, + "inverse": { + "type": "boolean" + }, + "is_custom": { + "type": "boolean" + } + } +} diff --git a/traigent_schema/schemas/measures/metric_update_request_schema.json b/traigent_schema/schemas/measures/metric_update_request_schema.json new file mode 100644 index 00000000..6d591fa1 --- /dev/null +++ b/traigent_schema/schemas/measures/metric_update_request_schema.json @@ -0,0 +1,87 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/measures/metric_update_request_schema.json", + "title": "Metric Update Request", + "description": "Body of PATCH /api/v1/metrics/{metric_ref}. Partial update: send only the fields to change, at least one. Closed: the evaluator fields evaluation_method, criteria, python_packages and measure_parameters are rejected with a 422 validation_failed that names no keys or values.", + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "label": { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "measure_type": { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "description": { + "type": "string", + "maxLength": 5000 + }, + "category": { + "type": "string", + "maxLength": 255 + }, + "value_type": { + "type": "string", + "maxLength": 255 + }, + "categories": { + "type": "array", + "items": { + "type": "string", + "maxLength": 255 + }, + "maxItems": 1000 + }, + "target_aspect": { + "$ref": "./measure_schema.json#/definitions/TargetAspect" + }, + "metric_type": { + "$ref": "./measure_schema.json#/definitions/MetricType" + }, + "output_type": { + "$ref": "./measure_schema.json#/definitions/MetricOutputType" + }, + "target_types": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/TargetType" + } + }, + "allowed_score_sources": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/AllowedScoreSource" + } + }, + "agent_types": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/AgentType" + }, + "minItems": 1 + }, + "domain_min": { + "type": [ + "number", + "null" + ] + }, + "domain_max": { + "type": [ + "number", + "null" + ] + }, + "inverse": { + "type": "boolean" + }, + "is_custom": { + "type": "boolean" + } + } +} diff --git a/traigent_schema/schemas/measures/metric_write_request_schema.json b/traigent_schema/schemas/measures/metric_write_request_schema.json new file mode 100644 index 00000000..cda28d6d --- /dev/null +++ b/traigent_schema/schemas/measures/metric_write_request_schema.json @@ -0,0 +1,90 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/measures/metric_write_request_schema.json", + "title": "Metric Create Request", + "description": "Body of POST /api/v1/projects/{project_id}/metrics and POST /api/v1/metrics. A metric is a definition only: the evaluator fields evaluation_method, criteria, python_packages and measure_parameters are not accepted (the schema is closed) and are answered with a 422 validation_failed that names no keys or values. The server generates the metric_ref and decides the scope from the path.", + "type": "object", + "required": [ + "label", + "measure_type" + ], + "additionalProperties": false, + "properties": { + "label": { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "measure_type": { + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "description": { + "type": "string", + "maxLength": 5000 + }, + "category": { + "type": "string", + "maxLength": 255 + }, + "value_type": { + "type": "string", + "maxLength": 255 + }, + "categories": { + "type": "array", + "items": { + "type": "string", + "maxLength": 255 + }, + "maxItems": 1000 + }, + "target_aspect": { + "$ref": "./measure_schema.json#/definitions/TargetAspect" + }, + "metric_type": { + "$ref": "./measure_schema.json#/definitions/MetricType" + }, + "output_type": { + "$ref": "./measure_schema.json#/definitions/MetricOutputType" + }, + "target_types": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/TargetType" + } + }, + "allowed_score_sources": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/AllowedScoreSource" + } + }, + "agent_types": { + "type": "array", + "items": { + "$ref": "./measure_schema.json#/definitions/AgentType" + }, + "minItems": 1 + }, + "domain_min": { + "type": [ + "number", + "null" + ] + }, + "domain_max": { + "type": [ + "number", + "null" + ] + }, + "inverse": { + "type": "boolean" + }, + "is_custom": { + "type": "boolean" + } + } +} From e915c5cf07acfc981bad10c11939d020694f749c Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Thu, 26 Nov 2026 21:34:37 +0200 Subject: [PATCH 03/20] fix(contracts): metric responses project the backend row; closed list, 422 and 404 bodies; fragment refs resolve in the validator The metric response uses the resolver scope values (project, shared, builtin), requires project_id for project-owned rows, carries metric_ref, unit and version, and reports domain and agent_types in the backend shape. Both metric lists declare a collection body bound to the metric schema. The write 422 and the item 404 are closed bodies with fixed codes and messages. Write bodies accept unit and version and no longer accept is_custom. The schema validator resolves file#/pointer references, so the dataset-example update bodies validate. Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Opus 5.5 --- tests/test_datasets_contract.py | 67 ++++++++- tests/test_metric_contract.py | 138 +++++++++++++++++- .../datasets/content_identity_endpoints.json | 4 +- .../schemas/measures/measures_endpoints.json | 60 +++++--- .../measures/metric_list_response_schema.json | 42 ++++++ .../metric_not_found_error_schema.json | 28 ++++ .../schemas/measures/metric_schema.json | 109 +++++++++++--- .../metric_update_request_schema.json | 14 +- ...metric_validation_failed_error_schema.json | 28 ++++ .../measures/metric_write_request_schema.json | 14 +- traigent_schema/validator.py | 30 +++- 11 files changed, 476 insertions(+), 58 deletions(-) create mode 100644 traigent_schema/schemas/measures/metric_list_response_schema.json create mode 100644 traigent_schema/schemas/measures/metric_not_found_error_schema.json create mode 100644 traigent_schema/schemas/measures/metric_validation_failed_error_schema.json diff --git a/tests/test_datasets_contract.py b/tests/test_datasets_contract.py index 17244b9b..b1d7cb2a 100644 --- a/tests/test_datasets_contract.py +++ b/tests/test_datasets_contract.py @@ -275,9 +275,70 @@ def test_scoped_dataset_operation_mirrors_the_unscoped_one(method, suffix, op_id assert new["responses"][status] == resp -def test_scoped_dataset_operation_ids_are_distinct_and_unscoped_routes_stay(): - ids = [op_id for _, _, op_id in _SCOPED_OPS] - assert len(ids) == len(set(ids)) == 16 +_DEFERRED = [ + ("post", "/{dataset_id}/archive"), + ("post", "/{dataset_id}/unarchive"), + ("post", "/generate"), + ("get", "/generation-sessions/{session_id}/status"), + ("get", "/{dataset_id}/versions"), + ("post", "/{dataset_id}/versions"), + ("get", "/{dataset_id}/versions/{version_id}"), + ("get", "/{dataset_id}/versions/{version_id}/snapshot"), +] + + +def _actual_scoped_operations(): + found = [] + for name in ("datasets_endpoints.json", "content_identity_endpoints.json"): + for path, item in _load(name)["paths"].items(): + if path.startswith(_SCOPED): + for method, op in item.items(): + found.append((method, path[len(_SCOPED):], op["operationId"])) + return found + + +def test_scoped_dataset_operation_set_equals_the_spec_and_ids_are_distinct(): + actual = _actual_scoped_operations() + assert len(actual) == len({op_id for _, _, op_id in actual}) + assert sorted(actual) == sorted(_SCOPED_OPS) + assert len(actual) == 16 + + +def test_deferred_dataset_operations_are_all_absent(): + assert len(_DEFERRED) == 8 + actual = {(method, suffix) for method, suffix, _ in _actual_scoped_operations()} + for deferred in _DEFERRED: + assert deferred not in actual, deferred + declared_scoped_paths = { + path + for name in ("datasets_endpoints.json", "content_identity_endpoints.json") + for path in _load(name)["paths"] + if path.startswith(_SCOPED) + } + for _, suffix in _DEFERRED: + assert _SCOPED + suffix not in declared_scoped_paths, suffix + + +_EXAMPLE_ROUTES = [ + ("PUT", "/api/v1/datasets/ds-1/examples/ex-1"), + ("PUT", "/api/v1/projects/p-1/datasets/ds-1/examples/ex-1"), +] + + +@pytest.mark.parametrize("method,route", _EXAMPLE_ROUTES) +def test_example_put_route_validates_through_the_fragment_ref(method, route): + v = SchemaValidator(contract="backend") + template = "/api/v1/projects/{project_id}/datasets/{dataset_id}/examples/{example_id}" + if "projects" not in route: + template = "/api/v1/datasets/{dataset_id}/examples/{example_id}" + assert v._endpoint_schemas[f"{method}:{template}"].endswith("#/definitions/EvaluationSetExample") + valid = {"example_id": "ex-1", "input_text": "What is 2+2?", "expected_output": "4"} + assert v.validate_request(route, method, valid) == [] + errors = v.validate_request(route, method, {"example_id": "ex-1", "score": 5}) + assert errors and not any("Schema not found" in e for e in errors) + + +def test_unscoped_dataset_routes_stay_undeprecated(): all_paths = {**_scoped_paths(""), **_scoped_paths("/{dataset_id}/public-benchmark")} for path in _UNSCOPED_STAYS: for op in all_paths[path].values(): diff --git a/tests/test_metric_contract.py b/tests/test_metric_contract.py index 584ef555..61487fde 100644 --- a/tests/test_metric_contract.py +++ b/tests/test_metric_contract.py @@ -57,7 +57,13 @@ def test_write_bodies_reject_evaluator_fields(name, field): assert not set(EVALUATOR_FIELDS) & set(schema["properties"]) body = {"label": "L", "measure_type": "accuracy", field: []} errors = list(jsonschema.Draft7Validator({k: v for k, v in schema.items() if k != "$schema"}).iter_errors(body)) - assert errors, field + assert [e.validator for e in errors] == ["additionalProperties"], field + assert field in errors[0].message + # The refusal the server renders for it is the one closed 422, bound on all three writes. + for path, method in [(PROJECT, "post"), ("/api/v1/metrics", "post"), (REF, "patch")]: + assert PATHS[path][method]["responses"]["422"]["content"]["application/json"]["schema"]["$ref"] == ( + "./metric_validation_failed_error_schema.json" + ) def test_write_bodies_require_what_they_must(): @@ -88,3 +94,133 @@ def test_measure_deprecations(): # The evaluator-capable legacy writes are kept until the evaluator cutover. assert "deprecated" not in PATHS["/api/v1/measures"]["post"] assert "deprecated" not in PATHS["/api/v1/measures/{measure_id}"]["put"] + + +def _validator(name): + schema = _schema(name) + resolver_store = {s["$id"]: s for s in (_schema(n) for n in M_FILES)} + resolver_store["https://schemas.traigent.ai/pagination_schema.json"] = json.loads( + (get_schemas_dir() / "pagination_schema.json").read_text(encoding="utf-8") + ) + from referencing import Registry, Resource + from referencing.jsonschema import DRAFT7 + + registry = Registry().with_resources( + [(uri, Resource.from_contents(doc, default_specification=DRAFT7)) for uri, doc in resolver_store.items()] + ) + return jsonschema.Draft7Validator(schema, registry=registry) + + +M_FILES = [ + "metric_schema.json", + "metric_list_response_schema.json", + "metric_validation_failed_error_schema.json", + "metric_not_found_error_schema.json", +] +VALIDATION_FAILED = { + "success": False, + "message": "Validation failed", + "error": "validation_failed", + "error_code": "validation_failed", +} +NOT_FOUND = { + "success": False, + "message": "Metric not found", + "error": "not_found", + "error_code": "not_found", +} + + +def _metric(**over): + row = { + "metric_ref": "metric_" + "ab" * 16, + "scope": "project", + "project_id": "p-1", + "label": "Accuracy", + "measure_type": "accuracy", + "unit": None, + "version": "1.0.0", + "domain": [0, 1], + "agent_types": [{"agent_type_id": "a1", "name": "qa", "description": None}], + "is_custom": True, + } + row.update(over) + return row + + +def _errors(name, body): + return list(_validator(name).iter_errors(body)) + + +@pytest.mark.parametrize( + "row", + [ + _metric(), + _metric(scope="shared", project_id=None), + _metric(scope="builtin", project_id=None, unit="ms", agent_types=[], domain=[None, 1e308]), + ], +) +def test_metric_projection_accepts_the_three_scopes(row): + assert not _errors("metric_schema.json", row) + + +@pytest.mark.parametrize( + "row", + [ + _metric(scope="tenant", project_id=None), + _metric(scope="built_in", project_id=None), + _metric(project_id=None), + _metric(scope="shared", project_id="p-1"), + _metric(scope="builtin", project_id="p-1"), + _metric(metric_ref="accuracy"), + ], +) +def test_metric_projection_rejects_bad_scope_project_pairs_and_refs(row): + assert _errors("metric_schema.json", row) + missing = {k: v for k, v in _metric().items() if k != "project_id"} + assert _errors("metric_schema.json", missing) + + +def test_list_bodies_are_bound_and_items_use_the_metric_schema(): + for path, method in [(PROJECT, "get"), ("/api/v1/metrics", "get")]: + ref = PATHS[path][method]["responses"]["200"]["content"]["application/json"]["schema"]["$ref"] + assert ref == "./metric_list_response_schema.json" + page = {"page": 1, "per_page": 20, "total": 1, "total_pages": 1, "has_next": False, "has_prev": False} + body = {"success": True, "message": "ok", "data": {"items": [_metric()], "pagination": page}} + assert not _errors("metric_list_response_schema.json", body) + body["data"]["items"][0]["scope"] = "tenant" + assert _errors("metric_list_response_schema.json", body) + + +def test_write_bodies_carry_unit_and_version_but_not_is_custom(): + for name in ("metric_write_request_schema.json", "metric_update_request_schema.json"): + props = _schema(name)["properties"] + assert {"unit", "version"} <= set(props) + assert "is_custom" not in props + assert _errors(name, {"label": "L", "measure_type": "accuracy", "is_custom": True}) + assert not _errors(name, {"label": "L", "measure_type": "accuracy", "unit": "ms", "version": "1.2.0"}) + + +def _closed_ref(path, method, status): + return PATHS[path][method]["responses"][status]["content"]["application/json"]["schema"]["$ref"] + + +def test_422_on_every_write_is_bound_to_the_closed_validation_error(): + for path, method in [(PROJECT, "post"), ("/api/v1/metrics", "post"), (REF, "patch")]: + assert _closed_ref(path, method, "422") == "./metric_validation_failed_error_schema.json" + name = "metric_validation_failed_error_schema.json" + assert not _errors(name, VALIDATION_FAILED) + assert _errors(name, {**VALIDATION_FAILED, "details": {"label": "secret text"}}) + assert _errors(name, {**VALIDATION_FAILED, "message": "label 'secret' is invalid"}) + assert _errors(name, {**VALIDATION_FAILED, "error_code": "other"}) + assert _errors(name, NOT_FOUND) + + +def test_404_on_every_item_op_is_bound_to_the_closed_not_found_error(): + for method in PATHS[REF]: + assert _closed_ref(REF, method, "404") == "./metric_not_found_error_schema.json" + name = "metric_not_found_error_schema.json" + assert not _errors(name, NOT_FOUND) + assert _errors(name, {**NOT_FOUND, "details": {"metric_ref": "metric_x"}}) + assert _errors(name, {**NOT_FOUND, "message": "Metric metric_x not found"}) + assert _errors(name, VALIDATION_FAILED) diff --git a/traigent_schema/schemas/datasets/content_identity_endpoints.json b/traigent_schema/schemas/datasets/content_identity_endpoints.json index 82f3bd52..3f4c2826 100644 --- a/traigent_schema/schemas/datasets/content_identity_endpoints.json +++ b/traigent_schema/schemas/datasets/content_identity_endpoints.json @@ -146,7 +146,7 @@ }, "/api/v1/datasets/{dataset_id}/public-benchmark": { "put": { - "summary": "Set or clear the dataset's public-benchmark opt-in (ruling D3)", + "summary": "Set or clear the dataset's public-benchmark opt-in", "deprecated": true, "x-deprecated": "Use PUT /api/v1/projects/{project_id}/datasets/{dataset_id}/public-benchmark. Removal is unscheduled.", "description": "TraigentBackend src/routes/dataset_version_routes.py set_dataset_public_benchmark. Requires dataset write access and project editor role, THEN tenant owner/admin (or platform admin) membership; API-key principals are refused even when the key's owner is a tenant admin. A refusal is audited (ACCESS_DENIED, reason tenant_admin_required); a change is audited (DATASET_PUBLIC_BENCHMARK_CHANGED) and not applied if the audit write fails. The Backend also emits the flag as public_benchmark on the dataset read (Benchmark.to_dict); dataset_schema.json is closed and does not declare it yet -- adding it is a separately acknowledged contract change (breaking_schema_check classifies it property_added on a closed schema).", @@ -267,7 +267,7 @@ "/api/v1/projects/{project_id}/datasets/{dataset_id}/public-benchmark": { "put": { "operationId": "dataset_version.set_dataset_public_benchmark", - "summary": "Set or clear the dataset's public-benchmark opt-in (ruling D3)", + "summary": "Set or clear the dataset's public-benchmark opt-in", "description": "Project-scoped form of PUT /api/v1/datasets/{dataset_id}/public-benchmark. Same request, response and error bodies. Requires dataset write access and the project editor role, then tenant owner or admin membership; API-key principals are refused.", "x-asserted-against-backend": false, "x-wrap-status": "wrapped", diff --git a/traigent_schema/schemas/measures/measures_endpoints.json b/traigent_schema/schemas/measures/measures_endpoints.json index 6f034250..52aa47b5 100644 --- a/traigent_schema/schemas/measures/measures_endpoints.json +++ b/traigent_schema/schemas/measures/measures_endpoints.json @@ -27,7 +27,7 @@ "description": "Default measure created successfully" }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -50,7 +50,9 @@ "in": "query", "required": false, "description": "Filter metrics by whether at least one evaluator visible to the caller is attached. A non-boolean value is rejected with a 422 validation error.", - "schema": { "type": "boolean" } + "schema": { + "type": "boolean" + } } ], "responses": { @@ -58,7 +60,7 @@ "description": "Measures retrieved successfully" }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -86,7 +88,7 @@ "description": "Measure created successfully" }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -115,7 +117,7 @@ } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -143,7 +145,7 @@ "description": "Measure updated successfully" }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -163,7 +165,7 @@ "description": "Measure deleted successfully" }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -195,7 +197,14 @@ ], "responses": { "200": { - "description": "Metrics retrieved successfully" + "description": "Metrics retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./metric_list_response_schema.json" + } + } + } }, "401": { "description": "Unauthenticated.", @@ -228,7 +237,7 @@ } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -322,13 +331,13 @@ "content": { "application/json": { "schema": { - "$ref": "../error_envelope_schema.json" + "$ref": "./metric_validation_failed_error_schema.json" } } } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -348,7 +357,14 @@ "x-asserted-against-backend": false, "responses": { "200": { - "description": "Metrics retrieved successfully" + "description": "Metrics retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./metric_list_response_schema.json" + } + } + } }, "401": { "description": "Unauthenticated.", @@ -371,7 +387,7 @@ } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -443,13 +459,13 @@ "content": { "application/json": { "schema": { - "$ref": "../error_envelope_schema.json" + "$ref": "./metric_validation_failed_error_schema.json" } } } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -504,13 +520,13 @@ "content": { "application/json": { "schema": { - "$ref": "../error_envelope_schema.json" + "$ref": "./metric_not_found_error_schema.json" } } } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -593,7 +609,7 @@ "content": { "application/json": { "schema": { - "$ref": "../error_envelope_schema.json" + "$ref": "./metric_not_found_error_schema.json" } } } @@ -603,13 +619,13 @@ "content": { "application/json": { "schema": { - "$ref": "../error_envelope_schema.json" + "$ref": "./metric_validation_failed_error_schema.json" } } } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { @@ -665,13 +681,13 @@ "content": { "application/json": { "schema": { - "$ref": "../error_envelope_schema.json" + "$ref": "./metric_not_found_error_schema.json" } } } }, "429": { - "description": "Too many requests — rate limit exceeded.", + "description": "Too many requests \u2014 rate limit exceeded.", "content": { "application/json": { "schema": { diff --git a/traigent_schema/schemas/measures/metric_list_response_schema.json b/traigent_schema/schemas/measures/metric_list_response_schema.json new file mode 100644 index 00000000..32e07373 --- /dev/null +++ b/traigent_schema/schemas/measures/metric_list_response_schema.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/measures/metric_list_response_schema.json", + "title": "Metric List Response", + "description": "200 body of the metric list endpoints. Wrapped envelope with nested pagination; each item is a metric (metric_schema.json) carrying the metric_ref used to build the item URL and its scope.", + "type": "object", + "additionalProperties": false, + "required": [ + "success", + "message", + "data" + ], + "properties": { + "success": { + "type": "boolean", + "const": true + }, + "message": { + "type": "string", + "maxLength": 200 + }, + "data": { + "type": "object", + "additionalProperties": false, + "required": [ + "items", + "pagination" + ], + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "./metric_schema.json" + } + }, + "pagination": { + "$ref": "../pagination_schema.json" + } + } + } + } +} diff --git a/traigent_schema/schemas/measures/metric_not_found_error_schema.json b/traigent_schema/schemas/measures/metric_not_found_error_schema.json new file mode 100644 index 00000000..6338266d --- /dev/null +++ b/traigent_schema/schemas/measures/metric_not_found_error_schema.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/measures/metric_not_found_error_schema.json", + "title": "Metric Not Found Error", + "description": "Closed metric not found error body for the metric endpoints: fixed code and message, no details, and nothing from the request is echoed.", + "type": "object", + "additionalProperties": false, + "required": [ + "success", + "message", + "error", + "error_code" + ], + "properties": { + "success": { + "const": false + }, + "message": { + "const": "Metric not found" + }, + "error": { + "const": "not_found" + }, + "error_code": { + "const": "not_found" + } + } +} diff --git a/traigent_schema/schemas/measures/metric_schema.json b/traigent_schema/schemas/measures/metric_schema.json index 02743446..1893025f 100644 --- a/traigent_schema/schemas/measures/metric_schema.json +++ b/traigent_schema/schemas/measures/metric_schema.json @@ -2,11 +2,12 @@ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://schemas.traigent.ai/measures/metric_schema.json", "title": "Metric", - "description": "A metric definition as returned by the metric endpoints. It reuses the measure definition vocabulary and carries no evaluator fields (evaluation_method, criteria, python_packages, measure_parameters). Two owners' metrics with the same label, and a built-in with that label, are three distinct rows with three distinct metric_ref values.", + "description": "A metric definition as returned by the metric endpoints. It reuses the measure definition vocabulary and carries no evaluator fields (evaluation_method, criteria, python_packages, measure_parameters). Two owners' metrics with the same label, and a built-in with that label, are three distinct rows with three distinct metric_ref values. Projection of the stored row: metric_ref is the server-minted reference; scope is project, shared or builtin; project_id is the owning project for scope project and null otherwise; domain is the pair [min, max] with a null min meaning unbounded below and an unbounded max reported as the number 1e308; agent_types is a list of {agent_type_id, name, description} objects, [] when none; value_type is numeric when unset; categories, target_types and allowed_score_sources are [] when unset.", "type": "object", "required": [ "metric_ref", "scope", + "project_id", "label", "measure_type" ], @@ -22,21 +23,23 @@ "type": "string", "enum": [ "project", - "tenant", - "built_in" + "shared", + "builtin" ], - "description": "project: owned by one project. tenant: shared through the tenant library. built_in: shipped by the platform, read-only." + "description": "project: owned by one project. shared: shared through the tenant library. builtin: shipped by the platform, read-only." }, "project_id": { "type": [ "string", "null" ], - "description": "Owning project for scope project; null otherwise." + "minLength": 1, + "description": "Owning project for scope project (required, non-null); null for shared and builtin." }, "version": { "type": "string", - "pattern": "^\\d+\\.\\d+\\.\\d+$" + "maxLength": 20, + "description": "Metric definition version, for example 1.0.0." }, "label": { "type": "string", @@ -92,27 +95,95 @@ "agent_types": { "type": "array", "items": { - "$ref": "./measure_schema.json#/definitions/AgentType" + "type": "object", + "additionalProperties": false, + "required": [ + "agent_type_id", + "name" + ], + "properties": { + "agent_type_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": [ + "string", + "null" + ] + } + } }, - "minItems": 1 + "description": "Agent types the metric applies to; [] when none." + }, + "inverse": { + "type": "boolean" + }, + "is_custom": { + "type": "boolean" }, - "domain_min": { + "unit": { "type": [ - "number", + "string", "null" - ] + ], + "maxLength": 20, + "description": "Unit of the value, for example ms or $; null when unitless." + }, + "domain": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": { + "type": [ + "number", + "null" + ] + }, + "description": "[min, max]. A null min means unbounded below; an unbounded max is reported as 1e308." }, - "domain_max": { + "created_at": { "type": [ - "number", + "string", "null" ] }, - "inverse": { - "type": "boolean" - }, - "is_custom": { - "type": "boolean" + "updated_at": { + "type": [ + "string", + "null" + ] + } + }, + "allOf": [ + { + "if": { + "properties": { + "scope": { + "const": "project" + } + }, + "required": [ + "scope" + ] + }, + "then": { + "properties": { + "project_id": { + "type": "string", + "minLength": 1 + } + } + }, + "else": { + "properties": { + "project_id": { + "type": "null" + } + } + } } - } + ] } diff --git a/traigent_schema/schemas/measures/metric_update_request_schema.json b/traigent_schema/schemas/measures/metric_update_request_schema.json index 6d591fa1..5ded8d8d 100644 --- a/traigent_schema/schemas/measures/metric_update_request_schema.json +++ b/traigent_schema/schemas/measures/metric_update_request_schema.json @@ -80,8 +80,18 @@ "inverse": { "type": "boolean" }, - "is_custom": { - "type": "boolean" + "unit": { + "type": [ + "string", + "null" + ], + "maxLength": 20, + "description": "Unit of the value, for example ms or $." + }, + "version": { + "type": "string", + "maxLength": 20, + "description": "Metric definition version, for example 1.0.0." } } } diff --git a/traigent_schema/schemas/measures/metric_validation_failed_error_schema.json b/traigent_schema/schemas/measures/metric_validation_failed_error_schema.json new file mode 100644 index 00000000..30ff092e --- /dev/null +++ b/traigent_schema/schemas/measures/metric_validation_failed_error_schema.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/measures/metric_validation_failed_error_schema.json", + "title": "Metric Validation Failed Error", + "description": "Closed metric validation failed error body for the metric endpoints: fixed code and message, no details, and nothing from the request is echoed.", + "type": "object", + "additionalProperties": false, + "required": [ + "success", + "message", + "error", + "error_code" + ], + "properties": { + "success": { + "const": false + }, + "message": { + "const": "Validation failed" + }, + "error": { + "const": "validation_failed" + }, + "error_code": { + "const": "validation_failed" + } + } +} diff --git a/traigent_schema/schemas/measures/metric_write_request_schema.json b/traigent_schema/schemas/measures/metric_write_request_schema.json index cda28d6d..12c5052f 100644 --- a/traigent_schema/schemas/measures/metric_write_request_schema.json +++ b/traigent_schema/schemas/measures/metric_write_request_schema.json @@ -83,8 +83,18 @@ "inverse": { "type": "boolean" }, - "is_custom": { - "type": "boolean" + "unit": { + "type": [ + "string", + "null" + ], + "maxLength": 20, + "description": "Unit of the value, for example ms or $." + }, + "version": { + "type": "string", + "maxLength": 20, + "description": "Metric definition version, for example 1.0.0." } } } diff --git a/traigent_schema/validator.py b/traigent_schema/validator.py index e9dc5f41..f31bc697 100644 --- a/traigent_schema/validator.py +++ b/traigent_schema/validator.py @@ -432,10 +432,18 @@ def _register_operation(self, key: str, spec: dict[str, Any], inline_base_id: st self._known_endpoints.add(key) if schema_ref: - schema_name = schema_ref.split("/")[-1] - if schema_name.endswith(".json"): - schema_name = schema_name[:-5] - self._endpoint_schemas[key] = schema_name + file_part, _, pointer = schema_ref.partition("#") + if pointer.startswith("/"): + # ``file.json#/json/pointer``: keep the fragment so the sub-schema is validated. + schema_name = file_part.split("/")[-1] + if schema_name.endswith(".json"): + schema_name = schema_name[:-5] + self._endpoint_schemas[key] = f"{schema_name}#{pointer}" + else: + schema_name = schema_ref.split("/")[-1] + if schema_name.endswith(".json"): + schema_name = schema_name[:-5] + self._endpoint_schemas[key] = schema_name elif isinstance(json_schema, dict) and json_schema: self._inline_request_schemas[key] = json_schema self._inline_request_schema_base_ids[key] = inline_base_id @@ -581,13 +589,21 @@ def validate_json( Returns: List of validation error messages. Empty if valid. """ - schema = self._schemas.get(schema_name) + name, _, pointer = schema_name.partition("#") + schema = self._schemas.get(name) if not schema: # Try with _schema suffix - schema = self._schemas.get(f"{schema_name}_schema") + schema = self._schemas.get(f"{name}_schema") if not schema: - return [f"Schema not found: {schema_name}"] + return [f"Schema not found: {name}"] + + if pointer: + # ``name#/json/pointer``: validate against that sub-schema of the named file. + schema_id = schema.get("$id") + if not isinstance(schema_id, str) or not pointer.startswith("/"): + return [f"Schema not found: {schema_name}"] + return self._run_validator(data, {"$ref": f"{schema_id}#{pointer}"}) return self._run_validator(data, schema) From 7ed5e9012efe670235b5d27ba59093b34d5599e9 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Thu, 26 Nov 2026 22:06:00 +0200 Subject: [PATCH 04/20] fix(contracts): metric description may be null; the domain upper bound is always a number Co-Authored-By: Claude Haiku 4.5 Co-Authored-By: Claude Opus 5.5 --- tests/test_metric_contract.py | 16 +++++++++++++ .../schemas/measures/metric_schema.json | 24 ++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/tests/test_metric_contract.py b/tests/test_metric_contract.py index 61487fde..ac7caec6 100644 --- a/tests/test_metric_contract.py +++ b/tests/test_metric_contract.py @@ -224,3 +224,19 @@ def test_404_on_every_item_op_is_bound_to_the_closed_not_found_error(): assert _errors(name, {**NOT_FOUND, "details": {"metric_ref": "metric_x"}}) assert _errors(name, {**NOT_FOUND, "message": "Metric metric_x not found"}) assert _errors(name, VALIDATION_FAILED) + + +def test_metric_description_accepts_null_and_still_caps_strings(): + assert not _errors("metric_schema.json", _metric(description=None)) + assert not _errors("metric_schema.json", _metric(description="Accuracy of the answer")) + assert _errors("metric_schema.json", _metric(description="x" * 5001)) + + +@pytest.mark.parametrize("domain", [[0, 1], [None, 1e308], [None, 1], [0.5, 2.5]]) +def test_metric_domain_accepts_numeric_bounds_and_null_lower(domain): + assert not _errors("metric_schema.json", _metric(domain=domain)) + + +@pytest.mark.parametrize("domain", [[0, None], [None, None], [0, "1"], [0, 1, 2]]) +def test_metric_domain_rejects_null_upper_bound(domain): + assert _errors("metric_schema.json", _metric(domain=domain)) diff --git a/traigent_schema/schemas/measures/metric_schema.json b/traigent_schema/schemas/measures/metric_schema.json index 1893025f..0d17ffff 100644 --- a/traigent_schema/schemas/measures/metric_schema.json +++ b/traigent_schema/schemas/measures/metric_schema.json @@ -52,7 +52,10 @@ "maxLength": 255 }, "description": { - "type": "string", + "type": [ + "string", + "null" + ], "maxLength": 5000 }, "category": { @@ -136,13 +139,18 @@ "type": "array", "minItems": 2, "maxItems": 2, - "items": { - "type": [ - "number", - "null" - ] - }, - "description": "[min, max]. A null min means unbounded below; an unbounded max is reported as 1e308." + "items": [ + { + "type": [ + "number", + "null" + ] + }, + { + "type": "number" + } + ], + "description": "[min, max]. A null min means unbounded below; an unbounded max is reported as 1e308 and is never null." }, "created_at": { "type": [ From 9ba17db2ec3aeb26b39f276866d03502b09e6996 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 04:56:31 +0200 Subject: [PATCH 05/20] docs(changelog): fragment for the dataset and metric project paths Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/dataset-metric-project-paths.added.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 changelog.d/dataset-metric-project-paths.added.md diff --git a/changelog.d/dataset-metric-project-paths.added.md b/changelog.d/dataset-metric-project-paths.added.md new file mode 100644 index 00000000..46b51d26 --- /dev/null +++ b/changelog.d/dataset-metric-project-paths.added.md @@ -0,0 +1,14 @@ +- **Project-scoped dataset paths.** Datasets, their examples, files, upload, + example generation, public-benchmark marking and version content identity + are declared under `/api/v1/projects/{project_id}/datasets/...`. Additive: + no existing path is removed. +- **Metric operations.** New `metric.*` operations: list and create a + project's metrics at `/api/v1/projects/{project_id}/metrics`; list and + create library metrics at `/api/v1/metrics`; and get, update (`PATCH`) and + delete one metric at `/api/v1/metrics/{metric_ref}`. Metric descriptions may + be null. Writes reject evaluator fields with a closed validation problem. +- **Idempotency conflicts on the group run query.** + `experiment_group.query_group_runs` declares its `409` responses + (`idempotency_conflict`, `idempotency_in_progress`). +- **Fragment references.** The schema validator resolves `$ref` values that + point into another file (`file.json#/pointer`). From d3a1e6953986cac709fb50bd2091060465e9b449 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 04:56:31 +0200 Subject: [PATCH 06/20] feat(contract): declare the idempotency 409 responses on the group run query Co-Authored-By: Claude Sonnet 5.5 --- .../execution/execution_endpoints.json | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/traigent_schema/schemas/execution/execution_endpoints.json b/traigent_schema/schemas/execution/execution_endpoints.json index 79bf8d16..6f4c3174 100644 --- a/traigent_schema/schemas/execution/execution_endpoints.json +++ b/traigent_schema/schemas/execution/execution_endpoints.json @@ -418,6 +418,9 @@ "404": { "$ref": "#/components/responses/GroupsNotFound" }, + "409": { + "$ref": "#/components/responses/GroupsConflict" + }, "413": { "$ref": "#/components/responses/GroupsPayloadTooLarge" }, @@ -2655,6 +2658,76 @@ "maxLength": 32 } } + }, + { + "type": "object", + "required": [ + "type", + "title", + "status", + "code", + "detail", + "problem_id" + ], + "additionalProperties": false, + "properties": { + "type": { + "const": "urn:traigent:problem:idempotency_conflict" + }, + "title": { + "const": "Conflict" + }, + "status": { + "const": 409 + }, + "code": { + "const": "idempotency_conflict" + }, + "detail": { + "const": "The idempotency key was already used with a different request." + }, + "problem_id": { + "type": "string", + "pattern": "^[0-9a-f]{32}$", + "minLength": 32, + "maxLength": 32 + } + } + }, + { + "type": "object", + "required": [ + "type", + "title", + "status", + "code", + "detail", + "problem_id" + ], + "additionalProperties": false, + "properties": { + "type": { + "const": "urn:traigent:problem:idempotency_in_progress" + }, + "title": { + "const": "Conflict" + }, + "status": { + "const": 409 + }, + "code": { + "const": "idempotency_in_progress" + }, + "detail": { + "const": "A request with this idempotency key is still being processed." + }, + "problem_id": { + "type": "string", + "pattern": "^[0-9a-f]{32}$", + "minLength": 32, + "maxLength": 32 + } + } } ] } @@ -2749,6 +2822,16 @@ } } } + }, + "GroupsConflict": { + "description": "The idempotency key was reused with a different request, or a request with the same key is still in progress (closed problem)", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/GroupsProblem" + } + } + } } } } From 8d5306ddf30ef952c0e084c152a8056cb07a6029 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 03:10:04 +0200 Subject: [PATCH 07/20] feat(contract): certificate build-session and process-record contracts under project paths Add-only: new contracts; no existing entry changes. Co-Authored-By: Claude Sonnet 5.5 --- parity/python-js-sdk.json | 4 +- tests/test_process_record_v1_schema.py | 55 + .../certificate_build_sessions_endpoints.json | 216 +++ .../process_record_request_schema.json | 171 ++ .../process_records_endpoints.json | 1518 +++++++++++++++++ .../schemas/closed_request_error_schema.json | 474 +++++ traigent_schema/schemas/mep_endpoints.json | 10 + 7 files changed, 2446 insertions(+), 2 deletions(-) create mode 100644 traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json create mode 100644 traigent_schema/schemas/certification/process_record_request_schema.json create mode 100644 traigent_schema/schemas/certification/process_records_endpoints.json create mode 100644 traigent_schema/schemas/closed_request_error_schema.json diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index acffb57a..fafed836 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,8 +399,8 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "f23916e05f64abe2a9b03a30d2dfff3d70aad200fe03af0b29587b569f947e97", - "schemaFileCount": 677, + "lastSchemaFileSha": "946fb5f22466ee31684503f83a5edf5f32306e8f252122af238c54085687ae68", + "schemaFileCount": 681, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } } diff --git a/tests/test_process_record_v1_schema.py b/tests/test_process_record_v1_schema.py index 1c0b58d9..e3d8f444 100644 --- a/tests/test_process_record_v1_schema.py +++ b/tests/test_process_record_v1_schema.py @@ -10,6 +10,8 @@ from jsonschema import Draft7Validator from referencing import Registry, Resource +from traigent_schema.validator import _FORMAT_CHECKER as DATE_TIME_FORMAT_CHECKER + ROOT = Path(__file__).resolve().parents[1] SCHEMAS = ROOT / "traigent_schema" / "schemas" SCHEMA_PATH = SCHEMAS / "certification" / "process_record_v1_schema.json" @@ -592,3 +594,56 @@ def test_utc_timestamp_pattern_is_anchored_and_rejects_malformed_variants() -> N assert _errors("2026-09-05T10:11:12.1234567Z", "UtcTimestampV1") # An empty fraction after the dot is not "1-6 digits". assert _errors("2026-09-05T10:11:12.Z", "UtcTimestampV1") + + +# -------------------------------------------------------------------------- +# Request field schemas, reached through the public request document +# -------------------------------------------------------------------------- + +REQUEST_ID = "https://schemas.traigent.ai/certification/process_record_request_schema.json" + + +def _field_is_valid(request_definition: str, field: str, value: object) -> bool: + """Validate one request field via a JSON pointer into the public request document.""" + schema = {"$ref": f"{REQUEST_ID}#/definitions/{request_definition}/properties/{field}"} + validator = Draft7Validator( + schema, registry=REGISTRY, format_checker=DATE_TIME_FORMAT_CHECKER + ) + return validator.is_valid(value) + + +@pytest.mark.parametrize( + "request_definition", ["VerifyProcessRecordRequest", "FinalizeProcessRecordRequest"] +) +@pytest.mark.parametrize( + "field,value,valid", + [ + ("build_session_ref", BUILD, True), + ("build_session_ref", BUILD + "\n", False), + ("project_ref", PROJECT, True), + ("project_ref", PROJECT + "\n", False), + ("agent_commitment_ref", SHA, True), + ("agent_commitment_ref", "sha256:" + "a" * 63, False), + ("agent_commitment_ref", "sha256:" + "a" * 65, False), + ("agent_commitment_ref", "sha256:" + "A" * 64, False), + ("agent_commitment_ref", SHA + "\n", False), + ], +) +def test_request_reference_fields_bound_their_shapes( + request_definition: str, field: str, value: str, valid: bool +) -> None: + assert _field_is_valid(request_definition, field, value) is valid + + +@pytest.mark.parametrize( + "value,valid", + [ + ("2026-09-05T10:11:12.123456Z", True), + ("2026-09-05T10:11:12+00:00", False), + ("2026-02-30T10:11:12Z", False), + ("2026-09-05T10:11:12Z\n", False), + ("2026-09-05T10:11:12.1234567Z", False), + ], +) +def test_verification_time_is_strict_utc_timestamp(value: str, valid: bool) -> None: + assert _field_is_valid("VerifyProcessRecordRequest", "verification_time", value) is valid diff --git a/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json b/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json new file mode 100644 index 00000000..2bbff9db --- /dev/null +++ b/traigent_schema/schemas/certification/certificate_build_sessions_endpoints.json @@ -0,0 +1,216 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Traigent Certificate Build Session Routes", + "version": "1.0.0", + "description": "Project-scoped certificate build-session abandonment and issuance readiness." + }, + "x-asserted-against-backend": false, + "paths": { + "/api/v1/projects/{project_id}/certificate-build-sessions/{bsn}/abandon": { + "post": { + "operationId": "certification_g1_sessions.abandon_certificate_build_session", + "summary": "Abandon certificate issuance through a build session", + "description": "Abandons pending issuance for the run linked to the build session. An already abandoned or timed-out session returns its current state. A finalized session is a conflict. Takes no request body.", + "x-wrap-status": "bare", + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": {"type": "string", "minLength": 1, "maxLength": 128} + }, + { + "name": "bsn", + "in": "path", + "required": true, + "description": "The issued certificate build-session reference.", + "schema": {"type": "string", "pattern": "^bsn:[A-Za-z0-9_-]{43}$"} + } + ], + "responses": { + "200": { + "description": "The terminal issuance state.", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": ["state"], + "properties": {"state": {"type": "string", "enum": ["abandoned", "timed_out"]}} + } + } + } + }, + "400": {"$ref": "#/components/responses/BadRequest"}, + "401": {"$ref": "#/components/responses/Unauthorized"}, + "403": {"$ref": "#/components/responses/Forbidden"}, + "404": {"$ref": "#/components/responses/NotFound"}, + "409": {"$ref": "#/components/responses/Conflict"}, + "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "422": {"$ref": "#/components/responses/Unprocessable"}, + "429": {"$ref": "#/components/responses/RateLimited"}, + "500": {"$ref": "#/components/responses/AuthenticationError"}, + "503": { + "description": "Issuance or authentication is temporarily unavailable.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "./certificate_error_v0_schema.json#/definitions/ServiceUnavailableV0"}, + {"$ref": "../closed_request_error_schema.json#/definitions/Unavailable"} + ] + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/certificate-build-sessions/readiness": { + "get": { + "operationId": "certification_g1_sessions.g1_issuance_readiness", + "summary": "Check G1 issuance readiness", + "description": "Reports whether G1 issuance is available. The probe does not issue or modify certificates.", + "x-wrap-status": "bare", + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "schema": {"type": "string", "minLength": 1, "maxLength": 128} + } + ], + "responses": { + "200": { + "description": "Availability of G1 issuance.", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": false, + "required": ["readiness_version", "g1_issuance"], + "properties": { + "readiness_version": {"type": "integer", "const": 1}, + "g1_issuance": {"type": "string", "enum": ["available", "unavailable"]} + } + } + } + } + }, + "400": {"$ref": "#/components/responses/ProviderCredentialRejected"}, + "401": {"$ref": "#/components/responses/Unauthorized"}, + "403": {"$ref": "#/components/responses/Forbidden"}, + "404": {"$ref": "#/components/responses/NotFound"}, + "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "422": {"$ref": "#/components/responses/Unprocessable"}, + "429": {"$ref": "#/components/responses/RateLimited"}, + "500": {"$ref": "#/components/responses/AuthenticationError"}, + "503": { + "description": "Authentication is temporarily unavailable.", + "content": {"application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unavailable"}}} + } + } + } + } + }, + "components": { + "responses": { + "PayloadTooLarge": { + "description": "The request exceeds the size limit.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "./certificate_error_v0_schema.json#/definitions/RequestTooLargeV0"}, + {"$ref": "../closed_request_error_schema.json#/definitions/RequestTooLarge"} + ] + } + } + } + }, + "RateLimited": { + "description": "The request exceeded a rate limit.", + "content": { + "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/RateLimited"}} + } + }, + "Unprocessable": { + "description": "Request validation or scope resolution failed.", + "content": { + "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"}} + } + }, + "BadRequest": { + "description": "Invalid build-session reference, unsupported content type, or provider credential rejected.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "./certificate_error_v0_schema.json#/definitions/InvalidRequestV0"}, + {"$ref": "../closed_request_error_schema.json#/definitions/UnsupportedContentType"} + ] + } + }, + "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} + } + }, + "ProviderCredentialRejected": { + "description": "Provider credential rejected.", + "content": { + "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} + } + }, + "Unauthorized": { + "description": "Authentication required.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "./certificate_error_v0_schema.json#/definitions/AuthenticationRequiredV0"}, + {"$ref": "../closed_request_error_schema.json#/definitions/Unauthorized"} + ] + } + } + } + }, + "Forbidden": { + "description": "Authorization denied.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "./certificate_error_v0_schema.json#/definitions/AuthorizationDeniedV0"}, + {"$ref": "../closed_request_error_schema.json#/definitions/EntitlementRequired"}, + {"$ref": "../closed_request_error_schema.json#/definitions/OptimizationOnly"} + ] + } + } + } + }, + "NotFound": { + "description": "The project or build session was not found, or the route is unavailable.", + "content": {"application/json": {"schema": { + "anyOf": [ + {"$ref": "./certificate_error_v0_schema.json#/definitions/NotFoundV0"}, + {"$ref": "../closed_request_error_schema.json#/definitions/RouteNotFound"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectNotFound"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextNotFound"} + ] + }}} + }, + "Conflict": { + "description": "The issuance state conflicts with abandonment.", + "content": {"application/json": {"schema": {"$ref": "./certificate_error_v0_schema.json#/definitions/StateConflictV0"}}} + }, + "AuthenticationError": { + "description": "Authentication or request handling failed unexpectedly.", + "content": { + "application/json": { + "schema": {"$ref": "../closed_request_error_schema.json#/definitions/InternalError"} + } + } + } + } + } +} diff --git a/traigent_schema/schemas/certification/process_record_request_schema.json b/traigent_schema/schemas/certification/process_record_request_schema.json new file mode 100644 index 00000000..2dc57ef6 --- /dev/null +++ b/traigent_schema/schemas/certification/process_record_request_schema.json @@ -0,0 +1,171 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/certification/process_record_request_schema.json", + "title": "Process Record Requests", + "description": "Request bodies and reference types for the project-scoped process record routes.", + "definitions": { + "ProcessRecordReference": { + "type": "string", + "minLength": 1, + "description": "An opaque process record reference scoped to the named project." + }, + "Sha256Reference": { + "allOf": [{"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}], + "maxLength": 71 + }, + "SignedReference": { + "allOf": [{"$ref": "./certification_common_v0_schema.json#/definitions/OpaqueRef"}], + "not": {"pattern": "[\\r\\n\\u2028\\u2029]"} + }, + "ProjectReference": { + "allOf": [{"$ref": "./certification_common_v0_schema.json#/definitions/ProjectRefV0"}], + "not": {"pattern": "[\\r\\n\\u2028\\u2029]"} + }, + "PrepareProcessRecordRequest": { + "type": "object", + "additionalProperties": false, + "required": ["process_record_ref"], + "properties": {"process_record_ref": {"$ref": "#/definitions/ProcessRecordReference"}} + }, + "VerificationContextV0": { + "type": "object", + "additionalProperties": false, + "required": [ + "expected_nonce", + "expected_build_session_ref", + "expected_issuer_key_ref", + "expected_issuer_algorithm", + "expected_trust_ring_ref", + "expected_project_ref" + ], + "properties": { + "expected_nonce": {"type": "string", "minLength": 1}, + "expected_build_session_ref": {"$ref": "#/definitions/SignedReference"}, + "expected_issuer_key_ref": {"$ref": "#/definitions/SignedReference"}, + "expected_issuer_algorithm": {"type": "string", "minLength": 1}, + "expected_trust_ring_ref": {"$ref": "#/definitions/SignedReference"}, + "expected_project_ref": {"$ref": "#/definitions/ProjectReference"}, + "expected_client_key_ref": {"type": ["string", "null"]}, + "expected_client_algorithm": {"type": ["string", "null"]}, + "client_public_key_der_b64": {"type": ["string", "null"]} + }, + "oneOf": [ + { + "properties": { + "expected_client_key_ref": {"type": "null"}, + "expected_client_algorithm": {"type": "null"}, + "client_public_key_der_b64": {"type": "null"} + } + }, + { + "required": ["expected_client_key_ref", "expected_client_algorithm", "client_public_key_der_b64"], + "properties": { + "expected_client_key_ref": {"type": "string", "minLength": 1}, + "expected_client_algorithm": {"type": "string", "minLength": 1}, + "client_public_key_der_b64": {"type": "string", "minLength": 1} + } + } + ] + }, + "FinalizeProcessRecordRequest": { + "type": "object", + "additionalProperties": false, + "required": [ + "project_ref", + "build_session_ref", + "agent_commitment_ref", + "dataset_commitment_ref", + "evaluator_commitment_ref", + "build_definition_commitment_ref", + "base_certificate_v0", + "verification_materials_v0", + "v0_context_kwargs" + ], + "properties": { + "project_ref": {"$ref": "#/definitions/ProjectReference"}, + "build_session_ref": {"$ref": "#/definitions/SignedReference"}, + "agent_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "dataset_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "evaluator_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "build_definition_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "base_certificate_v0": {"$ref": "./agent_certificate_v0_schema.json"}, + "verification_materials_v0": {"$ref": "./certificate_verification_materials_v0_schema.json"}, + "v0_context_kwargs": {"$ref": "#/definitions/VerificationContextV0"}, + "claim_id": {"enum": ["PROC1", null, ""], "default": "PROC1"}, + "experiment_run_id": {"type": ["string", "null"], "minLength": 1}, + "openings": { + "type": "object", + "additionalProperties": false, + "properties": { + "agent": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "dataset": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "config_space": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:primary": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r0": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r1": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r2": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r3": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r4": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r5": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r6": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r7": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"} + }, + "minProperties": 1 + } + } + }, + "VerifyProcessRecordRequest": { + "type": "object", + "additionalProperties": false, + "required": [ + "project_ref", + "build_session_ref", + "agent_commitment_ref", + "dataset_commitment_ref", + "evaluator_commitment_ref", + "build_definition_commitment_ref", + "bundle", + "verification_materials_v0", + "v0_context_kwargs", + "trust_anchor", + "trust_status" + ], + "properties": { + "project_ref": {"$ref": "#/definitions/ProjectReference"}, + "build_session_ref": {"$ref": "#/definitions/SignedReference"}, + "agent_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "dataset_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "evaluator_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "build_definition_commitment_ref": {"$ref": "#/definitions/Sha256Reference"}, + "bundle": {"$ref": "./process_record_v1_schema.json"}, + "verification_materials_v0": { + "type": "object", + "required": ["materials_digest", "certificate_ref"], + "properties": { + "materials_digest": {"$ref": "#/definitions/Sha256Reference"}, + "certificate_ref": {"$ref": "#/definitions/SignedReference"} + }, + "description": "Verification materials for the base certificate. Verification uses only the materials digest and certificate reference." + }, + "v0_context_kwargs": {"$ref": "#/definitions/VerificationContextV0"}, + "verification_time": { + "allOf": [{"$ref": "./process_record_v1_schema.json#/definitions/UtcTimestampV1"}], + "format": "date-time", + "not": {"pattern": "[\\r\\n]"} + }, + "trust_anchor": { + "type": "object", + "additionalProperties": false, + "required": ["key_ref", "algorithm", "public_key_der_b64", "public_key_digest"], + "properties": { + "key_ref": {"$ref": "#/definitions/SignedReference"}, + "algorithm": {"enum": ["ed25519", "ecdsa_p256_sha256"]}, + "public_key_der_b64": {"type": "string", "minLength": 1}, + "public_key_digest": {"$ref": "#/definitions/Sha256Reference"} + } + }, + "trust_status": {"$ref": "./process_record_v1_schema.json#/definitions/TrustStatusEnvelopeV1"} + } + } + } +} diff --git a/traigent_schema/schemas/certification/process_records_endpoints.json b/traigent_schema/schemas/certification/process_records_endpoints.json new file mode 100644 index 00000000..b118e57c --- /dev/null +++ b/traigent_schema/schemas/certification/process_records_endpoints.json @@ -0,0 +1,1518 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Traigent Process Record Routes", + "version": "1.0.0", + "description": "Project-scoped preparation, retrieval, issuance and verification of process record certificates." + }, + "x-asserted-against-backend": false, + "paths": { + "/api/v1/projects/{project_id}/process-records": { + "post": { + "operationId": "certification_process_record.prepare_process_record", + "summary": "Check receipt readiness for a process record", + "description": "Reports the receipts currently visible for an issued build session. This probe does not reserve issuance.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "The project id.", + "schema": {"type": "string", "minLength": 1, "maxLength": 128} + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": {"allOf": [{"$ref": "./process_record_request_schema.json#/definitions/PrepareProcessRecordRequest"}]} + } + } + }, + "responses": { + "201": { + "description": "Receipt readiness calculated.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/PrepareProcessRecordResponse"}}} + }, + "400": { + "description": "Invalid request body, process record reference or tenant context.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/UnsupportedContentType"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "INVALID_BODY"}, + "error_code": {"const": "INVALID_BODY"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "MALFORMED_PROCESS_RECORD_REF"}, + "error_code": {"const": "MALFORMED_PROCESS_RECORD_REF"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "TENANT_CONTEXT_MISSING"}, + "error_code": {"const": "TENANT_CONTEXT_MISSING"} + } + } + ] + } + }, + "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} + } + }, + "401": {"$ref": "#/components/responses/Unauthorized"}, + "403": {"$ref": "#/components/responses/WriteForbidden"}, + "404": {"$ref": "#/components/responses/NotFound"}, + "422": {"$ref": "#/components/responses/Unprocessable"}, + "409": { + "description": "The requested receipt snapshot conflicts with current state.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordStorageConflict"}}} + }, + "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "429": {"$ref": "#/components/responses/RateLimited"}, + "500": {"$ref": "#/components/responses/InternalError"}, + "503": { + "description": "Receipt or authentication data is temporarily unavailable.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Internal server error"}, + "error": {"const": "Internal server error"}, + "error_code": { + "type": "string", + "enum": [ + "AUTH_BACKEND_UNAVAILABLE", + "SNAPSHOT_ISOLATION_FAILED", + "STORAGE_UNAVAILABLE", + "UNCLASSIFIED_INTEGRITY_VIOLATION", + "UNKNOWN_STREAM_ID", + "UNKNOWN_STEP_ID", + "UNKNOWN_OBSERVATION_BASIS", + "UNKNOWN_REGISTERED_KEY", + "EMPTY_REGISTERED_VALUES", + "NON_INTEGER_REGISTERED_VALUE", + "NUMERIC_BOUND_VIOLATION", + "RECEIPT_PROJECTION_TOO_LARGE" + ] + } + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unavailable"} + ] + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/process-records/{process_record_ref}": { + "get": { + "operationId": "certification_process_record.retrieve_process_record", + "summary": "Retrieve an issued process record", + "description": "Returns the stored certificate after checked re-verification. Optional companions are separate from the signed bundle.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "The project id.", + "schema": {"type": "string", "minLength": 1, "maxLength": 128} + }, + { + "name": "process_record_ref", + "in": "path", + "required": true, + "description": "Opaque reference to the process record in this project.", + "schema": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"} + } + ], + "responses": { + "200": { + "description": "Issued process record retrieved.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/RetrieveProcessRecordResponse"}}} + }, + "400": { + "description": "Invalid process-record reference or tenant context.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "MALFORMED_PROCESS_RECORD_REF"}, + "error_code": {"const": "MALFORMED_PROCESS_RECORD_REF"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "TENANT_CONTEXT_MISSING"}, + "error_code": {"const": "TENANT_CONTEXT_MISSING"} + } + } + ] + } + }, + "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} + } + }, + "401": {"$ref": "#/components/responses/Unauthorized"}, + "403": { + "description": "The caller lacks read access to the project.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectAccessDenied"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextForbidden"}, + {"$ref": "../closed_request_error_schema.json#/definitions/OptimizationOnly"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "no project context bound to this request"}, + "error": {"const": "PROJECT_CONTEXT_REQUIRED"}, + "error_code": {"const": "PROJECT_CONTEXT_REQUIRED"} + } + }, + { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "Missing required permissions: harness.read"}, + "error": {"const": "INSUFFICIENT_PERMISSIONS"}, + "error_code": {"const": "INSUFFICIENT_PERMISSIONS"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["missing_permissions"], + "properties": { + "missing_permissions": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/EntitlementRequired"} + ] + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "tenant_context_missing"}, + "error_code": {"const": "TENANT_CONTEXT_MISSING"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "tenant_binding_failed"}, + "error_code": {"const": "TENANT_BINDING_FAILED"} + } + } + ] + } + } + } + }, + "404": { + "description": "No accessible issuance was found.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectNotFound"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextNotFound"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Resource not found"}, + "error": {"const": "Not found"}, + "error_code": {"const": "NOT_FOUND"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "no process record certificate has been minted for this build session"}, + "error": {"const": "PROCESS_RECORD_NOT_FOUND"}, + "error_code": {"const": "PROCESS_RECORD_NOT_FOUND"} + } + } + ] + } + } + } + }, + "422": { + "description": "The stored certificate failed checked re-verification.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "allOf": [ + {"$ref": "#/components/schemas/ProcessRecordVerificationFailure"}, + { + "properties": { + "message": {"const": "checked re-verification of the stored certificate failed"}, + "error_code": {"enum": ["REVOCATION_STATUS_UNAVAILABLE", "KEY_REVOKED", "CERTIFICATE_REVOKED"]} + } + } + ] + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"} + ] + } + } + } + }, + "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "429": {"$ref": "#/components/responses/RateLimited"}, + "500": {"$ref": "#/components/responses/InternalError"}, + "503": { + "description": "The stored issuance could not be read or reconciled.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Internal server error"}, + "error": {"const": "Internal server error"}, + "error_code": { + "type": "string", + "enum": [ + "AUTH_BACKEND_UNAVAILABLE", + "SNAPSHOT_ISOLATION_FAILED", + "STORAGE_UNAVAILABLE", + "UNCLASSIFIED_INTEGRITY_VIOLATION", + "UNKNOWN_STREAM_ID", + "UNKNOWN_STEP_ID", + "UNKNOWN_OBSERVATION_BASIS", + "UNKNOWN_REGISTERED_KEY", + "EMPTY_REGISTERED_VALUES", + "NON_INTEGER_REGISTERED_VALUE", + "NUMERIC_BOUND_VIOLATION", + "RECEIPT_PROJECTION_TOO_LARGE", + "ISSUANCE_RECORD_CORRUPT", + "FRONT_CLAIM_SUPPLEMENT_CORRUPT", + "ISSUANCE_RECONCILIATION_FAILED", + "ISSUANCE_RECORD_TOO_LARGE", + "COMMITMENT_LINKAGE_CORRUPT" + ] + } + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unavailable"} + ] + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/process-records/{process_record_ref}/finalize": { + "post": { + "operationId": "certification_process_record.finalize_process_record", + "summary": "Issue a process record certificate", + "description": "Issues and stores a signed certificate for the named build session. After an ambiguous storage failure, retrieve the record before retrying.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "The project id.", + "schema": {"type": "string", "minLength": 1, "maxLength": 128} + }, + { + "name": "process_record_ref", + "in": "path", + "required": true, + "description": "Opaque reference to the process record in this project.", + "schema": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"} + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": {"allOf": [{"$ref": "./process_record_request_schema.json#/definitions/FinalizeProcessRecordRequest"}]} + } + } + }, + "responses": { + "201": { + "description": "Signed process record issued.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FinalizeProcessRecordResponse"}}} + }, + "400": { + "description": "Invalid request body, reference, or issuance inputs.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/UnsupportedContentType"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "INVALID_BODY"}, + "error_code": {"const": "INVALID_BODY"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "MALFORMED_PROCESS_RECORD_REF"}, + "error_code": {"const": "MALFORMED_PROCESS_RECORD_REF"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "TENANT_CONTEXT_MISSING"}, + "error_code": {"const": "TENANT_CONTEXT_MISSING"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "MISSING_FIELD"}, + "error_code": {"const": "MISSING_FIELD"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "invalid_request"}, + "error_code": {"const": "invalid_request"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "missing_project_id"}, + "error_code": {"const": "MISSING_PROJECT_ID"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "commitment_linkage_disabled"}, + "error_code": {"const": "COMMITMENT_LINKAGE_DISABLED"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "commitment_linkage_opening_shape"}, + "error_code": {"const": "COMMITMENT_LINKAGE_OPENING_SHAPE"} + } + } + ] + } + }, + "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} + } + }, + "401": {"$ref": "#/components/responses/Unauthorized"}, + "403": {"$ref": "#/components/responses/WriteForbidden"}, + "404": {"$ref": "#/components/responses/NotFound"}, + "409": { + "description": "Issuance conflicts with current state. A retry delay is returned when issuance is already in progress.", + "headers": { + "Retry-After": {"description": "Seconds to wait when issuance is in progress.", "schema": {"type": "integer", "const": 2}} + }, + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "#/components/schemas/ProcessRecordStorageConflict"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "receipt_snapshot_stale"}, + "error_code": {"const": "RECEIPT_SNAPSHOT_STALE"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "duplicate_issuance"}, + "error_code": {"const": "DUPLICATE_ISSUANCE"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "session_project_conflict"}, + "error_code": {"const": "SESSION_PROJECT_CONFLICT"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "issuance_in_progress"}, + "error_code": {"const": "ISSUANCE_IN_PROGRESS"} + } + } + ] + } + } + } + }, + "422": { + "description": "Issuance inputs or assembled certificate failed verification.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "no_receipts_visible"}, + "error_code": {"const": "NO_RECEIPTS_VISIBLE"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["_global"], + "properties": { + "_global": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "issuer_key_binding_mismatch"}, + "error_code": {"const": "ISSUER_KEY_BINDING_MISMATCH"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["_global"], + "properties": { + "_global": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record issuance refused the request"}, + "error": {"const": "commitment_linkage_unavailable"}, + "error_code": {"const": "COMMITMENT_LINKAGE_UNAVAILABLE"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["_global"], + "properties": { + "_global": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + { + "allOf": [ + {"$ref": "#/components/schemas/ProcessRecordVerificationFailure"}, + { + "properties": {"message": {"const": "self-verification of the assembled bundle failed"}} + } + ] + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"} + ] + } + } + } + }, + "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "429": {"$ref": "#/components/responses/RateLimited"}, + "500": {"$ref": "#/components/responses/InternalError"}, + "503": { + "description": "Issuance could not be completed or confirmed.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Internal server error"}, + "error": {"const": "Internal server error"}, + "error_code": { + "type": "string", + "enum": [ + "AUTH_BACKEND_UNAVAILABLE", + "SNAPSHOT_ISOLATION_FAILED", + "STORAGE_UNAVAILABLE", + "UNCLASSIFIED_INTEGRITY_VIOLATION", + "UNKNOWN_STREAM_ID", + "UNKNOWN_STEP_ID", + "UNKNOWN_OBSERVATION_BASIS", + "UNKNOWN_REGISTERED_KEY", + "EMPTY_REGISTERED_VALUES", + "NON_INTEGER_REGISTERED_VALUE", + "NUMERIC_BOUND_VIOLATION", + "RECEIPT_PROJECTION_TOO_LARGE", + "ISSUANCE_RECORD_CORRUPT", + "FRONT_CLAIM_SUPPLEMENT_CORRUPT", + "ISSUANCE_RECONCILIATION_FAILED", + "ISSUANCE_RECORD_TOO_LARGE", + "COMMITMENT_LINKAGE_CORRUPT", + "DEDICATED_ISSUER_KEY_ABSENT", + "TEST_SIGNER_FORBIDDEN_IN_PRODUCTION", + "ISSUER_SIGNER_UNAVAILABLE", + "DEDICATED_ANCHOR_KEY_ABSENT", + "TRUST_STATUS_SNAPSHOT_INVALID", + "TRUST_STATUS_SOURCE_UNAVAILABLE", + "ANCHOR_KEY_NOT_DISTINCT_FROM_ISSUER_KEY", + "MALFORMED_OPAQUE_REF" + ] + } + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unavailable"} + ] + } + } + } + } + } + } + }, + "/api/v1/projects/{project_id}/process-records/verify": { + "post": { + "operationId": "certification_process_record.verify_process_record", + "summary": "Verify a process record certificate", + "description": "Checks a supplied bundle against the caller's independent pins and trust-status evidence without reading a stored issuance.", + "x-asserted-against-backend": false, + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "The project id.", + "schema": {"type": "string", "minLength": 1, "maxLength": 128} + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": {"schema": {"allOf": [{"$ref": "./process_record_request_schema.json#/definitions/VerifyProcessRecordRequest"}]}} + } + }, + "responses": { + "200": { + "description": "Bundle and trust status verified.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/VerifyProcessRecordResponse"}}} + }, + "400": { + "description": "Request body or verification inputs are malformed.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/UnsupportedContentType"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "INVALID_BODY"}, + "error_code": {"const": "INVALID_BODY"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "MISSING_FIELD"}, + "error_code": {"const": "MISSING_FIELD"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request could not be processed"}, + "error": {"const": "invalid_request"}, + "error_code": {"const": "invalid_request"} + } + } + ] + } + }, + "application/problem+json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/ProviderCredentialRejected"}} + } + }, + "401": {"$ref": "#/components/responses/Unauthorized"}, + "403": { + "description": "The caller lacks read access.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectAccessDenied"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextForbidden"}, + {"$ref": "../closed_request_error_schema.json#/definitions/OptimizationOnly"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "Missing required permissions: harness.read"}, + "error": {"const": "INSUFFICIENT_PERMISSIONS"}, + "error_code": {"const": "INSUFFICIENT_PERMISSIONS"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["missing_permissions"], + "properties": { + "missing_permissions": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/EntitlementRequired"} + ] + } + } + } + }, + "404": { + "description": "No accessible matching scope was found.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Resource not found"}, + "error": {"const": "Not found"}, + "error_code": {"const": "NOT_FOUND"} + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectNotFound"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextNotFound"} + ] + } + } + } + }, + "422": { + "description": "Cryptographic, scope or trust-status verification failed.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "allOf": [ + {"$ref": "#/components/schemas/ProcessRecordVerificationFailure"}, + { + "properties": {"message": {"const": "verification failed"}} + } + ] + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"} + ] + } + } + } + }, + "413": {"$ref": "#/components/responses/PayloadTooLarge"}, + "429": {"$ref": "#/components/responses/RateLimited"}, + "500": {"$ref": "#/components/responses/InternalError"}, + "503": { + "description": "Authentication is temporarily unavailable.", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Internal server error"}, + "error": {"const": "Internal server error"}, + "error_code": {"type": "string", "enum": ["AUTH_BACKEND_UNAVAILABLE"]} + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/Unavailable"} + ] + } + } + } + } + } + } + } + }, + "components": { + "responses": { + "PayloadTooLarge": { + "description": "The request exceeds the size limit.", + "content": { + "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/RequestTooLarge"}} + } + }, + "RateLimited": { + "description": "The request exceeded a rate limit.", + "content": { + "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/RateLimited"}} + } + }, + "Unprocessable": { + "description": "Request validation or scope resolution failed.", + "content": { + "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unprocessable"}} + } + }, + "Unauthorized": { + "description": "Authentication required.", + "content": { + "application/json": {"schema": {"$ref": "../closed_request_error_schema.json#/definitions/Unauthorized"}} + } + }, + "WriteForbidden": { + "description": "The caller lacks write access to the project.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordWriteForbidden"}}} + }, + "NotFound": { + "description": "No accessible matching scope was found.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordScopeNotFound"}}} + }, + "InternalError": { + "description": "An unexpected server error occurred.", + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordInternal"}}} + } + }, + "schemas": { + "PrepareProcessRecordResponse": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "data"], + "properties": { + "success": {"const": true}, + "message": { + "type": "string", + "enum": ["build session ready for issuance", "build session has no visible receipts; finalize will refuse"] + }, + "data": { + "type": "object", + "additionalProperties": false, + "required": ["process_record_ref", "status", "stream_counts", "present_count", "issuable"], + "properties": { + "process_record_ref": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"}, + "status": {"const": "prepared"}, + "stream_counts": { + "type": "object", + "additionalProperties": false, + "required": ["decision_stream", "receipt_event_stream", "transition_stream"], + "properties": { + "decision_stream": {"type": "integer", "minimum": 0}, + "receipt_event_stream": {"type": "integer", "minimum": 0}, + "transition_stream": {"type": "integer", "minimum": 0} + } + }, + "present_count": {"type": "integer", "minimum": 0, "maximum": 5}, + "issuable": {"type": "boolean"} + } + } + }, + "if": {"properties": {"data": {"properties": {"present_count": {"const": 0}}}}}, + "then": { + "properties": { + "message": {"const": "build session has no visible receipts; finalize will refuse"}, + "data": {"properties": {"issuable": {"const": false}}} + } + }, + "else": { + "properties": {"message": {"const": "build session ready for issuance"}, "data": {"properties": {"issuable": {"const": true}}}} + } + }, + "FinalizeProcessRecordResponse": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "data"], + "properties": { + "success": {"const": true}, + "message": {"const": "process record certificate minted"}, + "data": {"$ref": "./process_record_v1_schema.json"}, + "commitment_linkage": {"$ref": "./commitment_linkage_v1_schema.json#/definitions/CommitmentLinkageEnvelopeV1"} + } + }, + "RetrieveProcessRecordResponse": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "data"], + "properties": { + "success": {"const": true}, + "message": {"const": "process record certificate"}, + "data": {"$ref": "./process_record_v1_schema.json"}, + "front_claim": {"$ref": "#/components/schemas/FrontClaimCompanion"}, + "commitment_linkage": {"$ref": "./commitment_linkage_v1_schema.json#/definitions/CommitmentLinkageEnvelopeV1"} + } + }, + "VerifyProcessRecordResponse": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "data"], + "properties": { + "success": {"const": true}, + "message": {"const": "verification verdict"}, + "data": { + "type": "object", + "additionalProperties": false, + "required": [ + "valid", + "code", + "trust_status_evidence", + "present_count", + "missing_count", + "receipt_count", + "receipt_bundle_digest", + "process_report_digest", + "unsigned_manifest_digest" + ], + "properties": { + "valid": {"const": true}, + "code": {"const": "PROCESS_RECORD_VERIFIED"}, + "trust_status_evidence": {"const": "checked_active"}, + "present_count": {"type": "integer", "minimum": 0, "maximum": 5}, + "missing_count": {"type": "integer", "minimum": 0, "maximum": 5}, + "receipt_count": {"type": "integer", "minimum": 0}, + "receipt_bundle_digest": {"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}, + "process_report_digest": {"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}, + "unsigned_manifest_digest": {"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"} + } + } + } + }, + "FrontClaimCompanion": { + "description": "Optional unsigned assessment delivered beside the signed certificate bundle. Its absence is explicit when the assessment is served but was never retained.", + "type": "object", + "additionalProperties": false, + "required": [ + "supplement_present", + "assessment_state", + "outcome", + "headline", + "capture_basis", + "exhaustive_inventory", + "disclosures" + ], + "properties": { + "supplement_present": {"type": "boolean"}, + "assessment_state": {"type": "string", "minLength": 1}, + "outcome": { + "enum": [ + "non_dominated_within_scope", + "dominated_within_scope", + "no_comparable_peers", + "candidate_not_comparable", + "candidate_not_retrievable", + "not_assessed" + ] + }, + "headline": {"type": "string", "minLength": 1}, + "capture_basis": {"type": ["string", "null"]}, + "exhaustive_inventory": {"type": "boolean"}, + "disclosures": { + "type": "object", + "additionalProperties": false, + "required": ["unsigned_companion", "digest_scope", "bounded_claim", "capture_basis"], + "properties": { + "unsigned_companion": {"type": "string", "minLength": 1}, + "digest_scope": {"type": "string", "minLength": 1}, + "bounded_claim": {"type": "string", "minLength": 1}, + "capture_basis": {"type": "string", "minLength": 1} + } + }, + "not_assessed": { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"type": "string", "minLength": 1}, + "detail": {"type": "string", "minLength": 1}, + "record": {"type": ["object", "null"]} + } + }, + "schema_version": {"type": "string", "minLength": 1}, + "binding": { + "type": "object", + "additionalProperties": false, + "required": ["process_record_ref", "unsigned_manifest_digest", "computed_at"], + "properties": { + "process_record_ref": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"}, + "unsigned_manifest_digest": {"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}, + "computed_at": {"type": "string", "format": "date-time"} + } + }, + "selection_binding": { + "type": "object", + "additionalProperties": false, + "required": [ + "experiment_run_id", + "experiment_run_id_source", + "winner_trial_id", + "eligible_trial_ids_digest", + "eligible_trial_ids_digest_scope", + "selection_receipt_store", + "selection_receipt_validated_against", + "candidate_rows_store", + "stores_reconciled" + ], + "properties": { + "experiment_run_id": {"type": ["string", "null"]}, + "experiment_run_id_source": {"type": "string", "minLength": 1}, + "winner_trial_id": {"type": ["string", "null"]}, + "eligible_trial_ids_digest": {"type": ["string", "null"]}, + "eligible_trial_ids_digest_scope": {"type": "string", "minLength": 1}, + "selection_receipt_store": {"type": "string", "minLength": 1}, + "selection_receipt_validated_against": {"type": "string", "minLength": 1}, + "candidate_rows_store": {"type": "string", "minLength": 1}, + "stores_reconciled": {"const": false} + } + }, + "authentication": { + "type": "object", + "additionalProperties": false, + "required": ["inside_signed_v1_bundle", "covered_by_v1_issuer_signature", "verified_by_v1_standalone_verifier", "bound_by"], + "properties": { + "inside_signed_v1_bundle": {"const": false}, + "covered_by_v1_issuer_signature": {"const": false}, + "verified_by_v1_standalone_verifier": {"const": false}, + "bound_by": {"type": "string", "minLength": 1} + } + }, + "front_status": {"type": "string", "minLength": 1}, + "withheld_reason": {"type": ["string", "null"]}, + "candidate_id": {"type": ["string", "null"]}, + "dominated_by": {"type": "array", "items": {"type": "string", "minLength": 1}}, + "not_comparable": {"type": "array", "items": {"type": ["object", "string"]}}, + "not_comparable_count": {"type": "integer", "minimum": 0}, + "objectives": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "objective_id", + "direction", + "registration", + "measurement_scope", + "metric_key", + "unit", + "input_representation", + "declaration_source" + ], + "properties": { + "objective_id": {"type": ["string", "null"]}, + "direction": {"type": ["string", "null"]}, + "registration": {"type": ["string", "null"]}, + "measurement_scope": {"type": ["string", "null"]}, + "metric_key": {"type": ["string", "null"]}, + "unit": {"type": ["string", "null"]}, + "input_representation": {"type": ["string", "null"]}, + "declaration_source": {"type": ["string", "null"]} + } + } + }, + "objectives_source": {"type": ["object", "string", "null"]}, + "value_resolution": {"type": ["object", "null"]}, + "set_completeness": { + "type": "object", + "additionalProperties": false, + "required": ["named", "resolved", "unresolved_ids", "attested"], + "properties": { + "named": {"type": "integer", "minimum": 0}, + "resolved": {"type": "integer", "minimum": 0}, + "unresolved_ids": {"type": "array", "items": {"type": "string", "minLength": 1}}, + "attested": {"type": "boolean"} + } + }, + "population": { + "type": "object", + "additionalProperties": false, + "required": [ + "scope", + "population_source", + "captured_at", + "scope_row_count", + "captured_member_count", + "unnamed_captured_count" + ], + "properties": { + "scope": {"type": "string", "minLength": 1}, + "population_source": {"type": "string", "minLength": 1}, + "captured_at": {"type": "string", "minLength": 1}, + "scope_row_count": {"type": "integer", "minimum": 0}, + "captured_member_count": {"type": "integer", "minimum": 0}, + "unnamed_captured_count": {"type": "integer", "minimum": 0} + } + }, + "member_count": {"type": "integer", "minimum": 0}, + "members": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "record_id", + "status", + "named_in_receipt", + "values", + "omitted_objectives", + "scores_source", + "scores_source_wording", + "value_bases", + "metric_source_conflicts", + "source_boundary" + ], + "properties": { + "record_id": {"type": ["string", "null"]}, + "status": {"type": ["string", "null"]}, + "named_in_receipt": {"type": "boolean"}, + "values": {"type": ["object", "null"]}, + "omitted_objectives": {"type": ["array", "object", "null"]}, + "scores_source": {"type": ["string", "null"]}, + "scores_source_wording": {"type": ["string", "null"]}, + "value_bases": {"type": ["object", "null"]}, + "metric_source_conflicts": {"type": "object"}, + "source_boundary": {"type": ["object", "null"]} + } + } + } + }, + "if": {"properties": {"supplement_present": {"const": true}}}, + "then": {"required": ["schema_version", "binding", "selection_binding", "authentication"]}, + "else": { + "required": ["not_assessed"], + "properties": {"outcome": {"const": "not_assessed"}, "capture_basis": {"const": null}, "exhaustive_inventory": {"const": false}} + } + }, + "ProcessRecordStorageConflict": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "session_project_conflict"}, + "error_code": {"const": "SESSION_PROJECT_CONFLICT"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "immutable_row"}, + "error_code": {"const": "IMMUTABLE_ROW"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "duplicate_seq"}, + "error_code": {"const": "DUPLICATE_SEQ"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "duplicate_receipt_ref"}, + "error_code": {"const": "DUPLICATE_RECEIPT_REF"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "constraint_violation"}, + "error_code": {"const": "CONSTRAINT_VIOLATION"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "stream_overflow"}, + "error_code": {"const": "STREAM_OVERFLOW"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "lineage_scope_mismatch"}, + "error_code": {"const": "LINEAGE_SCOPE_MISMATCH"} + } + } + ] + }, + "ProcessRecordInternal": {"$ref": "../closed_request_error_schema.json#/definitions/InternalError"}, + "ProcessRecordWriteForbidden": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectAccessDenied"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextForbidden"}, + {"$ref": "../closed_request_error_schema.json#/definitions/OptimizationOnly"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "no project context bound to this request"}, + "error": {"const": "PROJECT_CONTEXT_REQUIRED"}, + "error_code": {"const": "PROJECT_CONTEXT_REQUIRED"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "Missing required permissions: harness.write"}, + "error": {"const": "INSUFFICIENT_PERMISSIONS"}, + "error_code": {"const": "INSUFFICIENT_PERMISSIONS"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["missing_permissions"], + "properties": { + "missing_permissions": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "project access forbidden"}, + "error": {"const": "project access forbidden"}, + "error_code": {"const": "PROJECT_FORBIDDEN"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "tenant_context_missing"}, + "error_code": {"const": "TENANT_CONTEXT_MISSING"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "tenant_binding_failed"}, + "error_code": {"const": "TENANT_BINDING_FAILED"} + } + }, + {"$ref": "../closed_request_error_schema.json#/definitions/EntitlementRequired"} + ] + }, + "ProcessRecordScopeNotFound": { + "anyOf": [ + {"$ref": "../closed_request_error_schema.json#/definitions/ProjectNotFound"}, + {"$ref": "../closed_request_error_schema.json#/definitions/ContextNotFound"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Resource not found"}, + "error": {"const": "Not found"}, + "error_code": {"const": "NOT_FOUND"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "unknown_scope_reference"}, + "error_code": {"const": "UNKNOWN_SCOPE_REFERENCE"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "process record storage refused the request"}, + "error": {"const": "lineage_unmapped"}, + "error_code": {"const": "LINEAGE_UNMAPPED"} + } + } + ] + }, + "ProcessRecordVerificationFailure": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": { + "enum": [ + "verification failed", + "self-verification of the assembled bundle failed", + "checked re-verification of the stored certificate failed" + ] + }, + "error": {"type": "string"}, + "error_code": {"type": "string"}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["_global"], + "properties": {"_global": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}}} + } + }, + "oneOf": [ + { + "properties": {"error": {"const": "ASSERTION_DIGEST_MISMATCH"}, "error_code": {"const": "ASSERTION_DIGEST_MISMATCH"}} + }, + { + "properties": {"error": {"const": "BASE_CERTIFICATE_INVALID"}, "error_code": {"const": "BASE_CERTIFICATE_INVALID"}} + }, + { + "properties": {"error": {"const": "BASE_MANIFEST_DIGEST_MISMATCH"}, "error_code": {"const": "BASE_MANIFEST_DIGEST_MISMATCH"}} + }, + {"properties": {"error": {"const": "BUNDLE_SHAPE"}, "error_code": {"const": "BUNDLE_SHAPE"}}}, + {"properties": {"error": {"const": "CANONICALIZATION"}, "error_code": {"const": "CANONICALIZATION"}}}, + {"properties": {"error": {"const": "CAPTURE_POLICY_MISMATCH"}, "error_code": {"const": "CAPTURE_POLICY_MISMATCH"}}}, + {"properties": {"error": {"const": "CERTIFICATE_REVOKED"}, "error_code": {"const": "CERTIFICATE_REVOKED"}}}, + {"properties": {"error": {"const": "CLAIM_NOT_VERIFIED"}, "error_code": {"const": "CLAIM_NOT_VERIFIED"}}}, + { + "properties": {"error": {"const": "CLAIM_SUPPORT_ROW_MISMATCH"}, "error_code": {"const": "CLAIM_SUPPORT_ROW_MISMATCH"}} + }, + {"properties": {"error": {"const": "COMMITMENT_REF_MISMATCH"}, "error_code": {"const": "COMMITMENT_REF_MISMATCH"}}}, + {"properties": {"error": {"const": "CONTEXT"}, "error_code": {"const": "CONTEXT"}}}, + { + "properties": {"error": {"const": "ISSUER_SIGNATURE_INVALID"}, "error_code": {"const": "ISSUER_SIGNATURE_INVALID"}} + }, + {"properties": {"error": {"const": "KEY_REVOKED"}, "error_code": {"const": "KEY_REVOKED"}}}, + {"properties": {"error": {"const": "KEY_RING_MISMATCH"}, "error_code": {"const": "KEY_RING_MISMATCH"}}}, + { + "properties": {"error": {"const": "RECEIPT_BUNDLE_DIGEST_MISMATCH"}, "error_code": {"const": "RECEIPT_BUNDLE_DIGEST_MISMATCH"}} + }, + {"properties": {"error": {"const": "RECEIPT_DIGEST_MISMATCH"}, "error_code": {"const": "RECEIPT_DIGEST_MISMATCH"}}}, + {"properties": {"error": {"const": "RECEIPT_DUPLICATE"}, "error_code": {"const": "RECEIPT_DUPLICATE"}}}, + {"properties": {"error": {"const": "RECEIPT_LIMIT_EXCEEDED"}, "error_code": {"const": "RECEIPT_LIMIT_EXCEEDED"}}}, + {"properties": {"error": {"const": "RECEIPT_ORDER"}, "error_code": {"const": "RECEIPT_ORDER"}}}, + {"properties": {"error": {"const": "RECEIPT_SIZE_EXCEEDED"}, "error_code": {"const": "RECEIPT_SIZE_EXCEEDED"}}}, + {"properties": {"error": {"const": "RECEIPT_STREAM_MISMATCH"}, "error_code": {"const": "RECEIPT_STREAM_MISMATCH"}}}, + {"properties": {"error": {"const": "REPORT_MISMATCH"}, "error_code": {"const": "REPORT_MISMATCH"}}}, + { + "properties": {"error": {"const": "REVOCATION_STATUS_UNAVAILABLE"}, "error_code": {"const": "REVOCATION_STATUS_UNAVAILABLE"}} + }, + {"properties": {"error": {"const": "SCHEMA"}, "error_code": {"const": "SCHEMA"}}}, + {"properties": {"error": {"const": "SCHEMA_DEPENDENCY"}, "error_code": {"const": "SCHEMA_DEPENDENCY"}}}, + {"properties": {"error": {"const": "SCOPE_MISMATCH"}, "error_code": {"const": "SCOPE_MISMATCH"}}}, + {"properties": {"error": {"const": "STREAM_INDEX_MISMATCH"}, "error_code": {"const": "STREAM_INDEX_MISMATCH"}}}, + {"properties": {"error": {"const": "STRICT_INTEGER"}, "error_code": {"const": "STRICT_INTEGER"}}}, + {"properties": {"error": {"const": "TRUST_ANCHOR_MISMATCH"}, "error_code": {"const": "TRUST_ANCHOR_MISMATCH"}}}, + {"properties": {"error": {"const": "TRUST_POLICY_MISMATCH"}, "error_code": {"const": "TRUST_POLICY_MISMATCH"}}}, + { + "properties": {"error": {"const": "TRUST_STATUS_DIGEST_MISMATCH"}, "error_code": {"const": "TRUST_STATUS_DIGEST_MISMATCH"}} + }, + {"properties": {"error": {"const": "TRUST_STATUS_SCHEMA"}, "error_code": {"const": "TRUST_STATUS_SCHEMA"}}}, + {"properties": {"error": {"const": "TRUST_STATUS_SHAPE"}, "error_code": {"const": "TRUST_STATUS_SHAPE"}}}, + { + "properties": {"error": {"const": "TRUST_STATUS_SIGNATURE_INVALID"}, "error_code": {"const": "TRUST_STATUS_SIGNATURE_INVALID"}} + }, + { + "properties": { + "error": {"const": "UNSIGNED_MANIFEST_DIGEST_MISMATCH"}, + "error_code": {"const": "UNSIGNED_MANIFEST_DIGEST_MISMATCH"} + } + }, + { + "properties": {"error": {"const": "UNSIGNED_MANIFEST_MISMATCH"}, "error_code": {"const": "UNSIGNED_MANIFEST_MISMATCH"}} + }, + {"properties": {"error": {"const": "VERIFICATION_FAILED"}, "error_code": {"const": "VERIFICATION_FAILED"}}} + ] + } + } + } +} diff --git a/traigent_schema/schemas/closed_request_error_schema.json b/traigent_schema/schemas/closed_request_error_schema.json new file mode 100644 index 00000000..9bb6408f --- /dev/null +++ b/traigent_schema/schemas/closed_request_error_schema.json @@ -0,0 +1,474 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/closed_request_error_schema.json", + "title": "Closed Request Error Bodies", + "description": "Fixed response bodies for request handling and project resolution.", + "type": "object", + "additionalProperties": false, + "definitions": { + "ProjectNotFound": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "project not found"}, + "error": {"const": "PROJECT_NOT_FOUND"}, + "error_code": {"enum": ["PROJECT_NOT_FOUND"]} + } + }, + "ProjectAccessDenied": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": { + "enum": [ + "API key is not scoped to the requested project", + "Authenticated principal is not scoped to the requested project", + "API key project scope is invalid", + "Authenticated principal project scope is invalid", + "credential-bound project is invalid" + ] + }, + "error": {"const": "PROJECT_ACCESS_DENIED"}, + "error_code": {"enum": ["PROJECT_ACCESS_DENIED"]} + } + }, + "ContextNotFound": { + "anyOf": [ + { + "allOf": [ + {"$ref": "./fleet_observe/fleet_observe_responses_schema.json#/definitions/ErrorBody"}, + {"properties": {"error": {"const": "not_found"}}} + ] + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Resource not found"}, + "error": {"const": "RESOURCE_NOT_FOUND"}, + "error_code": {"enum": ["RESOURCE_NOT_FOUND"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": { + "enum": [ + "Tenant context is invalid for this request", + "credential-bound tenant does not exist", + "requested tenant does not exist", + "configured deployment tenant does not exist" + ] + }, + "error": {"const": "TENANT_NOT_FOUND"}, + "error_code": {"enum": ["TENANT_NOT_FOUND"]} + } + } + ] + }, + "RouteNotFound": { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Not Found"}, + "code": {"enum": ["NOT_FOUND"]} + } + }, + "BadRequest": { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Bad Request"}, + "code": {"enum": ["BAD_REQUEST"]} + } + }, + "PayloadTooLarge": { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Request Entity Too Large"}, + "code": {"enum": ["REQUEST_ENTITY_TOO_LARGE"]} + } + }, + "RequestTooLarge": { + "anyOf": [ + {"$ref": "./analytics/body_too_large_schema.json"}, + {"$ref": "./analytics/payload_too_large_schema.json"}, + {"$ref": "#/definitions/PayloadTooLarge"} + ] + }, + "Unauthorized": { + "anyOf": [ + {"$ref": "./fleet_observe/fleet_observe_responses_schema.json#/definitions/AuthErrorBody"}, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Unauthorized"}, + "code": {"enum": ["UNAUTHORIZED"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Authentication required"}, + "error": {"const": "authenticated user no longer exists"}, + "error_code": {"enum": ["AUTHENTICATION_REQUIRED"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": { + "enum": [ + "Tenant context is invalid for this request", + "token tenant claim does not match requested tenant", + "credential tenant does not match deployment tenant" + ] + }, + "error": {"const": "INVALID_TOKEN"}, + "error_code": {"enum": ["INVALID_TOKEN"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Authentication required"}, + "error": {"const": "CSRF_VALIDATION_FAILED"}, + "error_code": {"const": "CSRF_VALIDATION_FAILED"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Session ended after a period of inactivity."}, + "error": {"const": "SESSION_IDLE_EXPIRED"}, + "error_code": {"const": "SESSION_IDLE_EXPIRED"} + } + } + ] + }, + "EntitlementRequired": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "Your access period has ended. Choose a plan to continue using Traigent."}, + "error": {"enum": ["entitlement_required"]}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["reason"], + "properties": {"reason": {"enum": ["access_period_ended", "no_active_plan"]}} + } + } + }, + "OptimizationOnly": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "This workspace is limited to optimization; this operation is not available."}, + "error": {"const": "optimization_only"}, + "error_code": {"enum": ["optimization_only"]} + } + }, + "RateLimited": { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "Rate limit exceeded"}, + "error": {"const": "Too many requests"}, + "error_code": {"enum": ["RATE_LIMIT_EXCEEDED"]}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["scope", "retry_after"], + "properties": { + "scope": {"enum": ["api", "tenant", "global"]}, + "retry_after": {"type": "integer", "minimum": 1} + } + } + } + }, + "Unavailable": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Internal server error"}, + "error": {"const": "Internal server error"}, + "error_code": { + "enum": [ + "AUTH_BACKEND_UNAVAILABLE", + "RATE_LIMIT_UNAVAILABLE", + "TENANT_CONTEXT_UNAVAILABLE", + "TENANT_OVERRIDE_AUDIT_UNAVAILABLE", + "TENANT_PROVISION_FAILED", + "SESSION_ACTIVITY_UNAVAILABLE" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Access status is temporarily unavailable"}, + "error": {"const": "ACCESS_DECISION_UNAVAILABLE"}, + "error_code": {"enum": ["ACCESS_DECISION_UNAVAILABLE"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Internal server error"}, + "code": {"enum": ["INTERNAL_ERROR"]} + } + } + ] + }, + "InternalError": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Internal server error"}, + "error": {"const": "Internal server error"}, + "error_code": { + "enum": [ + "AUTHENTICATION_ERROR", + "INTERNAL_ERROR", + "INTERNAL_SERVER_ERROR", + "SECURITY_MIDDLEWARE_ERROR" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Internal server error"}, + "code": {"enum": ["INTERNAL_ERROR"]} + } + }, + {"$ref": "./analytics/middleware_message_error_schema.json"} + ] + }, + "ContextForbidden": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": { + "enum": [ + "Tenant context is invalid for this request", + "requested tenant is not accessible to this user" + ] + }, + "error": {"const": "TENANT_ACCESS_DENIED"}, + "error_code": {"enum": ["TENANT_ACCESS_DENIED"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": { + "enum": [ + "Tenant context is invalid for this request", + "Single sign-on is required for this tenant" + ] + }, + "error": {"const": "SSO_REQUIRED"}, + "error_code": {"enum": ["SSO_REQUIRED"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Forbidden"}, + "code": {"enum": ["FORBIDDEN"]} + } + } + ] + }, + "Unprocessable": { + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "required": ["success", "error", "code"], + "properties": { + "success": {"const": false}, + "error": {"const": "Unprocessable Entity"}, + "code": {"enum": ["UNPROCESSABLE_ENTITY"]} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"enum": ["Tenant context is invalid for this request", "tenant context required"]}, + "error": {"const": "TENANT_CONTEXT_REQUIRED"}, + "error_code": {"enum": ["TENANT_CONTEXT_REQUIRED"]}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["_global"], + "properties": { + "_global": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"const": "Invalid request"}} + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": {"const": "Request body is nested too deeply"}, + "error": {"const": "body: Request body is nested too deeply"}, + "error_code": {"enum": ["VALIDATION_ERROR"]}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["body"], + "properties": { + "body": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": {"const": "Request body is nested too deeply"} + } + } + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code", "details"], + "properties": { + "success": {"const": false}, + "message": { + "const": "Request contains a string with a NUL character or an unpaired surrogate, which cannot be stored" + }, + "error": { + "const": "body: Request contains a string with a NUL character or an unpaired surrogate, which cannot be stored" + }, + "error_code": {"enum": ["VALIDATION_ERROR"]}, + "details": { + "type": "object", + "additionalProperties": false, + "required": ["body"], + "properties": { + "body": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": { + "const": "Request contains a string with a NUL character or an unpaired surrogate, which cannot be stored" + } + } + } + } + } + } + ] + }, + "ProviderCredentialRejected": { + "allOf": [ + {"$ref": "./agents/agent_import_credential_error_schema.json"}, + { + "properties": { + "message": { + "const": "Provider credentials are not accepted by the API. Configure them in the deployment environment or secret storage." + }, + "detail": { + "const": "Provider credentials are not accepted by the API. Configure them in the deployment environment or secret storage." + } + } + } + ] + }, + "UnsupportedContentType": { + "allOf": [ + {"$ref": "./analytics/unsupported_content_type_schema.json"}, + { + "properties": { + "allowed_content_types": { + "items": { + "enum": [ + "application/json", + "application/x-protobuf", + "application/x-www-form-urlencoded", + "multipart/form-data", + "text/plain" + ] + } + } + } + } + ] + } + } +} diff --git a/traigent_schema/schemas/mep_endpoints.json b/traigent_schema/schemas/mep_endpoints.json index 8ac2a20f..ed734421 100644 --- a/traigent_schema/schemas/mep_endpoints.json +++ b/traigent_schema/schemas/mep_endpoints.json @@ -132,6 +132,16 @@ "description": "Content-free Agent Certificate v0 build, binding, issuance, retrieval, and verification-material routes.", "paths_file": "./certification/certification_endpoints_v0.json" }, + { + "name": "Certificate Build Sessions", + "description": "Project-scoped certificate build-session abandonment and issuance readiness.", + "paths_file": "./certification/certificate_build_sessions_endpoints.json" + }, + { + "name": "Process Records", + "description": "Project-scoped process record preparation, issuance, retrieval and verification.", + "paths_file": "./certification/process_records_endpoints.json" + }, { "name": "SmartOps Planner V2", "description": "Additive Planner V2 decision, receipt, lifecycle, private resolution, and service-only shadow routes.", From e47ced4587c22d2233e5cadf0153351550da2a42 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 03:38:15 +0200 Subject: [PATCH 08/20] fix(contract): declare the session-expiry 401 variants; closed public codes and text for process-record retrieve and conflicts Co-Authored-By: Claude Opus 5.5 --- parity/python-js-sdk.json | 2 +- .../process_records_endpoints.json | 776 ++++++++++++++---- .../schemas/closed_request_error_schema.json | 22 + 3 files changed, 630 insertions(+), 170 deletions(-) diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index fafed836..1872ad2d 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,7 +399,7 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "946fb5f22466ee31684503f83a5edf5f32306e8f252122af238c54085687ae68", + "lastSchemaFileSha": "f8019708a8f4a2a3d9a8937d2c98ee5fbcbc833c698c711b9d7c7a44efc2f500", "schemaFileCount": 681, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } diff --git a/traigent_schema/schemas/certification/process_records_endpoints.json b/traigent_schema/schemas/certification/process_records_endpoints.json index b118e57c..8da4d70b 100644 --- a/traigent_schema/schemas/certification/process_records_endpoints.json +++ b/traigent_schema/schemas/certification/process_records_endpoints.json @@ -87,7 +87,7 @@ "422": {"$ref": "#/components/responses/Unprocessable"}, "409": { "description": "The requested receipt snapshot conflicts with current state.", - "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordStorageConflict"}}} + "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordConflict"}}} }, "413": {"$ref": "#/components/responses/PayloadTooLarge"}, "429": {"$ref": "#/components/responses/RateLimited"}, @@ -110,9 +110,7 @@ "type": "string", "enum": [ "AUTH_BACKEND_UNAVAILABLE", - "SNAPSHOT_ISOLATION_FAILED", - "STORAGE_UNAVAILABLE", - "UNCLASSIFIED_INTEGRITY_VIOLATION", + "PROCESS_RECORD_UNAVAILABLE", "UNKNOWN_STREAM_ID", "UNKNOWN_STEP_ID", "UNKNOWN_OBSERVATION_BASIS", @@ -246,7 +244,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request refused"}, "error": {"const": "tenant_context_missing"}, "error_code": {"const": "TENANT_CONTEXT_MISSING"} } @@ -257,7 +255,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request refused"}, "error": {"const": "tenant_binding_failed"}, "error_code": {"const": "TENANT_BINDING_FAILED"} } @@ -346,9 +344,7 @@ "type": "string", "enum": [ "AUTH_BACKEND_UNAVAILABLE", - "SNAPSHOT_ISOLATION_FAILED", - "STORAGE_UNAVAILABLE", - "UNCLASSIFIED_INTEGRITY_VIOLATION", + "PROCESS_RECORD_UNAVAILABLE", "UNKNOWN_STREAM_ID", "UNKNOWN_STEP_ID", "UNKNOWN_OBSERVATION_BASIS", @@ -379,7 +375,7 @@ "post": { "operationId": "certification_process_record.finalize_process_record", "summary": "Issue a process record certificate", - "description": "Issues and stores a signed certificate for the named build session. After an ambiguous storage failure, retrieve the record before retrying.", + "description": "Issues and stores a signed certificate for the named build session. After an ambiguous failure, retrieve the record before retrying.", "x-asserted-against-backend": false, "parameters": [ { @@ -523,7 +519,7 @@ "application/json": { "schema": { "anyOf": [ - {"$ref": "#/components/schemas/ProcessRecordStorageConflict"}, + {"$ref": "#/components/schemas/ProcessRecordConflict"}, { "type": "object", "additionalProperties": false, @@ -671,9 +667,7 @@ "type": "string", "enum": [ "AUTH_BACKEND_UNAVAILABLE", - "SNAPSHOT_ISOLATION_FAILED", - "STORAGE_UNAVAILABLE", - "UNCLASSIFIED_INTEGRITY_VIOLATION", + "PROCESS_RECORD_UNAVAILABLE", "UNKNOWN_STREAM_ID", "UNKNOWN_STEP_ID", "UNKNOWN_OBSERVATION_BASIS", @@ -1031,7 +1025,7 @@ } }, "FrontClaimCompanion": { - "description": "Optional unsigned assessment delivered beside the signed certificate bundle. Its absence is explicit when the assessment is served but was never retained.", + "description": "Optional unsigned assessment delivered beside the signed certificate bundle. It is a closed projection of the retained assessment. Its absence is explicit when the assessment is served but was never retained.", "type": "object", "additionalProperties": false, "required": [ @@ -1045,7 +1039,7 @@ ], "properties": { "supplement_present": {"type": "boolean"}, - "assessment_state": {"type": "string", "minLength": 1}, + "assessment_state": {"enum": ["assessed", "not_assessed"]}, "outcome": { "enum": [ "non_dominated_within_scope", @@ -1057,112 +1051,84 @@ ] }, "headline": {"type": "string", "minLength": 1}, - "capture_basis": {"type": ["string", "null"]}, - "exhaustive_inventory": {"type": "boolean"}, + "capture_basis": {"enum": ["state_observed_at_issuance", null]}, + "exhaustive_inventory": {"const": false}, "disclosures": { "type": "object", "additionalProperties": false, "required": ["unsigned_companion", "digest_scope", "bounded_claim", "capture_basis"], "properties": { - "unsigned_companion": {"type": "string", "minLength": 1}, - "digest_scope": {"type": "string", "minLength": 1}, - "bounded_claim": {"type": "string", "minLength": 1}, - "capture_basis": {"type": "string", "minLength": 1} + "unsigned_companion": { + "const": "This assessment companion is retained with this issuance. It is outside the signed V1 bundle and is not authenticated by the V1 signature or verified by the V1 standalone verifier." + }, + "digest_scope": { + "const": "This digest covers the candidate-ID list only; it does not authenticate the selected winner, scores, or original selection event." + }, + "bounded_claim": { + "const": "This records reported measurements and selection; any comparison applies only to the enumerated comparable records under the declared policy. It certifies no performance threshold or deployment fitness." + }, + "capture_basis": { + "const": "This is state observed at issuance, not a reconstruction of the state at the original selection, and it is a scope rather than an inventory. The selection receipt and the candidate records come from independent sources that can disagree, so a binding to the receipt is not a binding to the records this comparison used. No reconciliation between them is attempted or implied." + } } }, - "not_assessed": { - "type": "object", - "additionalProperties": false, - "required": ["reason", "detail"], - "properties": { - "reason": {"type": "string", "minLength": 1}, - "detail": {"type": "string", "minLength": 1}, - "record": {"type": ["object", "null"]} - } + "not_assessed": {"$ref": "#/components/schemas/FrontClaimNotAssessed"}, + "schema_version": { + "enum": [ + "traigent.process_record.front_claim_supplement.v1", + "traigent.process_record.front_claim_supplement.v2", + "traigent.process_record.front_claim_supplement.v3" + ] }, - "schema_version": {"type": "string", "minLength": 1}, "binding": { "type": "object", "additionalProperties": false, "required": ["process_record_ref", "unsigned_manifest_digest", "computed_at"], "properties": { - "process_record_ref": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"}, - "unsigned_manifest_digest": {"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}, - "computed_at": {"type": "string", "format": "date-time"} + "process_record_ref": { + "allOf": [ + {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"}, + {"type": "string", "pattern": "^prr:[A-Za-z0-9_-]{16,128}(?![\\s\\S])"} + ] + }, + "unsigned_manifest_digest": {"$ref": "./process_record_request_schema.json#/definitions/Sha256Reference"}, + "computed_at": {"$ref": "#/components/schemas/FrontClaimTimestamp"} } }, - "selection_binding": { + "selection_binding": {"$ref": "#/components/schemas/FrontClaimSelectionBinding"}, + "authentication": { "type": "object", "additionalProperties": false, "required": [ - "experiment_run_id", - "experiment_run_id_source", - "winner_trial_id", - "eligible_trial_ids_digest", - "eligible_trial_ids_digest_scope", - "selection_receipt_store", - "selection_receipt_validated_against", - "candidate_rows_store", - "stores_reconciled" + "inside_signed_v1_bundle", + "covered_by_v1_issuer_signature", + "verified_by_v1_standalone_verifier", + "bound_by" ], - "properties": { - "experiment_run_id": {"type": ["string", "null"]}, - "experiment_run_id_source": {"type": "string", "minLength": 1}, - "winner_trial_id": {"type": ["string", "null"]}, - "eligible_trial_ids_digest": {"type": ["string", "null"]}, - "eligible_trial_ids_digest_scope": {"type": "string", "minLength": 1}, - "selection_receipt_store": {"type": "string", "minLength": 1}, - "selection_receipt_validated_against": {"type": "string", "minLength": 1}, - "candidate_rows_store": {"type": "string", "minLength": 1}, - "stores_reconciled": {"const": false} - } - }, - "authentication": { - "type": "object", - "additionalProperties": false, - "required": ["inside_signed_v1_bundle", "covered_by_v1_issuer_signature", "verified_by_v1_standalone_verifier", "bound_by"], "properties": { "inside_signed_v1_bundle": {"const": false}, "covered_by_v1_issuer_signature": {"const": false}, "verified_by_v1_standalone_verifier": {"const": false}, - "bound_by": {"type": "string", "minLength": 1} + "bound_by": {"const": "issuance_digest_verified_on_read"} } }, - "front_status": {"type": "string", "minLength": 1}, - "withheld_reason": {"type": ["string", "null"]}, - "candidate_id": {"type": ["string", "null"]}, - "dominated_by": {"type": "array", "items": {"type": "string", "minLength": 1}}, - "not_comparable": {"type": "array", "items": {"type": ["object", "string"]}}, - "not_comparable_count": {"type": "integer", "minimum": 0}, - "objectives": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "required": [ - "objective_id", - "direction", - "registration", - "measurement_scope", - "metric_key", - "unit", - "input_representation", - "declaration_source" - ], - "properties": { - "objective_id": {"type": ["string", "null"]}, - "direction": {"type": ["string", "null"]}, - "registration": {"type": ["string", "null"]}, - "measurement_scope": {"type": ["string", "null"]}, - "metric_key": {"type": ["string", "null"]}, - "unit": {"type": ["string", "null"]}, - "input_representation": {"type": ["string", "null"]}, - "declaration_source": {"type": ["string", "null"]} - } - } + "front_status": {"enum": ["asserted", "withheld_dominated", "not_assessed"]}, + "withheld_reason": { + "enum": [ + "dominated_by_member", + "candidate_not_comparable", + "no_comparable_peers", + "candidate_not_retrievable", + null + ] }, - "objectives_source": {"type": ["object", "string", "null"]}, - "value_resolution": {"type": ["object", "null"]}, + "candidate_id": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}]}, + "dominated_by": {"type": "array", "items": {"$ref": "#/components/schemas/FrontClaimRecordReference"}}, + "not_comparable": {"type": "array", "items": {"$ref": "#/components/schemas/FrontClaimRecordReference"}}, + "not_comparable_count": {"type": "integer", "minimum": 0}, + "objectives": {"type": "array", "items": {"$ref": "#/components/schemas/FrontClaimObjective"}}, + "objectives_source": {"enum": ["mutable_metadata", null]}, + "value_resolution": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimValueResolution"}, {"type": "null"}]}, "set_completeness": { "type": "object", "additionalProperties": false, @@ -1170,71 +1136,543 @@ "properties": { "named": {"type": "integer", "minimum": 0}, "resolved": {"type": "integer", "minimum": 0}, - "unresolved_ids": {"type": "array", "items": {"type": "string", "minLength": 1}}, - "attested": {"type": "boolean"} + "unresolved_ids": {"type": "array", "items": {"$ref": "#/components/schemas/FrontClaimRecordReference"}}, + "attested": {"const": false} } }, - "population": { + "population": {"$ref": "#/components/schemas/FrontClaimPopulation"}, + "member_count": {"type": "integer", "minimum": 0}, + "members": {"type": "array", "items": {"$ref": "#/components/schemas/FrontClaimMember"}} + }, + "allOf": [ + { + "anyOf": [ + { + "properties": { + "outcome": {"const": "non_dominated_within_scope"}, + "headline": { + "const": "No enumerated comparable record in the declared scope dominates the selected configuration on every declared objective." + } + } + }, + { + "properties": { + "outcome": {"const": "dominated_within_scope"}, + "headline": { + "const": "At least one enumerated record in the declared scope is at least as good on every declared objective and strictly better on one. The records are listed." + } + } + }, + { + "properties": { + "outcome": {"const": "no_comparable_peers"}, + "headline": { + "const": "No record other than the selected configuration carried every declared objective, so no comparison was performed." + } + } + }, + { + "properties": { + "outcome": {"const": "candidate_not_comparable"}, + "headline": { + "const": "The selected configuration does not carry every declared objective, so it could not be placed against the other records." + } + } + }, + { + "properties": { + "outcome": {"const": "candidate_not_retrievable"}, + "headline": { + "const": "The selection receipt named a configuration whose record no longer resolves, so no comparison was possible. Nothing is wrong with the objectives; the evidence for the selected configuration itself is gone." + } + } + }, + { + "properties": { + "outcome": {"const": "not_assessed"}, + "headline": { + "const": "No comparison was performed and none is claimed. The reason is recorded below." + } + } + } + ] + }, + { + "if": {"properties": {"assessment_state": {"const": "not_assessed"}}}, + "then": { + "required": ["not_assessed"], + "properties": {"outcome": {"const": "not_assessed"}, "capture_basis": {"const": null}} + }, + "else": {"not": {"required": ["not_assessed"]}} + } + ], + "if": {"properties": {"supplement_present": {"const": true}}}, + "then": { + "required": ["schema_version", "binding", "selection_binding", "authentication"], + "properties": {"not_assessed": {"properties": {"reason": {"not": {"const": "assessment_not_retained"}}}}} + }, + "else": { + "required": ["not_assessed"], + "properties": { + "assessment_state": {"const": "not_assessed"}, + "outcome": {"const": "not_assessed"}, + "capture_basis": {"const": null}, + "exhaustive_inventory": {"const": false}, + "not_assessed": {"properties": {"reason": {"const": "assessment_not_retained"}}} + } + } + }, + "FrontClaimRecordReference": { + "description": "A closed record reference: a UUID, a positive decimal ID, or trial_ followed by 16-64 lowercase hex.", + "type": "string", + "pattern": "^(?:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}|[1-9][0-9]{0,18}|trial_[0-9a-f]{16,64})(?![\\s\\S])" + }, + "FrontClaimObjectiveReference": { + "description": "A known metric label, or objective- for a custom objective.", + "type": "string", + "pattern": "^(?:accuracy|total_cost|cost|latency|objective-[1-9][0-9]{0,8})(?![\\s\\S])" + }, + "FrontClaimOmissionReason": { + "enum": ["metric_key_absent", "value_is_null", "value_is_bool", "value_not_numeric", "value_not_finite", "conversion_failed", "representation_undeclared", "representation_mismatch", "registered_bound_violation", "measurement_scope_mismatch", "measurement_scope_undeclared", "metric_source_conflict", "reported_count_invalid", "aggregation_semantics_undeclared"] + }, + "FrontClaimTimestamp": { + "type": "string", + "format": "date-time", + "maxLength": 20, + "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" + }, + "FrontClaimNotAssessed": { + "anyOf": [ + { "type": "object", "additionalProperties": false, - "required": [ - "scope", - "population_source", - "captured_at", - "scope_row_count", - "captured_member_count", - "unnamed_captured_count" - ], + "required": ["reason", "detail"], "properties": { - "scope": {"type": "string", "minLength": 1}, - "population_source": {"type": "string", "minLength": 1}, - "captured_at": {"type": "string", "minLength": 1}, - "scope_row_count": {"type": "integer", "minimum": 0}, - "captured_member_count": {"type": "integer", "minimum": 0}, - "unnamed_captured_count": {"type": "integer", "minimum": 0} + "reason": {"const": "no_experiment_run_reference"}, + "detail": { + "const": "No experiment run was named for this issuance, so no selection receipt or candidate records could be located." + }, + "record": {"type": "null"} } }, - "member_count": {"type": "integer", "minimum": 0}, - "members": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "required": [ - "record_id", - "status", - "named_in_receipt", - "values", - "omitted_objectives", - "scores_source", - "scores_source_wording", - "value_bases", - "metric_source_conflicts", - "source_boundary" - ], - "properties": { - "record_id": {"type": ["string", "null"]}, - "status": {"type": ["string", "null"]}, - "named_in_receipt": {"type": "boolean"}, - "values": {"type": ["object", "null"]}, - "omitted_objectives": {"type": ["array", "object", "null"]}, - "scores_source": {"type": ["string", "null"]}, - "scores_source_wording": {"type": ["string", "null"]}, - "value_bases": {"type": ["object", "null"]}, - "metric_source_conflicts": {"type": "object"}, - "source_boundary": {"type": ["object", "null"]} - } + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "experiment_run_not_in_scope"}, + "detail": { + "const": "The named experiment run does not resolve within the request's tenant and project scope." + }, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "request_scope_unavailable"}, + "detail": { + "const": "No tenant and project scope was bound to the request, so no scoped read was performed." + }, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "selection_receipt_unusable"}, + "detail": { + "const": "No accepted, digest-checked selection receipt was usable for the named experiment run." + }, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "objectives_not_declarable"}, + "detail": { + "const": "The declared objectives could not be used for a comparison. No objective was inferred or dropped." + }, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "objective_direction_conflict"}, + "detail": { + "const": "A declared objective direction contradicts the metric semantics policy, so the comparison was withheld for the whole objective set." + }, + "record": {"$ref": "#/components/schemas/FrontClaimDirectionConflict"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "claim_assertion_malformed"}, + "detail": {"const": "The comparison inputs did not form a valid claim, so no assessment is claimed."}, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "claim_computation_failed"}, + "detail": {"const": "The assessment could not be computed, so no assessment is claimed."}, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "supplement_exceeds_size_bound"}, + "detail": {"const": "The assessment exceeds the size limit and was withheld whole rather than trimmed."}, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "assessment_not_configured"}, + "detail": {"const": "No assessment was configured for this issuance, so none was attempted."}, + "record": {"type": "null"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "assessment_not_retained"}, + "detail": {"const": "No assessment is retained for this issuance and none is reconstructed."}, + "record": {"type": "null"} } } - }, - "if": {"properties": {"supplement_present": {"const": true}}}, - "then": {"required": ["schema_version", "binding", "selection_binding", "authentication"]}, - "else": { - "required": ["not_assessed"], - "properties": {"outcome": {"const": "not_assessed"}, "capture_basis": {"const": null}, "exhaustive_inventory": {"const": false}} + ] + }, + "FrontClaimDirectionConflict": { + "type": "object", + "additionalProperties": false, + "required": ["metric_key", "declared_direction", "expected_direction", "policy_version"], + "properties": { + "metric_key": {"enum": ["accuracy", "total_cost", "cost", "latency"]}, + "declared_direction": {"enum": ["maximize", "minimize"]}, + "expected_direction": {"enum": ["maximize", "minimize"]}, + "policy_version": { + "enum": [ + "traigent.certification.metric_semantics_policy.v1", + "traigent.certification.metric_semantics_policy.v2", + "traigent.certification.metric_semantics_policy.v3" + ] + } + } + }, + "FrontClaimSelectionBinding": { + "type": "object", + "additionalProperties": false, + "required": [ + "experiment_run_id", + "experiment_run_id_source", + "winner_trial_id", + "eligible_trial_ids_digest", + "eligible_trial_ids_digest_scope", + "selection_validation_source", + "candidate_source", + "sources_reconciled" + ], + "properties": { + "experiment_run_id": { + "anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}] + }, + "experiment_run_id_source": {"const": "request_field_resolved_within_project_scope"}, + "winner_trial_id": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}]}, + "eligible_trial_ids_digest": { + "anyOf": [{"$ref": "./process_record_request_schema.json#/definitions/Sha256Reference"}, {"type": "null"}] + }, + "eligible_trial_ids_digest_scope": { + "const": "This digest covers the candidate-ID list only; it does not authenticate the selected winner, scores, or original selection event." + }, + "selection_validation_source": {"const": "selection_session"}, + "candidate_source": {"const": "configuration_run_records"}, + "sources_reconciled": {"const": false} + } + }, + "FrontClaimObjective": { + "type": "object", + "additionalProperties": false, + "required": [ + "objective_id", + "direction", + "registration", + "measurement_scope", + "metric_key", + "unit", + "input_representation", + "declaration_source" + ], + "properties": { + "objective_id": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"}, + "direction": {"enum": ["maximize", "minimize"]}, + "registration": {"enum": ["registered", "explicitly_unregistered"]}, + "measurement_scope": { + "enum": [ + "undeclared", + "obj.accuracy.exact_match.v1", + "obj.accuracy.evaluator_score_mean.v1", + "obj.cost.mean_microusd_per_item.v1", + "obj.latency.mean_us.v1", + "obj.latency.p50_us.v1" + ] + }, + "metric_key": {"enum": ["accuracy", "total_cost", "cost", "latency", null]}, + "unit": {"enum": ["ppm", "microusd", "microseconds", null]}, + "input_representation": { + "enum": [ + "fraction_0_1", + "percentage_0_100", + "ppm_integer", + "usd", + "millidollars", + "microusd_integer", + "seconds", + "milliseconds", + "microseconds_integer", + "undeclared", + null + ] + }, + "declaration_source": {"enum": ["caller_declared", "default_preset", null]} + } + }, + "FrontClaimValueResolution": { + "type": "object", + "additionalProperties": false, + "required": ["policy_version", "copy_agreement_rule"], + "properties": { + "policy_version": { + "enum": [ + "traigent.certification.metric_semantics_policy.v1", + "traigent.certification.metric_semantics_policy.v2", + "traigent.certification.metric_semantics_policy.v3", + "undeclared" + ] + }, + "copy_agreement_rule": {"enum": ["exact_decimal_repr_equality", "undeclared"]}, + "quantity_contract": {"enum": ["assumed_not_evidenced", "not_declared", "undeclared"]} + } + }, + "FrontClaimPopulation": { + "type": "object", + "additionalProperties": false, + "required": [ + "scope", + "population_source", + "captured_at", + "scope_record_count", + "captured_member_count", + "unnamed_captured_count" + ], + "properties": { + "scope": { + "type": "object", + "additionalProperties": false, + "required": ["scope_kind", "experiment_run_id", "scope_filters", "scope_enforcement", "declared"], + "properties": { + "scope_kind": {"enum": ["experiment_run", "undeclared"]}, + "experiment_run_id": { + "anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}] + }, + "scope_filters": { + "type": "array", + "uniqueItems": true, + "items": {"enum": ["tenant", "project", "experiment_run"]} + }, + "scope_enforcement": {"enum": ["request_scope_fail_closed", "undeclared"]}, + "declared": {"type": "boolean"} + } + }, + "population_source": {"enum": ["scoped_configuration_run_records", "caller_supplied_records", "undisclosed"]}, + "captured_at": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimTimestamp"}, {"const": "undeclared"}]}, + "scope_record_count": {"type": ["integer", "null"], "minimum": 0}, + "captured_member_count": {"type": "integer", "minimum": 0}, + "unnamed_captured_count": {"type": "integer", "minimum": 0} + } + }, + "FrontClaimReportedValueText": { + "type": ["string", "null"], + "maxLength": 128, + "pattern": "^-?[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?$", + "not": {"type": "string", "pattern": "[\\r\\n]"} + }, + "FrontClaimValueBasis": { + "type": "object", + "additionalProperties": false, + "required": [ + "observation_basis", + "reported_value", + "reported_value_repr", + "value_supply", + "input_representation", + "derivation" + ], + "properties": { + "observation_basis": {"enum": ["backend_observed", "client_attested"]}, + "reported_value": {"type": ["number", "null"]}, + "reported_value_repr": {"$ref": "#/components/schemas/FrontClaimReportedValueText"}, + "value_supply": {"enum": ["converted_from_reported_value", "supplied_as_integer"]}, + "input_representation": { + "enum": [ + "fraction_0_1", + "percentage_0_100", + "ppm_integer", + "usd", + "millidollars", + "microusd_integer", + "seconds", + "milliseconds", + "microseconds_integer", + "undeclared", + null + ] + }, + "derivation": {"enum": ["server_transformed", "client_reported_mean", null]}, + "source_shape": {"enum": ["flat_scalar", "nested_scalar", "describe_mean", "aggregation_scalar", null]}, + "aggregation_kind": {"enum": ["mean_over_examples", "total_over_examples", "undeclared", null]}, + "reported_count": {"type": ["integer", "null"], "minimum": 0}, + "compared_source_count": {"type": ["integer", "null"], "minimum": 0}, + "quantity_id": {"enum": ["traigent.certification.quantity.trial_total_cost_usd", null]}, + "source_metric_name": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimObjectiveReference"}, {"type": "null"}]}, + "equivalent_metric_names": { + "anyOf": [ + { + "type": "array", + "uniqueItems": true, + "items": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"} + }, + {"type": "null"} + ] + }, + "absent_metric_names": { + "anyOf": [ + { + "type": "array", + "uniqueItems": true, + "items": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"} + }, + {"type": "null"} + ] + } + } + }, + "FrontClaimConflictObservation": { + "type": "object", + "additionalProperties": false, + "required": ["source_shape", "reported_value", "reported_value_repr"], + "properties": { + "source_shape": {"enum": ["flat_scalar", "nested_scalar", "describe_mean", "aggregation_scalar", null]}, + "reported_value": {"type": ["number", "null"]}, + "reported_value_repr": {"$ref": "#/components/schemas/FrontClaimReportedValueText"} + } + }, + "FrontClaimSourceBoundary": { + "type": "object", + "additionalProperties": false, + "required": ["selected_source", "excluded_sources", "rule"], + "properties": { + "selected_source": {"enum": ["primary_metrics", "secondary_metrics", "undeclared"]}, + "excluded_sources": { + "type": "array", + "uniqueItems": true, + "items": {"enum": ["primary_metrics", "secondary_metrics"]} + }, + "rule": {"enum": ["primary_when_present_otherwise_secondary", "undeclared"]} + } + }, + "FrontClaimMember": { + "type": "object", + "additionalProperties": false, + "required": [ + "record_id", + "status", + "named_in_receipt", + "values", + "omitted_objectives", + "scores_source", + "scores_source_wording", + "value_bases", + "metric_source_conflicts", + "source_boundary" + ], + "properties": { + "record_id": {"$ref": "#/components/schemas/FrontClaimRecordReference"}, + "status": { + "anyOf": [{"$ref": "../status_schema.json#/definitions/ConfigurationRunStatus"}, {"type": "null"}] + }, + "named_in_receipt": {"type": "boolean"}, + "values": { + "anyOf": [ + { + "type": "object", + "propertyNames": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"}, + "additionalProperties": {"type": "integer"} + }, + {"type": "null"} + ] + }, + "omitted_objectives": { + "anyOf": [ + { + "type": "object", + "propertyNames": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"}, + "additionalProperties": {"$ref": "#/components/schemas/FrontClaimOmissionReason"} + }, + {"type": "null"} + ] + }, + "scores_source": {"enum": ["backend_observed", "client_attested", "mixed_see_value_bases", null]}, + "scores_source_wording": { + "enum": ["Server-observed", "Client-attested (client-reported)", "Mixed; see each value basis", null] + }, + "value_bases": { + "anyOf": [ + { + "type": "object", + "propertyNames": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"}, + "additionalProperties": {"$ref": "#/components/schemas/FrontClaimValueBasis"} + }, + {"type": "null"} + ] + }, + "metric_source_conflicts": { + "type": "object", + "propertyNames": {"$ref": "#/components/schemas/FrontClaimObjectiveReference"}, + "additionalProperties": { + "type": "array", + "minItems": 2, + "items": {"$ref": "#/components/schemas/FrontClaimConflictObservation"} + } + }, + "source_boundary": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimSourceBoundary"}, {"type": "null"}]} } }, - "ProcessRecordStorageConflict": { + "ProcessRecordConflict": { "anyOf": [ { "type": "object", @@ -1242,7 +1680,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request conflicts with current state"}, "error": {"const": "session_project_conflict"}, "error_code": {"const": "SESSION_PROJECT_CONFLICT"} } @@ -1253,9 +1691,9 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, - "error": {"const": "immutable_row"}, - "error_code": {"const": "IMMUTABLE_ROW"} + "message": {"const": "process record request conflicts with current state"}, + "error": {"const": "process_record_immutable"}, + "error_code": {"const": "PROCESS_RECORD_IMMUTABLE"} } }, { @@ -1264,9 +1702,9 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, - "error": {"const": "duplicate_seq"}, - "error_code": {"const": "DUPLICATE_SEQ"} + "message": {"const": "process record request conflicts with current state"}, + "error": {"const": "process_record_sequence_conflict"}, + "error_code": {"const": "PROCESS_RECORD_SEQUENCE_CONFLICT"} } }, { @@ -1275,7 +1713,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request conflicts with current state"}, "error": {"const": "duplicate_receipt_ref"}, "error_code": {"const": "DUPLICATE_RECEIPT_REF"} } @@ -1286,9 +1724,9 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, - "error": {"const": "constraint_violation"}, - "error_code": {"const": "CONSTRAINT_VIOLATION"} + "message": {"const": "process record request conflicts with current state"}, + "error": {"const": "process_record_conflict"}, + "error_code": {"const": "PROCESS_RECORD_CONFLICT"} } }, { @@ -1297,9 +1735,9 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, - "error": {"const": "stream_overflow"}, - "error_code": {"const": "STREAM_OVERFLOW"} + "message": {"const": "process record request conflicts with current state"}, + "error": {"const": "process_record_receipt_limit"}, + "error_code": {"const": "PROCESS_RECORD_RECEIPT_LIMIT"} } }, { @@ -1308,7 +1746,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request conflicts with current state"}, "error": {"const": "lineage_scope_mismatch"}, "error_code": {"const": "LINEAGE_SCOPE_MISMATCH"} } @@ -1368,7 +1806,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request refused"}, "error": {"const": "tenant_context_missing"}, "error_code": {"const": "TENANT_CONTEXT_MISSING"} } @@ -1379,7 +1817,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request refused"}, "error": {"const": "tenant_binding_failed"}, "error_code": {"const": "TENANT_BINDING_FAILED"} } @@ -1408,7 +1846,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request refused"}, "error": {"const": "unknown_scope_reference"}, "error_code": {"const": "UNKNOWN_SCOPE_REFERENCE"} } @@ -1419,7 +1857,7 @@ "required": ["success", "message", "error", "error_code"], "properties": { "success": {"const": false}, - "message": {"const": "process record storage refused the request"}, + "message": {"const": "process record request refused"}, "error": {"const": "lineage_unmapped"}, "error_code": {"const": "LINEAGE_UNMAPPED"} } diff --git a/traigent_schema/schemas/closed_request_error_schema.json b/traigent_schema/schemas/closed_request_error_schema.json index 9bb6408f..0e7c1e1b 100644 --- a/traigent_schema/schemas/closed_request_error_schema.json +++ b/traigent_schema/schemas/closed_request_error_schema.json @@ -174,6 +174,28 @@ "error": {"const": "SESSION_IDLE_EXPIRED"}, "error_code": {"const": "SESSION_IDLE_EXPIRED"} } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Session reached its maximum lifetime."}, + "error": {"const": "SESSION_ABSOLUTE_EXPIRED"}, + "error_code": {"const": "SESSION_ABSOLUTE_EXPIRED"} + } + }, + { + "type": "object", + "additionalProperties": false, + "required": ["success", "message", "error", "error_code"], + "properties": { + "success": {"const": false}, + "message": {"const": "Session is not valid."}, + "error": {"const": "SESSION_INVALID"}, + "error_code": {"const": "SESSION_INVALID"} + } } ] }, From da72a35357b38bcc405c540ff2fb92c64643e0a8 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 03:52:34 +0200 Subject: [PATCH 09/20] fix(contract): one build-session reference for process records; public configuration-run references; discriminated retained/not-retained companion; closed fallbacks Co-Authored-By: Claude Opus 5.5 --- parity/python-js-sdk.json | 2 +- .../process_record_request_schema.json | 4 +- .../process_records_endpoints.json | 94 ++++++++++++------- 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index 1872ad2d..bfd3d330 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,7 +399,7 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "f8019708a8f4a2a3d9a8937d2c98ee5fbcbc833c698c711b9d7c7a44efc2f500", + "lastSchemaFileSha": "9353693a0fdfd4142713bda50fd1584ae09b49b4daf8d35f32161dd9168ed2e9", "schemaFileCount": 681, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } diff --git a/traigent_schema/schemas/certification/process_record_request_schema.json b/traigent_schema/schemas/certification/process_record_request_schema.json index 2dc57ef6..213a2ffb 100644 --- a/traigent_schema/schemas/certification/process_record_request_schema.json +++ b/traigent_schema/schemas/certification/process_record_request_schema.json @@ -6,8 +6,8 @@ "definitions": { "ProcessRecordReference": { "type": "string", - "minLength": 1, - "description": "An opaque process record reference scoped to the named project." + "pattern": "^bsn:[A-Za-z0-9_-]{43}(?![\\s\\S])", + "description": "Use the build_session_ref returned when the certificate build session was created, including for an existing issuance. Prepare echoes the same reference. Resolve it within the named project." }, "Sha256Reference": { "allOf": [{"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}], diff --git a/traigent_schema/schemas/certification/process_records_endpoints.json b/traigent_schema/schemas/certification/process_records_endpoints.json index 8da4d70b..b2b17090 100644 --- a/traigent_schema/schemas/certification/process_records_endpoints.json +++ b/traigent_schema/schemas/certification/process_records_endpoints.json @@ -11,7 +11,7 @@ "post": { "operationId": "certification_process_record.prepare_process_record", "summary": "Check receipt readiness for a process record", - "description": "Reports the receipts currently visible for an issued build session. This probe does not reserve issuance.", + "description": "Reports the receipts currently visible for a build session. Send the build_session_ref as process_record_ref. The response echoes that reference. This probe does not reserve issuance.", "x-asserted-against-backend": false, "parameters": [ { @@ -150,7 +150,7 @@ "name": "process_record_ref", "in": "path", "required": true, - "description": "Opaque reference to the process record in this project.", + "description": "Use the build_session_ref issued for this project. An existing issuance can be retrieved with that same reference without calling prepare.", "schema": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"} } ], @@ -389,7 +389,7 @@ "name": "process_record_ref", "in": "path", "required": true, - "description": "Opaque reference to the process record in this project.", + "description": "Use the build_session_ref issued for this project, also echoed by prepare.", "schema": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"} } ], @@ -1053,25 +1053,7 @@ "headline": {"type": "string", "minLength": 1}, "capture_basis": {"enum": ["state_observed_at_issuance", null]}, "exhaustive_inventory": {"const": false}, - "disclosures": { - "type": "object", - "additionalProperties": false, - "required": ["unsigned_companion", "digest_scope", "bounded_claim", "capture_basis"], - "properties": { - "unsigned_companion": { - "const": "This assessment companion is retained with this issuance. It is outside the signed V1 bundle and is not authenticated by the V1 signature or verified by the V1 standalone verifier." - }, - "digest_scope": { - "const": "This digest covers the candidate-ID list only; it does not authenticate the selected winner, scores, or original selection event." - }, - "bounded_claim": { - "const": "This records reported measurements and selection; any comparison applies only to the enumerated comparable records under the declared policy. It certifies no performance threshold or deployment fitness." - }, - "capture_basis": { - "const": "This is state observed at issuance, not a reconstruction of the state at the original selection, and it is a scope rather than an inventory. The selection receipt and the candidate records come from independent sources that can disagree, so a binding to the receipt is not a binding to the records this comparison used. No reconciliation between them is attempted or implied." - } - } - }, + "disclosures": {"type": "object"}, "not_assessed": {"$ref": "#/components/schemas/FrontClaimNotAssessed"}, "schema_version": { "enum": [ @@ -1085,12 +1067,7 @@ "additionalProperties": false, "required": ["process_record_ref", "unsigned_manifest_digest", "computed_at"], "properties": { - "process_record_ref": { - "allOf": [ - {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"}, - {"type": "string", "pattern": "^prr:[A-Za-z0-9_-]{16,128}(?![\\s\\S])"} - ] - }, + "process_record_ref": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"}, "unsigned_manifest_digest": {"$ref": "./process_record_request_schema.json#/definitions/Sha256Reference"}, "computed_at": {"$ref": "#/components/schemas/FrontClaimTimestamp"} } @@ -1209,21 +1186,54 @@ "if": {"properties": {"supplement_present": {"const": true}}}, "then": { "required": ["schema_version", "binding", "selection_binding", "authentication"], - "properties": {"not_assessed": {"properties": {"reason": {"not": {"const": "assessment_not_retained"}}}}} + "properties": { + "disclosures": { + "additionalProperties": false, + "required": ["unsigned_companion", "digest_scope", "bounded_claim", "capture_basis"], + "properties": { + "unsigned_companion": { + "const": "This assessment companion is retained with this issuance. It is outside the signed V1 bundle and is not authenticated by the V1 signature or verified by the V1 standalone verifier." + }, + "digest_scope": { + "const": "This digest covers the candidate-ID list only; it does not authenticate the selected winner, scores, or original selection event." + }, + "bounded_claim": { + "const": "This records reported measurements and selection; any comparison applies only to the enumerated comparable records under the declared policy. It certifies no performance threshold or deployment fitness." + }, + "capture_basis": { + "const": "This is state observed at issuance, not a reconstruction of the state at the original selection, and it is a scope rather than an inventory. The selection receipt and the candidate records come from independent sources that can disagree, so a binding to the receipt is not a binding to the records this comparison used. No reconciliation between them is attempted or implied." + } + } + }, + "not_assessed": {"properties": {"reason": {"not": {"const": "assessment_not_retained"}}}} + } }, "else": { "required": ["not_assessed"], + "propertyNames": { + "enum": ["supplement_present", "assessment_state", "outcome", "headline", "capture_basis", "exhaustive_inventory", "disclosures", "not_assessed"] + }, "properties": { "assessment_state": {"const": "not_assessed"}, "outcome": {"const": "not_assessed"}, - "capture_basis": {"const": null}, - "exhaustive_inventory": {"const": false}, + "disclosures": { + "additionalProperties": false, + "required": ["unsigned_companion"], + "properties": { + "unsigned_companion": {"const": "No unsigned assessment accompanies this issuance."} + } + }, "not_assessed": {"properties": {"reason": {"const": "assessment_not_retained"}}} } } }, "FrontClaimRecordReference": { - "description": "A closed record reference: a UUID, a positive decimal ID, or trial_ followed by 16-64 lowercase hex.", + "description": "Public configuration run reference. Use the same reference for each occurrence of the same configuration in the companion.", + "type": "string", + "pattern": "^configuration_run_[0-9a-f]{32}(?![\\s\\S])" + }, + "FrontClaimExperimentRunReference": { + "description": "Reference to the experiment run associated with the build session.", "type": "string", "pattern": "^(?:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}|[1-9][0-9]{0,18}|trial_[0-9a-f]{16,64})(?![\\s\\S])" }, @@ -1355,6 +1365,16 @@ "record": {"type": "null"} } }, + { + "type": "object", + "additionalProperties": false, + "required": ["reason", "detail"], + "properties": { + "reason": {"const": "other"}, + "detail": {"const": "The retained assessment records a refusal without a listed public reason."}, + "record": {"type": "null"} + } + }, { "type": "object", "additionalProperties": false, @@ -1399,9 +1419,12 @@ ], "properties": { "experiment_run_id": { - "anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}] + "anyOf": [{"$ref": "#/components/schemas/FrontClaimExperimentRunReference"}, {"type": "null"}] + }, + "experiment_run_id_source": { + "description": "The run associated with the build session within the project supplies the reference, including when finalize omits experiment_run_id. Null indicates that the source is unavailable.", + "enum": ["build_session_run_within_project_scope", null] }, - "experiment_run_id_source": {"const": "request_field_resolved_within_project_scope"}, "winner_trial_id": {"anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}]}, "eligible_trial_ids_digest": { "anyOf": [{"$ref": "./process_record_request_schema.json#/definitions/Sha256Reference"}, {"type": "null"}] @@ -1497,7 +1520,7 @@ "properties": { "scope_kind": {"enum": ["experiment_run", "undeclared"]}, "experiment_run_id": { - "anyOf": [{"$ref": "#/components/schemas/FrontClaimRecordReference"}, {"type": "null"}] + "anyOf": [{"$ref": "#/components/schemas/FrontClaimExperimentRunReference"}, {"type": "null"}] }, "scope_filters": { "type": "array", @@ -1516,6 +1539,7 @@ } }, "FrontClaimReportedValueText": { + "description": "Canonical decimal text represents the exact decimal value used in the comparison. Use the reported number's shortest round-trip decimal spelling, without a leading plus sign. Never round or change the value during normalization.", "type": ["string", "null"], "maxLength": 128, "pattern": "^-?[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?$", From 0437d08ccb878450a32daab1f29a9f8306f8420e Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 03:58:42 +0200 Subject: [PATCH 10/20] docs(contract): canonical process-record routes cover build-session issuances; runlineage certificates stay on the existing routes Co-Authored-By: Claude Sonnet 5.5 --- parity/python-js-sdk.json | 2 +- .../schemas/certification/process_record_request_schema.json | 2 +- .../schemas/certification/process_records_endpoints.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index bfd3d330..7a7decb9 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,7 +399,7 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "9353693a0fdfd4142713bda50fd1584ae09b49b4daf8d35f32161dd9168ed2e9", + "lastSchemaFileSha": "48376e5dcdafef70ebcd73507b03c398058d0e8d2b317e429fb570cdafdb2991", "schemaFileCount": 681, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } diff --git a/traigent_schema/schemas/certification/process_record_request_schema.json b/traigent_schema/schemas/certification/process_record_request_schema.json index 213a2ffb..87b5d1e8 100644 --- a/traigent_schema/schemas/certification/process_record_request_schema.json +++ b/traigent_schema/schemas/certification/process_record_request_schema.json @@ -7,7 +7,7 @@ "ProcessRecordReference": { "type": "string", "pattern": "^bsn:[A-Za-z0-9_-]{43}(?![\\s\\S])", - "description": "Use the build_session_ref returned when the certificate build session was created, including for an existing issuance. Prepare echoes the same reference. Resolve it within the named project." + "description": "Use the build_session_ref returned when the certificate build session was created. These routes cover issuances created through a certificate build session. A certificate that carries a runlineage: reference is not addressed here and stays on the existing certification routes. Prepare echoes the same reference. Resolve it within the named project." }, "Sha256Reference": { "allOf": [{"$ref": "./certification_common_v0_schema.json#/definitions/Sha256Digest"}], diff --git a/traigent_schema/schemas/certification/process_records_endpoints.json b/traigent_schema/schemas/certification/process_records_endpoints.json index b2b17090..acd4610f 100644 --- a/traigent_schema/schemas/certification/process_records_endpoints.json +++ b/traigent_schema/schemas/certification/process_records_endpoints.json @@ -150,7 +150,7 @@ "name": "process_record_ref", "in": "path", "required": true, - "description": "Use the build_session_ref issued for this project. An existing issuance can be retrieved with that same reference without calling prepare.", + "description": "Use the build_session_ref issued for this project. An issuance created through a certificate build session can be retrieved with that same reference without calling prepare. A certificate carrying a runlineage: reference stays on the existing certification routes.", "schema": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"} } ], @@ -389,7 +389,7 @@ "name": "process_record_ref", "in": "path", "required": true, - "description": "Use the build_session_ref issued for this project, also echoed by prepare.", + "description": "Use the build_session_ref issued for this project, also echoed by prepare. A certificate carrying a runlineage: reference stays on the existing certification routes.", "schema": {"$ref": "./process_record_request_schema.json#/definitions/ProcessRecordReference"} } ], From 916f6719a2099fe7f9eaaa137d44d1bd7ba648d0 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 04:05:38 +0200 Subject: [PATCH 11/20] docs(contract): unfinalized build-session references return LINEAGE_UNMAPPED; define present primary metrics Co-Authored-By: Claude Sonnet 5.5 --- parity/python-js-sdk.json | 2 +- .../schemas/certification/process_records_endpoints.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index 7a7decb9..de294b9c 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,7 +399,7 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "48376e5dcdafef70ebcd73507b03c398058d0e8d2b317e429fb570cdafdb2991", + "lastSchemaFileSha": "3a81a026324ba1ff7062b224f4edcd0a1a6fff2ae4ee6d5f0404f920314fd11d", "schemaFileCount": 681, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } diff --git a/traigent_schema/schemas/certification/process_records_endpoints.json b/traigent_schema/schemas/certification/process_records_endpoints.json index acd4610f..43d69180 100644 --- a/traigent_schema/schemas/certification/process_records_endpoints.json +++ b/traigent_schema/schemas/certification/process_records_endpoints.json @@ -11,7 +11,7 @@ "post": { "operationId": "certification_process_record.prepare_process_record", "summary": "Check receipt readiness for a process record", - "description": "Reports the receipts currently visible for a build session. Send the build_session_ref as process_record_ref. The response echoes that reference. This probe does not reserve issuance.", + "description": "Reports the receipts currently visible for a build session. Send the build_session_ref as process_record_ref. The response echoes that reference. This probe does not reserve issuance. Until the build session is finalized, the reference does not yet resolve to an issuance and the call returns the declared 404 with code LINEAGE_UNMAPPED; finalize the build session first, then retry.", "x-asserted-against-backend": false, "parameters": [ { @@ -375,7 +375,7 @@ "post": { "operationId": "certification_process_record.finalize_process_record", "summary": "Issue a process record certificate", - "description": "Issues and stores a signed certificate for the named build session. After an ambiguous failure, retrieve the record before retrying.", + "description": "Issues and stores a signed certificate for the named build session. After an ambiguous failure, retrieve the record before retrying. Until the build session is finalized, the reference does not yet resolve to an issuance and the call returns the declared 404 with code LINEAGE_UNMAPPED; finalize the build session first, then retry.", "x-asserted-against-backend": false, "parameters": [ { @@ -914,7 +914,7 @@ "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordWriteForbidden"}}} }, "NotFound": { - "description": "No accessible matching scope was found.", + "description": "No accessible matching scope was found. The code LINEAGE_UNMAPPED means the build session reference is valid but the build session is not yet finalized, so it does not resolve to an issuance; finalize the build session and retry.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ProcessRecordScopeNotFound"}}} }, "InternalError": { @@ -1626,7 +1626,7 @@ "uniqueItems": true, "items": {"enum": ["primary_metrics", "secondary_metrics"]} }, - "rule": {"enum": ["primary_when_present_otherwise_secondary", "undeclared"]} + "rule": {"description": "Primary metrics win when present. Present means a non-empty primary metric mapping; when the primary mapping is empty, the secondary metrics are used.", "enum": ["primary_when_present_otherwise_secondary", "undeclared"]} } }, "FrontClaimMember": { From 6218bd0876e76dfc0506b0640b1b49af3633ccae Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 04:56:38 +0200 Subject: [PATCH 12/20] docs(changelog): fragment for the certification project paths Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/certification-project-paths.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/certification-project-paths.added.md diff --git a/changelog.d/certification-project-paths.added.md b/changelog.d/certification-project-paths.added.md new file mode 100644 index 00000000..1378154e --- /dev/null +++ b/changelog.d/certification-project-paths.added.md @@ -0,0 +1 @@ +- **Project-scoped certification contracts.** New operations under `/api/v1/projects/{project_id}/`: certificate build-session issuance readiness and abandonment, and process-record preparation, verification, retrieval and finalization. Every process-record call takes the build-session reference (`bsn:...`); a reference whose build session is not finalized returns `404` with code `LINEAGE_UNMAPPED`. Certificates that carry a `runlineage:` reference stay on the existing certification routes, which are unchanged. Error bodies are closed, including the browser-session `401` variants (`CSRF_VALIDATION_FAILED`, `SESSION_IDLE_EXPIRED`, `SESSION_ABSOLUTE_EXPIRED`, `SESSION_INVALID`). Additive: no existing operation is changed or removed. From 0ce15cb37c355819eb676bc43d8e87699ea2745c Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 01:39:21 +0200 Subject: [PATCH 13/20] feat(contract): configuration-run measurement read; run-owned configuration aliases retire Adds GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/measurement (operation id configuration_run.get_configuration_run_measurement): the stored measures of one configuration run as one bounded, cursor-paged read, with a new response schema. Removes the two run-owned configuration aliases under /api/v1/experiment-runs/runs/..., which duplicated the canonical experiment-run configuration-runs collection. The removal is acknowledged in the breaking-change allowlist. Changelog entries are fragments under changelog.d/. Co-Authored-By: Claude Opus 5.5 --- ...onfiguration-run-measurement-read.added.md | 1 + .../configuration-run-status-read.added.md | 1 + ...un-owned-configuration-aliases.breaking.md | 1 + .../unreachable_schemas.json | 6 +- scripts/breaking_schema_allowlist.json | 25 ++ tests/test_create_request_contracts.py | 2 - ...ation_run_measurement_response_schema.json | 292 ++++++++++++++++++ .../configuration_run_problem_schema.json | 128 ++++++++ ...figuration_run_status_response_schema.json | 53 ++++ .../execution/execution_endpoints.json | 222 ++++++++++--- 10 files changed, 676 insertions(+), 55 deletions(-) create mode 100644 changelog.d/configuration-run-measurement-read.added.md create mode 100644 changelog.d/configuration-run-status-read.added.md create mode 100644 changelog.d/run-owned-configuration-aliases.breaking.md create mode 100644 traigent_schema/schemas/execution/configuration_run_measurement_response_schema.json create mode 100644 traigent_schema/schemas/execution/configuration_run_problem_schema.json create mode 100644 traigent_schema/schemas/execution/configuration_run_status_response_schema.json diff --git a/changelog.d/configuration-run-measurement-read.added.md b/changelog.d/configuration-run-measurement-read.added.md new file mode 100644 index 00000000..66cd460b --- /dev/null +++ b/changelog.d/configuration-run-measurement-read.added.md @@ -0,0 +1 @@ +- **`configuration_run.get_configuration_run_measurement`: the stored measures of a configuration run, read as one bounded page (additive).** `GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/measurement` returns the new `execution/configuration_run_measurement_response_schema.json`: `data.shape` is `flat` (a map of measure names to numbers in `measures`) or `per_example` (a cursor page of `items`; each item is either a `MeasurementItem` with `example_id` and metrics, or a bare metric map from the older stored form that has no `example_id`; metric values may be null), with `pagination` (`limit` default and maximum 100, `next_cursor`, `has_more`, `total`). Query: `limit` and `cursor`. The cursor is sealed and opaque; a cursor is invalidated when the stored results change, and a stale one is the closed 400 `invalid_cursor`. Path parameters are as for the other configuration-run operations. diff --git a/changelog.d/configuration-run-status-read.added.md b/changelog.d/configuration-run-status-read.added.md new file mode 100644 index 00000000..aae2f312 --- /dev/null +++ b/changelog.d/configuration-run-status-read.added.md @@ -0,0 +1 @@ +- **`configuration_run.get_configuration_run_status`: the status of a configuration run on its own reference (additive).** `GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/status` returns the new `execution/configuration_run_status_response_schema.json`: `data.status` (the shared configuration-run status) and `data.error_message` (string or null, any length the update accepts), with a fixed success message. It replaces the run-owned status read. The 404 is the closed `NotFoundProblem`, identical for a missing, foreign or ungranted configuration run. Path parameters are as for the other configuration-run operations. The optional query parameter `expected_run_ref` (an experiment run reference) makes a configuration run that does not belong to that experiment run answer the same closed 404 as an absent one. diff --git a/changelog.d/run-owned-configuration-aliases.breaking.md b/changelog.d/run-owned-configuration-aliases.breaking.md new file mode 100644 index 00000000..bde093f1 --- /dev/null +++ b/changelog.d/run-owned-configuration-aliases.breaking.md @@ -0,0 +1 @@ +- **BREAKING (pre-release). The run-owned configuration aliases are removed.** In `execution/execution_endpoints.json`, `POST /api/v1/experiment-runs/runs/{experiment_run_id}/configurations` and `GET /api/v1/experiment-runs/runs/{run_id}/configurations` are removed; use `POST`/`GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/configuration-runs` (`configuration_run.create_configuration_run`, `configuration_run.get_configuration_runs`). Acknowledged in `scripts/breaking_schema_allowlist.json`. diff --git a/reports/schema_reachability/unreachable_schemas.json b/reports/schema_reachability/unreachable_schemas.json index 371edc70..e4b1f2ad 100644 --- a/reports/schema_reachability/unreachable_schemas.json +++ b/reports/schema_reachability/unreachable_schemas.json @@ -10,10 +10,10 @@ "reachableByRule": { "allowlist": 0, "consumerReference": 33, - "refOrEndpointGraph": 581 + "refOrEndpointGraph": 584 }, - "reachableCount": 614, - "schemaFileCount": 677, + "reachableCount": 617, + "schemaFileCount": 680, "unreachableCount": 63 }, "unreachableSchemas": [ diff --git a/scripts/breaking_schema_allowlist.json b/scripts/breaking_schema_allowlist.json index e30feb91..0bc31f6a 100644 --- a/scripts/breaking_schema_allowlist.json +++ b/scripts/breaking_schema_allowlist.json @@ -11401,6 +11401,31 @@ "reason": "Route moved to its project-scoped canonical path with the same operation id; the backend retires the old path with a closed 404.", "version": "Unreleased", "pr": "Traigent/TraigentSchema#TBD" + }, + { + "file": "execution/execution_endpoints.json", + "rule": "endpoint_removed", + "findings": [ + { + "pointer": "#/paths//api/v1/experiment-runs/runs/{experiment_run_id}/configurations/post", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "a63364a382b161b9b6ec7d92d8702ba910b5185f3c39d07b42b3f96f7142e873" + }, + { + "pointer": "#/paths//api/v1/experiment-runs/runs/{run_id}/configurations/get", + "role": "request", + "subject": null, + "old": null, + "new": null, + "fingerprint": "067d354632010bc47e47f02c0fb1dc31688843b1732b29c4393d0a4876809f5f" + } + ], + "reason": "BREAKING PUBLIC CHANGE (pre-release). The run-owned configuration aliases are removed: POST /api/v1/experiment-runs/runs/{experiment_run_id}/configurations and GET /api/v1/experiment-runs/runs/{run_id}/configurations. They carried no operation id and duplicated the canonical collection; use POST and GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/configuration-runs (configuration_run.create_configuration_run and configuration_run.get_configuration_runs). Request and response bodies are those of the canonical operations. Consumers: the Python SDK and the Backend, updated in the same release.", + "version": "Unreleased", + "pr": "pending" } ] } diff --git a/tests/test_create_request_contracts.py b/tests/test_create_request_contracts.py index 72e7b201..27fb93ba 100644 --- a/tests/test_create_request_contracts.py +++ b/tests/test_create_request_contracts.py @@ -41,8 +41,6 @@ ("/api/v1/projects/{project_id}/agents/{agent_ref}/model-parameters", {}, None), ("/api/v1/experiments", {"name": "e", "dataset_id": "d", "agent_id": "a"}, {"name": "e"}), - ("/api/v1/experiment-runs/runs/{experiment_run_id}/configurations", - {"experiment_parameters": {}}, {}), ("/api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/configuration-runs", {"experiment_parameters": {}}, {}), ("/api/v1/measures", diff --git a/traigent_schema/schemas/execution/configuration_run_measurement_response_schema.json b/traigent_schema/schemas/execution/configuration_run_measurement_response_schema.json new file mode 100644 index 00000000..9943aa8f --- /dev/null +++ b/traigent_schema/schemas/execution/configuration_run_measurement_response_schema.json @@ -0,0 +1,292 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/execution/configuration_run_measurement_response_schema.json", + "title": "Configuration Run Measurement Response", + "description": "Success envelope for GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/measurement: the stored results of one configuration run, read as one bounded page. `data.shape` says how they are stored. `flat` is a single map of measure names to numbers (or null), at most 50, returned whole in `measures`, with `pagination.total` the number of measures, `has_more` false and `next_cursor` null. `per_example` is the list of stored results (each a per-example item, or a bare measure map for results stored in the older form) (MeasurementItem: the per-example fields of the update request without input_id): one cursor page of `items`, in stored order, with the total across all pages in `pagination.total` (at most 1000). The cursor is a sealed opaque string bound to the caller, project and configuration run; a cursor is invalidated when the stored results change, and a stale or foreign cursor is the closed 400 invalid_cursor, so a page walk never mixes two versions. `has_more` is true if and only if `next_cursor` is non-null. The configuration run is addressed by `configuration_run_ref`; the internal id is never emitted. Measure names and values are exactly those the measurement update accepts (values are numbers or null); the message is fixed text.", + "type": "object", + "additionalProperties": false, + "required": [ + "success", + "message", + "data" + ], + "properties": { + "success": { + "type": "boolean", + "const": true + }, + "message": { + "type": "string", + "const": "Configuration run measurement retrieved successfully." + }, + "data": { + "$ref": "#/definitions/MeasurementPage" + } + }, + "definitions": { + "Cursor": { + "type": "string", + "pattern": "^[A-Za-z0-9_-]{1,512}$", + "minLength": 1, + "maxLength": 512 + }, + "Pagination": { + "type": "object", + "additionalProperties": false, + "required": [ + "limit", + "next_cursor", + "has_more", + "total" + ], + "properties": { + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100 + }, + "next_cursor": { + "anyOf": [ + { + "$ref": "#/definitions/Cursor" + }, + { + "type": "null" + } + ], + "description": "Opaque sealed cursor of the next page; null on the last page." + }, + "has_more": { + "type": "boolean", + "description": "True if and only if next_cursor is non-null." + }, + "total": { + "type": "integer", + "minimum": 0, + "maximum": 1000, + "description": "Number of stored per-example results (or measures, for the flat shape) across all pages. At most 1000, the stored per-example cap." + } + }, + "allOf": [ + { + "if": { + "properties": { + "has_more": { + "const": true + } + }, + "required": [ + "has_more" + ] + }, + "then": { + "properties": { + "next_cursor": { + "type": "string" + } + } + } + }, + { + "if": { + "properties": { + "has_more": { + "const": false + } + }, + "required": [ + "has_more" + ] + }, + "then": { + "properties": { + "next_cursor": { + "type": "null" + } + } + } + } + ] + }, + "MeasurementPage": { + "type": "object", + "additionalProperties": false, + "required": [ + "configuration_run_ref", + "shape", + "pagination" + ], + "properties": { + "configuration_run_ref": { + "$ref": "#/definitions/ConfigurationRunRef" + }, + "shape": { + "type": "string", + "enum": [ + "flat", + "per_example" + ] + }, + "measures": { + "$ref": "#/definitions/MeasureMap", + "description": "Present only when shape is flat." + }, + "items": { + "type": "array", + "maxItems": 100, + "items": { + "oneOf": [ + { + "$ref": "#/definitions/MeasurementItem" + }, + { + "$ref": "#/definitions/MeasureMap" + } + ] + }, + "description": "Present only when shape is per_example: one page of stored results in stored order. Each item is a MeasurementItem, or, for results stored in the older form, a bare map of measure names to numbers with no example_id." + }, + "pagination": { + "$ref": "#/definitions/Pagination" + } + }, + "allOf": [ + { + "if": { + "properties": { + "shape": { + "const": "flat" + } + }, + "required": [ + "shape" + ] + }, + "then": { + "required": [ + "measures", + "pagination" + ], + "not": { + "required": [ + "items" + ] + }, + "properties": { + "pagination": { + "properties": { + "has_more": { + "const": false + }, + "next_cursor": { + "type": "null" + } + }, + "required": [ + "has_more", + "next_cursor" + ] + } + } + } + }, + { + "if": { + "properties": { + "shape": { + "const": "per_example" + } + }, + "required": [ + "shape" + ] + }, + "then": { + "required": [ + "items" + ], + "not": { + "required": [ + "measures" + ] + } + } + } + ] + }, + "MeasurementItem": { + "type": "object", + "description": "One stored per-example result: example_id, metrics and the optional digest fields of the update request, without input_id (a client-supplied identifier is customer content and is never returned here).", + "required": [ + "example_id", + "metrics" + ], + "properties": { + "example_id": { + "x-content-class": "opaque_ref", + "type": "string", + "maxLength": 255, + "pattern": "^ex_[a-f0-9]{8,12}_[0-9]+$", + "description": "Unique example identifier" + }, + "metrics": { + "$ref": "#/definitions/MeasureMap", + "description": "Numeric measure scores for this example" + }, + "example_digest": { + "x-content-class": "digest", + "type": "string", + "pattern": "^[0-9a-f]{64}$", + "description": "A keyed, one-way, client-computed identity digest derived from the example's input and expected output. Its purpose is to let the same example be recognized across runs without transmitting the content itself. It is keyed to a client key version identified by the accompanying signal_key_id: the same content under a different key version, or different content under the same key version, each yield a different digest." + }, + "output_digest": { + "x-content-class": "digest", + "type": "string", + "pattern": "^[0-9a-f]{64}$", + "description": "A keyed, one-way, client-computed identity digest derived from the example's produced output. Its purpose is to let the same output be recognized across runs without transmitting the content itself. It is keyed to a client key version identified by the accompanying signal_key_id, the same as example_digest." + }, + "verified_match": { + "x-content-class": "closed_enum", + "type": "number", + "enum": [ + 0.0, + 1.0 + ], + "description": "Whether the produced output matched the example's expected answer, determined client-side: 1.0 for a match, 0.0 for no match. Omitted entirely -- not sent as null or as 0.0 -- when the example has no usable expected answer to compare against. Absence therefore means \"not checked\", which is not the same as \"checked and failed\"." + }, + "signal_key_id": { + "x-content-class": "opaque_ref", + "type": "string", + "pattern": "^[0-9a-f]{12}$", + "description": "A short tag identifying which client key version example_digest and output_digest on this row were computed under. Its purpose is to let digests computed under different key versions be told apart rather than conflated as if they belonged to the same identity space. Present only alongside the digests it tags." + } + }, + "additionalProperties": false + }, + "MeasureMap": { + "x-content-key-class": "legacy_content", + "x-content-note": "Measure names are client-chosen identifiers; values are numbers or null.", + "type": "object", + "description": "Measure name to numeric value (or null), exactly the shape the measurement update accepts: names are identifiers of letters, digits, underscore, dot and hyphen starting with a letter or underscore; at most 50 per map.", + "maxProperties": 50, + "patternProperties": { + "^[a-zA-Z_][a-zA-Z0-9_.-]*$": { + "x-content-class": "number", + "type": [ + "number", + "null" + ], + "description": "Score for a specific measure (numeric values only)" + } + }, + "additionalProperties": false + }, + "ConfigurationRunRef": { + "type": "string", + "pattern": "^(trial_[0-9a-f]{16}|configuration_run_[0-9a-f]{32})$", + "minLength": 22, + "maxLength": 50, + "description": "The public reference of the configuration run: a server-issued trial_ or configuration_run_ reference." + } + } +} diff --git a/traigent_schema/schemas/execution/configuration_run_problem_schema.json b/traigent_schema/schemas/execution/configuration_run_problem_schema.json new file mode 100644 index 00000000..913bc627 --- /dev/null +++ b/traigent_schema/schemas/execution/configuration_run_problem_schema.json @@ -0,0 +1,128 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/execution/configuration_run_problem_schema.json", + "title": "Configuration Run Read Problems", + "description": "Closed RFC 9457 problem documents (application/problem+json) of the configuration run measurement and status reads. Each definition is one fixed status and code with fixed title and detail; nothing the client sent is echoed. NotFoundProblem (404, not_found) is the one answer for a missing, foreign, ungranted or wrong-parent configuration run: identical bytes in every case. BadRequestProblem (400, bad_request) is a query parameter that fails its declared format or range: a limit out of range, or a cursor that does not match the declared token format, or an unknown query parameter. InvalidCursorProblem (400, invalid_cursor) is a well-formed cursor that cannot be used: the stored results changed since it was issued, or it belongs to another configuration run or page shape.", + "definitions": { + "BadRequestProblem": { + "type": "object", + "additionalProperties": false, + "required": [ + "type", + "title", + "status", + "code", + "detail", + "problem_id" + ], + "x-privacy-classification": "aggregate_safe", + "properties": { + "type": { + "const": "urn:traigent:problem:bad_request", + "x-content-class": "closed_enum" + }, + "title": { + "const": "Bad Request", + "x-content-class": "closed_enum" + }, + "status": { + "const": 400, + "x-content-class": "closed_enum" + }, + "code": { + "const": "bad_request", + "x-content-class": "closed_enum" + }, + "detail": { + "const": "The request could not be processed.", + "x-content-class": "closed_enum" + }, + "problem_id": { + "const": "85bc321f5be7a6bf86cb2d354c10a826", + "x-content-class": "opaque_ref" + } + }, + "description": "A query parameter fails its declared format or range (limit out of range, a cursor that does not match the declared token format) or is not declared." + }, + "InvalidCursorProblem": { + "type": "object", + "additionalProperties": false, + "required": [ + "type", + "title", + "status", + "code", + "detail", + "problem_id" + ], + "x-privacy-classification": "aggregate_safe", + "properties": { + "type": { + "const": "urn:traigent:problem:invalid_cursor", + "x-content-class": "closed_enum" + }, + "title": { + "const": "Bad Request", + "x-content-class": "closed_enum" + }, + "status": { + "const": 400, + "x-content-class": "closed_enum" + }, + "code": { + "const": "invalid_cursor", + "x-content-class": "closed_enum" + }, + "detail": { + "const": "The cursor is not valid for this request.", + "x-content-class": "closed_enum" + }, + "problem_id": { + "const": "08264e9e27e2b651775ee2401912941c", + "x-content-class": "opaque_ref" + } + }, + "description": "A well-formed cursor that cannot be used: the stored results changed since it was issued, or it belongs to another configuration run or page shape." + }, + "NotFoundProblem": { + "type": "object", + "additionalProperties": false, + "required": [ + "type", + "title", + "status", + "code", + "detail", + "problem_id" + ], + "x-privacy-classification": "aggregate_safe", + "properties": { + "type": { + "const": "urn:traigent:problem:not_found", + "x-content-class": "closed_enum" + }, + "title": { + "const": "Not Found", + "x-content-class": "closed_enum" + }, + "status": { + "const": 404, + "x-content-class": "closed_enum" + }, + "code": { + "const": "not_found", + "x-content-class": "closed_enum" + }, + "detail": { + "const": "The requested resource was not found.", + "x-content-class": "closed_enum" + }, + "problem_id": { + "const": "2662cfb75ed0a8574c3d105e1a28dc67", + "x-content-class": "opaque_ref" + } + }, + "description": "The configuration run is missing, foreign, ungranted or outside the named parent; identical bytes in every case." + } + } +} diff --git a/traigent_schema/schemas/execution/configuration_run_status_response_schema.json b/traigent_schema/schemas/execution/configuration_run_status_response_schema.json new file mode 100644 index 00000000..7c27332f --- /dev/null +++ b/traigent_schema/schemas/execution/configuration_run_status_response_schema.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/execution/configuration_run_status_response_schema.json", + "title": "Configuration Run Status Response", + "description": "Success envelope for GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/status: the current status of one configuration run. `data` carries the same two fields the run-owned status read returned, `status` and `error_message` (null when there is none). The message is fixed text.", + "type": "object", + "additionalProperties": false, + "required": [ + "success", + "message", + "data" + ], + "properties": { + "success": { + "type": "boolean", + "const": true + }, + "message": { + "type": "string", + "const": "Configuration run status retrieved successfully." + }, + "data": { + "type": "object", + "additionalProperties": false, + "required": [ + "status", + "error_message" + ], + "properties": { + "status": { + "type": "string", + "enum": [ + "NOT_STARTED", + "RUNNING", + "COMPLETED", + "FAILED", + "UNKNOWN", + "CANCELLED", + "PRUNED" + ], + "description": "Status of the configuration run." + }, + "error_message": { + "type": [ + "string", + "null" + ], + "description": "The failure message recorded for the run, or null." + } + } + } + } +} diff --git a/traigent_schema/schemas/execution/execution_endpoints.json b/traigent_schema/schemas/execution/execution_endpoints.json index 6f4c3174..9db12eb0 100644 --- a/traigent_schema/schemas/execution/execution_endpoints.json +++ b/traigent_schema/schemas/execution/execution_endpoints.json @@ -571,36 +571,6 @@ } } }, - "/api/v1/experiment-runs/runs/{experiment_run_id}/configurations": { - "post": { - "summary": "Create configuration run from experiment run", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "../evaluation/configuration_run_create_request_schema.json" - } - } - } - }, - "responses": { - "201": { - "description": "Configuration run created successfully" - }, - "429": { - "description": "Too many requests — rate limit exceeded.", - "content": { - "application/json": { - "schema": { - "$ref": "../rate_limit_info_schema.json" - } - } - } - } - } - } - }, "/api/v1/experiment-runs/runs/{run_id}": { "get": { "summary": "Get experiment run", @@ -712,26 +682,6 @@ } } }, - "/api/v1/experiment-runs/runs/{run_id}/configurations": { - "get": { - "summary": "List configuration runs for an experiment run", - "responses": { - "200": { - "description": "Configuration runs retrieved successfully" - }, - "429": { - "description": "Too many requests — rate limit exceeded.", - "content": { - "application/json": { - "schema": { - "$ref": "../rate_limit_info_schema.json" - } - } - } - } - } - } - }, "/api/v1/experiment-runs/runs/{run_id}/traces": { "get": { "summary": "Get paginated traces for an experiment run", @@ -1039,6 +989,77 @@ } }, "/api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/status": { + "get": { + "summary": "Get configuration run status", + "operationId": "configuration_run.get_configuration_run_status", + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "The project id.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "configuration_run_ref", + "in": "path", + "required": true, + "description": "Configuration run reference: a server-issued `configuration_run_` reference; previously issued `trial_` references and configuration run ids are also accepted.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "expected_run_ref", + "in": "query", + "required": false, + "description": "Optional experiment run reference. When present and the configuration run does not belong to that experiment run, the answer is the same closed 404 as for an absent configuration run.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + } + ], + "responses": { + "200": { + "description": "Configuration run status retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./configuration_run_status_response_schema.json" + } + } + } + }, + "404": { + "description": "Closed 404: missing, foreign, ungranted or wrong-project configuration run, or a configuration run that does not belong to the experiment run named in expected_run_ref; identical bytes in every case.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "./configuration_run_problem_schema.json#/definitions/NotFoundProblem" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, "put": { "summary": "Update configuration run status", "operationId": "configuration_run.update_configuration_run_status", @@ -1109,6 +1130,107 @@ } }, "/api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/measurement": { + "get": { + "summary": "Get configuration run measurement", + "operationId": "configuration_run.get_configuration_run_measurement", + "parameters": [ + { + "name": "project_id", + "in": "path", + "required": true, + "description": "The project id.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "configuration_run_ref", + "in": "path", + "required": true, + "description": "Configuration run reference: a server-issued `configuration_run_` reference; previously issued `trial_` references and configuration run ids are also accepted.", + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 128 + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "Page size for per-example measures; default 100, maximum 100. Ignored for flat measures. 0, 101, booleans and non-integers are rejected.", + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 100 + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "description": "Opaque sealed next_cursor of the previous page, bound to the caller, project and configuration run; at most 512 characters of base64url. Never a raw index.", + "schema": { + "type": "string", + "pattern": "^[A-Za-z0-9_-]{1,512}$", + "minLength": 1, + "maxLength": 512 + } + } + ], + "responses": { + "200": { + "description": "Configuration run measurement retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "./configuration_run_measurement_response_schema.json" + } + } + } + }, + "400": { + "description": "A query parameter fails its declared format or range (limit out of range, a cursor that does not match the declared token format) or is not declared: bad_request; echoes no client value. A well-formed cursor that cannot be used (the stored results changed since it was issued, or it belongs to another configuration run or page shape) is the closed invalid_cursor 400.", + "content": { + "application/problem+json": { + "schema": { + "oneOf": [ + { + "$ref": "./configuration_run_problem_schema.json#/definitions/BadRequestProblem" + }, + { + "$ref": "./configuration_run_problem_schema.json#/definitions/InvalidCursorProblem" + } + ] + } + } + } + }, + "404": { + "description": "Closed 404: missing, foreign, ungranted or wrong-project configuration run; identical bytes in every case.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "./configuration_run_problem_schema.json#/definitions/NotFoundProblem" + } + } + } + }, + "429": { + "description": "Too many requests — rate limit exceeded.", + "content": { + "application/json": { + "schema": { + "$ref": "../rate_limit_info_schema.json" + } + } + } + } + } + }, "put": { "summary": "Update configuration run measurement", "operationId": "configuration_run.update_configuration_run_measurement", From 3060a114171ce8fe2d36f58e984df7970c466474 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 04:57:03 +0200 Subject: [PATCH 14/20] chore: regenerate parity and reachability for the combined contracts Co-Authored-By: Claude Sonnet 5.5 --- parity/python-js-sdk.json | 4 ++-- reports/schema_reachability/unreachable_schemas.json | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index de294b9c..9e0f3a82 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,8 +399,8 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "3a81a026324ba1ff7062b224f4edcd0a1a6fff2ae4ee6d5f0404f920314fd11d", - "schemaFileCount": 681, + "lastSchemaFileSha": "5e69d7ea1beaf28484d599d25f9223f35b35df3f06628b2b85bb74463ae9a0e3", + "schemaFileCount": 690, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } } diff --git a/reports/schema_reachability/unreachable_schemas.json b/reports/schema_reachability/unreachable_schemas.json index e4b1f2ad..67ab78c8 100644 --- a/reports/schema_reachability/unreachable_schemas.json +++ b/reports/schema_reachability/unreachable_schemas.json @@ -10,11 +10,11 @@ "reachableByRule": { "allowlist": 0, "consumerReference": 33, - "refOrEndpointGraph": 584 + "refOrEndpointGraph": 596 }, - "reachableCount": 617, - "schemaFileCount": 680, - "unreachableCount": 63 + "reachableCount": 629, + "schemaFileCount": 690, + "unreachableCount": 61 }, "unreachableSchemas": [ "agent_lifecycle_record/agent_lifecycle_agent_revision_register_request_schema.json", @@ -34,10 +34,8 @@ "certification/certificate_registry_agent_revision_v0_schema.json", "certification/certificate_registry_measurement_contract_v0_schema.json", "certification/certificate_rejection_v0_schema.json", - "certification/commitment_linkage_v1_schema.json", "certification/dataset_record_v1_schema.json", "certification/evaluator_quality_v1_schema.json", - "certification/process_record_v1_schema.json", "certification/prohibited_register_baseline_v1_schema.json", "connectors/connector_run_summary.json", "connectors/correlation_summary.json", From bf4ba37caac371cf8c6b6d6cf10ce423d13a5517 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 04:58:09 +0200 Subject: [PATCH 15/20] fix(contract): acknowledge the closed group problem union gaining the two idempotency variants Co-Authored-By: Claude Sonnet 5.5 --- scripts/breaking_schema_allowlist.json | 361 +++++++++++++++++++++++++ 1 file changed, 361 insertions(+) diff --git a/scripts/breaking_schema_allowlist.json b/scripts/breaking_schema_allowlist.json index 0bc31f6a..295a2c35 100644 --- a/scripts/breaking_schema_allowlist.json +++ b/scripts/breaking_schema_allowlist.json @@ -11426,6 +11426,367 @@ "reason": "BREAKING PUBLIC CHANGE (pre-release). The run-owned configuration aliases are removed: POST /api/v1/experiment-runs/runs/{experiment_run_id}/configurations and GET /api/v1/experiment-runs/runs/{run_id}/configurations. They carried no operation id and duplicated the canonical collection; use POST and GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/configuration-runs (configuration_run.create_configuration_run and configuration_run.get_configuration_runs). Request and response bodies are those of the canonical operations. Consumers: the Python SDK and the Backend, updated in the same release.", "version": "Unreleased", "pr": "pending" + }, + { + "file": "execution/execution_endpoints.json", + "rule": "oneOf_branch_count_changed", + "findings": [ + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/400/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "7d87c4f345c3a5be84c9d883d5a31ea0c666cfcedaf4bac6d20b60620b5dddbd" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/401/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "43c90ac3e06878bf9a37a1537097cd0c085a3bb7092aa8cef3271e8a23272294" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/403/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "615d20732cd1de4ea29c673bb53b554da370b29258493ca0694a0b82b5d6a5d3" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/404/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "613332c40972387de237c4d197c6a65b55dc1981397c68bce066219d91df3556" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/413/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "3853b048424b039e94db223c27a921edff65ef4d0b33bd1ea343e17eb3fa828a" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/422/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "292bd6f2072062bfc2bf80663d2ce0faf682ca63145ebf8a958dc2da48324b08" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/429/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "16c2f5bf042b662b8dac2367bf578069cadaf554ad6a3c8da00590b1121302c8" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/500/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "675245aca21574a389dd7a71be4e362e9d50ce7e4144916dcb3a1cd6b8a3ee1d" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/search/post/responses/503/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "7606280c3a76e3c83bc95a39d8cc7c1603f54d7a66264b433b8ca74705fce4d8" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/400/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "8d095f77c2b8a54d124cb638e2a941fd9b0e825a062c886b616df8e84e33991e" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/401/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "1b7fc04ec13a28215214f0eb68bccf5cbcb6d54bc9805a2b3bc6a1eb27ca6c71" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/403/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "91544acfb1074a37ba3d817a1dca0bcde6daa7cf96912919721ece96870af7e7" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/404/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "d8fb850903f26a4facfe67fd4aff6a53ac07ffe96a1a82eb231e6245d1d7b275" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/413/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "5fd17f6a77d8c014a4e13932b57ceb67f3e20b0f607d0cfe8d4450a7525238b4" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/422/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "da4d5d2932f23dc180e67f13fd433ba037cd62c90d3d91193f274a862f6a7f26" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/429/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "7b247d124b35a66e7b049c78d906c1f40956eff762b2cc683ac7912dfb242a9b" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/500/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "1a2a11e639d99813eef4e205aae896d3517c84d496dde7eea135111df7a1e651" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/get/responses/503/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "c39bdfa91b8902043cf10f49a226a8e8fbe08c8169bdfd6c84c24dd486e0b000" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/400/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "88e1b77fce2a1db43ff5b11e4cbcb6683fa1a681345eac7e8df43b03ac42ef9c" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/401/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "c7db5c442334e2461f3702a19d4ef661ce441791a43798a9b017bb5effe60886" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/403/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "d07d05856d9cb49b3a75febe4535f56b2a528143d4d6ed9890e1abf529c0d99c" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/404/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "e7759edd3ccec92eff315e9553b15400cad6fb78bfcad09d5606e8ee076f1290" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/413/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "9f3e92a0fcb1c3ad8c6c8eb928e07aca20613dc3cbfe86875eca8d3c688fe9f5" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/422/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "97122563b746e220722266e39d1a28602feb5fde21305a10648d783783f87dd9" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/429/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "6dc5e5a461eb62de222f999b65daf751e57b2c7c1e1f9cca8957ce43be412b96" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/500/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "242a5f0b2ae9140ab72b4a3904ab386c1c564695c8aac78ef78d6f51e7454d44" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/get/responses/503/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "7ca462430d64f41bbc09a8af4b1536ce1989d6287e65f7f4aa7eb98cea1e8b53" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/400/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "667de2a0f513e1bfc1b9f8a492000ca107cd0b4f768d4c16c7b8fd749d441f1f" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/401/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "ffb8f9c2448cc3bfe3ac606233e273cf0def1e27fe3be3ea68e109f2cf2152ea" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/403/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "b2711370aebb4fa0e8e7e4c9bde5b053d52e142caa8fb44ce58d14a198f0c400" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/404/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "cb3babec7e66603e016e4944a06e8deb4a44aa873edbd099bc2a0ba7d940788b" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/413/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "785b4ef53a5da6a15ab11a9d2479fbc1bb6767631425dc9b74e904b384121850" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/422/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "2b859e4d7ea96a470f34543708fc1c4a9f4f0bb495c1b53d875891b3811b2a58" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/429/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "70139d064acff30f7e6b712b2e39f6593a51de279d9697ffabea6359e2c8d4a1" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/500/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "79f7ac495cc6175dc44c378c0a1e4327700c48d8096d721f064f5f839fe4cac8" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/configuration-runs/query/post/responses/503/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "373227e056c7c3481f1efa016ff2fe648310b2b38d94984fb59ddd373fff0e96" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/400/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "1ab6ed56004c30ec3382b7b8339d1034cf417553c86c528ba3698b69d2649b1b" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/401/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "3a51a4ad35bdfd0989afc1910ce4bf542fd5b375ac8b609e3f4db18cad8888bd" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/403/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "44aaf6495613c2462e6de17776f73ff9bb49cc1ee2a8b30f509e9df818e17295" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/404/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "f9a554f94510b7129cfae2121da4f1d514f0293655bd616ce4623b2028e1a685" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/413/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "e250bb9867c6a21a47f650dde8b40d3643c4d217640323ba4436512b2815219c" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/429/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "e315913caaae0a77dc2a7ce1407339e99e709525822ef3c032de4b1d93f2d556" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/500/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "e18e006ca6dd0e17fece7c084bcc2c0cf3ee38b277f178c2033ff83a2a2d3d40" + }, + { + "pointer": "#/paths//api/v1/projects/{project_id}/experiment-groups/{group_ref}/experiments/get/responses/503/content/application/problem+json/schema/oneOf", + "role": "response", + "subject": "oneOf", + "old": 11, + "new": 13, + "fingerprint": "ec128a935b76a77ae1f1f1f849a68bccec926f76402d2d9d21926328ffb2e05d" + } + ], + "reason": "The closed group problem union gains two variants, idempotency_conflict and idempotency_in_progress, so the group run query can declare its 409 responses. Every problem response that references the union lists the two additional closed variants; the branch count rises from 11 to 13 and no existing variant changes. The two variants are closed objects with fixed type, title, status, code and detail values.", + "version": "Unreleased", + "pr": "Traigent/TraigentSchema#TBD" } ] } From 965c25c24dec3c20141f30233952457eb06c9c8f Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 05:48:09 +0200 Subject: [PATCH 16/20] test(contract): the group run query declares the idempotency 409 and its two closed problem variants Co-Authored-By: Claude Sonnet 5.5 --- tests/test_experiment_group_contract.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_experiment_group_contract.py b/tests/test_experiment_group_contract.py index 58683a9d..a10b07e4 100644 --- a/tests/test_experiment_group_contract.py +++ b/tests/test_experiment_group_contract.py @@ -1186,6 +1186,9 @@ def test_read_surfaces_expose_closed_problem_responses_for_every_declared_status # 422 is declared everywhere except the experiments listing. if not path.endswith("/experiments"): expected["422"] = "GroupsValidationFailed" + # Only the group run query is idempotent, so only it declares the 409. + if (method, path.rsplit("/", 1)[-1]) == ("post", "query"): + expected["409"] = "GroupsConflict" assert names == expected, (path, method) not_found = spec["components"]["responses"]["GroupsNotFound"] @@ -1210,6 +1213,8 @@ def _problem_validator(spec: dict[str, Any]) -> Draft7Validator: "service_unavailable": (503, "Service Unavailable"), "unauthenticated": (401, "Unauthorized"), "validation_failed": (422, "Unprocessable Content"), + "idempotency_conflict": (409, "Conflict"), + "idempotency_in_progress": (409, "Conflict"), } @@ -1237,6 +1242,7 @@ def test_group_problem_bodies_are_application_problem_json_with_a_closed_code() "GroupsForbidden", "GroupsRateLimited", "GroupsInternalError", + "GroupsConflict", } for name, response in responses.items(): assert list(response["content"]) == ["application/problem+json"], name From b2215f7c63b54cf40eb4be249d165239299f1927 Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 05:49:58 +0200 Subject: [PATCH 17/20] fix(contract): bound process-record request strings Co-Authored-By: Claude Sonnet 5.5 --- parity/python-js-sdk.json | 2 +- .../process_record_request_schema.json | 45 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index 9e0f3a82..5f77ee59 100644 --- a/parity/python-js-sdk.json +++ b/parity/python-js-sdk.json @@ -399,7 +399,7 @@ "sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket." }, "schemaRefresh": { - "lastSchemaFileSha": "5e69d7ea1beaf28484d599d25f9223f35b35df3f06628b2b85bb74463ae9a0e3", + "lastSchemaFileSha": "eb75d4ac806eecffe4b4c7ff6a2d8921e497214e3efff367adfb07aa1451ea82", "schemaFileCount": 690, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } diff --git a/traigent_schema/schemas/certification/process_record_request_schema.json b/traigent_schema/schemas/certification/process_record_request_schema.json index 87b5d1e8..60d1b339 100644 --- a/traigent_schema/schemas/certification/process_record_request_schema.json +++ b/traigent_schema/schemas/certification/process_record_request_schema.json @@ -6,6 +6,7 @@ "definitions": { "ProcessRecordReference": { "type": "string", + "maxLength": 47, "pattern": "^bsn:[A-Za-z0-9_-]{43}(?![\\s\\S])", "description": "Use the build_session_ref returned when the certificate build session was created. These routes cover issuances created through a certificate build session. A certificate that carries a runlineage: reference is not addressed here and stays on the existing certification routes. Prepare echoes the same reference. Resolve it within the named project." }, @@ -39,15 +40,15 @@ "expected_project_ref" ], "properties": { - "expected_nonce": {"type": "string", "minLength": 1}, + "expected_nonce": {"type": "string", "minLength": 1, "maxLength": 64}, "expected_build_session_ref": {"$ref": "#/definitions/SignedReference"}, "expected_issuer_key_ref": {"$ref": "#/definitions/SignedReference"}, - "expected_issuer_algorithm": {"type": "string", "minLength": 1}, + "expected_issuer_algorithm": {"type": "string", "minLength": 1, "enum": ["ecdsa_p256_sha256", "ed25519"]}, "expected_trust_ring_ref": {"$ref": "#/definitions/SignedReference"}, "expected_project_ref": {"$ref": "#/definitions/ProjectReference"}, - "expected_client_key_ref": {"type": ["string", "null"]}, - "expected_client_algorithm": {"type": ["string", "null"]}, - "client_public_key_der_b64": {"type": ["string", "null"]} + "expected_client_key_ref": {"type": ["string", "null"], "maxLength": 47}, + "expected_client_algorithm": {"type": ["string", "null"], "enum": ["ecdsa_p256_sha256", "ed25519", null]}, + "client_public_key_der_b64": {"type": ["string", "null"], "maxLength": 512} }, "oneOf": [ { @@ -60,9 +61,9 @@ { "required": ["expected_client_key_ref", "expected_client_algorithm", "client_public_key_der_b64"], "properties": { - "expected_client_key_ref": {"type": "string", "minLength": 1}, - "expected_client_algorithm": {"type": "string", "minLength": 1}, - "client_public_key_der_b64": {"type": "string", "minLength": 1} + "expected_client_key_ref": {"type": "string", "minLength": 1, "maxLength": 47}, + "expected_client_algorithm": {"type": "string", "minLength": 1, "enum": ["ecdsa_p256_sha256", "ed25519"]}, + "client_public_key_der_b64": {"type": "string", "minLength": 1, "maxLength": 512} } } ] @@ -92,23 +93,23 @@ "verification_materials_v0": {"$ref": "./certificate_verification_materials_v0_schema.json"}, "v0_context_kwargs": {"$ref": "#/definitions/VerificationContextV0"}, "claim_id": {"enum": ["PROC1", null, ""], "default": "PROC1"}, - "experiment_run_id": {"type": ["string", "null"], "minLength": 1}, + "experiment_run_id": {"type": ["string", "null"], "minLength": 1, "maxLength": 100}, "openings": { "type": "object", "additionalProperties": false, "properties": { - "agent": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "dataset": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "config_space": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:primary": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r0": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r1": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r2": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r3": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r4": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r5": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r6": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"}, - "evaluator:r7": {"type": "string", "pattern": "^[A-Za-z0-9+/]{43}=$"} + "agent": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "dataset": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "config_space": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:primary": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r0": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r1": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r2": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r3": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r4": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r5": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r6": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"}, + "evaluator:r7": {"type": "string", "maxLength": 44, "pattern": "^[A-Za-z0-9+/]{43}=$"} }, "minProperties": 1 } @@ -160,7 +161,7 @@ "properties": { "key_ref": {"$ref": "#/definitions/SignedReference"}, "algorithm": {"enum": ["ed25519", "ecdsa_p256_sha256"]}, - "public_key_der_b64": {"type": "string", "minLength": 1}, + "public_key_der_b64": {"type": "string", "minLength": 1, "maxLength": 512}, "public_key_digest": {"$ref": "#/definitions/Sha256Reference"} } }, From 8a93de50e82cc9581b2c75f0b3dc0960e220bb1a Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 06:50:16 +0200 Subject: [PATCH 18/20] docs(changelog): scope the certification 404 note, give the group-run 409 its own fragment, combine the configuration-run reads, note deprecated dataset paths Co-Authored-By: Claude Opus 5.5 --- changelog.d/certification-project-paths.added.md | 2 +- changelog.d/configuration-run-measurement-read.added.md | 1 - changelog.d/configuration-run-reads.added.md | 2 ++ changelog.d/configuration-run-status-read.added.md | 1 - changelog.d/dataset-metric-project-paths.added.md | 6 ++---- changelog.d/group-run-query-idempotency-conflicts.added.md | 3 +++ 6 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 changelog.d/configuration-run-measurement-read.added.md create mode 100644 changelog.d/configuration-run-reads.added.md delete mode 100644 changelog.d/configuration-run-status-read.added.md create mode 100644 changelog.d/group-run-query-idempotency-conflicts.added.md diff --git a/changelog.d/certification-project-paths.added.md b/changelog.d/certification-project-paths.added.md index 1378154e..9e326458 100644 --- a/changelog.d/certification-project-paths.added.md +++ b/changelog.d/certification-project-paths.added.md @@ -1 +1 @@ -- **Project-scoped certification contracts.** New operations under `/api/v1/projects/{project_id}/`: certificate build-session issuance readiness and abandonment, and process-record preparation, verification, retrieval and finalization. Every process-record call takes the build-session reference (`bsn:...`); a reference whose build session is not finalized returns `404` with code `LINEAGE_UNMAPPED`. Certificates that carry a `runlineage:` reference stay on the existing certification routes, which are unchanged. Error bodies are closed, including the browser-session `401` variants (`CSRF_VALIDATION_FAILED`, `SESSION_IDLE_EXPIRED`, `SESSION_ABSOLUTE_EXPIRED`, `SESSION_INVALID`). Additive: no existing operation is changed or removed. +- **Project-scoped certification contracts.** New operations under `/api/v1/projects/{project_id}/`: certificate build-session issuance readiness and abandonment, and process-record preparation, verification, retrieval and finalization. Every process-record call takes the build-session reference (`bsn:...`). Before the build session is finalized, prepare and finalize return `404` with code `LINEAGE_UNMAPPED`; retrieval returns `404` `PROCESS_RECORD_NOT_FOUND` until an issuance exists. Certificates that carry a `runlineage:` reference stay on the existing certification routes, which are unchanged. Error bodies are closed, including the browser-session `401` variants (`CSRF_VALIDATION_FAILED`, `SESSION_IDLE_EXPIRED`, `SESSION_ABSOLUTE_EXPIRED`, `SESSION_INVALID`). Additive: no existing operation is changed or removed. diff --git a/changelog.d/configuration-run-measurement-read.added.md b/changelog.d/configuration-run-measurement-read.added.md deleted file mode 100644 index 66cd460b..00000000 --- a/changelog.d/configuration-run-measurement-read.added.md +++ /dev/null @@ -1 +0,0 @@ -- **`configuration_run.get_configuration_run_measurement`: the stored measures of a configuration run, read as one bounded page (additive).** `GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/measurement` returns the new `execution/configuration_run_measurement_response_schema.json`: `data.shape` is `flat` (a map of measure names to numbers in `measures`) or `per_example` (a cursor page of `items`; each item is either a `MeasurementItem` with `example_id` and metrics, or a bare metric map from the older stored form that has no `example_id`; metric values may be null), with `pagination` (`limit` default and maximum 100, `next_cursor`, `has_more`, `total`). Query: `limit` and `cursor`. The cursor is sealed and opaque; a cursor is invalidated when the stored results change, and a stale one is the closed 400 `invalid_cursor`. Path parameters are as for the other configuration-run operations. diff --git a/changelog.d/configuration-run-reads.added.md b/changelog.d/configuration-run-reads.added.md new file mode 100644 index 00000000..845720be --- /dev/null +++ b/changelog.d/configuration-run-reads.added.md @@ -0,0 +1,2 @@ +- **`configuration_run.get_configuration_run_measurement`: the stored measures of a configuration run, read as one bounded page (additive).** `GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/measurement` returns the new `execution/configuration_run_measurement_response_schema.json`: `data.shape` is `flat` (a map of measure names to numbers or null in `measures`) or `per_example` (a cursor page of `items`; each item is either a `MeasurementItem` with `example_id` and metrics, or a bare metric map from the older stored form that has no `example_id`; metric values may be null), with `pagination` (`limit` default and maximum 100, `next_cursor`, `has_more`, `total`). Query: `limit` and `cursor`. The cursor is sealed and opaque; a cursor is invalidated when the stored results change, and a stale one is the closed 400 `invalid_cursor`. Path parameters are as for the other configuration-run operations. +- **`configuration_run.get_configuration_run_status`: the status of a configuration run on its own reference (additive).** `GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/status` returns the new `execution/configuration_run_status_response_schema.json`: `data.status` (the shared configuration-run status) and `data.error_message` (string or null, any length the update accepts), with a fixed success message. It replaces the run-owned status read. The 404 is the closed `NotFoundProblem`, identical for a missing, foreign or ungranted configuration run. Path parameters are as for the other configuration-run operations. The optional query parameter `expected_run_ref` (an experiment run reference) makes a configuration run that does not belong to that experiment run answer the same closed 404 as an absent one. diff --git a/changelog.d/configuration-run-status-read.added.md b/changelog.d/configuration-run-status-read.added.md deleted file mode 100644 index aae2f312..00000000 --- a/changelog.d/configuration-run-status-read.added.md +++ /dev/null @@ -1 +0,0 @@ -- **`configuration_run.get_configuration_run_status`: the status of a configuration run on its own reference (additive).** `GET /api/v1/projects/{project_id}/configuration-runs/{configuration_run_ref}/status` returns the new `execution/configuration_run_status_response_schema.json`: `data.status` (the shared configuration-run status) and `data.error_message` (string or null, any length the update accepts), with a fixed success message. It replaces the run-owned status read. The 404 is the closed `NotFoundProblem`, identical for a missing, foreign or ungranted configuration run. Path parameters are as for the other configuration-run operations. The optional query parameter `expected_run_ref` (an experiment run reference) makes a configuration run that does not belong to that experiment run answer the same closed 404 as an absent one. diff --git a/changelog.d/dataset-metric-project-paths.added.md b/changelog.d/dataset-metric-project-paths.added.md index 46b51d26..f211ffc8 100644 --- a/changelog.d/dataset-metric-project-paths.added.md +++ b/changelog.d/dataset-metric-project-paths.added.md @@ -1,14 +1,12 @@ - **Project-scoped dataset paths.** Datasets, their examples, files, upload, example generation, public-benchmark marking and version content identity are declared under `/api/v1/projects/{project_id}/datasets/...`. Additive: - no existing path is removed. + no existing path is removed; the unscoped dataset paths stay and are marked + deprecated, with removal unscheduled. - **Metric operations.** New `metric.*` operations: list and create a project's metrics at `/api/v1/projects/{project_id}/metrics`; list and create library metrics at `/api/v1/metrics`; and get, update (`PATCH`) and delete one metric at `/api/v1/metrics/{metric_ref}`. Metric descriptions may be null. Writes reject evaluator fields with a closed validation problem. -- **Idempotency conflicts on the group run query.** - `experiment_group.query_group_runs` declares its `409` responses - (`idempotency_conflict`, `idempotency_in_progress`). - **Fragment references.** The schema validator resolves `$ref` values that point into another file (`file.json#/pointer`). diff --git a/changelog.d/group-run-query-idempotency-conflicts.added.md b/changelog.d/group-run-query-idempotency-conflicts.added.md new file mode 100644 index 00000000..9d7a2ca6 --- /dev/null +++ b/changelog.d/group-run-query-idempotency-conflicts.added.md @@ -0,0 +1,3 @@ +- **Idempotency conflicts on the group run query.** + `experiment_group.query_group_runs` declares its `409` responses + (`idempotency_conflict`, `idempotency_in_progress`). From cb0fb027061ca00d6d4b6fd34cb771ae0aebd3dc Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 06:52:17 +0200 Subject: [PATCH 19/20] docs(changelog): limit the dataset deprecation note to paths with project-scoped replacements Co-Authored-By: Claude Opus 5.5 --- changelog.d/dataset-metric-project-paths.added.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog.d/dataset-metric-project-paths.added.md b/changelog.d/dataset-metric-project-paths.added.md index f211ffc8..35db526e 100644 --- a/changelog.d/dataset-metric-project-paths.added.md +++ b/changelog.d/dataset-metric-project-paths.added.md @@ -1,8 +1,9 @@ - **Project-scoped dataset paths.** Datasets, their examples, files, upload, example generation, public-benchmark marking and version content identity are declared under `/api/v1/projects/{project_id}/datasets/...`. Additive: - no existing path is removed; the unscoped dataset paths stay and are marked - deprecated, with removal unscheduled. + no existing path is removed; each unscoped dataset path that now has a + project-scoped replacement stays and is marked deprecated, with removal + unscheduled. - **Metric operations.** New `metric.*` operations: list and create a project's metrics at `/api/v1/projects/{project_id}/metrics`; list and create library metrics at `/api/v1/metrics`; and get, update (`PATCH`) and From d05a6b5ffa89cfbd75726e803dc13ce4eee5782c Mon Sep 17 00:00:00 2001 From: Nimrod Busany Date: Fri, 27 Nov 2026 07:03:45 +0200 Subject: [PATCH 20/20] chore(allowlist): record the PR for the project-scoped contract batch Co-Authored-By: Claude Opus 5.5 --- scripts/breaking_schema_allowlist.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/breaking_schema_allowlist.json b/scripts/breaking_schema_allowlist.json index f624cd5a..56a1612f 100644 --- a/scripts/breaking_schema_allowlist.json +++ b/scripts/breaking_schema_allowlist.json @@ -11417,7 +11417,7 @@ ], "reason": "Route moved to its project-scoped canonical path with the same operation id; the backend retires the old path with a closed 404.", "version": "Unreleased", - "pr": "Traigent/TraigentSchema#TBD" + "pr": "https://github.com/Traigent/TraigentSchema/pull/775" }, { "file": "execution/execution_endpoints.json", @@ -11442,7 +11442,7 @@ ], "reason": "BREAKING PUBLIC CHANGE (pre-release). The run-owned configuration aliases are removed: POST /api/v1/experiment-runs/runs/{experiment_run_id}/configurations and GET /api/v1/experiment-runs/runs/{run_id}/configurations. They carried no operation id and duplicated the canonical collection; use POST and GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/configuration-runs (configuration_run.create_configuration_run and configuration_run.get_configuration_runs). Request and response bodies are those of the canonical operations. Consumers: the Python SDK and the Backend, updated in the same release.", "version": "Unreleased", - "pr": "pending" + "pr": "https://github.com/Traigent/TraigentSchema/pull/775" }, { "file": "execution/execution_endpoints.json", @@ -11803,7 +11803,7 @@ ], "reason": "The closed group problem union gains two variants, idempotency_conflict and idempotency_in_progress, so the group run query can declare its 409 responses. Every problem response that references the union lists the two additional closed variants; the branch count rises from 11 to 13 and no existing variant changes. The two variants are closed objects with fixed type, title, status, code and detail values.", "version": "Unreleased", - "pr": "Traigent/TraigentSchema#TBD" + "pr": "https://github.com/Traigent/TraigentSchema/pull/775" } ] }