Skip to content

dispatch

diapason.mesh.dispatch

Sending a command, and telling the truth about what happened.

This is the layer the assistant talks to. It brings together the registry (who), presence (is it there), the tool catalogue (is this allowed), the queue (durability) and the transport (how) — and it is deliberately the only place that decides what the user is told.

The rule it exists to keep is spec §57, restated as code: a command that was merely queued must never be reported as done. Each terminal status carries a French sentence that is true of that status and no other.

dispatch_command(*, target_device_id, tool, arguments=None, registry=None, queue=None, idempotency_key='', transport=None)

Send tool to target_device_id, or explain precisely why not.

flush_pending(*, registry=None, queue=None, transport=None, limit_per_device=20)

Deliver what is waiting for devices that have come back.

This is the half of « partira dès son retour » that makes the sentence true. Without it that message is a promise nobody keeps: a command for a laptop that was asleep sits QUEUED until it expires, and the user was told it would arrive.

Only push devices are drained here. A polling device fetches its own, and delivering to it twice is not a courtesy — it is the same command arriving on two paths.

Never raises: this runs on a timer, and a peer that cannot be reached is the normal state of a fleet whose devices come and go.

receive_command(raw, *, registry=None, queue=None, nonces=None, executor=None)

Verify an inbound command and run it. The far end of the wire.