Skip to content

HTTP idempotency Nuget Package #106

Open

Description

@goodtocode

Universal Duplicate Transmission Guard

Goal

Prevent accidental duplicate transmissions caused by:

  • Double-clicks
  • UI bugs
  • Browser retries
  • Agent retries
  • MCP orchestration loops
  • Rapid repeated submissions

This is intentionally NOT financial-grade idempotency.

This package is a lightweight duplicate-transmission guard with a lifecycle measured in seconds, not hours or days.

Package Structure

Goodtocode.TransmissionGuard

Core transport-agnostic engine.

Responsibilities:

  • Detect duplicate operations
  • Maintain short-lived cache entries
  • Support configurable TTL windows
  • Support HTTP and MCP adapters

Goodtocode.Http.Idempotency

ASP.NET Core integration.

Responsibilities:

  • Read Idempotency-Key header
  • Detect duplicate requests
  • Reject duplicates
  • Register middleware

Goodtocode.Mcp.Idempotency

Future MCP integration.

Responsibilities:

  • Read idempotency metadata from MCP envelopes
  • Detect duplicate tool calls
  • Reject duplicate executions

Design Principles

  • No database persistence
  • No EF Core dependency
  • No request hashing
  • No response replay
  • No serialization
  • No tenant ownership tracking
  • No operation metadata interfaces
  • No background cleanup jobs

The purpose is simply:

Allow the first transmission.

Reject immediate duplicates.

Core Abstractions

public interface ITransmissionGuard
{
    bool TryAcquire(
        string operation,
        string key,
        TimeSpan duration);
}
public sealed class TransmissionGuardOptions
{
    public TimeSpan Window { get; set; }
        = TimeSpan.FromSeconds(5);
}

HTTP Behavior

Client sends:

POST /api/users
Idempotency-Key: abc123

Server cache key:

POST:/api/users:abc123

Processing:

  • Key not found

    • add to cache
    • continue pipeline
  • Key found

    • reject request

Response:

409 Conflict
{
  "error":"Duplicate request detected."
}

Client Integration

Package:

Goodtocode.Clients.Http

Capabilities:

  • Authorization enforcement
  • Correlation IDs
  • Idempotency-Key generation

Example:

await client.PostAsync(...);

Generated headers:

Authorization: Bearer xxx
X-Correlation-Id: guid
Idempotency-Key: guid

Registration

builder.Services.AddHttpIdempotency(options =>
{
    options.Window = TimeSpan.FromSeconds(5);
});
app.UseHttpIdempotency();

Future MCP Support

Apply the same concept to MCP envelopes.

Example:

{
  "metadata":
  {
    "idempotencyKey":"guid"
  }
}

Cache key:

ToolName:guid

Behavior:

  • First execution allowed
  • Immediate duplicates rejected

Success Criteria

  • Protects against double-submit bugs
  • Protects against rapid retry loops
  • Works in REST APIs
  • Works in MCP transports
  • Minimal dependencies
  • Memory-cache based
  • Seconds-based lifecycle
  • Easy one-line registration

Activity

  1. changed the title [-]Idempotency[/-] [+]Idempotency Nuget Package[/+] on Sep 12, 2026
  2. changed the title [-]Idempotency Nuget Package[/-] [+]HTTP Idempotency Nuget Package[/+] on Sep 19, 2026
  3. changed the title [-]HTTP Idempotency Nuget Package[/-] [+]HTTP idempotency Nuget Package[/+] on Sep 19, 2026
  4. self-assigned this
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions