Powered by AppSignal & Oban Pro

Lesson 07 Livebook: Drift Recovery

livebooks/07_drift_recovery.livemd

Lesson 07 Livebook: Drift Recovery

The bridge has two kinds of bad news now: stale telemetry and no telemetry at all.

Mix.install([
  {:helios_fleet, path: "../07_drift_recovery"}
])

Application.ensure_all_started(:helios_fleet)

Helpers

alias HeliosFleet.LessonSupport

Let The Mesh Drift

alias HeliosFleet
alias Jido.AgentServer
alias Jido.Signal

vessel_id = LessonSupport.unique_agent_id("orpheus")
{:ok, pid} = HeliosFleet.start_command_vessel(vessel_id)

{:ok, _vessel} =
  AgentServer.call(
    pid,
    Signal.new!(
      "fleet.command.mesh_deployment_requested",
      %{
        mesh_id: "mesh-icefall",
        target: "ice fragment 6R"
      },
      source: "/orpheus/bridge"
    )
  )

Process.sleep(50)
{:ok, command_state} = AgentServer.state(pid)
khepri_pid = command_state.children.khepri.pid

{:ok, _probe} =
  AgentServer.call(
    khepri_pid,
    Signal.new!(
      "fleet.probe.telemetry_drift_detected",
      %{
        telemetry_age_s: 480,
        ephemeris_error_km: 23
      },
      source: "/nav/core"
    )
  )

{:ok, _probe} =
  AgentServer.call(
    khepri_pid,
    Signal.new!("fleet.probe.health_report_requested", %{}, source: "/orpheus/bridge")
  )

Process.sleep(200)
{:ok, updated_command_state} = AgentServer.state(pid)

LessonSupport.stop_command_mesh_family(vessel_id)

%{
  probe_health_reports: updated_command_state.agent.state.probe_health_reports,
  recovery_snapshots: updated_command_state.agent.state.recovery_snapshots
}