|
| 1 | +{ |
| 2 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 3 | + "$id": "https://babelqueue.com/contracts/message-envelope.schema.json", |
| 4 | + "title": "BabelQueueMessageEnvelope", |
| 5 | + "description": "The canonical, language-agnostic BabelQueue wire envelope (schema_version 1). This schema is authoritative alongside contracts/message-envelope.md.", |
| 6 | + "type": "object", |
| 7 | + "additionalProperties": true, |
| 8 | + "required": ["job", "trace_id", "data", "meta", "attempts"], |
| 9 | + "properties": { |
| 10 | + "job": { |
| 11 | + "type": "string", |
| 12 | + "minLength": 1, |
| 13 | + "description": "The message URN — language-agnostic identity. Canonical producer field name. Consumers also accept 'urn' as an inbound alias. Never a class name.", |
| 14 | + "examples": ["urn:babel:orders:created", "urn:babel:orders:invoice.requested"] |
| 15 | + }, |
| 16 | + "urn": { |
| 17 | + "type": "string", |
| 18 | + "minLength": 1, |
| 19 | + "description": "Inbound alias for 'job'. Accepted by consumers for interoperability; producers SHOULD emit 'job'." |
| 20 | + }, |
| 21 | + "trace_id": { |
| 22 | + "type": "string", |
| 23 | + "format": "uuid", |
| 24 | + "description": "Cross-service correlation id. Generated by the first producer, preserved and forwarded unchanged by every SDK across every hop." |
| 25 | + }, |
| 26 | + "data": { |
| 27 | + "type": "object", |
| 28 | + "description": "Pure, JSON-encodable business payload. No language-specific types. Numbers/time/binary per contracts/message-envelope.md section 6.", |
| 29 | + "additionalProperties": true |
| 30 | + }, |
| 31 | + "meta": { |
| 32 | + "type": "object", |
| 33 | + "description": "Producer-set, immutable descriptive metadata.", |
| 34 | + "additionalProperties": true, |
| 35 | + "required": ["id", "queue", "lang", "schema_version", "created_at"], |
| 36 | + "properties": { |
| 37 | + "id": { |
| 38 | + "type": "string", |
| 39 | + "format": "uuid", |
| 40 | + "description": "Unique id for THIS message (distinct from trace_id)." |
| 41 | + }, |
| 42 | + "queue": { |
| 43 | + "type": "string", |
| 44 | + "minLength": 1, |
| 45 | + "description": "Logical queue name (not the broker key)." |
| 46 | + }, |
| 47 | + "lang": { |
| 48 | + "type": "string", |
| 49 | + "enum": ["php", "go", "python", "java", "dotnet", "node"], |
| 50 | + "description": "Producer language tag." |
| 51 | + }, |
| 52 | + "schema_version": { |
| 53 | + "type": "integer", |
| 54 | + "const": 1, |
| 55 | + "description": "Envelope schema version. Consumers MUST reject versions they do not support." |
| 56 | + }, |
| 57 | + "created_at": { |
| 58 | + "type": "integer", |
| 59 | + "minimum": 0, |
| 60 | + "description": "Production time as Unix epoch MILLISECONDS, UTC." |
| 61 | + } |
| 62 | + } |
| 63 | + }, |
| 64 | + "attempts": { |
| 65 | + "type": "integer", |
| 66 | + "minimum": 0, |
| 67 | + "description": "Top-level transport retry counter, mutated by the broker/worker. Deliberately kept OUT of the immutable meta block." |
| 68 | + }, |
| 69 | + "dead_letter": { |
| 70 | + "type": "object", |
| 71 | + "description": "Optional. Present ONLY on messages sitting on a dead-letter queue (ADR-0009). Additive, so it does not change schema_version. Normal consumers ignore it.", |
| 72 | + "additionalProperties": true, |
| 73 | + "required": ["reason", "failed_at", "original_queue", "attempts"], |
| 74 | + "properties": { |
| 75 | + "reason": { |
| 76 | + "type": "string", |
| 77 | + "enum": ["failed", "unknown_urn", "poison"], |
| 78 | + "description": "Why the message was dead-lettered." |
| 79 | + }, |
| 80 | + "error": { |
| 81 | + "type": ["string", "null"], |
| 82 | + "description": "Human-readable error message, if any." |
| 83 | + }, |
| 84 | + "exception": { |
| 85 | + "type": ["string", "null"], |
| 86 | + "description": "Producer-language exception/type name, if any (informational, language-specific)." |
| 87 | + }, |
| 88 | + "failed_at": { |
| 89 | + "type": "integer", |
| 90 | + "minimum": 0, |
| 91 | + "description": "Dead-letter time as Unix epoch milliseconds, UTC." |
| 92 | + }, |
| 93 | + "original_queue": { |
| 94 | + "type": "string", |
| 95 | + "description": "The queue the message was consumed from before dead-lettering." |
| 96 | + }, |
| 97 | + "attempts": { |
| 98 | + "type": "integer", |
| 99 | + "minimum": 0, |
| 100 | + "description": "Delivery attempts made before dead-lettering." |
| 101 | + }, |
| 102 | + "lang": { |
| 103 | + "type": "string", |
| 104 | + "enum": ["php", "go", "python", "java", "dotnet", "node"], |
| 105 | + "description": "Language of the SDK that dead-lettered the message." |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | +} |
0 commit comments