mirror of
https://github.com/luxfi/aml.git
synced 2026-09-24 00:25:20 +00:00
The refresh filled a Base-backed sanctions store and the search endpoint queried a separate empty in-memory one. Neither was reachable from the other, so /v1/aml/sanctions/search returned no matches for every name, permanently, and nothing in the system reported it. There is now one store, shared by the endpoints and by the engine's screening term. Screening refuses rather than reports clean. An unloaded or stale list set, a list that parsed to zero entries, or a class the deployment cannot answer all produce an error, which the engine turns into a review. Political exposure is refused outright: there is no authoritative public list of politically exposed persons and none of the four sanctions publishers is one, so answering from sanctions data would report every customer as not politically exposed. Each publisher is fetched and parsed by its own parser, and a failure for one leaves the other three loaded rather than clearing them. Transactions carry a direction and the customer's name and jurisdiction. The previous ingestion path synthesised a customer from the identifier alone, so every screening and jurisdiction rule evaluated against an empty name and an empty country and could not fire whatever the engine did. Case events check that the case belongs to the requesting organisation. A case identifier is returned to whoever submitted the transaction, so possession of it was authority to write on another tenant's investigation. Health reports function rather than process: whether the lists are ready, which loaded when, and how many terms this deployment can answer. Currency rates and the higher-risk jurisdiction listing are loaded, never compiled in. /v1/aml/catalog publishes the rules with their citations, the obligations claimed, and the obligations outstanding. Screening 31,338 real designations across the four published lists produced two false positives, both a one-word list entry matching an unrelated three-part name on a shared prefix. Raising the threshold could not separate them from genuine transliterations, which score lower; the asymmetry could. A single-token name now has to match a multi-token name near-exactly. Zero false positives after. Co-authored-by: Hanzo Dev <[email protected]>
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package reference
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// RatesFromEnv reads the currency table from AML_RATES.
|
|
//
|
|
// The value is a JSON object of ISO 4217 code to USD value per unit, with the date
|
|
// it was current at:
|
|
//
|
|
// {"as_of":"2026-07-29T00:00:00Z","max_age":"48h","rates":{"EUR":1.08,"GBP":1.27}}
|
|
//
|
|
// There is no built-in table. A compiled-in rate is wrong within days and silently
|
|
// moves every threshold expressed in another currency; an absent rate is refused at
|
|
// evaluation and routed to review. Only the second is safe, and only the second is
|
|
// visible.
|
|
func RatesFromEnv() Rates {
|
|
raw := os.Getenv("AML_RATES")
|
|
if strings.TrimSpace(raw) == "" {
|
|
return Rates{}
|
|
}
|
|
var in struct {
|
|
AsOf time.Time `json:"as_of"`
|
|
MaxAge string `json:"max_age"`
|
|
Rates map[string]float64 `json:"rates"`
|
|
}
|
|
if err := json.Unmarshal([]byte(raw), &in); err != nil {
|
|
return Rates{}
|
|
}
|
|
r := Rates{AsOf: in.AsOf, USDPer: in.Rates}
|
|
if d, err := time.ParseDuration(in.MaxAge); err == nil {
|
|
r.MaxAge = d
|
|
}
|
|
return r
|
|
}
|
|
|
|
// JurisdictionsFromEnv reads the higher-risk country listing from
|
|
// AML_JURISDICTIONS:
|
|
//
|
|
// {"as_of":"2026-06-27T00:00:00Z","action":["KP","IR"],"monitoring":["SY"]}
|
|
//
|
|
// Membership changes several times a year, so it is loaded rather than compiled in,
|
|
// and an absent listing makes the jurisdiction rules fail loudly rather than report
|
|
// every country on earth as unlisted.
|
|
func JurisdictionsFromEnv() Jurisdictions {
|
|
raw := os.Getenv("AML_JURISDICTIONS")
|
|
if strings.TrimSpace(raw) == "" {
|
|
return Jurisdictions{}
|
|
}
|
|
var in struct {
|
|
AsOf time.Time `json:"as_of"`
|
|
Action []string `json:"action"`
|
|
Monitoring []string `json:"monitoring"`
|
|
}
|
|
if err := json.Unmarshal([]byte(raw), &in); err != nil {
|
|
return Jurisdictions{}
|
|
}
|
|
return Jurisdictions{AsOf: in.AsOf, Action: in.Action, Monitoring: in.Monitoring}
|
|
}
|