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: 0 additions & 1 deletion changelog.d/compliance-evidence-contracts.breaking.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- **A `not_applicable` applicability decision requires a rationale.** `DecisionInput` gains an if/then: when `decision` is `not_applicable`, `rationale` is required and must hold at least one character that is not whitespace, a control character or a zero-width/format character (the 2000-character cap is unchanged). `applicable` and `unresolved` keep it optional, and a `carry: true` item is not re-validated. The Backend refuses the violation with a closed 400 `rationale_required` (new closed body `RationaleRequiredError`, declared beside the shared error envelope on the write's 400, acknowledged in `scripts/breaking_schema_allowlist.json`).
- **Compliance attestation signing is bound to the reviewed subject.** `AttestationCreateRequest` gains a REQUIRED `review_context` (64 lowercase hex): the opaque, server-issued, keyed freshness token the signer read from the evidence response (new `Ingredient.review_context`, required on `A` rows as a string or null, absent on other kinds). A stale value is refused with 409 `stale_review_context` and nothing is recorded; the sign operation also declares a 503 for when the server cannot issue or verify the token. The token is never derived from customer text and is not evidence: never store, log or export it. Acknowledged in `scripts/breaking_schema_allowlist.json`.
- **Compliance document references: search by link substring (additive; contract only).** New operation `POST /api/v1/projects/{project_id}/agents/{agent_ref}/compliance-document-refs/search` (`project_compliance_document_refs.search_compliance_document_references`, `x-replay: read`) and closed request `DocumentReferenceSearchRequest` (`q` 1 to 200 characters after trimming, optional `include_withdrawn`, `page`, `per_page`). It is a read served as POST so the search text, which is customer content, stays out of URLs, logs and traces; it matches case-insensitively, as a literal substring, against the declared link and answers the existing `DocumentReferenceListResponse` with the list's ordering and paging. Pinned by `tests/test_compliance_document_ref_contract.py`.
1 change: 1 addition & 0 deletions changelog.d/compliance-review-context-optional.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Compliance freshness tokens are optional until the server issues and checks them: `Ingredient.review_context` may be present on `A` rows and `AttestationCreateRequest.review_context` may be omitted; the closed rules for kinds M, D and L are unchanged.
2 changes: 1 addition & 1 deletion parity/python-js-sdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
"sdk032Surface": "Manifest Python pin advanced from d56e4353 to 6e8e4a54 (origin/develop, the SDK 0.32.0 release candidate) to cover two root exports the js-public-parity gate flagged unclassified on Traigent/Traigent#2861. requirement (traigent.runtime.decorator) is the runtime latency requirement decorator; traigent-js origin/main and origin/develop both export requirement from src/runtime/index.ts and list it in tests/integration/fixtures/api-surface.snapshot.json, so it is classified matched and added to requiredRootExports next to require. SnapshotBindingError (traigent.utils.exceptions) is the typed error of the Python opt-in snapshot store (S0 before dispatch, S1 from the terminal result, online G1); traigent-js has no snapshot store and no export of it (zero occurrences in src or its api-surface snapshot), so it is classified deferred-backlog, Python-only for now with no open JS design and no ticket. Owner may re-bucket."
},
"schemaRefresh": {
"lastSchemaFileSha": "b67ecd143e25de91c4347af09316c5c178e0fb24f0f3943ffe16033fb9601d9c",
"lastSchemaFileSha": "52d2225ee443c2d4d5c3fdc6456503157815834929211813e1e27b4d65153a0b",
"schemaFileCount": 692,
"note": "Auto-stamped by scripts/refresh_parity.py. Do not hand-edit this block."
}
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 @@ -12039,6 +12039,23 @@
"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": "agent_readiness/compliance_evidence_response_schema.json",
"rule": "allOf_branch_count_changed",
"findings": [
{
"pointer": "#/properties/ingredients/items/allOf",
"role": "response",
"subject": "allOf",
"old": 2,
"new": 1,
"fingerprint": "9ffc86621dadac8da734bd4e02ebee79dcaeec95861a11c317bd6670d5fc202c"
}
],
"reason": "Freshness tokens become optional until the server issues and checks them; the closed rules for kinds M, D and L are unchanged; readers treat an absent value like null.",
"version": "Unreleased pending (TraigentSchema, review_context optional)",
"pr": "pending (TraigentSchema, not yet opened)"
}
]
}
7 changes: 6 additions & 1 deletion tests/test_compliance_attestation_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ def test_schema_is_valid_draft7_and_discoverable() -> None:
Draft7Validator.check_schema(_SCHEMA)


def test_review_context_is_optional_on_the_sign_request() -> None:
request = _request()
request.pop("review_context")
assert _errors("AttestationCreateRequest", request) == []


