This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
backendcritical PriorityID: axum-08-quic-flow-control-backpressure-standard

Axum 0.8 HTTP/3 QUIC Datagram & Stream Flow-Control Backpressure Standard

Shields server memory pools by enforcing strict QUIC stream-level credit boundaries and bounded transmission pipelines in Axum 0.8 and h3/quinn stacks. Prevents unbounded heap allocation and buffer bloat caused by slow-consuming multiplexed edge clients. Guarantees that producers yield execution when transport window credits are exhausted.

Prohibited Anti-Pattern: Unbounded task buffering and unconstrained streaming without polling QUIC stream capacity and transport credit limits

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Axum 0.8 HTTP/3 QUIC Datagram & Stream Flow-Control Backpressure Standard - Shields server memory pools by enforcing strict QUIC stream-level credit boundaries and bounded transmission pipelines in Axum 0.8 and h3/quinn stacks. Prevents unbounded heap allocation and buffer bloat caused by slow-consuming multiplexed edge clients. Guarantees that producers yield execution when transport window credits are exhausted.
globs: src/**/*.rs, crates/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/axum-08-quic-flow-control-backpressure-standard"
---

# Axum 0.8 HTTP/3 QUIC Datagram & Stream Flow-Control Backpressure Standard

> **Severity**: CRITICAL | **Category**: backend
> **Anti-Pattern Warning**: Unbounded task buffering and unconstrained streaming without polling QUIC stream capacity and transport credit limits

## System Constraints
You are a Principal Network Architect enforcing the Axum 0.8 HTTP/3 QUIC Datagram and Stream Flow-Control Backpressure Standard. Mandate that all streaming responses, WebTransport datagram tunnels, and HTTP/3 byte transfers enforce strict stream credit backpressure. Prohibit unbounded task spawning, unbounded channel usage, and unconstrained body accumulation that bypasses QUIC window credit limits.

## Strict Guidelines
- Engineers MUST ALWAYS bound response stream channels using strictly budgeted capacities sized to calculated Bandwidth-Delay Product (BDP) limits.
- Engineers MUST NOT spawn detached background producer tasks that push to HTTP/3 responses without explicit flow-control backpressure feedback.
- Code SHOULD leverage bounded `tokio::sync::mpsc` channels or direct poll-based streaming to ensure producer tasks suspend when transport stream credits are depleted.
- Services MUST drop unreliable QUIC datagrams immediately when edge queues exceed defined thresholds rather than buffering in heap memory pools.
- Components NEVER accumulate raw byte vectors into unbounded stream wrappers without continuous drain verification from the client socket.

## Bad vs Good Implementations
### Axum HTTP/3 Stream Producer Backpressure

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using an unbounded channel (`mpsc::unbounded_channel`) completely disconnects the producer loop from QUIC stream window credits. If the edge client consumes slowly or suspends window updates via MAX_STREAM_DATA frames, the background task continues pushing chunks into memory until the process is killed by the OS Out-Of-Memory (OOM) killer.
```rust
use axum::{body::Body, response::IntoResponse};
use tokio::sync::mpsc;
use tokio_stream::wrappers::UnboundedReceiverStream;
use bytes::Bytes;

// ANTI-PATTERN: Unbounded channel decouples producer from transport window credits.
// A slow HTTP/3 client will cause unbounded chunk accumulation in RAM.
pub async fn stream_handler() -> impl IntoResponse {
    let (tx, rx) = mpsc::unbounded_channel::<Result<Bytes, std::io::Error>>();

    tokio::spawn(async move {
        loop {
            let payload = fetch_telemetry_batch().await;
            // Fails to respect QUIC stream flow control: pushes indefinitely
            if tx.send(Ok(Bytes::from(payload))).is_err() {
                break;
            }
        }
    });

    Body::from_stream(UnboundedReceiverStream::new(rx))
}

async fn fetch_telemetry_batch() -> Vec<u8> {
    vec![0u8; 65536]
}
```

