Skip to content

Simplify OrderedClientElection by reading quorum directly#26693

Open
ChumpChief wants to merge 16 commits intomicrosoft:mainfrom
ChumpChief:SummarizerElection-PR1
Open

Simplify OrderedClientElection by reading quorum directly#26693
ChumpChief wants to merge 16 commits intomicrosoft:mainfrom
ChumpChief:SummarizerElection-PR1

Conversation

@ChumpChief
Copy link
Contributor

Summary

  • Simplifies the summarizer election implementation by merging OrderedClientCollection into OrderedClientElection, eliminating a layer of indirection
  • OrderedClientElection now reads quorum members directly instead of maintaining its own parallel sorted list of tracked clients, de-duplicating the client tracking that the Quorum already provides
  • No behavioral changes to election logic; all existing tests pass with only assertion updates to reflect the streamlined internals

Follow-up PRs will do further cleanup and collapse OrderedClientElection into SummarizerClientElection.

Test plan

  • All existing unit tests pass (orderedClientElection.spec.ts, summarizerClientElection.spec.ts)
  • pnpm build passes (compilation, lint, api-extractor)
  • Verify no downstream consumers depend on removed OrderedClientCollection export

🤖 Generated with Claude Code

ChumpChief and others added 15 commits March 9, 2026 13:34
Collapse OrderedClientCollection and OrderedClientElection into a single
OrderedClientElection class that scans quorum directly instead of
maintaining a doubly-linked list. SummarizerClientElection is unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ructure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…vents

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… findNextEligibleParentAfter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the elected parent leaves, prefer electing the next younger
eligible client rather than resetting to the oldest, matching the
original behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…clone

resetElectedClient compared _electedClient === _electedParent by object
reference, but our init path creates separate ITrackedClient objects for
the same client. Switch to clientId comparison. Also restore the shallow
clone of client details from the original implementation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ChumpChief ChumpChief marked this pull request as ready for review March 10, 2026 22:30
Copy link
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

This PR refactors summarizer election by removing the OrderedClientCollection layer and having OrderedClientElection read quorum membership directly, aiming to reduce duplicated client tracking while preserving election behavior.

Changes:

  • Removed OrderedClientCollection and updated OrderedClientElection to observe IQuorumClients directly.
  • Updated runtime wiring (ContainerRuntime) to construct OrderedClientElection with delta manager + quorum.
  • Updated unit tests to match the new OrderedClientElection internals and telemetry payloads.

Reviewed changes

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

Show a summary per file
File Description
packages/runtime/container-runtime/src/summary/orderedClientElection.ts Replaces the internal ordered-client list with direct quorum iteration and quorum event handling.
packages/runtime/container-runtime/src/summary/index.ts Removes OrderedClientCollection (and interface) exports from the summary module surface.
packages/runtime/container-runtime/src/containerRuntime.ts Updates summarizer election initialization to use the new OrderedClientElection constructor signature.
packages/runtime/container-runtime/src/test/summary/orderedClientElection.spec.ts Updates tests to construct OrderedClientElection directly and adjusts assertions/log expectations.
packages/runtime/container-runtime/src/test/summary/summarizerClientElection.spec.ts Updates test setup to use the new OrderedClientElection constructor signature.

Remove the unnecessary `_electedClient !== undefined` guard so that a
summarizer already in the quorum can be elected even when no interactive
parent client exists, matching the original upstream initialization logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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