Repository navigation
Description
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 thepolicyfilter by itself, so no newregister_filters!line is necessary. - Not a direct replacement. The Praxis
policyfilter 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.tomlsetspraxis-proxytodefault-features = falseand turns on onlypingora,admin-apiandforward-proxy.- The upstream defaults are
pingora,config-reload,admin-apiandpolicy-builtins. So the gateway also has noconfig-reload. praxis/Cargo.lockhas nopraxis-policyentry.- 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.
OnRequestandOnResponserun the hookscmf.tool_pre_invoke,cmf.tool_post_invoke,cmf.llm_inputandcmf.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, andcpex/-prefixed custom keys. -
Identity. Cortex reads a principal token from
principal.token_fileand sends it asx-user-token. It gets a SPIFFE JWT-SVID and sends it asx-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
pctxsecurity 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_egresstool 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(onlyx-praxis-*,x-ext-agent-*orx-ext-protocol-*),trusted_proxiesandmax_buffer_bytes(10 MiB) (config.rs:24-28). - Inference. It routes
llm:on the top-levelmodel. CEL, OPA and Cedar see the parsed body asllm.request(filter.rs:110-125). - MCP. It reads only the
mcp.methodandmcp.namemetadata, and only fortools/call,prompts/getandresources/read(common_message_format.rs:1-35). Thepraxis-aiclassifier sets that metadata. Cortex'sparsedoes 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 denycustom.llm.streamwhen 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 (denyWithcan change it). An MCP deny gets HTTP 200 with a JSON-RPC error. Every denial setsX-Policy-Violation: <code>(error.rs). - Identity. It reads JWTs from
Authorization,X-Agent-TokenandX-Workload-Token, with presets for Keycloak, Auth0, Cognito and IBM Verify. It maps a JWT-SVIDspiffe_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 theenvsecret provider is registered. - Observe mode. None in 0.6.0. A CEL, OPA or Cedar deny runs
on_denyand then always denies (apl-core evaluator.rs:412-415). Soobserve_codesis still necessary. - Hooks for a host.
register_policy_plugin_factory(kind, ...)is public (lib.rs:128,host_plugins.rs:51-66), and it supportsAuditandFireAndForgetmodes. 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-jwtpulls inaws-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) andpolicy-celare the large additions (inferred: several MB each).- Nobody has measured the binary size. For comparison, the
main-latestgateway 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.historyis nowVec<Message>, in CMF shape.&and|behave differently when an operand cannot be ordered.- New facts
llm.input.*,llm.model.*andllm.output.*. The oldllm.model_idkeys 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_onlyother than true,session.enabled: false, and non-loopback addresses. The spec lists the K8s shapes as a non-goal. gateway.yamlis generated.gatewayYAML(cmd/cortex/gateway.go:68-101) writes it again at each supervisor start. It has no user pass-through. The chain isip_acl→cortex_attribution→cortex_observe→access_log→router→load_balancer.- No hot reload.
config-reloadis off, and thepraxis:block needs a restart. - Recorded decisions conflict with this plan:
- Tracker: Move the laptop data plane to Praxis when the upstream gaps close #1714 D0: "Build the hairpin, for processing and recording in Praxis (praxis mode), not for new checks."
- The spec: "This design moves the processing, not the policy."
- The
--praxisdefault gate stays. Praxis mode stays opt-in untilcortex-gatewayis 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)
- Kubernetes scope: laptop only. Deprecate and later remove the laptop
cortex-cpexbuild andinstall.sh --cpex. The Go plugin, theauthbridge-cpeximage andgo-ci-cpexstay for Kubernetes. - A2A (G1) and SSE (G3): accept and document.
- Cortex-only features (G5, G7, G8): port none of them. This covers
observe_codes, the principaltoken_file, bypass/strict hosts, synthetic egress and delegation host binding. We add each one later, when a real use case needs it. - 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-celandconfig-reload. With all ofpolicy-builtinsit is 38.0 MiB. scripts/build-gateway.shneeds no change.aws-lc-sysbuilds with thecmakethat the script already installs.- The gateway then links three crypto libraries: OpenSSL, ring and aws-lc.
- The static musl linux/arm64 binary is 18.5 MiB today and 28.6 MiB with
- Runtime:
- The
policyfilter works on the hop. It must run aftercortex_observe. - MCP works when
cortex_observesetsmcp.methodandmcp.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.
- The
- Policy files:
- The
hr-cpexfixture and the doc examples use only plain PPE constructs. - On 0.6.0 the fixture fails only because CIBA now needs
store:. when/dotaints a session without a deny.- Taints are held in memory, and they are lost at each restart and each reload.
- The
- 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_observerecords 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
- Run-time memory and latency of the policy filter.
- A live call of the audit sink on a deny. PPE 3/5: Record PPE policy decisions in the gateway's rows #1799 tests this first.
- linux/amd64 musl, and the
policy-jwt-openssl-fipsbackend.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
huang195 commentedon Nov 17, 2026
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:
cortex-cpex_*copies.