phase 1 core platform

Milestone 1.2.2: Proxy Request Normalization — complete.

Milestone 1.2.2: Proxy Request Normalization

Status: Complete
Goal: 1.2 Proxy platform integration
Phase: 1 — Core Platform

Summary

Parse OpenAI-compatible POST /v1/chat/completions bodies into internal/llm types after auth. Malformed JSON → 400 INVALID_JSON. Valid parse → metadata-only log → 501 stub. No provider HTTP. Semantic validation and body limits → 1.2.3.

Branch

feature/m1-2-2-proxy-request-normalization

PR title

feat(proxy): request normalization (m1.2.2)

Prerequisites

  • 1.2.1 merged (ADR-0011, auth middleware)
  • make proto-gen (unchanged for this milestone)

Tasks

  • ADR-0012
  • services/proxy/internal/llm/ChatCompletionRequest, ParseChatCompletionRequest, context helpers
  • Chat handler reads body after auth; 400 / 501 per ADR-0012
  • Error constants: INVALID_JSON, PROVIDER_NOT_CONFIGURED in internal/errors/
  • Unit tests: parser + httptest handler
  • Integration: valid JSON → 501; malformed → 400
  • Contributor execution materials prepared

Files affected

PathAction
docs/adr/ADR-0012-proxy-request-normalization.mdAdd
services/proxy/internal/llm/Add
services/proxy/internal/errors/envelope.goExtend codes
services/proxy/internal/http/router.goChat handler parse
services/proxy/internal/http/chat_handler_test.goAdd
services/proxy/proxy_auth_integration_test.goExtend chat cases
services/proxy/README.mdParse + curl examples
docs/API_DOCUMENTATION.mdPath alias + 501 code
docs/TESTING_STRATEGY.md§6.2.2

Testing requirements

bash
go test ./services/proxy/...
go test -tags=integration ./services/proxy/...

Definition of done

  • Valid authenticated JSON → parsed + 501 PROVIDER_NOT_CONFIGURED
  • Malformed JSON → 400 INVALID_JSON with stable envelope
  • Logs contain model/message_count/stream/org_id only — never content
  • No outbound provider HTTP
  • proxy-auth-smoke / go-services (proxy) green

Deferred (1.2.3)

  • Body size limit, Content-Type 415, 413
  • Required model, role enum, message bounds, field_errors
  • X-IBEX-Agent-ID enforcement
  • Response header middleware

Risks

RiskMitigation
Unbounded body until 1.2.3Document in ADR-0012; ship 1.2.3 next
Logging message contentCode review + structured log fields only
Path /v1 vs /proxy/v1ADR-0012 + API doc gateway alias
Edit on GitHub

Last updated on

On this page

0%