Round #713

10 May 2026, 15:11· csharp· Meta-Llama-3.3-70B-Instruct· r13-clean-hints
Complexity
band 0
ZP / UO / OBS
2 / 3 / 1
Journey weight
308
Lightshift ΔL
+0.00

Prompt

Set up a circuit breaker via ResiliencePipelineBuilder with exponential backoff, AddTimeout, AddRetry, and AddCircuitBreaker stacked.

Zero-point index (what the engine surfaced)

ZPI-ZPI-0012 | 2026-05-10T15:11:36Z Set up a circuit breaker via ResiliencePipelineBuilder with exponential backoff, AddTimeout, AddRetry, and AddCircuitBreaker stacked. ZERO POINT — 2 entries (structural invariants) ● hsl(296.42, 100%, 50%) ResiliencePipeline [contract] ● hsl(211.57, 100%, 50%) ResiliencePipelineBuilder [contract] UNOBSERVED — 3 entries (implied truths) ○ hsl(27.69, 100%, 50%) async [feature] ○ hsl(49.23, 100%, 50%) try [feature] ○ hsl(144.00, 100%, 42%) Connection resilience [function] OBSERVED — 1 entries (explicit in request) ◉ hsl(98.46, 100%, 50%) with [feature] COMPLEXITY │ 6 entries │ spread: 116° │ band: LOW

Baseline response (no ZPI)

Here's an example of setting up a circuit breaker via `ResiliencePipelineBuilder` with exponential backoff, `AddTimeout`, `AddRetry`, and `AddCircuitBreaker` stacked in C#: ```csharp using Polly; using Polly.Extensions.Http; public class ResiliencePipelineBuilder { public static IAsyncPolicy<HttpResponseMessage> CreateResiliencePolicy() { // Define the retry policy with exponential backoff var retryPolicy = Policy.Handle<HttpRequestException>() .OrResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode) .WaitAndRetryAsync( retryCount: 3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (exception, timeSpan, retryCount, context) => { Console.WriteLine($"Retry {retryCount} after {timeSpan.TotalSeconds} seconds"); }); // Define the circuit breaker policy var circuitBreakerPolicy = Policy.Handle<HttpRequestException>() .OrResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode) .CircuitBreakerAsync( exceptionsAllowedBeforeBreaking: 2, durationOfBreak: TimeSpan.FromMinutes(1), onBreak: (exception, ts) => { Console.WriteLine($"Circuit broken for {ts.TotalMinutes} minutes"); }, onReset: () => { Console.WriteLine("Circuit reset"); }); // Define the timeout policy var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(TimeSpan.FromSeconds(10)); // Stack the policies var resiliencePolicy = Policy.WrapAsync(timeoutPolicy, retryPolicy, circuitBreakerPolicy); return resiliencePolicy; } } ``` In this example, we define three policies: 1. `retryPolicy`: This policy will retry the HTTP request up to 3 times with an exponential backoff (2, 4, 8 seconds) if an `HttpRequestException` occurs or if the HTTP response status code is not successful. 2. `circuitBreakerPolicy`: This policy will break the circuit if 2 consecutive exceptions occur within a short period. The circuit will remain broken for 1 minute before it is reset. 3. `timeoutPolicy`: This policy will timeout the HTTP request after 10 seconds. We then stack these policies using `Policy.WrapAsync` to create a resilience policy that combines the behaviors of all three policies. To use this resilience policy, you can execute an HTTP request like this: ```csharp var httpClient = new HttpClient(); var resiliencePolicy = ResiliencePipelineBuilder.CreateResiliencePolicy(); var response = await resiliencePolicy.ExecuteAsync(async () => { var request = new HttpRequestMessage(HttpMethod.Get, "https://example.com"); return await httpClient.SendAsync(request); }); ``` In this example, the `resiliencePolicy` will be applied to the HTTP request sent to `https://example.com`. If any of the policies are triggered (e.g., retry, circuit breaker, timeout), the corresponding behavior will be executed.

Enhanced response (with ZPI)

```csharp using Polly; using Polly.Extensions.Http; public class ResiliencePipelineBuilder { public static IAsyncPolicy<HttpResponseMessage> BuildResiliencePipeline() { // Define the exponential backoff policy var exponentialBackoffPolicy = Policy.Handle<HttpRequestException>() .WaitAndRetryAsync( retryCount: 5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (exception, span) => Console.WriteLine($"Retrying in {span.TotalSeconds} seconds...") ); // Define the timeout policy var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(TimeSpan.FromSeconds(10)); // Define the retry policy var retryPolicy = Policy.Handle<HttpRequestException>() .RetryAsync(3, (exception, retryCount) => Console.WriteLine($"Retrying {retryCount} time(s)...")); // Define the circuit breaker policy var circuitBreakerPolicy = Policy.Handle<HttpRequestException>() .CircuitBreakerAsync( exceptionsAllowedBeforeBreaking: 3, durationOfBreak: TimeSpan.FromMinutes(1), onBreak: (exception, ts) => Console.WriteLine($"Circuit broken for {ts.TotalMinutes} minutes..."), onReset: () => Console.WriteLine("Circuit reset.") ); // Stack the policies var resiliencePipeline = Policy.WrapAsync(exponentialBackoffPolicy, timeoutPolicy, retryPolicy, circuitBreakerPolicy); return resiliencePipeline; } } class Program { static async Task Main(string[] args) { var resiliencePipeline = ResiliencePipelineBuilder.BuildResiliencePipeline(); // Use the resilience pipeline to execute an HTTP request var httpClient = new HttpClient(); var response = await resiliencePipeline.ExecuteAsync(async () => { return await httpClient.GetAsync("https://example.com"); }); Console.WriteLine($"Response status code: {response.StatusCode}"); } } ``` This C# code sets up a circuit breaker using the `ResiliencePipelineBuilder` class, which stacks exponential backoff, timeout, retry, and circuit breaker policies. The `BuildResiliencePipeline` method defines each policy and then wraps them together using `Policy.WrapAsync`. The resulting resilience pipeline is then used to execute an HTTP request in the `Main` method. The policies are defined as follows: * Exponential backoff: Waits for an increasing amount of time between retries, with a maximum of 5 retries. * Timeout: Times out after 10 seconds. * Retry: Retries up to 3 times if an `HttpRequestException` occurs. * Circuit breaker: Breaks the circuit if 3 exceptions occur within a short period, and then waits for 1 minute before resetting. By stacking these policies, the resilience pipeline provides a robust mechanism for handling failures and exceptions when making HTTP requests.

Grader chain

Each grader reads the same baseline + enhanced pair and casts an independent verdict. Disagreement is the framework's own signal — not noise to be averaged away.

V1samba/Meta-Llama-3.3-70B-Instruct
Better
V4qwen2.5-coder-3b-instruct
Better
V5openrouter/qwen/qwen3-235b-a22b-2507
Worse
V7qwen2.5-coder-7b-instruct
Better
V8openai/gpt-4.1
Worse
V9anthropic/claude-opus-4-7
Worse
V12openai/gpt-4o
Better

Comments

Our grader said what it said. What do you say? Comment as a guest below.

No comments yet. Be the first to say what you make of this round.

← back to all rounds