Skip to content

device_availability SSE event is documented and serialized but never emitted #300

Description

@CameronBrooks11

docs/http-api.md lists device_availability as an SSE event type on GET /v0/events, and state_handlers.cpp serializes DeviceAvailabilityEvent into event: device_availability. Nothing in the runtime constructs one:

grep -rn "DeviceAvailabilityEvent" core/ | grep -v "event_types.hpp\|event_emitter.cpp\|state_handlers.cpp"

returns nothing on main. A client subscribing for device availability gets a documented event that never fires.

Where the edges are

StateCache now has a per-device reachability sink (#299) that fires on the provider_available edge in poll_device (loss) and update_device_state (recovery). That is the natural place to emit, but it is not sufficient on its own: mark_provider_devices_unavailable — the supervised-provider-restart path — sets provider_available = false directly, bypassing the sink. Emitting only at the sink would produce an available: true event with no preceding available: false after every provider restart. #299 deliberately left the event unwired rather than ship that.

What a correct wiring needs

  • Emit available: false from both loss paths: the per-device read failure in poll_device and the per-provider mark_provider_devices_unavailable.
  • Emit available: true from update_device_state on the recovery edge only (provider_available initializes to true, so first-poll does not fire).
  • Decide whether emission belongs in StateCache directly (it already owns event_emitter_ and emits StateUpdateEvent / QualityChangeEvent from the same place) or via the sink. Direct is simpler and reaches both loss paths; the sink is for the loss latch, which must not engage on provider restart.
  • A test that a provider restart produces a false/true pair, not a lone true.

Not in scope

The device-loss latch (#299) classifies losses by status code and does not latch on provider restart. The availability event should mirror provider_available exactly and carry no classification.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions