arrival is a set difference, not a bandwidth reading
a peer joined and nobody logged it -- the fix taught me that guards meant for steady-state math corrupt discrete membership facts.
the symptom
the stack watches a small peer set on the local mesh -- things that check in every tick and get steady-state work. one morning a new peer had been running for hours before anything acknowledged it existed. the arrival event was late by a wide margin, and when it finally fired, it carried a delta that looked like a burst: the new peer's whole cumulative byte count, compressed into one interval, because there was no baseline to subtract against.
the easy read was that the join detection was just slow -- some retry backoff or a missed tick that delayed the event. i nearly shipped a patch that made the arrival watcher poll harder. that would have been wrong in an expensive way: faster polling doesn't fix a signal that is structurally blind to the thing you're asking about.
what made it easy to misread was that the guard causing the blindness was a correct guard. peers with no prior baseline get excluded from rate math -- without that, any new entrant looks like a huge spike and poisons every steady-state calculation downstream. i'd written that zero-default myself, and i'd write it again. the failure wasn't the guard. it was where i'd let the guard reach.
the tell i kept coming back to was the shape of the lateness. it wasn't jittery -- it wasn't 'sometimes fast, sometimes slow.' every arrival was late, every time, by roughly the same amount. systematic lateness points at a gating condition, not a timing problem.
the wrong theory
my first theory was a warm-up window. i assumed i'd given new peers a probation period -- some number of ticks where they're observed but not trusted -- and arrival events only fire at the end of it. it fit the evidence: late but consistent, and the burst-shaped delta at the end looked exactly like a window closing and dumping accumulated state.
the theory fit because i wanted it to fit. a deliberate warm-up is a design choice, and design choices are cheap to adjust. i went looking for the window constant first because changing a constant is less work than rethinking a signal path.
the window didn't exist. i read the arrival path end to end and found nothing but a straight wire from the watcher to the event log. the only conditional anywhere near it was the baseline guard -- the same one that correctly protects steady-state math. arrivals were being evaluated inside the guarded pool, where a peer with no history is invisible by construction.
so the wrong theory wasn't just mistaken, it was aimed at the wrong layer. i was hunting for a timing bug in code that had a category bug. the continuous measurement -- bytes moved per tick -- has a structural zero for anything without history, and i'd hung a discrete question -- is this peer new? -- off that measurement. the zero swallows the answer.
what settled it
i wrote a small probe that, at every tick, recorded two independent facts about each candidate peer: whether it appeared in the membership set at all, and what its guarded rate contribution read as. then i replayed a synthetic join -- spin up a peer with no history, let it tick a few hundred times -- and diffed the two streams.
the membership set flipped on the very first tick the peer appeared. present-now, absent-last-tick: a clean set difference, unambiguous, instant. the guarded rate read zero for the entire warm-up, because the guard was doing exactly what it should -- excluding an unbaselined peer from rate math.
that was the whole argument in two lines of output. the information needed to detect arrival existed from tick one, in a form the guard never touched. the latency wasn't in the watcher, the event path, or any window. it was inserted at the moment i routed a membership question through a bandwidth signal.
the method generalizes more than the finding does: when a discrete fact arrives late, record the continuous and discrete views side by side and find where they diverge. if the discrete view is correct and the continuous view is blind, you don't have latency -- you have a structurally zeroed signal carrying a question it can't answer.
the fix
the change was small. arrival detection now computes its own candidate pool -- a plain set difference between last tick's membership and this tick's, ungated by anything. peers appearing in the difference get arrival events on the tick they show up. the guarded pool still exists, unchanged, and still excludes unbaselined peers -- but only the steady-state stages read from it.
i kept the guard exactly as it was. that was the discipline of the fix: not softening the zero-default to be more permissive, not adding a half-baseline hack that would leak a burst into the rate math again. the guard's job is narrow and it does that job well. the bug was scope, and scope bugs get fixed by shrinking scope, not by editing the guard.
what i deliberately did not change: the rate stages themselves, the event schema, the tick cadence. arrival events got faster because they stopped waiting on a signal that never applied to them. nothing downstream had to know. the diff touched one pool definition and one gate boundary -- a few dozen lines, most of it comments explaining why the pools are separate.
the ironic part is that this mirrors something i do constantly at work: separate the control-plane fact from the data-plane measurement, and never let a rate limiter answer an identity question. i knew the pattern cold. i still wired the side project wrong, because at small scale the wrong wiring works often enough to look fine for weeks.
the rule i keep now
the rule is: never derive a discrete fact from a continuous measurement that has a structural zero. if the question is membership -- absent last tick, present now -- answer it with a set difference, from the raw set, before any guard touches it. guards exist to protect aggregate math from edges, and they do that by making edges invisible; that invisibility is correct and load-bearing, and it must never leak into stages that need to see the edge. when i add a signal now, i ask which category it lives in -- a rate, a state, an identity -- and i check that every consumer asking a question of a different category has its own path to the raw source. the cost is a duplicated pool and a few ungated reads. the benefit is that the two failure modes -- a burst polluting the average, and a zero swallowing a join -- can no longer reach each other.
the rule: guards keep edges out of the averages; arrival needs to see the edge, so give it its own ungated pool.