Skip to content

Broken messages become rows

The physical worldMQTTDashboardLineCodecstrictcontract-violationMachines.genericCodec

Under a strict codec a message that breaks the contract is confirmed, never acted on, and shown to an operator as a row.

The situation

A machine vendor ships firmware that sends a malformed job event. Acting on half a message could move the wrong unit. Dropping it silently hides the fault until something downstream stalls.

The recipe

A codec translates the machines’ wire protocol into the gateway’s line protocol. Set strict: true:

start.ts
const codec: Machines.LineCodec = {
...Machines.genericCodec({ root: 'line/v1', receiptFrom: 'started' }),
strict: true,
};
await start({
// ...database, workers, roles
machines: { lines: [Machines.loadLine('/etc/line.json')], codec },
});
Codec A message with contract violations
strict: true Confirmed, never acted on; one contract-violation row on the operator role holds the raw message and the violations
default Known fields are acted on and the violations are logged

A person resolves the contract-violation row once the cause is understood. Unknown body fields are allowed; known ones are checked. Payloads may be up to 256 KB.

The guarantee

Under a strict codec, a message that breaks the contract never moves a unit or resolves a row. It is held for a person as a row in the operator’s queue, with the evidence attached, and the machine receives its receipt so it stops resending. See Machines.