Repository navigation
add apply changes and list transforms RPCs to world state store service - #948
Open
Devin T. Currie (DTCurrie) wants to merge 5 commits into
Open
Devin T. Currie (DTCurrie) wants to merge 5 commits into
Devin T. Currie (DTCurrie) wants to merge 5 commits into
Conversation
abe-winter
approved these changes
Nov 13, 2026
| // TransformChange describes a single change to apply to the world state. | ||
| message TransformChange { | ||
| // The kind of change to apply. TRANSFORM_CHANGE_TYPE_UNSPECIFIED is invalid. | ||
| TransformChangeType change_type = 1; |
Member
There was a problem hiding this comment.
non blocking, but possible extra field here -- replace_if_present on add (so people can do upserts)
Member
Author
There was a problem hiding this comment.
That's how the visualizer client handles it. If an add event comes through on an existing event, we treat it as an update, so we can define that here.
Member
Author
There was a problem hiding this comment.
Defined all the change operations as their own enum and added the upsert type, I think that is a cleaner split.
|
Hey Devin T. Currie (@DTCurrie) — this PR has been approved and CI has been green for 3+ business days. Ready to merge? Auto-comment from overwatch. Will not re-nudge for 7 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add ApplyTransformChanges and ListTransforms to the world state store service
Summary
Adds two RPCs to
WorldStateStoreService:ApplyTransformChanges: a standard way to write to a store. One call carries any mix of additions, updates and removals and applies them all or not at all.ListTransforms: a bulk read that returns a snapshot of the whole world state as a stream of batches.Only
proto/viam/service/worldstatestore/v1/world_state_store.protois changed by hand. The generated Go and JS code comes from theready-for-protosworkflow.Why
The service has no write call today. The builtin store in RDK takes writes through
DoCommand(add,update,remove), so every other implementation has to invent its own, and clients cannot write to a store without knowing which model it is.It also has no way to read the world state in one consistent view. A client has to call
ListUUIDsand thenGetTransformonce per transform, and the store can change between those calls. The motion service reads the store this way, so aMoveplanned while obstacles are being swapped can see part of the old set and part of the new one.ApplyTransformChangesrpc ApplyTransformChanges(ApplyTransformChangesRequest) returns (ApplyTransformChangesResponse) { option (google.api.http) = {post: "/viam/api/v1/service/worldstatestore/{name}/apply_transform_changes"}; } enum TransformChangeOperation { TRANSFORM_CHANGE_OPERATION_UNSPECIFIED = 0; TRANSFORM_CHANGE_OPERATION_ADD = 1; TRANSFORM_CHANGE_OPERATION_REMOVE = 2; TRANSFORM_CHANGE_OPERATION_UPDATE = 3; TRANSFORM_CHANGE_OPERATION_UPSERT = 4; } message TransformChange { TransformChangeOperation operation = 1; common.v1.Transform transform = 2; google.protobuf.FieldMask updated_fields = 3; } message ApplyTransformChangesRequest { string name = 1; repeated TransformChange changes = 2; google.protobuf.Struct extra = 99; } message ApplyTransformChangesResponse { repeated bytes uuids = 1; }TransformChangehas the same layout asStreamTransformChangesResponse: the kind of change in field 1, the transform in field 2 and the field mask in field 3.StreamTransformChangesResponseitself is unchanged.TransformChangeOperationsays what a request asks for;TransformChangeTypesays what the stream reports happened. They are separate because a request can ask for an upsert, which the stream never reports.ADD,REMOVEandUPDATEkeep the same numbers asADDED,REMOVEDandUPDATED, and the two enums are to be kept in sync.uuidshas one entry for each change, in request order: the UUID of the transform that change applied to.operationtransformupdated_fieldsADDREMOVEUPDATEUPSERTUpserts
UPSERTadds the transform, or replaces the stored one whole if its UUID already exists, so a client can write a transform without first checking whether it is there. This is how the visualizer client already treats an add event for a transform it has.ADD. Adding and upserting behave differently, so each has its own value.ADDstays strict.Server-assigned UUIDs
An
ADDorUPSERTsent without a UUID is given one by the service, and the response reports it. This matches what the builtin store'sDoCommanddoes today. A request of[ADD (no UUID), REMOVE b2xk, ADD Ym94]returns[<assigned>, b2xk, Ym94].ADDfails as "already exists" and a retriedUPSERTsucceeds harmlessly, so callers that retry should supply one.Why request order rather than a fixed remove, add, update order
The builtin store's
DoCommandapplies changes in a fixed order of removals, additions, then updates. That order exists because the command is a JSON object keyed byadd,updateandremove, which has no order of its own. This request is a list, so it already has one.[ADD X, REMOVE X]it would run the removal first, which either fails the batch or leaves X present.ListTransformsrpc ListTransforms(ListTransformsRequest) returns (stream ListTransformsResponse) { option (google.api.http) = {get: "/viam/api/v1/service/worldstatestore/{name}/list_transforms"}; } message ListTransformsRequest { string name = 1; google.protobuf.Struct extra = 99; } message ListTransformsResponse { repeated common.v1.Transform transforms = 1; }Why a stream rather than one response
MaxMessageSizein goutils), and a transform can carry a mesh or a point cloud. A single response would fail outright on a large world.A single transform larger than the message limit still fails, as it does with
GetTransformtoday.Not in this PR
ListTransforms. It always returns everything. A filter can be added to the request later, and needs a rule for a UUID that is not found.DoCommandwrite path will be rebuilt onApplyTransformChanges.Compatibility
Additive only: two new RPCs, five new messages and one new enum. No existing message, field or RPC is changed.
Testing
Run locally with buf 1.55.1:
buf lint: passesbuf breaking --against '.git#branch=main': passesbuf format -d: no changes