[rush] (BREAKING CHANGE) Overhaul watch-mode to facilitate orchestration#5378
Open
dmichon-msft wants to merge 21 commits intomicrosoft:mainfrom
Open
[rush] (BREAKING CHANGE) Overhaul watch-mode to facilitate orchestration#5378dmichon-msft wants to merge 21 commits intomicrosoft:mainfrom
dmichon-msft wants to merge 21 commits intomicrosoft:mainfrom
Conversation
49f3abe to
2da4c4a
Compare
019bc07 to
7c87ca0
Compare
7c87ca0 to
6726d88
Compare
bmiddha
reviewed
Mar 12, 2026
libraries/rush-lib/src/logic/operations/OperationExecutionManager.ts
Outdated
Show resolved
Hide resolved
libraries/rush-lib/src/logic/operations/OperationExecutionManager.ts
Outdated
Show resolved
Hide resolved
dmichon-msft
commented
Mar 12, 2026
dmichon-msft
commented
Mar 12, 2026
284dc4c to
2224f15
Compare
iclanton
reviewed
Mar 17, 2026
| * @alpha | ||
| */ | ||
| export interface IExecuteOperationsContext extends ICreateOperationsContext { | ||
| export interface IOperationExecutionManager { |
Member
There was a problem hiding this comment.
This should move somewhere else.
iclanton
reviewed
Mar 17, 2026
2224f15 to
939b967
Compare
939b967 to
69e530b
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.
[rush] (BREAKING CHANGE) Overhaul watch-mode to facilitate orchestration
Summary
Completely retools the watch engine in Rush to facilitate better interaction with plugins that wish to orchestrate the build process. Makes the Rush execution engine stateful across an entire Rush watch session.
BREAKING CHANGES
PhasedCommandHooksnow has only two hooks:createOperationsAsyncandonGraphCreatedAsync. All other hooks have been moved toOperationGraphHooks, accessible viaoperationGraph.hooksinside theonGraphCreatedAsynccallback.createOperationsis nowcreateOperationsAsync, and the properties on theICreateOperationsContextparameter have changed:isInitial,projectsInUnknownState,phaseOriginal, andinvalidateOperationhave been removed;generateFullGraphandincludePhaseDepshave been added.OperationGraphHooksclass. TapoperationGraph.hooksfor:configureIteration— synchronous hook to select which operations run in the next iterationbeforeExecuteIterationAsync— replacesbeforeExecuteOperationsAsyncafterExecuteIterationAsync— replacesafterExecuteOperationsAsyncbeforeExecuteOperationAsync— moved fromPhasedCommandHooksafterExecuteOperationAsync— moved fromPhasedCommandHookscreateEnvironmentForOperation— moved fromPhasedCommandHooksbeforeLog— moved fromPhasedCommandHooks; now invoked by the graph before writing telemetryonIdle— replaceswaitingForChanges(moved fromPhasedCommandHooks)onExecutionStatesUpdated,onEnableStatesChanged,onIterationScheduled,onGraphStateChanged,onInvalidateOperations— new hooksIOperationRunnerContextnow includesgetInvalidateCallback(), which returns a lightweight(reason: string) => voidcallback that marks the current operation for re-execution. This replaces the previousinvalidateOperationonICreateOperationsContextand removes the need for runners to capture anIOperationGraphreference.IOperationRunner.executeAsyncnow takes an optional second parameterlastState?: IOperationLastState, providing the previous execution result to inform incremental behavior (e.g. choosing an initial vs. incremental command).IBaseOperationExecutionResult.getStateHashComponents()now returns a structuredIOperationStateHashComponentsinterface ({ dependencies, local, config }) instead of a flatReadonlyArray<string>.IBaseOperationExecutionResult.metadataFolderPathis nowstring(wasstring | undefined).Details
The new lifecycle of a Rush phased command is that the command first invokes
createOperationsAsyncto create the session-long operation graph. This set of operations is then passed intoonGraphCreatedAsync, which constructs anIOperationGraphthat owns the lifecycle of the execution session.There is a new watch option
includeAllProjectsInWatchGraph(incommand-line.json) that, if set to true, will cause Rush to build the graph with all projects inrush.json, regardless of CLI selection parameters. Selected projects will only affect which projects are enabled for execution during the initial run. This also allows for a bare command, e.g.rush start, to select no projects. This feature is intended for use with plugins that offer the ability to alter the enabled/disabled states of operations in the graph while the session is ongoing. For an example, see@rushstack/rush-serve-plugin, which facilitates altering these states via Web Socket messages.Runner self-invalidation
Long-lived runners (e.g. IPC processes, file watchers) can now request re-execution directly via
context.getInvalidateCallback(). This returns a minimal closure that delegates toIOperationGraph.invalidateOperations(), without the runner needing access to the graph orOperationobject. TheIPCOperationRunneruses this internally to handlerequestRunIPC messages from child processes.Error handling
Operation runner errors are now uniformly caught and wrapped in
OperationErrorbyOperationExecutionRecord.executeAsync, rather than requiring each runner implementation to handle its own error wrapping.All in-repo plugins that interact with the Rush execution graph have also been updated.
How it was tested
Added unit tests for all functionality of the new
IOperationGraphAPI contract (633 tests passing).Manual validation via the rushstack repo's
rush startcommand for the CLI interaction (enable/disable debug or verbose, alter parallelism, pause/resume, kick a single build, invalidate, close runners).Impacted documentation
All watch-mode documentation. Plugin documentation for phased commands.
New docs added in this PR:
docs/rush/phased-commands.md— architecture reference for the phased command execution model,OperationGraphHooks,IOperationGraphAPI, andIOperationRunnercontractdocs/rush/plugin-migration-guide.md— hook-by-hook migration guide for plugin authors upgrading from the previous API