160 lines
8.4 KiB
JSON
160 lines
8.4 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://go-sip.local/contracts/proposals/call-result-v0.1-proposal.schema.json",
|
|
"title": "Project-local contract: single final call.result event; external compatibility unverified",
|
|
"$comment": "Project-local contract derived from docs/thirds/第三方对接事件与请求消费顺序_v0.1.md; not the published MQ v2 contract. Runtime caps each serialized UTF-8 JSON body at 8,388,608 bytes, without compression, truncation, or event splitting. Expected recording finalizes no later than call.ended_at + 15m; at most one PUT per upload_id and one immutable call.result event.",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["schema_version", "event_id", "event_type", "dispatcher_id", "tenant_id", "tenant_key", "trace_id", "occurred_at", "aggregate_type", "aggregate_id", "aggregate_version", "payload"],
|
|
"properties": {
|
|
"schema_version": {"const": "call-result.v0.1-proposal"},
|
|
"event_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"event_type": {"const": "call.result"},
|
|
"dispatcher_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/dispatcherId"},
|
|
"tenant_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"tenant_key": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/tenantKey"},
|
|
"trace_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"occurred_at": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/time"},
|
|
"aggregate_type": {"const": "call"},
|
|
"aggregate_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"aggregate_version": {"type": "integer", "minimum": 1},
|
|
"payload": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["source_command_id", "execution_id", "call_id", "task_id", "task_revision", "agent_version_id", "route_policy_id", "caller_profile_id", "callee", "trunk_id", "started_at", "ended_at", "duration_ms", "outcome", "reason_code", "transcript", "opt_out", "recording"],
|
|
"properties": {
|
|
"source_command_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"execution_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"call_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"task_id": {"$ref": "#/$defs/task_id"},
|
|
"task_revision": {"type": "integer", "minimum": 1},
|
|
"agent_version_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"route_policy_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"caller_profile_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"callee": {"type": "string", "minLength": 1},
|
|
"trunk_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"started_at": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/time"},
|
|
"ended_at": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/time"},
|
|
"duration_ms": {"type": "integer", "minimum": 0},
|
|
"outcome": {"type": "string", "minLength": 1},
|
|
"reason_code": {"type": ["string", "null"], "minLength": 1},
|
|
"transcript": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["turn_id", "segment_id", "role", "text", "start_ms", "end_ms"],
|
|
"properties": {
|
|
"turn_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"segment_id": {"$ref": "https://go-sip.local/contracts/v1/mq.schema.json#/$defs/id"},
|
|
"role": {"type": "string", "minLength": 1},
|
|
"text": {"type": "string"},
|
|
"start_ms": {"type": "integer", "minimum": 0},
|
|
"end_ms": {"type": "integer", "minimum": 0}
|
|
}
|
|
}
|
|
},
|
|
"opt_out": {"type": "boolean"},
|
|
"recording": {
|
|
"oneOf": [
|
|
{"$ref": "#/$defs/recording_uploaded"},
|
|
{"$ref": "#/$defs/recording_unavailable"},
|
|
{"$ref": "#/$defs/recording_not_created"}
|
|
]
|
|
}
|
|
},
|
|
"$comment": "aggregate_id must equal payload.call_id; timestamps and duration must agree. Runtime enforces the 8 MiB serialized-body budget. If too large, retain the exact result in durable outbox and expose blocked_payload_too_large; never truncate, split, or discard it."
|
|
}
|
|
},
|
|
"$defs": {
|
|
"task_id": {"type": "string", "pattern": "^[A-Za-z0-9_-]{1,128}$"},
|
|
"recording_asset_fields": {
|
|
"type": "object",
|
|
"required": ["recording_id", "upload_id", "bucket", "object_key", "format", "channels", "sample_rate_hz", "duration_ms", "size_bytes", "checksum_sha256"],
|
|
"properties": {
|
|
"recording_id": {"type": ["string", "null"], "minLength": 1},
|
|
"upload_id": {"type": ["string", "null"], "minLength": 1},
|
|
"bucket": {"type": ["string", "null"], "minLength": 1},
|
|
"object_key": {"type": ["string", "null"], "minLength": 1},
|
|
"format": {"type": ["string", "null"], "minLength": 1},
|
|
"channels": {"type": ["integer", "null"], "minimum": 1},
|
|
"sample_rate_hz": {"type": ["integer", "null"], "minimum": 1},
|
|
"duration_ms": {"type": ["integer", "null"], "minimum": 0},
|
|
"size_bytes": {"type": ["integer", "null"], "minimum": 0},
|
|
"checksum_sha256": {"type": ["string", "null"], "pattern": "^[a-f0-9]{64}$"}
|
|
}
|
|
},
|
|
"recording_uploaded": {
|
|
"allOf": [
|
|
{"$ref": "#/$defs/recording_asset_fields"},
|
|
{
|
|
"type": "object",
|
|
"required": ["status"],
|
|
"properties": {
|
|
"status": {"const": "uploaded"},
|
|
"recording_id": {"type": "string", "minLength": 1},
|
|
"upload_id": {"type": "string", "minLength": 1},
|
|
"bucket": {"type": "string", "minLength": 1},
|
|
"object_key": {"type": "string", "minLength": 1},
|
|
"format": {"type": "string", "minLength": 1},
|
|
"channels": {"type": "integer", "minimum": 1},
|
|
"sample_rate_hz": {"type": "integer", "minimum": 1},
|
|
"duration_ms": {"type": "integer", "minimum": 0},
|
|
"size_bytes": {"type": "integer", "minimum": 0},
|
|
"checksum_sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
|
|
}
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"recording_unavailable": {
|
|
"allOf": [
|
|
{"$ref": "#/$defs/recording_asset_fields"},
|
|
{
|
|
"type": "object",
|
|
"required": ["status", "error_code"],
|
|
"properties": {
|
|
"status": {"const": "unavailable"},
|
|
"error_code": {"enum": ["upload_authorization_failed", "upload_authorization_expired", "upload_failed", "upload_timeout", "deadline_exceeded", "checksum_mismatch"]},
|
|
"recording_id": {"type": "string", "minLength": 1},
|
|
"upload_id": {"type": "string", "minLength": 1},
|
|
"bucket": {"type": "null"},
|
|
"object_key": {"type": "null"},
|
|
"format": {"type": "string", "minLength": 1},
|
|
"channels": {"type": "integer", "minimum": 1},
|
|
"sample_rate_hz": {"type": "integer", "minimum": 1},
|
|
"duration_ms": {"type": "integer", "minimum": 0},
|
|
"size_bytes": {"type": "null"},
|
|
"checksum_sha256": {"type": "null"}
|
|
}
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
},
|
|
"recording_not_created": {
|
|
"allOf": [
|
|
{"$ref": "#/$defs/recording_asset_fields"},
|
|
{
|
|
"type": "object",
|
|
"required": ["status", "reason_code"],
|
|
"properties": {
|
|
"status": {"const": "not_created"},
|
|
"reason_code": {"type": "string", "pattern": "^[a-z][a-z0-9_]{0,63}$"},
|
|
"recording_id": {"type": "null"},
|
|
"upload_id": {"type": "null"},
|
|
"bucket": {"type": "null"},
|
|
"object_key": {"type": "null"},
|
|
"format": {"type": "null"},
|
|
"channels": {"type": "null"},
|
|
"sample_rate_hz": {"type": "null"},
|
|
"duration_ms": {"type": "null"},
|
|
"size_bytes": {"type": "null"},
|
|
"checksum_sha256": {"type": "null"}
|
|
}
|
|
}
|
|
],
|
|
"unevaluatedProperties": false
|
|
}
|
|
}
|
|
}
|