The pipeline
How Veilgate turns a payload into a routed decision — chunking, the deterministic regex fast-path, speculative Jev evaluation, the priority-ordered policy engine, and re-hydration.
Every redact() call runs a four-stage hybrid pipeline.
- split into spans: sentences, fields, chat turns
- local regex: AWS, GCP, Azure, JWT, SSN, Luhn-valid cards
- matched spans redacted locally, zero network
- batch remaining spans into one call
- parallel Noul + Score detectors → calibrated P-values
- vault maps placeholder → original
- model reply re-hydrated on the way back to the user
Fig. 3.1 Stages of a redact() call. Spans leave stage 01 only if regex could not settle them.
Stage 1 — chunk + fast-path
The payload is split into spans: sentences for text, field values for JSON, message turns for chat. Then a local, zero-latency regex pass flags high-confidence patterns — AWS/GCP/Azure keys, JWTs, SSNs, and Luhn-valid credit cards — and redacts them before any network call.
Because these spans are handled locally, they cost nothing against your Jev budget, and the secret is stripped before it could be sent anywhere — including into Jev’s own input.
Stage 2 — speculative Jev fan-out
Whatever is left (spans that need semantic judgement) is batched into a single
systemOne() call. Jev evaluates all five detectors across all spans in one parallel pass and
returns a calibrated DetectorResult (each value in [0,1]) per span.
Stage 3 — the policy engine
Each span’s detector values are compared against the active policy. When several rules fire for one span, the highest-priority action wins:
BLOCK (3) > REDACT_AND_FORWARD (2) > REROUTE_LOCAL (1) > ALLOW (0)| Action | What happens |
|---|---|
| ALLOW | Span passes through untouched |
| REDACT_AND_FORWARD | Span replaced with a typed placeholder; original stored in the vault |
| REROUTE_LOCAL | Payload diverted to a trusted local model instead of the cloud |
| BLOCK | blocked is set; the caller must refuse to forward |
Stage 4 — re-hydration
Redactions are stored in a reversible vault mapping each placeholder to its original value.
When the model’s reply comes back, rehydrate() restores the originals so the end user sees
real values while the cloud model only ever saw placeholders.
const r = await redact("email Alice Johnson, ssn 123-45-6789");
r.output; // "email [REDACTED_PII_1]" (regex + policy combined)
rehydrate(r.output, r.vault); // "email Alice Johnson, ssn 123-45-6789" (exact round-trip)rehydrate() resolves nested placeholders: when the regex fast-path redacts a substring and
a policy rule then redacts the enclosing span, the stored value itself contains a placeholder.
Re-hydration loops until stable, so round-trips are exact.