Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/release-candidates.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Release candidate API contract.** Clients can report a promotion gate verdict and its digests for an agent's best-config version. The portal can list and read those records to prefill a person's release acceptance. The agent detail response (`GET /api/v1/projects/{project_id}/agents/{agent_ref}`, 200 `data`) gains an optional `agent_ref`: the server-issued release reference (`AgentRef`, `opaque_ref`) that the release-acceptance and release routes take in their `{agent_ref}` segment. It is defined by the new `agents/agent_detail_schema.json`, which references each property of `agent_schema.json` by pointer, so the shared `agent_schema.json` and the other endpoints that use it are unchanged. The release-family `agent_ref` path parameters now name where a portal reads the reference.
17 changes: 17 additions & 0 deletions docs/content-class-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1090,11 +1090,28 @@
"optimization/release_acceptance_schema.json#/definitions/ReleaseRefusal/properties/error_code": "closed_enum",
"optimization/release_acceptance_schema.json#/definitions/ReleaseRefusal/properties/message": "closed_enum",
"optimization/release_acceptance_schema.json#/definitions/ReleaseRefusal/properties/success": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidate/properties/recorded_by_kind": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidate/properties/state": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateConflict/properties/error": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateConflict/properties/error_code": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateConflict/properties/message": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateConflict/properties/success": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateListResponse/properties/success": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateNotFound/allOf/1/properties/error_code": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateRateLimited/properties/details/properties/scope": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateRateLimited/properties/message": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateRef": "opaque_ref",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateRequest/properties/gate_verdict": "closed_enum",
"optimization/release_candidate_schema.json#/definitions/ReleaseCandidateResponse/properties/success": "closed_enum",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1best-config-head~1release/post/parameters/0/schema": "key_material",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1best-config-head~1rollback/post/parameters/0/schema": "key_material",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-acceptances/get/parameters/0/schema": "key_material",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-acceptances/get/parameters/3/schema": "number",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-acceptances/post/parameters/0/schema": "key_material",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-candidates/get/parameters/0/schema": "key_material",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-candidates/get/parameters/3/schema": "number",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-candidates/post/parameters/0/schema": "key_material",
"optimization/release_endpoints.json#/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}~1release-candidates~1{candidate_ref}/get/parameters/0/schema": "key_material",
"optimization/semantic_saturation_schema.json#/definitions/ContinuousObjectiveDiagnostic/properties/best": "number",
"optimization/semantic_saturation_schema.json#/definitions/ContinuousObjectiveDiagnostic/properties/direction": "closed_enum",
"optimization/semantic_saturation_schema.json#/definitions/ContinuousObjectiveDiagnostic/properties/improvement": "number",
Expand Down
4 changes: 2 additions & 2 deletions parity/python-js-sdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@
"sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket."
},
"schemaRefresh": {
"lastSchemaFileSha": "f23916e05f64abe2a9b03a30d2dfff3d70aad200fe03af0b29587b569f947e97",
"schemaFileCount": 677,
"lastSchemaFileSha": "9b313249074bfa5a752162a8c4a59063172fff8018b6635ed73ef22fc7727533",
"schemaFileCount": 679,
"note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block."
}
}
6 changes: 3 additions & 3 deletions reports/schema_reachability/unreachable_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"reachableByRule": {
"allowlist": 0,
"consumerReference": 33,
"refOrEndpointGraph": 581
"refOrEndpointGraph": 583
},
"reachableCount": 614,
"schemaFileCount": 677,
"reachableCount": 616,
"schemaFileCount": 679,
"unreachableCount": 63
},
"unreachableSchemas": [
Expand Down
17 changes: 17 additions & 0 deletions scripts/breaking_schema_allowlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -11256,6 +11256,23 @@
"version": "8.0.0",
"pr": "https://github.com/Traigent/TraigentSchema/pull/762"
},
{
"file": "agents/agents_endpoints.json",
"rule": "property_added",
"findings": [
{
"pointer": "#/paths//api/v1/projects/{project_id}/agents/{agent_ref}/get/responses/200/content/application/json/schema/properties/data/properties/agent_ref",
"role": "response",
"subject": "agent_ref",
"old": false,
"new": true,
"fingerprint": "0881379da9343ea95786055c3b4890a125dba49106e1727bee3d062934422848"
}
],
"reason": "additive optional response field on the agent detail read: the server-issued release reference a portal needs to call the release routes. Payloads valid under the previous schema still validate. A client that validates responses against the previous closed schema can reject a response once the field is emitted; the Python SDK and the JS SDK do not read or validate the agent detail response.",
"version": "Unreleased",
"pr": "pending (TraigentSchema, feat/release-candidates)"
},
{
"file": "execution/execution_endpoints.json",
"rule": "endpoint_removed",
Expand Down
1 change: 1 addition & 0 deletions scripts/content_class_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"^[0-9a-f]{32}(?![\\s\\S])", # per-request problem id (uuid4 hex) of a closed problem body
# server-minted project id: random, tenant-derived default or personal-workspace form
PROJECT_ID_PATTERN,
"^release_candidate_[0-9a-f]{32}$", # server-minted release-candidate ref (bounded to 50 by the schema)
# Fleet Observe: the signed pagination cursor (see CURSOR_PATTERN: accepted only at
# CURSOR_LOCATIONS, checked in _check_cursor_site) and the 16-hex id of the customer-held
# digest key (derived by HMAC, so it carries no text).
Expand Down
112 changes: 112 additions & 0 deletions tests/test_agent_detail_agent_ref_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""Contract for the optional agent_ref on the agent detail response.

GET /api/v1/projects/{project_id}/agents/{agent_ref} returns the success envelope; its
``data`` is ``agent_detail_schema.json``: the shared agent schema plus the optional
server-issued ``agent_ref``. The shared ``agent_schema.json`` must stay unchanged.
"""

from __future__ import annotations

import json
from typing import Any

import jsonschema
from referencing import Registry, Resource
from referencing.jsonschema import DRAFT7

from traigent_schema.utils import get_schemas_dir

S = get_schemas_dir()
AGENTS = S / "agents"
VALID_REF = "agentref_" + "0" * 32
PLAIN_AGENT_ID = "agent_9f2c4e1a"


def _load(path):
return json.loads(path.read_text(encoding="utf-8"))


def _registry() -> Registry:
registry = Registry()
for path in S.rglob("*.json"):
doc = json.loads(path.read_text(encoding="utf-8"))
uri = "https://schemas.traigent.ai/" + path.relative_to(S).as_posix()
registry = registry.with_resource(uri, Resource.from_contents(doc, default_specification=DRAFT7))
return registry


def _validator(schema: dict[str, Any]) -> jsonschema.Draft7Validator:
return jsonschema.Draft7Validator(schema, registry=_registry())


DETAIL = _validator(_load(AGENTS / "agent_detail_schema.json"))


def _agent(**extra: Any) -> dict[str, Any]:
body: dict[str, Any] = {"id": PLAIN_AGENT_ID, "name": "Support bot", "agent_type": "chat"}
body.update(extra)
return body


def _errors(validator, body):
return list(validator.iter_errors(body))


def test_detail_accepts_a_valid_server_issued_reference():
assert not _errors(DETAIL, _agent(agent_ref=VALID_REF))


def test_detail_rejects_a_plain_agent_id_in_the_reference_slot():
assert _errors(DETAIL, _agent(agent_ref=PLAIN_AGENT_ID))


def test_detail_rejects_a_reference_with_uppercase_hex():
assert _errors(DETAIL, _agent(agent_ref="agentref_" + "A" * 32))


def test_detail_allows_absence_of_agent_ref():
assert "agent_ref" not in _load(AGENTS / "agent_detail_schema.json").get("required", [])
assert not _errors(DETAIL, _agent())


def test_detail_stays_closed_to_unknown_keys():
assert _errors(DETAIL, _agent(agent_id=PLAIN_AGENT_ID))


def test_detail_agent_ref_is_the_shared_opaque_reference_definition():
prop = _load(AGENTS / "agent_detail_schema.json")["properties"]["agent_ref"]
assert "$ref" not in prop
assert prop["allOf"] == [{"$ref": "../labels/label_common_schema.json#/definitions/AgentRef"}]
assert prop["x-content-class"] == "opaque_ref"
assert prop["description"] == (
"Server-issued release reference of this agent (an `agentref_` digest), scoped to the "
"tenant and project and derived one-way from the agent id. It is not the agent id used in "
"this request's path: the release-acceptance and release routes take this reference in "
"their `{agent_ref}` path segment."
)


def test_detail_property_set_tracks_shared_agent_schema_plus_agent_ref():
shared = set(_load(AGENTS / "agent_schema.json")["properties"])
detail = set(_load(AGENTS / "agent_detail_schema.json")["properties"])
assert detail == shared | {"agent_ref"}


def test_shared_agent_schema_is_unchanged_and_still_rejects_agent_ref():
shared = _load(AGENTS / "agent_schema.json")
assert "agent_ref" not in shared["properties"]
assert shared["additionalProperties"] is False
assert _errors(_validator(shared), _agent(agent_ref=VALID_REF))


def test_get_agent_200_data_is_wired_to_the_detail_schema():
get_200_pointer = (
"/paths/~1api~1v1~1projects~1{project_id}~1agents~1{agent_ref}"
"/get/responses/200/content/application~1json/schema"
)
envelope_ref = {"$ref": "https://schemas.traigent.ai/agents/agents_endpoints.json#" + get_200_pointer}
envelope = _validator(envelope_ref)
ok = {"success": True, "message": "ok", "data": _agent(agent_ref=VALID_REF)}
assert not _errors(envelope, ok)
assert _errors(envelope, {"success": True, "message": "ok", "data": _agent(agent_ref=PLAIN_AGENT_ID)})
assert not _errors(envelope, {"success": True, "message": "ok", "data": _agent()})
3 changes: 3 additions & 0 deletions tests/test_release_acceptance_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def test_routes_are_registered_with_operation_ids_and_closed_bodies():
assert ops == {
(base + "/release-acceptances", "post"): "best_configs.create_release_acceptance",
(base + "/release-acceptances", "get"): "best_configs.list_release_acceptances",
(base + "/release-candidates", "post"): "best_configs.create_release_candidate",
(base + "/release-candidates", "get"): "best_configs.list_release_candidates",
(base + "/release-candidates/{candidate_ref}", "get"): "best_configs.get_release_candidate",
(base + "/best-config-head/release", "post"): "best_configs.release_agent_head",
(base + "/best-config-head/rollback", "post"): "best_configs.rollback_agent_head",
}
Expand Down
Loading
Loading