Skip to content

Replace the Go CPEX plugin with PPE in cortex-gateway under --praxis #1785

Closed
5 of 5 issues completed
Closed

Description

@huang195

Goal

Deprecate the Go CPEX plugin (core/plugins/cpex/, a cgo FFI to contextforge-org/cpex). In its place, run the Praxis Policy Engine (PPE) inside cortex-gateway, under the --praxis flag.

This issue records the findings of a deep dive on 2026-11-11, which looked at upstream main at b1a87e38. Nothing is built or tested yet. Each line says where its evidence comes from. Lines marked (inferred) do not have direct evidence.

Priority

This issue must be done before the next stage of the Praxis work (phase B, D or C, #1726-#1728) starts (decided 2026-11-11). It is a sub-issue of #1714, and the tracker's Plan, Work and Gates sections name it.

Summary

  • Feasible. To turn PPE on in cortex-gateway, change the Cargo features. Praxis registers the policy filter by itself, so no new register_filters! line is necessary.
  • Not a direct replacement. The Praxis policy filter does fewer things than the Go plugin. It has no A2A support, it does not apply response policy to SSE streams, it does not rewrite bodies, and it gives no decision to Cortex.
  • Four decisions come first (see "Decisions" below). The largest one: praxis mode is laptop-only, but CPEX also ships as the K8s image authbridge-cpex.

Background: PPE and CPEX are the same engine

Component Pins PPE Evidence
CPEX FFI v0.3.1 (what Cortex links today) praxis-policy =0.5.0 contextforge-org/cpex Cargo.toml:85 at tag v0.3.1. cmd/cortex-cpex/CPEX_FFI_VERSION
praxis-proxy-filter 0.8.0 (what cortex-gateway uses) praxis-policy 0.6.0, optional praxis-proxy-filter-0.8.0/Cargo.toml:175

PPE lives in praxis-proxy/policy. CPEX is a host and plugin framework around PPE, with FFI, Python and Go bindings and some plugins of its own (for example delegator-biscuit).

Today cortex-gateway does not contain PPE:

  • praxis/server/Cargo.toml sets praxis-proxy to default-features = false and turns on only pingora, admin-api and forward-proxy.
  • The upstream defaults are pingora, config-reload, admin-api and policy-builtins. So the gateway also has no config-reload.
  • praxis/Cargo.lock has no praxis-policy entry.
  • In praxis mode the outbound pipeline is off, so the Go CPEX plugin does not run either. See Praxis mode: an outbound policy plugin fails open with only a Warn #1768 (it fails open, with only a Warn line).

What the Go CPEX plugin does today

Total size: 5,548 lines of source and 7,331 lines of tests, in 51 files.

  • Phases. OnRequest and OnResponse run the hooks cmf.tool_pre_invoke, cmf.tool_post_invoke, cmf.llm_input and cmf.llm_output (hooks.go:16-29). The chain stops at the first deny (plugin.go:444-456).

  • CMF mapping (cmf_parts.go:145-175). The order is:

    • synthetic egress;
    • MCP (tool call, prompt, resource, tool result);
    • inference, as llm:<model>;
    • A2A;
    • the raw body.

    An entity with no name becomes http/* or gets no meta (cmf_body.go:104-128).

  • Extensions (manager_cpex.go:803-978): the subject, the workload (SPIFFE), LLM and completion data, conversation history, A2A session and task ids, delegation, request and trace ids, request headers with secrets removed, and cpex/-prefixed custom keys.

  • Identity. Cortex reads a principal token from principal.token_file and sends it as x-user-token. It gets a SPIFFE JWT-SVID and sends it as x-workload-token (principal.go, workload.go).

  • Delegation. A credential that delegate() mints goes into a request header only when two checks pass: the header is in an allowlist, and the credential is bound to the destination host (globs, IPs, CIDRs; delegation_hosts.go).

  • Elicitation. An MCP client gets JSON-RPC error -32120 or -32121. Other clients get a 403 with an id. The client retries with X-Policy-Elicitation-Id (elicitation.go).

  • Write-back. The plugin writes back header diffs, and it rewrites MCP, inference and A2A bodies by format (cmf_mcp_mod.go, cmf_inference.go, cmf_a2a.go). A rewrite that it cannot apply fails closed.

  • Labels and taint. Labels go into pctx security labels. Taint is keyed by the session id, which comes from a header or from the trusted listener session (cmf_body.go:34-85).

  • observe_codes. A listed deny is recorded and the request continues. Cortex invented this because "PPE 0.5.0 has no other conditional taint" (config.go:161-169, observe_policy.go).

  • Cortex-only features:

    • bypass_hosts, bypass_paths, strict_hosts, private_destinations;
    • synthetic http_egress tool calls;
    • refusals that happen before CPEX sees the request: unnamed_entity, ambiguous_request, unparseable_request;
    • fail_open;
    • a fail-closed result when it cannot inspect an SSE response.

Where it ships

Shape Artifact Evidence
Laptop cortex-cpex_<v>_<os>_<arch> tarball, install.sh --cpex. agentop update and doctor keep the cpex build release-binaries.yaml:205-302, install.sh:417-433
K8s proxy-sidecar authbridge-cpex image (Alpine/musl). The operator selects images by name cmd/cortex-cpex/Dockerfile, build.yaml:71-161
envoy-sidecar Not supported scripts/profile-tags/profiles.go:83

These CI and release jobs use the plugin: go-ci-cpex (ci.yaml:120-197), the release job build-cpex (it blocks publish), and the Linux release smoke test --cpex. The demo is rossoctl/cortex-demos/hr-cpex/. The test fixture is core/plugins/cpex/testdata/hr-cpex/.

What the Praxis policy filter does (PPE 0.6.0)

Source: praxis-proxy-filter-0.8.0/src/builtins/http/security/policy/.

  • Config. The config is flat YAML: config_path, body_access, require_protocol_metadata (default true), llm: {...}, context_headers (only x-praxis-*, x-ext-agent-* or x-ext-protocol-*), trusted_proxies and max_buffer_bytes (10 MiB) (config.rs:24-28).
  • Inference. It routes llm: on the top-level model. CEL, OPA and Cedar see the parsed body as llm.request (filter.rs:110-125).
  • MCP. It reads only the mcp.method and mcp.name metadata, and only for tools/call, prompts/get and resources/read (common_message_format.rs:1-35). The praxis-ai classifier sets that metadata. Cortex's parse does not set it.
  • A2A. Not supported. No source file in the policy filter names A2A (checked).
  • SSE. A streamed inference response skips the response-phase policy (filter.rs:1703-1714, checked). Upstream tells you to deny custom.llm.stream when you need response rules (filter.rs:733).
  • Body rewrite. Redact does not rewrite inference bodies.
  • Denials. An identity failure gets 401 with WWW-Authenticate. An HTTP or LLM deny gets 403 (denyWith can change it). An MCP deny gets HTTP 200 with a JSON-RPC error. Every denial sets X-Policy-Violation: <code> (error.rs).
  • Identity. It reads JWTs from Authorization, X-Agent-Token and X-Workload-Token, with presets for Keycloak, Auth0, Cognito and IBM Verify. It maps a JWT-SVID spiffe_id. It also accepts API keys and DPoP. It has no X.509-SVID input.
  • Delegation. RFC 8693 delegate(...) with audience-scoped tokens, strict by default since 0.5.0. It also has a Vault delegator and CIBA. Only the env secret provider is registered.
  • Observe mode. None in 0.6.0. A CEL, OPA or Cedar deny runs on_deny and then always denies (apl-core evaluator.rs:412-415). So observe_codes is still necessary.
  • Hooks for a host. register_policy_plugin_factory(kind, ...) is public (lib.rs:128, host_plugins.rs:51-66), and it supports Audit and FireAndForget modes. The filter does not give its decision or its taints to later filters or to the access log. A Cortex audit plugin is the way to get them.

Feature flags and dependency cost

Feature set Crates (cargo tree, normal + build)
cortex-gateway today 256
+ policy-engine, policy-crypto-default, policy-jwt, policy-cel 295
+ policy-builtins (upstream default) 428
  • policy-jwt pulls in aws-lc-rs / aws-lc-sys, a C library built with cmake, into the static musl build (scripts/build-gateway.sh). This is a risk.
  • policy-cedar, policy-opa (regorus) and policy-cel are the large additions (inferred: several MB each).
  • Nobody has measured the binary size. For comparison, the main-latest gateway tarballs are about 9 MB compressed.

Policy file changes from PPE 0.5 to 0.6

  • CIBA config refuses unknown fields and needs store.
  • ConversationContext.history is now Vec<Message>, in CMF shape.
  • & and | behave differently when an operand cannot be ordered.
  • New facts llm.input.*, llm.model.* and llm.output.*. The old llm.model_id keys stay as aliases.
  • Policies that use plugins only CPEX has (for example delegator-biscuit) will not load.

Current praxis mode constraints

  • Laptop only. validatePraxis (core/config/validate.go:83-101) refuses these: mtls, bind_loopback_only other than true, session.enabled: false, and non-loopback addresses. The spec lists the K8s shapes as a non-goal.
  • gateway.yaml is generated. gatewayYAML (cmd/cortex/gateway.go:68-101) writes it again at each supervisor start. It has no user pass-through. The chain is ip_acl → cortex_attribution → cortex_observe → access_log → router → load_balancer.
  • No hot reload. config-reload is off, and the praxis: block needs a restart.
  • Recorded decisions conflict with this plan:
  • The --praxis default gate stays. Praxis mode stays opt-in until cortex-gateway is the only proxy. So PPE would be available only to users who opt in.

Gap table

# Area Go CPEX plugin PPE in cortex-gateway Possible fix
G1 A2A Mapped, rewritten, ids sent Not supported Ask upstream, or accept the loss
G2 MCP Full mapping, incl. tool results Needs mcp.method and mcp.name. 3 methods only parse sets the metadata before policy
G3 SSE responses Fails closed Response policy skipped Deny custom.llm.stream in the policy, or accept
G4 Body rewrite MCP, inference, A2A No inference rewrite Accept, or ask upstream
G5 Observe mode observe_codes None Port observe_codes, or use an on_allow taint (untested)
G6 Recording Decision and labels in Cortex rows Not given to filters or to the access log A Cortex audit plugin through register_policy_plugin_factory
G7 Identity injection Principal token_file, SPIFFE JWT-SVID Reads headers only A Cortex filter injects X-Agent-Token / X-Workload-Token
G8 Cortex-only features Synthetic egress, bypass/strict hosts, pre-CPEX refusals, delegation host binding None Port each one or drop it
G9 Config and reload Cortex hot reload Generated gateway.yaml, no reload A praxis.policy block. Turn on config-reload (effect on the policy file not checked)
G10 Kubernetes authbridge-cpex sidecar Laptop only See decision 1

Decisions (Hai, 2026-11-11)

  1. Kubernetes scope: laptop only. Deprecate and later remove the laptop cortex-cpex build and install.sh --cpex. The Go plugin, the authbridge-cpex image and go-ci-cpex stay for Kubernetes.
  2. A2A (G1) and SSE (G3): accept and document.
  3. Cortex-only features (G5, G7, G8): port none of them. This covers observe_codes, the principal token_file, bypass/strict hosts, synthetic egress and delegation host binding. We add each one later, when a real use case needs it.
  4. Tracker: Move the laptop data plane to Praxis when the upstream gaps close #1714 D0: still open.

Grounding (spikes on 2026-11-11)

These results replace the guesses in the sections above.

  • Build:
    • The static musl linux/arm64 binary is 18.5 MiB today and 28.6 MiB with policy-engine, policy-crypto-default, policy-jwt, policy-cel and config-reload. With all of policy-builtins it is 38.0 MiB.
    • scripts/build-gateway.sh needs no change. aws-lc-sys builds with the cmake that the script already installs.
    • The gateway then links three crypto libraries: OpenSSL, ring and aws-lc.
  • Runtime:
    • The policy filter works on the hop. It must run after cortex_observe.
    • MCP works when cortex_observe sets mcp.method and mcp.name. Without them, every MCP request gets HTTP 500.
    • A denial reaches the row only as gateway_refused, with no code. A PPE audit sink sees each allow and each deny, with the code.
  • Policy files:
    • The hr-cpex fixture and the doc examples use only plain PPE constructs.
    • On 0.6.0 the fixture fails only because CIBA now needs store:.
    • when/do taints a session without a deny.
    • Taints are held in memory, and they are lost at each restart and each reload.
  • Identity: JWT identity works. On a laptop it must use a header other than Authorization. PPE does not remove that header before the origin.
  • Reload: with config-reload, an edit to the policy file reloads it, and a bad edit keeps the old policy.
  • Operator: the operator repo has no reference to cpex.
  • Bug found: with body_access: read_write, cortex_observe records an SSE completion two times. PPE 1/5: Build PPE into cortex-gateway and add praxis.policy.config_path #1797 does not expose that option.

Sub-issues (run each with /sdd-fast)

Issue Work Depends on
#1797 PPE 1/5: build PPE into cortex-gateway, add praxis.policy.config_path —
#1798 PPE 2/5: MCP metadata for the policy filter #1797
#1799 PPE 3/5: record policy decisions in rows #1797, #1798
#1800 PPE 4/5: docs, migration guide, deprecation of the laptop CPEX build #1797-#1799
#1801 PPE 5/5: remove the laptop CPEX build #1800 and the deprecation window (Hai starts it)

Also found

main-latest lost its darwin/arm64 cortex-gateway tarball on run 42951822649 (b1a87e38, 2026-11-11). Cause: a network failure on the macOS runner. Cargo could not download wasm-bindgen-macro-support (curl failed … [16] Error in the HTTP2 framing layer). The four runs before it passed this leg. build-gateway is optional by design (continue-on-error: true), and the main-latest prune then deletes the asset of the leg that failed (release-binaries.yaml:18-26). The next push to main restores it. This is not a part of this issue.

Not checked

Related: #1714, #1768, #1727

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    enhancement
    on Nov 11, 2026
  2. self-assigned this
    on Nov 11, 2026
  3. added
    laptop
    rust
    on Nov 11, 2026
  4. huang195 commented on Nov 17, 2026

    @huang195
    MemberAuthor

    All five sub-issues are done: #1797 (PR #1842), #1798 (PR #1858), #1799 (PR #1863), #1800 (PR #1866) and #1801 (PR #1868).

    Two steps from #1801 remain for the next release:

    • Make sure the release notes have the cpex line, and the assets have the three cortex-cpex_* copies.
    • Tell the CPEX contributor that the laptop build is gone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementlaptoprust

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions