✨ feat(replication): version the operation envelope#611
Merged
gaborbernat merged 1 commit intoJul 18, 2026
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
gaborbernat
enabled auto-merge (squash)
July 18, 2026 04:19
Wrap the version-1 Change in an OperationEnvelope that carries the schema version, source, authority epoch, operation kind, and an optional W3C trace context, keeping the identity as the (source, epoch, serial) triple over the existing change serial. Bounded encode/decode rejects oversized or over-nested peer bytes, enforces the supported schema-version window, tolerates unknown fields for a rolling upgrade, and redacts payload from Debug/Display.
gaborbernat
force-pushed
the
feat/versioned-replication-op-envelope-503
branch
from
July 18, 2026 04:21
f03056b to
705408f
Compare
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.
The availability contracts express staleness and recovery as a serial frontier over the
peryx-replicationchange serial, yet the change stream carries no per-operation provenance a follower can reason about before it applies an operation. AChangeholds a serial and an opaque payload. It does not say which schema version encoded it, which primary authored it, which authority generation was in force, or what kind of mutation it is, and nothing bounds an untrusted peer's bytes before they parse. Storage durability and a later transport both need to depend on the stream, so replication first needs a stable, versioned envelope around each operation.OperationEnvelopewraps the existing version-1Changeinstead of opening a second replication stream. It adds aschema_version, thesourceidentity, anAuthorityEpochfencing token that a failover advances, anOperationKindnaming the mutation, and an optional W3CTraceContext. An operation's identity is the(source, epoch, serial)triple: stable across replay, idempotent to apply, and safe to log.encodeanddecoderound-trip through JSON.decodetreats its input as untrusted: it rejects bytes past a size or nesting-depth limit before parsing, requires a schema version withinSUPPORTED_SCHEMA_VERSIONS, and validates the traceparent when a trace context is present.SchemaVersion::negotiateis the version-negotiation surface, returning the newest version two ends share.Two compatibility rules keep a rolling upgrade between adjacent schema versions safe. Decoding ignores fields it does not recognize, so a newer producer that adds a field stays readable by an older consumer inside the supported window, and it refuses any version outside that window instead of guessing at a schema it cannot model.
DebugandDisplayrender the operation kind, version, and identity, and they omit the payload bytes and metadata values, so a log line carries what an operator needs to trace an operation without its contents. A local benchmark reports the encode and decode cost and allocation count for a representative wheel upload and registry manifest push, holding metadata replication clear of becoming a blob transport.Persistence, transport, and applying operations stay downstream and out of scope; this change defines the wire and persistence type, its bounded encode and decode, and its version-negotiation surface.
Closes #503