Skip to content

Split TEncodeContext and TDecodeContext#27338

Open
CraigMacomber wants to merge 4 commits into
microsoft:mainfrom
CraigMacomber:betterID
Open

Split TEncodeContext and TDecodeContext#27338
CraigMacomber wants to merge 4 commits into
microsoft:mainfrom
CraigMacomber:betterID

Conversation

@CraigMacomber
Copy link
Copy Markdown
Contributor

Description

Allow codecs to have distinct encode and decode context types, to allow for better management of id-compressor sessions, and other compression and session related inputs in the future.

Reviewer Guidance

The review process is outlined on this wiki page.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Hi! Thank you for opening this PR. Want me to review it?

Based on the diff (307 lines, 3 files), I've queued these reviewers:

  • Correctness — logic errors, race conditions, lifecycle issues
  • Security — vulnerabilities, secret exposure, injection
  • API Compatibility — breaking changes, release tags, type design
  • Performance — algorithmic regressions, memory leaks
  • Testing — coverage gaps, hollow tests

How this works

  • Adjust the reviewer set by ticking/unticking boxes above. Reviewer toggles alone don't trigger anything.

  • Tick Start review below to dispatch the review fleet.

  • After review finishes, tick Start review again to request another run — it auto-resets after each dispatch.

  • This comment updates as new commits land; your reviewer selections are preserved.

  • Start review

@CraigMacomber CraigMacomber marked this pull request as ready for review May 19, 2026 21:20
@CraigMacomber CraigMacomber requested a review from a team as a code owner May 19, 2026 21:20
Copilot AI review requested due to automatic review settings May 19, 2026 21:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the codec type system to allow different context types for encoding vs decoding, enabling future scenarios like distinct session/compression inputs on each side.

Changes:

  • Split TContext into TEncodeContext and TDecodeContext across codec interfaces and version-dispatching codec builder types.
  • Propagate the new context typing through versioned codec normalization/build paths.
  • Add a test covering distinct encode/decode context typing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/dds/tree/src/test/codec/versioned/codec.spec.ts Adds a regression test ensuring encode/decode can use distinct context types.
packages/dds/tree/src/codec/versioned/codec.ts Refactors versioned codec builder/normalization types to support separate encode/decode contexts.
packages/dds/tree/src/codec/codec.ts Updates core codec interfaces/utilities (IJsonCodec, ICodecFamily, withSchemaValidation, etc.) to support split contexts.

Comment thread packages/dds/tree/src/codec/codec.ts
Comment thread packages/dds/tree/src/codec/versioned/codec.ts Outdated
IDecoder<TDecoded, TValidate, TContext> {
TEncodeContext = void,
TDecodeContext = TEncodeContext,
> extends IEncoder<TDecoded, TEncoded, TEncodeContext>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we update TContext (line 175) in the doc comments now that it's TEncodeContext and TDecodeContext?

export interface VersionDispatchingCodec<
TDecoded,
TContext,
TEncodeContext,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update TContext to TEncodeContext

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.

3 participants