This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
backendcritical PriorityID: go-http3-quic-migration-stateless-reset-invariant

Go HTTP/3 QUIC Connection Migration & Stateless Reset Token Determinism Standard

Enforces deterministic Stateless Reset Token generation and synchronized Connection ID routing across Go HTTP/3 QUIC servers. Guarantees multiplexed stream resilience and mitigates off-path connection hijacking and silent transport desynchronization during mobile cell-to-Wi-Fi handovers.

Prohibited Anti-Pattern: Ephemeral per-instance reset keys and uncoordinated Connection IDs causing silent stream termination and hijack vulnerabilities during client IP migration.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Go HTTP/3 QUIC Connection Migration & Stateless Reset Token Determinism Standard - Enforces deterministic Stateless Reset Token generation and synchronized Connection ID routing across Go HTTP/3 QUIC servers. Guarantees multiplexed stream resilience and mitigates off-path connection hijacking and silent transport desynchronization during mobile cell-to-Wi-Fi handovers.
globs: **/transport/**/*.go, **/server/**/*.go, **/http3/**/*.go, **/*quic*.go
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/go-http3-quic-migration-stateless-reset-invariant"
---

# Go HTTP/3 QUIC Connection Migration & Stateless Reset Token Determinism Standard

> **Severity**: CRITICAL | **Category**: backend
> **Anti-Pattern Warning**: Ephemeral per-instance reset keys and uncoordinated Connection IDs causing silent stream termination and hijack vulnerabilities during client IP migration.

## System Constraints
You are a Principal Systems & Network Security Engineer enforcing RFC 9000/9114 invariants in Go HTTP/3 applications using quic-go. You mandate deterministic StatelessResetKey injection across distributed edge topologies, proactive active Connection ID pool management, and explicit path validation routines to secure dynamic client address transitions without transport-level desynchronization.

## Strict Guidelines
- Engineers MUST ALWAYS provide a deterministic, cryptographically derived cluster-wide `StatelessResetKey` (32 bytes) in `quic.Config` to prevent transport resets across multi-homed or load-balanced endpoints.
- Engineers MUST NOT leave `StatelessResetKey` uninitialized (`nil`) or bound to ephemeral per-process memory, which causes migrating clients to be abruptly dropped when hitting adjacent edge instances.
- Code MUST configure `quic.Config.ConnectionIDLength` between 4 and 20 bytes and register a secure `ConnectionIDGenerator` to prevent connection correlation attacks during cell-to-Wi-Fi migration.
- Services MUST enable non-probing frame monitoring and enforce reciprocal `PATH_CHALLENGE` / `PATH_RESPONSE` validation before elevating newly announced client IP:port tuples to active path status.
- Components NEVER terminate inflight multiplexed streams when receiving packets from an unverified network path before path validation completes or anti-amplification limits are exhausted.

## Bad vs Good Implementations
### Configuring quic-go HTTP/3 Server with Deterministic Stateless Reset Key and Robust Migration Settings

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omitting a static, securely derived StatelessResetKey in quic.Config means quic-go generates an ephemeral key per instance. When mobile clients migrate from 5G to Wi-Fi, alternate edge workers cannot validate the stateless reset token, dropping the connection and exposing endpoints to desynchronization and potential connection hijacking.
```go
package transport

import (
	"net/http"
	"github.com/quic-go/quic-go"
	"github.com/quic-go/quic-go/http3"
)

func StartVulnerableServer(handler http.Handler) error {
	server := &http3.Server{
		Addr:    ":443",
		Handler: handler,
		// Flaw: quic.Config omitted or empty.
		// StatelessResetKey is nil (ephemeral), causing dropped connections
		// on mobile migration if packets hit an alternate process/worker.
		QuicConfig: &quic.Config{
			// Zero-value allows off-path reset injection or breaks handoff
		},
	}
	return server.ListenAndServeTLS("cert.pem", "key.pem")
}
```

#### Production Standard (Correct)
> **Standard**: Derives a deterministic, 256-bit StatelessResetKey from a distributed secret shared across edge instances. This ensures all instances calculate identical stateless reset tokens for a given connection ID, allowing seamless client migration across network interfaces (cell-to-Wi-Fi) and preventing connection desynchronization and hijacking.
```go
package transport

import (
	"crypto/hmac"
	"crypto/sha256"
	"fmt"
	"net/http"
	"time"

	"github.com/quic-go/quic-go"
	"github.com/quic-go/quic-go/http3"
)

func deriveStatelessResetKey(clusterSecret []byte) *quic.StatelessResetKey {
	h := hmac.New(sha256.New, clusterSecret)
	h.Write([]byte("quic-stateless-reset-key-v1"))
	sum := h.Sum(nil)
	
	var key quic.StatelessResetKey
	copy(key[:], sum[:32])
	return &key
}

func StartSecureServer(handler http.Handler, clusterSecret []byte) error {
	if len(clusterSecret) < 32 {
		return fmt.Errorf("cluster secret must be >= 32 bytes")
	}

	resetKey := deriveStatelessResetKey(clusterSecret)

	quicCfg := &quic.Config{
		StatelessResetKey:    resetKey,
		MaxIdleTimeout:       30 * time.Second,
		KeepAlivePeriod:      10 * time.Second,
		EnableDatagrams:      true,
		AllowConnectionWindowIncrease: func(conn quic.Connection, delta uint64) bool {
			return true
		},
	}

	server := &http3.Server{
		Addr:       ":443",
		Handler:    handler,
		QuicConfig: quicCfg,
	}

	return server.ListenAndServeTLS("cert.pem", "key.pem")
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Go HTTP/3 QUIC Connection Migration & Stateless Reset Token Determinism Standard

Go HTTP/3 QUIC Connection Migration & Stateless Reset Token Determinism Standard defines an industrial-grade behavioral standard for backend engineering. Enforces deterministic Stateless Reset Token generation and synchronized Connection ID routing across Go HTTP/3 QUIC servers. Guarantees multiplexed stream resilience and mitigates off-path connection hijacking and silent transport desynchronization during mobile cell-to-Wi-Fi handovers. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Ephemeral per-instance reset keys and uncoordinated Connection IDs causing silent stream termination and hijack vulnerabilities during client IP migration. Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftEphemeral per-instance reset keys and uncoordinated Connection IDs causing silent stream termination and hijack vulnerabilities during client IP migration.Critical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS provide a deterministic, cryptographically derived cluster-wide `StatelessResetKey` (32 bytes) in `quic.Config` to prevent transport resets across multi-homed or load-balanced endpoints.

Engineers MUST ALWAYS provide a deterministic, cryptographically derived cluster-wide `StatelessResetKey` (32 bytes) in `quic.Config` to prevent transport resets across multi-homed or load-balanced endpoints.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT leave `StatelessResetKey` uninitialized (`nil`) or bound to ephemeral per-process memory, which causes migrating clients to be abruptly dropped when hitting adjacent edge instances.

Engineers MUST NOT leave `StatelessResetKey` uninitialized (`nil`) or bound to ephemeral per-process memory, which causes migrating clients to be abruptly dropped when hitting adjacent edge instances.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Code MUST configure `quic.Config.ConnectionIDLength` between 4 and 20 bytes and register a secure `ConnectionIDGenerator` to prevent connection correlation attacks during cell-to-Wi-Fi migration.

Code MUST configure `quic.Config.ConnectionIDLength` between 4 and 20 bytes and register a secure `ConnectionIDGenerator` to prevent connection correlation attacks during cell-to-Wi-Fi migration.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Services MUST enable non-probing frame monitoring and enforce reciprocal `PATH_CHALLENGE` / `PATH_RESPONSE` validation before elevating newly announced client IP

Services MUST enable non-probing frame monitoring and enforce reciprocal `PATH_CHALLENGE` / `PATH_RESPONSE` validation before elevating newly announced client IP:port tuples to active path status.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Components NEVER terminate inflight multiplexed streams when receiving packets from an unverified network path before path validation completes or anti-amplification limits are exhausted.

Components NEVER terminate inflight multiplexed streams when receiving packets from an unverified network path before path validation completes or anti-amplification limits are exhausted.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Go HTTP/3 QUIC Connection Migration & Stateless Reset Token Determinism Standard critical for AI coding assistants?

Enforces deterministic Stateless Reset Token generation and synchronized Connection ID routing across Go HTTP/3 QUIC servers. Guarantees multiplexed stream resilience and mitigates off-path connection hijacking and silent transport desynchronization during mobile cell-to-Wi-Fi handovers. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Ephemeral per-instance reset keys and uncoordinated Connection IDs causing silent stream termination and hijack vulnerabilities during client IP migration.) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Go