Import and scrub
Traced at commit ffe4e48 ·
apps/api/src/app/imports/* ·
libs/contracts/src/lib/scrub.ts ·
libs/temporal/src/activities/scrub.ts
Summary
- A client uploads a CSV or XLSX file.
- The platform checks the shape of each row.
- A rejected row is either remediable or terminal.
- An accepted row becomes a lead.
- Every number starts with the scrub status
PENDING. - A
PENDINGnumber never dials. Gate check 4 refuses it. - A scrub provider checks the number. The worst hit wins.
- If nobody configures a provider, numbers stay
PENDINGand nothing dials. This is the designed behaviour.
Workflow 1 — the file
- A client uploads a CSV file or an XLSX file.
- The platform reads the columns and checks the format of each field.
- The platform checks each phone number.
- An accepted row becomes a lead in the state
INGESTED, thenVALIDATED. - The platform records a rejected row with a class and a reason.
The two reject classes
- Remediable — the client can correct the row and send the file again.
- Terminal — the platform cannot use the row.
- The distinction tells a client where to spend effort.
- A client can act on a remediable reject. A client cannot act on a terminal one.
Workflow 2 — the scrub
What the scrub does
- Every imported number starts with the status
PENDING. - A scrub provider checks the number against three databases.
- The databases cover do-not-call registers, litigators and reassigned numbers.
- A number can match more than one. The worst hit wins.
- The hit types are
dnc_federal,dnc_state,litigator,reassigned_numberandinvalid_number. - A clean number lets the lead move to
QUEUED. - A hit suppresses the lead.
- The result has a freshness window. Gate check 4 refuses a result that is too old.
When nobody configures a provider
- The default provider is
none. - The provider
nonescrubs nothing. - Numbers stay
PENDING. - Gate check 4 refuses every
PENDINGnumber. - Nothing dials. The platform fails closed.
- A
stubprovider returns clean for every number. - The stub stamps its result so no audit record can mistake it for a vendor verdict.
- The stub is for pilot and development use. An unset environment does not enable it.
Do not fix a stalled import by hand. Setting scrub_status
to CLEAN in the database satisfies the gate by assertion. No vendor verdict
stands behind that value. The audit record cannot show the difference later.
Lead lifecycle and cadence — what happens to a lead after the scrub clears it.