Implementation:416rehman DeepZero ProcessorEntry
| Knowledge Sources | |
|---|---|
| Domains | Pipeline_Orchestration, Extensibility |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Data structure representing a single sample being processed, with lazy-loaded upstream history that reads from disk only when accessed.
Description
The ProcessorEntry dataclass represents a sample in flight through the pipeline. It carries the sample's identity (sample_id, source_path, filename) and its working directory (sample_dir). The key feature is its lazy-loaded history: the upstream stage outputs are not loaded into memory until entry.history is first accessed, at which point they are loaded from the StateStore and cached.
This lazy loading is critical for memory efficiency. A pipeline processing thousands of samples cannot hold every sample's full history in memory simultaneously. By deferring the load until a processor actually needs upstream data, the runner keeps memory usage proportional to the parallelism of the current stage, not the total corpus size.
Two accessor methods provide typed access to upstream data:
- upstream(processor_name): returns the full StageOutput from a named upstream stage, or None.
- upstream_data(processor_name, key, default): returns a specific data field from an upstream stage's output.
Usage
- Accessing upstream data in a custom processor: entry.upstream_data("discover", "sha256")
- Getting full upstream output: entry.upstream("ghidra_decompile")
- Flattening all upstream data: iterate entry.history.values() and merge output.data
- Accessing the sample's working directory: entry.sample_dir
Code Reference
Source Location
- Repository: DeepZero
- File: src/deepzero/engine/stage.py
Signature
@dataclass
class ProcessorEntry:
sample_id: str
source_path: Path
filename: str
sample_dir: Path | None = None
_store: StateStore | None = field(default=None, repr=False, compare=False)
@property
def history(self) -> dict[str, StageOutput]: ...
def upstream(self, processor_name: str) -> StageOutput | None: ...
def upstream_data(
self, processor_name: str, key: str, default: Any = None
) -> Any: ...
Import
from deepzero.engine.stage import ProcessorEntry
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| sample_id | str | Yes | Unique identifier (typically sha256 prefix) |
| source_path | Path | Yes | Path to the original source file |
| filename | str | Yes | Display name for the sample |
| _store | None | No | Attached by runner for lazy history loading |
Outputs
| Name | Type | Description |
|---|---|---|
| history | dict[str, StageOutput] | Lazy-loaded per-stage output ledger |
| upstream() returns | None | Full output from a named upstream stage |
| upstream_data() returns | Any | Specific data field from an upstream stage |
Usage Examples
Accessing Upstream Data
from deepzero.engine.stage import MapProcessor, ProcessorContext, ProcessorEntry, ProcessorResult
class MyProcessor(MapProcessor):
def process(self, ctx: ProcessorContext, entry: ProcessorEntry) -> ProcessorResult:
# Get sha256 from the "discover" stage
sha = entry.upstream_data("discover", "sha256", "")
if not sha:
return ProcessorResult.fail("no sha256 from discover stage")
# Get full output from a previous stage
ghidra_output = entry.upstream("ghidra_decompile")
if ghidra_output and ghidra_output.data.get("ioctl_count", 0) > 0:
return ProcessorResult.ok(data={"has_ioctls": True})
# Flatten all upstream data
flat = {}
for output in entry.history.values():
flat.update(output.data)
return ProcessorResult.ok(data=flat)