AML(#78) M3: flag companies that changed owner before onboarding (KYB_OWNER_CHANGED) - #1694
Closed
stenehrlich-tuleva wants to merge 1 commit into
Closed
AML(#78) M3: flag companies that changed owner before onboarding (KYB_OWNER_CHANGED)#1694stenehrlich-tuleva wants to merge 1 commit into
stenehrlich-tuleva wants to merge 1 commit into
Conversation
Screens the methodology rule "juriidiline isik on vahetanud omanikku enne on-boardimist kunagi" (KKR) from the authoritative Äriregister relationship history (getCompanyRelationships, with start/end dates), rather than the person-keyed screening-comparison that contaminated multi-company representatives. OwnershipChangeDetector flags a company when an owner (shareholder or beneficial owner) appears in its history but is no longer a current owner - i.e. someone exited, so ownership changed at some point before onboarding. A re-recorded same-person owner and board-only changes do not trigger it. The signal rides in KybCompanyData (computed in LegalEntityScreener from full history); a new OwnerChangeScreener emits KYB_OWNER_CHANGED. It is a risk signal (non-gating via isOnboardingGate), so it is scored by M7 without blocking onboarding. Stacked on M2 (reuses KybCheckType.isOnboardingGate from the M2 gate fix). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1694 +/- ##
=========================================
Coverage 91.30% 91.30%
- Complexity 6131 6144 +13
=========================================
Files 949 951 +2
Lines 22456 22481 +25
Branches 1669 1670 +1
=========================================
+ Hits 20503 20526 +23
Misses 1300 1300
- Partials 653 655 +2
🚀 New features to boost your workflow:
|
This was referenced Jun 11, 2026
Contributor
Author
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.
Milestone M3 of the company AML risk-scoring rollout (issue TulevaEE/tuleva#78, Phase A). Self-contained spec: the rev-3 comment on tuleva#78 and the plan file in TulevaEE/tuleva#79.
Rule
Methodology rule (KKR): "Kas juriidiline isik on vahetanud omanikku enne on-boardimist kunagi" — has the company ever changed owner before onboarding. A company that changed hands before coming to us is an acquired-shell red flag (pairs with M2's company-age signal).
Why now / what it replaces
The methodology notes this signal's data (
getCompanyRelationshipsendDatehistory) was "fetched but not used." The existingDATA_CHANGEDcheck inferred change from screening-to-screening diffs keyed by the representative's personal code, which contaminates a person who runs multiple companies. M3 reads the change from the authoritative Äriregister relationship history instead — per company, with dates.Change
OwnershipChangeDetectorflags a company when an owner (shareholderOSANor beneficial owner) appears in the full history but is not a current owner — i.e. someone exited. A re-recorded same-person owner and board-only changes do not trigger it.KybCompanyData(computed inLegalEntityScreenerfromgetCompanyRelationships, like M2'sfoundingDate); a newOwnerChangeScreeneremitsKYB_OWNER_CHANGED.OWNER_CHANGEDisisOnboardingGate()=false, so it's persisted and scored by M7 without rejecting the company (depends on the M2 fix).Tests (TDD)
OwnershipChangeDetectorTest— exit detected; sole-owner no-change; same-person record split (not a false positive); beneficial-owner exit; board-only change ignored; empty history.OwnerChangeScreenerTest— emits failing/passingOWNER_CHANGED.KybScreeningIntegrationTest— a changed-owner company persists a failingKYB_OWNER_CHANGED.pg/Testcontainers:KybEndToEndTest28/28,KybScreeningIntegrationTest6/6, + 149 kyb/aml unit tests, spotless.For Maria's sign-off (fine print of the rule)
planned_owner_changed_ever, "Omanikku vahetanud kunagi", status ⏳), which is owner-only by definition. Board-member changes are a separate, already-active rule — rule 5kkr_related_changed(the existingDATA_CHANGEDsince-last-screening check, ✓) — not part of M3. So this is not a widen-to-board toggle; the two are distinct rules.getCompanyRelationshipsSOAP call per screen/validate (could be deduplicated against the active-relationships fetch later).Refs TulevaEE/tuleva#78.
🤖 Generated with Claude Code