Harden closed-loan trainer — concurrency, idempotency, limits

FeatureSecurityService
Shipped
July 15, 2026 at 3:26 AM UTC
Author
Kamo
Commit
807a235

- Concurrency: in-process activeOrgs guard + the DB claim() so this instance never double-walks an org and two replicas can't overlap; a run whose heartbeat is >10min stale is reclaimable (process died mid-walk). - Idempotency: skip loans already marked closedLoanTrainedAt, and mark a loan only after a real closed-loan training pass (not-yet-closed loans stay unmarked so later passes catch them once they close). - Memory safety: skip documents over 30MB — downloadDocument buffers the whole file and SecurityService is memory-tight. - Signed-URL TTL for training docs is now configurable and defaults to 15min so a slow 15-page vision read can't outrun a 5-min token.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing