Powered by AppSignal & Oban Pro

Lesson 08 Livebook: Autonomy After Light-Lag

08_autonomy_after_lightlag.livemd

Lesson 08 Livebook: Autonomy After Light-Lag

The bridge has run out of time. The frontier probe still has to choose.

Mix.install([
  {:helios_fleet, path: "../08_autonomy_after_lightlag"}
])

Application.ensure_all_started(:helios_fleet)

Helpers

alias HeliosFleet.LessonSupport

Release Intent To Khepri

alias HeliosFleet
alias HeliosFleet.Signals.Command.AutonomyReleaseRequested
alias HeliosFleet.Signals.Command.MeshDeploymentRequested
alias HeliosFleet.Signals.Probe.HealthReportRequested
alias HeliosFleet.Signals.Probe.TelemetryDriftDetected
alias Jido.AgentServer

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

{:ok, _vessel} =
  AgentServer.call(
    pid,
    MeshDeploymentRequested.new!(%{
      mesh_id: "mesh-icefall",
      target: "ice fragment 6R"
    })
  )

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

{:ok, _probe} =
  AgentServer.call(
    khepri_pid,
    TelemetryDriftDetected.new!(%{
      telemetry_age_s: 480,
      ephemeris_error_km: 23
    })
  )

{:ok, _probe} = AgentServer.call(khepri_pid, HealthReportRequested.new!())

Process.sleep(200)

{:ok, _vessel} =
  AgentServer.call(
    pid,
    AutonomyReleaseRequested.new!(%{
      intent: "protect contact truth before intercept",
      autonomy_target: "khepri",
      command_window_s: 900
    })
  )

Process.sleep(50)

{:ok, updated_command_state} = AgentServer.state(pid)
{:ok, updated_probe_state} = AgentServer.state(khepri_pid)

LessonSupport.stop_command_mesh_family(vessel_id)

%{
  autonomy_packets: updated_command_state.agent.state.autonomy_packets,
  autonomy_decisions: updated_probe_state.agent.state.autonomy_decisions
}