hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

commit 0b253f5787748b53cd96928299bbf0e986813ce8
parent fc82fae7ec3930b80ed7b7b318a5676206d49542
Author: triesap <tyson@radroots.org>
Date:   Mon, 26 Oct 2026 20:53:47 +0000

hyf: add version three advisory operation contracts

- Select the exact Jev model in versioned participant contexts
- Mirror shared quantity, money, identity and time representations
- Keep all three operations guarded before business activation
- Verify strict contexts and preserve historical rejection behavior

Diffstat:
Aschemas/hyf_ops_v3/README.md | 48++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/buyer_request_interpret.request.schema.json | 172+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/buyer_request_interpret.response.schema.json | 250+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/buyer_request_match.request.schema.json | 431+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/buyer_request_match.response.schema.json | 305++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/common.schema.json | 3981+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/domain_manifest.json | 322+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/examples/buyer_request_interpret.error.json | 9+++++++++
Aschemas/hyf_ops_v3/examples/buyer_request_interpret.request.json | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/examples/buyer_request_interpret.response.json | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/examples/buyer_request_match.error.json | 9+++++++++
Aschemas/hyf_ops_v3/examples/buyer_request_match.request.json | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/examples/buyer_request_match.response.json | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/examples/farm_update_interpret.error.json | 9+++++++++
Aschemas/hyf_ops_v3/examples/farm_update_interpret.request.json | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/examples/farm_update_interpret.response.json | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/farm_update_interpret.request.schema.json | 211+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/farm_update_interpret.response.schema.json | 386+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/manifest.json | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/reference/currency_registry_v1.csv | 171+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/reference/currency_registry_v1.license | 201+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aschemas/hyf_ops_v3/reference/currency_registry_v1.notice | 23+++++++++++++++++++++++
Aschemas/hyf_ops_v3/version_manifest.json | 14++++++++++++++
Msrc/hyf_core/operation_context.mojo | 159++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Msrc/hyf_stdio/envelope.mojo | 10++++++----
Msrc/hyf_stdio/server.mojo | 2+-
Mtests/test_hyf.mojo | 171+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27 files changed, 7376 insertions(+), 23 deletions(-)

