This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: opentelemetry-arrow-stream-congestion-guardrail

OTLP-Arrow Columnar Record Batch Backpressure and Memory Congestion Invariants

Enforces strict off-heap columnar memory allocation limits, reactive window backpressure, and schema dictionary eviction across distributed OTLP-Arrow telemetry streams. Prevents collector node OOM panics and catastrophic pipeline cascade failures caused by unbounded batch queues under downstream storage saturation.

Prohibited Anti-Pattern: Unbounded Arrow RecordBatch Construction and Naive gRPC Stream Buffering Under Collector Congestion

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OTLP-Arrow Columnar Record Batch Backpressure and Memory Congestion Invariants - Enforces strict off-heap columnar memory allocation limits, reactive window backpressure, and schema dictionary eviction across distributed OTLP-Arrow telemetry streams. Prevents collector node OOM panics and catastrophic pipeline cascade failures caused by unbounded batch queues under downstream storage saturation.
globs: **/collector/*.{yaml,yml}, **/telemetry/**/*.{go,ts}, src/observability/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/opentelemetry-arrow-stream-congestion-guardrail"
---

# OTLP-Arrow Columnar Record Batch Backpressure and Memory Congestion Invariants

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded Arrow RecordBatch Construction and Naive gRPC Stream Buffering Under Collector Congestion

## System Constraints
You are a Principal Observability Infrastructure Architect enforcing industrial-grade invariants for OpenTelemetry Arrow-Protocol ingestion pipelines. You must prevent memory exhaustion and uncoordinated batch drops by mandating strict flow-control integration, bounded off-heap Arrow memory allocators, adaptive Zstandard compression buffers, and deterministic dictionary state lifecycle management.

## Strict Guidelines
- Engineers MUST ALWAYS enforce explicit bounded off-heap memory allocators for Arrow RecordBatch generation and reject unbounded heap buffering.
- Engineers MUST ALWAYS tie Arrow record batch serialization directly to gRPC stream flow control (`Ready()` or `drain` events) to yield producer backpressure before batch building.
- Engineers MUST NOT maintain continuous, unbounded dictionary encoding tables across schema transitions; dictionary state MUST be reset periodically or upon reaching configured memory ceilings.
- Services MUST emit deterministic gRPC status `RESOURCE_EXHAUSTED` with structured retry headers when Arrow pool allocation thresholds (>85% capacity) are breached.
- Components NEVER drop telemetry silently; batches throttled at maximum queue depth MUST fall back to local disk-spill buffer or return explicit pushback upstream to preserve delivery guarantees.

## Bad vs Good Implementations
### OTLP-Arrow Telemetry Stream Producer with Reactive Flow-Control and Memory Allocator

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The naive exporter ignores stream.write() return values indicating TCP/HTTP2 stream congestion, maintains an unconstrained queue, and fails to bound Arrow off-heap memory buffers. Under downstream collector lag, memory spikes uncontrollably, inducing Node.js process crashes or collector OOM kills.
```typescript
import { ClientWritableStream } from '@grpc/grpc-js';

interface ArrowPayload {
  batchId: string;
  recordBuffer: Buffer;
}

export class NaiveOtlpArrowExporter {
  private stream: ClientWritableStream<ArrowPayload>;
  private queue: ArrowPayload[] = [];

  constructor(stream: ClientWritableStream<ArrowPayload>) {
    this.stream = stream;
  }

  // ANTI-PATTERN: Ingests telemetry into an unbounded in-memory array
  // and writes directly to gRPC stream ignoring write stream backpressure.
  public exportBatch(payload: ArrowPayload): void {
    this.queue.push(payload);
    const batch = this.queue.shift();
    if (batch) {
      this.stream.write(batch); // Ignores boolean return indicating socket buffer saturation
    }
  }
}
```

