# Loan Desk

**loan-desk.infinity-sdg.com** — mortgage underwriting where AI reads documents and drafts conditions, and underwriters decide, clear and close.

```
borrower → loan: submitted → processing → underwriting
    → approved (with conditions) → clear to close → closed
    → declined (adverse-action reasons required) | suspended → withdrawn
document: uploaded with an AI summary and confidence → verified or rejected by a processor
condition: AI-drafted or written by the underwriter
    draft → accepted (open) | discarded (with a reason)
    open  → cleared (against a verified document) | waived (manager, with a reason)
nightly: loans suspended for 30 days are withdrawn
```

## What it enforces

| Rule | Why |
|---|---|
| No approval while AI-drafted conditions are unreviewed | The AI drafts; an underwriter decides which conditions stand |
| Approval needs a verified credit report and income document | The basics are verified, not just uploaded |
| No approval above 50% DTI or 97% LTV | Program limits hold at the decision |
| The underwriter can't be the processor who built the file | Separation of duties |
| A condition clears only against a verified document | Every cleared condition points at evidence |
| Discarding an AI draft, waiving a condition or suspending a file needs a reason | Every exception is explained |
| No clear-to-close with an open or unreviewed condition, or without a verified appraisal | Nothing closes with loose ends |
| No new conditions once a loan is clear to close | The closing package is final |
| Every decline states its adverse-action reasons | The borrower is told why |

Every resource is audited. Loans and conditions keep a readable history.

## Resources, views, roles

- **Resources:** borrower, loan, document, loancondition
- **Views:**
  - `pipeline`
  - `openConditions`
  - `aiDraftReview`: every AI-drafted condition, its rationale and what the underwriter did with it
- **Roles:**
  - `processor`: builds files and verifies documents
  - `underwriter`: reviews AI drafts, decides, clears conditions
  - `manager`: waives conditions and can decide
  - `closer`: closes clear-to-close loans
  - `admin`

## Demo data

The demo has 24 loans across conventional, FHA, VA and jumbo programs, in every state:

- 6 closed
- 3 clear to close
- 4 approved with conditions still open
- 3 in underwriting, with AI drafts waiting for review
- 3 declined, one each for DTI, credit history and collateral
- 2 suspended
- 1 withdrawn
- 1 in processing
- 1 just submitted

The files hold 126 documents, each with an AI summary. Five bank statements were rejected for missing pages.

There are 88 conditions:

- The AI drafted most of them.
- Underwriters accepted the sound drafts. They discarded the "self-employment" draft with a reason: the employer had been renamed, not changed.
- Underwriters added their own employment verification condition.
- Each cleared condition points at the verified document that satisfied it.
- A manager waived a large-deposit condition with a reason.

Every decision is made by the demo user who would make it (`processor1`, `processor2`, `uw1`, `uw2`, `manager1`, `closer1`), with that user's own roles. That needs Kalos seeder 1.2.0 or later.

Every borrower is invented, phone numbers use the 555 range, and no tax ID or account numbers are stored. To regenerate the data, run `python3 seeds/gen_seed.py`.

## Run it

```bash
scripts/kalos.sh validate    # static checks
scripts/kalos.sh start       # kalosd on :9222
scripts/kalos.sh verify      # live checks
```

By default, `KALOS_REPO` is `../kalos`.

Sign in with `admin` / `Admin123!`. The other users are `processor1`, `processor2`, `uw1`, `uw2`, `manager1` and `closer1`, all with password `Demo123!`.

## Reselling

This is an original ISDG product for mortgage lenders, credit unions and loan servicers. It has no customer data and no third-party branding. In a real deployment, program limits, condition libraries and adverse-action wording are configured per lender and investor guidelines.
