Files
ai-spel-rule-engine/contracts/rule-evaluation-v1.schema.json
T

77 lines
2.5 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://gitea.k3s.k0.nu/ai-spel/ai-spel-rule-engine/raw/tag/v0.1.5/contracts/rule-evaluation-v1.schema.json",
"title": "AI Spel Luau rule evaluation contract v1",
"type": "object",
"additionalProperties": false,
"required": ["contract_version", "correlation_id", "invocation"],
"properties": {
"contract_version": { "const": 1 },
"correlation_id": { "type": "string", "format": "uuid" },
"invocation": {
"type": "object",
"additionalProperties": false,
"required": ["rule_id", "rule_version", "source", "snapshot"],
"properties": {
"rule_id": { "type": "string", "format": "uuid" },
"rule_version": { "type": "integer", "minimum": 1 },
"source": { "type": "string", "maxLength": 16384 },
"snapshot": {
"type": "object",
"additionalProperties": false,
"required": ["world_id", "version", "world_time", "facts"],
"properties": {
"world_id": { "type": "string", "format": "uuid" },
"version": { "type": "integer" },
"world_time": { "type": "integer" },
"facts": { "type": "object" }
}
}
}
}
},
"$defs": {
"effect": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "payload"],
"properties": {
"kind": { "type": "string", "minLength": 1, "maxLength": 64 },
"payload": { "type": "object" }
}
},
"response": {
"type": "object",
"additionalProperties": false,
"required": ["contract_version", "correlation_id", "outcome"],
"properties": {
"contract_version": { "const": 1 },
"correlation_id": { "type": "string", "format": "uuid" },
"outcome": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": ["status", "effects"],
"properties": {
"status": { "const": "evaluated" },
"effects": { "type": "array", "maxItems": 16, "items": { "$ref": "#/$defs/effect" } }
}
},
{
"type": "object",
"additionalProperties": false,
"required": ["status", "code", "detail"],
"properties": {
"status": { "const": "rejected" },
"code": { "type": "string" },
"detail": { "type": "string" }
}
}
]
}
}
}
}
}