attachTransitionSink

Send this element's transitions to sink, from now until it is detached (§4.8.2).

Attachment is external and repeatable, which is what lets a sink be added from main() or from a tool layer rather than written into the element's declaration — the same freedom ModelElement.attachModelElementObserver gives an observer and ksl.animation.AnimationCapture gives an animation trace. Several sinks may be attached; each receives every record, in attachment order.

The prohibition it keeps. A sink may not be attached or detached while the model is running: a trajectory that starts at the middle of an episode has no predecessor for its first row and is worse than no trajectory at all. That is a narrower rule than the one this subsystem used to enforce — "declare it when the element is built" — which was strong enough to also forbid the harmless case of attaching before a run, or between two runs, and could only be enforced by making the API unreachable. The real invariant is that the set of sinks is fixed for the duration of an experiment, and that is checkable, so it is checked here rather than promised in prose.

The element does not own sink. It calls beginExperiment/endExperiment around each run; close() belongs to whoever constructed it (§4.7).

Throws

if the model is running, or if sink is already attached — a double attach would deliver every record to it twice, which no caller means.