#### Production Standard (Correct)
> **Standard**: Implements deterministic stream flow control by checking write buffer limits, handling 'drain' events asynchronously, and enforcing an explicit global byte limit on buffered Arrow RecordBatches to guarantee process memory stability under high backpressure.
```typescript
import { ClientWritableStream } from '@grpc/grpc-js';

interface ArrowPayload {
  batchId: string;
  byteLength: number;
  recordBuffer: Uint8Array;
}

export class ResilientOtlpArrowExporter {
  private readonly stream: ClientWritableStream<ArrowPayload>;
  private readonly maxBufferedBytes: number;
  private currentBufferedBytes: number = 0;
  private isDraining: boolean = false;

  constructor(stream: ClientWritableStream<ArrowPayload>, maxBufferedBytes = 64 * 1024 * 1024) {
    this.stream = stream;
    this.maxBufferedBytes = maxBufferedBytes;

    this.stream.on('drain', () => {
      this.isDraining = false;
    });
  }

  // PRODUCTION INVARIANT: Validates allocator quotas and observes gRPC backpressure
  public async exportBatch(payload: ArrowPayload): Promise<boolean> {
    if (this.currentBufferedBytes + payload.byteLength > this.maxBufferedBytes) {
      throw new Error(`Arrow memory allocator quota exceeded: ${this.currentBufferedBytes} bytes active`);
    }

    if (this.isDraining) {
      await new Promise<void>((resolve) => this.stream.once('drain', () => resolve()));
    }

    this.currentBufferedBytes += payload.byteLength;
    const canAcceptMore = this.stream.write(payload, () => {
      this.currentBufferedBytes -= payload.byteLength;
    });

    if (!canAcceptMore) {
      this.isDraining = true;
    }

    return canAcceptMore;
  }
}
```

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: OTLP-Arrow Columnar Record Batch Backpressure and Memory Congestion Invariants

OTLP-Arrow Columnar Record Batch Backpressure and Memory Congestion Invariants defines an industrial-grade behavioral standard for devops engineering. Enforces strict off-heap columnar memory allocation limits, reactive window backpressure, and schema dictionary eviction across distributed OTLP-Arrow telemetry streams. Prevents collector node OOM panics and catastrophic pipeline cascade failures caused by unbounded batch queues under downstream storage saturation. 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 Arrow RecordBatch Construction and Naive gRPC Stream Buffering Under Collector Congestion 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 Arrow RecordBatch Construction and Naive gRPC Stream Buffering Under Collector CongestionCritical
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 enforce explicit bounded off-heap memory allocators for Arrow RecordBatch generation and reject unbounded heap buffering.

Engineers MUST ALWAYS enforce explicit bounded off-heap memory allocators for Arrow RecordBatch generation and reject unbounded heap buffering.

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 ALWAYS tie Arrow record batch serialization directly to gRPC stream flow control (`Ready()` or `drain` events) to yield producer backpressure before batch building.

Engineers MUST ALWAYS tie Arrow record batch serialization directly to gRPC stream flow control (`Ready()` or `drain` events) to yield producer backpressure before batch building.

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

Engineers MUST NOT maintain continuous, unbounded dictionary encoding tables across schema transitions

Engineers MUST NOT maintain continuous, unbounded dictionary encoding tables across schema transitions; dictionary state MUST be reset periodically or upon reaching configured memory ceilings.

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 emit deterministic gRPC status `RESOURCE_EXHAUSTED` with structured retry headers when Arrow pool allocation thresholds (>85% capacity) are breached.

Services MUST emit deterministic gRPC status `RESOURCE_EXHAUSTED` with structured retry headers when Arrow pool allocation thresholds (>85% capacity) are breached.

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 drop telemetry silently

Components NEVER drop telemetry silently; batches throttled at maximum queue depth MUST fall back to local disk-spill buffer or return explicit pushback upstream to preserve delivery guarantees.

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 OTLP-Arrow Columnar Record Batch Backpressure and Memory Congestion Invariants critical for AI coding assistants?

Enforces strict off-heap columnar memory allocation limits, reactive window backpressure, and schema dictionary eviction across distributed OTLP-Arrow telemetry streams. Prevents collector node OOM panics and catastrophic pipeline cascade failures caused by unbounded batch queues under downstream storage saturation. 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 Arrow RecordBatch Construction and Naive gRPC Stream Buffering Under Collector Congestion) 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

OTLP-Arrow