Skip to content

feat: add Scheduler Agent Supervisor pattern#327

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/scheduler-agent-supervisor-322
May 22, 2026
Merged

feat: add Scheduler Agent Supervisor pattern#327
JerrettDavis merged 1 commit into
mainfrom
feature/scheduler-agent-supervisor-322

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Summary

  • add fluent Scheduler Agent Supervisor runtime with retry supervision and TinyBDD coverage
  • add source generator attributes, generator, diagnostics, and generator coverage
  • add warehouse DI/Generic Host example plus catalogs and docs

Validation

  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net8.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net9.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators.Abstractions\PatternKit.Generators.Abstractions.csproj /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0 --no-restore --filter FullyQualifiedName~SchedulerAgentSupervisorTests /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net9.0 --no-restore --filter FullyQualifiedName~SchedulerAgentSupervisorTests /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter FullyQualifiedName~SchedulerAgentSupervisorTests /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter FullyQualifiedNameSchedulerAgentSupervisorGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net9.0 --no-restore --filter FullyQualifiedNameSchedulerAgentSupervisorGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter FullyQualifiedNameSchedulerAgentSupervisorGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • git diff --check

Full local solution build still hits the known Windows analyzer/compiler mismatch for generated examples; PR CI is the authoritative full solution validation.

Closes #322

Copilot AI review requested due to automatic review settings May 22, 2026 22:09
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “Scheduler Agent Supervisor” pattern end-to-end: runtime fluent API, a source generator + diagnostics, and a production-shaped warehouse demo with docs and catalog integration.

Changes:

  • Introduces SchedulerAgentSupervisor<TWork,TResult> runtime with retry supervision and result capture, plus TinyBDD coverage.
  • Adds [GenerateSchedulerAgentSupervisor] generator/attributes, diagnostics, and generator tests.
  • Adds warehouse DI/Generic Host example and wires it into example/pattern catalogs and documentation TOCs.

Reviewed changes

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

Show a summary per file
File Description
test/PatternKit.Tests/Cloud/SchedulerAgentSupervisor/SchedulerAgentSupervisorTests.cs Adds TinyBDD coverage for scheduling, due dispatch, retry/exhaustion, and input validation.
test/PatternKit.Generators.Tests/SchedulerAgentSupervisorGeneratorTests.cs Verifies generated factory output and invalid-declaration diagnostics.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Extends attribute coverage suite to include new scheduler attributes.
test/PatternKit.Examples.Tests/SchedulerAgentSupervisorDemo/WarehouseSchedulerAgentSupervisorDemoTests.cs Tests fluent + generated demo behavior, DI import, hosted service lifecycle, and catalog presence.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates expected catalog entries/counts for the new pattern.
src/PatternKit.Generators/SchedulerAgentSupervisor/SchedulerAgentSupervisorGenerator.cs Implements incremental generator emitting a configured supervisor factory and diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new generator diagnostic IDs (PKSAS001–PKSAS005).
src/PatternKit.Generators.Abstractions/Cloud/SchedulerAgentSupervisorAttributes.cs Adds generator-facing attributes for supervisor/agents/retry predicate.
src/PatternKit.Examples/SchedulerAgentSupervisorDemo/WarehouseSchedulerAgentSupervisorDemo.cs Adds the warehouse demo (fluent + generated supervisor), DI wiring, and hosted service.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds the new pattern entry referencing docs, runtime, generator, tests, and example.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds the new warehouse scheduler demo to the example catalog.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Registers the new demo/example in aggregate DI helpers.
src/PatternKit.Core/Cloud/SchedulerAgentSupervisor/SchedulerAgentSupervisor.cs Adds the runtime supervisor, context/result model, and supervision policy builder.
docs/patterns/toc.yml Adds the new pattern page to the patterns TOC.
docs/patterns/cloud/scheduler-agent-supervisor.md Documents the runtime pattern usage and integration guidance.
docs/guides/pattern-coverage.md Adds the pattern to the pattern coverage matrix.
docs/generators/toc.yml Adds the generator page to the generators TOC.
docs/generators/scheduler-agent-supervisor.md Documents generator usage and generated factory behavior.
docs/generators/index.md Adds the generator to the generators index table.
docs/examples/warehouse-scheduler-agent-supervisor.md Documents the warehouse demo usage via DI/Generic Host.
docs/examples/toc.yml Adds the warehouse demo to the examples TOC.
docs/examples/index.md Adds the warehouse demo to the examples index list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +177 to +180
private SchedulerAgentResult<TResult> Dispatch(ScheduledJob job, DateTimeOffset now)
{
var agent = _agents[0];
var attempt = job.Attempt + 1;
Comment on lines +85 to +90
if (agents.Length == 0 || retries.Length > 1)
{
context.ReportDiagnostic(Diagnostic.Create(MissingMembers, node.Identifier.GetLocation(), type.Name));
return;
}

Comment on lines +151 to +154
=> method.GetAttributes()
.First(attr => attr.AttributeClass?.ToDisplayString() == AgentAttributeName)
.ConstructorArguments[0].Value as string ?? method.Name;

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

    1 files      1 suites   2m 55s ⏱️
1 003 tests 1 003 ✅ 0 💤 0 ❌
1 008 runs  1 008 ✅ 0 💤 0 ❌

Results for commit aa9bee2.

@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 22:14:48
  Coverage date: 05/22/2026 - 22:13:15 - 05/22/2026 - 22:14:37
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1431
  Files: 582
  Line coverage: 94.6%
  Covered lines: 38664
  Uncovered lines: 2181
  Coverable lines: 40845
  Total lines: 89422
  Branch coverage: 75.3% (11317 of 15011)
  Covered branches: 11317
  Total branches: 15011
  Method coverage: 96.2% (7650 of 7946)
  Full method coverage: 88.3% (7022 of 7946)
  Covered methods: 7650
  Fully covered methods: 7022
  Total methods: 7946

PatternKit.Core                                                                                                     95.9%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                 90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                      100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                           85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                          95.4%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                             94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                  90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                            84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                      95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                      100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                       87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                         100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                         96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                             100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                           92.8%
  PatternKit.Application.MaterializedViews.MaterializedView<T1, T2>                                                 98.4%
  PatternKit.Application.Repository.InMemoryRepository<T1, T2>                                                      92.8%
  PatternKit.Application.Repository.RepositoryResult<T>                                                             93.3%
  PatternKit.Application.ServiceLayer.ServiceLayerOperation<T1, T2>                                                 96.7%
  PatternKit.Application.ServiceLayer.ServiceLayerResult<T>                                                         94.7%
  PatternKit.Application.ServiceLayer.ServiceLayerRule<T>                                                            100%
  PatternKit.Application.Specification.Specification<T>                                                              100%
  PatternKit.Application.Specification.SpecificationRegistry<T>                                                     93.3%
  PatternKit.Application.TableDataGateway.InMemoryTableDataGateway<T1, T2>                                            86%
  PatternKit.Application.TableDataGateway.TableGatewayResult<T>                                                     82.3%
  PatternKit.Application.TransactionScript.TransactionScript<T1, T2>                                                  97%
  PatternKit.Application.TransactionScript.TransactionScriptError                                                     90%
  PatternKit.Application.TransactionScript.TransactionScriptResult<T>                                                100%
  PatternKit.Application.UnitOfWork.UnitOfWork                                                                      90.9%
  PatternKit.Application.UnitOfWork.UnitOfWorkResult                                                                94.7%
  PatternKit.Application.UnitOfWork.UnitOfWorkRollbackResult                                                         100%
  PatternKit.Application.UnitOfWork.UnitOfWorkStep                                                                   100%
  PatternKit.Behavioral.Chain.ActionChain<T>                                                                         100%
  PatternKit.Behavioral.Chain.AsyncActionChain<T>                                                                    100%
  PatternKit.Behavioral.Chain.AsyncResultChain<T1, T2>                                                              97.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                                                    100%

@github-actions
Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 94.45983% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.72%. Comparing base (ec2e4f1) to head (aa9bee2).

Files with missing lines Patch % Lines
...entSupervisor/SchedulerAgentSupervisorGenerator.cs 92.36% 11 Missing ⚠️
...visorDemo/WarehouseSchedulerAgentSupervisorDemo.cs 89.79% 5 Missing ⚠️
...hedulerAgentSupervisor/SchedulerAgentSupervisor.cs 96.89% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #327      +/-   ##
==========================================
+ Coverage   89.72%   95.72%   +6.00%     
==========================================
  Files         472      476       +4     
  Lines       38987    39346     +359     
  Branches     5577     5634      +57     
==========================================
+ Hits        34980    37664    +2684     
+ Misses       1796     1682     -114     
+ Partials     2211        0    -2211     
Flag Coverage Δ
unittests 95.72% <94.45%> (+6.00%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JerrettDavis JerrettDavis merged commit a77441f into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feature/scheduler-agent-supervisor-322 branch May 22, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Scheduler Agent Supervisor pattern

2 participants