Skip to content

state: node properties (min, max, unit, ...), as STATE_API.md documents them - #685

Merged
transfix merged 1 commit into
masterfrom
feat/state-properties
Oct 18, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/state-properties

Conversation

@transfix

Copy link
Copy Markdown
Owner

docs/STATE_API.md has documented state::property("min", ...) / property("max", ...) / property("units", ...) as the place for a node's metadata ("Use state properties for metadata (units, ranges, descriptions)"), but cvc::state nodes only carried comment, hidden and readOnly. This adds the documented API, so a binding can publish a recommended range, a unit or a role next to a value, and any application can read it: a UI slider, a validator, a remote peer.

The API

  • property(key) returns the value, "" when the key is not set.
  • property(key, value) sets it; "" removes the key.
  • has_property(key), property_keys(), properties().
  • propertyChanged fires with the key.
  • A property does not initialize the node (unlike comment), so describing a key before anything sets it does not make it look set.
  • reset() clears a node's properties.

Replication and snapshots

  • Live changes replicate as a new state_mutation_op::set_property: the key in type_name, the value in string_value. The op is appended to the enum, so the IPC wire's op byte keeps its existing values. On gRPC it is MUTATION_OP_SET_PROPERTY = 11.
  • Snapshots carry them, so a late joiner gets them:
    • snapshot_entry::properties, applied by state_cluster_shard::ingest_snapshot_entry;
    • gRPC: SnapshotEntry.properties (field 11);
    • IPC: a trailer after the entries, which a reader that predates it stops before. A newer reader reads it only when it is there, so mixed versions keep working.

Python

pycvc's State wraps the real header, so it gets property, has_property and property_keys. The signal and the map accessor are %ignored, like the other signals.

Tests

  • state_test: set, get, remove, the signal, not initializing, reset().
  • distributed_state_session_test: live replication, removal, and snapshot reassembly on a joiner.

Built and run on Windows MSVC (state_test 165 tests, distributed_state_session_test 16 tests). This box builds neither the IPC transport (POSIX-only) nor gRPC, so their edits rest on CI.

The vehicle-physics bindings use this next, for recommended ranges, units and comments on every knob (the P3 PR).

STATE_API.md has documented state::property("min", ...) for metadata such
as units and ranges, but nodes carried only comment, hidden and readOnly.
This adds the documented API:

- property(key), property(key, value), has_property, property_keys and
  properties(): named metadata strings beside the comment. "" removes a
  key. propertyChanged fires with the key. A property does not
  initialize the node, and reset() clears them.
- They replicate as a new set_property mutation (the key in type_name,
  the value in string_value). It is appended to state_mutation_op, so
  the IPC wire's op byte keeps its values, and becomes
  MUTATION_OP_SET_PROPERTY = 11 in the proto.
- Snapshots carry them:
  - snapshot_entry::properties, applied by ingest_snapshot_entry;
  - gRPC SnapshotEntry.properties (field 11);
  - IPC: a trailer after the entries, which older peers stop before.
- pycvc's State gets property, has_property and property_keys; the signal
  and the map accessor are %ignored.

Tests: state_test (set, get, remove, signal, reset) and
distributed_state_session_test (live replication, removal, and snapshot
reassembly).
@transfix
transfix merged commit edcc2c9 into master Oct 18, 2026
15 checks passed
@transfix
transfix deleted the feat/state-properties branch October 18, 2026 10:54
transfix added a commit that referenced this pull request Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant