Add ExperimentFramework.Simulation package with isolation and integration testing models#57
Conversation
Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF ScorecardScorecard details
Scanned Files
|
There was a problem hiding this comment.
Pull request overview
This PR adds the ExperimentFramework.Simulation package to enable shadow-mode execution for validating control vs experimental implementations through side-by-side comparison with structured reporting. The implementation provides a fluent builder API, built-in comparators for result validation, async/ValueTask support, and deterministic JSON/text report generation suitable for CI artifacts.
Changes:
- New simulation package with fluent builder API supporting control and multiple condition configurations
- Built-in equality and JSON structural comparators with extensible custom comparator interface
- Deterministic JSON and text report generation with per-scenario timing and diff analysis
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ExperimentFramework.Simulation/ExperimentFramework.Simulation.csproj | Multi-targeted project file (net8.0, net9.0, net10.0) with System.Text.Json dependency |
| src/ExperimentFramework.Simulation/Builders/SimulationRunnerBuilder.cs | Entry point and builder classes for creating simulation runners |
| src/ExperimentFramework.Simulation/Builders/SimulationRunner.cs | Core simulation execution logic with scenario orchestration and result comparison |
| src/ExperimentFramework.Simulation/Comparators/*.cs | Equality and JSON comparators with factory methods |
| src/ExperimentFramework.Simulation/Models/*.cs | Data models for scenarios, results, and configuration options |
| src/ExperimentFramework.Simulation/Reporting/SimulationReportExtensions.cs | JSON and text report generation extension methods |
| src/ExperimentFramework.Simulation/ServiceCollectionExtensions.cs | DI registration extension for future extensibility |
| tests/ExperimentFramework.Simulation.Tests/*.cs | Test suite covering runners, comparators, and reporting |
| docs/simulation-and-shadow-mode.md | Comprehensive documentation with usage examples and best practices |
| ExperimentFramework.slnx | Solution file updated to include new projects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/ExperimentFramework.Simulation/Builders/SimulationRunner.cs
Outdated
Show resolved
Hide resolved
src/ExperimentFramework.Simulation/Builders/SimulationRunner.cs
Outdated
Show resolved
Hide resolved
src/ExperimentFramework.Simulation/Builders/SimulationRunnerBuilder.cs
Outdated
Show resolved
Hide resolved
src/ExperimentFramework.Simulation/Builders/SimulationRunner.cs
Outdated
Show resolved
Hide resolved
src/ExperimentFramework.Simulation/Builders/SimulationRunner.cs
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #57 +/- ##
=======================================
Coverage ? 83.42%
=======================================
Files ? 194
Lines ? 7023
Branches ? 993
=======================================
Hits ? 5859
Misses ? 1164
Partials ? 0
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:
|
|
@copilot apply changes based on the comments in this thread |
|
@copilot Retry |
…icate method, add test Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Applied all code review feedback in commit 2dcd1c5:
All 18 tests passing. |
|
@copilot we need support and demos to demonstrate how simulations work with both action-based and output-based experiments. For example, if someone has multiple database implementation and we're conducting experiments, we may want to simulate writing to the database or we may want to actually shadow write to the database. We need to ensure we demonstrate comprehensive isolation and integration models to allow users to run simulations on real and simulated dependencies (e.g. we don't want to cascade down a dependency tree and write to a real database if that isn't actually desired). Review the current implementation and ensure our simulation and shadow packages enable robust workflows that account for various different scenarios. |
…s integration models Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Added comprehensive simulation sample and enhanced documentation in commit 766aabe. New Sample: Demonstrates 4 key scenarios:
Documentation Updates:
Run the sample: The sample explicitly shows how to test write operations safely without cascading down dependency trees by using mock implementations for dependencies while testing the target service. |
Code Coverage |
Description
Adds
ExperimentFramework.Simulationpackage enabling pre-production validation of control vs experimental implementations through shadow execution with structured reporting. Supports keyed services to test different implementations side-by-side with comprehensive isolation and integration models for both output-based (read) and action-based (write) experiments.Type of Change
Related Issues
(Issue linking handled automatically by the system)
Changes Made
Core Implementation
SimulationRunnerwith fluent builder API supporting control + multiple conditionsISimulationComparator<T>with built-in equality and JSON structural comparatorsSimulationReportwith deterministic JSON and text output suitable for CI artifactsIScenarioResult/IImplementationResultinterfaces (no reflection)Async Support
ValueTask<T>support avoiding unnecessary Task allocationsScenario<TService, TResult>acceptingFunc<TService, ValueTask<TResult>>Models & Configuration
ShadowModeOptionswithReturnMode(Control/Selected) andFailOnDifferenceIsolation & Integration Models
Comprehensive Sample (
samples/ExperimentFramework.SimulationSample/)Example Usage
Testing
Test Configuration
Checklist
Screenshots (if applicable)
N/A
Additional Context
Architecture Decisions
Code Review Feedback Addressed
AsRunnerFormethod (consolidated toWithResultType)isControlparameter_optionsfield readonlyIsolation & Integration Support
Documentation
docs/simulation-and-shadow-mode.mdsamples/ExperimentFramework.SimulationSample/Original prompt
ExperimentFramework.Simulationpackage for shadow-mode execution and report generation #56💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.