File size: 3,351 Bytes
e1ced61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://explicit-learning.local/schemas/compiled_program.schema.json",
  "title": "Canonical executable question program proposal",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "compile_id",
    "base_id",
    "compiler_role",
    "model",
    "question_sha256",
    "choices_sha256",
    "compile_status"
  ],
  "properties": {
    "schema_version": {"const": 1},
    "compile_id": {"$ref": "#/$defs/sha256"},
    "base_id": {"$ref": "#/$defs/sha256"},
    "compiler_role": {
      "type": "string",
      "enum": ["program_proposer", "independent_program_verifier"]
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repo_id", "revision"],
      "properties": {
        "repo_id": {"type": "string", "minLength": 3},
        "revision": {"type": "string", "pattern": "^[a-f0-9]{40}$"}
      }
    },
    "question_sha256": {"$ref": "#/$defs/sha256"},
    "choices_sha256": {"$ref": "#/$defs/sha256"},
    "compile_status": {
      "type": "string",
      "enum": ["compiled", "unsupported", "invalid_response"]
    },
    "dsl": {
      "type": "string",
      "enum": ["plotqa_dsl_v1", "geometry_dsl_v1", "table_dsl_v1", "clevr_dsl_v1"]
    },
    "program": {"$ref": "#/$defs/astNode"},
    "referent_selector": {
      "oneOf": [{"$ref": "#/$defs/astNode"}, {"type": "null"}]
    },
    "required_referent_cardinality": {
      "type": ["integer", "null"],
      "minimum": 0
    },
    "referenced_node_ids": {
      "type": "array",
      "items": {"type": "string", "minLength": 1},
      "uniqueItems": true
    },
    "canonical_program_sha256": {
      "anyOf": [{"$ref": "#/$defs/sha256"}, {"type": "null"}]
    },
    "reason_code": {"type": ["string", "null"]},
    "request_sha256": {"$ref": "#/$defs/sha256"},
    "response_sha256": {"$ref": "#/$defs/sha256"},
    "parse_status": {
      "type": "string",
      "enum": ["valid_first_response", "valid_after_one_repair", "invalid"]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {"compile_status": {"const": "compiled"}},
        "required": ["compile_status"]
      },
      "then": {
        "required": [
          "dsl",
          "program",
          "referent_selector",
          "required_referent_cardinality",
          "referenced_node_ids",
          "canonical_program_sha256"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "compile_status": {"enum": ["unsupported", "invalid_response"]}
        },
        "required": ["compile_status"]
      },
      "then": {
        "required": ["reason_code"]
      }
    }
  ],
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "astNode": {
      "type": "object",
      "additionalProperties": false,
      "required": ["op", "args"],
      "properties": {
        "op": {"type": "string", "minLength": 1},
        "args": {
          "type": "array",
          "items": {
            "oneOf": [
              {"$ref": "#/$defs/astNode"},
              {"type": "string"},
              {"type": "number"},
              {"type": "boolean"}
            ]
          }
        },
        "return_type": {"type": "string", "minLength": 1}
      }
    }
  }
}