Skip to content

Commit f225ae8

Browse files
committed
chore(runtime): remove stale control-plane references
Stop treating pruned Codex app-server helper paths as protected runtime ingress routes. Codex Pooler supports Codex model-provider access plus local usage reads, not ChatGPT backend/control-plane proxying.
1 parent 7f0f748 commit f225ae8

2 files changed

Lines changed: 29 additions & 90 deletions

File tree

lib/codex_pooler_web/plugs/runtime_ingress.ex

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngress do
1818
["backend-api", "transcribe"],
1919
["api", "codex", "usage"],
2020
["wham", "usage"],
21-
["backend-api", "wham", "agent-identities", "jwks"],
2221
["backend-api", "wham", "usage"],
2322
["v1"]
2423
]
@@ -363,37 +362,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngress do
363362
}),
364363
do: true
365364

366-
def protected_backend_json_request?(%Plug.Conn{
367-
method: "POST",
368-
path_info: ["backend-api", "codex", "thread", "goal", action]
369-
})
370-
when action in ["get", "set", "clear"],
371-
do: true
372-
373-
def protected_backend_json_request?(%Plug.Conn{
374-
method: "POST",
375-
path_info: ["backend-api", "codex", "analytics-events", "events"]
376-
}),
377-
do: true
378-
379-
def protected_backend_json_request?(%Plug.Conn{
380-
method: "POST",
381-
path_info: ["backend-api", "codex", "memories", "trace_summarize"]
382-
}),
383-
do: true
384-
385-
def protected_backend_json_request?(%Plug.Conn{
386-
method: "POST",
387-
path_info: ["backend-api", "codex", "alpha", "search"]
388-
}),
389-
do: true
390-
391-
def protected_backend_json_request?(%Plug.Conn{
392-
method: "POST",
393-
path_info: ["backend-api", "codex", "safety", "arc"]
394-
}),
395-
do: true
396-
397365
def protected_backend_json_request?(%Plug.Conn{
398366
method: "POST",
399367
path_info: ["backend-api", "files"]
@@ -409,13 +377,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngress do
409377

410378
def protected_backend_json_request?(_conn), do: false
411379

412-
@spec protected_backend_raw_request?(Plug.Conn.t() | term()) :: boolean()
413-
def protected_backend_raw_request?(%Plug.Conn{
414-
method: "POST",
415-
path_info: ["backend-api", "codex", "realtime", "calls"]
416-
}),
417-
do: true
418-
419380
def protected_backend_raw_request?(_conn), do: false
420381

421382
defp decode_or_send_compressed_body(conn, settings) do

test/codex_pooler_web/plugs/runtime_ingress_test.exs

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngressTest do
33

44
import CodexPooler.PoolerFixtures
55

6-
alias CodexPooler.Accounting.{Attempt, Request}
76
alias CodexPooler.Catalog.PricingSnapshot
87
alias CodexPooler.FakeUpstream
98
alias CodexPooler.Gateway.OperationalSettings
@@ -121,7 +120,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngressTest do
121120

122121
for {method, path} <- [
123122
{:get, "/backend-api/codex/models"},
124-
{:get, "/backend-api/codex/agent-identities/jwks"},
125123
{:post, "/backend-api/codex/responses"},
126124
{:get, "/backend-api/codex/v1/responses"},
127125
{:post, "/backend-api/codex/v1/responses"},
@@ -131,7 +129,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngressTest do
131129
{:post, "/backend-api/files/file_123/uploaded"},
132130
{:post, "/backend-api/transcribe"},
133131
{:get, "/wham/usage"},
134-
{:get, "/backend-api/wham/agent-identities/jwks"},
135132
{:get, "/backend-api/wham/usage"}
136133
] do
137134
conn = conn |> recycle() |> remote_ip({198, 51, 100, 20}) |> dispatch(method, path)
@@ -270,7 +267,6 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngressTest do
270267
"/backend-api/codex/v1/chat/completions",
271268
"/backend-api/codex/images/generations",
272269
"/backend-api/codex/images/edits",
273-
"/backend-api/codex/alpha/search",
274270
"/backend-api/files",
275271
"/backend-api/files/file_123/uploaded"
276272
] do
@@ -284,56 +280,29 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngressTest do
284280
end
285281
end
286282

287-
@tag :feature_control_plane_alpha_search
288-
test "authenticates alpha search before malformed, compressed, or large bodies", %{conn: conn} do
289-
setup_runtime_ingress(%OperationalSettings{max_compressed_body_bytes: 1})
290-
upstream = start_upstream(FakeUpstream.json_response(%{"unexpected" => true}))
291-
_setup = gateway_setup(upstream)
292-
293-
malformed_conn =
294-
conn
295-
|> recycle()
296-
|> put_req_header("content-type", "application/json")
297-
|> post("/backend-api/codex/alpha/search", ~s({"id":))
298-
299-
assert json_response(malformed_conn, 401)["error"]["code"] == "api_key_missing"
300-
301-
compressed_conn =
302-
conn
303-
|> recycle()
304-
|> compressed_post(
305-
"/backend-api/codex/alpha/search",
306-
"gzip",
307-
:zlib.gzip(~s({"id":"search_alpha_fixture"}))
308-
)
309-
310-
assert json_response(compressed_conn, 401)["error"]["code"] == "api_key_missing"
311-
312-
large_conn =
313-
conn
314-
|> recycle()
315-
|> put_req_header("content-type", "application/json")
316-
|> post(
317-
"/backend-api/codex/alpha/search",
318-
~s({"id":"search_alpha_fixture","input":") <>
319-
String.duplicate("a", 10_000) <> ~s("})
320-
)
321-
322-
assert json_response(large_conn, 401)["error"]["code"] == "api_key_missing"
323-
assert FakeUpstream.count(upstream) == 0
324-
assert Repo.aggregate(Request, :count, :id) == 0
325-
assert Repo.aggregate(Attempt, :count, :id) == 0
326-
end
327-
328-
test "authenticates realtime SDP before controller raw body handling", %{conn: conn} do
283+
test "pruned backend helper routes fall through as absent without ingress auth", %{conn: conn} do
329284
setup_runtime_ingress(%OperationalSettings{})
330285

331-
conn =
332-
conn
333-
|> put_req_header("content-type", "application/sdp")
334-
|> post("/backend-api/codex/realtime/calls", "v=0\r\ns=codex-pooler-test\r\n")
286+
for {method, path, content_type, body} <- [
287+
{"GET", "/backend-api/codex/agent-identities/jwks?kid=absent", nil, nil},
288+
{"GET", "/backend-api/wham/agent-identities/jwks?kid=absent", nil, nil},
289+
{"POST", "/backend-api/codex/thread/goal/get", "application/json", "{}"},
290+
{"POST", "/backend-api/codex/thread/goal/set", "application/json", "{}"},
291+
{"POST", "/backend-api/codex/thread/goal/clear", "application/json", "{}"},
292+
{"POST", "/backend-api/codex/analytics-events/events", "application/json", "{}"},
293+
{"POST", "/backend-api/codex/memories/trace_summarize", "application/json", "{}"},
294+
{"POST", "/backend-api/codex/alpha/search", "application/json", "{}"},
295+
{"POST", "/backend-api/codex/realtime/calls", "application/sdp",
296+
"v=0\r\ns=codex-pooler-test\r\n"},
297+
{"POST", "/backend-api/codex/safety/arc", "application/json", "{}"}
298+
] do
299+
conn =
300+
conn
301+
|> recycle()
302+
|> dispatch_absent_backend_helper(method, path, content_type, body)
335303

336-
assert json_response(conn, 401)["error"]["code"] == "api_key_missing"
304+
assert response(conn, 404) =~ "Not Found"
305+
end
337306
end
338307
end
339308

@@ -742,6 +711,15 @@ defmodule CodexPoolerWeb.Plugs.RuntimeIngressTest do
742711
defp dispatch(conn, :get, path), do: get(conn, path)
743712
defp dispatch(conn, :post, path), do: post(conn, path, %{})
744713

714+
defp dispatch_absent_backend_helper(conn, "GET", path, _content_type, _body),
715+
do: get(conn, path)
716+
717+
defp dispatch_absent_backend_helper(conn, "POST", path, content_type, body) do
718+
conn
719+
|> put_req_header("content-type", content_type)
720+
|> post(path, body)
721+
end
722+
745723
defp deflate(body) when is_map(body), do: body |> Jason.encode!() |> :zlib.compress()
746724

747725
defp zstd(body) when is_map(body) do

0 commit comments

Comments
 (0)