Conversation
docs: update invariants to reflect RangeResult structure and behavior
…ailable range and data; refactor: improve boundary handling logic in data fetching and caching mechanisms; docs: update comments and documentation for clarity on range handling
…Enumerable; test assertions modified to access Data property
…vailability information
…ta source limits; feat: BoundedDataSource test infrastructure has been implemented for bounded data scenarios
…st: parameter count mismatches have been resolved for Invariant tests
There was a problem hiding this comment.
Pull request overview
This PR introduces explicit boundary/data-availability semantics for the sliding window cache by making GetDataAsync return a RangeResult<TRange, TData>, and by updating IDataSource to return RangeChunk so bounded sources can signal partial fulfillment or “no data available” without throwing.
Changes:
- Public API breaking change:
GetDataAsyncnow returnsValueTask<RangeResult<TRange, TData>>;IDataSource.FetchAsyncnow returnsRangeChunk<TRange, TData>. - Cache/user-path and rebalance merge logic updated to handle out-of-bounds/unavailable segments (including diagnostics for unavailable segments).
- Broad refactor of tests/benchmarks/docs to use
RangeResult/RangeChunk, plus new integration tests for boundary handling.
Reviewed changes
Copilot reviewed 29 out of 36 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/SlidingWindowCache.Unit.Tests/Public/WindowCacheDisposalTests.cs | Updates test data source + assertions for RangeResult.Data. |
| tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs | Refactors invariant tests to use .Data from RangeResult. |
| tests/SlidingWindowCache.Invariants.Tests/TestInfrastructure/TestHelpers.cs | Updates mocks/helpers to return RangeChunk and unwrap RangeResult.Data. |
| tests/SlidingWindowCache.Integration.Tests/TestInfrastructure/SpyDataSource.cs | Updates spy data source to return RangeChunk. |
| tests/SlidingWindowCache.Integration.Tests/TestInfrastructure/BoundedDataSource.cs | Adds bounded test data source that returns null ranges when out-of-bounds. |
| tests/SlidingWindowCache.Integration.Tests/RebalanceExceptionHandlingTests.cs | Updates faulty data source and assertions for RangeChunk/RangeResult. |
| tests/SlidingWindowCache.Integration.Tests/RangeSemanticsContractTests.cs | Updates range semantics assertions to use RangeResult.Data. |
| tests/SlidingWindowCache.Integration.Tests/RandomRangeRobustnessTests.cs | Updates robustness assertions to use RangeResult.Data. |
| tests/SlidingWindowCache.Integration.Tests/ExecutionStrategySelectionTests.cs | Updates test data source and assertions for new return types. |
| tests/SlidingWindowCache.Integration.Tests/DataSourceRangePropagationTests.cs | Updates propagation assertions to use RangeResult.Data. |
| tests/SlidingWindowCache.Integration.Tests/ConcurrencyStabilityTests.cs | Updates concurrency tests to unwrap RangeResult.Data. |
| tests/SlidingWindowCache.Integration.Tests/CacheDataSourceInteractionTests.cs | Updates interaction tests to unwrap RangeResult.Data. |
| tests/SlidingWindowCache.Integration.Tests/BoundaryHandlingTests.cs | Adds new integration test suite validating bounded-source behavior. |
| src/SlidingWindowCache/Public/WindowCache.cs | Changes public interface + facade to return RangeResult and updates docs/error message. |
| src/SlidingWindowCache/Public/IDataSource.cs | Changes single-range fetch to return RangeChunk; updates batch contract language. |
| src/SlidingWindowCache/Public/Dto/RangeResult.cs | Adds RangeResult DTO for fulfilled-range + data payload. |
| src/SlidingWindowCache/Public/Dto/RangeChunk.cs | Updates RangeChunk to allow Range = null for unavailable segments and documents contract. |
| src/SlidingWindowCache/Public/Configuration/WindowCacheOptions.cs | Minor formatting tweak in validation logic. |
| src/SlidingWindowCache/Infrastructure/Instrumentation/NoOpDiagnostics.cs | Adds no-op implementation for new diagnostic hook. |
| src/SlidingWindowCache/Infrastructure/Instrumentation/ICacheDiagnostics.cs | Adds DataSegmentUnavailable() contract for boundary/unavailable segments. |
| src/SlidingWindowCache/Infrastructure/Instrumentation/EventCounterCacheDiagnostics.cs | Adds counter + implementation for DataSegmentUnavailable. |
| src/SlidingWindowCache/Infrastructure/Concurrency/AsyncActivityCounter.cs | Minor whitespace-only cleanup. |
| src/SlidingWindowCache/Core/UserPath/UserRequestHandler.cs | Implements RangeResult return and boundary-aware fetching behavior on user path. |
| src/SlidingWindowCache/Core/Rebalance/Intent/IntentController.cs | Minor whitespace-only cleanup. |
| src/SlidingWindowCache/Core/Rebalance/Execution/TaskBasedRebalanceExecutionController.cs | Minor whitespace-only cleanup. |
| src/SlidingWindowCache/Core/Rebalance/Execution/RebalanceExecutor.cs | Comment indentation/formatting update. |
| src/SlidingWindowCache/Core/Rebalance/Execution/ChannelBasedRebalanceExecutionController.cs | Minor whitespace-only cleanup. |
| src/SlidingWindowCache/Core/Rebalance/Execution/CacheDataExtensionService.cs | Updates union logic to skip null-range chunks and emit diagnostics. |
| src/SlidingWindowCache.WasmValidation/WasmCompilationValidator.cs | Updates validation data source + usage for RangeChunk/RangeResult. |
| docs/invariants.md | Adds invariant documenting RangeResult boundary semantics. |
| docs/boundary-handling.md | Adds new guide explaining boundary handling and usage patterns. |
| benchmarks/SlidingWindowCache.Benchmarks/Infrastructure/SynchronousDataSource.cs | Updates benchmark data source to return RangeChunk. |
| benchmarks/SlidingWindowCache.Benchmarks/Infrastructure/SlowDataSource.cs | Updates benchmark data source to return RangeChunk. |
| benchmarks/SlidingWindowCache.Benchmarks/Benchmarks/UserFlowBenchmarks.cs | Updates benchmarks to unwrap RangeResult.Data; nullable options adjustments. |
| benchmarks/SlidingWindowCache.Benchmarks/Benchmarks/ExecutionStrategyBenchmarks.cs | Minor formatting tweak. |
| README.md | Updates examples and adds boundary-handling section for new API surface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs
Outdated
Show resolved
Hide resolved
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs
Outdated
Show resolved
Hide resolved
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
… nullable ranges in response structures
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 36 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
docs/boundary-handling.md:307
- This doc claims “Test Coverage (15 tests)”, but
BoundaryHandlingTests.cscurrently contains 10[Fact]tests. Please update the number and/or the listed categories so the documentation stays accurate.
The cache includes comprehensive boundary handling tests in `BoundaryHandlingTests.cs`:
### Test Coverage (15 tests)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/SlidingWindowCache/Infrastructure/Instrumentation/ICacheDiagnostics.cs
Outdated
Show resolved
Hide resolved
…luding full vacuum boundary misses; UserRequestHandler finally block has been restructured to decouple served-counter from intent publication; test: UserPathExceptionHandlingTests added covering exception propagation and post-exception cache operability; test: BoundaryHandlingTests extended with physical data miss diagnostics assertion; refactor: FaultyDataSource and GenerateStringData extracted to shared TestInfrastructure; docs: ICacheDiagnostics UserRequestServed and DataSegmentUnavailable docs corrected; docs: diagnostics.md UserRequestServed description updated and DataSegmentUnavailable section added; docs: boundary-handling.md out-of-bounds RangeChunk examples corrected to use null Range; docs: component-map.md stale skip-event method names replaced with current method names
… have been corrected; fix: G.45 has been rewritten to describe actual I/O separation between User Path and Rebalance Execution; fix: stale 'every user request produces exactly one intent' claims have been removed from ICacheDiagnostics, UserRequestHandler XML doc, diagnostics.md, and actors-and-responsibilities.md
1f6d148 to
b5447b2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 41 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (5)
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs:1101
- The documentation comment still references the removed
storageNameparameter at line 1100. This should be removed to match the actual method signature.
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs:317 - The test data
A3_8_TestDataincludes bothstorage[0](storageName) andstorage[1](readMode) at positions 5 and 6 in the yielded array (lines 105-106), but the test method signature removed thescenarioandstorageNameparameters and now only accepts the numeric parameters and readMode. This creates a parameter count mismatch - the test data yields 8 values but the method now expects only 6. This will cause test failures at runtime. Either removestorage[0]from the test data or keep thestorageNameparameter (even if unused) to maintain the parameter count.
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs:1104 - The test method signature has removed the
storageNameparameter but theStorageStrategyTestDatastill provides it at position 0. The test data yields bothstorage[0](storageName) andstorage[1](readMode), but the method signature now only acceptsreadMode. This creates a parameter count mismatch - the test data yields 2 values but the method expects only 1. This will cause test failures at runtime. Either removestorage[0]from the test data or keep thestorageNameparameter (even if unused).
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs:1135 - The test method signature has removed the
storageNameparameter but the documentation comment still references it at line 1134. The parameter documentation should be removed to match the actual method signature.
tests/SlidingWindowCache.Invariants.Tests/WindowCacheInvariantTests.cs:1138 - Same issue as the other test methods - the test method signature has removed the
storageNameparameter butStorageStrategyTestDatastill provides it at position 0. This creates a parameter count mismatch that will cause test failures at runtime.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces explicit boundary handling and data availability contracts for the cache system, centered around the new
RangeResult<TRange, TData>return type forGetDataAsync. The documentation is updated to explain these changes, and code across the benchmarks and validation projects is refactored to useRangeResultandRangeChunkinstead of raw data collections. The cache now gracefully handles partial fulfillment and out-of-bounds requests without exceptions, and the merging logic ensures only contiguous, available data is stored.Boundary Handling & Data Availability:
RangeResult<TRange, TData>as the return type forGetDataAsync, enabling explicit signaling of fulfilled ranges, partial fulfillment, and unavailability (null range). This is documented in the README and invariants with usage examples and rationale. [1] [2] [3]Codebase Refactoring for Boundary Contracts:
SlowDataSource,SynchronousDataSource,SimpleDataSource) to returnRangeChunk<TRange, TData>instead ofIEnumerable<TData>, and updated all usages to access.DatafromRangeResult. [1] [2] [3] [4] [5] [6] [7].DatafromRangeResult. [1] [2] [3] [4] [5] [6]Cache Merging Logic Improvements:
UnionAllinCacheDataExtensionServiceto filter out segments with null ranges, ensuring cache contiguity and compliance with architectural invariants. Added remarks and diagnostics for unavailable segments. [1] [2]Miscellaneous:
These changes provide a clearer, safer, and more flexible interface for cache consumers, especially when dealing with bounded or partially available data sources.