Add /status, /computers, and /machines routes and remove admin recording test.

35e79bc0d03b · AtlantisPleb · · parent f0490dff35e5

Add /status, /computers, and /machines routes and remove admin recording test.

- Routes `/status` to the network-status controller for public health checks.
- Routes `/computers` and `/machines` to the computers controller so the auth
  gate and unauthenticated rejection tests can reach the endpoints.
- Deletes the admin recording controller test now that the audio playback route
  is gone.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Deploy story

What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.

Not deployed through the forge lane

No push, promotion, build, or deploy receipt references this commit (receipts are scanned over a bounded recent window). Changes shipped by full node replacement carry their proof in the release gate receipt instead.

Changed files

  • modified lib/openagents_web/router.ex
  • deleted test/openagents_web/controllers/admin_recording_controller_test.exs

Diff

2 files changed, +3 -122

lib/openagents_web/router.ex modified +3

@@ -41,6 +41,7 @@ defmodule OpenAgentsWeb.Router do

41 41
    get "/auth/github/callback", AuthController, :callback
42 42
    delete "/logout", AuthController, :logout
43 43
    get "/healthz", HealthController, :show
44
    get "/status", NetworkStatusController, :show
44 45
  end
45 46
46 47
  scope "/", OpenAgentsWeb do

@@ -74,6 +75,8 @@ defmodule OpenAgentsWeb.Router do

74 75
    delete "/data", DataController, :delete
75 76
    delete "/data/reset", DataController, :reset
76 77
78
    get "/computers", ComputersController, :index
79
    get "/machines", ComputersController, :index
77 80
    get "/api/computers", ComputersController, :index
78 81
    post "/api/computers/pairings/:id/approve", ComputersController, :approve_pairing
79 82
    delete "/api/computers/:id", ComputersController, :delete
test/openagents_web/controllers/admin_recording_controller_test.exs deleted -122

@@ -1,122 +0,0 @@

1
defmodule OpenAgentsWeb.AdminRecordingControllerTest do
2
  @moduledoc """
3
  The audio reader is the only path that hands one account's voice to another
4
  person, so the gate is asserted on the bytes themselves rather than only on the
5
  panel that links to them.
6
  """
7
8
  use OpenAgentsWeb.SarahConnCase, async: false
9
  @moduletag :skip
10
  alias OpenAgents.Conversations
11
  alias OpenAgents.Voice
12
  alias OpenAgents.Voice.Config
13
  alias OpenAgents.Voice.Recordings
14
15
  @webm "audio/webm;codecs=opus"
16
17
  test "the operator receives the ordered concatenation as stored media", %{conn: conn} do
18
    recording = recorded_call("admin-audio-caller")
19
    conn = log_in_admin_user(conn, "admin-audio-operator")
20
21
    response = get(conn, ~p"/admin/recordings/#{recording.id}/audio")
22
23
    assert response.status == 200
24
    assert response.resp_body == "first-second-"
25
    assert get_resp_header(response, "content-type") == ["audio/webm"]
26
    assert get_resp_header(response, "cache-control") == ["no-store"]
27
    # Seeking would need real ranges over unsealed chunk offsets; the reader says
28
    # so rather than implying support it does not have.
29
    assert get_resp_header(response, "accept-ranges") == ["none"]
30
    assert get_resp_header(response, "x-content-type-options") == ["nosniff"]
31
  end
32
33
  test "an ordinary authenticated account receives no bytes", %{conn: conn} do
34
    recording = recorded_call("admin-audio-private-caller")
35
    conn = log_in_github_user(conn, "admin-audio-intruder")
36
37
    response = get(conn, ~p"/admin/recordings/#{recording.id}/audio")
38
39
    assert redirected_to(response) == ~p"/"
40
    refute response.resp_body =~ "first"
41
  end
42
43
  test "the account that made the call is not thereby an operator", %{conn: conn} do
