Skip to content

Report a robot's status to InOrbit when it changes - #94

Merged
b-Tomas merged 1 commit into
mainfrom
report-robot-status-changes
Aug 28, 2026
Merged

Report a robot's status to InOrbit when it changes#94
b-Tomas merged 1 commit into
mainfrom
report-robot-status-changes

Conversation

@b-Tomas

@b-Tomas b-Tomas commented Aug 27, 2026

Copy link
Copy Markdown
Member

Blocked on inorbit-ai/edge-sdk-python#113 being merged and released. The tests fail against edge-sdk 3.2.x, which has neither RobotSession.publish_status() nor RobotSessionFactory.set_online_status_callback().

Problem

#92 stopped publishing system stats for robots the connector reports offline, which stops InOrbit asking for state and re-stamping the robot's offline timestamp on every execution loop iteration. Reading the platform side afterwards showed that it also removes the only signal that can mark such a robot offline in the first place:

  • ingest's system module sends get_state only for a robot it already has offline, and only on a system/stats message. No other message type triggers it.
  • The pinger only pings robots it already has online, and the Edge SDK auto-echoes every incoming message, so pings succeed for as long as the connector process is alive — however dead the robot is.

So a robot that dies while InOrbit has it online stays online indefinitely: no stats to provoke get_state, no failing pings, and the session is up so neither the will nor disconnect() fires. The connector knows the robot is offline and has no way to say so.

Change

Hand the online check's result to the session on every iteration, next to the decision it already drives:

online = self._is_fleet_robot_online(robot_id)   # already computed for the stats gate
session.publish_status(online)

The edge-sdk publishes it only when it changed, so the robot is reported offline once — at the moment it goes offline, which is the timestamp you want — and nothing touches it afterwards. When the robot comes back, the status flips to online in the same place and the stats resume.

Also moves the online status callback registration from the session to the RobotSessionFactory. RobotSessionPool.get_session() builds and connects a session in one step, so registering on the session happened after the first connection had already published a status — the callback only ever affected later reconnections.

Dependency floor moves to inorbit-edge>=3.3.0 for publish_status() and RobotSessionFactory.set_online_status_callback().

Notes for review

  • publish_status is called every iteration on purpose. The de-duplication lives in the edge-sdk, so the connector keeps no extra per-robot state and cannot drift out of sync with what was actually published.
  • A callback stuck at False now marks the robot offline rather than merely muting its stats. A callback that raises still falls back to online, as before.
  • The MQTT will still restamps on an ungraceful connector kill. It is broker-side and fires exactly when the connector could not speak for itself.

Testing

  • test_publish_pending_system_stats_publishes_online_status — online robot gets publish_status(True), offline robot publish_status(False)
  • test_sets_online_status_callback — rewritten for factory-level registration, asserts nothing is registered on the session
  • 238 passed, flake8 and black clean, run against the edge-sdk branch from Report the robot's actual status, and only when it changes edge-sdk-python#113

🤖 Generated with Claude Code

Not publishing system stats for an offline robot stops InOrbit from asking for
state and re-stamping the robot's offline timestamp, but it also removes the
only thing that could ever mark that robot offline: InOrbit requests state only
from robots it already has offline, and the robot session answers InOrbit's
pings for as long as the connector process is alive. A robot that dies while
InOrbit has it online would stay online indefinitely.

Hand the online check's result to the session on every iteration instead. The
edge-sdk publishes it only when it changed, so the robot is reported offline
once, when it goes offline, and its offline timestamp is left alone from then
on.

Register the online status callback on the RobotSessionFactory rather than on
each session: the pool connects a session as soon as it builds it, so the
per-session registration happened after the first connection had already
reported a status.

Requires the edge-sdk release with publish_status() and the factory-level
callback, so the dependency floor moves to 3.3.0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@b-Tomas
b-Tomas force-pushed the report-robot-status-changes branch from fa5bac2 to 34c3383 Compare August 28, 2026 14:23
@b-Tomas b-Tomas self-assigned this Aug 28, 2026
@b-Tomas
b-Tomas merged commit 41e9e77 into main Aug 28, 2026
16 of 52 checks passed
@b-Tomas
b-Tomas deleted the report-robot-status-changes branch August 28, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants