Implement two virtual node patterns for message flow orchestration: - Sequence: Chains listeners in order (A→B→C), feeding each step's output as input to the next. Uses ephemeral listeners to intercept step results without modifying core pump behavior. - Buffer: Fan-out to parallel worker threads with optional result collection. Supports fire-and-forget mode (collect=False) for non-blocking dispatch. New files: - sequence_registry.py / buffer_registry.py: State tracking - sequence.py / buffer.py: Payloads and handlers - test_sequence.py / test_buffer.py: 52 new tests Pump additions: - register_generic_listener(): Accept any payload type - unregister_listener(): Cleanup ephemeral listeners - Global singleton accessors for pump instance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
"""
|
|
System primitives — Core message types handled by the organism itself.
|
|
|
|
These are not user-defined listeners but system-level messages that
|
|
establish context, handle errors, and manage the organism lifecycle.
|
|
"""
|
|
|
|
from xml_pipeline.primitives.boot import Boot, handle_boot
|
|
from xml_pipeline.primitives.todo import (
|
|
TodoUntil,
|
|
TodoComplete,
|
|
TodoRegistered,
|
|
TodoClosed,
|
|
handle_todo_until,
|
|
handle_todo_complete,
|
|
)
|
|
from xml_pipeline.primitives.text_input import TextInput, TextOutput
|
|
from xml_pipeline.primitives.sequence import (
|
|
SequenceStart,
|
|
SequenceComplete,
|
|
SequenceError,
|
|
handle_sequence_start,
|
|
)
|
|
from xml_pipeline.primitives.buffer import (
|
|
BufferStart,
|
|
BufferItem,
|
|
BufferComplete,
|
|
BufferDispatched,
|
|
BufferError,
|
|
handle_buffer_start,
|
|
)
|
|
|
|
__all__ = [
|
|
# Boot
|
|
"Boot",
|
|
"handle_boot",
|
|
# Todo
|
|
"TodoUntil",
|
|
"TodoComplete",
|
|
"TodoRegistered",
|
|
"TodoClosed",
|
|
"handle_todo_until",
|
|
"handle_todo_complete",
|
|
# Text I/O
|
|
"TextInput",
|
|
"TextOutput",
|
|
# Sequence orchestration
|
|
"SequenceStart",
|
|
"SequenceComplete",
|
|
"SequenceError",
|
|
"handle_sequence_start",
|
|
# Buffer orchestration
|
|
"BufferStart",
|
|
"BufferItem",
|
|
"BufferComplete",
|
|
"BufferDispatched",
|
|
"BufferError",
|
|
"handle_buffer_start",
|
|
]
|