Skip to content

Return PrUpdater states and persist them in DB#6290

Merged
adamzip merged 18 commits into
dotnet:mainfrom
adamzip:register-subscription-outcomes
May 22, 2026
Merged

Return PrUpdater states and persist them in DB#6290
adamzip merged 18 commits into
dotnet:mainfrom
adamzip:register-subscription-outcomes

Conversation

@adamzip

@adamzip adamzip commented May 12, 2026

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings May 12, 2026 15:34

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 changes the dependency-flow subscription update pipeline to return a structured SubscriptionUpdateResult from PR updaters and introduces infrastructure intended to persist update outcomes to the BAR database (via SubscriptionOutcome). It also plumbs work item attempt metadata so “final attempt” logic can be applied when recording failures.

Changes:

  • Introduces SubscriptionUpdateResult and updates PR updaters/processors/triggerer interfaces to return it instead of Task/bool.
  • Adds SubscriptionUpdateOutcomeRecorder and wires it into SubscriptionUpdateProcessor and SubscriptionTriggerProcessor to persist outcomes.
  • Adds attempt/max-attempt tracking to WorkItem/WorkItemScope/WorkItemConsumer to enable “record only on final attempt” behavior.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
test/ProductConstructionService/ProductConstructionService.DependencyFlow.Tests/SubscriptionUpdaterTests.cs Updates test callsites for new UpdateSubscriptionAsync signature.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/WorkItemProcessors/SubscriptionUpdateProcessor.cs Wraps subscription updates in outcome recorder; switches to returning SubscriptionUpdateResult.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/WorkItemProcessors/SubscriptionTriggerProcessor.cs Wraps trigger updates in outcome recorder; returns SubscriptionUpdateResult and passes entities through.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/SubscriptionUpdateOutcomeRecorder.cs New component intended to record/persist subscription outcomes.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/SubscriptionTriggerer.cs Returns SubscriptionUpdateResult from the underlying PR updater.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdaters/SubscriptionUpdateResult.cs New record type representing outcome message/type/PR URL.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdaters/PullRequestUpdater.cs Changes pending-update processing to return SubscriptionUpdateResult; adds reschedule result path.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdaters/DependencyPullRequestUpdater.cs Implements outcome results for dependency PR updates/creation.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdaters/CodeFlowPullRequestUpdater.cs Implements outcome results for codeflow paths; refactors flow execution/exception handling.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/ISubscriptionTriggerer.cs Updates interface to return SubscriptionUpdateResult and accept entities.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/IPullRequestUpdater.cs Updates interface methods to return SubscriptionUpdateResult.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/DependencyFlowConfiguration.cs Registers ISubscriptionUpdateOutcomeRecorder.
src/Microsoft.DotNet.Darc/DarcLib/Models/VirtualMonoRepo/CodeFlowResult.cs Extends CodeFlowResult with FlowIsBlocked.
src/Maestro/Maestro.WorkItems/WorkItemScope.cs Adds overloads to pass attempt/max-attempt info into work item creation.
src/Maestro/Maestro.WorkItems/WorkItemConsumer.cs Passes dequeue count/max retries into work item scope; makes NonRetriableException public.
src/Maestro/Maestro.WorkItems/WorkItem.cs Adds attempt tracking and IsFinalAttempt() helper.
src/Maestro/Maestro.Data/Models/SubscriptionOutcome.cs Renames/extends outcome enum to SubscriptionOutcomeType and adds new outcome values.
Comments suppressed due to low confidence (1)

src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdaters/CodeFlowPullRequestUpdater.cs:355

  • InvokeFlowAsync no longer handles TargetBranchNotFoundException (previously treated as a non-fatal stop). It will now be caught by the generic catch, logged as an error, and rethrown, causing work item retries and eventual discard. If a missing target branch is non-retriable/user-error, map it to an appropriate SubscriptionUpdateResult (e.g., NotUpdatable/UserError) or throw NonRetriableException so it isn’t retried.
        catch (Exception e) when (e is not NonLinearCodeflowException)
        {
            _logger.LogError("Failed to flow source changes for build {buildId} in subscription {subscriptionId}",
                build.Id,
                subscription.Id);

Comment thread src/Maestro/Maestro.WorkItems/WorkItem.cs
Comment thread src/Maestro/Maestro.Data/Models/SubscriptionOutcome.cs
@dkurepa

dkurepa commented May 14, 2026

Copy link
Copy Markdown
Member

we should add/enhance existing tests for the new feature

Comment thread src/Maestro/Maestro.Data/Models/SubscriptionOutcome.cs

@premun premun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamzip we have many tests testing the dependency flow outcomes (the pr updater etc). Should we also add verifications to these that the right outcome happened? It would be of a great value, I am quite sure.

- Remove prUrl from PR updater status
- Rework status messages
- Add UserException which is a type of NonRetriableException
Comment thread src/Maestro/Maestro.WorkItems/WorkItemConsumer.cs Outdated
Comment thread src/Maestro/Maestro.Data/Models/SubscriptionOutcome.cs Outdated
@adamzip adamzip force-pushed the register-subscription-outcomes branch from 638b75c to 8b60493 Compare May 20, 2026 13:32
premun
premun previously approved these changes May 20, 2026
@adamzip adamzip merged commit 2b2c6a4 into dotnet:main May 22, 2026
9 checks passed
&& (update.CoherencyUpdates == null
|| update.CoherencyUpdates.Count == 0)))
{
_logger.LogInformation("No updates found for pull request {url}", pr.Url);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we missed this codepath. This currently returns a Dependencies successfully updated into existing PR:

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.

4 participants