Skip to content

improvement(client-ordered-collection): ConsensusQueueFactory generic#27497

Open
jason-ha wants to merge 3 commits into
microsoft:mainfrom
jason-ha:dds/ordered-collection/ConsensusQueueFactoryTyping
Open

improvement(client-ordered-collection): ConsensusQueueFactory generic#27497
jason-ha wants to merge 3 commits into
microsoft:mainfrom
jason-ha:dds/ordered-collection/ConsensusQueueFactoryTyping

Conversation

@jason-ha

@jason-ha jason-ha commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
  • Remove unused IConsensusOrderedCollectionFactory
  • Make ConsensusQueueFactory generic (assumes unknown)
    • Get specific on create & load return types
  • Remove most intended internal class use in test

- Remove unused `IConsensusOrderedCollectionFactory`
- Make `ConsensusQueueFactory` generic (assumes `unknown`)
  - Get specific on `create` & `load` return types
- Remove most intended internal class use in test
Copilot AI review requested due to automatic review settings June 5, 2026 18:59
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

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

Based on the diff (115 lines, 5 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

Copilot AI left a comment

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.

Pull request overview

Note

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

This PR updates the ordered-collection DDS factory to be generic, removes the now-unneeded IConsensusOrderedCollectionFactory type, and adjusts tests/fuzz utilities to rely less on internal classes and more on public legacy typings.

Changes:

  • Removed IConsensusOrderedCollectionFactory from interfaces.ts and public exports.
  • Made ConsensusQueueFactory generic and tightened create/load return types.
  • Updated tests/fuzz utilities to use ConsensusQueueFactory<T> and legacy imports/types.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/dds/ordered-collection/src/test/fuzzUtils.ts Updates fuzz model/state typings to use ConsensusQueueFactory<T>.
packages/dds/ordered-collection/src/test/consensusOrderedCollection.spec.ts Switches test typings/imports to legacy public interfaces and adjusts class generics.
packages/dds/ordered-collection/src/interfaces.ts Removes the IConsensusOrderedCollectionFactory interface definition.
packages/dds/ordered-collection/src/index.ts Stops exporting IConsensusOrderedCollectionFactory.
packages/dds/ordered-collection/src/consensusOrderedCollectionFactory.ts Introduces generic ConsensusQueueFactory<T> and updates ConsensusQueue shared-object-kind export.

Comment thread packages/dds/ordered-collection/src/consensusOrderedCollectionFactory.ts Outdated
Comment thread packages/dds/ordered-collection/src/index.ts
Comment thread packages/dds/ordered-collection/src/test/fuzzUtils.ts
Comment thread packages/dds/ordered-collection/src/test/fuzzUtils.ts Outdated
Comment thread packages/dds/ordered-collection/src/test/consensusOrderedCollection.spec.ts Outdated
jason-ha added 2 commits June 12, 2026 10:37
- symmetric explicit `<unknown>`
- consistent `<string>` for fuzzUtils.ts
- remove unused `<any>` on class value use
@jason-ha jason-ha requested a review from CraigMacomber June 12, 2026 17:53
* Test class that exposes protected applyStashedOp method for testing
*/
class TestConsensusQueue extends ConsensusQueueClass {
class TestConsensusQueue extends ConsensusQueueClass<unknown> {

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.

Personally, I do not like the pattern of using generics such that they can cause incorrectly typed code to silently compile, especially when there is no runtime check involved.

There is no way for the TypeScript compiler to validate that the content stored in all possible current and future documents makes the type provided here, and not even a way for a careful developer to ensure its correct either. When importing persisted data, I don't think we should use generics to simply assume its what ever type the code feels like inferring, removing the compiler enforced validation of the data and hiding where the unsafe type conversion is occurring.

If you store Foos in your document, then a dev changes the Foo type in an incompatible way, or even uses a totally different type, there is nothing we can do at compile time to stop them, checked runtime conversion is required, and developers know where to do that because get type Unknown, and are forced to convert.

Anything that implicitly type converts content from persistence should require a runtime check: this is why we use strongly type schema like Tree schema and TypeBox. I'd rather not add violations to this typer safety practice in legacy code to make it slightly more ergonomic to write type unsafe usages of it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think that is an opinion unique to you. I was equally put off when I saw what is going on here.
Unfortunately, we don't have all the time to go address past silliness. This at least moves the generic to unknown here instead of any.

@jason-ha jason-ha requested a review from CraigMacomber June 12, 2026 21:44
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