AML / Sanctions Screening β the yente engine (S0) + the screening module (S1)
The sanctions/PEP screening capability (epic RC-02, board #15) closes the one genuine control gap in the ktayl IS: today a party can be bound and paid with no sanctions screen β a real compliance failure for a regulated insurer, not mere incompleteness. The design is an adopt-the-engine + build-the-gate split (ADR-001): adopt yente (OpenSanctions' matching API) as the engine; build a screening module in ktayl-core as the gate + workflow + audit.
:::note S0 (engine) + S1 (module) + S2/S4 (bind + payment HOLD gates) are live on dev AND PROD (2026-11-17).
S0 (live): yente + a dedicated OpenSearch index + the official free lists + a freshness monitor β on dev (ns yente) and prod (ns yente-prod), each a dedicated engine (a prod compliance control must not depend on the dev one). S1 (live): the ktayl-core screening module β ScreenParty (fail-closed + idempotent), append-only audit, and the published ScreeningGate interface other modules call. S2/S4 (live): ScreeningGate wired at bind (HOLD blocks the bind) and before payment (HOLD = asset-freeze, no money moves). Promoted to prod (ktayl-core:4bbc7cd, 2/2 healthy, Flyway-migrated, SCREENING_YENTE_BASE_URL β yente-prod, prodβyente-prod path verified). Next: nightly re-screen (S5) + governed-AI triage (S6). Planning of record: ktayl-compliance/docs/architecture/rc02-screening-architecture.md + ADR-001 + the SPEC.
:::
What's deployed (S0)β
| Piece | As-built |
|---|---|
| yente | ghcr.io/opensanctions/yente:4.3.1 β the matching API (POST /match/default, /search, /catalog, /readyz). Standalone chart services/yente/helm, ns yente (dev-only β no prod consumer until the screening module ships). ArgoCD app apps/is/compliance/yente-dev.yaml. |
| Index | a dedicated single-node OpenSearch (opensearchproject/opensearch:2.17.1, Longhorn PVC) β no shared ES/OpenSearch existed on the cluster. |
| Lists | the official FREE lists only (OFAC SDN Β· EU consolidated Β· UN SC Β· UK OFSI) β licence-clean even in a production-shaped demo (ADR-001 Β§8), via a catalogs manifest. YENTE_AUTO_REINDEX keeps them fresh. |
| Freshness | a stdlib exporter emits yente_sanctions_dataset_age_hours; a PrometheusRule alarms at stale > 48h (critical) / > 24h (warn) / catalog-down β "how do you know the lists were current when you screened?" (SEC-SCR-04). |
| Egress | ingress default-deny + egress default-deny + DNS + cluster-internal + controlled external HTTPS to data.opensanctions.org only (SEC-SCR-03). Gatekeeper-clean (non-root, no-priv-esc, drop-caps, seccomp). |
Verified live (2026-11-16)β
- OpenSearch
green; yente/readyz= 200;/cataloglists the four free lists (OFAC 72,994 entities + EU 16,045 + UN + UK). - Acceptance proof β
POST /match/defaulta known sanctioned name β "Vladimir Putin" matched at score 1.0 fromus_ofac_sdn; an obvious non-name (control) β 0 matches (no false positive). - Freshness gauge live:
yente_sanctions_dataset_age_hours β 0.2(well under the 24h target);yente_catalog_up = 1. - Egress confirmed to
data.opensanctions.org; default-deny holds otherwise.
Adoption gotchas (yente on a hardened cluster)β
Four fixes, each caught by live verification (not unit tests), worth knowing for any yente/OpenSearch adopt:
enableServiceLinks: falseβ a Service namedyentemakes K8s injectYENTE_PORT=tcp://<ip>:8000, which yente reads as its listen port βint()crash.YENTE_INDEX_TYPE=opensearchβ yente defaults to the Elasticsearch client, whose product-check rejects OpenSearch (UnsupportedProductError).- manifest via
catalogs(noturl/entities_url) β a per-dataseturl: β¦/index.jsonmis-parses;entities_urlhits a307yente's httpx won't follow. The native mechanism reads the main catalog's absolute artifact URLs. - freshness parse β yente
/catalogexposes recency asversion=YYYYMMDDHHMMSS(compact, not ISO).
What's deployed (S1 β the screening module in ktayl-core)β
The gate + workflow + audit, as a module inside the ktayl-core modular monolith (not a new service β the modular-monolith decision), schema-per-module (screening schema, Flyway V11), hexagonal (domain ports + a YenteClient adapter):
| Piece | As-built |
|---|---|
ScreenParty (application) | the use case: resolve/De-dupe the party (idempotent by external_ref), screen once per (party, gate, UTC-day), persist the screening + any alerts, write an append-only audit row. Fail-CLOSED: any engine error β persist a HOLD screening (null dataset_version) + a SCREEN_FAILCLOSED audit β return HOLD (never a silent allow, NFR-SCR-02). |
ScreeningGate (@NamedInterface) | the published, in-process interface other ktayl-core modules call β screen(PartyRef, gate) β ScreeningOutcome {verdict, alertId, datasetVersion}. A match β HOLD; no hit β ALLOW. This is what S2/S4 wire at bind/payment. |
| Audit | screening_audit β bigint IDENTITY, append-only (no update/delete), one row per screen/decision, actor from the JWT (preferred_username/subject). The DORA/AML evidence trail. |
| HITL decision | POST /alerts/{id}/decision β @PreAuthorize("hasAuthority('GROUP_Compliance')"); every alert is a human review (the AI triage S6 never auto-clears a true hit). Authority is server-side. |
| Engine adapter | YenteClient β POST /match/default on the S0 yente; score β₯ threshold β a SANCTION Hit; GET /catalog β the dataset_version logged as "the lists were current when we screened". |
| Network | ktayl-core egress β ns yente :8000; yente ingress β ns ktayl-core(+-prod). Both default-deny + explicit allow. |
Verified live (2026-11-16) β the full gate path, end-to-end on devβ
Screened via the ktayl-core API with a real M2M (Authentik client-credentials) token:
POST /v1/screening/screen"Vladimir Putin" β{"verdict":"HOLD", "alert_id":"eeabc8cb-β¦", "dataset_version":"20261116210012"}β a real alert,bucket: SANCTION, score: 100, matched_entry: "Vladimir Vladimirovich Putin".- A clean control name β
{"verdict":"ALLOW", β¦}(dataset_version stamped on both β the "lists were current" evidence). GET /v1/screening/alertslists the open alert; the fail-closed invariant proven separately (engine-unavailable βHOLD+ null alert; unauthenticated β401).
S1 gotcha (worth knowing for any Spring-Boot β FastAPI/uvicorn call)β
The ktayl-core YenteClient (Spring Boot 3 RestClient) got 400 "Invalid HTTP request received" / 422 "body required" from yente while an identical curl from the same namespace worked. Cause: Spring Boot 3.2+'s default RestClient factory is the JDK java.net.http.HttpClient, which sends an h2c upgrade on cleartext http://. nginx/ERPNext tolerate it; yente's uvicorn/h11 rejects it and drops the body. Fix: RestClient.builder().requestFactory(new SimpleClientHttpRequestFactory()) β HttpURLConnection speaks clean HTTP/1.1, no h2c. (And: a rollout leaves old+new pods briefly β verify on the pod matching the new image digest, not just the deploy tag; a stale pod gives a false fail-closed.)
What's deployed (S2 + S4 β the bind + payment HOLD gates)β
The ScreeningGate is now wired into the two money/commitment paths inside ktayl-core, so a sanctioned party is held before it can be bound or paid (not merely flagged after). Both are in-process calls to the published screening.api interface (no intra-monolith HTTP), server-side (the gate is in the application layer, not the caller), and fail-CLOSED (a yente outage β HOLD β the action is blocked, the intended compliance posture):
| Gate | Where | Behaviour |
|---|---|---|
| S2 β bind | PolicyService.activate() (SUBMITTEDβACTIVE) | screens the holder at the bind gate before the transition; HOLD β 409 held pending sanctions review (+ alertId), the policy stays SUBMITTED (nothing saved), an auditable alert awaits the compliance officer. |
| S4 β payment | PaymentService.initiate() | resolves the party (installmentβinvoiceβPolicyQuery) and screens at the payment gate before the Stripe PSP call; HOLD β 409, the PSP is never called β no money moves (the asset-freeze). |
HITL clears a hold via the existing POST /v1/screening/alerts/{id}/decision (GROUP_Compliance). Module boundaries hold β ApplicationModules.verify() is green (policyβscreening.api, billingβscreening.api+policy.api).
Verified live (2026-11-17) β the bind gate, end-to-end on devβ
Drove a real bind through the ktayl-core policy API (create β submit β activate) with an M2M token:
- "Vladimir Putin" policy β
activate=409{"gate":"bind","alertId":"6a2e1f2c-β¦","detail":"held pending sanctions review"}β the bind is blocked server-side and a fresh auditable alert is created; the policy remains SUBMITTED (not bound). - A clean-name policy β
activate=204β binds normally (ALLOW).
S4 (payment) is wired identically and covered by the L2 integration + unit tests (HOLD β the PSP is never invoked); it uses the same ScreeningGate, so the live bind proof is the proof of the pattern.
Screening at these gates is name-based today (the
Policyaggregate carriesholderName; DOB/nationality enrichment is a later refinement) β yente matches on name, so this is the real-world baseline, not a stub.
The invariantβ
The gate fails CLOSED: if yente is down/stale, a screen returns HOLD, never a silent allow (NFR-SCR-02). Authority is server-side; every match that could block a bind/payment goes to human review (HITL) β the AI triage (S6) never auto-clears a true hit.
Detailed design lives with the code: ktayl-compliance/docs β ADR-001 (adopt-vs-build), the screening architecture (C4 + threat model + the gates), the SPEC (the S0βS6 slice plan). The module source is in ktayl-core (src/main/java/com/ktayl/core/screening).