@rushstack/rush-sdk 5.169.3 → 5.170.1-pr5378.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/rush-lib.d.ts +470 -133
  2. package/dist/tsdoc-metadata.json +1 -1
  3. package/lib-commonjs/index.js +1 -0
  4. package/lib-commonjs/logic/operations/IOperationGraph.js +2 -0
  5. package/lib-commonjs/logic/operations/OperationGraph.js +3 -0
  6. package/lib-commonjs/logic/operations/OperationStatus.js +1 -0
  7. package/lib-commonjs/logic/operations/ParseParallelism.js +6 -0
  8. package/lib-commonjs/pluginFramework/OperationGraphHooks.js +3 -0
  9. package/lib-dts/api/CommandLineConfiguration.d.ts +7 -0
  10. package/lib-dts/api/CommandLineJson.d.ts +1 -0
  11. package/lib-dts/api/EnvironmentConfiguration.d.ts +12 -0
  12. package/lib-dts/api/EventHooks.d.ts +1 -1
  13. package/lib-dts/api/RushProjectConfiguration.d.ts +1 -1
  14. package/lib-dts/cli/parsing/SelectionParameterSet.d.ts +1 -1
  15. package/lib-dts/cli/scriptActions/PhasedScriptAction.d.ts +2 -12
  16. package/lib-dts/index.d.ts +7 -4
  17. package/lib-dts/logic/ProjectWatcher.d.ts +64 -42
  18. package/lib-dts/logic/buildCache/OperationBuildCache.d.ts +2 -2
  19. package/lib-dts/logic/operations/IOperationExecutionResult.d.ts +57 -16
  20. package/lib-dts/logic/operations/IOperationGraph.d.ts +137 -0
  21. package/lib-dts/logic/operations/IOperationRunner.d.ts +32 -2
  22. package/lib-dts/logic/operations/IPCOperationRunner.d.ts +8 -8
  23. package/lib-dts/logic/operations/Operation.d.ts +50 -14
  24. package/lib-dts/logic/operations/OperationExecutionRecord.d.ts +21 -9
  25. package/lib-dts/logic/operations/OperationGraph.d.ts +125 -0
  26. package/lib-dts/logic/operations/OperationStatus.d.ts +4 -0
  27. package/lib-dts/logic/operations/ParseParallelism.d.ts +33 -0
  28. package/lib-dts/logic/operations/ShellOperationRunner.d.ts +6 -5
  29. package/lib-dts/logic/operations/ShellOperationRunnerPlugin.d.ts +2 -1
  30. package/lib-dts/logic/operations/ValidateOperationsPlugin.d.ts +1 -3
  31. package/lib-dts/pluginFramework/OperationGraphHooks.d.ts +129 -0
  32. package/lib-dts/pluginFramework/PhasedCommandHooks.d.ts +32 -98
  33. package/lib-dts/utilities/Stopwatch.d.ts +2 -2
  34. package/lib-shim/index.js +32 -2
  35. package/lib-shim/index.js.map +1 -1
  36. package/package.json +13 -13
  37. package/lib-commonjs/cli/parsing/ParseParallelism.js +0 -3
  38. package/lib-commonjs/logic/operations/OperationExecutionManager.js +0 -3
  39. package/lib-commonjs/logic/operations/WeightedOperationPlugin.js +0 -3
  40. package/lib-dts/cli/parsing/ParseParallelism.d.ts +0 -6
  41. package/lib-dts/logic/operations/OperationExecutionManager.d.ts +0 -60
  42. package/lib-dts/logic/operations/WeightedOperationPlugin.d.ts +0 -10
@@ -31,6 +31,7 @@ import type { StdioSummarizer } from '@rushstack/terminal';
31
31
  import { SyncHook } from 'tapable';
32
32
  import { SyncWaterfallHook } from 'tapable';
33
33
  import { Terminal } from '@rushstack/terminal';
34
+ import type { TerminalWritable } from '@rushstack/terminal';
34
35
 
35
36
  /**
36
37
  * This represents the JSON file specified via the "approvedPackagesFile" option in rush.json.
@@ -537,6 +538,7 @@ export declare class EnvironmentConfiguration {
537
538
  private static _cobuildLeafProjectLogOnlyAllowed;
538
539
  private static _gitBinaryPath;
539
540
  private static _tarBinaryPath;
541
+ private static _quietMode;
540
542
  /**
541
543
  * If true, the environment configuration has been validated and initialized.
542
544
  */
@@ -629,6 +631,11 @@ export declare class EnvironmentConfiguration {
629
631
  * See {@link EnvironmentVariableNames.RUSH_TAR_BINARY_PATH}
630
632
  */
631
633
  static get tarBinaryPath(): string | undefined;
634
+ /**
635
+ * If `true`, Rush will suppress informational startup messages, equivalent to passing `--quiet`.
636
+ * See {@link EnvironmentVariableNames.RUSH_QUIET_MODE}
637
+ */
638
+ static get quietMode(): boolean;
632
639
  /**
633
640
  * The front-end RushVersionSelector relies on `RUSH_GLOBAL_FOLDER`, so its value must be read before
634
641
  * `EnvironmentConfiguration` is initialized (and actually before the correct version of `EnvironmentConfiguration`
@@ -867,10 +874,16 @@ export declare const EnvironmentVariableNames: {
867
874
  * if Rush did not explicitly pass along command-line parameters to their process.
868
875
  */
869
876
  readonly RUSH_INVOKED_ARGS: "RUSH_INVOKED_ARGS";
877
+ /**
878
+ * When set to `1` or `true`, this environment variable is equivalent to passing the `--quiet` flag
879
+ * to `rush`, `rushx`, and `install-run-rush.ts`. It suppresses informational startup messages
880
+ * while preserving error output.
881
+ */
882
+ readonly RUSH_QUIET_MODE: "RUSH_QUIET_MODE";
870
883
  };
