Message Envelope and Payload Design#
1. Purpose#
This document defines the relationship between the message envelope and the message payload for the observatory Instrument Control System (ICS) messaging protocol.
The goal is to keep messages structured, traceable, and easy to parse while avoiding unnecessary duplication between routing metadata and command/status content.
2. Design Principle#
A message is divided into two parts:
message envelope = protocol metadata
message payload = command, status, telemetry, or result content
The envelope answers:
Who sent this?
Who should receive it?
What kind of message is this?
What command, keyword, topic, or resource is this about?
How should this message be delivered?
How do we correlate it with other messages?
The payload answers:
What value, command parameters, result, status, or error is being reported?
The payload should not duplicate fields that already exist in the envelope unless the message contains a batch, wildcard, compound response, or delegated/proxy response.
3. Message Envelope#
Every protocol message shall use a common envelope.
3.1 Envelope Fields#
Field |
Type |
Required |
Meaning |
|---|---|---|---|
|
integer |
yes |
Protocol/envelope version. |
|
string |
yes |
Message type, such as |
|
string |
yes |
Transaction ID used to correlate requests, acknowledgements, responses, events, and logs. |
|
string |
yes |
Semantic key identifying the command, keyword, telemetry topic, status topic, or resource. |
|
string |
yes |
Identity of the sending node. |
|
string or null |
no |
Identity of the receiving node; null for broadcast or publish/subscribe messages. |
|
number |
yes |
Unix epoch timestamp for when the message was created. |
|
integer |
no |
Delivery expectation. Example: |
|
string |
no |
Human-readable delivery policy, such as |
|
object |
yes |
Message-specific content. |
|
object or null |
no |
Optional binary data reference or attachment metadata. |
4. Message Types#
Type |
Meaning |
|---|---|
|
Request a command, read, write, or query. |
|
Acknowledge that a request was received and accepted for processing. |
|
Final successful response to a request. |
|
Rejection or failure response. |
|
Publish status, telemetry, event, or progress information. |
|
Subscribe to a topic or key, if supported by the transport/profile. |
|
Node introduction or handshake. |
|
Periodic liveness message. |
|
Configuration exchange or update. |
5. Envelope vs. Payload#
The envelope should contain routing, identity, correlation, and protocol metadata.
The payload should contain only the value, command parameters, result, status, or error content.
6. Standard Single-Value Payload#
TODO
8. Batch or Compound Payloads#
TODO
9. Command Request Payload#
TODO
9.1 Keyword Request Example#
TODO
10. Command ACK Payload#
For long-running commands, a daemon may send an ACK quickly after accepting the command.
The ACK means:
I received the command, validated it, and accepted responsibility for executing it.
Example TODO
Full message TODO
11. Command Response Payload#
For most commands, the final RESP is the command completion result.
Example TODO
12. Command Failure Payload#
Rejected or failed commands should use msg_type: ERROR and the standard payload shape.
Example rejected command TODO
Example failed command after acceptance TODO
13. Progress / Status Event Payload#
For long-running commands, daemons may publish progress or status events using msg_type: PUB and the same trans_id as the original command.
Example TODO
Progress events are informational. They do not replace the final RESP or ERROR.
14. Daemon Status Payload#
Daemon status messages may be compound values.
Example TODO
15. Cancel Command Payload#
Cancellation shall use the normal command envelope. The cancel request gets its own trans_id and references the command being cancelled.
Example TODO
16. Naming Rules#
Recommended naming pattern for key:
<domain>.<subsystem>.<resource-or-command>
Examples:
instrument.focus.position
instrument.focus.move
instrument.camera.expose
instrument.camera.status
instrument.slit.width
instrument.slit.move
sequencer.sequence.progress
daemon.health
observatory.weather.status
Guidelines:
Use stable names.
Prefer lowercase names.
Use dot-separated hierarchy.
Avoid transport-specific names.
Keep command keys and telemetry keys distinct where useful.
Do not put routing information in the key if
src_idanddest_idalready provide it.
17. Summary Rules#
The envelope carries protocol metadata.
The payload carries value, command, status, result, or error content.
Use
ACKonly when a command is accepted but not yet complete.Use
RESPfor the final successful result.Use
ERRORfor rejected or failed commands.