Skip to content

The assignment cursor

The assignment cursor is the four-revision record of where a node stands in its assignment stream. Its revisions record how far the node has read, how far that reading is on disk, how far the work has been acted on, and how far the control plane has confirmed. After a restart, each combination describes a different situation.

This page covers what each revision means, the order they are kept in, and what a given combination tells you about a node that has just come back. The record's validation contract and its refusal reasons are on Assignment cursor runtime.

The four revisions

last_seen_revision        the furthest the control plane has told the node about
last_persisted_revision   the furthest written to the node's volume
last_applied_revision     the furthest the node has acted on
last_acked_revision       the furthest the control plane has confirmed

Each belongs to a different actor. The control plane moves the first. The node's own write moves the second. Its work moves the third. The control plane's acknowledgement moves the fourth.

How they advance within one cycle

flowchart TB
  subgraph CYCLE["ONE RECONCILE CYCLE"]
    direction TB
    W["Watch returns a higher revision"]
    P["Persist the record"]
    A["Work the admitted assignments"]
    K["Report status and receive acknowledgement"]
  end
  S1[("last_seen")]
  S2[("last_persisted")]
  S3[("last_applied")]
  S4[("last_acked")]
  W --> S1
  P --> S2
  A --> S3
  K --> S4
  S1 -->|"bounds"| S2
  S2 -->|"bounds"| S3
  S2 -->|"bounds"| S4

Watch returns a higher revision is the only step that can raise the position at all, and Persist the record is the step that carries it past the process. The two bounds edges are the ordering invariants: no revision exceeds what has been seen and stored.

The order they are kept in

last_seen_revision      >= last_persisted_revision
last_persisted_revision >= last_applied_revision
last_persisted_revision >= last_acked_revision

Storage trails reading, and work and confirmation trail storage. A record that breaks any of the three is refused as a monotonicity violation, on load and on write alike.

Applied and acknowledged are both clamped to what has been seen before a write, so a record carried forward from a previous process cannot describe progress past the stream position the node currently holds.

Reading a record after a restart

The record says The node's situation
Seen equals persisted equals applied Everything the node was told about was acted on
Persisted ahead of applied Assignments arrived and were recorded, and the work was interrupted; their control-plane leases lapse and they are dispatched again
Applied ahead of acknowledged Work completed and its status was not confirmed; the status is reported again and the control plane recognises the duplicate
Seen ahead of persisted The last advance did not reach the volume; the node resumes from the stored position and reads that range again
Zero across all four A first start, a replaced identity state, or a position the node could not load

A cursor that failed its checks and a new node look the same in the record. The corruption condition the node reports tells them apart. See The watch cursor.

Repeating a range is safe

Resuming behind the true position means a range of assignments is read twice. That is absorbed at two points: the control plane dispatches only assignments whose lease is held by the node and still valid, and the node's own execution dedupe records recognise an assignment and attempt it has already carried out and reuse the recorded outcome. See Idempotency and replay-safe reprocessing.

One record, one stream

The record names the stream it belongs to, built from the node identity, the instance identity, the dispatch partition and the channel kind:

dataplane_uuid=<uuid>;dataplane_instance_uuid=<uuid>;dispatch_partition=default;channel_kind=assignment_watch

The partition and channel default to default and assignment_watch. The key is stored in the record and compared on every load and write, so a position for one stream is never continued as a position in another.