871
884
 
872
885
  /**
873
- * Events happen during Rush runs.
886
+ * Events happen during Rush invocation.
874
887
  * @beta
875
888
  */
876
889
  declare enum Event_2 {
@@ -1042,6 +1055,31 @@ declare interface IBaseBuildCacheJson {
1042
1055
  cacheHashSalt?: string;
1043
1056
  }
1044
1057
 
1058
+ /**
1059
+ * @alpha
1060
+ */
1061
+ export declare interface IBaseOperationExecutionResult {
1062
+ /**
1063
+ * The operation itself
1064
+ */
1065
+ readonly operation: Operation;
1066
+ /**
1067
+ * The relative path to the folder that contains operation metadata. This folder will be automatically included in cache entries.
1068
+ */
1069
+ readonly metadataFolderPath: string;
1070
+ /**
1071
+ * Gets the hash of the state of all registered inputs to this operation.
1072
+ * Calling this method will throw if Git is not available.
1073
+ */
1074
+ getStateHash(): string;
1075
+ /**
1076
+ * Gets the structured components of the state hash. This is useful for debugging and
1077
+ * incremental change detection.
1078
+ * Calling this method will throw if Git is not available.
1079
+ */
1080
+ getStateHashComponents(): IOperationStateHashComponents;
1081
+ }
1082
+
1045
1083
  /**
1046
1084
  * @beta
1047
1085
  */
@@ -1182,6 +1220,18 @@ export declare interface ICobuildLockProvider {
1182
1220
  getCompletedStateAsync(context: Readonly<ICobuildContext>): Promise<ICobuildCompletedState | undefined>;
1183
1221
  }
1184
1222
 
1223
+ /**
1224
+ * The `IConfigurableOperation` interface represents an {@link Operation} whose
1225
+ * execution can be configured before running.
1226
+ * @alpha
1227
+ */
1228
+ export declare interface IConfigurableOperation extends IBaseOperationExecutionResult {
1229
+ /**
1230
+ * True if the operation should execute in this iteration, false otherwise.
1231
+ */
1232
+ enabled: boolean;
1233
+ }
1234
+
1185
1235
  /**
1186
1236
  * A collection of environment variables
1187
1237
  * @public
@@ -1234,16 +1284,15 @@ export declare interface ICreateOperationsContext {
1234
1284
  * Maps from the `longName` field in command-line.json to the parser configuration in ts-command-line.
1235
1285
  */
1236
1286
  readonly customParameters: ReadonlyMap<string, CommandLineParameter>;
1287
+ /**
1288
+ * If true, dependencies of the selected phases will be automatically enabled in the execution.
1289
+ */
1290
+ readonly includePhaseDeps: boolean;
1237
1291
  /**
1238
1292
  * If true, projects may read their output from cache or be skipped if already up to date.
1239
1293
  * If false, neither of the above may occur, e.g. "rush rebuild"
1240
1294
  */
1241
1295
  readonly isIncrementalBuildAllowed: boolean;
1242
- /**
1243
- * If true, this is the initial run of the command.
1244
- * If false, this execution is in response to changes.
1245
- */
1246
- readonly isInitial: boolean;
1247
1296
  /**
1248
1297
  * If true, the command is running in watch mode.
1249
1298
  */
@@ -1251,45 +1300,28 @@ export declare interface ICreateOperationsContext {
1251
1300
  /**
1252
1301
  * The currently configured maximum parallelism for the command.
1253
1302
  */
1254
- readonly parallelism: number;
1303
+ readonly parallelism: Parallelism;
1255
1304
  /**
1256
- * The set of phases original for the current command execution.
1257
- */
1258
- readonly phaseOriginal: ReadonlySet<IPhase>;
1259
- /**
1260
- * The set of phases selected for the current command execution.
1305
+ * The set of phases selected for execution.
1261
1306
  */
1262
1307
  readonly phaseSelection: ReadonlySet<IPhase>;
1263
- /**
1264
- * The set of Rush projects selected for the current command execution.
1265
- */
1266
- readonly projectSelection: ReadonlySet<RushConfigurationProject>;
1267
1308
  /**
1268
1309
  * All successfully loaded rush-project.json data for selected projects.
1269
1310
  */
1270
1311
  readonly projectConfigurations: ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>;
1271
1312
  /**
1272
- * The set of Rush projects that have not been built in the current process since they were last modified.
1273
- * When `isInitial` is true, this will be an exact match of `projectSelection`.
1313
+ * The set of Rush projects selected for execution.
1274
1314
  */
1275
- readonly projectsInUnknownState: ReadonlySet<RushConfigurationProject>;
1315
+ readonly projectSelection: ReadonlySet<RushConfigurationProject>;
1276
1316
  /**
1277
- * The Rush configuration
1317
+ * If true, the operation graph should include all projects in the repository (watch broad graph mode).
1318
+ * Only the projects in projectSelection should start enabled; others are present but disabled.
1278
1319
  */
1279
- readonly rushConfiguration: RushConfiguration;
1320
+ readonly generateFullGraph?: boolean;
1280
1321
  /**
1281
- * If true, Rush will automatically include the dependent phases for the specified set of phases.
1282
- * @remarks
1283
- * If the selection of projects was "unsafe" (i.e. missing some dependencies), this will add the
1284
- * minimum number of phases required to make it safe.
1285
- */
1286
- readonly includePhaseDeps: boolean;
1287
- /**
1288
- * Marks an operation's result as invalid, potentially triggering a new build. Only applicable in watch mode.
1289
- * @param operation - The operation to invalidate
1290
- * @param reason - The reason for invalidating the operation
1322
+ * The Rush configuration
1291
1323
  */
1292
- readonly invalidateOperation?: ((operation: Operation, reason: string) => void) | undefined;
1324
+ readonly rushConfiguration: RushConfiguration;
1293
1325
  }
1294
1326
 
1295
1327
  export { ICredentialCacheEntry }
@@ -1387,22 +1419,6 @@ declare interface IEventHooksJson {
1387
1419
  postRushBuild?: string[];
1388
1420
  }
1389
1421
 
1390
- /**
1391
- * Context used for executing operations.
1392
- * @alpha
1393
- */
1394
- export declare interface IExecuteOperationsContext extends ICreateOperationsContext {
1395
- /**
1396
- * The current state of the repository, if available.
1397
- * Not part of the creation context to avoid the overhead of Git calls when initializing the graph.
1398
- */
1399
- readonly inputsSnapshot?: IInputsSnapshot;
1400
- /**
1401
- * An abort controller that can be used to abort the current set of queued operations.
1402
- */
1403
- readonly abortController: AbortController;
1404
- }
1405
-
1406
1422
  /**
1407
1423
  * The `IExecutionResult` interface represents the results of executing a set of {@link Operation}s.
1408
1424
  * @alpha
@@ -1820,11 +1836,7 @@ export declare interface _IOperationBuildCacheOptions {
1820
1836
  * The `IOperationExecutionResult` interface represents the results of executing an {@link Operation}.
1821
1837
  * @alpha
1822
1838
  */
1823
- export declare interface IOperationExecutionResult {
1824
- /**
1825
- * The operation itself
1826
- */
1827
- readonly operation: Operation;
1839
+ export declare interface IOperationExecutionResult extends IBaseOperationExecutionResult, IOperationLastState {
1828
1840
  /**
1829
1841
  * The current execution status of an operation. Operations start in the 'ready' state,
1830
1842
  * but can be 'blocked' if an upstream operation failed. It is 'executing' when
@@ -1841,6 +1853,10 @@ export declare interface IOperationExecutionResult {
1841
1853
  * If this operation is only present in the graph to maintain dependency relationships, this flag will be set to true.
1842
1854
  */
1843
1855
  readonly silent: boolean;
1856
+ /**
1857
+ * True if the operation should execute in this iteration, false otherwise.
1858
+ */
1859
+ readonly enabled: boolean;
1844
1860
  /**
1845
1861
  * Object tracking execution timing.
1846
1862
  */
@@ -1857,24 +1873,165 @@ export declare interface IOperationExecutionResult {
1857
1873
  * The value indicates the duration of the same operation without cache hit.
1858
1874
  */
1859
1875
  readonly nonCachedDurationMs: number | undefined;
1860
- /**
1861
- * The relative path to the folder that contains operation metadata. This folder will be automatically included in cache entries.
1862
- */
1863
- readonly metadataFolderPath: string | undefined;
1864
1876
  /**
1865
1877
  * The paths to the log files, if applicable.
1866
1878
  */
1867
1879
  readonly logFilePaths: ILogFilePaths | undefined;
1880
+ }
1881
+
1882
+ /**
1883
+ * Public API for the operation graph.
1884
+ * @alpha
1885
+ */
1886
+ export declare interface IOperationGraph {
1868
1887
  /**
1869
- * Gets the hash of the state of all registered inputs to this operation.
1870
- * Calling this method will throw if Git is not available.
1888
+ * Hooks into the execution process for operations
1871
1889
  */
1872
- getStateHash(): string;
1890
+ readonly hooks: OperationGraphHooks;
1873
1891
  /**
1874
- * Gets the components of the state hash. This is useful for debugging purposes.
1875
- * Calling this method will throw if Git is not available.
1892
+ * The set of operations in the graph.
1893
+ */
1894
+ readonly operations: ReadonlySet<Operation>;
1895
+ /**
1896
+ * A map from each `Operation` in the graph to its current result record.
1897
+ * The map is updated in real time as operations execute during an iteration.
1898
+ * Only statuses representing a completed execution (e.g. `Success`, `Failure`,
1899
+ * `SuccessWithWarning`) write to this map; statuses such as `Skipped` or `Aborted` —
1900
+ * which indicate that an operation did not actually run — do not update it.
1901
+ * For operations that have not yet run in the current iteration, the map retains the
1902
+ * result from whichever prior iteration the operation last ran in.
1903
+ * An entry with status `Ready` indicates that the operation is considered stale and
1904
+ * has been queued to run again.
1905
+ * Empty until at least one operation has completed execution.
1906
+ */
1907
+ readonly resultByOperation: ReadonlyMap<Operation, IOperationExecutionResult>;
1908
+ /**
1909
+ * The maximum allowed parallelism for this operation graph.
1910
+ * Reads as a concrete integer. Accepts a `Parallelism` value and coerces it on write.
1911
+ */
1912
+ get parallelism(): number;
1913
+ set parallelism(value: Parallelism);
1914
+ /**
1915
+ * If additional debug information should be printed during execution.
1916
+ */
1917
+ debugMode: boolean;
1918
+ /**
1919
+ * If true, operations will be executed in "quiet mode" where only errors are reported.
1920
+ */
1921
+ quietMode: boolean;
1922
+ /**
1923
+ * If true, allow operations to oversubscribe the CPU. Defaults to true.
1924
+ */
1925
+ allowOversubscription: boolean;
1926
+ /**
1927
+ * When true, the operation graph will pause before running the next iteration (manual mode).
1928
+ * When false, iterations run automatically when scheduled.
1929
+ */
1930
+ pauseNextIteration: boolean;
1931
+ /**
1932
+ * The current overall status of the execution.
1933
+ */
1934
+ readonly status: OperationStatus;
1935
+ /**
1936
+ * The current set of terminal destinations.
1937
+ */
1938
+ readonly terminalDestinations: ReadonlySet<TerminalWritable>;
1939
+ /**
1940
+ * True if there is a scheduled (but not yet executing) iteration.
1941
+ * This will be false while an iteration is actively executing, or when no work is scheduled.
1942
+ */
1943
+ readonly hasScheduledIteration: boolean;
1944
+ /**
1945
+ * AbortController controlling the lifetime of the overall session (e.g. watch mode).
1946
+ * Aborting this controller should signal all listeners (such as file system watchers) to dispose
1947
+ * and prevent further iterations from being scheduled.
1948
+ */
1949
+ readonly abortController: AbortController;
1950
+ /**
1951
+ * Abort the current execution iteration, if any. Operations that have already started
1952
+ * will run to completion; only operations that have not yet begun will be aborted.
1953
+ */
1954
+ abortCurrentIterationAsync(): Promise<void>;
1955
+ /**
1956
+ * Cleans up any resources used by the operation runners, if applicable.
1957
+ * @param operations - The operations whose runners should be closed, or undefined to close all runners.
1958
+ */
1959
+ closeRunnersAsync(operations?: Iterable<Operation>): Promise<void>;
1960
+ /**
1961
+ * Executes a single iteration of the operations.
1962
+ * @param options - Options for this execution iteration.
1963
+ * @returns A promise that resolves to true if the iteration has work to be done, or false if the iteration was empty and therefore not scheduled.
1964
+ */
1965
+ scheduleIterationAsync(options: IOperationGraphIterationOptions): Promise<boolean>;
1966
+ /**
1967
+ * Executes all operations in the currently scheduled iteration, if any.
1968
+ * @returns A promise which is resolved when all operations have been processed to a final state.
1969
+ */
1970
+ executeScheduledIterationAsync(): Promise<boolean>;
1971
+ /**
1972
+ * Invalidates the specified operations, causing them to be re-executed.
1973
+ * @param operations - The operations to invalidate, or undefined to invalidate all operations.
1974
+ * @param reason - Optional reason for invalidation.
1975
+ */
1976
+ invalidateOperations(operations?: Iterable<Operation>, reason?: string): void;
1977
+ /**
1978
+ * Sets the enabled state for a collection of operations.
1979
+ *
1980
+ * @param operations - The operations whose enabled state should be updated.
1981
+ * @param targetState - The target enabled state to apply.
1982
+ * @param mode - 'unsafe' to directly mutate only the provided operations, 'safe' to also enable
1983
+ * transitive dependencies of enabled operations and disable transitive dependents of disabled operations.
1984
+ * @returns true if any operation's enabled state changed, false otherwise.
1985
+ */
1986
+ setEnabledStates(operations: Iterable<Operation>, targetState: Operation['enabled'], mode: 'safe' | 'unsafe'): boolean;
1987
+ /**
1988
+ * Adds a terminal destination for output. Only new output will be sent to the destination.
1989
+ * @param destination - The destination to add.
1990
+ */
1991
+ addTerminalDestination(destination: TerminalWritable): void;
1992
+ /**
1993
+ * Removes a terminal destination for output. Optionally closes the stream.
1994
+ * New output will no longer be sent to the destination.
1995
+ * @param destination - The destination to remove.
1996
+ * @param close - Whether to close the stream. Defaults to `true`.
1997
+ */
1998
+ removeTerminalDestination(destination: TerminalWritable, close?: boolean): boolean;
1999
+ }
2000
+
2001
+ /**
2002
+ * Context used for configuring the operation graph.
2003
+ * @alpha
2004
+ */
2005
+ export declare interface IOperationGraphContext extends ICreateOperationsContext {
2006
+ /**
2007
+ * The current state of the repository, if available.
2008
+ * Not part of the creation context to avoid the overhead of Git calls when initializing the graph.
2009
+ */
2010
+ readonly initialSnapshot?: IInputsSnapshot;
2011
+ }
2012
+
2013
+ /**
2014
+ * Options for a single iteration of operation execution.
2015
+ * @alpha
2016
+ */
2017
+ export declare interface IOperationGraphIterationOptions {
2018
+ inputsSnapshot?: IInputsSnapshot;
2019
+ /**
2020
+ * The time when the iteration was scheduled, if available, as returned by `performance.now()`.
2021
+ */
2022
+ startTime?: number;
2023
+ }
2024
+
2025
+ /**
2026
+ * A snapshot of a previous operation execution, passed to runners to inform incremental behavior.
2027
+ *
2028
+ * @beta
2029
+ */
2030
+ export declare interface IOperationLastState {
2031
+ /**
2032
+ * The status from the previous execution of this operation.
1876
2033
  */
1877
- getStateHashComponents(): ReadonlyArray<string>;
2034
+ readonly status: OperationStatus;
1878
2035
  }
1879
2036
 
1880
2037
  /**
@@ -1909,6 +2066,18 @@ export declare interface IOperationOptions {
1909
2066
  * The Rush project associated with this Operation
1910
2067
  */
1911
2068
  project: RushConfigurationProject;
2069
+ /**
2070
+ * If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped).
2071
+ * This is useful for plugins to alter the scope of the operation graph across executions,
2072
+ * e.g. to enable or disable unit test execution, or to include or exclude dependencies.
2073
+ *
2074
+ * The special value "ignore-dependency-changes" can be used to indicate that this operation should only
2075
+ * be executed if there are local changes in the project. This is useful for operations like
2076
+ * "test" where you may want to skip testing projects that haven't changed.
2077
+ *
2078
+ * The default value is `true`, meaning the operation will be executed if it or any dependencies change.
2079
+ */
2080
+ enabled?: OperationEnabledState;
1912
2081
  /**
1913
2082
  * When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
1914
2083
  * running the operation.
@@ -1926,7 +2095,7 @@ export declare interface IOperationOptions {
1926
2095
 
1927
2096
  /**
1928
2097
  * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
1929
- * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
2098
+ * `OperationGraph`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
1930
2099
  * implementation manages the actual process for running a single operation.
1931
2100
  *
1932
2101
  * @beta
@@ -1958,14 +2127,27 @@ export declare interface IOperationRunner {
1958
2127
  * analysis purposes.
1959
2128
  */
1960
2129
  readonly isNoOp?: boolean;
2130
+ /**
2131
+ * If true, this runner currently owns some kind of active resource (e.g. a service or a watch process).
2132
+ * This can be used to determine if the operation is "in progress" even if it is not currently executing.
2133
+ * If the runner supports this property, it should update it as appropriate during execution.
2134
+ * The property is optional to avoid breaking existing implementations of IOperationRunner.
2135
+ */
2136
+ readonly isActive?: boolean;
1961
2137
  /**
1962
2138
  * Method to be executed for the operation.
2139
+ * @param context - The context object containing information about the execution environment.
2140
+ * @param lastState - The last execution result of this operation, if any.
1963
2141
  */
1964
- executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
2142
+ executeAsync(context: IOperationRunnerContext, lastState?: IOperationLastState): Promise<OperationStatus>;
1965
2143
  /**
1966
2144
  * Return a hash of the configuration that affects the operation.
1967
2145
  */
1968
2146
  getConfigHash(): string;
2147
+ /**
2148
+ * If this runner performs any background work to optimize future runs, this method will clean it up.
2149
+ */
2150
+ closeAsync?(): Promise<void>;
1969
2151
  }
1970
2152
 
1971
2153
  /**
@@ -2013,6 +2195,12 @@ export declare interface IOperationRunnerContext {
2013
2195
  * it later (for example to re-print errors at end of execution).
2014
2196
  */
2015
2197
  error?: Error;
2198
+ /**
2199
+ * Returns a callback that invalidates this operation so that it will be re-executed in the next iteration.
2200
+ * The returned callback captures only the minimal state needed, avoiding retention of the full context.
2201
+ * Callers should store the result rather than calling this method repeatedly.
2202
+ */
2203
+ getInvalidateCallback(): (reason: string) => void;
2016
2204
  /**
2017
2205
  * Invokes the specified callback with a terminal that is associated with this operation.
2018
2206
  *
@@ -2094,7 +2282,7 @@ export declare interface IOperationSettings {
2094
2282
  * How many concurrency units this operation should take up during execution. The maximum concurrent units is
2095
2283
  * determined by the -p flag.
2096
2284
  */
2097
- weight?: number;
2285
+ weight?: number | `${number}%`;
2098
2286
  /**
2099
2287
  * If true, this operation can use cobuilds for orchestration without restoring build cache entries.
2100
2288
  */
@@ -2120,6 +2308,26 @@ export declare interface _IOperationStateFileOptions {
2120
2308
  metadataFolder: string;
2121
2309
  }
2122
2310
 
2311
+ /**
2312
+ * Structured components of the state hash for an operation.
2313
+ * @alpha
2314
+ */
2315
+ export declare interface IOperationStateHashComponents {
2316
+ /**
2317
+ * The state hashes of operation dependencies, sorted by name.
2318
+ * Each entry is of the form `{dependencyName}={hash}`.
2319
+ */
2320
+ readonly dependencies: readonly string[];
2321
+ /**
2322
+ * The hash of the operation's own local inputs (e.g. tracked files, environment variables).
2323
+ */
2324
+ readonly local: string;
2325
+ /**
2326
+ * The hash of the operation's configuration (e.g. CLI parameters).
2327
+ */
2328
+ readonly config: string;
2329
+ }
2330
+
2123
2331
  /**
2124
2332
  * @internal
2125
2333
  */
@@ -2140,6 +2348,14 @@ export declare interface IPackageManagerOptionsJsonBase {
2140
2348
  environmentVariables?: IConfigurationEnvironment;
2141
2349
  }
2142
2350
 
2351
+ /**
2352
+ * A parallelism value expressed as a fraction of total available concurrency slots.
2353
+ * @beta
2354
+ */
2355
+ export declare interface IParallelismScalar {
2356
+ readonly scalar: number;
2357
+ }
2358
+
2143
2359
  /**
2144
2360
  * Metadata about a phase.
2145
2361
  * @alpha
@@ -2215,6 +2431,17 @@ export declare interface IPhasedCommand extends IRushCommand {
2215
2431
  readonly sessionAbortController: AbortController;
2216
2432
  }
2217
2433
 
2434
+ /**
2435
+ * A plugin that interacts with a phased commands.
2436
+ * @alpha
2437
+ */
2438
+ export declare interface IPhasedCommandPlugin {
2439
+ /**
2440
+ * Applies this plugin.
2441
+ */
2442
+ apply(hooks: PhasedCommandHooks): void;
2443
+ }
2444
+
2218
2445
  /**
2219
2446
  * Possible values for the `pnpmLockfilePolicies` setting in Rush's pnpm-config.json file.
2220
2447
  * @public
@@ -2942,7 +3169,7 @@ export declare class NpmOptionsConfiguration extends PackageManagerOptionsConfig
2942
3169
 
2943
3170
  /**
2944
3171
  * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
2945
- * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
3172
+ * `OperationGraph`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
2946
3173
  * implementation manages the actual process of running a single operation.
2947
3174
  *
2948
3175
  * The graph of `Operation` instances will be cloned into a separate execution graph after processing.
@@ -2978,17 +3205,23 @@ export declare class Operation {
2978
3205
  */
2979
3206
  runner: IOperationRunner | undefined;
2980
3207
  /**
2981
- * The weight for this operation. This scalar is the contribution of this operation to the
2982
- * `criticalPathLength` calculation above. Modify to indicate the following:
2983
- * - `weight` === 1: indicates that this operation has an average duration
2984
- * - `weight` &gt; 1: indicates that this operation takes longer than average and so the scheduler
2985
- * should try to favor starting it over other, shorter operations. An example might be an operation that
2986
- * bundles an entire application and runs whole-program optimization.
2987
- * - `weight` &lt; 1: indicates that this operation takes less time than average and so the scheduler
2988
- * should favor other, longer operations over it. An example might be an operation to unpack a cached
2989
- * output, or an operation using NullOperationRunner, which might use a value of 0.
3208
+ * The concurrency weight for this operation. When coerced to an integer via `coerceParallelism`,
3209
+ * this value represents how many concurrency slots the operation consumes while running.
3210
+ *
3211
+ * May be specified as:
3212
+ * - A raw `number`: used directly as the slot count (e.g. `2` consumes two slots).
3213
+ * - An `IParallelismScalar` (e.g. `{ scalar: 0.5 }`): coerced relative to the graph's
3214
+ * configured `maxParallelism` at execution time, so the weight scales with the available
3215
+ * concurrency rather than being fixed at parse time.
3216
+ *
3217
+ * Coerced values guide scheduling as follows:
3218
+ * - `1` slot: typical operation consuming one logical thread.
3219
+ * - `> 1` slots: operation that spawns multiple threads or requires significant RAM; reserving
3220
+ * extra slots prevents overloading the machine (e.g. a whole-program bundler or a test suite
3221
+ * that runs its own internal parallelism).
3222
+ * - `0` slots: effectively free (e.g. a no-op or cache-restore step).
2990
3223
  */
2991
- weight: number;
3224
+ weight: Parallelism;
2992
3225
  /**
2993
3226
  * Get the operation settings for this operation, defaults to the values defined in
2994
3227
  * the project configuration.
@@ -2998,8 +3231,14 @@ export declare class Operation {
2998
3231
  * If set to false, this operation will be skipped during evaluation (return OperationStatus.Skipped).
2999
3232
  * This is useful for plugins to alter the scope of the operation graph across executions,
3000
3233
  * e.g. to enable or disable unit test execution, or to include or exclude dependencies.
3234
+ *
3235
+ * The special value "ignore-dependency-changes" can be used to indicate that this operation should only
3236
+ * be executed if there are local changes in the project. This is useful for operations like
3237
+ * "test" where you may want to skip testing projects that haven't changed.
3238
+ *
3239
+ * The default value is `true`, meaning the operation will be executed if it or any dependencies change.
3001
3240
  */
3002
- enabled: boolean;
3241
+ enabled: OperationEnabledState;
3003
3242
  constructor(options: IOperationOptions);
3004
3243
  /**
3005
3244
  * The name of this operation, for logging.
@@ -3036,7 +3275,7 @@ export declare class _OperationBuildCache {
3036
3275
  private static _tryGetTarUtility;
3037
3276
  get cacheId(): string | undefined;
3038
3277
  static getOperationBuildCache(options: _IProjectBuildCacheOptions): _OperationBuildCache;
3039
- static forOperation(executionResult: IOperationExecutionResult, options: _IOperationBuildCacheOptions): _OperationBuildCache;
3278
+ static forOperation(executionResult: IBaseOperationExecutionResult, options: _IOperationBuildCacheOptions): _OperationBuildCache;
3040
3279
  tryRestoreFromCacheAsync(terminal: ITerminal, specifiedCacheId?: string): Promise<boolean>;
3041
3280
  trySetCacheEntryAsync(terminal: ITerminal, specifiedCacheId?: string): Promise<boolean>;
3042
3281
  /**
@@ -3049,6 +3288,139 @@ export declare class _OperationBuildCache {
3049
3288
  private static _getCacheId;
3050
3289
  }
3051
3290
 
3291
+ /**
3292
+ * State for the `enabled` property of an `Operation`.
3293
+ *
3294
+ * - `true`: The operation should be executed if it or any dependencies changed.
3295
+ * - `false`: The operation should be skipped.
3296
+ * - `"ignore-dependency-changes"`: The operation should be executed if there are local changes in the project,
3297
+ * otherwise it should be skipped. This is useful for operations like "test" where you may want to skip
3298
+ * testing projects that haven't changed.
3299
+ * @alpha
3300
+ */
3301
+ export declare type OperationEnabledState = boolean | 'ignore-dependency-changes';
3302
+
3303
+ /**
3304
+ * Hooks into the execution process for operations within the graph.
3305
+ *
3306
+ * Per-iteration lifecycle:
3307
+ * 1. `configureIteration` - Synchronously decide which operations to enable for the next iteration.
3308
+ * 2. `onIterationScheduled` - Fires after the iteration is prepared but before execution begins, if it has any enabled operations.
3309
+ * 3. `beforeExecuteIterationAsync` - Async hook that can bail out the iteration entirely.
3310
+ * 4. Operations execute (status changes reported via `onExecutionStatesUpdated`).
3311
+ * 5. `afterExecuteIterationAsync` - Fires after all operations in the iteration have settled.
3312
+ * 6. `onIdle` - Fires when the graph enters idle state awaiting changes (watch mode only).
3313
+ *
3314
+ * Additional hooks:
3315
+ * - `onEnableStatesChanged` - Fires when `setEnabledStates` mutates operation enabled flags.
3316
+ * - `onInvalidateOperations` - Fires when operations are invalidated (e.g. by file watchers).
3317
+ * - `onGraphStateChanged` - Fires on any observable graph state change.
3318
+ *
3319
+ * @alpha
3320
+ */
3321
+ export declare class OperationGraphHooks {
3322
+ /**
3323
+ * Hook invoked to decide what work a potential new iteration contains.
3324
+ * Use the `lastExecutedRecords` to determine which operations are new or have had their inputs changed.
3325
+ * Set the `enabled` states on the values in `initialRecords` to control which operations will be executed.
3326
+ *
3327
+ * @remarks
3328
+ * This hook is synchronous to guarantee that the `lastExecutedRecords` map remains stable for the
3329
+ * duration of configuration. This hook often executes while an execution iteration is currently running, so
3330
+ * operations could complete if there were async ticks during the configuration phase.
3331
+ *
3332
+ * If no operations are marked for execution, the iteration will not be scheduled.
3333
+ * If there is an existing scheduled iteration, it will remain.
3334
+ */
3335
+ readonly configureIteration: SyncHook<[
3336
+ ReadonlyMap<Operation, IConfigurableOperation>,
3337
+ ReadonlyMap<Operation, IOperationExecutionResult>,
3338
+ IOperationGraphIterationOptions
3339
+ ]>;
3340
+ /**
3341
+ * Hook invoked before operation start for an iteration. Allows a plugin to perform side-effects or
3342
+ * short-circuit the entire iteration.
3343
+ *
3344
+ * If any tap returns an {@link OperationStatus}, the remaining taps are skipped and the iteration will
3345
+ * end immediately with that status. All operations which have not yet executed will be marked
3346
+ * Aborted.
3347
+ */
3348
+ readonly beforeExecuteIterationAsync: AsyncSeriesBailHook<[
3349
+ ReadonlyMap<Operation, IOperationExecutionResult>,
3350
+ IOperationGraphIterationOptions
3351
+ ], OperationStatus | undefined | void>;
3352
+ /**
3353
+ * Batched hook invoked when one or more operation statuses have changed during the same microtask.
3354
+ * The hook receives an array of the operation execution results that changed status.
3355
+ * @remarks
3356
+ * This hook is batched to reduce noise when updating many operations synchronously in quick succession.
3357
+ */
3358
+ readonly onExecutionStatesUpdated: SyncHook<[ReadonlySet<IOperationExecutionResult>]>;
3359
+ /**
3360
+ * Hook invoked when one or more operations have their enabled state mutated via
3361
+ * {@link IOperationGraph.setEnabledStates}. Provides the set of operations whose
3362
+ * enabled state actually changed.
3363
+ */
3364
+ readonly onEnableStatesChanged: SyncHook<[ReadonlySet<Operation>]>;
3365
+ /**
3366
+ * Hook invoked immediately after a new execution iteration is scheduled (i.e. operations selected and prepared),
3367
+ * before any operations in that iteration have started executing. Can be used to snapshot planned work,
3368
+ * drive UIs, or pre-compute auxiliary data.
3369
+ */
3370
+ readonly onIterationScheduled: SyncHook<[ReadonlyMap<Operation, IOperationExecutionResult>]>;
3371
+ /**
3372
+ * Hook invoked when any observable state on the operation graph changes.
3373
+ * This includes configuration mutations (parallelism, quiet/debug modes, pauseNextIteration)
3374
+ * as well as dynamic state (status transitions, scheduled iteration availability, etc.).
3375
+ * Hook is series for stable output.
3376
+ */
3377
+ readonly onGraphStateChanged: SyncHook<[IOperationGraph]>;
3378
+ /**
3379
+ * Hook invoked when operations are invalidated for any reason.
3380
+ */
3381
+ readonly onInvalidateOperations: SyncHook<[Iterable<Operation>, string | undefined]>;
3382
+ /**
3383
+ * Hook invoked after an iteration has finished and the command is watching for changes.
3384
+ * May be used to display additional relevant data to the user.
3385
+ * Only relevant when running in watch mode.
3386
+ */
3387
+ readonly onIdle: SyncHook<void>;
3388
+ /**
3389
+ * Hook invoked after executing a set of operations.
3390
+ * Hook is series for stable output.
3391
+ */
3392
+ readonly afterExecuteIterationAsync: AsyncSeriesWaterfallHook<[
3393
+ OperationStatus,
3394
+ ReadonlyMap<Operation, IOperationExecutionResult>,
3395
+ IOperationGraphIterationOptions
3396
+ ]>;
3397
+ /**
3398
+ * Hook invoked after executing an iteration, before the telemetry entry is written.
3399
+ * Allows the caller to augment or modify the log entry.
3400
+ */
3401
+ readonly beforeLog: SyncHook<ITelemetryData, void>;
3402
+ /**
3403
+ * Hook invoked before executing a operation.
3404
+ */
3405
+ readonly beforeExecuteOperationAsync: AsyncSeriesBailHook<[
3406
+ IOperationRunnerContext & IOperationExecutionResult
3407
+ ], OperationStatus | undefined>;
3408
+ /**
3409
+ * Hook invoked to define environment variables for an operation.
3410
+ * May be invoked by the runner to get the environment for the operation.
3411
+ */
3412
+ readonly createEnvironmentForOperation: SyncWaterfallHook<[
3413
+ IEnvironment,
3414
+ IOperationRunnerContext & IOperationExecutionResult
3415
+ ]>;
3416
+ /**
3417
+ * Hook invoked after executing a operation.
3418
+ */
3419
+ readonly afterExecuteOperationAsync: AsyncSeriesHook<[
3420
+ IOperationRunnerContext & IOperationExecutionResult
3421
+ ]>;
3422
+ }
3423
+
3052
3424
  /**
3053
3425
  * A helper class for managing the meta files of a operation.
3054
3426
  *
@@ -3293,69 +3665,34 @@ export declare abstract class PackageManagerOptionsConfigurationBase implements
3293
3665
  }
3294
3666
 
3295
3667
  /**
3296
- * Hooks into the execution process for phased commands
3668
+ * A parallelism value, either as an absolute integer count or a scalar fraction of available parallelism.
3669
+ * @beta
3670
+ */
3671
+ export declare type Parallelism = number | IParallelismScalar;
3672
+
3673
+ /**
3674
+ * Hooks into the execution process for phased commands.
3675
+ *
3676
+ * Lifecycle:
3677
+ * 1. `createOperationsAsync` - Invoked to populate the set of operations for execution.
3678
+ * 2. `onGraphCreatedAsync` - Invoked after the operation graph is created, allowing plugins to
3679
+ * tap into graph-level hooks (e.g. `configureIteration`, `onIdle`).
3680
+ * See {@link OperationGraphHooks} for the per-iteration lifecycle.
3681
+ *
3297
3682
  * @alpha
3298
3683
  */
3299
3684
  export declare class PhasedCommandHooks {
3300
3685
  /**
3301
3686
  * Hook invoked to create operations for execution.
3302
- * Use the context to distinguish between the initial run and phased runs.
3303
- */
3304
- readonly createOperations: AsyncSeriesWaterfallHook<[Set<Operation>, ICreateOperationsContext]>;
3305
- /**
3306
- * Hook invoked before operation start
3307
- * Hook is series for stable output.
3308
- */
3309
- readonly beforeExecuteOperations: AsyncSeriesHook<[
3310
- Map<Operation, IOperationExecutionResult>,
3311
- IExecuteOperationsContext
3312
- ]>;
3313
- /**
3314
- * Hook invoked when operation status changed
3315
- * Hook is series for stable output.
3316
- */
3317
- readonly onOperationStatusChanged: SyncHook<[IOperationExecutionResult]>;
3318
- /**
3319
- * Hook invoked after executing a set of operations.
3320
- * Use the context to distinguish between the initial run and phased runs.
3321
- * Hook is series for stable output.
3322
- */
3323
- readonly afterExecuteOperations: AsyncSeriesHook<[IExecutionResult, IExecuteOperationsContext]>;
3324
- /**
3325
- * Hook invoked before executing a operation.
3326
- */
3327
- readonly beforeExecuteOperation: AsyncSeriesBailHook<[
3328
- IOperationRunnerContext & IOperationExecutionResult
3329
- ], OperationStatus | undefined>;
3330
- /**
3331
- * Hook invoked to define environment variables for an operation.
3332
- * May be invoked by the runner to get the environment for the operation.
3333
- */
3334
- readonly createEnvironmentForOperation: SyncWaterfallHook<[
3335
- IEnvironment,
3336
- IOperationRunnerContext & IOperationExecutionResult
3337
- ]>;
3338
- /**
3339
- * Hook invoked after executing a operation.
3340
3687
  */
3341
- readonly afterExecuteOperation: AsyncSeriesHook<[
3342
- IOperationRunnerContext & IOperationExecutionResult
3688
+ readonly createOperationsAsync: AsyncSeriesWaterfallHook<[
3689
+ Set<Operation>,
3690
+ ICreateOperationsContext
3343
3691
  ]>;
3344
3692
  /**
3345
- * Hook invoked to shutdown long-lived work in plugins.
3693
+ * Hook invoked when the operation graph is created, allowing the plugin to tap into it and interact with it.
3346
3694
  */
3347
- readonly shutdownAsync: AsyncParallelHook<void>;
3348
- /**
3349
- * Hook invoked after a run has finished and the command is watching for changes.
3350
- * May be used to display additional relevant data to the user.
3351
- * Only relevant when running in watch mode.
3352
- */
3353
- readonly waitingForChanges: SyncHook<void>;
3354
- /**
3355
- * Hook invoked after executing operations and before waitingForChanges. Allows the caller
3356
- * to augment or modify the log entry about to be written.
3357
- */
3358
- readonly beforeLog: SyncHook<ITelemetryData, void>;
3695
+ readonly onGraphCreatedAsync: AsyncSeriesHook<[IOperationGraph, IOperationGraphContext]>;
3359
3696
  }
3360
3697
 
3361
3698
  /**