Repository navigation
Conversation
Run the Presidio PII analyzer inside the gateway enclave, so the TEE gateway can serve keys with PII masking on without sending prompt text out of the enclave, and give it the egress, routing and metrics the regular gateway has. - nexus-enclave-init: a small supervisor that is the enclave entrypoint. It reads apps/gateway/enclave/services.yaml (Compose-like), brings up loopback, starts Presidio as uid 1001 and then the gateway once Presidio is healthy, restarts a service that exits (clearing its process group first), reaps orphans, and stops everything in reverse order. The gateway launches nothing itself. Services get a minimal environment unless they opt in. - Dockerfile.enclave: the runtime image is Presidio 2.2.362 pinned by digest with the gateway and init on top. Two --no-cache builds still produce the same image ID and the same PCR0/1/2. - PII: a cross-request analyzer cache (LRU keyed by SHA-256 of mode, language and text; holds no text). On a 25-turn agent conversation it cuts analyzer calls from 1,650 to 126 and masking time per turn from 578 ms to 40 ms, with identical output. In Nitro builds the analyzer must be on loopback and is reached through a loopback-only transport. - Egress: measured routes for llm.dappnode.net (DappNode Qwen) and api.frankfurter.dev, so the enclave serves every advertised provider and shows live USD prices. The FX client calls api.frankfurter.dev directly; api.frankfurter.app now only redirects there. - Metrics: Nitro builds serve /metrics on vsock 9090 for the parent to forward to Prometheus, so Grafana sees both gateways under one job. The manifest schema stays at 4 (the webapp verifier checks it); the new routes change the manifest content, as any route change does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The enclave serves guest chat like the regular gateway, so it takes the same output limit from the operator instead of relying on the code default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plain SHA-256 of a short secret pasted into a prompt could be brute-forced from a memory dump. Keyed digests under a random per-process key cannot be matched against guessed texts. Flagged by CodeQL (go/weak-sensitive-data-hashing). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The TEE gateway advertises the same 18 models as the regular gateway but cannot serve them all:
nexus/autoanddappnode/qwen3.8-27breturn 500, keys with PII masking on are silently not masked (PII_FILTER_ENABLED=falsein the enclave), USD prices use a fixed fallback rate, and the enclave's metrics are unreachable. This makes the TEE gateway able to serve every request the regular gateway serves, so the two can run side by side. The regular gateway is unaffected until its own image pin is bumped.What changes
nexus-enclave-init(apps/gateway/cmd/nexus-enclave-init): the enclave entrypoint. It reads a Compose-like file,apps/gateway/enclave/services.yaml, brings up loopback, starts Presidio as uid 1001, starts the gateway once Presidio is healthy, restarts a service that exits (clearing its process group first so a leftover worker cannot hold the port), reaps orphans, and stops everything in reverse order. The gateway itself launches nothing. Services get a minimal environment unless they setinherit_env(Presidio's image setsPORT=3000, which the gateway also reads).Dockerfile.enclave: the runtime image ispresidio-analyzer:2.2.362pinned by digest, with the gateway and init added. Same builder, same reproducibility rules.PRESIDIO_ANALYZER_URLthat is nothttp://127.0.0.1:<port>and reach the analyzer through a loopback-only transport, so prompt text never leaves the enclave for masking.PII_CACHE_ENTRIES, default 20,000). It holds hashes and entity offsets, never text. Chat clients resend the whole conversation every turn, so without it each turn re-analyzes all earlier messages.llm.dappnode.net(DappNode Qwen, 8454) andapi.frankfurter.dev(FX, 8455). The FX client now callsapi.frankfurter.dev/v1/latestdirectly;api.frankfurter.apponly redirects there./metricson vsock 9090 for the parent to forward to Prometheus. Same metric names, so the existing Grafana dashboard sums both gateways underjob="nexus-gateway".The manifest schema stays at 4, which the webapp verifier checks.
require_attested_inferencebehaviour is unchanged: attested requests still skip PII masking and refuse routers.Evidence (local, 2 CPUs and 4 GB like the enclave)
--no-cacheamd64 builds withrewrite-timestamp: identical image ID and identical PCR0, PCR1, PCR2go test ./...passes. With-tags nitro_enclaveon Linux, the same 8 tests fail as onv0.1.73(they use local test servers the enclave build routes over vsock); no new failuresDeploying (needs the infrastructure PR)
The enclave needs more memory and new parent proxies, so this must ship with the matching infrastructure change: enclave memory 4096 MiB and allocator resize, parent proxies for router/typesafe/minimax/dappnode/frankfurter, a router TLS listener on premium-1, the metrics forwarder, and
PII_FILTER_ENABLED/provider keys in the enclave bundle. Release this first, then the infra bump, then the enclave cutover.Open
🤖 Generated with Claude Code