Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:416rehman DeepZero Processor Contract

From Leeroopedia
Knowledge Sources
Domains Pipeline_Orchestration, Software_Architecture
Last Updated 2026-10-27 00:00 GMT

Overview

A typed four-lane processor contract where each pipeline stage declares its relationship to the sample stream (1→N, 1:1, N→ranked, N:1 batch) and its outputs, enabling static validation of pipeline graphs before execution.

Description

A processor contract defines the interface between the pipeline engine and the stages that do the actual work. DeepZero uses four lanes because different analysis steps have fundamentally different relationships to the sample stream:

  • Ingest (1→N): discovers samples from a source. One invocation produces N samples. Always the first stage.
  • Map (1:1): transforms one sample at a time. The engine fans out across samples in parallel. Thread-safe by contract—no shared mutable state.
  • Reduce (N→ranked): sees all active samples at once and decides which survive. A global sync barrier that cannot be auto-chunked because it requires interdependence.
  • BulkMap (N:1 batch): processes all samples in one external invocation. More efficient than Map when the external process has high startup cost (e.g., semgrep CLI).

Each processor declares a Config dataclass that names its accepted YAML keys, and a provides tuple listing the data keys and artifact names downstream stages can reference. This enables static validation: deepzero validate checks every Jinja2 prompt against the names its upstream stages produce, catching empty-payload bugs before a run starts.

Usage

Use this contract pattern when:

  • Designing a pipeline framework where stages are pluggable
  • Static validation of pipeline graphs is needed (catch misconfigured prompts before running)
  • Different stages need different parallelism models (per-sample vs. global vs. batch)
  • Extensibility by subclassing is preferred over configuration

Theoretical Basis

The four lanes correspond to four dataflow patterns:

# Abstract lane semantics (NOT real implementation)

# Ingest: 1 -> N (source discovery)
samples = ingest.process(target)  # one call, many outputs

# Map: 1:1 fan-out (parallel transformation)
results = pool.map(lambda s: stage.process(s), active_samples)  # per sample

# Reduce: N -> ranked (global selection)
surviving_ids = reduce.process(all_samples)  # sees everything

# BulkMap: N -> 1 batch (single invocation)
results = bulkmap.process(all_samples)  # one call, many results

The provides declaration enables a form of type checking for pipeline graphs. A prompt in stage N referencing variable X is only valid if some stage before N declares X in its provides. This is checked statically by parsing the Jinja2 template (without rendering it) and comparing undeclared variables against the union of all upstream provides.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment