Skip to main content

What It Does

The PID Mapper is the core innovation that enables per-process identity. It runs as a sidecar container with shareProcessNamespace: true, giving it visibility into all processes in the pod. When a new process starts in the agent container (e.g., a CrewAI spawns a researcher subprocess), the PID Mapper:
  1. Detects the new process via /proc filesystem monitoring
  2. Matches the process to a role from the process context ConfigMap
  3. Requests a unique SPIFFE SVID for that specific process
  4. Delivers the SVID so the process gets its own cryptographic identity

How It Works

1

Agent forks subprocess

The agent container spawns a new subprocess (e.g., researcher at PID 42).
2

PID Mapper detects new process

The PID Mapper watches /proc and detects the new PID 42. It reads /proc/42/cmdline to identify the process.
3

Match to process context

The PID is matched against the process-context/researcher.json file to determine the SPIFFE role.
4

Fetch SVID from SPIRE

PID Mapper calls FetchX509SVID with selectors hexr:role:researcher + k8s:pod-uid:.... SPIRE returns an X.509 SVID for spiffe://.../researcher.
5

Register SVID for PID

The SVID is registered for PID 42. When the researcher process calls hexr_tool(), Envoy automatically uses this specific SVID for mTLS.

Process Context

The PID Mapper reads from a ConfigMap mounted at /hexr/process-contexts/:

Detection Methods

The PID Mapper uses multiple strategies to match a process to a role:

Why This Matters

Without PID Mapper, all processes in a container share one identity. With it:
PID Mapper requires shareProcessNamespace: true in the pod spec. This is automatically configured by hexr build.

Configuration

The PID Mapper is configured via pod spec, not environment variables: