Source code for fleetmesh_node.planes.transport.link.compartment

"""The relay links this node holds open, as a compartment.

The transport keeps the sockets and counts what it drops. Nothing watched it:
the tick read `transport.health` directly to decide what to say to the journal,
and `health()` read six more of its counters by name. A subscription that
dropped was therefore visible in two hand-written places and in no refusal
channel at all, so `meshnode refusals` - the one view that answers "what has
this node been saying no to" - could not show a relay that had been refusing
this node for an hour.

This compartment owns what the journal has already been told, so it says a
transition once and not once a tick, and it records the drop as a refusal like
every other no.

It also records the transport's verdicts on stored messages. A kind 1059 the
relay accepted and never served used to be indistinguishable from one that
arrived; now every stored message asks for an acknowledgment, and a peer that
has spoken since and not acknowledged is a `stored: unacknowledged` refusal
here, with the message type and the relays it went through, so `meshnode
refusals` can show the day the control plane went quiet.
"""
from __future__ import annotations

from typing import Any, Callable, Optional

from fleetmesh_node.compartment import stores as st
from fleetmesh_node.channels import Channel, NOTE, TROUBLE
from fleetmesh_node.compartment import Command, Compartment, Need
from fleetmesh_node.metrics import COUNTER, Metric
from fleetmesh_node.interfaces import AwaitingAckRow
from fleetmesh_node.transport.ladder import Fault
from fleetmesh_node.transport.relay_rung.cooldown import Cooling


from fleetmesh_node.config import TransportConfig
from .types import LinkState