feat: streaming query pipeline (IAsyncEnumerable, ExecuteStream, resilience) — closes #299#350
Merged
Conversation
Add requirements, design review, and ADR 0019 for the streaming query pipeline feature (spec 012-streaming_results). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add tasks.md with 31 TDD-first tasks across 9 phases, sequenced structural-before-behavioural per ADR 0019, with a dependency graph and risk-mitigation traceability table. Update spec README checklist. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…003) Add IAsyncEnumerable support via Microsoft.Bcl.AsyncInterfaces (netstandard2.0 only), stream query/handler/decorator contracts, and the StreamQueryHandlerAttribute base. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ry type (T004) Adds IStreamQueryHandlerRegistry and StreamQueryHandlerRegistry with generic/type-based registration, duplicate and result-type guards, and RegisterFromAssemblies scan. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…plementations (T005) Assembly scan was already implemented in T004; these tests lock in the behavior: stream handlers are discovered, async/sync handlers are ignored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…er, and processor (T006) Additive structural wiring: HandlerConfiguration gains optional StreamHandlerRegistry member, PipelineBuilder gains a new ctor slot, QueryProcessor reads it from configuration. No behaviour change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…teStream (T007) BuildStream resolves the stream handler by signature (not bare name) to avoid AmbiguousMatchException; ExecuteStream is an async iterator binding span and pipeline lifetime to enumeration. FakeQueryProcessor updated for new interface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… provided context (T008) ExecuteStream was implemented in T007; these tests lock in the full wiring behavior including cancellation token flow and caller-supplied context preservation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ffering (T009) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… OperationCanceledException (T010) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…vocationException (T011) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y once (T012) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Exception (T013) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…c for unregistered stream query (T014) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…g (T015) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…async pipelines (T016) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eline (T017) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and duration (T018) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…level (T019) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… (T020) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ndler stub (T021) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lishment succeeds yields all items (T022) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… duplicate emission (T023) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…024) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…umerator (T025) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… at establishment (T026) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add ServiceCollectionStreamHandlerRegistry that registers stream handler types in DI alongside the sync/async registries; thread it through AddHandlersFromAssemblies and BuildQueryProcessor into HandlerConfiguration so ExecuteStream resolves handlers from the container after an assembly scan. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add AddStreamHandlers(Action<IStreamQueryHandlerRegistry>) to IDarkerHandlerBuilder and implement it on ServiceCollectionDarkerHandlerBuilder, mirroring AddAsyncHandlers so callers can explicitly register stream handlers without an assembly scan. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Verify that a processor built via the fluent QueryProcessorBuilder with a StreamQueryHandlerRegistry in HandlerConfiguration executes stream queries via ExecuteStream; behaviour was already covered by T006/T008 so no new implementation was required. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
T027-T029 DI wiring complete; T030 verified green on net8.0/net9.0 Release build and AOT publish with no new warnings or errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a 'Streaming Queries' section to the root README covering: ExecuteStream + await foreach usage, DI registration (scan and explicit), QueryProcessorBuilder wiring, UseResiliencePipelineStream attribute, and a semantics table (laziness, cancellation, exceptions, deferred config error, re-enumeration, caller context, legacy attribute restriction). Update specs/012-streaming_results/README.md with full implementation summary — all 31 tasks across 9 phases complete. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements spec 012 — streaming query results — across 31 tasks and 9 phases (T001–T031).
IStreamQuery<TResult>marker andIStreamQueryHandler<TQuery,TResult>base contract withStreamQueryHandler<,>abstract base;TResultis the item type, not the enumerableIQueryProcessor.ExecuteStream<TResult>— async iterator entry point; span + handler/decorator lifetime are bound to enumeration so earlybreakand exceptions never leak resourcesPipelineBuilder.BuildStream— resolves handlers from a dedicatedStreamQueryHandlerRegistry, chainsIStreamQueryHandlerDecoratorinstances ordered byStepdescending, validates that legacy sync/async attributes are not used on stream handlers (and vice versa)src/Paramore.Darker/Logging/) — logs start, yields items lazily, records item count + duration on completion, captures mid-stream faultsUseResiliencePipelineStreamHandler(Polly v8) — wraps stream establishment and the firstMoveNextAsyncinside the named pipeline; items are yielded only after the pipeline succeeds, so retry produces no duplicate emission; faults after the first item propagate un-retried; failed-attempt enumerators are disposed before rethrowingServiceCollectionStreamHandlerRegistry,AddHandlersFromAssembliesextended to scanIStreamQueryHandler<,>, newAddStreamHandlers(Action<IStreamQueryHandlerRegistry>)builder method,HandlerConfigurationcarries the stream registry intoQueryProcessorQueryProcessorBuilder— accepts aHandlerConfigurationwith a stream registry, no additional changes required (T006/T008 already covered this)FakeQueryProcessorupdated with a no-opExecuteStreamimplementationnetstandard2.0support via conditionalMicrosoft.Bcl.AsyncInterfacespackage referenceBuildAsyncpath; AOT publish verified greenREADME.mdcovering usage, DI registration, resilience, and all documented semanticsDocumented semantics (key behavioural differences from
ExecuteAsync)await foreachiteration (deliberate — avoids handler leak when caller never enumerates)Timeoutbounds start-up;Hedgingunsupported[RetryableQuery]/[FallbackPolicy]throwConfigurationExceptionon a stream handler; use[UseResiliencePipelineStream]queryContextis scoped to a single enumerationTest plan
AddStreamHandlers,QueryProcessorBuilderwith stream registrynet9.0,osx-arm64) succeeds with no new IL warnings beyond pre-existingBuildAsynconesCloses #299
🤖 Generated with Claude Code