Skip to content

Feat/context cancellation propagation#25

Merged
Desz01ate merged 13 commits into
mainfrom
feat/context-cancellation-propagation
Apr 11, 2026
Merged

Feat/context cancellation propagation#25
Desz01ate merged 13 commits into
mainfrom
feat/context-cancellation-propagation

Conversation

@Desz01ate

Copy link
Copy Markdown
Owner

No description provided.

Desz01ate added 13 commits April 2, 2026 00:24
Add focused failing tests for parent-child cancellation propagation,
child isolation, and timeout-derived cancellation so the new Context
primitive ships with a concrete behavioral contract.

Constraint: Cancellation must fit the existing GoOptions-centric API surface
Rejected: Start implementation without tests | easy to drift on semantics
Confidence: high
Scope-risk: narrow
Directive: Keep Context cancellation-focused in v1; do not add value storage during this pass
Tested: dotnet test src/Concur.Tests/Concur.Tests.csproj --filter ContextTests -v minimal (expected compile failure)
Not-tested: Full solution build
Add a small, cancellation-focused Context primitive and expose it through
GoOptions so existing Concur APIs gain a shared operation lifetime without
exploding the Go overload surface.

Constraint: v1 must stay interoperable with CancellationToken-based APIs
Rejected: Add value storage to Context | not needed for cancellation propagation
Confidence: medium
Scope-risk: moderate
Directive: Keep Context additive; do not thread it as a positional argument across Go overloads in this change
Tested: dotnet test src/Concur.Tests/Concur.Tests.csproj --filter ContextTests -v minimal
Not-tested: Full solution build
Add cancellable WaitAsync/Wait overloads so callers can abandon waits when
an operation Context is canceled without mutating the underlying wait-group
state or breaking reuse semantics.

Constraint: Existing lock-free WaitGroup state machine must remain intact
Rejected: Build a separate cancellable wait primitive | unnecessary extra API surface
Confidence: high
Scope-risk: narrow
Directive: Keep cancellation outside the wait-group count; never couple token cancellation to Done()
Tested: dotnet test src/Concur.Tests/Concur.Tests.csproj --filter WaitGroupTests -v minimal
Not-tested: Full solution build
Add focused tests for pre-start cancellation, blocked-on-limiter cancellation,
channel failure on producer cancellation, and exception-handler suppression for
cooperative OperationCanceledException paths.

Constraint: Existing Go overloads must keep their current signatures
Rejected: Infer semantics from docs alone | too easy to regress across overloads
Confidence: high
Scope-risk: narrow
Directive: Treat cooperative cancellation separately from faults in every Go code path
Tested: dotnet test src/Concur.Tests/Concur.Tests.csproj --filter "FullyQualifiedName~Concur.Tests.ConcurRoutineTests|FullyQualifiedName~Concur.Tests.ExceptionHandlingTests" -v minimal
Not-tested: Full solution build
Teach ConcurRoutine to stop before delegate execution when an operation
Context is canceled, to stop treating matching OperationCanceledException
as a fault, and to surface producer cancellation through returned channels.

Constraint: Public Go overload signatures must remain unchanged
Rejected: Add Context as a new positional parameter to every overload | too much surface churn for v1
Confidence: medium
Scope-risk: broad
Directive: Reuse the helper methods for every overload; do not reintroduce raw semaphore.WaitAsync calls in individual Go bodies
Tested: dotnet test src/Concur.Tests/Concur.Tests.csproj --filter "FullyQualifiedName~Concur.Tests.ConcurRoutineTests|FullyQualifiedName~Concur.Tests.ExceptionHandlingTests" -v minimal
Not-tested: Full solution build
Explain how the new Context primitive works with GoOptions, WaitGroup, and
channel-producing Go overloads so callers can adopt cancellation propagation
without reading the implementation first.

Constraint: README examples must stay aligned with the shipped public API
Rejected: Leave the feature undocumented | increases adoption friction and misuse risk
Confidence: high
Scope-risk: narrow
Directive: Keep README examples cooperative; show token propagation explicitly
Tested: dotnet test src/Concur.Tests/Concur.Tests.csproj -v minimal; dotnet build src/Concur.sln -v minimal
Not-tested: Benchmarks
…ption

The spec defines a dedicated Concur.Extensions.AspNetCore package with global-on Context parameter binding for controllers and minimal APIs, configurable token-source composition, and explicit strict/lenient failure policy. It also records the docs layout decision: detailed guidance lives in the new project directory while the root README links to it.

Constraint: Existing docs/superpowers/specs markdown files are gitignored and must be force-added intentionally
Rejected: Middleware-first Context injection | introduces ordering concerns and weaker native parameter UX
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep token-source configuration API unambiguous (separate method names, no delegate-overload ambiguity)
Tested: Spec self-review (placeholder and consistency pass)
Not-tested: Runtime ASP.NET behavior (design artifact only)
…ons.AspNetCore` package

Add `Concur.Extensions.AspNetCore` with Context parameter binding for controllers and minimal APIs. Introduce configurable token-source composition and strict/lenient failure policies. Update solution structure and tests to validate ASP.NET Core-specific behavior and allow seamless global Context access. Update root README with new package details and link to detailed usage docs.
ManualResetEventSlim.Wait and Task.WhenAny sentinel delays in tests that
wait on goroutines (Task.Run), timer callbacks, or channel operations can
all be blocked when the CI thread pool is saturated by concurrent tests.
Raising the ceiling to 5s gives enough headroom without making the suite
meaningfully slower when the pool is healthy.

Unaffected: SpinWait.SpinUntil calls that wait on direct cts.Cancel()
propagation — those run synchronously on the cancelling thread and
complete in microseconds regardless of thread pool state.
@Desz01ate Desz01ate merged commit d82a6a4 into main Apr 11, 2026
2 checks passed
@Desz01ate Desz01ate deleted the feat/context-cancellation-propagation branch April 11, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant