Source code for zephon.ops.traits

# Copyright 2025 DatologyAI
# SPDX-License-Identifier: Apache-2.0

"""Operator traits that guide planning and scheduling."""

from dataclasses import dataclass


[docs] @dataclass(frozen=True, kw_only=True) class OpTraits: """Static capabilities an operator advertises to the planner. ``indexable`` — whether the operator preserves indexability through the plan. ``preserves_cursor_order`` — whether the operator preserves per-lane cursor order (no reordering across chunk/offset/lineage). Required — every operator author must make an explicit ``True`` (1:1 maps, payload transforms, non-reordering filters) or ``False`` (reorders, shuffles, packs) call. ``calibration_replayable`` — set True if processing each fetched record independently produces the same output payloads and record counts as normal execution, including which records are dropped. Otherwise leave False (default). Output order may differ. The op must also run without accumulators or runner services. Sample IDs are real; lane/chunk positions, component counts, and stage metadata are placeholders and must not affect payloads or drops. Text cleanup, content-based filters, and per-record splits qualify; packing and padding to the longest item in a batch do not. Buffers that only delay or reorder records are safe. ``parallelism`` — suggested parallelism for the operator when not overridden. ``batch_shape_sensitive`` — if True, the operator's outputs can depend on how inputs are grouped into micro-batches (e.g., per-batch RNG or statistics). In deterministic mode, stages that contain at least one such operator will have time-based flush disabled to preserve strong determinism. When False, ordering determinism suffices and latency flush may be kept for performance. ``requires_serial_state`` — if True, the operator maintains cross-invocation state (e.g., buffers) that must be confined to a single operator instance for determinism. In deterministic mode, operators with this trait will automatically run with parallelism=1. This prevents nondeterministic behavior when multiple worker instances would each maintain separate buffers. """ indexable: bool = True preserves_cursor_order: bool calibration_replayable: bool = False parallelism: int = 1 batch_shape_sensitive: bool = False requires_serial_state: bool = False
__all__ = ["OpTraits"]