- Expanso + Jev
- Example 08 of 10
A data quality firewall in front of the warehouse.
Every row gets a quality score and a conformance judgment — garbage quarantines before it can poison the warehouse.
Where the record goes
Every stage on the left is Expanso, and it is deterministic. The record crosses to Jev once, for the one question a rule cannot answer, and comes straight back. Line numbers link to the YAML below.
POST /rows- Receive
- Shape
- Ask Jev
- Gate
- Route
qualityconformant
quarantinewarehouse
- Receivelines 11 to 16
An HTTP server input accepts rows on
POST /rows. - Shapelines 17 to 26
Parses the POST body if it arrived as a string, then stamps
received_at. It applies the same fixed rules every time, with no model involved; the timestamp is the one value that differs. - Ask Jevlines 27 to 72
Expanso packs the whole record and the typed questions into one request. Jev answers. If the call fails, a
catchsubstitutes empty answers markedjev-unavailable, and the pipeline keeps going.qualityscoreconformantnoul
- Gatelines 73 to 84
Fixed thresholds over Jev’s answers choose quarantine or warehouse.
- Routelines 85 to 102
A
switchoutput writes quarantined and accepted rows to separate files.
What Jev is asked
Jev, judgmentThe pipeline sends the record with 2 typed questions. Jev answers each one with a value the pipeline can compare against a number.
qualityscoreRate the data quality of this row for analytics use.
conformantnoulDoes this row conform to the expected schema and plausible value ranges?
What Expanso does with the answers
Expanso, deterministicFixed thresholds, checked in order. The first rule that matches sets the route. These are the expressions in the pipeline, not a summary of them.
- $quality < 1 || $conformant < 0.3quarantine · Unusable, or clearly off-schema.
- elsewarehouse · Good enough to load.
If Jev is unreachable: quarantine
With no answers, quality defaults to 0, which is under 1, so every row quarantines. The example fails closed.
The pipeline
This is the example's own pipeline file, unmodified. Violet marks the lines Expanso runs on its own. Orange marks the handoff, and the darker orange band is the HTTP call to Jev itself.
name: jev-data-quality
type: pipeline
description: Data quality firewall with Jev — warehouse-bound rows are judged for quality and schema conformance at the edge. Bad rows quarantine with reasons attached; good rows flow through.
namespace: production
labels:
category: data-transformation
pattern: ai-decision
model: jev
config:
input:
http_server:
address: "0.0.0.0:8080"
path: /rows
allowed_verbs: ["POST"]
pipeline:
processors:
- mapping: |
# http_server already parses JSON bodies; only parse raw strings
root = if this.type() == "string" { this.parse_json() } else { this }
- mapping: |
root = this
root.received_at = now()
# ── Ask Jev ──
- mutation: |
meta jev_start = timestamp_unix_milli()
- branch:
request_map: |
root = {
"state": this.string(),
"model": "jev-latest",
"questions": {
"quality": {
"type": "score",
"instructions": "Rate the data quality of this row for analytics use.",
"criteria": [
"Corrupt or unusable",
"Poor, major issues",
"Acceptable with caveats",
"Good, minor issues only",
"Pristine"
]
},
"conformant": {
"type": "noul",
"instructions": "Does this row conform to the expected schema and plausible value ranges? Expected: order_id (string), customer_id (string), amount (positive number), currency (3-letter code), ts (ISO timestamp)."
}
}
}
processors:
- http:
url: "${JEV_API_URL:https://api.typesafe.ai/v1/systemone}"
verb: POST
headers:
Content-Type: application/json
Authorization: "Bearer ${TYPESAFE_API_KEY}"
timeout: 2s
retries: 1
- catch:
- mapping: |
root = {"answers": {}, "model": "jev-unavailable"}
result_map: |
root.jev = {
"answers": this.answers,
"model": this.model.or("jev-latest"),
"ms": timestamp_unix_milli() - metadata("jev_start")
}
# ── Confidence-gated cascade ──
- mapping: |
root = this
let quality = this.jev.answers.quality.score.or(0)
let conformant = this.jev.answers.conformant.noul.or(0)
root.jev_decision = if $quality < 1 || $conformant < 0.3 {
"quarantine"
} else {
"warehouse"
}
output:
broker:
pattern: fan_out
outputs:
- stdout:
codec: lines
- switch:
cases:
- check: this.jev_decision == "quarantine"
output:
file:
path: ./data/jev-data-quality/quarantine-${! now().ts_format("2006-01-02") }.jsonl
codec: lines
- check: "true"
output:
file:
path: ./data/jev-data-quality/warehouse-${! now().ts_format("2006-01-02") }.jsonl
codec: lines
102 lines. Copy and Download both give you the file byte for byte.
What you need
- Expanso Edge installed, to validate and run the pipeline.
- A Jev endpoint. The pipeline posts to
JEV_API_URL, and falls back tohttps://api.typesafe.ai/v1/systemonewhen that variable is unset. - A key for that endpoint in
TYPESAFE_API_KEY. The pipeline sends it as a bearer token and has no default for it.
What it proves
- Input. POST /rows on port 8080.
- Output. Local files under
./data/jev-data-quality/. The warehouse route is a file in this example, not a warehouse connection. - Scope. This example ships as a pipeline file and sample records. Its README marks the live runtime (event generator and dashboard) as coming next, so what is published here is the pipeline itself.
- Revision. The file shown is the example as of commit
517c38fof its repository, which is still being developed.
Sample records
The first two of the records that ship with this example. Download all of them.
{"order_id":"ord-9001","customer_id":"cus-88121","amount":129.99,"currency":"USD","ts":"2026-09-18T14:00:00Z"}{"order_id":"ord-9002","customer_id":"cus-10422","amount":-45.00,"currency":"USD","ts":"2026-09-18T14:01:00Z"}Questions about this example.
receive, shape, gate, route. Each of those stages applies the same fixed rules every time, with no model involved. Expanso also sets the thresholds that turn Jev's answers into a route.
Jev answers 2 typed questions about each record: quality, conformant. It does not choose the route. The pipeline's gate does that from Jev's answers.
The pipeline catches the failed call, marks the record jev-unavailable, and the gate resolves to "quarantine". With no answers, quality defaults to 0, which is under 1, so every row quarantines. The example fails closed.
Run the deterministic half on your own nodes.
Expanso Edge runs these pipelines where the data is created. The first five nodes are free.