{ "module": "dagpipe.state", "content": { "path": "dagpipe.state", "docstring": "# Summary\n\nDefines the core `State` object used by `dagpipe`.\n\nThe `State` represents a single point in pipeline execution. It contains\narbitrary data and metadata and is designed to be immutable. Instead of\nmodifying an existing state, nodes create new child states via `fork()`.\n\n---\n\n# Design principles\n\n- **Immutability:** States must never be modified after creation.\n All transformations must create a new state via `fork()`.\n- **Cheap cloning:** Forking must be efficient since branching may create many states.\n- **Lineage tracking:** Each state maintains a reference to its parent and\n execution metadata for debugging and observability.\n- **Domain agnostic:** State contains generic key-value data and does not\n assume any schema.\n- **Engine-friendly:** State contains execution metadata such as depth and history.", "objects": { "Iterable": { "name": "Iterable", "kind": "alias", "path": "dagpipe.state.Iterable", "signature": "", "docstring": null }, "Mapping": { "name": "Mapping", "kind": "alias", "path": "dagpipe.state.Mapping", "signature": "", "docstring": null }, "dataclass": { "name": "dataclass", "kind": "alias", "path": "dagpipe.state.dataclass", "signature": "", "docstring": null }, "field": { "name": "field", "kind": "alias", "path": "dagpipe.state.field", "signature": "", "docstring": null }, "UnionType": { "name": "UnionType", "kind": "alias", "path": "dagpipe.state.UnionType", "signature": "", "docstring": null }, "Any": { "name": "Any", "kind": "alias", "path": "dagpipe.state.Any", "signature": "", "docstring": null }, "ClassVar": { "name": "ClassVar", "kind": "alias", "path": "dagpipe.state.ClassVar", "signature": "", "docstring": null }, "Optional": { "name": "Optional", "kind": "alias", "path": "dagpipe.state.Optional", "signature": "", "docstring": null }, "Union": { "name": "Union", "kind": "alias", "path": "dagpipe.state.Union", "signature": "", "docstring": null }, "get_args": { "name": "get_args", "kind": "alias", "path": "dagpipe.state.get_args", "signature": "", "docstring": null }, "Payload": { "name": "Payload", "kind": "class", "path": "dagpipe.state.Payload", "signature": "", "docstring": "Immutable hierarchical container with dot-path access.\n\nAttributes:\n _data (Mapping[str, Any]):\n Immutable hierarchical data structure.\n\nNotes:\n **Responsibilities:**\n\n - Stores execution data used by `State`.\n - Supports efficient atomic updates without modifying existing instances.\n - `Payload` instances are fully thread-safe due to immutability.", "members": { "iter_paths": { "name": "iter_paths", "kind": "function", "path": "dagpipe.state.Payload.iter_paths", "signature": "", "docstring": "Recursively yield dot-paths for all leaf nodes.\n\nArgs:\n data (Mapping[str, Any]):\n The mapping to iterate over.\n prefix (str, optional):\n Current path prefix.\n\nReturns:\n Iterable[str]:\n Generator yielding dot-paths." }, "get": { "name": "get", "kind": "function", "path": "dagpipe.state.Payload.get", "signature": "", "docstring": "Retrieve value using dot-path.\n\nArgs:\n path (str):\n Dot-separated path to the value.\n default (Any, optional):\n Default value if path doesn't exist.\n\nReturns:\n Any:\n The retrieved value or default." }, "has": { "name": "has", "kind": "function", "path": "dagpipe.state.Payload.has", "signature": "", "docstring": "Return True if path exists.\n\nArgs:\n path (str):\n Dot-separated path to check.\n\nReturns:\n bool:\n Existence of the path." }, "update": { "name": "update", "kind": "function", "path": "dagpipe.state.Payload.update", "signature": "", "docstring": "Create a new `Payload` with dot-path updates applied.\n\nArgs:\n updates (Mapping[str, Any]):\n Dot-path to value mapping.\n\nReturns:\n Payload:\n New immutable payload instance with updates.\n\nNotes:\n **Guarantees:**\n\n - Preserves existing data by copying only modified branches.\n - Returns a new immutable `Payload`." }, "keys": { "name": "keys", "kind": "function", "path": "dagpipe.state.Payload.keys", "signature": "", "docstring": "Return top-level keys.\n\nReturns:\n Iterable[str]:\n Iterator over top-level keys." }, "as_dict": { "name": "as_dict", "kind": "function", "path": "dagpipe.state.Payload.as_dict", "signature": "", "docstring": "Return underlying mapping.\n\nReturns:\n Mapping[str, Any]:\n Read-only view of the underlying data." } } }, "SchemaNode": { "name": "SchemaNode", "kind": "attribute", "path": "dagpipe.state.SchemaNode", "signature": null, "docstring": null }, "Schema": { "name": "Schema", "kind": "class", "path": "dagpipe.state.Schema", "signature": "", "docstring": "Immutable hierarchical schema defining allowed payload structure.\n\nAttributes:\n tree (Mapping[str, SchemaNode]):\n Hierarchical schema definition.\n\nNotes:\n **Responsibilities:**\n\n - Validates `State` payloads and updates.\n - Reusable across all `State` instances.\n - Fully thread-safe due to immutability.", "members": { "tree": { "name": "tree", "kind": "attribute", "path": "dagpipe.state.Schema.tree", "signature": null, "docstring": null }, "validate_payload": { "name": "validate_payload", "kind": "function", "path": "dagpipe.state.Schema.validate_payload", "signature": "", "docstring": "Validate complete payload structure.\n\nArgs:\n payload (Payload):\n Payload to validate.\n\nRaises:\n SchemaError:\n If payload violates schema." }, "validate_update": { "name": "validate_update", "kind": "function", "path": "dagpipe.state.Schema.validate_update", "signature": "", "docstring": "Validate payload update paths.\n\nArgs:\n updates (Mapping[str, Any]):\n Dot-path updates to validate.\n\nRaises:\n SchemaError:\n If any path is invalid according to the schema." } } }, "SchemaError": { "name": "SchemaError", "kind": "class", "path": "dagpipe.state.SchemaError", "signature": "", "docstring": "Raised when payload data violates the declared schema.\n\nIndicates invalid structure, invalid path, or invalid type.\n---" }, "State": { "name": "State", "kind": "class", "path": "dagpipe.state.State", "signature": "", "docstring": "Immutable execution state propagated through dagpipe pipeline.\n\nAttributes:\n payload (Payload):\n Execution data container.\n\n schema (ClassVar[Schema]):\n Payload validation schema.\n\n confidence (float):\n Execution confidence score.\n\n parent (Optional[State]):\n Parent state reference.\n\n depth (int):\n Execution depth.\n\n history (Tuple[str, ...]):\n Ordered node execution lineage.\n\n metadata (Dict[str, Any]):\n Execution metadata.\n\nNotes:\n **Responsibilities:**\n\n - Represents a complete execution snapshot at a specific point in\n pipeline traversal.\n - Fundamental unit of execution in `dagpipe`.\n - Fully thread-safe due to immutability.", "members": { "payload": { "name": "payload", "kind": "attribute", "path": "dagpipe.state.State.payload", "signature": null, "docstring": null }, "schema": { "name": "schema", "kind": "attribute", "path": "dagpipe.state.State.schema", "signature": null, "docstring": null }, "confidence": { "name": "confidence", "kind": "attribute", "path": "dagpipe.state.State.confidence", "signature": null, "docstring": null }, "parent": { "name": "parent", "kind": "attribute", "path": "dagpipe.state.State.parent", "signature": null, "docstring": null }, "depth": { "name": "depth", "kind": "attribute", "path": "dagpipe.state.State.depth", "signature": null, "docstring": null }, "history": { "name": "history", "kind": "attribute", "path": "dagpipe.state.State.history", "signature": null, "docstring": null }, "metadata": { "name": "metadata", "kind": "attribute", "path": "dagpipe.state.State.metadata", "signature": null, "docstring": null }, "fork": { "name": "fork", "kind": "function", "path": "dagpipe.state.State.fork", "signature": "", "docstring": "Create a new child `State` derived from this state.\n\nArgs:\n payload_update (Mapping[str, Any], optional):\n Dot-path updates applied to the payload.\n\n confidence_delta (float, optional):\n Adjustment applied to current confidence.\n\n node_id (str, optional):\n Identifier of the node creating this state.\n\n metadata_update (Mapping[str, Any], optional):\n Updates merged into state metadata.\n\nReturns:\n State:\n A new immutable `State` instance.\n\nNotes:\n **Guarantees:**\n\n - This is the only supported mechanism for modifying execution data.\n - Validates payload updates, preserves lineage, increments depth,\n and appends to history." }, "lineage": { "name": "lineage", "kind": "function", "path": "dagpipe.state.State.lineage", "signature": "", "docstring": "Return lineage from root to this State.\n\nReturns:\n Tuple[State, ...]:\n Ordered execution lineage (root first)." }, "get": { "name": "get", "kind": "function", "path": "dagpipe.state.State.get", "signature": "", "docstring": "Retrieve payload value.\n\nArgs:\n key (str):\n Dot-path key.\n default (Any, optional):\n Fallback value.\n\nReturns:\n Any:\n Stored value or default." }, "has": { "name": "has", "kind": "function", "path": "dagpipe.state.State.has", "signature": "", "docstring": "Check whether payload contains key.\n\nArgs:\n key (str):\n Dot-path key.\n\nReturns:\n bool:\n Existence of the key." } } }, "Incomplete": { "name": "Incomplete", "kind": "alias", "path": "dagpipe.state.Incomplete", "signature": "", "docstring": null } } } }