Skip to content

feat(testing): add resilience state probes - #111

Merged
thomhurst merged 2 commits into
mainfrom
issue-100-state-probes
Aug 21, 2026
Merged

feat(testing): add resilience state probes#111
thomhurst merged 2 commits into
mainfrom
issue-100-state-probes

Conversation

@thomhurst

@thomhurst thomhurst commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Closes #100

Adds immutable v1 state snapshots for circuit breakers, rate limiters, and concurrency limiters, plus typed/untyped ExecutionProbe wrappers for deterministic attempt and cancellation assertions. Snapshot reads reuse existing state atomics and locks; production execution paths gain no probe hooks or extra work.

Validation:

  • dotnet build Kevlar.slnx -c Release
  • Kevlar.Tests: 670 passed
  • Kevlar.Testing.Tests: 21 passed
  • Kevlar.IntegrationTests: 34 passed
  • Kevlar.Analyzers.Tests: 38 passed
  • Kevlar.Chaos.Tests: 23 passed
  • Kevlar.AllocationTests: 2 passed
  • dotnet pack + Verify-Packages.ps1 passed
  • Verify-DocSnippets.ps1: 97 snippets passed
  • docs npm run build passed

Summary by CodeRabbit

  • New Features

    • Added immutable state snapshots for shields, circuit breakers, rate limits, and concurrency limits.
    • Added execution probes to track attempts and cancellation requests, with asynchronous wait support.
    • Added snapshot support for typed and untyped shields, including strategy ordering and contract versions.
  • Documentation

    • Added guidance and examples for inspecting resilience state during live testing.
  • Tests

    • Added coverage for limiter queues, circuit states, retries, cancellations, shared state, and fake-time behavior.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b49db87-1cf4-4020-9fca-58ba661e1690

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd6799 and c235e5a.

📒 Files selected for processing (1)
  • tests/Kevlar.Testing.Tests/TelemetryRecorderTests.cs

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The change adds immutable, versioned resilience-state snapshots for shields and limiter strategies. It also adds ExecutionProbe for attempt and cancellation tracking, asynchronous wait helpers, internal state capture, tests, public API entries, and documentation.

Changes

Resilience state snapshots

Layer / File(s) Summary
Versioned shield state snapshots
src/Kevlar.Testing/*StateSnapshot.cs, src/Kevlar.Testing/ShieldStateSnapshotExtensions.cs, src/Kevlar/Strategies/...
The testing assembly defines immutable snapshots for shield strategies. Extensions capture indexed circuit-breaker, rate-limit, and concurrency-limit state. Internal strategy methods expose the required metrics.
Execution attempt and cancellation probing
src/Kevlar.Testing/ExecutionProbe.cs, src/Kevlar.Testing/ExecutionProbeSnapshot.cs
ExecutionProbe wraps typed and untyped asynchronous delegates, counts attempts and cancellations atomically, forwards cancellation tokens, and supports threshold wait methods.
Contracts, validation, and documentation
src/Kevlar.Testing/PublicAPI.Unshipped.txt, tests/Kevlar.Testing.Tests/StateProbeTests.cs, tests/Kevlar.Testing.Tests/TelemetryRecorderTests.cs, docs/docs/testing.md
Public API entries, state-sharing and fake-time tests, typed-shield tests, cancellation tests, null validation, test isolation, and testing documentation cover the new contracts.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to c235e

The PR adds testing probes and immutable state snapshots with no production execution-path overhead; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Shield
  participant SnapshotExtensions
  participant Strategies
  Shield->>SnapshotExtensions: GetStateSnapshot()
  SnapshotExtensions->>Strategies: Capture state
  Strategies-->>SnapshotExtensions: Return strategy metrics
  SnapshotExtensions-->>Shield: Return immutable snapshot
Loading

Poem

I hop through snapshots, tidy and bright,
Counting each attempt through the night.
Cancellations ring, permits align,
Fake clocks make rate limits shine.
Safe probes bloom in testing’s burrow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: adding resilience state probes for testing.
Linked Issues check ✅ Passed The changes add versioned snapshots, typed and untyped execution probes, API declarations, documentation, and focused tests for the linked requirements [#100].
Out of Scope Changes check ✅ Passed The changes are focused on resilience snapshots, execution probes, related APIs, documentation, and test reliability.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-100-state-probes

Comment @coderabbitai help to get the list of available commands.

@thomhurst
thomhurst merged commit 62e53a4 into main Aug 21, 2026
6 checks passed
@thomhurst
thomhurst deleted the issue-100-state-probes branch August 21, 2026 20:04
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.

feat(testing): add resilience state probes

1 participant