feat: add Scheduler Agent Supervisor pattern#327
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
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.
| private SchedulerAgentResult<TResult> Dispatch(ScheduledJob job, DateTimeOffset now) | ||
| { | ||
| var agent = _agents[0]; | ||
| var attempt = job.Attempt + 1; |
| if (agents.Length == 0 || retries.Length > 1) | ||
| { | ||
| context.ReportDiagnostic(Diagnostic.Create(MissingMembers, node.Identifier.GetLocation(), type.Name)); | ||
| return; | ||
| } | ||
|
|
| => method.GetAttributes() | ||
| .First(attr => attr.AttributeClass?.ToDisplayString() == AgentAttributeName) | ||
| .ConstructorArguments[0].Value as string ?? method.Name; | ||
|
|
Test Results 1 files 1 suites 2m 55s ⏱️ Results for commit aa9bee2. |
Code Coverage |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Validation
SchedulerAgentSupervisorGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests /p:BuildProjectReferences=false /p:UseSharedCompilation=falseSchedulerAgentSupervisorGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests /p:BuildProjectReferences=false /p:UseSharedCompilation=falseSchedulerAgentSupervisorGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests /p:BuildProjectReferences=false /p:UseSharedCompilation=falseFull local solution build still hits the known Windows analyzer/compiler mismatch for generated examples; PR CI is the authoritative full solution validation.
Closes #322