feat(aml): track AML decision source (automatic/GSheet/compliance)#3852
Draft
TaprootFreak wants to merge 1 commit into
Draft
feat(aml): track AML decision source (automatic/GSheet/compliance)#3852TaprootFreak wants to merge 1 commit into
TaprootFreak wants to merge 1 commit into
Conversation
Add an authoritative amlSource enum (Automatic | GSheet | Compliance) to buy_crypto and buy_fiat, set server-side, so every AML pass/fail is clearly attributable to its origin instead of relying on the inconsistent free-string amlResponsible. - Automatic checks (AmlHelperService) stamp amlSource = Automatic. - Manual decisions via the COMPLIANCE update/amlCheck endpoints derive the source from the authenticated principal (@GetJwt): the configured GSheet technical account (AML_GS_ACCOUNT_ID) maps to GSheet, otherwise Compliance, and the acting principal is recorded in amlResponsible when not provided. - Log the first gs/db caller per principal to reveal the GSheet account id. GSheet recognition activates once AML_GS_ACCOUNT_ID is set; until then manual passes are recorded as Compliance with the acting principal captured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Manual AML passes/fails cannot be reliably attributed to their origin. The generic compliance update endpoint records no actor at all, and
amlResponsibleis an inconsistent client-supplied free-string (mix ofAPI,null, first names, typos). The GSheet admin and the human compliance tool both hit the samePUT /buyCrypto/:id(update()) with the same role, so the backend cannot tell them apart.Change
Introduce an authoritative
amlSourceenum (Automatic | GSheet | Compliance), set server-side, onbuy_cryptoandbuy_fiat.AmlHelperService.getAmlResultstampsamlSource = Automaticon every automatic decision.update()andmanualPassAmlCheck()now receive the authenticated principal via@GetJwt(). When an amlCheck decision is made, the source is derived from the principal:AML_GS_ACCOUNT_ID) →GSheetCompliance, and the acting principal is recorded inamlResponsiblewhen the caller didn't supply one (fills the previousnullgap).GsController.getDbDatalogs the firstgs/dbcaller per principal (deduplicated, INFO). This surfaces the GSheet technical account id from the live logs soAML_GS_ACCOUNT_IDcan be set.The client-supplied
responsiblestring is no longer the source of truth; the source is decided in the backend.Scope
AmlSource, nullableamlSourcecolumn onbuy_cryptoandbuy_fiat+ migration.update()/manualPassAmlCheck()(BuyCrypto + BuyFiat) + their controllers pass@GetJwt().Rollout
gs/dbfirst-access log reveals the GSheet technical account id.AML_GS_ACCOUNT_IDto that account id (DEV + PRD). From then on GSheet passes are recorded asGSheet; before that they are recorded asCompliancewith the acting principal captured.Test plan
type-check,lint,formatcleanbuild(nest build) greenamlSourceis populated on automatic, compliance-tool and GSheet passes after deployFollow-ups
amlSourcein the relevant response DTOs / compliance UI once needed.amlSourcefor historical rows.