Skip to content

[main] Source code updates from dnceng/internal/dotnet-build-insights - #6606

Merged
premun merged 3 commits into
mainfrom
darc-main-da4b05f7-f160-49b1-9343-a1eaebf851e5
Aug 18, 2026
Merged

[main] Source code updates from dnceng/internal/dotnet-build-insights#6606
premun merged 3 commits into
mainfrom
darc-main-da4b05f7-f160-49b1-9343-a1eaebf851e5

Conversation

@dotnet-maestro

@dotnet-maestro dotnet-maestro Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

This is a codeflow update. It may contain both source code changes from
the VMR
as well as dependency updates. Learn more here.

This pull request brings the following source code changes

From https://dev.azure.com/dnceng/internal/_git/dotnet-build-insights

Associated changes in source repos

Diff the source with this PR branch
darc vmr diff --name-only https://dev.azure.com/dnceng/internal/_git/dotnet-build-insights:53e42fd264381a413668d21596cf3d23160c94bf..https://github.com/dotnet/arcade-services:darc-main-da4b05f7-f160-49b1-9343-a1eaebf851e5

@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

Note

VMR PRs included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/prodconsvcs for assistance.

No dependency updates to commit
[[ commit created by automation ]]

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

This PR is a codeflow update that reworks PCS work-item processing control from a single “state” key into a desired/observed protocol, adding an in-process admission gate and a replica-side controller to safely stop/start queue processing during deployments and operator actions.

Changes:

  • Introduces IWorkItemProcessorStateStore (desired + observed Redis keys), WorkItemAdmissionGate, and WorkItemProcessorStateController to manage replica-side queue admission and state acknowledgements.
  • Updates the deployment CLI flow to coordinate replica state across revisions via ReplicaStateCoordinator before traffic transfer and cleanup.
  • Updates PCS API initialization and the /status controller to use the new state protocol; adjusts/expands tests accordingly.

Reviewed changes

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

Show a summary per file
File Description
tools/Tools.Cli.Common/Options/DeploymentOptions.cs Updates CLI DI registrations to use the new replica provider + state store + coordinator.
tools/Tools.Cli.Common/Operations/ReplicaStateCoordinator.cs Adds control-plane polling logic for desired/observed state convergence per revision replica set.
tools/Tools.Cli.Common/Operations/DeploymentOperation.cs Reworks deployment sequencing to stop old replicas, start candidate replicas, transfer traffic, and cleanup state keys.
src/Maestro/Maestro.WorkItems/WorkItemProcessorState.cs Replaces string-based state machine with a simplified WorkItemProcessorState enum.
src/Maestro/Maestro.WorkItems/WorkItemProcessorStateStore.cs Adds desired/observed Redis key storage for queue processing state.
src/Maestro/Maestro.WorkItems/ReplicaWorkItemProcessorStateStore.cs Adds replica-scoped interface to enforce “replica reads desired, writes observed”.
src/Maestro/Maestro.WorkItems/WorkItemAdmissionGate.cs Adds an in-process admission gate + draining semantics for safe stopping.
src/Maestro/Maestro.WorkItems/WorkItemProcessorStateController.cs Adds a hosted service to reconcile desired state into admission open/close and observed acknowledgements.
src/Maestro/Maestro.WorkItems/WorkItemScopeManager.cs Switches work-item scope creation to be governed by the admission gate (with cancellation).
src/Maestro/Maestro.WorkItems/WorkItemProcessorReplicaProvider.cs Adds replica enumeration abstraction for local vs ACA environments.
src/Maestro/Maestro.WorkItems/WorkItemConsumer.cs Updates consumer loop to pass cancellation into scope admission and stop cleanly on cancellation.
src/Maestro/Maestro.WorkItems/WorkItemConfiguration.cs Registers new state/admission/controller services and improves local queue initialization logging/perf.
src/ProductConstructionService/ProductConstructionService.Api/Controllers/StatusController.cs Moves Start/Stop/Status to replicaProvider + stateStore using desired/observed keys.
src/ProductConstructionService/ProductConstructionService.Api/InitializationHealthCheck.cs Uses WorkItemProcessorStateController.IsInitializationPending instead of querying old state.
src/ProductConstructionService/ProductConstructionService.Api/InitializationBackgroundService.cs Signals initialization completion via the state controller.
src/ProductConstructionService/ProductConstructionService.Api/Configuration/WorkItemProcessorStateInitialization.cs In dev only, seeds desired state to Working for the local replica.
test/Maestro/Maestro.WorkItems.Tests/WorkItemScopeTests.cs Updates tests to use admission gate; adds assertions around admission release and closed-gate behavior.
test/Maestro/Maestro.WorkItems.Tests/WorkItemProcessorStateStoreTests.cs Adds coverage for desired/observed keys, parsing, and delete behavior.
test/Maestro/Maestro.WorkItems.Tests/WorkItemProcessorStateControllerTests.cs Adds coverage for controller start/stop sequencing, draining, and initialization gating.
test/Maestro/Maestro.WorkItems.Tests/WorkItemAdmissionGateTests.cs Adds coverage for open/close/drain semantics.
test/Maestro/Maestro.WorkItems.Tests/FakeRedisCache.cs Expands fake Redis to support multi-key store; adds a fake cache factory.
test/Maestro/Maestro.WorkItems.Tests/WorkItemsProcessorScopeManagerTests.cs Removes legacy tests tied to the old state machine implementation.
src/Maestro/Maestro.WorkItems/WorkItemProcessorStateCache.cs Removes legacy single-key state cache implementation.
src/Maestro/Maestro.WorkItems/ReplicaWorkItemProcessorStateCache.cs Removes legacy replica cache factory implementation.
src/Maestro/Maestro.WorkItems/LocalReplicaWorkItemProcessorStateCacheFactory.cs Removes legacy local replica cache factory.
global.json Adds additional runtime roll-forward entries (10.0.10 alongside 10.0.11).
eng/Version.Details.xml Updates codeflow source SHA/BarId for dotnet-build-insights.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Maestro/Maestro.WorkItems/WorkItemProcessorStateStore.cs
Comment thread src/Maestro/Maestro.WorkItems/WorkItemProcessorStateController.cs

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

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Suppressed comments (7)

tools/Tools.Cli.Common/Operations/ReplicaStateCoordinator.cs:61

  • The first rollout of this protocol cannot stop an existing replica running the previous implementation: that code reads and writes the single <replicaName> key and transitions through Stopping, while this code writes queue-processing-state:<replica>:desired and waits on a new observed key. Such replicas can never acknowledge this command, so deployment times out and compensates instead of upgrading. Add a migration path that can stop legacy replicas, or stage a backward-compatible replica implementation before switching the coordinator.
                    await _stateStore.SetDesiredStateAsync(replicaName, desiredState, cancellationToken);

tools/Tools.Cli.Common/Operations/DeploymentOperation.cs:199

  • This newly added async helper must use the Async suffix per the repository's C# coding guidelines; rename it to CompensateAsync and update its callers.
    private async Task Compensate(string? oldRevisionName, string? candidateRevisionName)

tools/Tools.Cli.Common/Operations/DeploymentOperation.cs:229

  • This newly added async helper must use the Async suffix per the repository's C# coding guidelines; rename it to WaitForRevisionToBecomeHealthyAsync and update its caller.
    private async Task<bool> WaitForRevisionToBecomeHealthy(string revisionName, bool wasReusedInactiveCandidate)

tools/Tools.Cli.Common/Operations/DeploymentOperation.cs:346

  • This newly added async helper must use the Async suffix per the repository's C# coding guidelines; rename it to StopDeactivateAndCleanupRevisionAsync and update its callers.
    private async Task<bool> StopDeactivateAndCleanupRevision(string revisionName)

tools/Tools.Cli.Common/Operations/DeploymentOperation.cs:466

  • This newly added async helper must use the Async suffix per the repository's C# coding guidelines; rename it to ActivateRevisionAsync and update its callers.
    private async Task ActivateRevision(string revisionName)

tools/Tools.Cli.Common/Operations/DeploymentOperation.cs:160

  • This newly added async helper must use the Async suffix per the repository's C# coding guidelines; rename it to TransferTrafficAsync and update its caller.

This issue also appears in the following locations of the same file:

  • line 199
  • line 229
  • line 346
  • line 466
    private async Task<bool> TransferTraffic(string candidateRevisionName, string? oldRevisionName, string label)

src/Maestro/Maestro.WorkItems/WorkItemProcessorStateStore.cs:110

  • These writes no longer set the 60-day expiration used by the removed state cache. Replica names disappear during scale-in, and keys written by the status endpoints are not tracked by ReplicaStateCoordinator.DeleteStateAsync, so desired/observed keys for retired replicas can accumulate indefinitely (and remain available as stale state if a name is reused). Restore a bounded retention policy or add authoritative cleanup for departed replicas.
        await _redisCacheFactory.Create(key).SetAsync(state.ToString());

Comment thread tools/Tools.Cli.Common/Operations/ReplicaStateCoordinator.cs
Comment thread tools/Tools.Cli.Common/Operations/DeploymentOperation.cs
@premun
premun merged commit 00959cc into main Aug 18, 2026
13 checks passed
@premun
premun deleted the darc-main-da4b05f7-f160-49b1-9343-a1eaebf851e5 branch August 18, 2026 10:03
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