implement-backpressure-in-pipelines

implement-backpressure-in-pipelines is a cursor rule for Cursor from PaulJPhilp/EffectPatterns. It costs 981 tokens per session, scanned A, original, MIT.

A TypeScript rule for adding backpressure to a data pipeline, which slows producers or buffers data when consumers cannot keep up.

In plain words
What is it for?
Use it for Effect streams and queues that process data at uneven speeds, including pipelines that need buffering, throttling, or dropping rules.
Why use it?
It prevents a fast producer from overwhelming a slower consumer and gives the pipeline a defined way to handle full buffers.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it for Effect streams and queues that process data at uneven speeds, including pipelines that need buffering, throttling, or dropping rules.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/PaulJPhilp/EffectPatterns

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for implement-backpressure-in-pipelines

README.md
[![agentmods](https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines/github.svg)](https://agentmods.dev/rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines)
Your own site
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for implement-backpressure-in-pipelines

Your own site · 80×15
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/implement-backpressure-in-pipelines.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 981 This file is loaded in full into every session.
When invoked 981 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00981 $0.00981
Opus 5.5 $0.00392 $0.00392
Sonnet 5.5 $0.00196 $0.00196
Haiku 4.5 $0.00098 $0.00098

Measured 2mo ago against content hash cfd93418aa7f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

implement-backpressure-in-pipelines scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

content/published/rules/cursor/implement-backpressure-in-pipelines.mdc · 150 lines

How it starts

The opening of the file, as written. The whole thing — 150 lines — stays where its author put it; the contents beside it link to each section on GitHub.

description: Use buffering and throttling to handle producers faster than consumers. globs: "**/*.ts" alwaysApply: true

Implement Backpressure in Pipelines

Rule: Use buffering and throttling to handle producers faster than consumers.

Example

import { Effect, Stream, Schedule, Duration, Queue, Chunk } from "effect"

// ============================================
// 1. Stream with natural backpressure
// ============================================

// Streams have built-in backpressure - consumers pull data
const fastProducer = Stream.fromIterable(Array.from({ length: 1000 }, (_, i) => i))

const slowConsumer = fastProducer.pipe(
  Stream.tap((n) =>
    Effect.gen(function* () {
      yield* Effect.sleep("10 millis")  // Slow processing
      yield* Effect.log(`Processed: ${n}`)
    })
  ),
  Stream.runDrain
)

// Producer automatically slows down to match consumer

// ============================================
// 2. Explicit buffer with drop strategy
// ============================================

const bufferedStream = (source: Stream.Stream<number>) =>
  source.pipe(
    // Buffer up to 100 items, drop oldest when full
    Stream.buffer({ capacity: 100, strategy: "dropping" })
  )

// ============================================
// 3. Throttling - limit rate
// ============================================

const throttledStream = (source: Stream.Stream<number>) =>
  source.pipe(
    // Process at most 10 items per second
    Stream.throttle({
      cost: () => 1,
      units: 10,
      duration: "1 second",
      strategy: "enforce",
    })
  )

// ============================================
// 4. Debounce - wait for quiet period
// ============================================

const debouncedStream = (source: Stream.Stream<number>) =>
  source.pipe(
    // Wait 100ms of no new items before emitting
    Stream.debounce("100 millis")
  )

// ============================================
// 5. Bounded queue for producer-consumer
// ============================================

const boundedQueueExample = Effect.gen(function* () {
  // Create bounded queue - blocks producer when full
  const queue = yield* Queue.bounded<number>(10)

  // Fast producer
  const producer = Effect.gen(function* () {
    for (let i = 0; i < 100; i++) {
      yield* Queue.offer(queue, i)
      yield* Effect.log(`Produced: ${i}`)
    }
    yield* Queue.shutdown(queue)
  })

  // Slow consumer
  const consumer = Effect.gen(function* () {
    let count = 0
    while (true) {
      const item = yield* Queue.take(queue).pipe(
        Effect.catchTag("QueueShutdown", () => Effect.fail("done" as const))
      )
      if (item === "done") break
      yield* Effect.sleep("50 millis")  // Slow processing
      yield* Effect.log(`Consumed: ${item}`)
      count++
    }
    return count
  }).pipe(Effect.catchAll(() => Effect.succeed(0)))

  // Run both - producer will block when queue is full
  yield* Effect.all([producer, consumer], { concurrency: 2 })
})

// ============================================
// 6. Sliding window - keep most recent
// ============================================

const slidingWindowStream = (source: Stream.Stream<number>) =>
  source.pipe(
    Stream.sliding(5),  // Keep last 5 items
    Stream.map((window) => ({
      items: window,
      average: Chunk.reduce(window, 0, (a, b) => a + b) / Chunk.size(window),
    }))
  )

// ============================================
// 7. Run example
// ============================================

const program = Effect.gen(function* () {
  yield* Effect.log("=== Backpressure Demo ===")

  // Throttled stream
  const throttled = Stream.fromIterable([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).pipe(
    Stream.tap((n) => Effect.log(`Emitting: ${n}`)),
    Stream.throttle({
      cost: () => 1,
      units: 2,
      duration: "1 second",
      strategy: "enforce",
    }),
    Stream.tap((n) => Effect.log(`After throttle: ${n}`)),
    Stream.runDrain
  )

  yield* throttled
})

Effect.runPromise(program)

Read the full file on GitHub · 150 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 150 lines · 981 tokens per session scan A cfd93418aa7f

Subscribe to this mod's changes

implement-backpressure-in-pipelines is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (807 stars, last pushed 5mo ago), licensed MIT. It adds 981 tokens to every session, about $0.0039 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

implement-backpressure-in-pipelines compared with cursor rules from other repositories

implement-backpressure-in-pipelines next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
implement-backpressure-in-pipelinesPaulJPhilp/EffectPatternsCursor rule8075mo agoMITA981Cursor
workflowWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA0Cursor
activitiesWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA0Cursor
go-api-development-general-rulesWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA0Cursor
backend-general-expertWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA349Cursor
service-class-conventionsWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA172Cursor
repository-class-conventionsWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA149Cursor