IBEX Harness
DocsBenchmarksBlogChangelogRoadmap
GitHub
IBEX Harness

Documentation

OverviewConfigurationAuthenticationAuth cachingDirectivesSessionsRate limitingRequest routingProvider adapters
Proxy›Overview
Proxy

Overview

How the IBEX Harness proxy authenticates, injects context, and forwards to LLM providers.

The proxy is the public HTTP edge for IBEX Harness. Every protected request passes through authentication, agent identity verification, rate limiting, directive resolution, and provider routing before returning a completion.

Late Phase 2 scope

Auth, agent verify, semantic validation, org rate limits, mock/live forwarding, directives, sessions, and optional ClickHouse traces are production-ready for the Go stack. Memory retrieval remains Phase 3. Track status on current state.

Role in the platform

The proxy stays horizontally scalable: identity validation goes through the auth service over gRPC (with an optional bloom+LRU cache), rate-limit and idempotency state live in Redis, and session/directive data use Postgres when POSTGRES_DSN is set.

See Architecture overview for the full system diagram and Request lifecycle for the end-to-end flow.

Mermaid diagram: flowchart LR
+-------------+       +-------------+                           +-----------------+  
|             |       |             |                           |                 |  
| Agent / SDK |-HTTPS>| Proxy :8080 |      ----ValidateToken--->| Auth gRPC :9091 |  
|             |       |             |                           |                 |  
+-------------+       +-------------+                           +-----------------+  
                             |                                           |           
                             |                                           |           
                             |                                           +----------+
                             |                                                      |
                             |                                                      |
                             |                                  +-----------------+ |
                             |                                  |                 | |
                             +-----------RPM-/-cache----------->|      Redis      | |
                             |                                  |                 | |
                             |                                  +-----------------+ |
                             |                                                      |
                             |                                                      |
                             |                                           +----------+
                             |                                           |           
                             |                                           v           
                             |                                  +-----------------+  
                             |                                  |                 |  
                             +--------------------------------->|     Postgres    |  
                             |                                  |                 |  
                             |                                  +-----------------+  
                             |                                                       
                             |                                                       
                             |                                                       
                             |                                                       
                             |                                                       
                             |                                  +-----------------+  
                             |                                  |                 |  
                             +-----------mock-/-live----------->|   LLM provider  |  
                                                                |                 |  
                                                                +-----------------+  

Endpoint surface

RouteAuthPurpose
GET /healthNoLiveness — minimal JSON per ADR-0022
GET /readyNoReadiness — probes auth_grpc and redis when configured
GET /metricsNoPrometheus text exposition
GET /v1/internal/auth-probePAT + agentReturns {org_id, permissions} from validated token
GET /v1/orgs/{org_id}/auth-probePAT + agentSame probe; path org_id must match token org
POST /v1/chat/completionsPAT + agent + ProxyChatCompletionOpenAI-compatible chat — mock 200 or live forward

Organization scope for chat comes from the validated token, not the URL path. Cross-tenant path probes return 403 — see Tenant isolation.

Middleware pipeline

Global middleware wraps every route: metrics → request context → response headers → logging → mux.

Protected chat completions add:

1

Body limit and Content-Type

Rejects oversize payloads and non-JSON POST bodies before auth runs (ADR-0013).

2

Token validation

Calls auth ValidateToken over gRPC (50ms production budget), optionally via auth cache when Redis revocation is healthy (ADR-0011, ADR-0028).

3

Agent verification

Requires X-IBEX-Agent-ID; confirms active agent belongs to token org (ADR-0016).

4

Rate limit

Org-level RPM in Redis; fail-open when Redis is unavailable (ADR-0015).

5

Directive resolve

Loads org directive versions and prepares system-prompt injection (ADR-0031).

6

Normalize, route, forward

Parses OpenAI chat JSON, selects mock or live provider, returns completion or 501 for unknown models.

Auth-probe routes skip body limit and Content-Type checks but still run auth, agent verify, and rate limit.

Failure modes

DependencyBehaviorHTTP signal
Auth gRPC down / timeoutFail closed on token validation503 SERVICE_DEGRADED
Auth gRPC down on agent verifyFail closed503 AUTH_UNAVAILABLE
Redis downRate limit skipped (fail-open); auth cache not wrappedRequest proceeds; monitor /ready
Unknown modelNo adapter for that model id501 PROVIDER_NOT_CONFIGURED
ClickHouse downTraces dropChat still 200

Full threat-model context: Security overview and Authentication.

Response headers

Every response includes correlation headers (names configurable via env):

  • X-Request-ID — UUID v7 when generated; valid inbound v4/v7 UUIDs are honoured (ADR-0017)
  • X-Trace-ID — OpenTelemetry trace correlation
  • X-Response-Time — server-side duration

Protected routes with rate limiting enabled also emit X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset. 429 responses add Retry-After.

Verify locally

1

Boot dependencies

make compose-dev-up && make db-migrate && make db-seed

2

Start auth then proxy

Auth must listen on gRPC 9091 before the proxy starts. See Configuration.

3

Health check

curl -s http://localhost:8080/health — expect HTTP 200.

4

Smoke test

make dev-smoke exercises probes, auth failures, and mock chat success.

Related guides

  • Authentication — headers, error codes, probe examples
  • Auth caching — bloom+LRU and revocation gate
  • Directives / Sessions — platform features
  • Configuration — env vars and readiness dependencies
  • Rate limiting — RPM budgets and Redis keys
  • Provider adapters — mock vs live

Was this page helpful?

Edit on GitHub

Last updated on

PreviousRequest lifecycleNextConfiguration

On this page

  • Role in the platform
  • Endpoint surface
  • Middleware pipeline
  • Failure modes
  • Response headers
  • Verify locally
  • Related guides
0%