Follow-ups from review of the activity-state guard:
1. The guard only covered a reconnect landing on a different node. If the
replacement lands on this node while the stale callback is still tearing its
own session down, isOwnedByAnotherNode sees this node's own service id and the
stale active=false is written anyway - the exact state the guard exists to
prevent. Add the local-session check, matching the eviction guard which
already tests for a newer local session.
2. LAST_DISCONNECT_TIME and the DISCONNECT_EVENT push ran unconditionally. The
timestamp would contradict the live session's lastConnectTime, and the event
payload is {"active": false, ...} with SERVER_SCOPE in its metadata - exactly
what a Save Attributes node persists, so a rule chain wiring Disconnect Event
to Save Attributes writes active=false straight back and re-creates the
dropped-event behaviour through the rule engine. Both now sit inside the same
guard. scheduleDisconnectNotification stays outside: it re-verifies liveness
itself before firing.
3. The eviction guard only checked cache ownership, so a replacement on this node
would have its claim evicted by the stale callback. It now also requires that
no live session holds the edge.
4. cleanupZombieSessions removed by edge id unconditionally after destroy(),
which is not instantaneous. If the edge reconnected in that gap the live
session was dropped from 'sessions' while remaining in 'sessionsById', so it
was never torn down but every downlink lookup silently no-opped. Use a
compare-and-remove. removeFunc becomes a Consumer, since its return value was
already discarded.
5. Document that the guard narrows rather than closes the race - the attribute is
last-writer-wins across nodes - and that the dead-owner fallback does not
cover a node restarting under the same service id.
Tests: cover the same-node replacement, the DISCONNECT_EVENT suppression and its
positive counterpart, and pin the onEdgeConnect ownership publish order with an
InOrder assertion, which nothing held before. The rule-engine stubs in the
suppression tests are lenient on purpose: without them the push could never fire
and the never() assertions would pass vacuously.