-
Notifications
You must be signed in to change notification settings - Fork 549
feat(client): [internal] container extensions and presence
use
#24399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(client): [internal] container extensions and presence
use
#24399
Conversation
There was a problem hiding this 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 introduces support for path-based Signal addressing and centralizes signal submission logic through refactored APIs and generic message types. Key changes include:
- Migrating signal submission and validation to use a centralized helper and updated types.
- Removing deprecated container extension definitions and unused APIs.
- Updating examples and documentation to align with the new Presence APIs.
Reviewed Changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/framework/presence/src/datastorePresenceManagerFactory.ts | Introduces emitter-based event wiring and updates signal validation to use RawInboundExtensionMessage. |
packages/framework/presence/src/container-definitions/*.ts | Removes unused container extension interfaces and definitions. |
packages/common/driver-definitions/src/protocol/protocol.ts | Updates signal message types to use generics with TypedMessage. |
packages/common/core-interfaces/* | Adds and updates definitions for TypedMessage, ISignalEnvelope, and FlattenIntersection. |
packages/common/container-definitions/* | Exposes new extension runtime and container extension support. |
examples/* | Updates example usage from getPresenceViaDataObject to getPresence and refines related comments. |
docs/docs/build/presence.md | Revises onboarding instructions and fixes a typo in the documentation. |
.changeset/wet-towns-ask.md | Adds a changeset detailing the new path-based addressing scheme. |
Files not reviewed (1)
- packages/framework/presence/package.json: Language not supported
Comments suppressed due to low confidence (1)
packages/common/driver-definitions/src/protocol/protocol.ts:346
- [nitpick] Ensure that the renaming and generic update to ISignalMessageBase and related types aligns with all downstream consumers to avoid type mismatches.
export interface ISignalMessageBase<TMessage extends TypedMessage = TypedMessage> {
For Signals, support using a `/` separated address in `IEnvelope` (at ContainerRuntime). No change to Ops. - Reading is always supported. - Writing (sending) for all signals requires `IContainerRuntimeOptionsInternal.enablePathBasedAddressing` to be enabled and is not externally exposed nor internally enabled apart from testing. Refactor signal submission so that application of `applyTrackingToBroadcastSignalEnvelope` is centralized and use `UnsequencedSignalEnvelope` to make `clientBroadcastSignalSequenceNumber` stamping (or lack of) more obvious. Add two helpers: - `submitWithPathBasedSignalAddress` will promote addressing to always use paths. - `submitAssertingLegacySignalAddressing` confirms envelopes coming through don't start with `/` that is reserved for path-based addressing. docs(client): changeset format update and additional comment. style(client): shorten option name improvement(client-contain-runtime): remove pathBasedAddressing from DocSchema impact
and use to type ContainerRuntime signals received.
refactor `ContainerExtension` interface from `presence` with several updates to `ExtensionRuntime` and accommodating `presence` changes.
…n messages across submitting and processing signals. + Improve incoming signal validation: - Check for exactly known type names - Allow for "optional" unrecognized signal; if a signal is not optional it must be recognized to avoid assert (throw) + Clean up test data types and content to conform
from [at least partially] validated/verified ones
and use in presence examples and tests docs: fix presence.md typo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
cb8b9d3
to
112853b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll pause on deeper review, I think the two big comments are core to the idea of this PR and so probably want to hash those out first.
// Note that this pattern allows for ! prefix in top-address but | ||
// does not give it any more special treatment than without it. | ||
const topAddressAndSubaddress = fullAddress.match( | ||
/^\/(?<optional>[!?]?)(?<top>[^/]*)\/(?<subaddress>.*)$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've become more averse to path-based approaches recently, particularly as I've been working on handle-related stuff and hating their absolutePath. IMO most of our current path-like stuff is fallout from the request() pattern, which has generally just been a source of pain for us.
Is it necessary to collapse routing information into a string? Could we send it as a structured object instead, or wrap envelopes, etc.? I would love if when this function looks at the envelope, it simply has the information it wants already without needing to do any parsing/transformation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion to continue in internal Team chat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've kept using the existing address string as the full routing information but removed all of the pattern complexity so that it is just split by /
. There is no plan to extend this to ops currently where structuring might be more useful.
string is kept because we need (want) a string address anyway to play nice(r) with older client that happen to see these otherwise unexpected signals.
for explicit simplicity and correctness when no UseContext
ee27d5d
to
46fa5bf
Compare
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for docs.
Dear reviewers, I believe that most concerns have been addressed here, but as many are out I am completing the PR to unblock Designer. Will address all feedback given here or in either of the internal Teams chats. Support for encapsulated model to be designed and reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving API changes
|
||
import type { IRuntimeInternal } from "@fluidframework/presence/internal/container-definitions/internal"; | ||
/** | ||
* @internal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we add semantic docs since this is package-exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not package exported
import type { SystemWorkspaceDatastore } from "./systemWorkspace.js"; | ||
|
||
/** | ||
* @internal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: docs for package-exported members
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not package exported. It is just inter package file "exported".
/** | ||
* Brand for value that has not been verified. | ||
* | ||
* Usage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
* Usage: | |
* @remarks | |
* Usage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix in post
- removes @internal where API is not package exported and adding real notes where none were. - adds documentation to exported APIs Follow-up for microsoft#24399 and microsoft#24710
ContainerRuntime path-based Signal addressing
For Signals, support using a
/
prefixed address inIEnvelope
(at ContainerRuntime). No change to Ops./
prefix./ext/
(as well as/runtime/
and/channels/
for uniformity).Refactor signal submission so that application of
applyTrackingToBroadcastSignalEnvelope
is centralized undersequenceAndSubmitSignal
and useUnsequencedSignalEnvelope
to makeclientBroadcastSignalSequenceNumber
stamping (or lack of) more obvious.ContainerRuntime.submitSignalFn
confirms envelopes coming through don't start with/
that is reserved for path-based addressing.Signal message types promoted to generics
ISignalEnvelope
andI*SignalMessage*
related types accepttype
andcontent
pairs to form tight association between them.[internal]
ContainerExtension
APIRefactor the prototype API from
presence
package tocontainer-runtime-definitions
.Extensions are registered with
ContainerRuntime
(via support fromFluidContainer
influid-static
in declarative API) and currently may only send and receive Signals. Encapsulated support will require further work to define appropriate cross-layer interfaces.fluid-static
support will likely change to registerpresence
directly but does not currently.Build out extension message types to define outbound and inbound variants with inbound further divided into raw (unverified) and verified versions. Extensions may only submit messages conforming to the types they specify. The
ExtensionHost
(akaContainerRuntime
will deliver typed messages viaprocessSignal
but in unverified form.core-interfaces
additionsTypedMessage
added for Signal message generics constraint type.BrandedType
added to support distinguishing raw from verified messages.InternalUtilityTypes.FlattenIntersection
exposed and fixed up for extension message types.presence
changesIEphemeralRuntime
to mostly matchExtensionHost
.protocol.ts
and use more broadly.Support
getPresence(container: IFluidContainer)
Container
andContainerRuntime
to support extensions.getPresenceViaDataObject
use in examples and tests