Let a flow keep state in the messages it already has
Logic nodes are pure functions with no state handle, but real automations count things and remember the last reading. The shape for that is a message a node both reads and writes: the graph already declines to make a node depend on itself, so this worked by accident. It is now defined, tested, and checked — a node that is the only writer of a message it reads is told at edit time that it needs a starting value, rather than silently never running. Feeding a value back between two nodes was still a cycle, and rejected. An input can now be marked non-triggering: read when the node runs, never the reason it runs, and no dependency either way. That is what a back edge actually means.
This commit is contained in:
@@ -46,6 +46,10 @@ class MessageSpec(BaseModel):
|
||||
On an output it holds back publishing, on an input it holds back waking
|
||||
the node. The value is never lost — state keeps the latest — only the
|
||||
delivery is skipped.
|
||||
:param trigger: Whether arriving values wake the node. An input with this
|
||||
off is read when the node runs for some other reason, but never causes
|
||||
a run and never makes the node wait — which is how a node reads a
|
||||
message it also produces without depending on itself.
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(frozen=True)
|
||||
@@ -54,6 +58,7 @@ class MessageSpec(BaseModel):
|
||||
port: str = ""
|
||||
dtype: DType = DType.FLOAT
|
||||
interval: float = Field(default=0, ge=0)
|
||||
trigger: bool = True
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _default_port(self) -> MessageSpec:
|
||||
|
||||
Reference in New Issue
Block a user