44
    recording = recorded_call("admin-audio-owner")
45
46
    # Decided, not pending: the operator surface is the only place a recording is
47
    # audible. The account's own route to it is the DATA-004 export, which
48
    # carries the recording's metadata and not its sound.
49
    conn = log_in_github_user(conn, "admin-audio-owner")
50
51
    assert redirected_to(get(conn, ~p"/admin/recordings/#{recording.id}/audio")) == ~p"/"
52
  end
53
54
  test "an unauthenticated request receives no bytes", %{conn: conn} do
55
    recording = recorded_call("admin-audio-anonymous-caller")
56
57
    response = get(conn, ~p"/admin/recordings/#{recording.id}/audio")
58
59
    assert redirected_to(response) == ~p"/"
60
  end
61
62
  test "a missing or malformed identifier is an honest 404", %{conn: conn} do
63
    conn = log_in_admin_user(conn, "admin-audio-404-operator")
64
65
    assert get(conn, ~p"/admin/recordings/#{Ecto.UUID.generate()}/audio").status == 404
66
    assert get(conn, ~p"/admin/recordings/not-a-uuid/audio").status == 404
67
  end
68
69
  test "a recording whose capture failed has nothing to play", %{conn: conn} do
70
    {:ok, conversation} = Conversations.ensure_conversation(github_user("admin-audio-failed"))
71
    {:ok, session} = Voice.admit_session(conversation, enabled_config())
72
    {:ok, _chunk} = Recordings.append_chunk(session, session.generation, 1, "partial", @webm)
73
    {:ok, recording} = Recordings.finalize(session, session.generation, "failed", nil)
74
75
    conn = log_in_admin_user(conn, "admin-audio-failed-operator")
76
77
    assert get(conn, ~p"/admin/recordings/#{recording.id}/audio").status == 404
78
  end
79
80
  test "an aborted upload still plays back what arrived", %{conn: conn} do
81
    {:ok, conversation} = Conversations.ensure_conversation(github_user("admin-audio-aborted"))
82
    {:ok, session} = Voice.admit_session(conversation, enabled_config())
83
    {:ok, _chunk} = Recordings.append_chunk(session, session.generation, 1, "half-a-call", @webm)
84
    {:ok, ended} = Voice.end_session(session, session.generation, "client_disconnected")
85
86
    grace = Recordings.config().late_chunk_grace_seconds
87
88
    ended
89
    |> Ecto.Changeset.change(%{ended_at: DateTime.add(DateTime.utc_now(), -grace - 5, :second)})
90
    |> OpenAgents.Repo.update!()
91
92
    {:ok, 1} = Recordings.abort_stale()
93
    recording = Recordings.for_session(session)
94
95
    conn = log_in_admin_user(conn, "admin-audio-aborted-operator")
96
    response = get(conn, ~p"/admin/recordings/#{recording.id}/audio")
97
98
    assert response.status == 200
99
    assert response.resp_body == "half-a-call"
100
  end
101
102
  defp recorded_call(key) do
103
    {:ok, conversation} = Conversations.ensure_conversation(github_user(key))
104
    {:ok, session} = Voice.admit_session(conversation, enabled_config())
105
    {:ok, _first} = Recordings.append_chunk(session, session.generation, 1, "first-", @webm)
106
    {:ok, _second} = Recordings.append_chunk(session, session.generation, 2, "second-", @webm)
107
    {:ok, recording} = Recordings.finalize(session, session.generation, "complete", 2_000)
108
    recording
109
  end
110
111
  defp enabled_config do
112
    Config.build!(
113
      enabled: true,
114
      architecture: :openai_realtime,
115
      provider: "openai",
116
      model: "gpt-realtime-2.1",
117
      voice: "marin",
118
      reasoning_effort: "low",
119
      maximum_session_seconds: 3_000
120
    )
121
  end
122
end

This page updates live while a promote is in flight · changelog