#### Production Standard (Correct)
> **Standard**: By utilizing a bounded `mpsc::channel` with a fixed window budget and awaiting `send()`, the producer task is suspended at the `await` boundary when the consumer lags. Axum's underlying HTTP/3 connection stops pulling from the `ReceiverStream` when Quinn/s2n-quinn buffers are filled, strictly propagating network-layer QUIC flow control up to the asynchronous generation task.
```rust
use axum::{body::Body, response::IntoResponse};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use bytes::Bytes;

// PRODUCTION FIX: Sized channel budget enforces upstream backpressure.
// Yields producer task when QUIC transport transmission window is saturated.
const FLOW_CONTROL_WINDOW_BUFFER: usize = 4;

pub async fn stream_handler() -> impl IntoResponse {
    let (tx, rx) = mpsc::channel::<Result<Bytes, std::io::Error>>(FLOW_CONTROL_WINDOW_BUFFER);

    tokio::spawn(async move {
        loop {
            let payload = fetch_telemetry_batch().await;
            // Halts execution once buffer capacity is reached; resumes only
            // when Axum/H3 drains frames over the network to the client.
            if tx.send(Ok(Bytes::from(payload))).await.is_err() {
                break;
            }
        }
    });

    Body::from_stream(ReceiverStream::new(rx))
}

async fn fetch_telemetry_batch() -> Vec<u8> {
    vec![0u8; 65536]
}
```

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: Axum 0.8 HTTP/3 QUIC Datagram & Stream Flow-Control Backpressure Standard

Axum 0.8 HTTP/3 QUIC Datagram & Stream Flow-Control Backpressure Standard defines an industrial-grade behavioral standard for backend engineering. Shields server memory pools by enforcing strict QUIC stream-level credit boundaries and bounded transmission pipelines in Axum 0.8 and h3/quinn stacks. Prevents unbounded heap allocation and buffer bloat caused by slow-consuming multiplexed edge clients. Guarantees that producers yield execution when transport window credits are exhausted. 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: Unbounded task buffering and unconstrained streaming without polling QUIC stream capacity and transport credit limits 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 DriftUnbounded task buffering and unconstrained streaming without polling QUIC stream capacity and transport credit limitsCritical
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 bound response stream channels using strictly budgeted capacities sized to calculated Bandwidth-Delay Product (BDP) limits.

Engineers MUST ALWAYS bound response stream channels using strictly budgeted capacities sized to calculated Bandwidth-Delay Product (BDP) limits.

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 spawn detached background producer tasks that push to HTTP/3 responses without explicit flow-control backpressure feedback.

Engineers MUST NOT spawn detached background producer tasks that push to HTTP/3 responses without explicit flow-control backpressure feedback.

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 SHOULD leverage bounded `tokio

Code SHOULD leverage bounded `tokio::sync::mpsc` channels or direct poll-based streaming to ensure producer tasks suspend when transport stream credits are depleted.

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 drop unreliable QUIC datagrams immediately when edge queues exceed defined thresholds rather than buffering in heap memory pools.

Services MUST drop unreliable QUIC datagrams immediately when edge queues exceed defined thresholds rather than buffering in heap memory pools.

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 accumulate raw byte vectors into unbounded stream wrappers without continuous drain verification from the client socket.

Components NEVER accumulate raw byte vectors into unbounded stream wrappers without continuous drain verification from the client socket.

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 Axum 0.8 HTTP/3 QUIC Datagram & Stream Flow-Control Backpressure Standard critical for AI coding assistants?

Shields server memory pools by enforcing strict QUIC stream-level credit boundaries and bounded transmission pipelines in Axum 0.8 and h3/quinn stacks. Prevents unbounded heap allocation and buffer bloat caused by slow-consuming multiplexed edge clients. Guarantees that producers yield execution when transport window credits are exhausted. 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 (Unbounded task buffering and unconstrained streaming without polling QUIC stream capacity and transport credit limits) 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

Axum