hyf

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

buyer_request_interpret.request.schema.json (8488B)


      1 {
      2   "$schema": "https://json-schema.org/draft/2020-12/schema",
      3   "$id": "hyf_ops_v2/buyer_request_interpret.request.schema.json",
      4   "title": "hyf_ops_v2 buyer_request.interpret strict request (ADR-0025 D45 CB01-CB04)",
      5   "$comment": "Corrected versioned operation contract. Buyer operations never require a fabricated farm identity; context farm_id is forbidden and the trusted buyer principal is context.actor_id.",
      6   "type": "object",
      7   "properties": {
      8     "version": {
      9       "type": "integer",
     10       "const": 1
     11     },
     12     "request_id": {
     13       "type": "string",
     14       "minLength": 1
     15     },
     16     "trace_id": {
     17       "type": "string",
     18       "minLength": 1
     19     },
     20     "capability": {
     21       "type": "string",
     22       "const": "buyer_request.interpret"
     23     },
     24     "context": {
     25       "$ref": "#/$defs/buyer_context"
     26     },
     27     "input": {
     28       "$ref": "#/$defs/buyer_interpret_input"
     29     }
     30   },
     31   "required": ["version", "request_id", "capability", "context", "input"],
     32   "additionalProperties": false,
     33   "$defs": {
     34     "versions": {
     35       "type": "object",
     36       "properties": {
     37         "schema": {"type": "string", "const": "hyf_ops_v2"},
     38         "taxonomy": {"type": "string", "minLength": 1},
     39         "normalization": {"type": "string", "minLength": 1},
     40         "review_policy": {"type": "string", "minLength": 1},
     41         "ranking_policy": {"type": "string", "minLength": 1},
     42         "question_bundle": {"type": "string", "minLength": 1},
     43         "model": {"type": "string", "minLength": 1}
     44       },
     45       "required": [
     46         "schema",
     47         "taxonomy",
     48         "normalization",
     49         "review_policy",
     50         "ranking_policy",
     51         "question_bundle",
     52         "model"
     53       ],
     54       "additionalProperties": false
     55     },
     56     "buyer_context": {
     57       "type": "object",
     58       "properties": {
     59         "consumer": {"type": "string", "minLength": 1},
     60         "execution_mode_preference": {
     61           "type": "string",
     62           "enum": ["deterministic", "assisted"]
     63         },
     64         "deadline_ms": {"type": "integer", "minimum": 1},
     65         "evaluation_time": {"type": "string", "minLength": 1},
     66         "timezone": {"type": "string", "minLength": 1},
     67         "locale": {"type": "string", "minLength": 1},
     68         "versions": {"$ref": "#/$defs/versions"},
     69         "return_provenance": {"type": "boolean"},
     70         "actor_id": {"type": "string", "minLength": 1}
     71       },
     72       "required": ["evaluation_time", "versions", "actor_id"],
     73       "additionalProperties": false
     74     },
     75     "interpretation_source_buyer": {
     76       "type": "object",
     77       "properties": {
     78         "source_id": {"type": "string", "minLength": 1},
     79         "revision": {"type": "string", "minLength": 1},
     80         "text": {"type": "string", "minLength": 1},
     81         "source_time": {"type": "string", "minLength": 1},
     82         "timezone": {"type": "string", "minLength": 1},
     83         "locale": {"type": "string", "minLength": 1},
     84         "actor_id": {"type": "string", "minLength": 1},
     85         "ingestion_time": {"type": "string", "minLength": 1}
     86       },
     87       "required": [
     88         "source_id",
     89         "revision",
     90         "text",
     91         "source_time",
     92         "actor_id"
     93       ],
     94       "additionalProperties": false
     95     },
     96     "reported_quantity": {
     97       "type": "object",
     98       "properties": {
     99         "state": {"type": "string", "enum": ["known", "unknown"]},
    100         "value": {
    101           "type": ["string", "null"],
    102           "pattern": "^-?(0|[1-9][0-9]*)(\\.[0-9]{1,9})?$"
    103         },
    104         "unit": {"type": ["string", "null"], "minLength": 1},
    105         "qualifier": {"type": "string", "enum": ["exact", "approximate"]}
    106       },
    107       "required": ["state", "qualifier"],
    108       "additionalProperties": false,
    109       "allOf": [
    110         {
    111           "if": {
    112             "properties": {"state": {"const": "unknown"}},
    113             "required": ["state"]
    114           },
    115           "then": {
    116             "properties": {"value": {"type": "null"}, "unit": {"type": "null"}}
    117           }
    118         },
    119         {
    120           "if": {
    121             "properties": {"state": {"const": "known"}},
    122             "required": ["state"]
    123           },
    124           "then": {
    125             "properties": {
    126               "value": {
    127                 "type": "string",
    128                 "pattern": "^-?(0|[1-9][0-9]*)(\\.[0-9]{1,9})?$"
    129               },
    130               "unit": {"type": "string", "minLength": 1}
    131             },
    132             "required": ["value", "unit"]
    133           }
    134         }
    135       ]
    136     },
    137     "taxonomy_bundle": {
    138       "type": "object",
    139       "properties": {
    140         "version": {"type": "string", "minLength": 1},
    141         "provenance": {"type": "string", "enum": ["synthetic", "host_supplied"]},
    142         "products": {
    143           "type": "array",
    144           "items": {
    145             "type": "object",
    146             "properties": {
    147               "catalogue_id": {"type": "string", "minLength": 1},
    148               "terms": {
    149                 "type": "array",
    150                 "minItems": 1,
    151                 "items": {"type": "string", "minLength": 1}
    152               }
    153             },
    154             "required": ["catalogue_id", "terms"],
    155             "additionalProperties": false
    156           }
    157         }
    158       },
    159       "required": ["version", "provenance", "products"],
    160       "additionalProperties": false
    161     },
    162     "normalization_bundle": {
    163       "type": "object",
    164       "properties": {
    165         "version": {"type": "string", "minLength": 1},
    166         "provenance": {"type": "string", "enum": ["synthetic", "host_supplied"]},
    167         "units": {
    168           "type": "array",
    169           "items": {
    170             "type": "object",
    171             "properties": {
    172               "unit": {"type": "string", "minLength": 1},
    173               "dimension": {
    174                 "type": "string",
    175                 "enum": ["mass", "volume", "count", "unknown"]
    176               }
    177             },
    178             "required": ["unit", "dimension"],
    179             "additionalProperties": false
    180           }
    181         },
    182         "conversions": {
    183           "type": "array",
    184           "items": {
    185             "type": "object",
    186             "properties": {
    187               "from_unit": {"type": "string", "minLength": 1},
    188               "to_unit": {"type": "string", "minLength": 1},
    189               "numerator": {"type": "string", "pattern": "^[1-9][0-9]*$"},
    190               "denominator": {"type": "string", "pattern": "^10*$"}
    191             },
    192             "required": ["from_unit", "to_unit", "numerator", "denominator"],
    193             "additionalProperties": false
    194           }
    195         },
    196         "packs": {
    197           "type": "array",
    198           "items": {
    199             "type": "object",
    200             "properties": {
    201               "product_id": {"type": "string", "minLength": 1},
    202               "pack_unit": {"type": "string", "minLength": 1},
    203               "inner_unit": {"type": "string", "minLength": 1},
    204               "value": {
    205                 "type": "string",
    206                 "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]{1,9})?$",
    207                 "allOf": [
    208                   {"not": {"const": "0"}},
    209                   {"not": {"pattern": "^0(\\.0+)?$"}}
    210                 ]
    211               }
    212             },
    213             "required": ["product_id", "pack_unit", "inner_unit", "value"],
    214             "additionalProperties": false
    215           }
    216         }
    217       },
    218       "required": ["version", "provenance", "units", "conversions", "packs"],
    219       "additionalProperties": false
    220     },
    221     "references": {
    222       "type": "object",
    223       "properties": {
    224         "taxonomy": {"$ref": "#/$defs/taxonomy_bundle"},
    225         "normalization": {"$ref": "#/$defs/normalization_bundle"}
    226       },
    227       "required": ["taxonomy", "normalization"],
    228       "additionalProperties": false
    229     },
    230     "clarification": {
    231       "type": "object",
    232       "properties": {
    233         "source_id": {"type": "string", "minLength": 1},
    234         "revision": {"type": "string", "minLength": 1},
    235         "target_field": {"type": "string", "minLength": 1},
    236         "text": {"type": "string", "minLength": 1},
    237         "expected_revision": {"type": "string", "minLength": 1}
    238       },
    239       "required": ["source_id", "revision", "target_field", "text", "expected_revision"],
    240       "additionalProperties": false
    241     },
    242     "buyer_interpret_input": {
    243       "type": "object",
    244       "properties": {
    245         "source": {"$ref": "#/$defs/interpretation_source_buyer"},
    246         "references": {"$ref": "#/$defs/references"},
    247         "clarification": {"$ref": "#/$defs/clarification"}
    248       },
    249       "required": ["source", "references"],
    250       "additionalProperties": false
    251     }
    252   }
    253 }