diff --git a/.github/workflows/auth-taxonomy-parity.yml b/.github/workflows/auth-taxonomy-parity.yml index c2395a6c..f593cacf 100644 --- a/.github/workflows/auth-taxonomy-parity.yml +++ b/.github/workflows/auth-taxonomy-parity.yml @@ -30,10 +30,15 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: auth-taxonomy-parity: name: Auth-taxonomy parity (DETECT, non-blocking) runs-on: ubuntu-latest + timeout-minutes: 10 # Non-blocking: surface drift as a signal, never fail the PR on it. continue-on-error: true diff --git a/.github/workflows/parity-check.yml b/.github/workflows/parity-check.yml index e3170f12..5edb4269 100644 --- a/.github/workflows/parity-check.yml +++ b/.github/workflows/parity-check.yml @@ -18,10 +18,15 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: parity-check: name: Parity manifest freshness runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4ea00e50..b16d1c0b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,6 +25,7 @@ jobs: name: Verify exact main release ref if: inputs.confirm_publish == true runs-on: ubuntu-latest + timeout-minutes: 10 permissions: contents: read outputs: @@ -64,6 +65,7 @@ jobs: publish: needs: verify-release-ref runs-on: ubuntu-latest + timeout-minutes: 30 if: inputs.confirm_publish == true && needs.verify-release-ref.result == 'success' environment: ${{ inputs.environment || 'testpypi' }} outputs: @@ -218,6 +220,7 @@ jobs: verify-publication: needs: [verify-release-ref, publish] runs-on: ubuntu-latest + timeout-minutes: 10 if: >- always() && needs.verify-release-ref.result == 'success' && diff --git a/.github/workflows/schema-orphan-check.yml b/.github/workflows/schema-orphan-check.yml index 0547ec77..fd5a4ce8 100644 --- a/.github/workflows/schema-orphan-check.yml +++ b/.github/workflows/schema-orphan-check.yml @@ -32,10 +32,15 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: schema-orphan-check: name: Schema reachability report freshness runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/spine-trail-gate.yml b/.github/workflows/spine-trail-gate.yml index 4dde172e..8be1125a 100644 --- a/.github/workflows/spine-trail-gate.yml +++ b/.github/workflows/spine-trail-gate.yml @@ -31,6 +31,7 @@ jobs: spine-trail: name: spine-trail present runs-on: ubuntu-latest + timeout-minutes: 10 # No token at all: this job only echoes and reads the PR body out of the # event payload. It never checks out code and never calls the GitHub API, so # granting it `contents: read` was privilege it could not use. @@ -102,6 +103,7 @@ jobs: # Promotion of this job to a required check is a separate, later owner # decision. This job leaves the existing "spine-trail present" job untouched. runs-on: ubuntu-latest + timeout-minutes: 10 continue-on-error: true permissions: contents: read diff --git a/.github/workflows/validation-g8-dispatch.yml b/.github/workflows/validation-g8-dispatch.yml index 726e76ec..e53faf39 100644 --- a/.github/workflows/validation-g8-dispatch.yml +++ b/.github/workflows/validation-g8-dispatch.yml @@ -13,6 +13,7 @@ jobs: dispatch: name: Dispatch validation-spine G8 runs-on: ubuntu-latest + timeout-minutes: 10 steps: # TraigentSchema is a PUBLIC repo, so org-level secrets with # visibility:private (SPINE_RO_TOKEN / VALIDATION_CI_PAT) are invisible diff --git a/CHANGELOG.md b/CHANGELOG.md index 28acdcab..e8ef5d47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,7 +68,7 @@ Unreleased changes are kept as fragments in changelog.d/; see changelog.d/README - Some changes inside shared `definitions`/`$defs` were not flagged by the breaking-change check, and some of them narrow what consumers accept. - A fix that makes the check walk definitions is in progress. -## [7.1.0] - 2026-10-29 +## [7.1.0] - 2026-11-03 ### Added - **Certification data-flow mode `private_online` (additive minor).** `DataFlowModeV0` gains a third value, accepted by the unsigned manifest `privacy_mode.declared_mode`, the `bind-g1` request `declared_mode` enum and the Python relying-party verifier's closed mode set (`expected_privacy_mode`). Meaning: the server-recorded session privacy policy was active for the run and the run used the online Traigent backend; it does NOT attest complete SDK egress, customer-content confinement or zero egress, and it is derived by the server from its own stamp, never from a client declaration alone. `current_online` stays an explicitly client-declared, unwitnessed mode; `offline` stays reserved for a witnessed zero-backend-egress run (D2, unsupported in v0). The D2 payload constant and the fixed 14 non-claims are unchanged. Existing documents with `offline` or `current_online` validate unchanged. Parity manifest regenerated. diff --git a/changelog.d/schema-audit-contract-alignment.changed.md b/changelog.d/schema-audit-contract-alignment.changed.md new file mode 100644 index 00000000..bbeb7471 --- /dev/null +++ b/changelog.d/schema-audit-contract-alignment.changed.md @@ -0,0 +1,14 @@ +- **`promotion_policy_schema.json` per-schema version 0.10.0 to 0.11.0** for the #580 constraint tightening below. +- **Annotation-queue and evaluator update bodies need one usable field (BREAKING for clients that sent only a null description, or, on annotation queues, only a blank name or description; the service already refused these with 422) (#723).** `annotation_queue_update_request_schema.json` and `evaluator_update_request_schema.json` gain a root `anyOf`, and an empty body is refused by both. On annotation queues, a body whose only field is a null description, a blank name or a blank description is refused. On evaluators, a body whose only field is a null description is refused; a blank name or description is still accepted by the schema and the backend, which has no strip validator. Both update schemas are referenced via `$ref` from `observability_endpoints.json`. +- **Non-breaking: evaluator update accepts an explicit `null` for `target_type` (#723).** `target_type` is nullable in `evaluator_update_request_schema.json` and `null` means unchanged, matching `EvaluatorDefinitionUpdateRequest` in the backend. A body with another field and a null `target_type` is accepted; a body whose only field is a null `target_type` is refused, as the service refuses it. +- **Tighter request validation (breaking for clients that used the older schema allowances).** + `promotion_policy`: `alpha` in (0, 1), `min_effect` values >= 0, chance-constraint `threshold` in [0, 1], `confidence` in (0, 1) (#580). + Evaluators: the update and execute request bodies are closed (unknown keys are refused); update drops `primary_measure_id`, needs at least one property and declares `target_type`; execute drops `source`; the backfill body is the new closed `evaluator_backfill_request_schema.json` (`target_type`, `filters`, `limit`, `skip_existing_scores`; `target_ids` and `force` removed) (#584). + Annotation queues: the create and update bodies are closed, and `description` is at most 2000 characters before trimming. The backend trims first, so the schema can reject a padded value the service accepts. An update needs at least one property; a body whose only fields are null, or that has only blank name or description, is refused by the schema (#640, #645, #723). + Prompts: `prompt_text` at most 10000 characters before trimming in the three prompt request schemas. The backend trims first, so the schema can reject a padded prompt the service accepts (#650). + Example-set create: `selection_method` and `type` are enums, `tags` at most 100 (#671). +- **Finalize and backfill accept an explicit `null`.** `optimization_outcome` may be `null` on the session finalize request, meaning absent (completed). `target_type` may be `null` on the evaluator backfill request, meaning the evaluator's own target type. +- **Non-breaking: agent create `retrieval_configs` and `model_parameters` allow up to 100 items (was 50), matching the backend cap (#652).** This loosens the schema; no request the service accepts is refused. +- **Identity: `compute_agent_build_digest` now rejects a present `source_digest` that is not `sha256:<64 hex>`, including for dirty builds (#697).** + +- **Evaluator backfill result declares `skipped_reasons` and `skipped_reason_counts` (#648). These optional fields constrain values previously accepted as undeclared extensions.** Legacy run-analytics GET endpoints declare their query parameters (`objective`, `limit`, `request_count`, ...) (#641). The project-scoped replacements keep their existing query contracts. The session finalize request declares `optimization_outcome` (`completed`, `failed`, `cancelled`) (#696). diff --git a/docs/content-class-manifest.json b/docs/content-class-manifest.json index ae31b2d6..fe55f4c0 100644 --- a/docs/content-class-manifest.json +++ b/docs/content-class-manifest.json @@ -868,6 +868,7 @@ "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1finalize/post/requestBody/content/application~1json/schema/properties/include_full_history": "closed_enum", "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1finalize/post/requestBody/content/application~1json/schema/properties/metadata": "legacy_content", "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1finalize/post/requestBody/content/application~1json/schema/properties/metadata [keys]": "legacy_content", + "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1finalize/post/requestBody/content/application~1json/schema/properties/optimization_outcome": "closed_enum", "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1identity-binding/get/parameters/0/schema": "opaque_ref", "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1intermediate-report/post/parameters/0/schema": "opaque_ref", "optimization/optimization_endpoints.json#/paths/~1api~1v1~1sessions~1{session_id}~1next-trial/post/parameters/0/schema": "opaque_ref", diff --git a/parity/python-js-sdk.json b/parity/python-js-sdk.json index 04060676..000bfbe3 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": "e1336def76c4e9122fd14a4a4ccd8abb370e7a196a93fabecfabba6e270290c4", - "schemaFileCount": 692, + "lastSchemaFileSha": "9b49344e7c7e4eb3e0683071dcabe347616d76593d02e7b5b23b2b73dd99848b", + "schemaFileCount": 693, "note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block." } } diff --git a/pyproject.toml b/pyproject.toml index 529718cb..efcef7b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,11 +75,16 @@ include = [ [tool.ruff] line-length = 100 -target-version = "py310" +target-version = "py311" [tool.ruff.lint] select = ["E", "F", "I", "UP", "B"] +# Frozen shipped verifier: its bytes are pinned to the reference by +# tests/test_dataset_record_v1_schema.py, so it cannot take the py311 UP017 rewrite. +[tool.ruff.lint.per-file-ignores] +"traigent_schema/certification/process_record_verifier.py" = ["UP017"] + [tool.mypy] python_version = "3.11" warn_return_any = true diff --git a/reports/schema-rebase-result.md b/reports/schema-rebase-result.md index 8ef1f664..925d6ed2 100644 --- a/reports/schema-rebase-result.md +++ b/reports/schema-rebase-result.md @@ -68,16 +68,19 @@ Result: `schemaFileCount=394`, Consumer references were refreshed from clean archives of each sibling's current `origin/develop` ref, then the reachability report was regenerated: +Set `SIBLINGS_ROOT` to the directory containing the sibling checkouts before running the commands. + ```bash +: "${SIBLINGS_ROOT:?Set SIBLINGS_ROOT to the directory containing the sibling checkouts}" for repo in Traigent TraigentBackend TraigentFrontend traigent-js traigent-smartopt; do - git -C /$repo fetch origin develop + git -C "$SIBLINGS_ROOT/$repo" fetch origin develop done python3 scripts/refresh_consumer_schema_references.py \ - --repo Traigent=/Traigent \ - --repo TraigentBackend=/TraigentBackend \ - --repo TraigentFrontend=/TraigentFrontend \ - --repo traigent-js=/traigent-js \ - --repo traigent-smartopt=/traigent-smartopt + --repo "Traigent=$SIBLINGS_ROOT/Traigent" \ + --repo "TraigentBackend=$SIBLINGS_ROOT/TraigentBackend" \ + --repo "TraigentFrontend=$SIBLINGS_ROOT/TraigentFrontend" \ + --repo "traigent-js=$SIBLINGS_ROOT/traigent-js" \ + --repo "traigent-smartopt=$SIBLINGS_ROOT/traigent-smartopt" python3 scripts/schema_reachability.py --update python3 scripts/schema_reachability.py --check ``` @@ -191,9 +194,10 @@ Results: Schema worktree fails and shows the missing field in the generated diff: ```bash + : "${SIBLINGS_ROOT:?Set SIBLINGS_ROOT to the directory containing the sibling checkouts}" TRAIGENT_SCHEMA_REPO="$PWD" \ - /Traigent/.venv/bin/python \ - /Traigent/scripts/generate_schema_types.py \ + "$SIBLINGS_ROOT/Traigent/.venv/bin/python" \ + "$SIBLINGS_ROOT/Traigent/scripts/generate_schema_types.py" \ --check ``` diff --git a/reports/schema_reachability/unreachable_schemas.json b/reports/schema_reachability/unreachable_schemas.json index e6a4e4e2..05c55d9d 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": 598 + "refOrEndpointGraph": 599 }, - "reachableCount": 631, - "schemaFileCount": 692, + "reachableCount": 632, + "schemaFileCount": 693, "unreachableCount": 61 }, "unreachableSchemas": [ diff --git a/scripts/breaking_schema_allowlist.json b/scripts/breaking_schema_allowlist.json index 3bb850a1..a713e0d6 100644 --- a/scripts/breaking_schema_allowlist.json +++ b/scripts/breaking_schema_allowlist.json @@ -12039,6 +12039,736 @@ "reason": "A rows of the evidence response gain the review_context freshness token (string or null), a closed additive field that the signer echoes on sign. Pre-release contract; the backend is the only producer and the frontend reads it in the same slice.", "version": "Unreleased pending (TraigentSchema, review_context; backend change pending)", "pr": "pending (TraigentSchema, not yet opened)" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "0fba9cfb20992e0f0a28b2ba55f07b1133e7e9669885801f84a4f60d1b34398b" + } + ], + "reason": "#584: the evaluator backfill request body declared target_ids and force, which the backend EvaluatorBackfillRequest (extra=forbid, evaluation_ops.py) rejects with 422. The body now $refs evaluator_backfill_request_schema.json, closed, declaring the fields the backend accepts (target_type, filters, limit, skip_existing_scores). No request the backend accepts is removed.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "property_removed", + "findings": [ + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema/properties/force", + "role": "request", + "subject": "force", + "old": true, + "new": false, + "fingerprint": "9b190f9978ce1e715b34c7d0f176763dea47643368fd54aca10fdf779005ca61" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema/properties/target_ids", + "role": "request", + "subject": "target_ids", + "old": true, + "new": false, + "fingerprint": "224f3d9950c6a8458000106fbb5bead6fd9edb12ad9588832ed1cc238c14ab00" + } + ], + "reason": "#584: the evaluator backfill request body declared target_ids and force, which the backend EvaluatorBackfillRequest (extra=forbid, evaluation_ops.py) rejects with 422. The body now $refs evaluator_backfill_request_schema.json, closed, declaring the fields the backend accepts (target_type, filters, limit, skip_existing_scores). No request the backend accepts is removed.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "optimization/optimization_endpoints.json", + "rule": "maximum", + "findings": [ + { + "pointer": "#/paths//api/v1/hybrid/sessions/post/requestBody/content/application/json/schema/properties/promotion_policy/properties/chance_constraints/items/properties/threshold", + "role": "request", + "subject": "maximum", + "old": null, + "new": 1, + "fingerprint": "1dad7b5c2943a26f07679535ed5b7f21f5a55f6f69da40121cbc606fa3e55178" + }, + { + "pointer": "#/paths//api/v1/sessions/post/requestBody/content/application/json/schema/properties/promotion_policy/properties/chance_constraints/items/properties/threshold", + "role": "request", + "subject": "maximum", + "old": null, + "new": 1, + "fingerprint": "05f85c26787980e2fa3d5115f99949d29ff9625fea10055f2be5ba89a990aee2" + } + ], + "reason": "#580: the server already rejects these values with 400. On /api/v1/sessions the interactive_session_service.py normalizers refuse them (threshold in [0, 1], min_effect non-negative, alpha and confidence open intervals). On /api/v1/hybrid/sessions HybridSessionCreate (extra=\"forbid\", hybrid_schemas.py) refuses any promotion_policy key. TVL's validator (python/tvl/lints.py) rejects the same values. No request the server accepts is refused.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "optimization/optimization_endpoints.json", + "rule": "minimum", + "findings": [ + { + "pointer": "#/paths//api/v1/hybrid/sessions/post/requestBody/content/application/json/schema/properties/promotion_policy/properties/chance_constraints/items/properties/threshold", + "role": "request", + "subject": "minimum", + "old": null, + "new": 0, + "fingerprint": "e3fefb2f4bb20e45f6eb363befb4ff2ecb7efa932a43f818561838490e4499ce" + }, + { + "pointer": "#/paths//api/v1/hybrid/sessions/post/requestBody/content/application/json/schema/properties/promotion_policy/properties/min_effect/patternProperties/^[a-zA-Z_][a-zA-Z0-9_.-]*$", + "role": "request", + "subject": "minimum", + "old": null, + "new": 0, + "fingerprint": "985336213c3c6a34e12ab50369fa92e648708df11f5a74a1999c206951d01122" + }, + { + "pointer": "#/paths//api/v1/sessions/post/requestBody/content/application/json/schema/properties/promotion_policy/properties/chance_constraints/items/properties/threshold", + "role": "request", + "subject": "minimum", + "old": null, + "new": 0, + "fingerprint": "c8e5bb3eff73a939f730522f62bba7e102a3cb46f3dfb0800f6d15ae5093a149" + }, + { + "pointer": "#/paths//api/v1/sessions/post/requestBody/content/application/json/schema/properties/promotion_policy/properties/min_effect/patternProperties/^[a-zA-Z_][a-zA-Z0-9_.-]*$", + "role": "request", + "subject": "minimum", + "old": null, + "new": 0, + "fingerprint": "6d46aea554bb7db1f7d5a0e574ba7caad553bde7a468a7c9f798760de2366bbc" + } + ], + "reason": "#580: the server already rejects these values with 400. On /api/v1/sessions the interactive_session_service.py normalizers refuse them (threshold in [0, 1], min_effect non-negative, alpha and confidence open intervals). On /api/v1/hybrid/sessions HybridSessionCreate (extra=\"forbid\", hybrid_schemas.py) refuses any promotion_policy key. TVL's validator (python/tvl/lints.py) rejects the same values. No request the server accepts is refused.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "optimization/promotion_policy_schema.json", + "rule": "maximum", + "findings": [ + { + "pointer": "#/properties/alpha", + "role": "conservative", + "subject": "maximum", + "old": 1, + "new": null, + "fingerprint": "7b7a968a08bfb7d2c90e1c85ac6554857fd816599427ffd18355a1595ead2cb5" + }, + { + "pointer": "#/properties/chance_constraints/items/properties/confidence", + "role": "conservative", + "subject": "maximum", + "old": 1, + "new": null, + "fingerprint": "569e1f8821d7ceab7e52a669e85a83826b368ddee60a8caf8bc22f3e29dc0e10" + }, + { + "pointer": "#/properties/chance_constraints/items/properties/threshold", + "role": "conservative", + "subject": "maximum", + "old": null, + "new": 1, + "fingerprint": "8bb9a5db98e8c5850b579072f86e62595e9952c84a8d782594c2b5c0b790b57d" + } + ], + "reason": "#580: the server already rejects these values with 400. On /api/v1/sessions the interactive_session_service.py normalizers refuse them (threshold in [0, 1], min_effect non-negative, alpha and confidence open intervals). On /api/v1/hybrid/sessions HybridSessionCreate (extra=\"forbid\", hybrid_schemas.py) refuses any promotion_policy key. TVL's validator (python/tvl/lints.py) rejects the same values. No request the server accepts is refused.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "optimization/promotion_policy_schema.json", + "rule": "minimum", + "findings": [ + { + "pointer": "#/properties/alpha", + "role": "conservative", + "subject": "minimum", + "old": 0, + "new": null, + "fingerprint": "4a15d9da9ab623e0900f8d074d3de6dcec719f86c41c622d902664f72ee13553" + }, + { + "pointer": "#/properties/chance_constraints/items/properties/confidence", + "role": "conservative", + "subject": "minimum", + "old": 0, + "new": null, + "fingerprint": "292ab0d36caa9b6996d6424924d68bf6b4abf99a80f15a8bf4649aaee8a3b92b" + }, + { + "pointer": "#/properties/chance_constraints/items/properties/threshold", + "role": "conservative", + "subject": "minimum", + "old": null, + "new": 0, + "fingerprint": "047911f3d4a24c5df793bd174a4a2e8750ae60a696f9f0447d9a7b28aba552c7" + }, + { + "pointer": "#/properties/min_effect/patternProperties/^[a-zA-Z_][a-zA-Z0-9_.-]*$", + "role": "conservative", + "subject": "minimum", + "old": null, + "new": 0, + "fingerprint": "9d8b557629c97d0a260e46fc2823a0f1da959df2fe030cee8a402466ee522578" + } + ], + "reason": "#580: the server already rejects these values with 400. On /api/v1/sessions the interactive_session_service.py normalizers refuse them (threshold in [0, 1], min_effect non-negative, alpha and confidence open intervals). On /api/v1/hybrid/sessions HybridSessionCreate (extra=\"forbid\", hybrid_schemas.py) refuses any promotion_policy key. TVL's validator (python/tvl/lints.py) rejects the same values. No request the server accepts is refused.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "datasets/example_set_create_request_schema.json", + "rule": "maxItems", + "findings": [ + { + "pointer": "#/properties/tags", + "role": "request", + "subject": "maxItems", + "old": null, + "new": 100, + "fingerprint": "bd4ce8779396184bc40c3fc9b1b2453e7481a3b8492a5752a198e7af8c67bc45" + } + ], + "reason": "Example-set create now caps tags at 100 entries, matching the backend AddExampleSetRequest limit (MAX_AGENT_LIST_ITEMS = 100). The schema previously accepted an uncapped tags array that the service refuses, so this closes a false pass for clients validating against the contract (issue #671).", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/annotation_queue_create_request_schema.json", + "rule": "maxLength", + "findings": [ + { + "pointer": "#/properties/description", + "role": "request", + "subject": "maxLength", + "old": 5000, + "new": 2000, + "fingerprint": "4cee28efe702bb03a67c03ef684a8af22910444ee76870e994eacfe9be4809f2" + } + ], + "reason": "Annotation-queue create lowers the description cap from 5000 to 2000 characters to match AnnotationQueueCreateRequest (max_length=2000, annotation_queue.py). The backend measures the description after trimming surrounding whitespace, so the schema is stricter only for a value padded past 2000 whose trimmed length is 2000 or less. Descriptions of 2001-5000 characters after trimming passed the schema and were refused by the service with a 422 (issue #640).", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/annotation_queue_update_request_schema.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "c353388263d0d14f0ce120f7867810cc29f4069c8ed7a57156660fe8d1658cfd" + } + ], + "reason": "Annotation-queue update closes additionalProperties. The backend update model forbids unknown fields, so an unknown key was a false pass on the contract. Clients that send extra keys will now fail schema validation as the service already does (issue #645).", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/annotation_queue_update_request_schema.json", + "rule": "maxLength", + "findings": [ + { + "pointer": "#/properties/description", + "role": "request", + "subject": "maxLength", + "old": 5000, + "new": 2000, + "fingerprint": "6096f72acfa012ef17a2a4872c4cd5a905efa09b0c2d201806efdbbb56b9b06d" + } + ], + "reason": "Annotation-queue update lowers the description cap from 5000 to 2000 characters to match AnnotationQueueUpdateRequest (max_length=2000, annotation_queue.py). The backend measures the description after trimming surrounding whitespace, so the schema is stricter only for a value padded past 2000 whose trimmed length is 2000 or less. Descriptions of 2001-5000 characters after trimming passed the schema and were refused by the service with a 422 (issue #640).", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/annotation_queue_update_request_schema.json", + "rule": "minProperties", + "findings": [ + { + "pointer": "#", + "role": "request", + "subject": "minProperties", + "old": null, + "new": 1, + "fingerprint": "981587ad2bce6d7ab69c2a33acda53209da3ef7c4c92717b74b811ab3390ce50" + } + ], + "reason": "Annotation-queue update requires at least one property. The backend rejects an update with no fields, so an empty PATCH body was a false pass on the contract (issue #645). A body whose only field is null or blank is refused (description and target_type by the #723 anyOf, other fields by their non-null types) (see the anyOf entries below); this entry covers the empty body.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "prompts/prompt_create_request_schema.json", + "rule": "maxLength", + "findings": [ + { + "pointer": "#/properties/prompt_text", + "role": "request", + "subject": "maxLength", + "old": 50000, + "new": 10000, + "fingerprint": "372adf6a7bbd01207dc8bc032675c0b1a9425998d99562df1798efeeeeb85abe" + } + ], + "reason": "Prompt create lowers prompt_text from 50000 to 10000 characters to match the backend cap (PROMPT_TEXT_MAX_LENGTH = 10000, applied after validate_prompt_text trims whitespace). Prompts of 10001-50000 characters after trimming were accepted by the schema and refused by the service with a 422 (issue #650); the schema is stricter only for text padded past 10000 whose trimmed length is 10000 or less. Chat message content is unchanged pending the owner decision on that field.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "prompts/prompt_playground_request_schema.json", + "rule": "maxLength", + "findings": [ + { + "pointer": "#/properties/prompt_text", + "role": "request", + "subject": "maxLength", + "old": 50000, + "new": 10000, + "fingerprint": "a466116c6a689c01f23622d54b4120e95a364791d964860c2b6b9f0ba4a46fb4" + } + ], + "reason": "Prompt playground lowers prompt_text from 50000 to 10000 characters to match the backend cap (PROMPT_TEXT_MAX_LENGTH = 10000, applied after validate_prompt_text trims whitespace). Prompts of 10001-50000 characters after trimming were accepted by the schema and refused by the service with a 422 (issue #650); the schema is stricter only for text padded past 10000 whose trimmed length is 10000 or less.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "prompts/prompt_version_create_request_schema.json", + "rule": "maxLength", + "findings": [ + { + "pointer": "#/properties/prompt_text", + "role": "request", + "subject": "maxLength", + "old": 50000, + "new": 10000, + "fingerprint": "0db7f5dc93c96b5a4fb035c2792aeec8ad222d7312360b97490a268e410f8ed4" + } + ], + "reason": "Prompt version create lowers prompt_text from 50000 to 10000 characters to match the backend cap (PROMPT_TEXT_MAX_LENGTH = 10000, applied after validate_prompt_text trims whitespace). Prompts of 10001-50000 characters after trimming were accepted by the schema and refused by the service with a 422 (issue #650); the schema is stricter only for text padded past 10000 whose trimmed length is 10000 or less.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#/paths//api/v1beta/annotation-queues/{queue_id}/patch/requestBody/content/application/json/schema", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "e943d3b039024bbdc4a5ba609e7c0821beb6a316d05ee85b325ec9486c943e8a" + } + ], + "reason": "#645: the annotation-queue PATCH request body in the endpoint catalog now closes additionalProperties, matching the update request schema entry above (the backend update model forbids unknown keys).", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "maxLength", + "findings": [ + { + "pointer": "#/paths//api/v1beta/annotation-queues/post/requestBody/content/application/json/schema/properties/description", + "role": "request", + "subject": "maxLength", + "old": 5000, + "new": 2000, + "fingerprint": "080cd44730b9e7595c81a98204d9bf666b83d3391e2c195165ad8b8969799bc5" + }, + { + "pointer": "#/paths//api/v1beta/annotation-queues/{queue_id}/patch/requestBody/content/application/json/schema/properties/description", + "role": "request", + "subject": "maxLength", + "old": 5000, + "new": 2000, + "fingerprint": "479469a545cadf22f6e7f9c4ae828fb70c734e40530827d791eedecdb98abe83" + } + ], + "reason": "#640: the annotation-queue request description cap in the endpoint catalog is lowered from 5000 to 2000 characters, matching the create/update schema entries above and the backend limit, which the backend applies after trimming whitespace.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "minProperties", + "findings": [ + { + "pointer": "#/paths//api/v1beta/annotation-queues/{queue_id}/patch/requestBody/content/application/json/schema", + "role": "request", + "subject": "minProperties", + "old": null, + "new": 1, + "fingerprint": "ae2460b2c40b743e5daad7eccae4663d7d0249c8a88522f7f7469f6cbb3d8d15" + } + ], + "reason": "#645: the annotation-queue PATCH request body in the endpoint catalog requires at least one property, matching the update request schema entry above (the backend rejects an empty update).", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_execute_request_schema.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "c4d85afdcb2c319636390162c53264e380e0010175fb67021eff276607954f0d" + } + ], + "reason": "#584: the evaluator execute request schema is closed (additionalProperties false). The backend EvaluatorExecuteRequest inherits extra=\"forbid\" from EvaluationTargetRef (backend evaluation_ops.py), so the service already rejects any unknown key with 422. Bodies that use only target_type, target_id and override_judge_config are unchanged.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_execute_request_schema.json", + "rule": "property_removed", + "findings": [ + { + "pointer": "#/properties/source", + "role": "request", + "subject": "source", + "old": true, + "new": false, + "fingerprint": "d575f85ad04cb91e02c421cb8a8571ab2fc7475b3d5ff2bb324aa1d4689bc370" + } + ], + "reason": "#584: the source field is removed from the evaluator execute request. EvaluationTargetRef and EvaluatorExecuteRequest (backend evaluation_ops.py) have no source field and forbid extra keys, so a body carrying source already got a 422 from the service. Bodies without source are unchanged.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_update_request_schema.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "e856235cd0b071a5ac2b1233a66b685bb3daae215b021e86c0cdfeb735bfa00d" + } + ], + "reason": "#584: the evaluator update request schema is closed (additionalProperties false). EvaluatorDefinitionUpdateRequest sets extra=\"forbid\" (backend evaluation_ops.py), so the service already rejects any unknown key with 422. Bodies made only of fields the backend accepts are unchanged.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_update_request_schema.json", + "rule": "minProperties", + "findings": [ + { + "pointer": "#", + "role": "request", + "subject": "minProperties", + "old": null, + "new": 1, + "fingerprint": "5ac2b8b4fb647087904f08c48edab92515ea447193fc75dde8ede12af78ebdd2" + } + ], + "reason": "#584: the evaluator update request requires at least one property. EvaluatorDefinitionUpdateRequest.ensure_update_has_fields (backend evaluation_ops.py) rejects an update with no fields, so an empty PATCH already got a 422. A body whose only fields are null is refused (description and target_type by the #723 anyOf, other fields by their non-null types) (see the anyOf entries below); this entry covers the empty body.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_update_request_schema.json", + "rule": "property_removed", + "findings": [ + { + "pointer": "#/properties/primary_measure_id", + "role": "request", + "subject": "primary_measure_id", + "old": true, + "new": false, + "fingerprint": "88ae28400dfeb9ea93d0530cc38005d45be740106f3c4db6a4f214a428d81a56" + } + ], + "reason": "#584: primary_measure_id is removed from the evaluator update request. EvaluatorDefinitionUpdateRequest (backend evaluation_ops.py) has no such field and forbids extra keys, so a PATCH carrying it already got a 422. measure_id is the field the backend accepts.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/patch/requestBody/content/application/json/schema", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "01caefa58b268facdd3217becfdf0edf590b230437a96b2ec4ac718107a966b9" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/execute/post/requestBody/content/application/json/schema", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "f0e7abe61c40a4af4b6ff3dece50985772de29b62c6c311797bb1c0d2c79dd8c" + } + ], + "reason": "#584: the PATCH evaluator and POST execute request bodies in the endpoint catalog $ref evaluator_update_request_schema.json and evaluator_execute_request_schema.json, which close them as the schema-file entries above do. This matches the backend models (evaluation_ops.py, extra=\"forbid\"), so unknown keys already got a 422 from the service.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "minProperties", + "findings": [ + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/patch/requestBody/content/application/json/schema", + "role": "request", + "subject": "minProperties", + "old": null, + "new": 1, + "fingerprint": "a274260faece1cb4ac7c8e82e168663a038cff1027ab5f372a680f25ca700e2d" + } + ], + "reason": "#584: the PATCH evaluator request body in the endpoint catalog ($ref to evaluator_update_request_schema.json) requires at least one property, matching evaluator_update_request_schema.json and EvaluatorDefinitionUpdateRequest.ensure_update_has_fields (backend evaluation_ops.py). An empty PATCH already got a 422. A body whose only fields are null is refused (description and target_type by the #723 anyOf, other fields by their non-null types) (see the anyOf entries below); this entry covers the empty body.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "property_removed", + "findings": [ + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/patch/requestBody/content/application/json/schema/properties/primary_measure_id", + "role": "request", + "subject": "primary_measure_id", + "old": true, + "new": false, + "fingerprint": "1073de8db3b257eeaa95bb90c7da66189815cbdbbfeb6fcd58a172c1de1219b8" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/execute/post/requestBody/content/application/json/schema/properties/source", + "role": "request", + "subject": "source", + "old": true, + "new": false, + "fingerprint": "7d86c865efa1d98bef98fc36eae27981c7d08af6a4395d150ae583911674cf46" + } + ], + "reason": "#584: primary_measure_id is removed from the PATCH evaluator body and source from the POST execute body in the endpoint catalog, matching the schema files above. The backend models have neither field (backend evaluation_ops.py) and forbid extra keys, so both already got a 422 from the service.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/annotation_queue_create_request_schema.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "f3889dd45e10668195386e0107e917a6e0621a85191aa65007c1b2dd54dd0861" + } + ], + "reason": "#640: the annotation-queue create request schema is closed (additionalProperties false). AnnotationQueueCreateRequest is extra=\"forbid\" (backend annotation_queue.py) and the route validates the raw body with model_validate (backend annotation_queue_routes.py), so the service already rejects unknown keys with 422. Bodies that use only name, description, target_type, measure_ids and status are unchanged.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "additionalProperties", + "findings": [ + { + "pointer": "#/paths//api/v1beta/annotation-queues/post/requestBody/content/application/json/schema", + "role": "request", + "subject": "additionalProperties", + "old": "open (true/absent)", + "new": "closed (false)", + "fingerprint": "13555f5c6cc8843bcaa8d298c8578fb32688aea71a87529954c59a063b3465b9" + } + ], + "reason": "#640: the annotation-queue create request body in the endpoint catalog is closed, matching annotation_queue_create_request_schema.json and the backend model AnnotationQueueCreateRequest (backend annotation_queue.py, extra=\"forbid\"). The service already rejects unknown keys with 422 on this route.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/annotation_queue_update_request_schema.json", + "rule": "anyOf_added", + "findings": [ + { + "pointer": "#/anyOf", + "role": "request", + "subject": "anyOf", + "old": 0, + "new": 4, + "fingerprint": "e8e387ad51e7a028f26cd3f2d6e27a1627128115d85d8ced4ae3ddce6b7451bb" + } + ], + "reason": "#723: the annotation-queue update body must carry one field the service keeps. The service strips blank strings to None and rejects an update with no fields left, so a body whose only field is a null description, a blank name or a blank description is refused with a 422. The root anyOf makes the schema refuse the same bodies; a body with measure_ids or status alone still passes.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_update_request_schema.json", + "rule": "anyOf_added", + "findings": [ + { + "pointer": "#/anyOf", + "role": "request", + "subject": "anyOf", + "old": 0, + "new": 8, + "fingerprint": "c639b8496965cb6bf2a7be53a71cf35838fcf5d1b1d1375717aa47d1819843c4" + } + ], + "reason": "#723: the evaluator update body must carry one field the service keeps. The service drops null values before its empty-body check, so a body whose only field is a null description or a null target_type is refused with a 422. The root anyOf requires one property, and description and target_type must be strings, so the schema refuses the same bodies.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "anyOf_added", + "findings": [ + { + "pointer": "#/paths//api/v1beta/annotation-queues/{queue_id}/patch/requestBody/content/application/json/schema/anyOf", + "role": "request", + "subject": "anyOf", + "old": 0, + "new": 4, + "fingerprint": "bed45d6bf4ff6135628f57661ff48408353016d56f66d4217153d91725a74241" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/patch/requestBody/content/application/json/schema/anyOf", + "role": "request", + "subject": "anyOf", + "old": 0, + "new": 8, + "fingerprint": "d38db1896de6dcdce625ce53cf493e8642fb8120f0b21e967f9f8312b62919c7" + } + ], + "reason": "#723: a root anyOf matching the two update request schemas above, seen through their $ref copies in the endpoint catalog. The service already rejects these PATCH bodies with a 422 when the only field is a null description (evaluator) or a null description or blank name or description (annotation queue), so the catalog now matches the service.", + "version": "unreleased (next schema release)", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_backfill_result_schema.json", + "rule": "property_added", + "findings": [ + { + "pointer": "#/properties/skipped_reason_counts", + "role": "conservative", + "subject": "skipped_reason_counts", + "old": false, + "new": true, + "fingerprint": "39a928ffb6f1ced88807bf925cc6500ed72b14dd845f220f08ba08d88005f07d" + }, + { + "pointer": "#/properties/skipped_reasons", + "role": "conservative", + "subject": "skipped_reasons", + "old": false, + "new": true, + "fingerprint": "e52da5151ca38c523d1b01c40d9b8e19450298f2540d812d2548b296e09ee777" + } + ], + "reason": "Intentional tightening of an open response object: undeclared skipped_reasons and skipped_reason_counts keys previously accepted arbitrary values, and are now constrained to target-id-to-reason strings and reason-to-positive-counts. The backend backfill response constructs those exact maps in evaluation_ops_service.py; no field became required.", + "version": "Unreleased", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/evaluator_update_request_schema.json", + "rule": "property_added", + "findings": [ + { + "pointer": "#/properties/target_type", + "role": "request", + "subject": "target_type", + "old": false, + "new": true, + "fingerprint": "6d83e69f6ad0b32eaa677244842723fceba676e5de384f749ae81b97c585f7ec" + } + ], + "reason": "Intentional declaration of target_type on an update body that previously accepted arbitrary additional values. EvaluatorDefinitionUpdateRequest in evaluation_ops.py defines the supported nullable EvaluationTargetType; null means unchanged, and its validator still rejects an empty/null-only update.", + "version": "Unreleased", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "observability/observability_endpoints.json", + "rule": "property_added", + "findings": [ + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/patch/requestBody/content/application/json/schema/properties/target_type", + "role": "request", + "subject": "target_type", + "old": false, + "new": true, + "fingerprint": "ca3037d68a0bebec2d8a35130a15767e8d3accbba1683f3c5b2c5b34a8db847e" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema/properties/filters", + "role": "request", + "subject": "filters", + "old": false, + "new": true, + "fingerprint": "9b2d882bd63a0b2e4871b30cfe40ff7b1cea416644748a46015e74e2a8e112eb" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema/properties/limit", + "role": "request", + "subject": "limit", + "old": false, + "new": true, + "fingerprint": "3cae5c44d93d10a95a25a4a71ee594313639215b1fec70457775bed447b6a873" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema/properties/skip_existing_scores", + "role": "request", + "subject": "skip_existing_scores", + "old": false, + "new": true, + "fingerprint": "43f59b5a2133130cd71a98fc9f3a604a77b9c5ff8c58fb17bd66ee7de936ec58" + }, + { + "pointer": "#/paths//api/v1beta/evaluators/{evaluator_id}/backfill/post/requestBody/content/application/json/schema/properties/target_type", + "role": "request", + "subject": "target_type", + "old": false, + "new": true, + "fingerprint": "2046b577816d8f618057833d18efeba1c96223a629cfca0218a4c337b0062158" + } + ], + "reason": "Intentional declaration of the supported request DTO fields where the endpoint object previously allowed arbitrary values. EvaluatorBackfillRequest in evaluation_ops.py is extra=forbid and defines nullable target_type, object filters, limit 1..500 with default 16, and boolean skip_existing_scores. The schema now mirrors those accepted fields; unknown fields were already refused by the service.", + "version": "Unreleased", + "pr": "Traigent/TraigentSchema#727" + }, + { + "file": "optimization/optimization_endpoints.json", + "rule": "property_added", + "findings": [ + { + "pointer": "#/paths//api/v1/sessions/{session_id}/finalize/post/requestBody/content/application/json/schema/properties/optimization_outcome", + "role": "request", + "subject": "optimization_outcome", + "old": false, + "new": true, + "fingerprint": "3af9cefa7441f54ef3af279897c05aa32af1ac13f515e04dd1770069929d0aaf" + } + ], + "reason": "Intentional declaration of optimization_outcome on a request object that previously allowed arbitrary values. The route validates only completed, failed, cancelled, or null; terminal_outcome.py documents null/absence as the existing completed default. Other values are rejected by the service.", + "version": "Unreleased", + "pr": "Traigent/TraigentSchema#727" } ] } diff --git a/scripts/verify_identity_vectors_against_production.py b/scripts/verify_identity_vectors_against_production.py index 2010a3f7..52453a09 100644 --- a/scripts/verify_identity_vectors_against_production.py +++ b/scripts/verify_identity_vectors_against_production.py @@ -35,6 +35,12 @@ def check_sdk() -> list[str]: import traigent # noqa: PLC0415 problems, checked = [], 0 + if not hasattr(traigent, "optimize"): + # Without the entry point, the AttributeError an "unsupported" vector + # expects would fire for the wrong reason and pass vacuously. + problems.append("sdk: traigent has no attribute 'optimize'; wrong or stub SDK checkout") + print("sdk: checked 0 python vectors, 1 problems") + return problems for v in _py_vectors(): inp, exp = v["input"], v["expected"] if exp.get("outcome") == "unsupported": @@ -76,6 +82,9 @@ def probe(*a, **k): # noqa: ANN002, ANN003 problems.append( f"{v['id']}: experiment_name {got!r} != {exp['registration_identity']!r}" ) + if checked == 0: + # A vacuous run (no python entries, or none executed) must not pass. + problems.append("sdk: checked 0 python vectors; the check verified nothing") print(f"sdk: checked {checked} python vectors, {len(problems)} problems") return problems diff --git a/tests/test_analytics_schemas.py b/tests/test_analytics_schemas.py index 6184c48c..ee3abb90 100644 --- a/tests/test_analytics_schemas.py +++ b/tests/test_analytics_schemas.py @@ -540,6 +540,61 @@ def test_scoring_job_status_schema_loadable(self, validator): assert errors == [], f"Unexpected errors: {errors}" +# #641: the single-run analytics GET endpoints must declare the query parameters +# the backend accepts (its run analytics request models, +# every model extra="forbid"), so a schema-built request can carry a valid objective/limit. +RUN_ANALYTICS_QUERY_PARAMS = { + "/api/v1/analytics/runs/{run_id}/pareto": {"x_measure", "y_measure", "request_count"}, + "/api/v1/analytics/runs/{run_id}/correlations": {"method", "min_sample"}, + "/api/v1/analytics/runs/{run_id}/leaderboard": { + "objective", "weights", "constraints", "request_count", "limit", + }, + "/api/v1/analytics/runs/{run_id}/parameter-insights": { + "target_measure", "min_trials", "top_k", + }, +} + + +def _run_analytics_params(path: str) -> dict: + endpoints = json.loads( + (Path(__file__).resolve().parent.parent / "traigent_schema" / "schemas" / "analytics" + / "analytics_endpoints.json").read_text(encoding="utf-8") + ) + params = endpoints["paths"][path]["get"].get("parameters", []) + assert all(p["in"] == "query" for p in params), path + return {p["name"]: p["schema"] for p in params} + + +@pytest.mark.parametrize("path", sorted(RUN_ANALYTICS_QUERY_PARAMS)) +def test_run_analytics_get_declares_backend_query_parameters(path: str) -> None: + assert set(_run_analytics_params(path)) == RUN_ANALYTICS_QUERY_PARAMS[path] + + +def test_leaderboard_objective_enum_matches_backend() -> None: + from jsonschema import Draft7Validator + + objective = _run_analytics_params("/api/v1/analytics/runs/{run_id}/leaderboard")["objective"] + assert set(objective["enum"]) == {"weighted", "quality", "cost", "latency"} + assert objective["default"] == "weighted" + validator = Draft7Validator(objective) + assert all(validator.is_valid(v) for v in ("weighted", "quality", "cost", "latency")) + assert not validator.is_valid("bogus") + + +@pytest.mark.parametrize( + ("param", "accepted", "rejected"), + [ + ("limit", (1, 200), (0, 201)), + ("request_count", (1, 1_000_000), (0, 1_000_001)), + ], +) +def test_leaderboard_numeric_bounds_match_backend(param: str, accepted, rejected) -> None: + from jsonschema import Draft7Validator + + schema = _run_analytics_params("/api/v1/analytics/runs/{run_id}/leaderboard")[param] + validator = Draft7Validator(schema) + assert all(validator.is_valid(v) for v in accepted) + assert not any(validator.is_valid(v) for v in rejected) # --- stored-guidance read: closed not_generated / ready contracts (additive) --- _STORED = "analytics/next_steps_stored_response_schema.json" diff --git a/tests/test_analytics_validators_doctest.py b/tests/test_analytics_validators_doctest.py new file mode 100644 index 00000000..00dd6d81 --- /dev/null +++ b/tests/test_analytics_validators_doctest.py @@ -0,0 +1,24 @@ +"""Doctest gate for traigent_schema.analytics_validators (issue #713). + +The ``>>>`` examples in the docstrings are executable documentation. This +test runs them so they cannot rot: a NameError or a wrong documented output +fails the suite. +""" + +from __future__ import annotations + +import doctest + +import traigent_schema.analytics_validators as analytics_validators + +# validate_example_metrics, validate_example_id_format, validate_job_id_format +# and validate_algorithm_version each carry one or more examples. +MIN_EXAMPLES = 7 + + +def test_analytics_validators_docstring_examples_pass() -> None: + result = doctest.testmod(analytics_validators, verbose=False, report=True) + assert result.attempted >= MIN_EXAMPLES, ( + f"expected at least {MIN_EXAMPLES} doctest examples, ran {result.attempted}" + ) + assert result.failed == 0 diff --git a/tests/test_create_request_contracts.py b/tests/test_create_request_contracts.py index 27fb93ba..fea07253 100644 --- a/tests/test_create_request_contracts.py +++ b/tests/test_create_request_contracts.py @@ -117,6 +117,69 @@ def test_example_set_similarity_threshold_matches_backend_bounds(): ) +# Backend AddExampleSetRequest (agent.py enums, selection_method, type, +# tags max_length=MAX_AGENT_LIST_ITEMS=100). +EXAMPLE_SET_SELECTION_METHODS = { + "all", + "random", + "semantic_similarity", + "similarity", + "sequential", + "manual", + "diversity-based", + "difficulty-based", + "difficulty_weighted", +} +EXAMPLE_SET_TYPES = { + "input-only", + "input-output", + "multi-turn conversation", + "conversation", + "classification", + "structured", + "generation", + "evaluation", + "other", +} +EXAMPLE_SET_ROUTE = "/api/v1/projects/{project_id}/agents/{agent_ref}/example-sets" + + +def test_example_set_create_enums_and_tag_cap_match_backend(): + props = json.loads( + (S / "datasets" / "example_set_create_request_schema.json").read_text(encoding="utf-8") + )["properties"] + assert set(props["selection_method"]["enum"]) == EXAMPLE_SET_SELECTION_METHODS + assert set(props["type"]["enum"]) == EXAMPLE_SET_TYPES + assert props["tags"]["maxItems"] == 100 + + +@pytest.mark.parametrize("selection_method", sorted(EXAMPLE_SET_SELECTION_METHODS)) +def test_example_set_create_accepts_every_backend_selection_method(selection_method): + v = SchemaValidator(contract="backend") + assert v.validate_request( + EXAMPLE_SET_ROUTE, + "POST", + {"name": "set", "selection_method": selection_method}, + ) == [] + + +@pytest.mark.parametrize("example_type", sorted(EXAMPLE_SET_TYPES)) +def test_example_set_create_accepts_every_backend_type(example_type): + v = SchemaValidator(contract="backend") + assert v.validate_request( + EXAMPLE_SET_ROUTE, + "POST", + {"name": "set", "selection_method": "all", "type": example_type}, + ) == [] + + +def test_example_set_create_rejects_unknown_selection_method_type_and_too_many_tags(): + v = SchemaValidator(contract="backend") + base = {"name": "set", "selection_method": "all"} + assert v.validate_request(EXAMPLE_SET_ROUTE, "POST", {**base, "selection_method": "bogus"}) + assert v.validate_request(EXAMPLE_SET_ROUTE, "POST", {**base, "type": "bogus"}) + assert v.validate_request(EXAMPLE_SET_ROUTE, "POST", {**base, "tags": ["t"] * 101}) + assert v.validate_request(EXAMPLE_SET_ROUTE, "POST", {**base, "tags": ["t"] * 100}) == [] def test_shared_create_schemas_keep_their_strict_shape(): """The JS SDK generates RetrieverCreateRequestSchema from these two files: they stay unchanged; the project-scoped relaxed shapes live in project_* files.""" diff --git a/tests/test_example_identity.py b/tests/test_example_identity.py index 41c9e40e..95e1535d 100644 --- a/tests/test_example_identity.py +++ b/tests/test_example_identity.py @@ -824,6 +824,30 @@ def test_dirty_build_with_source_digest_is_accepted_by_code_and_schema() -> None assert not list(_validator(AGENT_SCHEMA_PATH, "AgentBuildManifestV1").iter_errors(manifest)) +@pytest.mark.parametrize("bad_source_digest", [None, "", 12, "not-a-digest", "sha256:ABC"]) +def test_dirty_build_rejects_a_source_digest_that_is_not_a_digest( + bad_source_digest: Any, +) -> None: + # Presence is not identity: a dirty tree with a non-digest source_digest + # must not mint a certifiable build digest (issue #697). + manifest = {**VECTORS["agent_builds"][0]["manifest"]} + manifest["code_revision"] = {**manifest["code_revision"], "dirty": True} + manifest["source_digest"] = bad_source_digest + with pytest.raises(ei.ContentIdentityError, match="source_digest"): + ei.compute_agent_build_digest(manifest, certifiable=True) + assert list(_validator(AGENT_SCHEMA_PATH, "AgentBuildManifestV1").iter_errors(manifest)) + + +@pytest.mark.parametrize("bad_source_digest", [None, "", "not-a-digest"]) +def test_clean_build_rejects_a_present_source_digest_that_is_not_a_digest( + bad_source_digest: Any, +) -> None: + manifest = {**VECTORS["agent_builds"][0]["manifest"]} + manifest["source_digest"] = bad_source_digest + with pytest.raises(ei.ContentIdentityError, match="source_digest"): + ei.compute_agent_build_digest(manifest) + + def test_evaluated_set_rejects_both_members_and_a_reference() -> None: root = ei.compute_multiset_root(_pairs(1)) member = root.members[0] diff --git a/tests/test_input_bounds_agents_prompts.py b/tests/test_input_bounds_agents_prompts.py index 8eba379d..2d029f5c 100644 --- a/tests/test_input_bounds_agents_prompts.py +++ b/tests/test_input_bounds_agents_prompts.py @@ -8,17 +8,20 @@ SCHEMAS_DIR = get_schemas_dir() +# Backend MAX_AGENT_LIST_ITEMS = 100 (src/shared_infrastructure/input_limits.py:33) is +# applied to every agent list field (src/shared_infrastructure/schemas/agent.py). AGENT_ARRAY_LIMITS = { "custom_validations": 100, "custom_tools": 100, "custom_responses": 100, "tags": 100, "example_sets": 100, - "retrieval_configs": 50, - "model_parameters": 50, + "retrieval_configs": 100, + "model_parameters": 100, "measure_ids": 100, } +PROMPT_TEXT_LIMIT = 10000 PROMPT_CHAT_MESSAGE_LIMIT = 50000 PROMPT_CHAT_MESSAGES_LIMIT = 200 PROMPT_LABEL_TAG_LIMIT = 100 @@ -67,6 +70,45 @@ def test_agent_create_array_bounds_are_declared_and_enforced() -> None: ) +@pytest.mark.parametrize( + ("relative_path", "schema_name", "payload"), + [ + ( + "prompts/prompt_create_request_schema.json", + "prompt_create_request_schema", + {"name": "support.prompt", "prompt_type": "text", "prompt_text": "x"}, + ), + ( + "prompts/prompt_version_create_request_schema.json", + "prompt_version_create_request_schema", + {"prompt_text": "x"}, + ), + ( + "prompts/prompt_playground_request_schema.json", + "prompt_playground_request_schema", + {"prompt_text": "x"}, + ), + ], +) +def test_prompt_text_bound_matches_backend_and_is_enforced( + relative_path: str, + schema_name: str, + payload: dict[str, Any], +) -> None: + # Backend PROMPT_TEXT_MAX_LENGTH = 10_000 (src/utils/prompt_validation.py:6), applied + # to prompt_create / prompt_version_create / prompt_playground (hybrid/prompt schemas). + schema = _load_schema(relative_path) + assert schema["properties"]["prompt_text"]["maxLength"] == PROMPT_TEXT_LIMIT + + validator = SchemaValidator(contract="planned_projects") + at_limit = {**payload, "prompt_text": "x" * PROMPT_TEXT_LIMIT} + errors = validator.validate_json(at_limit, schema_name) + assert not any("prompt_text" in error for error in errors), errors + + over_limit = {**payload, "prompt_text": "x" * (PROMPT_TEXT_LIMIT + 1)} + _assert_schema_validation_fails(validator, schema_name, over_limit, "prompt_text") + + def test_chat_prompt_message_content_bound_is_declared_and_enforced() -> None: schema = _load_schema("prompts/chat_prompt_message_schema.json") assert schema["properties"]["content"]["maxLength"] == PROMPT_CHAT_MESSAGE_LIMIT diff --git a/tests/test_json_duplicate_keys.py b/tests/test_json_duplicate_keys.py new file mode 100644 index 00000000..f2666844 --- /dev/null +++ b/tests/test_json_duplicate_keys.py @@ -0,0 +1,56 @@ +"""Regression gate: no JSON file in the repo may repeat an object key. + +Standard JSON parsers keep the last value of a repeated key and drop the rest +silently, so a duplicated "description" (or a duplicated validating keyword such +as "type" or "required") changes the contract without any error. This test +parses every JSON file with an object_pairs_hook that rejects repeated keys. +""" + +from __future__ import annotations + +import json +from pathlib import Path +from typing import Any + +import pytest + +REPO_ROOT = Path(__file__).resolve().parents[1] +_SKIPPED_DIR_NAMES = {"node_modules", "__pycache__"} + + +def _json_files() -> list[Path]: + files: list[Path] = [] + for path in REPO_ROOT.rglob("*.json"): + relative = path.relative_to(REPO_ROOT) + if any(part.startswith(".") or part in _SKIPPED_DIR_NAMES for part in relative.parts): + continue + files.append(path) + return sorted(files) + + +def _reject_duplicate_keys(pairs: list[tuple[str, Any]]) -> dict[str, Any]: + seen: set[str] = set() + duplicates: set[str] = set() + for key, _ in pairs: + if key in seen: + duplicates.add(key) + seen.add(key) + if duplicates: + raise ValueError(f"duplicate object keys: {sorted(duplicates)}") + return dict(pairs) + + +JSON_FILES = _json_files() + + +def test_json_file_discovery_finds_schema_files() -> None: + # Guards against the scan silently matching nothing. + assert len(JSON_FILES) > 100 + + +@pytest.mark.parametrize( + "path", JSON_FILES, ids=[str(p.relative_to(REPO_ROOT)) for p in JSON_FILES] +) +def test_json_file_has_no_duplicate_object_keys(path: Path) -> None: + with path.open(encoding="utf-8") as handle: + json.load(handle, object_pairs_hook=_reject_duplicate_keys) diff --git a/tests/test_observability_annotation_evaluator_contract.py b/tests/test_observability_annotation_evaluator_contract.py index cfe312b5..15567da5 100644 --- a/tests/test_observability_annotation_evaluator_contract.py +++ b/tests/test_observability_annotation_evaluator_contract.py @@ -85,6 +85,40 @@ def test_annotation_queue_update_request_is_all_optional_but_typed(v): assert v.validate_request(route, "PATCH", {"status": "bogus-status"}) +# Backend: AnnotationQueueCreateRequest / AnnotationQueueUpdateRequest, description +# max_length=2000 (annotation_queue.py). +@pytest.mark.parametrize( + ("file_name", "route", "method"), + [ + ("annotation_queue_create_request_schema.json", "/api/v1beta/annotation-queues", "POST"), + ( + "annotation_queue_update_request_schema.json", + "/api/v1beta/annotation-queues/{queue_id}", + "PATCH", + ), + ], +) +def test_annotation_queue_description_cap_matches_backend(v, file_name, route, method): + assert _load(file_name)["properties"]["description"]["maxLength"] == 2000 + base = {"name": "Q1", "target_type": "observability_trace", "measure_ids": ["m1"]} + body = base if method == "POST" else {} + assert v.validate_request(route, method, {**body, "description": "d" * 2000}) == [] + assert v.validate_request(route, method, {**body, "description": "d" * 2001}) + + +# Backend: AnnotationQueueUpdateRequest has extra="forbid" (annotation_queue.py) and +# ensure_update_has_fields rejects an update with no fields (annotation_queue.py). +def test_annotation_queue_update_rejects_empty_body_and_unknown_keys(v): + schema = _load("annotation_queue_update_request_schema.json") + assert schema["additionalProperties"] is False + assert schema["minProperties"] == 1 + + route = "/api/v1beta/annotation-queues/{queue_id}" + assert v.validate_request(route, "PATCH", {}) + assert v.validate_request(route, "PATCH", {"stauts": "paused"}) + assert v.validate_request(route, "PATCH", {"status": "paused", "bogus": 1}) + + def test_annotation_queue_item_create_result_wraps_created_items(): schema = _load("annotation_queue_item_create_result_schema.json") assert set(schema["required"]) == {"queue_id", "created_count", "items"} @@ -156,6 +190,63 @@ def test_evaluator_execute_request_requires_target_and_accepts_judge_override(v) ) +# #584: the fields the backend request models accept (extra="forbid") in +# the backend's evaluation request models: +# EvaluatorDefinitionUpdateRequest, EvaluatorExecuteRequest (via +# EvaluationTargetRef), EvaluatorBackfillRequest. +BACKEND_UPDATE_FIELDS = { + "name", "description", "measure_id", "target_type", "judge_config", + "sampling_rate", "target_filters", "is_active", +} +BACKEND_EXECUTE_FIELDS = {"target_type", "target_id", "override_judge_config"} +BACKFILL_ROUTE = "/api/v1beta/evaluators/{evaluator_id}/backfill" + + +def test_evaluator_update_request_declares_no_field_the_backend_forbids(v): + schema = _load("evaluator_update_request_schema.json") + assert set(schema["properties"]) <= BACKEND_UPDATE_FIELDS + assert "primary_measure_id" not in schema["properties"] + assert set(schema["properties"]["target_type"]["enum"]) == TARGET_TYPES | {None} + route = "/api/v1beta/evaluators/{evaluator_id}" + assert v.validate_request(route, "PATCH", {"target_type": "observability_trace"}) == [] + assert v.validate_request(route, "PATCH", {"measure_id": "accuracy"}) == [] + + +def test_evaluator_execute_request_declares_no_field_the_backend_forbids(v): + schema = _load("evaluator_execute_request_schema.json") + assert set(schema["properties"]) <= BACKEND_EXECUTE_FIELDS + assert "source" not in schema["properties"] + route = "/api/v1beta/evaluators/{evaluator_id}/execute" + assert v.validate_request( + route, "POST", {"target_type": "observability_trace", "target_id": "tr_1"} + ) == [] + + +def test_evaluator_backfill_request_is_a_closed_ref_matching_the_backend_model(v): + endpoints = _load("observability_endpoints.json") + body = endpoints["paths"][BACKFILL_ROUTE]["post"]["requestBody"]["content"][ + "application/json" + ]["schema"] + assert body == {"$ref": "./evaluator_backfill_request_schema.json"} + schema = _load("evaluator_backfill_request_schema.json") + assert schema["additionalProperties"] is False + assert set(schema["properties"]) == { + "target_type", "filters", "limit", "skip_existing_scores", + } + assert set(schema["properties"]["target_type"]["enum"]) == TARGET_TYPES | {None} + assert schema["properties"]["limit"]["minimum"] == 1 + assert schema["properties"]["limit"]["maximum"] == 500 + assert schema["properties"]["limit"]["default"] == 16 + assert v.validate_request(BACKFILL_ROUTE, "POST", {}) == [] + assert v.validate_request(BACKFILL_ROUTE, "POST", {"limit": 16}) == [] + assert v.validate_request( + BACKFILL_ROUTE, "POST", {"target_type": "observability_trace", "limit": 10} + ) == [] + assert v.validate_request(BACKFILL_ROUTE, "POST", {"target_ids": ["tr_1"]}) + assert v.validate_request(BACKFILL_ROUTE, "POST", {"force": True}) + assert v.validate_request(BACKFILL_ROUTE, "POST", {"limit": 501}) + + def test_evaluator_definition_create_request_extra_forbid_and_required(v): schema = _load("evaluator_definition_create_request_schema.json") assert schema["additionalProperties"] is False @@ -189,6 +280,26 @@ def test_evaluator_backfill_result_required_fields(): assert schema["properties"]["items"]["items"]["$ref"] == "./evaluator_run_schema.json" +def test_evaluator_backfill_result_declares_skip_reason_breakdown(v): + # #648: the backend's evaluation service returns skipped_reasons + # (target_id -> reason) and skipped_reason_counts (reason -> count). + schema = _load("evaluator_backfill_result_schema.json") + reasons = schema["properties"]["skipped_reasons"] + assert reasons["type"] == "object" + assert reasons["additionalProperties"] == {"type": "string"} + counts = schema["properties"]["skipped_reason_counts"] + assert counts["type"] == "object" + assert counts["additionalProperties"] == {"type": "integer", "minimum": 1} + body = { + "evaluator_id": "ev_1", "target_type": "observability_trace", + "submitted_count": 1, "skipped_count": 2, + "skipped_target_ids": ["tr_2", "tr_3"], "items": [], + "skipped_reasons": {"tr_2": "already_scored", "tr_3": "already_scored"}, + "skipped_reason_counts": {"already_scored": 2}, + } + assert v.validate_json(body, "evaluator_backfill_result_schema") == [] + + def test_evaluator_list_response_wraps_definitions(): schema = _load("evaluator_list_response_schema.json") assert set(schema["required"]) == {"items", "pagination"} @@ -378,3 +489,121 @@ def test_evaluator_definition_response_carries_target_filters(v): assert v.validate_json(resp, "evaluator_definition_schema") == [] assert v.validate_json({**resp, "target_filters": {"status": ["x"]}}, "evaluator_definition_schema") assert v.validate_json({**resp, "target_filters": {"tags": []}}, "evaluator_definition_schema") + + +# #584: the reproduction bodies from the issue, validated through the backend contract. +# Backend EvaluatorDefinitionUpdateRequest and EvaluatorExecuteRequest (via EvaluationTargetRef) +# are extra="forbid" (the backend's evaluation request models), and +# EvaluatorDefinitionUpdateRequest.ensure_update_has_fields rejects an empty body. The request schemas must reject the same bodies. +@pytest.mark.parametrize( + ("route", "method", "body"), + [ + ("/api/v1beta/evaluators/{evaluator_id}", "PATCH", {"primary_measure_id": "accuracy"}), + ( + "/api/v1beta/evaluators/{evaluator_id}/execute", + "POST", + {"target_type": "observability_trace", "target_id": "tr_1", "source": "manual"}, + ), + ("/api/v1beta/evaluators/{evaluator_id}", "PATCH", {}), + ], +) +def test_evaluator_bodies_the_backend_rejects_fail_schema(v, route, method, body): + assert v.validate_request(route, method, body) + + +def test_evaluator_update_and_execute_schemas_are_closed(): + update = _load("evaluator_update_request_schema.json") + assert update["additionalProperties"] is False + assert update["minProperties"] == 1 + assert _load("evaluator_execute_request_schema.json")["additionalProperties"] is False + + +def test_evaluator_update_and_execute_valid_bodies_still_pass(v): + update = "/api/v1beta/evaluators/{evaluator_id}" + execute = "/api/v1beta/evaluators/{evaluator_id}/execute" + assert v.validate_request(update, "PATCH", {"measure_id": "accuracy"}) == [] + assert v.validate_request(update, "PATCH", {"target_type": "observability_trace"}) == [] + assert v.validate_request(update, "PATCH", {"is_active": False}) == [] + assert v.validate_request( + execute, "POST", {"target_type": "observability_trace", "target_id": "tr_1"} + ) == [] + assert v.validate_request( + execute, + "POST", + {"target_type": "observability_trace", "target_id": "tr_1", "override_judge_config": None}, + ) == [] + + +# #640: AnnotationQueueCreateRequest is extra="forbid" (the backend's +# annotation queue request model) and the route validates the raw body +# with model_validate (annotation_queue_routes.py), so unknown keys get a 422. +def test_annotation_queue_create_rejects_unknown_keys(v): + schema = _load("annotation_queue_create_request_schema.json") + assert schema["additionalProperties"] is False + + route = "/api/v1beta/annotation-queues" + body = {"name": "Q1", "target_type": "observability_trace", "measure_ids": ["m1"]} + assert v.validate_request(route, "POST", body) == [] + assert v.validate_request(route, "POST", {**body, "bogus": 1}) + assert v.validate_request(route, "POST", {**body, "measure_id": "m1"}) + + +# Backend EvaluatorBackfillRequest.target_type is EvaluationTargetType | None +# (evaluation_ops.py) +# and the service falls back to the evaluator's own target_type when it is None +# (evaluation_ops_service.py). The route accepts an explicit null. +def test_evaluator_backfill_accepts_null_target_type(v): + assert v.validate_request(BACKFILL_ROUTE, "POST", {"target_type": None}) == [] + assert v.validate_request(BACKFILL_ROUTE, "POST", {"target_type": "bogus"}) + + +# #723: the update bodies must refuse what the service refuses. A body whose only field is a +# null description is a 422 on both routes (annotation queue: annotation_queue.py strips +# blank strings to None and ensure_update_has_fields rejects an empty result; evaluator: +# evaluation_ops.py dumps with exclude_none). Each update schema carries a root anyOf +# that requires one usable field. +def test_annotation_queue_update_rejects_null_or_blank_only_bodies(v): + schema = _load("annotation_queue_update_request_schema.json") + assert schema["minProperties"] == 1 + assert "anyOf" in schema + + route = "/api/v1beta/annotation-queues/{queue_id}" + assert v.validate_request(route, "PATCH", {"description": None}) + assert v.validate_request(route, "PATCH", {"name": " "}) + assert v.validate_request(route, "PATCH", {"description": " "}) + assert v.validate_request(route, "PATCH", {}) + + assert v.validate_request(route, "PATCH", {"description": None, "name": "q"}) == [] + assert v.validate_request(route, "PATCH", {"name": " ", "status": "paused"}) == [] + assert v.validate_request(route, "PATCH", {"measure_ids": [" "]}) == [] + + +def test_evaluator_update_rejects_null_description_only_body(v): + schema = _load("evaluator_update_request_schema.json") + assert schema["minProperties"] == 1 + assert "anyOf" in schema + + route = "/api/v1beta/evaluators/{evaluator_id}" + assert v.validate_request(route, "PATCH", {"description": None}) + assert v.validate_request(route, "PATCH", {}) + + assert v.validate_request(route, "PATCH", {"description": None, "name": "q"}) == [] + assert v.validate_request(route, "PATCH", {"description": " "}) == [] + + +# Parity with EvaluatorDefinitionUpdateRequest (backend evaluation_ops.py): +# target_type is `EvaluationTargetType | None` and a null target_type means "unchanged" +# (dumped with exclude_none). So a null target_type alongside another field is accepted, +# and a body whose only field is a null target_type is refused (422 "at least one field"). +def test_evaluator_update_null_target_type_means_unchanged(v): + route = "/api/v1beta/evaluators/{evaluator_id}" + assert v.validate_request(route, "PATCH", {"target_type": None, "is_active": True}) == [] + assert v.validate_request(route, "PATCH", {"target_type": None}) + assert v.validate_request(route, "PATCH", {"target_type": "observability_trace"}) == [] + assert v.validate_request(route, "PATCH", {"target_type": "not-a-target"}) + +def test_evaluator_update_anyof_target_type_enum_matches_the_property_enum() -> None: + """The anyOf branch repeats the enum (the maxLength lint needs it): it must not drift.""" + schema = _load("evaluator_update_request_schema.json") + branch = next(b for b in schema["anyOf"] if b.get("required") == ["target_type"]) + assert set(branch["properties"]["target_type"]["enum"]) == TARGET_TYPES diff --git a/tests/test_process_record_verifier.py b/tests/test_process_record_verifier.py index 33a78bb4..7e55cd7c 100644 --- a/tests/test_process_record_verifier.py +++ b/tests/test_process_record_verifier.py @@ -19,7 +19,7 @@ import tempfile import traceback from dataclasses import FrozenInstanceError, asdict, fields, replace -from datetime import datetime, timedelta, timezone +from datetime import UTC, datetime, timedelta from importlib import resources from pathlib import Path from typing import Any @@ -93,7 +93,7 @@ def _shift_timestamp(timestamp: str, *, seconds: float = 0, microseconds: int = inference" note) rather than through ``datetime``; this helper builds fixtures, it is not the code under test. """ - base = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc) + base = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=UTC) shifted = base + timedelta(seconds=seconds, microseconds=microseconds) return shifted.strftime("%Y-%m-%dT%H:%M:%S.%f") + "Z" diff --git a/tests/test_python_support_policy.py b/tests/test_python_support_policy.py index 9fa6740e..0d9ba4ca 100644 --- a/tests/test_python_support_policy.py +++ b/tests/test_python_support_policy.py @@ -1,8 +1,7 @@ from __future__ import annotations -from pathlib import Path - import tomllib +from pathlib import Path _REPO_ROOT = Path(__file__).resolve().parent.parent @@ -20,7 +19,7 @@ def test_package_metadata_supports_python_311_and_newer() -> None: assert '"Programming Language :: Python :: 3.11"' in pyproject assert '"pytest>=9.0.3"' in pyproject assert "python_version < '3.10'" not in pyproject - assert 'target-version = "py310"' in pyproject # held: py311 adds UP017 + assert 'target-version = "py311"' in pyproject # ruff target = requires-python floor (#711) assert 'python_version = "3.11"' in pyproject diff --git a/tests/test_stop_reason_schema.py b/tests/test_stop_reason_schema.py index 2b6b52dd..209030ec 100644 --- a/tests/test_stop_reason_schema.py +++ b/tests/test_stop_reason_schema.py @@ -93,3 +93,48 @@ def test_finalize_response_stop_reason_accepts_backend_reasons_and_null() -> Non ) == [] ) + + +# #696: optimization_outcome sets the terminal run status (the backend's +# terminal outcome mapping); the request must declare it. +OUTCOMES = {"completed", "failed", "cancelled"} + + +def test_finalize_request_declares_optimization_outcome_enum() -> None: + endpoints = _load("optimization_endpoints.json") + req = endpoints["paths"]["/api/v1/sessions/{session_id}/finalize"]["post"]["requestBody"][ + "content" + ]["application/json"]["schema"]["properties"] + assert set(req["optimization_outcome"]["enum"]) == OUTCOMES | {None} + + +@pytest.mark.parametrize("outcome", sorted(OUTCOMES)) +def test_finalize_request_accepts_every_outcome(outcome: str) -> None: + errors = SchemaValidator(contract="sdk_tuning").validate_request( + FINALIZE_PATH, "POST", {"optimization_outcome": outcome} + ) + assert errors == [] + + +@pytest.mark.parametrize("bad", ["running", "", "COMPLETED", 1]) +def test_finalize_request_rejects_unknown_optimization_outcome(bad: object) -> None: + assert SchemaValidator(contract="sdk_tuning").validate_request( + FINALIZE_PATH, "POST", {"optimization_outcome": bad} + ) + + +# optimization_outcome: null is accepted by the backend and means the same as absent. +# validate_optimization_outcome(None) returns None in the backend; +# the finalize route passes the raw value through; absent and None both resolve to "completed". +def test_finalize_request_accepts_null_optimization_outcome_like_absent() -> None: + v = SchemaValidator(contract="sdk_tuning") + assert v.validate_request(FINALIZE_PATH, "POST", {"optimization_outcome": None}) == [] + assert v.validate_request(FINALIZE_PATH, "POST", {}) == [] + + +def test_finalize_request_null_is_declared_in_the_schema_type() -> None: + endpoints = _load("optimization_endpoints.json") + req = endpoints["paths"]["/api/v1/sessions/{session_id}/finalize"]["post"]["requestBody"][ + "content" + ]["application/json"]["schema"]["properties"] + assert req["optimization_outcome"]["type"] == ["string", "null"] diff --git a/tests/test_structural_validity.py b/tests/test_structural_validity.py index 6e430e16..cc5fe84c 100644 --- a/tests/test_structural_validity.py +++ b/tests/test_structural_validity.py @@ -118,3 +118,12 @@ def test_version_matches_newest_dated_changelog_section() -> None: f"version.py is {version} but the newest dated CHANGELOG section is " f"[{dated[0]}] (#131: reconcile version.py with a dated CHANGELOG entry)" ) + + +def test_changelog_release_date_matches_version_bump_commit() -> None: + """The [7.1.0] header date is the version-bump date (commit 2616b2b, 2026-11-03), the + same convention as [7.0.0] and [6.1.0] (both dated their bump commit's day).""" + changelog = (_REPO_ROOT / "CHANGELOG.md").read_text(encoding="utf-8") + match = re.search(r"^## \[7\.1\.0\] - (\d{4}-\d{2}-\d{2})", changelog, re.MULTILINE) + assert match, "CHANGELOG has no [7.1.0] dated header" + assert match.group(1) == "2026-11-03" diff --git a/tests/test_tvl_governance_schemas.py b/tests/test_tvl_governance_schemas.py index 0f767e2d..8e2abb71 100644 --- a/tests/test_tvl_governance_schemas.py +++ b/tests/test_tvl_governance_schemas.py @@ -9,7 +9,9 @@ from __future__ import annotations -from traigent_schema import SchemaValidator +import json + +from traigent_schema import SchemaValidator, get_schemas_dir # The REAL package validator and registry — review round 1 found a custom # filename-keyed registry here hid an unresolvable $ref; using the package @@ -25,6 +27,60 @@ def _errors(schema_name: str, instance: dict) -> list: return _VALIDATOR.validate_json(instance, schema_name) +class TestPromotionPolicyBoundsMatchTvl: + """#580: the bounds TVL's validator (python/tvl/lints.py: invalid_alpha, + invalid_chance_threshold, invalid_chance_confidence) and the backend + normalizers (interactive_session_service.py: _normalize_policy_alpha, + _normalize_policy_min_effect, _normalize_chance_constraint) enforce.""" + + @staticmethod + def _policy(**fields) -> dict: + return {"dominance": "epsilon_pareto", **fields} + + def test_alpha_is_open_interval(self) -> None: + assert _errors(POLICY, self._policy(alpha=0)) + assert _errors(POLICY, self._policy(alpha=1)) + assert not _errors(POLICY, self._policy(alpha=0.05)) + + def test_min_effect_is_non_negative(self) -> None: + assert _errors(POLICY, self._policy(min_effect={"latency": -0.1})) + assert not _errors(POLICY, self._policy(min_effect={"latency": 0})) + assert not _errors(POLICY, self._policy(min_effect={"latency.p95": 0.1})) + + def test_chance_threshold_is_closed_unit_interval(self) -> None: + def cc(threshold, confidence=0.95): + return self._policy( + chance_constraints=[ + {"name": "slow_reply", "threshold": threshold, "confidence": confidence} + ] + ) + + assert _errors(POLICY, cc(1.5)) + assert _errors(POLICY, cc(-0.1)) + assert not _errors(POLICY, cc(0)) + assert not _errors(POLICY, cc(1)) + assert not _errors(POLICY, cc(0.05)) + + def test_chance_confidence_is_open_interval(self) -> None: + def cc(confidence): + return self._policy( + chance_constraints=[ + {"name": "slow_reply", "threshold": 0.05, "confidence": confidence} + ] + ) + + assert _errors(POLICY, cc(0)) + assert _errors(POLICY, cc(1)) + assert not _errors(POLICY, cc(0.95)) + + def test_threshold_is_described_as_violation_rate(self) -> None: + path = get_schemas_dir() / "optimization" / "promotion_policy_schema.json" + schema = json.loads(path.read_text(encoding="utf-8")) + threshold = schema["definitions"]["ChanceConstraint"]["properties"]["threshold"] + assert "violation" in threshold["description"].lower() + assert "Minimum acceptable metric value" not in threshold["description"] + + class TestRequireCalibration: def test_strict_policy_accepted(self) -> None: policy = { @@ -206,3 +262,10 @@ def test_finalize_full_history_accepted(self) -> None: ], } assert not _errors(FINALIZE, response) + + +def test_promotion_policy_version_bumped_for_580_constraint_tightening() -> None: + """#580 tightened alpha, min_effect, threshold and confidence, a contract change that must + move the schema's own version field (0.10.0 predates it; bumped to 0.11.0).""" + schema_path = get_schemas_dir() / "optimization" / "promotion_policy_schema.json" + assert json.loads(schema_path.read_text(encoding="utf-8"))["version"] == "0.11.0" diff --git a/tests/test_verify_identity_vectors_script.py b/tests/test_verify_identity_vectors_script.py new file mode 100644 index 00000000..de9d7b7f --- /dev/null +++ b/tests/test_verify_identity_vectors_script.py @@ -0,0 +1,110 @@ +"""The production identity-vector verifier must fail when it checks nothing (#709).""" + +from __future__ import annotations + +import importlib.util +import sys +import types +from pathlib import Path + +import pytest + +SCRIPT = ( + Path(__file__).resolve().parents[1] + / "scripts" + / "verify_identity_vectors_against_production.py" +) + + +def _load_script(): + spec = importlib.util.spec_from_file_location("verify_identity_vectors", SCRIPT) + assert spec is not None and spec.loader is not None + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +@pytest.fixture +def script(): + return _load_script() + + +@pytest.fixture +def stub_traigent(monkeypatch): + # The SDK import is the only thing check_sdk needs from the checkout. + monkeypatch.setitem(sys.modules, "traigent", types.ModuleType("traigent")) + + +@pytest.fixture +def stub_traigent_with_optimize(monkeypatch): + # Passes the entry-point guard, so an empty vector list reaches the + # `checked == 0` guard that these tests exercise. + stub = types.ModuleType("traigent") + stub.optimize = lambda **_kwargs: (lambda fn: fn) + monkeypatch.setitem(sys.modules, "traigent", stub) + + +def test_check_sdk_reports_a_problem_when_zero_python_vectors_are_checked( + script, stub_traigent_with_optimize, monkeypatch +): + monkeypatch.setattr(script, "_py_vectors", lambda: []) + problems = script.check_sdk() + assert problems, "checked 0 python vectors must be reported as a problem" + + +def test_main_exits_nonzero_when_zero_python_vectors_are_checked( + script, stub_traigent_with_optimize, monkeypatch, tmp_path +): + monkeypatch.setattr(script, "_py_vectors", lambda: []) + monkeypatch.setattr(sys, "path", list(sys.path)) + monkeypatch.setattr(sys, "argv", ["verify", "--component", "sdk", "--checkout", str(tmp_path)]) + monkeypatch.chdir(tmp_path) + assert script.main() != 0 + + +UNSUPPORTED_VECTOR = { + "id": "unsupported-vector", + "input": {"sdk": "python", "function_name": "f", "objectives": ["accuracy"]}, + "expected": {"outcome": "unsupported"}, +} + +SUPPORTED_VECTOR = { + "id": "supported-vector", + "input": {"sdk": "python", "function_name": "probe_fn", "objectives": ["accuracy"]}, + "expected": {"registration_identity": "probe_fn"}, +} + + +def _run_main(script, tmp_path, monkeypatch): + monkeypatch.setattr(sys, "path", list(sys.path)) + monkeypatch.setattr(sys, "argv", ["verify", "--component", "sdk", "--checkout", str(tmp_path)]) + monkeypatch.chdir(tmp_path) + return script.main() + + +def test_main_fails_when_stub_sdk_lacks_optimize_and_only_unsupported_vectors( + script, stub_traigent, monkeypatch, tmp_path +): + # A stub/old SDK with no `optimize` makes the unsupported vector raise + # AttributeError for the wrong reason; that must not count as verified. + monkeypatch.setattr(script, "_py_vectors", lambda: [UNSUPPORTED_VECTOR]) + assert _run_main(script, tmp_path, monkeypatch) != 0 + + +def test_main_exits_zero_when_supported_vector_checks_out( + script, monkeypatch, tmp_path +): + # Control: a working optimize decorator plus a supported vector passes. + stub = types.ModuleType("traigent") + + def optimize(**_kwargs): + def deco(fn): + fn.experiment_name = fn.__name__ + return fn + + return deco + + stub.optimize = optimize + monkeypatch.setitem(sys.modules, "traigent", stub) + monkeypatch.setattr(script, "_py_vectors", lambda: [UNSUPPORTED_VECTOR, SUPPORTED_VECTOR]) + assert _run_main(script, tmp_path, monkeypatch) == 0 diff --git a/tests/test_workflow_job_guards.py b/tests/test_workflow_job_guards.py new file mode 100644 index 00000000..58f6957b --- /dev/null +++ b/tests/test_workflow_job_guards.py @@ -0,0 +1,66 @@ +"""Every workflow job is bounded, and every pull_request workflow is cancellable. + +A job without ``timeout-minutes`` runs to GitHub's 6 hour default when it hangs, +and a pull_request workflow without a ``concurrency`` group keeps burning runners +on superseded pushes. #701 found three PR workflows and nine jobs with neither +guard; this pins the convention ci.yml already follows so a new workflow cannot +drift back. +""" + +from __future__ import annotations + +from pathlib import Path +from typing import Any + +import yaml + +REPO_ROOT = Path(__file__).resolve().parent.parent +WORKFLOWS_DIR = REPO_ROOT / ".github" / "workflows" + + +def _workflows() -> dict[str, dict[str, Any]]: + paths = sorted(WORKFLOWS_DIR.glob("*.yml")) + assert paths, f"no workflows found under {WORKFLOWS_DIR}" + parsed: dict[str, dict[str, Any]] = {} + for path in paths: + document = yaml.safe_load(path.read_text(encoding="utf-8")) + assert isinstance(document, dict), f"{path.name} must parse as a workflow mapping" + parsed[path.name] = document + return parsed + + +def _triggers(workflow: dict[str, Any]) -> set[str]: + # PyYAML reads the bare `on:` key as the boolean True. + on = workflow.get("on", workflow.get(True)) + if isinstance(on, str): + return {on} + if isinstance(on, list): + return set(on) + if isinstance(on, dict): + return set(on) + return set() + + +def test_every_job_declares_an_integer_timeout_minutes() -> None: + missing = [ + f"{name}:{job_id}" + for name, workflow in _workflows().items() + for job_id, job in (workflow.get("jobs") or {}).items() + if not isinstance(job.get("timeout-minutes"), int) + ] + + assert not missing, f"jobs without an integer timeout-minutes: {missing}" + + +def test_every_pull_request_workflow_declares_a_concurrency_group() -> None: + missing = [ + name + for name, workflow in _workflows().items() + if "pull_request" in _triggers(workflow) + and not ( + isinstance(workflow.get("concurrency"), dict) + and workflow["concurrency"].get("group") + ) + ] + + assert not missing, f"pull_request workflows without a concurrency group: {missing}" diff --git a/traigent_schema/analytics_validators.py b/traigent_schema/analytics_validators.py index 48c1e53c..4a9a7712 100644 --- a/traigent_schema/analytics_validators.py +++ b/traigent_schema/analytics_validators.py @@ -92,6 +92,7 @@ def validate_example_metrics(self, data: dict[str, Any]) -> list[str]: List of validation error messages. Empty if valid. Example: + >>> validator = AnalyticsValidator() >>> validator.validate_example_metrics({ ... "example_id": "ex_abc12345_0", ... "metrics": {"score": 0.85, "cost": 0.05} @@ -125,6 +126,7 @@ def validate_example_id_format(self, example_id: str) -> bool: True if valid format, False otherwise Example: + >>> validator = AnalyticsValidator() >>> validator.validate_example_id_format("ex_abc12345_0") True >>> validator.validate_example_id_format("invalid") @@ -145,6 +147,7 @@ def validate_job_id_format(self, job_id: str) -> bool: True if valid format, False otherwise Example: + >>> validator = AnalyticsValidator() >>> validator.validate_job_id_format("score_exp_run_abc123_1705320600") True >>> validator.validate_job_id_format("invalid_job") @@ -173,6 +176,7 @@ def validate_algorithm_version(self, version: str) -> bool: True if valid semver (MAJOR.MINOR.PATCH), False otherwise Example: + >>> validator = AnalyticsValidator() >>> validator.validate_algorithm_version("1.0.0") True >>> validator.validate_algorithm_version("v1.0.0") diff --git a/traigent_schema/certification/dataset_record_verifier.py b/traigent_schema/certification/dataset_record_verifier.py index 4a4ddd1f..9abbad89 100644 --- a/traigent_schema/certification/dataset_record_verifier.py +++ b/traigent_schema/certification/dataset_record_verifier.py @@ -71,7 +71,7 @@ import struct from collections.abc import Mapping, Sequence from dataclasses import dataclass -from datetime import date, datetime, timezone +from datetime import UTC, date, datetime from functools import lru_cache from importlib import resources from importlib.resources.abc import Traversable @@ -1957,7 +1957,7 @@ def _utc_microseconds(value: str) -> int: frac = value[dot_index + 1 : -1] if dot_index != -1 else "" frac_us = int((frac + "000000")[:6]) if frac else 0 try: - datetime(year, month, day, hour, minute, second, tzinfo=timezone.utc) + datetime(year, month, day, hour, minute, second, tzinfo=UTC) except ValueError: _fail("PREREGISTRATION_ORDER") days = date(year, month, day).toordinal() - _EPOCH_ORDINAL diff --git a/traigent_schema/example_identity.py b/traigent_schema/example_identity.py index 0ee0f5b4..75251e97 100644 --- a/traigent_schema/example_identity.py +++ b/traigent_schema/example_identity.py @@ -498,6 +498,8 @@ def _check_agent_revision(manifest: dict[str, Any]) -> None: raise ContentIdentityError( "agent build manifest with a dirty code_revision needs source_digest" ) + if "source_digest" in manifest: + _require_digest(manifest["source_digest"], "source_digest") def _check_agent_assets(assets: Any) -> None: diff --git a/traigent_schema/fleet_observe_digest.py b/traigent_schema/fleet_observe_digest.py index d8c4bf6b..7b90ef57 100644 --- a/traigent_schema/fleet_observe_digest.py +++ b/traigent_schema/fleet_observe_digest.py @@ -21,7 +21,7 @@ import re import unicodedata from collections.abc import Mapping, Sequence -from datetime import datetime, timezone +from datetime import UTC, datetime from typing import Any __all__ = [ @@ -91,7 +91,7 @@ def canonical_observed_at(stamp: str) -> str: if not isinstance(stamp, str) or _TIMESTAMP_RE.match(stamp) is None: raise _fail("observed_at") try: - parsed = datetime.fromisoformat(stamp[:-1] + "+00:00").astimezone(timezone.utc) + parsed = datetime.fromisoformat(stamp[:-1] + "+00:00").astimezone(UTC) except ValueError: raise _fail("observed_at") from None return parsed.strftime("%Y-%m-%dT%H:%M:%S.%fZ") diff --git a/traigent_schema/schemas/agents/agent_create_request_schema.json b/traigent_schema/schemas/agents/agent_create_request_schema.json index 561ff8d8..80948eb1 100644 --- a/traigent_schema/schemas/agents/agent_create_request_schema.json +++ b/traigent_schema/schemas/agents/agent_create_request_schema.json @@ -107,7 +107,7 @@ }, "retrieval_configs": { "type": "array", - "maxItems": 50, + "maxItems": 100, "items": { "type": "object", "additionalProperties": true @@ -115,7 +115,7 @@ }, "model_parameters": { "type": "array", - "maxItems": 50, + "maxItems": 100, "items": { "type": "object", "additionalProperties": true diff --git a/traigent_schema/schemas/agents/agent_response_schema.json b/traigent_schema/schemas/agents/agent_response_schema.json index 8ec71bd8..b09416e1 100644 --- a/traigent_schema/schemas/agents/agent_response_schema.json +++ b/traigent_schema/schemas/agents/agent_response_schema.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Agent Response Schema", - "description": "Schema for agent responses following OpenAI API format", "version": "1.0.0", "definitions": { "NonStreamResponse": { diff --git a/traigent_schema/schemas/analytics/analytics_endpoints.json b/traigent_schema/schemas/analytics/analytics_endpoints.json index 5877f09a..fe7c17ed 100644 --- a/traigent_schema/schemas/analytics/analytics_endpoints.json +++ b/traigent_schema/schemas/analytics/analytics_endpoints.json @@ -3830,7 +3830,42 @@ } }, "deprecated": true, - "description": "DEPRECATED: replaced by GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/pareto (operationId experiment_run.get_run_pareto), addressed by an explicit project and a server-issued run reference and paginated (limit, cursor, items, pagination); the same handler is also mounted on /api/v1beta/projects/{project_id}/analytics/runs/{run_id}/pareto (backend src/routes/api_v1beta.py:111), which is not declared in this contract and retires with it; removal follows the backend retirement PR after the client receipt." + "description": "DEPRECATED: replaced by GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/pareto (operationId experiment_run.get_run_pareto), addressed by an explicit project and a server-issued run reference and paginated (limit, cursor, items, pagination); the same handler is also mounted on /api/v1beta/projects/{project_id}/analytics/runs/{run_id}/pareto (backend src/routes/api_v1beta.py:111), which is not declared in this contract and retires with it; removal follows the backend retirement PR after the client receipt.", + "parameters": [ + { + "name": "x_measure", + "in": "query", + "required": false, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 100, + "default": "cost" + } + }, + { + "name": "y_measure", + "in": "query", + "required": false, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 100, + "default": "quality" + } + }, + { + "name": "request_count", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 1000000, + "default": 1 + } + } + ] } }, "/api/v1/analytics/runs/{run_id}/correlations": { @@ -3910,7 +3945,33 @@ } }, "deprecated": true, - "description": "DEPRECATED: replaced by GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/correlations (operationId experiment_run.get_run_correlations), addressed by an explicit project and a server-issued run reference, with bounded dimensions and a closed problem vocabulary; the same handler is also mounted on the project-scoped beta analytics mount (/api/v1beta/projects/{project_id}/analytics/runs/{run_id}/correlations, backend src/routes/api_v1beta.py:111), which is not declared in this contract and retires with it; removal follows the backend retirement PR after the client receipt." + "description": "DEPRECATED: replaced by GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/correlations (operationId experiment_run.get_run_correlations), addressed by an explicit project and a server-issued run reference, with bounded dimensions and a closed problem vocabulary; the same handler is also mounted on the project-scoped beta analytics mount (/api/v1beta/projects/{project_id}/analytics/runs/{run_id}/correlations, backend src/routes/api_v1beta.py:111), which is not declared in this contract and retires with it; removal follows the backend retirement PR after the client receipt.", + "parameters": [ + { + "name": "method", + "in": "query", + "required": false, + "schema": { + "type": "string", + "enum": [ + "pearson", + "spearman" + ], + "default": "pearson" + } + }, + { + "name": "min_sample", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 2, + "maximum": 10000, + "default": 3 + } + } + ] } }, "/api/v1/analytics/runs/{run_id}/leaderboard": { @@ -3990,7 +4051,64 @@ } }, "deprecated": true, - "description": "DEPRECATED: replaced by GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/leaderboard (operationId experiment_run.get_run_leaderboard), addressed by an explicit project and a server-issued run reference and paginated (limit default 20, maximum 100, cursor, items, pagination); the same handler is also mounted on /api/v1beta/projects/{project_id}/analytics/runs/{run_id}/leaderboard (backend src/routes/api_v1beta.py:111), which is not declared in this contract and retires with it; removal follows the backend retirement PR after the client receipt." + "description": "DEPRECATED: replaced by GET /api/v1/projects/{project_id}/experiment-runs/{experiment_run_ref}/leaderboard (operationId experiment_run.get_run_leaderboard), addressed by an explicit project and a server-issued run reference and paginated (limit default 20, maximum 100, cursor, items, pagination); the same handler is also mounted on /api/v1beta/projects/{project_id}/analytics/runs/{run_id}/leaderboard (backend src/routes/api_v1beta.py:111), which is not declared in this contract and retires with it; removal follows the backend retirement PR after the client receipt.", + "parameters": [ + { + "name": "objective", + "in": "query", + "required": false, + "schema": { + "type": "string", + "enum": [ + "weighted", + "quality", + "cost", + "latency" + ], + "default": "weighted" + } + }, + { + "name": "weights", + "in": "query", + "required": false, + "schema": { + "type": "string", + "description": "JSON object string mapping measure name to a finite number. Keys match ^[a-zA-Z_][a-zA-Z0-9_.-]*$; at most 50 keys." + } + }, + { + "name": "constraints", + "in": "query", + "required": false, + "schema": { + "type": "string", + "description": "JSON object string mapping measure name to a finite number. Keys match ^[a-zA-Z_][a-zA-Z0-9_.-]*$; at most 50 keys." + } + }, + { + "name": "request_count", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 1000000, + "default": 1 + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 200, + "default": 50 + } + } + ] } }, "/api/v1/analytics/runs/{run_id}/parameter-insights": { @@ -4068,7 +4186,42 @@ } } } - } + }, + "parameters": [ + { + "name": "target_measure", + "in": "query", + "required": false, + "schema": { + "type": "string", + "minLength": 1, + "maxLength": 100, + "default": "quality" + } + }, + { + "name": "min_trials", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 2, + "maximum": 10000, + "default": 10 + } + }, + { + "name": "top_k", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "minimum": 1, + "maximum": 50, + "default": 10 + } + } + ] } }, "/api/v1/analytics/runs/{run_id}/example-insights": { diff --git a/traigent_schema/schemas/datasets/example_set_create_request_schema.json b/traigent_schema/schemas/datasets/example_set_create_request_schema.json index d286ef0f..0f5cc189 100644 --- a/traigent_schema/schemas/datasets/example_set_create_request_schema.json +++ b/traigent_schema/schemas/datasets/example_set_create_request_schema.json @@ -17,9 +17,18 @@ }, "selection_method": { "type": "string", - "minLength": 1, "description": "Example-set selection method.", - "maxLength": 255 + "enum": [ + "all", + "random", + "semantic_similarity", + "similarity", + "sequential", + "manual", + "diversity-based", + "difficulty-based", + "difficulty_weighted" + ] }, "description": { "type": "string", @@ -28,7 +37,17 @@ "type": { "type": "string", "description": "Example-set type (default input-output).", - "maxLength": 255 + "enum": [ + "input-only", + "input-output", + "multi-turn conversation", + "conversation", + "classification", + "structured", + "generation", + "evaluation", + "other" + ] }, "num_examples": { "type": "integer", @@ -41,6 +60,7 @@ }, "tags": { "type": "array", + "maxItems": 100, "items": { "type": "string", "maxLength": 1000 diff --git a/traigent_schema/schemas/evaluation/evaluation_schema.json b/traigent_schema/schemas/evaluation/evaluation_schema.json index 4ba13976..71b3dfc5 100644 --- a/traigent_schema/schemas/evaluation/evaluation_schema.json +++ b/traigent_schema/schemas/evaluation/evaluation_schema.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Evaluation Schema", - "description": "Schema for evaluation requests and results in the Traigent platform", "version": "1.0.0", "definitions": { "EvaluationStatus": { diff --git a/traigent_schema/schemas/measures/score_schema.json b/traigent_schema/schemas/measures/score_schema.json index c64f6b7e..16d912a5 100644 --- a/traigent_schema/schemas/measures/score_schema.json +++ b/traigent_schema/schemas/measures/score_schema.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Score Schema", - "description": "Schema for scoring and evaluation metrics in the Traigent platform", "version": "1.0.0", "definitions": { "Score": { diff --git a/traigent_schema/schemas/observability/annotation_queue_create_request_schema.json b/traigent_schema/schemas/observability/annotation_queue_create_request_schema.json index b3023b50..4702f5cd 100644 --- a/traigent_schema/schemas/observability/annotation_queue_create_request_schema.json +++ b/traigent_schema/schemas/observability/annotation_queue_create_request_schema.json @@ -3,7 +3,7 @@ "$id": "https://schemas.traigent.ai/observability/annotation_queue_create_request_schema.json", "title": "Annotation Queue Create Request Schema", "type": "object", - "additionalProperties": true, + "additionalProperties": false, "properties": { "name": { "type": "string", @@ -15,7 +15,7 @@ "string", "null" ], - "maxLength": 5000 + "maxLength": 2000 }, "target_type": { "type": "string", diff --git a/traigent_schema/schemas/observability/annotation_queue_update_request_schema.json b/traigent_schema/schemas/observability/annotation_queue_update_request_schema.json index 115b4c3a..51dd864f 100644 --- a/traigent_schema/schemas/observability/annotation_queue_update_request_schema.json +++ b/traigent_schema/schemas/observability/annotation_queue_update_request_schema.json @@ -3,7 +3,8 @@ "$id": "https://schemas.traigent.ai/observability/annotation_queue_update_request_schema.json", "title": "Annotation Queue Update Request Schema", "type": "object", - "additionalProperties": true, + "additionalProperties": false, + "minProperties": 1, "properties": { "name": { "type": "string", @@ -15,7 +16,7 @@ "string", "null" ], - "maxLength": 5000 + "maxLength": 2000 }, "measure_ids": { "type": "array", @@ -33,5 +34,39 @@ "archived" ] } - } + }, + "anyOf": [ + { + "required": [ + "name" + ], + "properties": { + "name": { + "pattern": "\\S" + } + } + }, + { + "required": [ + "description" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 2000, + "pattern": "\\S" + } + } + }, + { + "required": [ + "measure_ids" + ] + }, + { + "required": [ + "status" + ] + } + ] } diff --git a/traigent_schema/schemas/observability/evaluator_backfill_request_schema.json b/traigent_schema/schemas/observability/evaluator_backfill_request_schema.json new file mode 100644 index 00000000..566b8272 --- /dev/null +++ b/traigent_schema/schemas/observability/evaluator_backfill_request_schema.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schemas.traigent.ai/observability/evaluator_backfill_request_schema.json", + "title": "Evaluator Backfill Request Schema", + "type": "object", + "additionalProperties": false, + "properties": { + "target_type": { + "type": [ + "string", + "null" + ], + "enum": [ + "observability_trace", + "observability_observation", + "configuration_run", + "experiment_run", + null + ] + }, + "filters": { + "type": "object" + }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 500, + "default": 16 + }, + "skip_existing_scores": { + "type": "boolean", + "default": true + } + } +} diff --git a/traigent_schema/schemas/observability/evaluator_backfill_result_schema.json b/traigent_schema/schemas/observability/evaluator_backfill_result_schema.json index ca1cee0f..000b35ad 100644 --- a/traigent_schema/schemas/observability/evaluator_backfill_result_schema.json +++ b/traigent_schema/schemas/observability/evaluator_backfill_result_schema.json @@ -21,6 +21,16 @@ "type": "array", "items": { "type": "string" } }, + "skipped_reasons": { + "type": "object", + "description": "Skip reason per skipped target id (target_id -> reason).", + "additionalProperties": { "type": "string" } + }, + "skipped_reason_counts": { + "type": "object", + "description": "Number of skipped targets per skip reason (reason -> count).", + "additionalProperties": { "type": "integer", "minimum": 1 } + }, "items": { "type": "array", "items": { "$ref": "./evaluator_run_schema.json" } diff --git a/traigent_schema/schemas/observability/evaluator_execute_request_schema.json b/traigent_schema/schemas/observability/evaluator_execute_request_schema.json index e87c0a19..ea109f53 100644 --- a/traigent_schema/schemas/observability/evaluator_execute_request_schema.json +++ b/traigent_schema/schemas/observability/evaluator_execute_request_schema.json @@ -3,7 +3,7 @@ "$id": "https://schemas.traigent.ai/observability/evaluator_execute_request_schema.json", "title": "Evaluator Execute Request Schema", "type": "object", - "additionalProperties": true, + "additionalProperties": false, "properties": { "target_type": { "type": "string", @@ -19,10 +19,6 @@ "minLength": 1, "maxLength": 128 }, - "source": { - "type": "string", - "maxLength": 5000 - }, "override_judge_config": { "oneOf": [ { diff --git a/traigent_schema/schemas/observability/evaluator_update_request_schema.json b/traigent_schema/schemas/observability/evaluator_update_request_schema.json index 6f14b957..336ef45d 100644 --- a/traigent_schema/schemas/observability/evaluator_update_request_schema.json +++ b/traigent_schema/schemas/observability/evaluator_update_request_schema.json @@ -3,7 +3,8 @@ "$id": "https://schemas.traigent.ai/observability/evaluator_update_request_schema.json", "title": "Evaluator Update Request Schema", "type": "object", - "additionalProperties": true, + "additionalProperties": false, + "minProperties": 1, "properties": { "name": { "type": "string", @@ -22,10 +23,18 @@ "minLength": 1, "maxLength": 100 }, - "primary_measure_id": { - "type": "string", - "minLength": 1, - "maxLength": 128 + "target_type": { + "type": [ + "string", + "null" + ], + "enum": [ + "observability_trace", + "observability_observation", + "configuration_run", + "experiment_run", + null + ] }, "judge_config": { "$ref": "./evaluator_definition_schema.json#/definitions/JudgeConfig" @@ -41,5 +50,64 @@ "is_active": { "type": "boolean" } - } + }, + "anyOf": [ + { + "required": [ + "name" + ] + }, + { + "required": [ + "measure_id" + ] + }, + { + "required": [ + "target_type" + ], + "properties": { + "target_type": { + "type": "string", + "enum": [ + "observability_trace", + "observability_observation", + "configuration_run", + "experiment_run" + ] + } + } + }, + { + "required": [ + "judge_config" + ] + }, + { + "required": [ + "sampling_rate" + ] + }, + { + "required": [ + "target_filters" + ] + }, + { + "required": [ + "is_active" + ] + }, + { + "required": [ + "description" + ], + "properties": { + "description": { + "type": "string", + "maxLength": 5000 + } + } + } + ] } diff --git a/traigent_schema/schemas/observability/observability_endpoints.json b/traigent_schema/schemas/observability/observability_endpoints.json index 4f188253..58cfcd0c 100644 --- a/traigent_schema/schemas/observability/observability_endpoints.json +++ b/traigent_schema/schemas/observability/observability_endpoints.json @@ -2111,19 +2111,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "additionalProperties": true, - "properties": { - "target_ids": { - "type": "array", - "items": { - "type": "string" - } - }, - "force": { - "type": "boolean" - } - } + "$ref": "./evaluator_backfill_request_schema.json" } } } diff --git a/traigent_schema/schemas/optimization/optimization_endpoints.json b/traigent_schema/schemas/optimization/optimization_endpoints.json index 959e92ef..5dc7f06a 100644 --- a/traigent_schema/schemas/optimization/optimization_endpoints.json +++ b/traigent_schema/schemas/optimization/optimization_endpoints.json @@ -1278,6 +1278,20 @@ "x-content-class": "closed_enum", "type": "boolean" }, + "optimization_outcome": { + "x-content-class": "closed_enum", + "type": [ + "string", + "null" + ], + "enum": [ + "completed", + "failed", + "cancelled", + null + ], + "description": "OPTIONAL terminal outcome of the optimization. Sets the status of the run, its experiment and the session; absent means completed. A replay cannot change a recorded outcome." + }, "metadata": { "x-content-key-class": "legacy_content", "x-content-class": "legacy_content", diff --git a/traigent_schema/schemas/optimization/promotion_policy_schema.json b/traigent_schema/schemas/optimization/promotion_policy_schema.json index 60afd94f..a9dec699 100644 --- a/traigent_schema/schemas/optimization/promotion_policy_schema.json +++ b/traigent_schema/schemas/optimization/promotion_policy_schema.json @@ -3,7 +3,7 @@ "type": "object", "title": "Promotion Policy Schema", "description": "Defines the promotion policy for epsilon-Pareto selection of optimal configurations.", - "version": "0.10.0", + "version": "0.11.0", "definitions": { "ChanceConstraint": { "type": "object", @@ -18,20 +18,22 @@ "x-content-class": "legacy_content", "x-content-note": "INV S1-23 (LEAK): name", "type": "string", - "description": "Name of the metric this constraint applies to", + "description": "Name of the violation event this constraint bounds", "pattern": "^[a-zA-Z_][a-zA-Z0-9_.-]*$" }, "threshold": { "x-content-class": "number", "type": "number", - "description": "Minimum acceptable metric value" + "description": "Maximum acceptable violation rate (0 to 1): the constraint passes when the upper confidence bound on the share of violating trials is at or below this value", + "minimum": 0, + "maximum": 1 }, "confidence": { "x-content-class": "number", "type": "number", - "description": "Required probability of meeting the threshold (0 to 1)", - "minimum": 0, - "maximum": 1 + "description": "Required probability of meeting the threshold (0 to 1, exclusive)", + "exclusiveMinimum": 0, + "exclusiveMaximum": 1 } }, "additionalProperties": false @@ -51,8 +53,8 @@ "x-content-class": "number", "type": "number", "description": "Significance level for statistical tests", - "minimum": 0, - "maximum": 1, + "exclusiveMinimum": 0, + "exclusiveMaximum": 1, "default": 0.05 }, "min_effect": { @@ -63,7 +65,8 @@ "patternProperties": { "^[a-zA-Z_][a-zA-Z0-9_.-]*$": { "x-content-class": "number", - "type": "number" + "type": "number", + "minimum": 0 } }, "additionalProperties": false diff --git a/traigent_schema/schemas/prompts/prompt_create_request_schema.json b/traigent_schema/schemas/prompts/prompt_create_request_schema.json index cb02a58d..2f3e1750 100644 --- a/traigent_schema/schemas/prompts/prompt_create_request_schema.json +++ b/traigent_schema/schemas/prompts/prompt_create_request_schema.json @@ -31,7 +31,7 @@ "null" ], "minLength": 1, - "maxLength": 50000 + "maxLength": 10000 }, "chat_messages": { "type": [ diff --git a/traigent_schema/schemas/prompts/prompt_playground_request_schema.json b/traigent_schema/schemas/prompts/prompt_playground_request_schema.json index 03ceb3f8..be6839af 100644 --- a/traigent_schema/schemas/prompts/prompt_playground_request_schema.json +++ b/traigent_schema/schemas/prompts/prompt_playground_request_schema.json @@ -26,7 +26,7 @@ "null" ], "minLength": 1, - "maxLength": 50000 + "maxLength": 10000 }, "chat_messages": { "type": [ diff --git a/traigent_schema/schemas/prompts/prompt_version_create_request_schema.json b/traigent_schema/schemas/prompts/prompt_version_create_request_schema.json index 55a850db..277ee1f8 100644 --- a/traigent_schema/schemas/prompts/prompt_version_create_request_schema.json +++ b/traigent_schema/schemas/prompts/prompt_version_create_request_schema.json @@ -11,7 +11,7 @@ "null" ], "minLength": 1, - "maxLength": 50000 + "maxLength": 10000 }, "chat_messages": { "type": [