fix(officer): scope reasons and forecasts to the run that produced the score

Both repositories were queried by enterprise alone, so every reason code and
every forecast point ever written came back. A run-287 model score was being
rendered beside run-145 rule sentences, and one enterprise's six-month chart
drew 102 points from seventeen different runs.

Now read through findByEnterpriseIdAndRunId..., resolved from the newest run.
The same unscoped query existed in EnterpriseAppService and is fixed there
too.

Also adds GET /officer/app-enrolled: which borrowers on this caller's book
have a phone login. Not every borrower is enrolled and that is the design —
the platform scores a book from core banking and UPI whether or not the owner
installs anything — so the console needs to know rather than offering to open
an app that does not exist. Scoped by intersecting with the caller's own book,
so it cannot be used to discover that an id exists on another bank's.

EnterpriseRow gains firstBreachHorizon, firstBreachMonth and topDriver so the
dashboard can rank by lead time instead of by composite score.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
LincPay
2026-08-25 13:44:22 +05:30
co-authored by Claude Opus 5
parent 6b4aec468d
commit e7c93e29ea
6 changed files with 108 additions and 4 deletions
@@ -54,7 +54,22 @@ public final class UdyamResponses {
Integer score,
String band,
List<Integer> trend,
String lastUpdated) {
String lastUpdated,
/**
* Months until the downside case first fails to cover the instalment,
* or null if it never does over the horizon.
*
* <p>Here because lead time is the product. A dashboard that ranks by
* score alone shows what a bureau score already shows; ranking by when
* trouble arrives is the thing this platform can do that they cannot.
*/
Integer firstBreachHorizon,
String firstBreachMonth,
/** The top-ranked reason sentence from the run that produced the score. */
String topDriver,
String topDriverHi) {
}
/** Dashboard KPI tiles plus the enterprises-by-risk register. */