fluksio.arrived(): a node can tell which inputs the wave behind it wrote, so a value written again unchanged is seen

This commit is contained in:
2026-11-05 21:24:21 +01:00
parent b7f1d21712
commit 7ddf8aa8f9
9 changed files with 127 additions and 7 deletions
+14 -1
View File
@@ -83,6 +83,8 @@ CHUNK = 1024 * 1024
_RPC: Any = None
#: The call being served, so an event can say which one it belongs to.
_CALL_ID = ""
#: The input ports the wave behind this call wrote, or None if it cannot say.
_ARRIVED: list[str] | None = None
def _emit(event: dict[str, Any]) -> None:
@@ -116,6 +118,16 @@ class _Reporter(ModuleType):
"""
_emit({"event": "emit", "outputs": dict(ports)})
def arrived(self) -> set[str] | None:
"""The input ports the message that started this run wrote.
The other inputs still hold what they held before. A value written
again unchanged is here too, which is how a node tells somebody
repeating a command from a value that only sits in state. None when
the engine cannot say, such as when the flow starts.
"""
return None if _ARRIVED is None else set(_ARRIVED)
def save_artifact(
self,
source: Any,
@@ -545,7 +557,7 @@ def _drain(generator: Any) -> Any:
def main() -> None:
global _RPC, _CALL_ID
global _RPC, _CALL_ID, _ARRIVED
_RPC = os.fdopen(os.dup(1), "w")
# Everything the node writes to the real stdout now goes to the server log.
@@ -558,6 +570,7 @@ def main() -> None:
continue
request = json.loads(line)
_CALL_ID = str(request.get("call_id") or "")
_ARRIVED = request.get("arrived")
captured = _Capped()
# ``id`` back untouched: the engine matches it against what it sent, so
# a pipe that has slipped a call is caught rather than handing one node