Return PrUpdater states and persist them in DB#6290
Conversation
There was a problem hiding this comment.
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
SubscriptionUpdateResultand updates PR updaters/processors/triggerer interfaces to return it instead ofTask/bool. - Adds
SubscriptionUpdateOutcomeRecorderand wires it intoSubscriptionUpdateProcessorandSubscriptionTriggerProcessorto persist outcomes. - Adds attempt/max-attempt tracking to
WorkItem/WorkItemScope/WorkItemConsumerto 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);
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
we should add/enhance existing tests for the new feature |
- Remove prUrl from PR updater status - Rework status messages - Add UserException which is a type of NonRetriableException
…NonRetriableException
638b75c to
8b60493
Compare
| && (update.CoherencyUpdates == null | ||
| || update.CoherencyUpdates.Count == 0))) | ||
| { | ||
| _logger.LogInformation("No updates found for pull request {url}", pr.Url); |
There was a problem hiding this comment.
looks like we missed this codepath. This currently returns a Dependencies successfully updated into existing PR:
#6187