Skip to content

Tests Tap

mchristegh edited this page Jul 14, 2026 · 1 revision

test-scripts/tap-harness.js — the tap's scope, capture, muting, and auto-error behavior. This harness adds the one genuinely new piece of stub machinery in the suite: a fake RED.hooks implementing add, pattern-based remove, and dispatchers that simulate onSend batches and onComplete events from a fake population of runtime nodes (mqtt-ins on different flows, a function, an http-request, and two flight-recorder family members used as would-be capture targets). It closes with a control-node-to-tap integration test.

Group Why it exists
S1 — hook lifecycle onSend registers on construction; onComplete registers only when auto-error dump is enabled; close removes every hook — no leaked handlers across redeploys.
S2 — flow scope & lazy pickup Nodes on the scoped flow are captured, others aren't — and a never-seen node appearing later (a partial-deploy addition) is picked up on first sight, proving the self-healing cache.
S3 — selectors & exclusions Node-id and type selectors both admit; exclusions beat selectors (a type-matched node excluded by id stays out; all-flows minus an excluded type stays out). The scope algebra as assertions.
S4 — family self-exclusion The unconditional rule under maximum pressure: all-flows plus the recorder nodes explicitly named in the Nodes field — and they're still not recorded. Recorders never record recorders.
S5 — fan-out dedupe One message sent to three wires in one hook batch yields one record (with the output port preserved), while genuinely distinct messages in the same batch all capture.
S6 — mute mechanics The full nothing-invisible story: suppression counted per target, mute/unmute marks on the tape in sequence position (the unmute mark carrying the suppressed count), events emitted, status showing the mute, type-level mutes working, query reporting active mutes and scope counters, redundant mutes ignored-acked.
S7 — out-of-scope mute Muting a node the tap has already seen and rejected is refused loudly (muteIgnored) with no mark laid — you probably typo'd the id.
S8 — auto error dump All four boundary conditions: an in-scope error produces a structured error incident (message and source in context, the tape attached); out-of-scope errors are ignored; the cooldown suppresses visibly; and — the subtle rule — a muted source's errors still dump (muted chatter, not muted failures).
S9 — auto-error off With the feature disabled, completion events produce nothing — proving the hook genuinely isn't registered rather than registered-but-ignored.
S10 — watermark on tapped traffic The watermark evaluates against hooked messages with the same capture-first semantics as inline.
S11 — the command input Payload commands work on the tap's own input (the convenience alias), garbage payloads are tolerated with an ignored-ack, and — important — command messages are never recorded as traffic.
S12 — control → tap The registry seam across node types: a mute issued through a control node reaches the tap with msg.target forwarded, takes effect, and the unmute receipt carries the suppressed count back.
S13 — incident meta Tap incidents carry the environment meta block, proving the shared wiring in the second wrapper.

Clone this wiki locally