Skip to content

fix(runtime): keep state versions consistent and emit versioned state deltas - #23

Open
Kushagra7777 wants to merge 6 commits into
risa-labs-inc:mainfrom
Kushagra7777:feat/versioned-plugin-state-deltas
Open

Kushagra7777 wants to merge 6 commits into
risa-labs-inc:mainfrom
Kushagra7777:feat/versioned-plugin-state-deltas

Conversation

@Kushagra7777

Copy link
Copy Markdown

Why

State and version were read separately during serialization, allowing an older state to be labelled with a newer version.

The runtime also sent full snapshots for every update, even when only a small field changed.

Changes

  • Publish state and version together as an atomic snapshot.
  • Use that snapshot for streamed updates and GetCurrentState responses.
  • Generate JSON Merge Patches when both the patch payload and complete protobuf message are smaller than a full update.
  • Track the last emitted state and version separately for each subscription.
  • Start every subscription with a full snapshot.
  • Handle skipped versions without assuming consecutive version numbers.
  • Fall back to full snapshots for unsupported input, excessive nesting, unrepresentable explicit-null changes, or patches without size savings.
  • Keep GetCurrentState responses as full snapshots.

Tests

Added regression coverage for:

  • Updates occurring during snapshot and stream serialization.
  • Concurrent state updates, immediate state reads, and equal-state updates.
  • Initial full snapshots followed by deltas.
  • Independent subscription baselines.
  • Skipped versions and exact delta base versions.
  • Nested edits, field deletion, and array replacement.
  • Explicit-null fallback and subsequent delta recovery.
  • Unsupported JSON, invalid UTF-8, excessive nesting, and patches without payload savings.

A local test run reported 276 tests with zero failures, errors, or skips.

Validation limits

The reported 276-test run preceded correcting two implementation files that were accidentally placed under src/test. Both files are now under src/main; a clean build and test result after that move still needs to be recorded.

The new service tests call the service directly. End-to-end host integration, transport reconnection, child-process restart behavior, and representative performance benchmarks remain unverified.

Dependency

This branch is based on the runtime IPC baseline from PR #21
(d98614e). That prerequisite work belongs to its original contributor.

Related to #20; this PR does not claim to complete the entire issue.

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.

2 participants