Skip to content

Assignment cursor runtime

The assignment cursor is the record of how far a node has read, stored, applied and confirmed its assignment stream. The cursor runtime owns that record's contract: what it holds, the invariants it must satisfy, the digest that proves it was not altered, and the checks it passes on every load and every write. This page is that contract, so a cursor refusal can be matched to the invariant it broke.

For the four revisions and how intake moves them, see Watch cursor and pull ingest. For what a given combination of revisions says about a node that has just come back, see The assignment cursor.

The record

flowchart LR
  subgraph FILE["/var/lib/xratu/cursor/xratud_watch_cursor_*.json"]
    direction TB
    KEY["stream_key<br/>dataplane, process, partition, channel"]
    BIND["bound_dataplane_uuid<br/>bound_cp_identity_revision"]
    REV["last_seen, last_persisted,<br/>last_applied, last_acked"]
    DG["cursor_digest<br/>sha256 over all of the above"]
    TS["updated_at"]
  end
  LOAD{{"Load checks"}}
  WRITE{{"Write checks"}}
  FILE --> LOAD
  WRITE --> FILE

The digest covers the key, the binding and the four revisions, so any change to the file that did not come through the write checks is caught by the load checks.

The stream key

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

A cursor belongs to one stream. The key is stored in the record and compared on every load and write, and a record whose key differs is refused with ASSIGNMENT_CURSOR_STREAM_KEY_MISMATCH.

The ordering invariants

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

Storage trails what was seen, and application and confirmation trail storage. A record that breaks any of the three is refused with ASSIGNMENT_CURSOR_MONOTONICITY_VIOLATION.

On load

The file Outcome
Absent A new record at the configured initial revision
Unreadable, missing a field, failing an invariant or its digest ASSIGNMENT_CURSOR_CORRUPTION_DETECTED
Written for a different stream ASSIGNMENT_CURSOR_STREAM_KEY_MISMATCH
Bound to a different dataplane_uuid or cp_identity_revision ASSIGNMENT_CURSOR_BINDING_MISMATCH
Behind the configured initial revision Raised to the initial revision, keeping applied and acknowledged positions that are further ahead
Valid Loaded as written

A refused load leaves the node running at its initial revision, holding the corruption as state for the control plane to answer with a snapshot and a resume point. See Recovery contracts.

On write

A write builds the new record and its digest, checks the new record's invariants, and then checks it against the record already on disk: the same stream key, the same binding, and no revision lower than the one stored. A write that would move any revision backwards is refused with ASSIGNMENT_CURSOR_MONOTONICITY_VIOLATION, naming the field:

cursor field last_applied_revision regressed from 812 to 790

The record is then written to a temporary file, flushed to disk, and renamed over the original.

The reasons

Reason Condition
ASSIGNMENT_CURSOR_CORRUPTION_DETECTED The record cannot be read or validated, or could not be written
ASSIGNMENT_CURSOR_DIGEST_MISMATCH The stored digest differs from the digest of the stored fields
ASSIGNMENT_CURSOR_MONOTONICITY_VIOLATION An ordering invariant fails, or a write would regress a revision
ASSIGNMENT_CURSOR_STREAM_KEY_MISMATCH The record belongs to a different stream
ASSIGNMENT_CURSOR_BINDING_MISMATCH The record was written under a different node or control-plane identity
ASSIGNMENT_CURSOR_RESYNC_REQUIRED The node's position must be restored from the control plane

A digest failure on load is reported as corruption, with the digest mismatch as its cause.