Probe

object Probe

Named, persistent output channels, keyed and long-lived. Any caller on any thread does Probe.emit("hits", ...) and a later execute_code reads it with Probe.segments("hits") — a patch handler is the motivating case, not the contract, and nothing here references Patches. Channels live in the game loader (single identity) and survive across evals, so what a channel holds accumulates until explicitly cleared.

Reads hand back immutable chunks, never one joined string, so the O(channel) cost of materializing is written where it is paid. Nothing is dropped or annotated on the way out either: the consumer is script CODE, and an injected note would land in whatever parses the result.

Channels are unbounded and nothing reclaims them — a probe on a hot method grows without limit, and is warned about in the game log (see Buffer). Reclaiming is the caller's: mute freezes a channel (new writes dropped, content kept), clear empties one, resetAll drops them all.

Types

Link copied to clipboard
private class Channel(id: String)

A named channel: its buffer plus a muted flag. Muting drops new writes but keeps existing content.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun clear(id: String)

Reclaim id's content, keeping the channel so a mute survives it. Dropping the channel instead would let the next emit recreate it unmuted, silently resuming the growth the mute had stopped.

Link copied to clipboard
fun emit(id: String, value: Any?)

Append value as a line to the named channel, creating it on first use. No-op while muted.

Link copied to clipboard
fun ids(): Set<String>

A snapshot: the backing key set is mutable and live, so handing it out would let a caller drop channels without going through clear, and would let iteration see channels a handler adds mid-loop.

Link copied to clipboard
fun mute(id: String)

Freeze id: new emits are dropped, existing content is kept and stays readable. Creates the channel if absent, so a channel can be muted before its first emit.

Link copied to clipboard
fun resetAll()
Link copied to clipboard

A channel's content as immutable chunks, oldest first; empty if unused. Non-destructive, and a snapshot rather than a live view. A chunk boundary never falls inside a line — every chunk ends at one of the newlines emit wrote.

Link copied to clipboard

segments and empty in one step, so an emit landing mid-consume isn't lost the way a segments + clear pair loses it. Keeps the channel and its mute state.

Link copied to clipboard
fun unmute(id: String)

Resume accepting emits on id. No-op if the channel doesn't exist.