def test_schema_is_closed_everywhere() -> None:
_walk_closed(_SCHEMA)
_walk_closed(load_json(ENDPOINTS_PATH)["paths"])
Expand Down Expand Up @@ -152,7 +158,6 @@ def test_valid_examples_conform(definition: str, factory: Any) -> None:
("definition", "factory", "mutate"),
[
# Server-derived fields are never accepted from the client.
("AttestationCreateRequest", _request, lambda r: r.pop("review_context")),
("AttestationCreateRequest", _request, lambda r: r.update(review_context=None)),
("AttestationCreateRequest", _request, lambda r: r.update(review_context="C" * 64)),
("AttestationCreateRequest", _request, lambda r: r.update(review_context="c" * 63)),
Expand Down
16 changes: 15 additions & 1 deletion tests/test_compliance_evidence_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def test_valid_populated_and_empty_packs() -> None:
lambda r: r["ingredients"][0].update(group="Legal"),
lambda r: r["ingredients"][0].update(producer_ref="free text"),
lambda r: r["ingredients"][0].update(note="customer text"),
lambda r: r["ingredients"][1].pop("review_context"), # required on A rows
lambda r: r["ingredients"][1].update(review_context="B" * 64),
lambda r: r["ingredients"][1].update(review_context="b" * 63),
lambda r: r["ingredients"][0].update(review_context="b" * 64), # absent on non-A rows
Expand Down Expand Up @@ -336,6 +335,21 @@ def test_coverage_ingredient_ids_over_cap_is_rejected_shape_only() -> None:
assert _errors(_with_ids(**{**_ALL_EMPTY, "supported": unique})) != []


@pytest.mark.parametrize("kind", ["M", "D", "L"])
def test_review_context_is_refused_on_non_attestation_rows(kind: str) -> None:
instance = copy.deepcopy(_response())
instance["ingredients"][0]["kind"] = kind
assert _errors(instance) == []
instance["ingredients"][0]["review_context"] = "b" * 64
assert _errors(instance) != []


def test_review_context_is_optional_on_attestation_rows() -> None:
instance = copy.deepcopy(_response())
instance["ingredients"][1].pop("review_context")
assert _errors(instance) == []


def test_review_context_is_a_digest_or_null_on_attestation_rows() -> None:
instance = copy.deepcopy(_response())
assert _errors(instance) == []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
}
},
"409": {
"description": "Conflict",
"description": "Conflict (stale_review_context applies when the server checks freshness tokens)",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -511,7 +511,7 @@
}
},
"503": {
"description": "The server cannot issue or verify the review context right now; nothing is recorded",
"description": "When the server checks freshness tokens and its key is unavailable: the server cannot issue or verify the review context right now; nothing is recorded",
"content": {
"application/json": {
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@
"ingredient_id",
"statement_digest",
"outcome",
"review_period_days",
"review_context"
"review_period_days"
],
"properties": {
"agent_id": {
Expand All @@ -346,7 +345,7 @@
"review_context": {
"type": "string",
"pattern": "^[0-9a-f]{64}$",
"description": "Echo the review_context of the evidence read the signer reviewed. A stale value is refused with 409 stale_review_context and nothing is recorded. Opaque, server-issued and never derived from customer text."
"description": "Send back only a string token read from the evidence view; omit the field when the row has none or null. When the server checks freshness tokens, it refuses a stale value with 409 stale_review_context. Opaque and server-issued."
},
"outcome": {
"$ref": "#/definitions/Outcome"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,10 @@
"review_context": {
"type": ["string", "null"],
"pattern": "^[0-9a-f]{64}$",
"description": "Present on an `A` ingredient only (a string, or null when the agent configuration or the statement cannot be resolved, or the server has no key to issue it). An opaque, server-issued freshness token, keyed and never derived from customer text. A signer echoes it unchanged in AttestationCreateRequest.review_context; the server refuses a stale value with 409 stale_review_context. It is not evidence: never store, log or export it."
"description": "Present on an `A` ingredient when the server issues freshness tokens; absent or null otherwise (readers treat both alike). When the server checks freshness tokens, a stale value sent back on signing is refused with 409 stale_review_context. An opaque, server-issued, keyed token, never derived from free text. It is not evidence: never store, log or export it."
}
},
"allOf": [
{
"if": { "properties": { "kind": { "const": "A" } }, "required": ["kind"] },
"then": { "required": ["review_context"] }
},
{
"if": { "properties": { "kind": { "enum": ["M", "D", "L"] } }, "required": ["kind"] },
"then": { "not": { "required": ["review_context"] } }
Expand Down
Loading