diff --git a/schemas/hyf_ops_v3/README.md b/schemas/hyf_ops_v3/README.md @@ -0,0 +1,48 @@ +# Operation contract v3 + +`context.versions.schema = "hyf_ops_v3"` selects the current contract for +`farm_update.interpret`, `buyer_request.interpret` and `buyer_request.match`. +The envelope remains version 1. These operations are **not activated**: the +daemon validates the versioned context and returns `capability_unavailable` +before legacy dispatch or provider execution. Full input/response schema and +semantic enforcement must be completed before activation. Schema examples and +reference checks do not establish that runtime enforcement. + +V2 remains only as historical pre-activation parser/rejection characterization. +Its farm context, scaled money and model identifiers do not define v3. The +unversioned operation journeys must be characterized and cut over explicitly +before activation; they cannot become a second active business engine. + +Public shared SDK wire values are mirrored exactly: + +- Quantity is `{amount, unit}`. Amount is a canonical nonnegative decimal + string with coefficient at most 999999999999 and scale at most 6. Units are + `g`, `kg`, `mL`, `L` and integral `each`. Unknown quantity is an explicit + alternative; it is never encoded as zero. Approximation remains explicit. +- Money is `{currency, minor, exponent}`. Minor amount is a canonical integer + string at most 999999999999999; currency and exponent must match the pinned + public registry. Registry data includes its Apache license and attribution. + No conversion, price basis, fee, tax or exchange rate is inferred. +- Evaluation, source and ingestion timestamps use the shared `UnixSeconds` + representation: unsigned canonical ASCII strings from 0 to 253402300799. + RFC3339 is not an alternative v3 encoding. Relative language, source recency + and timezone interpretation remain shared SDK/host responsibilities. + +Actor and workspace fields are descriptors. Parsing them does not authenticate +a participant or create an SDK `CommandContext`. The native host retains its +authenticated context and revalidates current scope, revisions and business +preconditions before any later use. A farm/organization association is optional; +buyer requests never need a private stock pool identifier. + +Matching consumes authorized SDK projections and returns bounded suggestions +with explicit uncertainty, coverage and `commitment: "none"`. It owns no stock +allocation, reservation, order, permission or signing action. A source message +or model score cannot override an SDK failure. Consulted-record provenance must +be based on actual use, independently of whether a suggestion was produced. +Source evidence uses UTF-8 byte offsets and exact revisions. + +The model axis is exact `jev-1.14.0`. Account/model availability and actual +returned identity require separate live qualification. Zero provider calls +requires null execution model and question bundle; manifest strings alone do +not prove model use. Existing frame, depth, provider, deadline, attempt and +cleanup limits remain binding as recorded in `manifest.json`. diff --git a/schemas/hyf_ops_v3/buyer_request_interpret.request.schema.json b/schemas/hyf_ops_v3/buyer_request_interpret.request.schema.json @@ -0,0 +1,172 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "integer", + "const": 1 + }, + "request_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "trace_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "capability": { + "const": "buyer_request.interpret" + }, + "context": { + "$ref": "common.schema.json#/$defs/context" + }, + "input": { + "type": "object", + "properties": { + "source": { + "$ref": "common.schema.json#/$defs/source" + }, + "references": { + "type": "object", + "properties": { + "taxonomy": { + "type": "object", + "properties": { + "version": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "provenance": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "products": { + "type": "array", + "items": { + "type": "object", + "properties": { + "catalogue_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "terms": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "maxItems": 128 + } + }, + "required": [ + "catalogue_id", + "terms" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "version", + "provenance", + "products" + ], + "additionalProperties": false + }, + "normalization": { + "type": "object", + "properties": { + "version": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "provenance": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "currency_registry": { + "const": "radroots.currency_registry.v1" + } + }, + "required": [ + "version", + "provenance", + "currency_registry" + ], + "additionalProperties": false + } + }, + "required": [ + "taxonomy", + "normalization" + ], + "additionalProperties": false + }, + "clarification": { + "type": "object", + "properties": { + "source_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "target_field": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "text": { + "type": "string", + "minLength": 1, + "pattern": "\\S", + "maxLength": 1048576 + }, + "expected_revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "source_id", + "revision", + "target_field", + "text", + "expected_revision" + ], + "additionalProperties": false + } + }, + "required": [ + "source", + "references" + ], + "additionalProperties": false + } + }, + "required": [ + "version", + "request_id", + "capability", + "context", + "input" + ], + "additionalProperties": false, + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/buyer_request_interpret.request.schema.json", + "$comment": "D57 hyf_ops_v3 pre-activation contract. No business write or trusted context can be minted by source/model text. Full semantic input-use and SDK revalidation remain required." +} diff --git a/schemas/hyf_ops_v3/buyer_request_interpret.response.schema.json b/schemas/hyf_ops_v3/buyer_request_interpret.response.schema.json @@ -0,0 +1,250 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "integer", + "const": 1 + }, + "request_id": { + "type": "string" + }, + "trace_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "ok": { + "type": "boolean" + }, + "output": { + "type": "object", + "properties": { + "versions": { + "$ref": "common.schema.json#/$defs/versions" + }, + "provenance": { + "type": "object", + "properties": { + "source": { + "$ref": "common.schema.json#/$defs/identity" + }, + "clarification": { + "anyOf": [ + { + "$ref": "common.schema.json#/$defs/identity" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "source", + "clarification" + ], + "additionalProperties": false + }, + "review": { + "$ref": "common.schema.json#/$defs/review" + }, + "execution": { + "$ref": "common.schema.json#/$defs/execution" + }, + "demand_lines": { + "type": "array", + "items": { + "type": "object", + "properties": { + "line_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "product": { + "$ref": "common.schema.json#/$defs/product_ref" + }, + "quantity": { + "$ref": "common.schema.json#/$defs/reported_quantity" + }, + "conditions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "fulfillment", + "window", + "grade", + "price", + "attribute", + "substitution" + ] + }, + "strength": { + "type": "string", + "enum": [ + "mandatory", + "preferred", + "excluded", + "permitted" + ] + }, + "value": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + { + "type": "null" + } + ] + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + } + }, + "required": [ + "kind", + "strength", + "value", + "evidence" + ], + "additionalProperties": false + }, + "maxItems": 128 + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + }, + "review_required": { + "type": "boolean" + } + }, + "required": [ + "line_id", + "product", + "quantity", + "conditions", + "evidence", + "review_required" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "versions", + "provenance", + "review", + "execution", + "demand_lines" + ], + "additionalProperties": false + }, + "error": { + "type": "object", + "properties": { + "code": { + "type": "string", + "enum": [ + "invalid_request", + "unsupported_capability", + "capability_disabled", + "capability_unavailable", + "internal_error" + ] + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "additionalProperties": false + }, + "meta": { + "type": "object", + "properties": { + "schema_version": { + "type": "integer", + "const": 1 + } + }, + "required": [ + "schema_version" + ], + "additionalProperties": false + } + }, + "required": [ + "version", + "request_id", + "ok" + ], + "additionalProperties": false, + "oneOf": [ + { + "properties": { + "ok": { + "const": true + }, + "request_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "output" + ], + "not": { + "required": [ + "error" + ] + } + }, + { + "properties": { + "ok": { + "const": false + } + }, + "required": [ + "error" + ], + "not": { + "anyOf": [ + { + "required": [ + "output" + ] + }, + { + "required": [ + "meta" + ] + } + ] + } + } + ], + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/buyer_request_interpret.response.schema.json", + "$comment": "D57 hyf_ops_v3 pre-activation contract. No business write or trusted context can be minted by source/model text. Full semantic input-use and SDK revalidation remain required." +} diff --git a/schemas/hyf_ops_v3/buyer_request_match.request.schema.json b/schemas/hyf_ops_v3/buyer_request_match.request.schema.json @@ -0,0 +1,431 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "integer", + "const": 1 + }, + "request_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "trace_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "capability": { + "const": "buyer_request.match" + }, + "context": { + "$ref": "common.schema.json#/$defs/context" + }, + "input": { + "type": "object", + "properties": { + "need": { + "type": "object", + "properties": { + "need_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "participant_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "demand_lines": { + "type": "array", + "items": { + "type": "object", + "properties": { + "line_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "product": { + "$ref": "common.schema.json#/$defs/product_ref" + }, + "quantity": { + "$ref": "common.schema.json#/$defs/reported_quantity" + }, + "conditions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "fulfillment", + "window", + "grade", + "price", + "attribute", + "substitution" + ] + }, + "strength": { + "type": "string", + "enum": [ + "mandatory", + "preferred", + "excluded", + "permitted" + ] + }, + "value": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + { + "type": "null" + } + ] + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + } + }, + "required": [ + "kind", + "strength", + "value", + "evidence" + ], + "additionalProperties": false + }, + "maxItems": 128 + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + }, + "review_required": { + "type": "boolean" + } + }, + "required": [ + "line_id", + "product", + "quantity", + "conditions", + "evidence", + "review_required" + ], + "additionalProperties": false + }, + "maxItems": 128 + }, + "partial_fulfillment": { + "type": "boolean" + } + }, + "required": [ + "need_id", + "revision", + "participant_id", + "demand_lines", + "partial_fulfillment" + ], + "additionalProperties": false + }, + "candidates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "candidate_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "listing_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "participant_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "product": { + "$ref": "common.schema.json#/$defs/product_ref" + }, + "declared_quantity": { + "$ref": "common.schema.json#/$defs/reported_quantity" + }, + "price": { + "anyOf": [ + { + "$ref": "common.schema.json#/$defs/money" + }, + { + "type": "null" + } + ] + }, + "sdk_projection": { + "type": "object", + "properties": { + "projection_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "source_revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "feasibility": { + "type": "string", + "enum": [ + "pass", + "fail", + "unknown" + ] + }, + "checks": { + "type": "array", + "items": { + "type": "object", + "properties": { + "kind": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "result": { + "type": "string", + "enum": [ + "pass", + "fail", + "unknown" + ] + }, + "reason": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + } + }, + "required": [ + "kind", + "result", + "reason", + "evidence" + ], + "additionalProperties": false + }, + "maxItems": 128 + }, + "revalidate_before_use": { + "const": true + } + }, + "required": [ + "projection_id", + "source_revision", + "feasibility", + "checks", + "revalidate_before_use" + ], + "additionalProperties": false + } + }, + "required": [ + "candidate_id", + "listing_id", + "revision", + "participant_id", + "product", + "declared_quantity", + "price", + "sdk_projection" + ], + "additionalProperties": false + }, + "maxItems": 64 + }, + "coverage": { + "type": "object", + "properties": { + "scope": { + "const": "supplied_only" + }, + "truncated": { + "type": "boolean" + }, + "evaluated": { + "type": "array", + "items": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "maxItems": 128 + }, + "excluded": { + "type": "array", + "items": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "maxItems": 128 + } + }, + "required": [ + "scope", + "truncated", + "evaluated", + "excluded" + ], + "additionalProperties": false + }, + "references": { + "type": "object", + "properties": { + "taxonomy": { + "type": "object", + "properties": { + "version": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "provenance": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "products": { + "type": "array", + "items": { + "type": "object", + "properties": { + "catalogue_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "terms": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "maxItems": 128 + } + }, + "required": [ + "catalogue_id", + "terms" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "version", + "provenance", + "products" + ], + "additionalProperties": false + }, + "normalization": { + "type": "object", + "properties": { + "version": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "provenance": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "currency_registry": { + "const": "radroots.currency_registry.v1" + } + }, + "required": [ + "version", + "provenance", + "currency_registry" + ], + "additionalProperties": false + } + }, + "required": [ + "taxonomy", + "normalization" + ], + "additionalProperties": false + } + }, + "required": [ + "need", + "candidates", + "coverage", + "references" + ], + "additionalProperties": false + } + }, + "required": [ + "version", + "request_id", + "capability", + "context", + "input" + ], + "additionalProperties": false, + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/buyer_request_match.request.schema.json", + "$comment": "D57 hyf_ops_v3 pre-activation contract. No business write or trusted context can be minted by source/model text. Full semantic input-use and SDK revalidation remain required." +} diff --git a/schemas/hyf_ops_v3/buyer_request_match.response.schema.json b/schemas/hyf_ops_v3/buyer_request_match.response.schema.json @@ -0,0 +1,305 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "integer", + "const": 1 + }, + "request_id": { + "type": "string" + }, + "trace_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "ok": { + "type": "boolean" + }, + "output": { + "type": "object", + "properties": { + "versions": { + "$ref": "common.schema.json#/$defs/versions" + }, + "provenance": { + "type": "object", + "properties": { + "need": { + "type": "object", + "properties": { + "need_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "need_id", + "revision" + ], + "additionalProperties": false + }, + "candidates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "candidate_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "candidate_id", + "revision" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "need", + "candidates" + ], + "additionalProperties": false + }, + "suggestions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "candidate_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "preference": { + "type": "number", + "minimum": 0, + "maximum": 1 + }, + "checks": { + "type": "array", + "items": { + "type": "object", + "properties": { + "kind": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "result": { + "type": "string", + "enum": [ + "pass", + "fail", + "unknown" + ] + }, + "reason": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + } + }, + "required": [ + "kind", + "result", + "reason", + "evidence" + ], + "additionalProperties": false + }, + "maxItems": 128 + }, + "unresolved": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "maxItems": 128 + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + }, + "commitment": { + "const": "none" + } + }, + "required": [ + "candidate_id", + "preference", + "checks", + "unresolved", + "evidence", + "commitment" + ], + "additionalProperties": false + }, + "maxItems": 8 + }, + "limitations": { + "type": "object", + "properties": { + "scope": { + "const": "supplied_only" + }, + "truncated": { + "type": "boolean" + }, + "unsupported": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "maxItems": 128 + }, + "commitment": { + "const": "none" + } + }, + "required": [ + "scope", + "truncated", + "unsupported", + "commitment" + ], + "additionalProperties": false + }, + "execution": { + "$ref": "common.schema.json#/$defs/execution" + } + }, + "required": [ + "versions", + "provenance", + "suggestions", + "limitations", + "execution" + ], + "additionalProperties": false + }, + "error": { + "type": "object", + "properties": { + "code": { + "type": "string", + "enum": [ + "invalid_request", + "unsupported_capability", + "capability_disabled", + "capability_unavailable", + "internal_error" + ] + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "additionalProperties": false + }, + "meta": { + "type": "object", + "properties": { + "schema_version": { + "type": "integer", + "const": 1 + } + }, + "required": [ + "schema_version" + ], + "additionalProperties": false + } + }, + "required": [ + "version", + "request_id", + "ok" + ], + "additionalProperties": false, + "oneOf": [ + { + "properties": { + "ok": { + "const": true + }, + "request_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "output" + ], + "not": { + "required": [ + "error" + ] + } + }, + { + "properties": { + "ok": { + "const": false + } + }, + "required": [ + "error" + ], + "not": { + "anyOf": [ + { + "required": [ + "output" + ] + }, + { + "required": [ + "meta" + ] + } + ] + } + } + ], + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/buyer_request_match.response.schema.json", + "$comment": "D57 hyf_ops_v3 pre-activation contract. No business write or trusted context can be minted by source/model text. Full semantic input-use and SDK revalidation remain required." +} diff --git a/schemas/hyf_ops_v3/common.schema.json b/schemas/hyf_ops_v3/common.schema.json @@ -0,0 +1,3981 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/common.schema.json", + "$comment": "D57: advisory boundary only. ActorRef/identifiers are descriptors, not authentication. Quantity/Money are exact public SDK wire mirrors; SDK owns authoritative feasibility/arithmetic/conservation. Span offsets are UTF-8 bytes; semantic use/revision validation is mandatory.", + "$defs": { + "versions": { + "type": "object", + "properties": { + "schema": { + "const": "hyf_ops_v3" + }, + "taxonomy": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "normalization": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "review_policy": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "ranking_policy": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "question_bundle": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "model": { + "const": "jev-1.14.0" + } + }, + "required": [ + "schema", + "taxonomy", + "normalization", + "review_policy", + "ranking_policy", + "question_bundle", + "model" + ], + "additionalProperties": false + }, + "actor": { + "type": "object", + "properties": { + "participant": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "role": { + "type": "string", + "enum": [ + "seller", + "buyer", + "coordinator" + ] + }, + "organization": { + "anyOf": [ + { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + { + "type": "null" + } + ] + }, + "grant_id": { + "anyOf": [ + { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "participant", + "role", + "organization", + "grant_id" + ], + "additionalProperties": false + }, + "context": { + "type": "object", + "properties": { + "consumer": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "execution_mode_preference": { + "type": "string", + "enum": [ + "deterministic", + "assisted" + ] + }, + "deadline_ms": { + "type": "integer", + "minimum": 1, + "maximum": 2147483647 + }, + "evaluation_time": { + "$ref": "#/$defs/unix_seconds" + }, + "timezone": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "locale": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "versions": { + "$ref": "#/$defs/versions" + }, + "return_provenance": { + "type": "boolean" + }, + "actor": { + "$ref": "#/$defs/actor" + }, + "workspace_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + } + }, + "required": [ + "evaluation_time", + "versions", + "actor", + "workspace_id" + ], + "additionalProperties": false + }, + "source": { + "type": "object", + "properties": { + "source_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "text": { + "type": "string", + "minLength": 1, + "pattern": "\\S", + "maxLength": 1048576 + }, + "source_time": { + "$ref": "#/$defs/unix_seconds" + }, + "timezone": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "locale": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "participant_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "ingestion_time": { + "$ref": "#/$defs/unix_seconds" + } + }, + "required": [ + "source_id", + "revision", + "text", + "source_time", + "participant_id" + ], + "additionalProperties": false + }, + "identity": { + "type": "object", + "properties": { + "source_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "source_id", + "revision" + ], + "additionalProperties": false + }, + "decimal": { + "type": "string", + "maxLength": 19, + "pattern": "^(?:0|[1-9][0-9]{0,11}|0\\.[0-9]{0,5}[1-9]|(?=[0-9.]{1,13}(?![\\s\\S]))[1-9][0-9]{0,10}\\.[0-9]{0,5}[1-9])(?![\\s\\S])" + }, + "quantity": { + "type": "object", + "properties": { + "amount": { + "$ref": "#/$defs/decimal" + }, + "unit": { + "type": "string", + "enum": [ + "g", + "kg", + "mL", + "L", + "each" + ] + } + }, + "required": [ + "amount", + "unit" + ], + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "unit": { + "const": "each" + } + }, + "required": [ + "unit" + ] + }, + "then": { + "properties": { + "amount": { + "pattern": "^(?:0|[1-9][0-9]{0,11})(?![\\s\\S])" + } + } + } + } + ] + }, + "reported_quantity": { + "oneOf": [ + { + "type": "object", + "properties": { + "state": { + "const": "known" + }, + "quantity": { + "$ref": "#/$defs/quantity" + }, + "qualifier": { + "type": "string", + "enum": [ + "exact", + "approximate" + ] + } + }, + "required": [ + "state", + "quantity", + "qualifier" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "state": { + "const": "unknown" + }, + "quantity": { + "type": "null" + }, + "qualifier": { + "type": "string", + "enum": [ + "exact", + "approximate" + ] + } + }, + "required": [ + "state", + "quantity", + "qualifier" + ], + "additionalProperties": false + } + ] + }, + "money": { + "type": "object", + "properties": { + "currency": { + "type": "string", + "enum": [ + "AED", + "AFN", + "ALL", + "AMD", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BOV", + "BRL", + "BSD", + "BTN", + "BWP", + "BYN", + "BZD", + "CAD", + "CDF", + "CHE", + "CHF", + "CHW", + "CLF", + "CLP", + "CNY", + "COP", + "COU", + "CRC", + "CUP", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GHS", + "GIP", + "GMD", + "GNF", + "GTQ", + "GYD", + "HKD", + "HNL", + "HTG", + "HUF", + "IDR", + "ILS", + "INR", + "IQD", + "IRR", + "ISK", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRU", + "MUR", + "MVR", + "MWK", + "MXN", + "MXV", + "MYR", + "MZN", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLE", + "SOS", + "SRD", + "SSP", + "STN", + "SVC", + "SYP", + "SZL", + "THB", + "TJS", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "USN", + "UYI", + "UYU", + "UYW", + "UZS", + "VED", + "VES", + "VND", + "VUV", + "WST", + "XAD", + "XAF", + "XCD", + "XCG", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMW", + "ZWG" + ] + }, + "minor": { + "type": "string", + "maxLength": 15, + "pattern": "^(?:0|[1-9][0-9]{0,14})(?![\\s\\S])" + }, + "exponent": { + "type": "integer", + "minimum": 0, + "maximum": 4 + } + }, + "required": [ + "currency", + "minor", + "exponent" + ], + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "currency": { + "const": "AED" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "AFN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ALL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "AMD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "AOA" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ARS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "AUD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "AWG" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "AZN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BAM" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BBD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BDT" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BHD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BIF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BMD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BND" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BOB" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BOV" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BRL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BSD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BTN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BWP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BYN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "BZD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CAD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CDF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CHE" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CHF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CHW" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CLF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 4 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CLP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CNY" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "COP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "COU" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CRC" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CUP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CVE" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "CZK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "DJF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "DKK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "DOP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "DZD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "EGP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ERN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ETB" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "EUR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "FJD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "FKP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GBP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GEL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GHS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GIP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GMD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GNF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GTQ" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "GYD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "HKD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "HNL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "HTG" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "HUF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "IDR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ILS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "INR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "IQD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "IRR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ISK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "JMD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "JOD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "JPY" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KES" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KGS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KHR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KMF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KPW" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KRW" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KWD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KYD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "KZT" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "LAK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "LBP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "LKR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "LRD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "LSL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "LYD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MAD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MDL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MGA" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MKD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MMK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MNT" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MOP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MRU" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MUR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MVR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MWK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MXN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MXV" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MYR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "MZN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "NAD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "NGN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "NIO" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "NOK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "NPR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "NZD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "OMR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PAB" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PEN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PGK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PHP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PKR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PLN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "PYG" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "QAR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "RON" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "RSD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "RUB" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "RWF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SAR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SBD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SCR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SDG" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SEK" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SGD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SHP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SLE" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SOS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SRD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SSP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "STN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SVC" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SYP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "SZL" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "THB" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TJS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TMT" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TND" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 3 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TOP" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TRY" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TTD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TWD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "TZS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "UAH" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "UGX" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "USD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "USN" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "UYI" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "UYU" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "UYW" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 4 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "UZS" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "VED" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "VES" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "VND" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "VUV" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "WST" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "XAD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "XAF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "XCD" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "XCG" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "XOF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "XPF" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 0 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "YER" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ZAR" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ZMW" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + }, + { + "if": { + "properties": { + "currency": { + "const": "ZWG" + } + }, + "required": [ + "currency" + ] + }, + "then": { + "properties": { + "exponent": { + "const": 2 + } + } + } + } + ] + }, + "unix_seconds": { + "type": "string", + "maxLength": 12, + "pattern": "^(?:0|[1-9][0-9]{0,10}|1[0-9]{11}|2[0-4][0-9]{10}|25[0-2][0-9]{9}|253[0-3][0-9]{8}|25340[0-1][0-9]{6}|253402[0-2][0-9]{5}|253402300[0-6][0-9]{2}|2534023007[0-8][0-9]{1}|25340230079[0-8][0-9]{0}|253402300799)(?![\\s\\S])" + }, + "evidence_span": { + "type": "object", + "properties": { + "kind": { + "const": "span" + }, + "source_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "start": { + "type": "integer", + "minimum": 0, + "maximum": 2147483647 + }, + "end": { + "type": "integer", + "minimum": 0, + "maximum": 2147483647 + }, + "method": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "kind", + "source_id", + "revision", + "start", + "end", + "method" + ], + "additionalProperties": false + }, + "record_field_evidence": { + "type": "object", + "properties": { + "kind": { + "const": "record_field" + }, + "source_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "record_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "field": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "method": { + "const": "trusted_record" + } + }, + "required": [ + "kind", + "source_id", + "revision", + "record_id", + "field", + "method" + ], + "additionalProperties": false + }, + "evidence_ref": { + "oneOf": [ + { + "$ref": "#/$defs/evidence_span" + }, + { + "$ref": "#/$defs/record_field_evidence" + } + ] + }, + "product_ref": { + "type": "object", + "properties": { + "phrase": { + "type": "string", + "minLength": 1 + }, + "catalogue_id": { + "type": [ + "string", + "null" + ], + "minLength": 1 + }, + "resolution": { + "type": "string", + "enum": [ + "resolved", + "unresolved" + ] + } + }, + "required": [ + "phrase", + "catalogue_id", + "resolution" + ], + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "resolution": { + "const": "resolved" + } + }, + "required": [ + "resolution" + ] + }, + "then": { + "properties": { + "catalogue_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + } + }, + "else": { + "properties": { + "catalogue_id": { + "type": "null" + } + } + } + } + ] + }, + "execution": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "complete", + "degraded", + "failed" + ] + }, + "provider_calls": { + "type": "integer", + "minimum": 0, + "maximum": 2147483647 + }, + "model": { + "anyOf": [ + { + "const": "jev-1.14.0" + }, + { + "type": "null" + } + ] + }, + "question_bundle": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + { + "type": "null" + } + ] + }, + "degraded_reason": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "status", + "provider_calls", + "model", + "question_bundle", + "degraded_reason" + ], + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "provider_calls": { + "const": 0 + } + }, + "required": [ + "provider_calls" + ] + }, + "then": { + "properties": { + "model": { + "type": "null" + }, + "question_bundle": { + "type": "null" + } + } + }, + "else": { + "properties": { + "model": { + "const": "jev-1.14.0" + }, + "question_bundle": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + } + } + }, + { + "if": { + "properties": { + "status": { + "const": "degraded" + } + }, + "required": [ + "status" + ] + }, + "then": { + "properties": { + "degraded_reason": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + } + }, + "else": { + "properties": { + "degraded_reason": { + "type": "null" + } + } + } + } + ] + }, + "review": { + "type": "object", + "properties": { + "required": { + "type": "boolean" + }, + "clarifications": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { + "type": "string", + "minLength": 1 + }, + "reason": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "field", + "reason" + ], + "additionalProperties": false + } + } + }, + "required": [ + "required", + "clarifications" + ], + "additionalProperties": false + } + } +} diff --git a/schemas/hyf_ops_v3/domain_manifest.json b/schemas/hyf_ops_v3/domain_manifest.json @@ -0,0 +1,322 @@ +{ + "schema_version": 1, + "revision": "hyf_ops_v3", + "meaning": "Schema/owner bindings only; no schema row is promoted to executed runtime enforcement. Except the strict context/guard, runtime implementation remains with the named dependent owners.", + "bindings": [ + { + "path": "context", + "owners": [ + "C004", + "C009" + ], + "domain": "hyf_core.operation_context.OperationContext; pre-activation parse only" + }, + { + "path": "context.actor", + "owners": [ + "C004", + "C063" + ], + "domain": "radroots_domain::ActorRef descriptor; never authenticated CommandContext" + }, + { + "path": "context.workspace_id", + "owners": [ + "C004", + "C063" + ], + "domain": "radroots_domain::WorkspaceId descriptor" + }, + { + "path": "context.evaluation_time", + "owners": [ + "C004", + "C023", + "C063" + ], + "domain": "radroots_domain::UnixSeconds" + }, + { + "path": "input.source", + "owners": [ + "C009", + "C023", + "C063" + ], + "domain": "Immutable source/revision/participant projection; shared UnixSeconds" + }, + { + "path": "input.references", + "owners": [ + "C009", + "C023", + "C063" + ], + "domain": "Versioned taxonomy and shared normalization references" + }, + { + "path": "input.clarification", + "owners": [ + "C009", + "C023" + ], + "domain": "Clarification source identity distinct from expected target revision" + }, + { + "path": "input.prior_records", + "owners": [ + "C009", + "C023", + "C063" + ], + "domain": "Authorized record descriptors with participant/workspace scope" + }, + { + "path": "input.need", + "owners": [ + "C009", + "C023", + "C063" + ], + "domain": "Read-only authorized need projection; canonical shared quantity" + }, + { + "path": "input.candidates", + "owners": [ + "C009", + "C023", + "C063" + ], + "domain": "Authorized candidate/SDK projection; no private pool or HYF allocator" + }, + { + "path": "input.coverage", + "owners": [ + "C009", + "C023", + "C041" + ], + "domain": "Actual supplied/evaluated coverage, not market completeness" + }, + { + "path": "output.versions", + "owners": [ + "C004", + "C009" + ], + "domain": "Exact requested axes; no fabricated model-use claim" + }, + { + "path": "output.provenance", + "owners": [ + "C009", + "C023", + "C030", + "C038", + "C041" + ], + "domain": "Independent actual-use source/revision witness" + }, + { + "path": "output.claims", + "owners": [ + "C009", + "C030" + ], + "domain": "Source-backed reviewable seller claims" + }, + { + "path": "output.proposed_changes", + "owners": [ + "C009", + "C023", + "C030" + ], + "domain": "Reviewable proposals with explicit correction direction; no write" + }, + { + "path": "output.demand_lines", + "owners": [ + "C009", + "C038" + ], + "domain": "Source-backed reviewable buyer need lines" + }, + { + "path": "output.review", + "owners": [ + "C009", + "C030", + "C038" + ], + "domain": "Immutable clarification and explicit uncertainty" + }, + { + "path": "output.suggestions", + "owners": [ + "C009", + "C041" + ], + "domain": "Advisory candidate preferences; shared SDK owns firm checks" + }, + { + "path": "output.limitations", + "owners": [ + "C009", + "C041" + ], + "domain": "Supplied-record coverage and no commitment" + }, + { + "path": "output.execution", + "owners": [ + "C009", + "C043" + ], + "domain": "Actual model/call/bundle use, degradation and no invented provider result" + }, + { + "path": "meta", + "owners": [ + "C004", + "C009" + ], + "domain": "Closed optional diagnostic metadata" + }, + { + "path": "error", + "owners": [ + "C004" + ], + "domain": "Closed sanitized wire error" + } + ], + "definitions": { + "versions": { + "owners": [ + "C004", + "C009" + ], + "domain": "Version axes" + }, + "actor": { + "owners": [ + "C004", + "C063" + ], + "domain": "radroots_domain::ActorRef descriptor" + }, + "context": { + "owners": [ + "C004", + "C009" + ], + "domain": "hyf_core.operation_context.OperationContext" + }, + "source": { + "owners": [ + "C009", + "C023", + "C063" + ], + "domain": "Immutable source projection" + }, + "identity": { + "owners": [ + "C009", + "C023" + ], + "domain": "Immutable source/revision pair" + }, + "decimal": { + "owners": [ + "C018", + "C063" + ], + "domain": "radroots_domain::Decimal" + }, + "quantity": { + "owners": [ + "C018", + "C019", + "C063" + ], + "domain": "radroots_domain::Quantity" + }, + "reported_quantity": { + "owners": [ + "C009", + "C018" + ], + "domain": "Known canonical quantity or explicit unknown, plus source qualifier" + }, + "money": { + "owners": [ + "C018", + "C019", + "C063" + ], + "domain": "radroots_domain::Money/MinorAmount/Currency" + }, + "unix_seconds": { + "owners": [ + "C004", + "C023", + "C063" + ], + "domain": "radroots_domain::UnixSeconds" + }, + "evidence_span": { + "owners": [ + "C009", + "C023" + ], + "domain": "Exact UTF-8 source/revision span" + }, + "record_field_evidence": { + "owners": [ + "C009", + "C023" + ], + "domain": "Actually consulted authorized record field" + }, + "evidence_ref": { + "owners": [ + "C009", + "C023" + ], + "domain": "Closed span/record-field union" + }, + "product_ref": { + "owners": [ + "C009", + "C023" + ], + "domain": "Resolved public product reference or explicit unresolved source phrase" + }, + "execution": { + "owners": [ + "C009", + "C043" + ], + "domain": "Actual provider execution metadata" + }, + "review": { + "owners": [ + "C009", + "C030", + "C038" + ], + "domain": "Explicit review and clarification output" + } + }, + "envelope_only": [ + "version", + "request_id", + "trace_id", + "capability", + "ok", + "input", + "output" + ] +} diff --git a/schemas/hyf_ops_v3/examples/buyer_request_interpret.error.json b/schemas/hyf_ops_v3/examples/buyer_request_interpret.error.json @@ -0,0 +1,9 @@ +{ + "version": 1, + "request_id": "v3-buyer_request_interpret", + "ok": false, + "error": { + "code": "capability_unavailable", + "message": "Operation not activated." + } +} diff --git a/schemas/hyf_ops_v3/examples/buyer_request_interpret.request.json b/schemas/hyf_ops_v3/examples/buyer_request_interpret.request.json @@ -0,0 +1,52 @@ +{ + "version": 1, + "request_id": "v3-buyer_request_interpret", + "capability": "buyer_request.interpret", + "context": { + "evaluation_time": "1793016000", + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "actor": { + "participant": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "role": "buyer", + "organization": null, + "grant_id": null + }, + "workspace_id": "0000000000000000000000000000000000000000000000000000000000000002" + }, + "input": { + "source": { + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1", + "text": "I need 2 kg cabbage.", + "source_time": "1793012400", + "participant_id": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + }, + "references": { + "taxonomy": { + "version": "hyf_ops_v3.taxonomy.v1", + "provenance": "authored_public_synthetic", + "products": [ + { + "catalogue_id": "cabbage", + "terms": [ + "cabbage" + ] + } + ] + }, + "normalization": { + "version": "hyf_ops_v3.normalization.v1", + "provenance": "public_shared_sdk", + "currency_registry": "radroots.currency_registry.v1" + } + } + } +} diff --git a/schemas/hyf_ops_v3/examples/buyer_request_interpret.response.json b/schemas/hyf_ops_v3/examples/buyer_request_interpret.response.json @@ -0,0 +1,69 @@ +{ + "version": 1, + "request_id": "v3-buyer_request_interpret", + "ok": true, + "output": { + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "provenance": { + "source": { + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1" + }, + "clarification": null + }, + "review": { + "required": true, + "clarifications": [ + { + "field": "proposal", + "reason": "Host review and shared SDK revalidation are required before use." + } + ] + }, + "execution": { + "status": "complete", + "provider_calls": 0, + "model": null, + "question_bundle": null, + "degraded_reason": null + }, + "demand_lines": [ + { + "line_id": "line-1", + "product": { + "phrase": "cabbage", + "catalogue_id": "cabbage", + "resolution": "resolved" + }, + "quantity": { + "state": "known", + "quantity": { + "amount": "2", + "unit": "kg" + }, + "qualifier": "exact" + }, + "conditions": [], + "evidence": [ + { + "kind": "span", + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1", + "start": 7, + "end": 19, + "method": "source_span" + } + ], + "review_required": true + } + ] + } +} diff --git a/schemas/hyf_ops_v3/examples/buyer_request_match.error.json b/schemas/hyf_ops_v3/examples/buyer_request_match.error.json @@ -0,0 +1,9 @@ +{ + "version": 1, + "request_id": "v3-buyer_request_match", + "ok": false, + "error": { + "code": "capability_unavailable", + "message": "Operation not activated." + } +} diff --git a/schemas/hyf_ops_v3/examples/buyer_request_match.request.json b/schemas/hyf_ops_v3/examples/buyer_request_match.request.json @@ -0,0 +1,122 @@ +{ + "version": 1, + "request_id": "v3-buyer_request_match", + "capability": "buyer_request.match", + "context": { + "evaluation_time": "1793016000", + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "actor": { + "participant": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "role": "buyer", + "organization": null, + "grant_id": null + }, + "workspace_id": "0000000000000000000000000000000000000000000000000000000000000002" + }, + "input": { + "need": { + "need_id": "0000000000000000000000000000000000000000000000000000000000000007", + "revision": "1", + "participant_id": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "demand_lines": [ + { + "line_id": "line-1", + "product": { + "phrase": "cabbage", + "catalogue_id": "cabbage", + "resolution": "resolved" + }, + "quantity": { + "state": "known", + "quantity": { + "amount": "2", + "unit": "kg" + }, + "qualifier": "exact" + }, + "conditions": [], + "evidence": [ + { + "kind": "record_field", + "source_id": "0000000000000000000000000000000000000000000000000000000000000007", + "revision": "1", + "record_id": "0000000000000000000000000000000000000000000000000000000000000007", + "field": "demand_lines", + "method": "trusted_record" + } + ], + "review_required": true + } + ], + "partial_fulfillment": false + }, + "candidates": [ + { + "candidate_id": "0000000000000000000000000000000000000000000000000000000000000004", + "listing_id": "0000000000000000000000000000000000000000000000000000000000000005", + "revision": "1", + "participant_id": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "product": { + "phrase": "cabbage", + "catalogue_id": "cabbage", + "resolution": "resolved" + }, + "declared_quantity": { + "state": "known", + "quantity": { + "amount": "8", + "unit": "kg" + }, + "qualifier": "exact" + }, + "price": { + "currency": "CAD", + "minor": "1250", + "exponent": 2 + }, + "sdk_projection": { + "projection_id": "0000000000000000000000000000000000000000000000000000000000000006", + "source_revision": "1", + "feasibility": "unknown", + "checks": [], + "revalidate_before_use": true + } + } + ], + "coverage": { + "scope": "supplied_only", + "truncated": false, + "evaluated": [ + "0000000000000000000000000000000000000000000000000000000000000004" + ], + "excluded": [] + }, + "references": { + "taxonomy": { + "version": "hyf_ops_v3.taxonomy.v1", + "provenance": "authored_public_synthetic", + "products": [ + { + "catalogue_id": "cabbage", + "terms": [ + "cabbage" + ] + } + ] + }, + "normalization": { + "version": "hyf_ops_v3.normalization.v1", + "provenance": "public_shared_sdk", + "currency_registry": "radroots.currency_registry.v1" + } + } + } +} diff --git a/schemas/hyf_ops_v3/examples/buyer_request_match.response.json b/schemas/hyf_ops_v3/examples/buyer_request_match.response.json @@ -0,0 +1,63 @@ +{ + "version": 1, + "request_id": "v3-buyer_request_match", + "ok": true, + "output": { + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "provenance": { + "need": { + "need_id": "0000000000000000000000000000000000000000000000000000000000000007", + "revision": "1" + }, + "candidates": [ + { + "candidate_id": "0000000000000000000000000000000000000000000000000000000000000004", + "revision": "1" + } + ] + }, + "suggestions": [ + { + "candidate_id": "0000000000000000000000000000000000000000000000000000000000000004", + "preference": 0.625, + "checks": [ + { + "kind": "feasibility", + "result": "unknown", + "reason": "Host projection remains conditional.", + "evidence": [] + } + ], + "unresolved": [ + "SDK revalidation required" + ], + "evidence": [], + "commitment": "none" + } + ], + "limitations": { + "scope": "supplied_only", + "truncated": false, + "unsupported": [ + "market completeness", + "stock allocation" + ], + "commitment": "none" + }, + "execution": { + "status": "complete", + "provider_calls": 0, + "model": null, + "question_bundle": null, + "degraded_reason": null + } + } +} diff --git a/schemas/hyf_ops_v3/examples/farm_update_interpret.error.json b/schemas/hyf_ops_v3/examples/farm_update_interpret.error.json @@ -0,0 +1,9 @@ +{ + "version": 1, + "request_id": "v3-farm_update_interpret", + "ok": false, + "error": { + "code": "capability_unavailable", + "message": "Operation not activated." + } +} diff --git a/schemas/hyf_ops_v3/examples/farm_update_interpret.request.json b/schemas/hyf_ops_v3/examples/farm_update_interpret.request.json @@ -0,0 +1,52 @@ +{ + "version": 1, + "request_id": "v3-farm_update_interpret", + "capability": "farm_update.interpret", + "context": { + "evaluation_time": "1793016000", + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "actor": { + "participant": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "role": "seller", + "organization": null, + "grant_id": null + }, + "workspace_id": "0000000000000000000000000000000000000000000000000000000000000002" + }, + "input": { + "source": { + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1", + "text": "I have 8 kg cabbage.", + "source_time": "1793012400", + "participant_id": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + }, + "references": { + "taxonomy": { + "version": "hyf_ops_v3.taxonomy.v1", + "provenance": "authored_public_synthetic", + "products": [ + { + "catalogue_id": "cabbage", + "terms": [ + "cabbage" + ] + } + ] + }, + "normalization": { + "version": "hyf_ops_v3.normalization.v1", + "provenance": "public_shared_sdk", + "currency_registry": "radroots.currency_registry.v1" + } + } + } +} diff --git a/schemas/hyf_ops_v3/examples/farm_update_interpret.response.json b/schemas/hyf_ops_v3/examples/farm_update_interpret.response.json @@ -0,0 +1,99 @@ +{ + "version": 1, + "request_id": "v3-farm_update_interpret", + "ok": true, + "output": { + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "provenance": { + "source": { + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1" + }, + "clarification": null, + "prior_records": [] + }, + "review": { + "required": true, + "clarifications": [ + { + "field": "proposal", + "reason": "Host review and shared SDK revalidation are required before use." + } + ] + }, + "execution": { + "status": "complete", + "provider_calls": 0, + "model": null, + "question_bundle": null, + "degraded_reason": null + }, + "claims": [ + { + "claim_id": "claim-1", + "product": { + "phrase": "cabbage", + "catalogue_id": "cabbage", + "resolution": "resolved" + }, + "status": "offered", + "quantity": { + "state": "known", + "quantity": { + "amount": "8", + "unit": "kg" + }, + "qualifier": "exact" + }, + "evidence": [ + { + "kind": "span", + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1", + "start": 7, + "end": 19, + "method": "source_span" + } + ], + "review_required": true + } + ], + "proposed_changes": [ + { + "target": { + "kind": "product", + "id": null + }, + "operation": "addition", + "direction": "none", + "quantity": { + "state": "known", + "quantity": { + "amount": "8", + "unit": "kg" + }, + "qualifier": "exact" + }, + "expected_revision": null, + "evidence": [ + { + "kind": "span", + "source_id": "0000000000000000000000000000000000000000000000000000000000000003", + "revision": "1", + "start": 7, + "end": 19, + "method": "source_span" + } + ] + } + ] + } +} diff --git a/schemas/hyf_ops_v3/farm_update_interpret.request.schema.json b/schemas/hyf_ops_v3/farm_update_interpret.request.schema.json @@ -0,0 +1,211 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "integer", + "const": 1 + }, + "request_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "trace_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "capability": { + "const": "farm_update.interpret" + }, + "context": { + "$ref": "common.schema.json#/$defs/context" + }, + "input": { + "type": "object", + "properties": { + "source": { + "$ref": "common.schema.json#/$defs/source" + }, + "references": { + "type": "object", + "properties": { + "taxonomy": { + "type": "object", + "properties": { + "version": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "provenance": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "products": { + "type": "array", + "items": { + "type": "object", + "properties": { + "catalogue_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "terms": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "maxItems": 128 + } + }, + "required": [ + "catalogue_id", + "terms" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "version", + "provenance", + "products" + ], + "additionalProperties": false + }, + "normalization": { + "type": "object", + "properties": { + "version": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "provenance": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "currency_registry": { + "const": "radroots.currency_registry.v1" + } + }, + "required": [ + "version", + "provenance", + "currency_registry" + ], + "additionalProperties": false + } + }, + "required": [ + "taxonomy", + "normalization" + ], + "additionalProperties": false + }, + "clarification": { + "type": "object", + "properties": { + "source_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "target_field": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "text": { + "type": "string", + "minLength": 1, + "pattern": "\\S", + "maxLength": 1048576 + }, + "expected_revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "source_id", + "revision", + "target_field", + "text", + "expected_revision" + ], + "additionalProperties": false + }, + "prior_records": { + "type": "array", + "items": { + "type": "object", + "properties": { + "record_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "participant_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "workspace_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + } + }, + "required": [ + "record_id", + "revision", + "participant_id", + "workspace_id" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "source", + "references" + ], + "additionalProperties": false + } + }, + "required": [ + "version", + "request_id", + "capability", + "context", + "input" + ], + "additionalProperties": false, + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/farm_update_interpret.request.schema.json", + "$comment": "D57 hyf_ops_v3 pre-activation contract. No business write or trusted context can be minted by source/model text. Full semantic input-use and SDK revalidation remain required." +} diff --git a/schemas/hyf_ops_v3/farm_update_interpret.response.schema.json b/schemas/hyf_ops_v3/farm_update_interpret.response.schema.json @@ -0,0 +1,386 @@ +{ + "type": "object", + "properties": { + "version": { + "type": "integer", + "const": 1 + }, + "request_id": { + "type": "string" + }, + "trace_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + "ok": { + "type": "boolean" + }, + "output": { + "type": "object", + "properties": { + "versions": { + "$ref": "common.schema.json#/$defs/versions" + }, + "provenance": { + "type": "object", + "properties": { + "source": { + "$ref": "common.schema.json#/$defs/identity" + }, + "clarification": { + "anyOf": [ + { + "$ref": "common.schema.json#/$defs/identity" + }, + { + "type": "null" + } + ] + }, + "prior_records": { + "type": "array", + "items": { + "type": "object", + "properties": { + "record_id": { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + "revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "record_id", + "revision" + ], + "additionalProperties": false + }, + "maxItems": 128 + } + }, + "required": [ + "source", + "clarification", + "prior_records" + ], + "additionalProperties": false + }, + "review": { + "$ref": "common.schema.json#/$defs/review" + }, + "execution": { + "$ref": "common.schema.json#/$defs/execution" + }, + "claims": { + "type": "array", + "items": { + "type": "object", + "properties": { + "claim_id": { + "type": "string", + "minLength": 1 + }, + "product": { + "$ref": "common.schema.json#/$defs/product_ref" + }, + "status": { + "type": "string", + "enum": [ + "offered", + "forecast", + "unavailable", + "correction", + "unclear" + ] + }, + "quantity": { + "$ref": "common.schema.json#/$defs/reported_quantity" + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + }, + "review_required": { + "type": "boolean" + } + }, + "required": [ + "claim_id", + "product", + "status", + "evidence", + "review_required" + ], + "additionalProperties": false + }, + "maxItems": 128 + }, + "proposed_changes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "target": { + "type": "object", + "properties": { + "kind": { + "type": "string", + "enum": [ + "listing", + "product" + ] + }, + "id": { + "anyOf": [ + { + "type": "string", + "minLength": 64, + "maxLength": 64, + "pattern": "^[0-9a-f]{64}(?![\\s\\S])" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "kind", + "id" + ], + "additionalProperties": false + }, + "operation": { + "type": "string", + "enum": [ + "addition", + "remaining", + "replacement", + "withdrawal", + "correction", + "unresolved" + ] + }, + "direction": { + "type": "string", + "enum": [ + "increase", + "decrease", + "none" + ] + }, + "quantity": { + "$ref": "common.schema.json#/$defs/reported_quantity" + }, + "expected_revision": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "pattern": "\\S" + }, + { + "type": "null" + } + ] + }, + "evidence": { + "type": "array", + "items": { + "$ref": "common.schema.json#/$defs/evidence_ref" + }, + "maxItems": 128 + } + }, + "required": [ + "target", + "operation", + "direction", + "quantity", + "expected_revision", + "evidence" + ], + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "target": { + "properties": { + "id": { + "type": "string" + } + }, + "required": [ + "id" + ] + } + }, + "required": [ + "target" + ] + }, + "then": { + "properties": { + "expected_revision": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + } + }, + "else": { + "properties": { + "expected_revision": { + "type": "null" + } + } + } + }, + { + "if": { + "properties": { + "operation": { + "const": "correction" + } + }, + "required": [ + "operation" + ] + }, + "then": { + "properties": { + "direction": { + "type": "string", + "enum": [ + "increase", + "decrease" + ] + } + } + }, + "else": { + "properties": { + "direction": { + "const": "none" + } + } + } + } + ] + }, + "maxItems": 128 + } + }, + "required": [ + "versions", + "provenance", + "review", + "execution", + "claims", + "proposed_changes" + ], + "additionalProperties": false + }, + "error": { + "type": "object", + "properties": { + "code": { + "type": "string", + "enum": [ + "invalid_request", + "unsupported_capability", + "capability_disabled", + "capability_unavailable", + "internal_error" + ] + }, + "message": { + "type": "string" + } + }, + "required": [ + "code", + "message" + ], + "additionalProperties": false + }, + "meta": { + "type": "object", + "properties": { + "schema_version": { + "type": "integer", + "const": 1 + } + }, + "required": [ + "schema_version" + ], + "additionalProperties": false + } + }, + "required": [ + "version", + "request_id", + "ok" + ], + "additionalProperties": false, + "oneOf": [ + { + "properties": { + "ok": { + "const": true + }, + "request_id": { + "type": "string", + "minLength": 1, + "pattern": "\\S" + } + }, + "required": [ + "output" + ], + "not": { + "required": [ + "error" + ] + } + }, + { + "properties": { + "ok": { + "const": false + } + }, + "required": [ + "error" + ], + "not": { + "anyOf": [ + { + "required": [ + "output" + ] + }, + { + "required": [ + "meta" + ] + } + ] + } + } + ], + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "hyf_ops_v3/farm_update_interpret.response.schema.json", + "$comment": "D57 hyf_ops_v3 pre-activation contract. No business write or trusted context can be minted by source/model text. Full semantic input-use and SDK revalidation remain required." +} diff --git a/schemas/hyf_ops_v3/manifest.json b/schemas/hyf_ops_v3/manifest.json @@ -0,0 +1,58 @@ +{ + "schema_version": 1, + "revision": "hyf_ops_v3", + "selector": { + "field": "context.versions.schema", + "value": "hyf_ops_v3" + }, + "envelope_version": 1, + "activation": { + "state": "pre_activation", + "guard_error_code": "capability_unavailable", + "owner": "C042-C046" + }, + "operations": { + "farm_update.interpret": { + "request": "farm_update_interpret.request.schema.json", + "response": "farm_update_interpret.response.schema.json" + }, + "buyer_request.interpret": { + "request": "buyer_request_interpret.request.schema.json", + "response": "buyer_request_interpret.response.schema.json" + }, + "buyer_request.match": { + "request": "buyer_request_match.request.schema.json", + "response": "buyer_request_match.response.schema.json" + } + }, + "retired_contracts": [ + "hyf_ops_v2" + ], + "compatibility": "v2 remains a pre-activation historical parser/rejection characterization, never an active competing model/business engine.", + "retained_limits": { + "stdio_frame_utf8_bytes": 1048576, + "json_depth": 64, + "candidates": 64, + "suggestions": 8, + "provider_state_utf8_bytes": 4096, + "questions": 32, + "logical_provider_calls": 4, + "wire_attempts": 4, + "authority": "D21; remaining transport/deadline/retry/cleanup limits unchanged" + }, + "shared_values": { + "owner": "radroots_domain", + "quantity": "Quantity { amount: canonical Decimal string, unit: g|kg|mL|L|each }; unknown distinct; each integral.", + "money": "Money { currency, minor: canonical unsigned integer string, exponent }; exact registry pair, no fees/FX/price-basis inference.", + "time": "radroots_domain::UnixSeconds canonical unsigned ASCII string 0..253402300799; no floating, RFC3339 wire alias or inferred timezone. Relative language interpretation remains C023/SDK-owned.", + "currency_data_sha256": "60d8282b2d7ddc27929b097d4de9e76a900a64f1de4a5aa7a4cb3308b55b82d0" + }, + "semantic_owners": { + "source_scope_revision_evidence": "C009/C023/C063", + "shared_feasibility_economics_conservation": "oss/lib; projected by C063; no HYF allocator", + "source_input_claims_and_clarification": "C030/C038", + "suggestion_composition": "C041", + "real_native_authenticated_host": "C064" + }, + "evaluation_projection": "C062 natural-language item/item-count oracle maps to SDK unit each, never a second unit identifier." +} diff --git a/schemas/hyf_ops_v3/reference/currency_registry_v1.csv b/schemas/hyf_ops_v3/reference/currency_registry_v1.csv @@ -0,0 +1,171 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2023-2026 rust_iso4217 contributors +# Derived from rust-iso/rust_iso4217 ce6b74546b3645ce11866acc93117128d2f7b1e0. +# Modified by Radroots: retain current currency/fund code and exponent pairs +# in range 0-4; sort by code; omit all names, countries, other data and code. +# See currency_registry_v1.license and currency_registry_v1.notice. +AED,2 +AFN,2 +ALL,2 +AMD,2 +AOA,2 +ARS,2 +AUD,2 +AWG,2 +AZN,2 +BAM,2 +BBD,2 +BDT,2 +BHD,3 +BIF,0 +BMD,2 +BND,2 +BOB,2 +BOV,2 +BRL,2 +BSD,2 +BTN,2 +BWP,2 +BYN,2 +BZD,2 +CAD,2 +CDF,2 +CHE,2 +CHF,2 +CHW,2 +CLF,4 +CLP,0 +CNY,2 +COP,2 +COU,2 +CRC,2 +CUP,2 +CVE,2 +CZK,2 +DJF,0 +DKK,2 +DOP,2 +DZD,2 +EGP,2 +ERN,2 +ETB,2 +EUR,2 +FJD,2 +FKP,2 +GBP,2 +GEL,2 +GHS,2 +GIP,2 +GMD,2 +GNF,0 +GTQ,2 +GYD,2 +HKD,2 +HNL,2 +HTG,2 +HUF,2 +IDR,2 +ILS,2 +INR,2 +IQD,3 +IRR,2 +ISK,0 +JMD,2 +JOD,3 +JPY,0 +KES,2 +KGS,2 +KHR,2 +KMF,0 +KPW,2 +KRW,0 +KWD,3 +KYD,2 +KZT,2 +LAK,2 +LBP,2 +LKR,2 +LRD,2 +LSL,2 +LYD,3 +MAD,2 +MDL,2 +MGA,2 +MKD,2 +MMK,2 +MNT,2 +MOP,2 +MRU,2 +MUR,2 +MVR,2 +MWK,2 +MXN,2 +MXV,2 +MYR,2 +MZN,2 +NAD,2 +NGN,2 +NIO,2 +NOK,2 +NPR,2 +NZD,2 +OMR,3 +PAB,2 +PEN,2 +PGK,2 +PHP,2 +PKR,2 +PLN,2 +PYG,0 +QAR,2 +RON,2 +RSD,2 +RUB,2 +RWF,0 +SAR,2 +SBD,2 +SCR,2 +SDG,2 +SEK,2 +SGD,2 +SHP,2 +SLE,2 +SOS,2 +SRD,2 +SSP,2 +STN,2 +SVC,2 +SYP,2 +SZL,2 +THB,2 +TJS,2 +TMT,2 +TND,3 +TOP,2 +TRY,2 +TTD,2 +TWD,2 +TZS,2 +UAH,2 +UGX,0 +USD,2 +USN,2 +UYI,0 +UYU,2 +UYW,4 +UZS,2 +VED,2 +VES,2 +VND,0 +VUV,0 +WST,2 +XAD,2 +XAF,0 +XCD,2 +XCG,2 +XOF,0 +XPF,0 +YER,2 +ZAR,2 +ZMW,2 +ZWG,2 diff --git a/schemas/hyf_ops_v3/reference/currency_registry_v1.license b/schemas/hyf_ops_v3/reference/currency_registry_v1.license @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative + Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023-2026 rust_iso4217 contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/schemas/hyf_ops_v3/reference/currency_registry_v1.notice b/schemas/hyf_ops_v3/reference/currency_registry_v1.notice @@ -0,0 +1,23 @@ +Currency registry v1 data attribution + +Copyright 2023-2026 rust_iso4217 contributors +Apache License 2.0; see currency_registry_v1.license. + +Source: https://github.com/rust-iso/rust_iso4217 +Revision: ce6b74546b3645ce11866acc93117128d2f7b1e0 +Original material: src/lib.rs (SHA256 7401727ea4da05fcbf0d1d679705c0245989e83dbc697e831066f992875e183d). + +Radroots changes: extract only current currency/fund alphabetic code and +minor-unit exponent facts in range 0-4; sort them; omit historic entries, +no-minor-unit entries, names, countries, numeric identifiers and all upstream +Rust/generator implementation. The Rust API is independently implemented. +This derived data retains the upstream Apache-2.0 license and attribution. + +The publisher identifies SIX ISO 4217 lists as its currency source and Datahub +as its country-relationship source. No country relationships are included here. +All 165 selected pairs match the separately acquired official SIX List One +snapshot published 2026-09-17. The XML and ISO standard text are not distributed. +No cash/display rounding, exchange rate, payment rule or currency conversion +is implied. The registry is fixed; replacement requires explicit versioned +contract and provenance review. Derived artifacts must include this material +and its license/notice before adopting it. diff --git a/schemas/hyf_ops_v3/version_manifest.json b/schemas/hyf_ops_v3/version_manifest.json @@ -0,0 +1,14 @@ +{ + "schema_version": 1, + "revision": "hyf_ops_v3", + "versions": { + "schema": "hyf_ops_v3", + "taxonomy": "hyf_ops_v3.taxonomy.v1", + "normalization": "hyf_ops_v3.normalization.v1", + "review_policy": "hyf_ops_v3.review_policy.v1", + "ranking_policy": "hyf_ops_v3.ranking_policy.v1", + "question_bundle": "hyf_ops_v3.question_bundle.v1", + "model": "jev-1.14.0" + }, + "note": "Contract revision identifiers; actual source/model use must be bound by later owners, not inferred from these strings." +} diff --git a/src/hyf_core/operation_context.mojo b/src/hyf_core/operation_context.mojo @@ -1,10 +1,9 @@ -# ADR-0025 D45 CB01-CB05 — corrected hyf_ops_v2 capability context. +# D57 — hyf_ops_v3 context; v2 is retained as pre-activation characterization. # -# This module owns only the strict, capability-aware operation context for the -# three corrected operations selected by ``context.versions.schema == -# "hyf_ops_v2"``. It does not implement the operation pipelines (C008/C009), -# typed semantic consistency (C023) or activation (C042-C046). A recognized v2 -# request is parsed here and then refused by the pre-activation guard in +# This module owns the strict operation context selected by hyf_ops_v3 and +# the historical v2 pre-activation compatibility controls. It does not implement +# operation pipelines (C008/C009), typed semantic consistency (C023) or +# activation (C042-C046). A recognized versioned request is parsed, then refused in # hyf_stdio.server; it must never reach the legacy shortcut handlers. from std.collections import Dict, List, Optional @@ -14,11 +13,12 @@ from json.deserialize import get_bool, get_int, get_string comptime OPERATION_CONTRACT_SCHEMA_V2: String = "hyf_ops_v2" +comptime OPERATION_CONTRACT_SCHEMA_V3: String = "hyf_ops_v3" comptime OPERATION_CONTEXT_DEFAULT_DEADLINE_MS: Int = 2500 def corrected_operation_selector() -> String: - return OPERATION_CONTRACT_SCHEMA_V2 + return OPERATION_CONTRACT_SCHEMA_V3 def is_corrected_operation(capability: String) -> Bool: @@ -136,7 +136,10 @@ def _parse_operation_versions( _require_allowed_keys(json, allowed_keys, context) var schema = _required_string(json, "schema", context + " schema") - if schema != OPERATION_CONTRACT_SCHEMA_V2: + if ( + schema != OPERATION_CONTRACT_SCHEMA_V2 + and schema != OPERATION_CONTRACT_SCHEMA_V3 + ): raise Error( context + " selects unsupported operation contract schema '" @@ -144,6 +147,10 @@ def _parse_operation_versions( + "'" ) + var model = _required_string(json, "model", context + " model") + if schema == OPERATION_CONTRACT_SCHEMA_V3 and model != "jev-1.14.0": + raise Error(context + " requires exact Jev model jev-1.14.0") + return OperationVersions( schema=schema, taxonomy=_required_string(json, "taxonomy", context + " taxonomy"), @@ -159,11 +166,84 @@ def _parse_operation_versions( question_bundle=_required_string( json, "question_bundle", context + " question_bundle" ), - model=_required_string(json, "model", context + " model"), + model=model, ) @fieldwise_init +struct OperationActor(Copyable, Movable): + # This is an untrusted public ActorRef descriptor, never an authenticated + # CommandContext. The host retains and revalidates its SDK context. + var participant: String + var role: String + var organization: Optional[String] + var grant_id: Optional[String] + + +def _canonical_identity(value: String, context: String) raises -> String: + if value.byte_length() != 64: + raise Error(context + " must be a 64-character lowercase hex identity") + for i in range(value.byte_length()): + var byte = value.unsafe_ptr()[i] + if not ((byte >= 48 and byte <= 57) or (byte >= 97 and byte <= 102)): + raise Error(context + " must use lowercase ASCII hex") + return value + + +def _nullable_identity( + value: Value, key: String, context: String +) raises -> Optional[String]: + if not _has_key(value, key): + raise Error(context + " is required (explicit null is permitted)") + var raw = value[key] + if raw.is_null(): + return None + return _canonical_identity(get_string(value, key), context) + + +def _parse_operation_actor(value: Value) raises -> OperationActor: + _require_object(value, "operation context actor") + _require_no_duplicate_keys(value, "operation context actor") + var keys = List[String]() + for key in ["participant", "role", "organization", "grant_id"]: + keys.append(key) + _require_allowed_keys(value, keys, "operation context actor") + var participant = _canonical_identity( + _required_string(value, "participant", "actor participant"), + "actor participant", + ) + var role = _required_string(value, "role", "actor role") + if role != "seller" and role != "buyer" and role != "coordinator": + raise Error("actor role must be seller, buyer or coordinator") + return OperationActor( + participant=participant, + role=role, + organization=_nullable_identity( + value, "organization", "actor organization" + ), + grant_id=_nullable_identity(value, "grant_id", "actor grant_id"), + ) + + +def _canonical_unix_seconds(value: String) raises: + # Representation parity with public radroots_domain::UnixSeconds. Time + # interpretation and source eligibility remain with the shared SDK owner. + var size = value.byte_length() + if size == 0 or size > 12: + raise Error("evaluation_time must be canonical bounded UnixSeconds") + if size > 1 and value.unsafe_ptr()[0] == 48: + raise Error("evaluation_time must not have leading zeros") + var seconds = 0 + for i in range(size): + var byte = value.unsafe_ptr()[i] + if byte < 48 or byte > 57: + raise Error("evaluation_time must use unsigned ASCII seconds") + seconds = seconds * 10 + Int(byte) - 48 + if seconds > 253402300799: + raise Error("evaluation_time exceeds the shared UnixSeconds bound") + + +@fieldwise_init struct OperationContext(Copyable, Movable): var consumer: String var execution_mode_preference: String @@ -175,6 +255,8 @@ struct OperationContext(Copyable, Movable): var return_provenance: Bool var actor_id: String var farm_id: Optional[String] + var actor: Optional[OperationActor] + var workspace_id: Optional[String] def default_operation_context() -> OperationContext: @@ -197,6 +279,21 @@ def default_operation_context() -> OperationContext: return_provenance=False, actor_id="", farm_id=None, + actor=None, + workspace_id=None, + ) + + +def operation_context_selects_v3(context_json: Value) raises -> Bool: + if not context_json.is_object() or not _has_key(context_json, "versions"): + return False + var versions = context_json["versions"] + if not versions.is_object() or not _has_key(versions, "schema"): + return False + var schema = versions["schema"] + return ( + schema.is_string() + and String(schema.string_value()) == OPERATION_CONTRACT_SCHEMA_V3 ) @@ -209,7 +306,7 @@ def operation_context_selects_v2(context_json: Value) raises -> Bool: ADR-0026 D46 CR04: this first-wins lookup is only used after the envelope root duplicate gate has rejected any ambiguous v2-targeting envelope; use - ``context_selects_v2_any`` when duplicate-aware inspection is required. + ``context_selects_versioned_any`` for duplicate-aware inspection. """ if not context_json.is_object(): return False @@ -226,8 +323,8 @@ def operation_context_selects_v2(context_json: Value) raises -> Bool: return String(schema.string_value()) == OPERATION_CONTRACT_SCHEMA_V2 -def context_selects_v2_any(context_json: Value) raises -> Bool: - """Duplicate-aware v2 selector inspection for the envelope admission gate. +def context_selects_versioned_any(context_json: Value) raises -> Bool: + """Duplicate-aware v2/v3 inspection for the envelope admission gate. Scans every decoded ``versions`` member and every decoded ``schema`` entry instead of the first match, so a duplicate key cannot hide a v2 selector @@ -247,6 +344,8 @@ def context_selects_v2_any(context_json: Value) raises -> Bool: if ( String(member[1].string_value()) == OPERATION_CONTRACT_SCHEMA_V2 + or String(member[1].string_value()) + == OPERATION_CONTRACT_SCHEMA_V3 ): return True return False @@ -265,7 +364,10 @@ def parse_operation_context( _require_object(json, "operation context") _require_no_duplicate_keys(json, "operation context") - var requires_farm = corrected_operation_requires_farm_id(capability) + var is_v3 = operation_context_selects_v3(json) + var requires_farm = not is_v3 and corrected_operation_requires_farm_id( + capability + ) var allowed_keys = List[String]() for key in [ "consumer", @@ -276,9 +378,13 @@ def parse_operation_context( "locale", "versions", "return_provenance", - "actor_id", ]: allowed_keys.append(key) + if is_v3: + allowed_keys.append("actor") + allowed_keys.append("workspace_id") + else: + allowed_keys.append("actor_id") if requires_farm: allowed_keys.append("farm_id") _require_allowed_keys(json, allowed_keys, "operation context") @@ -302,7 +408,9 @@ def parse_operation_context( if _has_key(json, "deadline_ms"): context.deadline_ms = get_int(json, "deadline_ms") - if context.deadline_ms <= 0: + if context.deadline_ms <= 0 or ( + is_v3 and context.deadline_ms > 2147483647 + ): raise Error( "operation context deadline_ms must be greater than zero" ) @@ -310,6 +418,8 @@ def parse_operation_context( context.evaluation_time = _required_string( json, "evaluation_time", "operation context evaluation_time" ) + if is_v3: + _canonical_unix_seconds(context.evaluation_time) context.timezone = _optional_string( json, "timezone", "operation context timezone" @@ -327,9 +437,22 @@ def parse_operation_context( if _has_key(json, "return_provenance"): context.return_provenance = get_bool(json, "return_provenance") - context.actor_id = _required_string( - json, "actor_id", "operation context actor_id" - ) + if is_v3: + if not _has_key(json, "actor"): + raise Error("operation context actor is required") + context.actor = _parse_operation_actor(json["actor"].clone()) + context.workspace_id = _canonical_identity( + _required_string( + json, "workspace_id", "operation context workspace_id" + ), + "operation context workspace_id", + ) + # Never turn this descriptor into an authorization token or a business + # write. It remains behind the pre-activation guard until later owners. + else: + context.actor_id = _required_string( + json, "actor_id", "operation context actor_id" + ) if requires_farm: context.farm_id = _required_string( diff --git a/src/hyf_stdio/envelope.mojo b/src/hyf_stdio/envelope.mojo @@ -6,9 +6,10 @@ from json.deserialize import Deserializable, get_string from hyf_core.metadata import hyf_protocol_version from hyf_core.operation_context import ( OperationContext, - context_selects_v2_any, + context_selects_versioned_any, is_corrected_operation, operation_context_selects_v2, + operation_context_selects_v3, parse_operation_context, ) from hyf_core.request_context import ( @@ -79,7 +80,7 @@ def envelope_targets_corrected_v2(json: Value) raises -> Bool: if is_corrected_operation(String(item[1].string_value())): return True elif item[0] == "context": - if context_selects_v2_any(item[1]): + if context_selects_versioned_any(item[1]): return True return False @@ -167,8 +168,9 @@ struct WireRequest(Copyable, Deserializable, Movable): var context = default_request_context() var operation_context: Optional[OperationContext] = None - if is_corrected_operation(capability) and operation_context_selects_v2( - context_json + if is_corrected_operation(capability) and ( + operation_context_selects_v2(context_json) + or operation_context_selects_v3(context_json) ): operation_context = parse_operation_context( context_json.clone(), capability diff --git a/src/hyf_stdio/server.mojo b/src/hyf_stdio/server.mojo @@ -203,7 +203,7 @@ def _route_business_capability[ request_id: String, runtime_context: RuntimeStartupContext, ) raises -> String: - # ADR-0025 D45 CB01 pre-activation guard: a recognized hyf_ops_v2 request has + # D57 pre-activation guard: a recognized v3 (or historical v2) request has # already passed the strict capability-context parse, but activation belongs # to C042-C046, so it must not reach the legacy shortcut handlers even when # their legacy enable flag is set. C008/C009 retain this guard. diff --git a/tests/test_hyf.mojo b/tests/test_hyf.mojo @@ -2695,3 +2695,174 @@ def test_c004_cr04_correlation_duplicate_matrix() raises: ) ) assert_true(single_escaped_context.operation_context) + + +# D57: current participant/workspace context, without a mandatory farm or pool. +def _v3_request(capability: String = "farm_update.interpret") -> String: + return ( + '{"version":1,"request_id":"v3-test","trace_id":"v3-trace",' + '"capability":"' + + capability + + '","context":{' + '"evaluation_time":"1793016000",' + '"versions":{"schema":"hyf_ops_v3","taxonomy":"t",' + '"normalization":"n","review_policy":"r","ranking_policy":"k",' + '"question_bundle":"q","model":"jev-1.14.0"},' + '"actor":{"participant":"' + + "1" * 64 + + '","role":"seller","organization":null,"grant_id":null},' + '"workspace_id":"' + + "2" * 64 + + '"},"input":{}}' + ) + + +def test_c004_v3_current_context_without_farm_or_pool() raises: + for capability in [ + "farm_update.interpret", + "buyer_request.interpret", + "buyer_request.match", + ]: + var request = decode_request(_v3_request(String(capability))) + assert_true(request.operation_context) + var context = request.operation_context.value().copy() + assert_equal(context.versions.schema, "hyf_ops_v3") + assert_equal(context.versions.model, "jev-1.14.0") + assert_equal(context.actor.value().copy().participant, "1" * 64) + assert_equal(context.actor.value().copy().role, "seller") + assert_equal(context.workspace_id.value(), "2" * 64) + assert_true(not context.farm_id) + assert_true(not context.actor.value().copy().organization) + assert_true(not context.actor.value().copy().grant_id) + # A parsed descriptor does not populate legacy actor authority. + assert_equal(context.actor_id, "") + + +def test_c004_v3_rejects_old_authority_and_model_fields() raises: + var base = _v3_request() + var mutations = List[String]() + mutations.append( + base.replace('"workspace_id":', '"farm_id":"old", "workspace_id":') + ) + mutations.append( + base.replace('"workspace_id":', '"actor_id":"old", "workspace_id":') + ) + mutations.append( + base.replace('"workspace_id":', '"pool_id":"private", "workspace_id":') + ) + mutations.append(base.replace('"jev-1.14.0"', '"jev-1.13.0"')) + mutations.append(base.replace('"jev-1.14.0"', '"jev-latest"')) + mutations.append(base.replace('"jev-1.14.0"', '"clef"')) + mutations.append(base.replace('"role":"seller"', '"role":"admin"')) + mutations.append(base.replace('"role":"seller"', '"role":true')) + mutations.append(base.replace('"organization":null,', "")) + mutations.append(base.replace('"grant_id":null', '"grant_id":0')) + mutations.append(base.replace('"grant_id":null', '"grant_id":"invalid"')) + mutations.append( + base.replace('"role":"seller"', '"role":"seller","authenticated":true') + ) + mutations.append( + base.replace('"participant":', '"participant":null,"participant":') + ) + mutations.append( + base.replace('"workspace_id":', '"deadline_ms":true,"workspace_id":') + ) + mutations.append( + base.replace( + '"workspace_id":', '"deadline_ms":2147483648,"workspace_id":' + ) + ) + mutations.append( + base.replace('"workspace_id":', '"deadline_ms":0,"workspace_id":') + ) + mutations.append( + base.replace( + '"schema":"hyf_ops_v3"', + '"schema":"hyf_ops_v3","schema":"hyf_ops_v2"', + ) + ) + mutations.append( + base.replace( + '"request_id":"v3-test"', '"request_id":"a","request_id":"b"' + ) + ) + for line in mutations: + assert_true(_decode_error_message(line) != "", line) + + +def test_c004_v3_identity_is_full_lowercase_ascii_hex() raises: + var base = _v3_request() + var invalid = List[String]() + invalid.append("1" * 63) + invalid.append("1" * 65) + invalid.append("A" * 64) + invalid.append("z" * 64) + invalid.append(" " * 64) + invalid.append("1" * 63 + "é") + for identity in invalid: + assert_true( + _decode_error_message(base.replace("1" * 64, identity)) != "" + ) + assert_true( + _decode_error_message(base.replace("2" * 64, identity)) != "" + ) + + +def test_c004_v3_time_matches_shared_unix_seconds_without_wire_aliases() raises: + var base = _v3_request() + for value in ["0", "1", "253402300799"]: + var request = decode_request(base.replace("1793016000", String(value))) + assert_equal( + request.operation_context.value().copy().evaluation_time, value + ) + for value in [ + "253402300800", + "999999999999", + "1000000000000", + "-0", + "-1", + "+1", + "01", + "1.0", + "1e3", + "1 ", + "2026-10-26T12:00:00+00:00", + ]: + assert_true( + _decode_error_message(base.replace("1793016000", String(value))) + != "" + ) + + +def test_c004_v3_real_route_keeps_all_operations_closed_before_activation() raises: + with SafeTempDir() as temp_dir: + var runtime_context = _temp_runtime_context(temp_dir) + runtime_context.config.effective.runtime.enable_farm_update_interpret = ( + True + ) + runtime_context.config.effective.runtime.enable_buyer_request_interpret = ( + True + ) + runtime_context.config.effective.runtime.enable_buyer_request_match = ( + True + ) + var observer = RecordingDispatchAttemptObserver(attempts=List[String]()) + for capability in [ + "farm_update.interpret", + "buyer_request.interpret", + "buyer_request.match", + ]: + var response = loads( + handle_request_line_with_runtime_context_and_observer( + _v3_request(String(capability)), runtime_context, observer + ) + ) + assert_equal(response["ok"].bool_value(), False) + assert_equal(response["request_id"].string_value(), "v3-test") + assert_equal(response["trace_id"].string_value(), "v3-trace") + assert_equal( + response["error"]["code"].string_value(), + "capability_unavailable", + ) + assert_true(not _has_key(response, "output")) + assert_equal(len(observer.attempts), 0)