Skip to content

test(pixel): pin the runtime gateway admission and SSRF-guard contract - #5690

Open
tang-vu wants to merge 1 commit into
Osmantic:public-betafrom
tang-vu:test/beta-gateway-policy-20260917
Open

tang-vu wants to merge 1 commit into
Osmantic:public-betafrom
tang-vu:test/beta-gateway-policy-20260917

Conversation

@tang-vu

@tang-vu tang-vu commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds ods/tests/pixel_inference/test_runtime_gateway_policy.py — boundary-policy coverage for ods/bin/pixel_provider/runtime_gateway.py, the turn-scoped OpenAI transport every Pixel generation call crosses. test_provider_runtime.py already covers failover/streaming mechanics; this pins the admission and SSRF-guard surface it did not.

Why this matters

This is the last process boundary before a turn leaves the device: request validation decides what may reach a provider, pinned_target is the DNS-rebinding/SSRF guard, and the session policy (single-flight, terminal-on-failure, call limit, cooldown) is what prevents SDK retries from multiplying provider attempts.

What is tested (56 cases)

  • validate_request — envelope allowlist, model=='ods/pixel', non-empty message list, bool stream, n==1, mutually exclusive max_tokens/max_completion_tokens; all six message roles; external-media gate — only data:image/{png,jpeg,webp};base64 URLs pass, every remote/foreign-scheme URL raises external-media-not-allowed; tools must be type:'function'; chat_template_kwargs limited to {enable_thinking: bool}.
  • pinned_target — loopback HTTP allowed with X-ODS-Pixel-Route-Hop/Host headers; link-local, private-LAN-over-http, unspecified, v4-mapped public, v6 link-local, and v6 multicast all raise unsafe-provider-address; HTTPS public allowed with sni_hostname extension; IPv6 loopback bracketed correctly.
  • Endpoint policy — missing/wrong Authorization → 401; X-ODS-Pixel-Route-Hop → 409 provider-route-cycle; transient upstream exhaustion → provider-attempts-exhausted then provider-session-stopped on the next call; non-JSON / wrong-shape upstream bodies → invalid-provider-response; non-SSE content-type on stream:trueinvalid-provider-stream; missing data: [DONE]provider-stream-interrupted and a terminal session (no client retry can splice a backup); oversized request body rejected; response headers carry provider id, revision, request id, Cache-Control: no-store.

Overlap check

Searched runtime_gateway, "runtime gateway". #5647 (open, roshangupta00750) adds stream-tail chunk-boundary [DONE] detection + tests in test_provider_runtime.py — different file, compatible semantics (my no-[DONE] → interrupted assertion holds under both). #5607/#5608 are dashboard-api/pixel-edge stream handling. My own #5659/#5661/#5663/#5665/#5668/#5669/#5671/#5674/#5675/#5676/#5677/#5681/#5686/#5687/#5688 touch other modules.

Validation

$ pytest ods/tests/pixel_inference/test_runtime_gateway_policy.py -x -q
56 passed in 4.39s

Test-only change; revert is a single file deletion.

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.

1 participant