76 lines
4.1 KiB
JSON
76 lines
4.1 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://go-sip.local/contracts/proposals/task-discovery-v0.4-proposal.schema.json",
|
|
"title": "Project-local restart snapshot and live assignment changes; SaaS compatibility unverified",
|
|
"oneOf": [
|
|
{"$ref": "#/$defs/snapshot_page"},
|
|
{"$ref": "#/$defs/change_page"},
|
|
{"$ref": "#/$defs/error_response"}
|
|
],
|
|
"$defs": {
|
|
"dispatcher_id": {
|
|
"type": "string", "format": "uuid",
|
|
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
},
|
|
"cursor": {
|
|
"type": "string", "pattern": "^(0|[1-9][0-9]{0,19})$",
|
|
"$comment": "Canonical decimal uint64 event ID per Dispatcher; semantic parsing enforces the uint64 maximum. Never derived from task_id or expires."
|
|
},
|
|
"task": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["task_id", "tenant_id", "tenant_key", "status", "task_revision"],
|
|
"properties": {
|
|
"task_id": {"type": "string", "pattern": "^[A-Za-z0-9_-]{1,128}$"},
|
|
"tenant_id": {"type": "string", "minLength": 1, "maxLength": 128},
|
|
"tenant_key": {"type": "string", "minLength": 1, "maxLength": 196,
|
|
"$comment": "Also enforce UTF-8 byte limit and tenant_id mapping in business logic."},
|
|
"status": {"enum": ["running", "paused", "stopped", "finished", "removed"]},
|
|
"task_revision": {"type": "integer", "minimum": 1}
|
|
},
|
|
"$comment": "Removed tombstones retain original task and tenant identity indefinitely. No per-item event_id or queue location."
|
|
},
|
|
"snapshot_page": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["schema_version", "mode", "dispatcher_id", "snapshot_id", "watermark", "next_page_token", "tasks"],
|
|
"properties": {
|
|
"schema_version": {"const": "task-discovery.v0.4-proposal"},
|
|
"mode": {"const": "snapshot"},
|
|
"dispatcher_id": {"$ref": "#/$defs/dispatcher_id"},
|
|
"snapshot_id": {"type": "string", "format": "uuid", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},
|
|
"watermark": {"$ref": "#/$defs/cursor"},
|
|
"next_page_token": {"type": ["string", "null"], "minLength": 1, "maxLength": 256},
|
|
"tasks": {"type": "array", "maxItems": 256, "items": {"$ref": "#/$defs/task"}}
|
|
},
|
|
"$comment": "Every page has identical snapshot_id and watermark; null next_page_token ends this consistent complete inventory. No task appears twice, and removed tasks are omitted only from the complete inventory. Server retains stopped tasks with not-yet-retired queues. Semantic client checks enforce consistency."
|
|
},
|
|
"change_page": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["schema_version", "mode", "dispatcher_id", "next_cursor", "tasks"],
|
|
"properties": {
|
|
"schema_version": {"const": "task-discovery.v0.4-proposal"},
|
|
"mode": {"const": "changes"},
|
|
"dispatcher_id": {"$ref": "#/$defs/dispatcher_id"},
|
|
"next_cursor": {"$ref": "#/$defs/cursor"},
|
|
"tasks": {"type": "array", "maxItems": 256, "items": {"$ref": "#/$defs/task"}}
|
|
},
|
|
"$comment": "Live-only event cursor; ordered complete event positions per dispatcher, no server expiry while the process is running. Removed tombstones are explicit; status values are not online control commands. A nonempty page advances the cursor, and an empty page repeats it."
|
|
},
|
|
"error_response": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["schema_version", "resource", "error"],
|
|
"properties": {
|
|
"schema_version": {"const": "task-discovery.v0.4-proposal"},
|
|
"resource": {"const": "error"},
|
|
"error": {
|
|
"type": "object", "additionalProperties": false,
|
|
"required": ["code", "message"],
|
|
"properties": {
|
|
"code": {"enum": ["invalid_request", "invalid_page_token", "snapshot_unavailable", "unauthorized", "dispatcher_not_authorized", "service_unavailable"]},
|
|
"message": {"type": "string", "minLength": 1, "maxLength": 256}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|