Skip to content

state

state #

ProcedureState — a node's private, non-field state.

Kept off the dataclass (a plain base class of Procedure) so none of it enters the constructor or __dataclass_fields__.

ProcedureState #

A node's identity and per-slot authoring state.

_return_type is a ClassVar set per class from the Procedure[X] base (nodes that compute their type overwrite it per instance); _uuid is set per instance in __post_init__. They are read through the typed return_type / uuid / kind properties.

_children and _assigned_value carry per-slot authoring state on the node itself (no global bookkeeping): the memoized navigation children — a non-empty dict marks the slot a container — and the procedure cached at this slot, or None. A slot is a value or a container, not both.

Source code in capturegraph-lib/capturegraph/procedures/procedure/methods/state.py
class ProcedureState:
    """A node's identity and per-slot authoring state.

    ``_return_type`` is a ``ClassVar`` set per class from the ``Procedure[X]``
    base (nodes that compute their type overwrite it per instance); ``_uuid`` is
    set per instance in ``__post_init__``. They are read through the typed
    ``return_type`` / ``uuid`` / ``kind`` properties.

    ``_children`` and ``_assigned_value`` carry per-slot authoring state on the
    node itself (no global bookkeeping): the memoized navigation children — a
    non-empty dict marks the slot a *container* — and the procedure cached at
    this slot, or ``None``. A slot is a value or a container, not both.
    """

    _uuid: str
    _return_type: ClassVar[type[CGType]]
    _children: dict[tuple[object, ...], Procedure[CGType]]
    _assigned_value: Procedure[CGType] | None = None

    @property
    def uuid(self) -> str:
        """This node's unique id (DAG identity / serialization key)."""
        return self._uuid

    @property
    def return_type(self) -> type[CGType]:
        """The ``CGType`` this node produces when executed."""
        return self._return_type

    @property
    def kind(self) -> type[Self]:
        """This node's class — its name is the JSON ``"kind"``."""
        return type(self)

kind property #

This node's class — its name is the JSON "kind".

return_type property #

The CGType this node produces when executed.

uuid property #

This node's unique id (DAG identity / serialization key).