Skip to content

Lot traceability by containment

The queue as a marketHTTPSDKCLIMQTTmetadata patchfacetsresolve

Stamp the lots each unit consumed onto its row as an array facet. Every row that used a lot is then one containment query.

The situation

A supplier reports a bad resin lot, LOT-7. Quality needs every part that used it, across every station, today, without a reporting pipeline.

The recipe

services/station.ts
await lt.escalations.resolve({
id: stepRowId,
resolverPayload: { ok: true },
metadata: { lots: ['LOT-7', 'LOT-12'], units: ['SN-101', 'SN-102'] },
});
Everything that touched LOT-7
curl -G https://lt.acme.dev/api/escalations \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode 'facets={"lots":["LOT-7"]}'

The outcome patch lands on the row as it closes. Containment on an array matches any row whose list includes the value, and the GIN index serves it.

The guarantee

The lots are written in the same atomic update as the resolve, so a closed step always carries its trace. A unit’s whole path is every row whose units holds it. Machines on MQTT get this stamped for them: the gateway merges trace and lots facets as each unit is released. See Machines.