Skip to content

feat: add gateway middleware examples#22

Merged
rlippmann merged 2 commits into
mainfrom
codex/gateway-middleware
Jun 29, 2026
Merged

feat: add gateway middleware examples#22
rlippmann merged 2 commits into
mainfrom
codex/gateway-middleware

Conversation

@rlippmann

Copy link
Copy Markdown
Owner

Summary

Adds generic Python and TypeScript gateway-middleware examples.

The examples demonstrate that a host-owned gateway can enforce Context Compiler authoritative state before requests reach downstream handlers. The host owns routing and forwarding decisions, while Context Compiler owns the policy state that determines whether requests are allowed, blocked, or routed differently.

Why

Gateway middleware is a distinct enforcement point.

These examples show that routing and access decisions occur before downstream processing. Requests are evaluated against authoritative Context Compiler state at the gateway boundary rather than relying on prompt instructions, model compliance, or downstream services.

The examples use a customer-support routing domain to demonstrate observable routing behavior changes as authoritative state changes.

Example metadata

  • Enforcement point: gateway middleware
  • Domain: customer support routing
  • Technology/runtime: generic Python, generic TypeScript
  • Example type: minimal example
  • Does this use directive drafter? should normally be no: no
  • Does this derive state from model output? must be no for primary examples: no

Checklist

  • Repository scaffolding / governance change
  • One primary enforcement point
  • Explicit authoritative state
  • No model-derived state mutation
  • Adversarial stub or equivalent test
  • Observable runtime behavior change
  • Domain vocabulary is natural
  • Framework is secondary to the enforcement point
  • Docs updated
  • Tests/smoke checks added where practical

Notes

Both implementations demonstrate:

  • billing-support requests are forwarded only when authorized
  • billing-support requests are blocked when state is absent
  • prohibited billing-support access is blocked
  • non-billing requests follow the documented general-support path
  • adversarial requests do not bypass gateway enforcement
  • downstream handlers are not invoked when requests are blocked
  • contradictory directives produce clarification behavior rather than silent overwrite

The examples intentionally perform enforcement at the gateway boundary before any downstream handler would be called. This keeps the example focused on gateway middleware as a host-side enforcement point rather than downstream application behavior.

TypeScript and Python validation scripts were updated so the new examples participate in repository validation.

Milestone

This PR completes the generic enforcement-point example matrix:

  • Schema selection
  • Checkpoint continuation
  • Execution authorization
  • Retrieval filtering
  • Tool gating
  • Prompt construction
  • Gateway middleware

@rlippmann
rlippmann merged commit 495d2f7 into main Jun 29, 2026
5 checks passed
@rlippmann
rlippmann deleted the codex/gateway-middleware branch June 29, 2026 06:41
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