The Session
The context everything after admission happens in: one bidirectional stream per admitted unit.
| From | To | When |
|---|---|---|
| admitted | open | the first envelope is a session OPEN carrying the identity admission issued |
| admitted | — | the unit dies before connecting; this stays distinguishable from a refusal |
| open | closed | session CLOSE, sent by the unit: a departure |
| open | revoked | session REVOKED, sent by the Core: an eviction |
| open | lost | the transport fails |
| lost | revoked | the heartbeat terms are exceeded |
Identity
- The Core generates the Session identity. A unit never proposes one.
- It is used once. A Session that has ended cannot be reopened; recovery is a new admission.
- An incarnation holds at most one Session, because its token is single-use.
- The Session identity is a secret and is not guessable; the incarnation is a counter for a person reading a log. Both are kept.
Validity
Validity is a condition a Session keeps satisfying, and the Core judges it.
| It persists while |
|---|
| health reports arrive within the assigned terms |
| behaviour stays within the granted scope |
| nothing has revoked it |
- A unit cannot assess its own Session. It observes consequences: a revocation, a closed stream, a refused message.
- A working connection is not evidence of validity. A unit can be connected and reporting into a Session that was already revoked.
- Traffic on an invalid Session is never processed as ordinary traffic.
Opening and closing
- The first envelope must be a session
OPENcarrying the identity admission issued. Anything else closes the stream. - An identity that was never issued, is already used, or belongs to an ended Session resolves to nothing, and the stream closes.
CLOSEis the unit's andREVOKEDis the Core's. Both end a Session and they are always told apart.- Losing the stream is not closing it. The Core acts when the heartbeat terms are exceeded. A unit that
intends to stop should send
CLOSE.
Revocation
The Core ends a Session on its own authority.
| Cause | What the unit can do next |
|---|---|
| liveness lost | be relaunched and admitted again |
| plugin disabled | nothing: it is refused at the gate while disabled |
| scope exceeded | nothing: it is a defect to report |
| protocol failure | nothing: further exchange was uninterpretable |
REVOKEDnames its cause and carries a line for a person.CLOSEcarries nothing.- A message outside the unit's scope is refused on its own, and the Session goes on. Revoking for a scope exceeded is for traffic a refusal cannot answer one message at a time: data on a stream nobody granted. The Core creates a stream's transport only for a granted stream and attributes what arrives by the transport, so such traffic has nowhere to arrive and no Session is revoked for that cause. The cause stays on the wire.
- Revocation is not a restart. Whether the process is relaunched is the supervisor's decision, taken when the process exits.
- A revocation by decision leaves the unit
Refused; one for lost liveness leaves itFailed.
The heartbeat terms
Set by the Core at admission and returned in the registration answer; never chosen by the unit.
| Term | Default |
|---|---|
| the interval | 10s |
| the tolerance | 3 missed intervals |
The Core acts after the tolerance is exceeded, not on the first miss.
The envelope
Every message of the Session, in both directions, carries four fields and exactly one payload.
| Field | Present | Holds |
|---|---|---|
| message identity | always | refers to this message; a repeat within a Session is refused |
| Session identity | always | what attributes the message |
| sender's clock | always | when it was sent, for a person reading a trail |
| correlation identity | where it answers another message | which message it answers |
- The plugin, unit and incarnation are resolved from the Session, never restated on a message.
- The timestamp is never a validity check and never orders processing.
- Absent by design: a family field (the payload is the family), a protocol version (fixed at admission), a sequence number (the stream is ordered), a credential (the Session identity is the proof).
- Never zero payloads and never two.
Correlation
A message that responds is correlated; a message that reports is not.
| Family | Correlated |
|---|---|
| ack, query answer | always |
| error | when the failure is attributable to a message |
| data, health, event, session | never |
- A correlation refers only within its own Session.
- A correlation is never the message's own identity.
- An acknowledgement with no correlation is refused. It is never matched by guessing.
Validation, in order
A receiver checks in this sequence and stops at the first failure.
| # | Check |
|---|---|
| 1 | structural: the message decodes, and no field exceeds its bound |
| 2 | Session resolution |
| 3 | validity |
| 4 | uniqueness of the message identity |
| 5 | direction: a family arriving from the side that may not send it is refused, whatever it contains |
| 6 | correlation, where the family requires it |
| 7 | semantics |
| Where the Session | The failure |
|---|---|
| can carry a response | is answered with an error, correlated to the offending message where one can be identified |
| cannot be resolved | is dropped and recorded on the Core's side |
A well-formed message can still be meaningless — data for a stream never granted, an acknowledgement for a command never issued. Structure and meaning are checked apart.