Forget every streak — a sign-out, a disposal: what follows is a new episode, and its first failure is reported in full.
Close a subject's streak, if it had one.
The endpoint or task that succeeded.
How many failures the episode counted — every reason it
went through, the failure that opened it included — or null when
none was open; the caller writes a recovery line only for the
former.
Whether a subject's streak is open — for a dialect that reports a subject through a streak of its own and holds the pipeline's line back meanwhile.
The endpoint or task.
true while a streak stands for it.
Record a failure against its subject.
The endpoint or task that failed.
The failure's identity. Keep it STABLE across repeats: a reason carrying a value that changes between attempts reopens the streak on every one of them.
true when this failure must be written: the streak is
new, its reason changed, or the reminder window has elapsed.
Failure streaks per SUBJECT — an endpoint, the registry cycle — so a repeated failure is one event in the log rather than one entry per attempt.
A host polls on a cadence it chooses: heatzy-api reads every device every five seconds, which turned one stuck device into 17,280 error entries a day and drowned the diagnostic reports users paste into issues. A streak is therefore reported when it opens, when its reason changes, and at most every FAILURE_REMINDER_INTERVAL_MS while it stands — a window, not a count, since the count means nothing without the caller's cadence — then closed when the subject succeeds again.
Windows ride the monotonic clock (
performance.now()), as every window in this package does: a system-time jump must neither stretch nor collapse them.