Skip to content

Add V2 operation types for protocol v6+#695

Merged
zknill merged 1 commit intomainfrom
v2-types-state-operation
Feb 16, 2026
Merged

Add V2 operation types for protocol v6+#695
zknill merged 1 commit intomainfrom
v2-types-state-operation

Conversation

@zknill
Copy link
Copy Markdown
Contributor

@zknill zknill commented Feb 12, 2026

Extend the Operation struct with fields for action-specific payloads used by protocol v6: MapCreate, MapSet, MapRemove, CounterCreate, CounterInc, and ObjectDelete.

Define corresponding V2 structs that carry the per-action data (semantics, entries, keys, counts, etc.).

Summary by CodeRabbit

  • New Features
    • Added v6+ nested operation payloads for live objects to expand protocol compatibility.
    • Map operations now support create, set, and remove actions via new structured payloads.
    • Counter operations now support create and increment actions via new structured payloads.
    • Dedicated payload support added for object deletion handling.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 12, 2026

Walkthrough

Adds nested operation payloads for protocol v6+ by extending the Operation struct with six new pointer fields and introducing six new public types (MapCreate, MapSet, MapRemove, CounterCreate, CounterInc, ObjectDelete) to model action-specific payloads for maps, counters, and deletes.

Changes

Cohort / File(s) Summary
Live objects operation payloads
ably/objects/liveobjects.go
Extended Operation with six new pointer fields (MapCreate, MapSet, MapRemove, CounterCreate, CounterInc, ObjectDelete) and added corresponding types: MapCreate (Semantics, Entries), MapSet (Key, Value), MapRemove (Key), CounterCreate (Count), CounterInc (Number), ObjectDelete (empty).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped through structs with a twitch and a grin,
New payloads tucked neatly, all snug within,
Maps and counters, keys that delight,
A tiny delete in the soft moonlight,
Code carrots ready — let’s hop into v6! 🥕✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding new V2 operation type definitions to support protocol v6+, which aligns with the PR's core objective of extending the Operation struct with action-specific payload fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v2-types-state-operation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot temporarily deployed to staging/pull/695/godoc February 12, 2026 18:12 Inactive
@github-actions github-actions Bot temporarily deployed to staging/pull/695/features February 12, 2026 18:12 Inactive
Comment thread ably/objects/liveobjects.go Outdated
Comment thread ably/objects/liveobjects.go Outdated
Copy link
Copy Markdown
Member

@lmars lmars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, also happy to merge this as is.

Extend the Operation struct with fields for action-specific payloads
used by protocol v6: MapCreate, MapSet, MapRemove, CounterCreate,
CounterInc, and ObjectDelete.

Define corresponding V2 structs that carry the per-action data
(semantics, entries, keys, counts, etc.).
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@ably/objects/liveobjects.go`:
- Around line 160-166: The JSON/codec struct tags on CounterCreate.Count and
CounterInc.Number include "omitempty", which will omit valid zero float64 values
(e.g., CounterCreate{Count: 0} or CounterInc{Number: 0}) from the wire; remove
"omitempty" from both the `json` and `codec` tags for the Count field in type
CounterCreate and the Number field in type CounterInc so zero values are encoded
and preserved for v6+ types.
- Around line 146-149: The Semantics field in MapCreate (and the similar Map
struct) uses `omitempty` so the valid zero-value semantic Map_LWW (value 0) is
omitted during serialization; remove `omitempty` from the JSON and codec tags
for the Semantics field (e.g., in struct MapCreate.Semantics and Map.Semantics)
so the semantics value is always emitted even when zero, preventing silent drops
and server-side misinterpretation.
🧹 Nitpick comments (2)
ably/objects/liveobjects.go (2)

151-154: Naming inconsistency: MapSet.Value vs MapOp.Data.

The existing MapOp uses Data *Data while the new MapSet uses Value *Data. If both carry the same semantic (the data/value for a map key), consider aligning the naming for consistency — or document the rationale for the difference if it's intentional per the v6 protocol spec.


168-168: Empty ObjectDelete struct — consider adding a brief doc comment.

An empty struct with no fields and no comment may confuse future readers about whether fields were accidentally omitted. A short doc comment clarifying it's intentionally empty (the action itself is the signal, no payload needed) would help.

Comment thread ably/objects/liveobjects.go
Comment thread ably/objects/liveobjects.go
@zknill zknill merged commit 3dad1b1 into main Feb 16, 2026
93 of 98 checks passed
@zknill zknill deleted the v2-types-state-operation branch February 16, 2026 10:41
@lmars lmars mentioned this pull request Apr 20, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants