# Scatter Engine
The scatter engine takes match events or records produced by earlier stages and writes them into an output buffer. Its primary obligations are preserving every logical event and avoiding duplicates under parallel execution.
## Invariants
NoOutputLost: every valid input event appears in the output exactly once unless the engine specification defines a filter that removes it.
NoDuplicateOutput: no logical event appears more than once. The logical event key is the event id when present; otherwise it is the tuple of source offset, pattern id, payload, and stable input index.
Deterministic: when ordering is declared stable for a scatter mode, repeated runs produce identical output bytes. When ordering is explicitly unordered, the normalized multiset of events must still be identical.
## Random Test Generation
Generate random match events with duplicate-looking payloads, repeated offsets, empty event lists, single events, maximum event counts, already-sorted inputs, reverse-sorted inputs, and adversarial distributions that send many events to the same workgroup or output page.
## Verification
Normalize CPU and backend outputs into logical event multisets. Verify every generated event appears exactly once and no extra event appears. For ordered scatter modes, compare byte order directly after the multiset check. Any failure persists the event list with `Fix: repair atomic reservation, prefix sum, or output write indexing so each event is emitted exactly once`.