← All seeds & suites
loandesk ADL 0.5.1 Mortgage Lending

Loan Desk

Mortgage underwriting where AI summarizes documents and drafts conditions, and underwriters decide: no approval over an unreviewed draft, conditions clear only against verified documents, no closing with an open condition, and every decline states its adverse-action reasons.

Resources (4)
borrower, loan, document, loancondition
Roles (5)
processor, underwriter, manager, closer, admin
Features (10)
suitepermissionsstate_machinevalidationrules_engineviewsscheduled_tasksaudithistory_eventsindexes

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

RuleWhy
No approval while AI-drafted conditions are unreviewedThe AI drafts; an underwriter decides which conditions stand
Approval needs a verified credit report and income documentThe basics are verified, not just uploaded
No approval above 50% DTI or 97% LTVProgram limits hold at the decision
The underwriter can’t be the processor who built the fileSeparation of duties
A condition clears only against a verified documentEvery cleared condition points at evidence
Discarding an AI draft, waiving a condition or suspending a file needs a reasonEvery exception is explained
No clear-to-close with an open or unreviewed condition, or without a verified appraisalNothing closes with loose ends
No new conditions once a loan is clear to closeThe closing package is final
Every decline states its adverse-action reasonsThe 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

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!.

Domain Resource Summary

ResourcePurpose & Lifecycle
borrowerA person applying for a loan.
loanOne mortgage application, from submission to closing. (States: submitted, processing, underwriting, suspended, approved, clear_to_close, closed, declined, withdrawn)
documentA borrower document, summarized by AI and verified by a processor. (States: received, verified, rejected)
loanconditionAn underwriting condition. AI drafts many; an underwriter decides which stand. (States: draft, open, cleared, waived, discarded)
Inspect domain.yaml (327 lines)
# loan-desk/backend/domain.yaml
#
# Loan Desk — mortgage underwriting where AI reads and drafts, and people decide.
#
#   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 → verified or rejected by a processor
#   loancondition: 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.
#
# No closing with an open condition. No approval over an unreviewed AI draft.
# A condition clears only against a verified document from the same loan.
#
# An ISDG product for mortgage lenders, credit unions and loan servicers.
# Borrowers are invented; no tax ID or account numbers are stored.
# query() filter keys are single lowercase words.

domain:
  name: loandesk
  version: "1.0.0"
  description: >
    Mortgage underwriting: AI reads documents and drafts conditions, underwriters
    accept and clear them against verified documents, no closing with open
    conditions, and every decline states its adverse-action reasons.

  resources:

    borrower:
      description: "A person applying for a loan."
      object:
        id:          { type: uuid, primaryKey: true, protected: true, allowUserProvided: true }
        fullName:    { type: string, required: true, maxLength: 120 }
        email:       { type: email, required: true }
        phone:       { type: phone, required: true }
        employer:    { type: string, maxLength: 120 }
        firstTimeBuyer: { type: boolean, required: true, default: false }
      permissions:
        list:   [processor, underwriter, manager, closer, admin]
        get:    [processor, underwriter, manager, closer, admin]
        create: [processor, admin]
        update: [processor, admin]
        delete: [admin]
      features: { audit: true }

    loan:
      description: "One mortgage application, from submission to closing."
      object:
        id:            { type: uuid, primaryKey: true, protected: true, allowUserProvided: true }
        number:        { type: string, required: true, unique: true, maxLength: 20 }
        borrower:
          type: reference
          references: "adl.loandesk.loandesk.borrower"
          required: true
        purpose:       { type: string, required: true, enum: [purchase, refinance, cash_out_refinance] }
        program:       { type: string, required: true, enum: [conventional, fha, va, jumbo] }
        amount:        { type: decimal, required: true, precision: 14, scale: 2, min: 0 }
        propertyValue: { type: decimal, required: true, precision: 14, scale: 2, min: 0 }
        rate:          { type: decimal, required: true, precision: 6, scale: 3, min: 0 }
        ltv:           { type: decimal, required: true, precision: 6, scale: 2, min: 0 }
        dti:           { type: decimal, required: true, precision: 6, scale: 2, min: 0 }
        creditScore:   { type: integer, required: true, min: 300, max: 850 }
        lockExpires:   { type: date }
        processor:     { type: string, maxLength: 60 }
        underwriter:   { type: string, maxLength: 60 }
        adverseReasons: { type: text }
        suspenseNote:  { type: text }
        suspendedAt:   { type: datetime }
        closedAt:      { type: datetime }
        status:        { type: string, required: true, default: submitted }
      stateMachine:
        field: status
        initial: submitted
        states:
          submitted:
            transitions:
              assign: { to: processing, guards: [processor, admin], requiredFields: [processor] }
          processing:
            transitions:
              submitToUnderwriting: { to: underwriting, guards: [processor, admin], requiredFields: [underwriter] }
              withdraw: { to: withdrawn, guards: [processor, admin] }
          underwriting:
            transitions:
              approve: { to: approved, guards: [underwriter, manager] }
              decline: { to: declined, guards: [underwriter, manager], requiredFields: [adverseReasons] }
              suspend: { to: suspended, guards: [underwriter, manager], requiredFields: [suspenseNote], sets: { suspendedAt: now() } }
          suspended:
            transitions:
              resume:   { to: underwriting, guards: [underwriter, manager] }
              withdraw: { to: withdrawn, guards: [processor, manager, admin] }
          approved:
            transitions:
              clearToClose: { to: clear_to_close, guards: [underwriter, manager] }
              withdraw:     { to: withdrawn, guards: [processor, manager, admin] }
          clear_to_close:
            transitions:
              close: { to: closed, guards: [closer, admin], sets: { closedAt: now() } }
          closed: {}
          declined: {}
          withdrawn: {}
      permissions:
        list:   [processor, underwriter, manager, closer, admin]
        get:    [processor, underwriter, manager, closer, admin]
        create: [processor, admin]
        update: [processor, underwriter, manager, closer, admin]
        delete: [admin]
      features: { audit: true }
      history:
        events:
          approved:   { trigger: transition, transition: approve, label: "Approved with conditions", severity: success }
          declined:   { trigger: transition, transition: decline, capture: [adverseReasons], label: "Declined: {adverseReasons}", severity: warning }
          suspended:  { trigger: transition, transition: suspend, capture: [suspenseNote], label: "Suspended: {suspenseNote}", severity: warning }
          ctc:        { trigger: transition, transition: clearToClose, label: "Clear to close", severity: success }
          closed:     { trigger: transition, transition: close, severity: success }
      indexes:
        - { fields: [borrower] }
        - { fields: [status] }

    document:
      description: "A borrower document, summarized by AI and verified by a processor."
      object:
        id:           { type: uuid, primaryKey: true, protected: true, allowUserProvided: true }
        loan:
          type: reference
          references: "adl.loandesk.loandesk.loan"
          required: true
        kind:         { type: string, required: true, enum: [paystub, w2, tax_return, bank_statement, credit_report, appraisal, title_commitment, insurance_binder, gift_letter, explanation_letter, employment_verification] }
        receivedAt:   { type: datetime, required: true }
        aiSummary:    { type: text, required: true }
        aiConfidence: { type: percentage, required: true }
        reviewNote:   { type: text }
        status:       { type: string, required: true, default: received }
      stateMachine:
        field: status
        initial: received
        states:
          received:
            transitions:
              verify: { to: verified, guards: [processor, underwriter] }
              reject: { to: rejected, guards: [processor, underwriter], requiredFields: [reviewNote] }
          verified: {}
          rejected: {}
      permissions:
        list:   [processor, underwriter, manager, closer, admin]
        get:    [processor, underwriter, manager, closer, admin]
        create: [processor, admin]
        update: [processor, underwriter, admin]
        delete: [admin]
      features: { audit: true }
      indexes:
        - { fields: [loan] }

    loancondition:
      description: "An underwriting condition. AI drafts many; an underwriter decides which stand."
      object:
        id:          { type: uuid, primaryKey: true, protected: true, allowUserProvided: true }
        loan:
          type: reference
          references: "adl.loandesk.loandesk.loan"
          required: true
        text:        { type: text, required: true }
        source:      { type: string, required: true, enum: [ai, underwriter] }
        rationale:   { type: text }
        document:
          type: reference
          references: "adl.loandesk.loandesk.document"
        note:        { type: text }
        status:      { type: string, required: true, default: draft }
      stateMachine:
        field: status
        initial: draft
        states:
          draft:
            transitions:
              accept:  { to: open, guards: [underwriter, manager] }
              discard: { to: discarded, guards: [underwriter, manager], requiredFields: [note] }
          open:
            transitions:
              clear: { to: cleared, guards: [underwriter, manager], requiredFields: [document] }
              waive: { to: waived, guards: [manager], requiredFields: [note] }
          cleared: {}
          waived: {}
          discarded: {}
      permissions:
        list:   [processor, underwriter, manager, closer, admin]
        get:    [processor, underwriter, manager, closer, admin]
        create: [underwriter, manager, admin]
        update: [underwriter, manager, admin]
        delete: [admin]
      features: { audit: true }
      history:
        events:
          discarded: { trigger: transition, transition: discard, capture: [note], label: "AI draft discarded: {note}", severity: info }
          cleared:   { trigger: transition, transition: clear, severity: success }
          waived:    { trigger: transition, transition: waive, capture: [note], label: "Waived: {note}", severity: warning }
      indexes:
        - { fields: [loan] }

  rules:

    reviewAiDraftsBeforeDeciding:
      description: "No approval while AI-drafted conditions are unreviewed."
      trigger: { resource: loan, events: [transition], transition: approve }
      condition: "len(query('loancondition', { loan: $record.id, status: 'draft' })) > 0"
      action: reject
      severity: error
      message: "Accept or discard every drafted condition first."

    approvalNeedsVerifiedIncomeAndCredit:
      description: "Approval needs a verified credit report and a verified income document."
      trigger: { resource: loan, events: [transition], transition: approve }
      condition: "len(query('document', { loan: $record.id, kind: 'credit_report', status: 'verified' })) == 0
                  || (len(query('document', { loan: $record.id, kind: 'paystub', status: 'verified' }))
                      + len(query('document', { loan: $record.id, kind: 'w2', status: 'verified' }))
                      + len(query('document', { loan: $record.id, kind: 'tax_return', status: 'verified' }))) == 0"
      action: reject
      severity: error
      message: "Verify the credit report and an income document first."

    debtToIncomeCap:
      description: "No approval above a 50% debt-to-income ratio."
      trigger: { resource: loan, events: [transition], transition: approve }
      condition: "$record.dti > 50"
      action: reject
      severity: error
      message: "Debt-to-income is above 50%."

    loanToValueCap:
      description: "No approval above a 97% loan-to-value ratio."
      trigger: { resource: loan, events: [transition], transition: approve }
      condition: "$record.ltv > 97"
      action: reject
      severity: error
      message: "Loan-to-value is above 97%."

    underwriterIsNotTheProcessor:
      description: "The person who built the file doesn't underwrite it."
      trigger: { resource: loan, events: [transition], transition: submitToUnderwriting }
      condition: "$record.underwriter == $record.processor"
      action: reject
      severity: error
      message: "Assign a different underwriter."

    noClosingWithOpenConditions:
      description: "Clear to close only when no condition is open or still a draft."
      trigger: { resource: loan, events: [transition], transition: clearToClose }
      condition: "len(query('loancondition', { loan: $record.id, status: 'open' }))
                  + len(query('loancondition', { loan: $record.id, status: 'draft' })) > 0"
      action: reject
      severity: error
      message: "Conditions are still open."

    clearToCloseNeedsAppraisal:
      description: "Clear to close needs a verified appraisal."
      trigger: { resource: loan, events: [transition], transition: clearToClose }
      condition: "len(query('document', { loan: $record.id, kind: 'appraisal', status: 'verified' })) == 0"
      action: reject
      severity: error
      message: "No verified appraisal on file."

    clearAgainstAVerifiedDocument:
      description: "A condition clears only against a verified document."
      trigger: { resource: loancondition, events: [transition], transition: clear }
      condition: "some(query('document', { id: $record.document }), d => d.status != 'verified')"
      action: reject
      severity: error
      message: "The document isn't verified."

    noNewConditionsAfterClearToClose:
      description: "Conditions can't be added once a loan is clear to close."
      trigger: { resource: loancondition, events: [create] }
      condition: "some(query('loan', { id: $record.loan }), l => l.status == 'clear_to_close' || l.status == 'closed')"
      action: reject
      severity: error
      message: "The loan is already clear to close."

  schedules:

    withdrawStaleSuspensions:
      description: "Loans suspended for 30 days are withdrawn."
      recurrence: daily at 02:30
      source:
        resource: loan
        filter: "status == 'suspended' && suspendedAt < dateSub(now(), 30, 'day')"
      action: transition
      transition: withdraw

  views:

    pipeline:
      description: "Every loan and where it stands."
      source: loan
      permissions: [processor, underwriter, manager, closer, admin]
      columns:
        - { field: number,      label: "Loan" }
        - { field: program,     label: "Program" }
        - { field: amount,      label: "Amount" }
        - { field: ltv,         label: "LTV %" }
        - { field: dti,         label: "DTI %" }
        - { field: underwriter, label: "Underwriter" }
        - { field: lockExpires, label: "Lock expires" }
        - { field: status,      label: "State" }
      defaultLimit: 500

    openConditions:
      description: "Conditions waiting to be cleared."
      source: loancondition
      filter: "status == 'open'"
      permissions: [processor, underwriter, manager, admin]
      columns:
        - { field: text,   label: "Condition" }
        - { field: source, label: "Drafted by" }
      defaultLimit: 500

    aiDraftReview:
      description: "AI-drafted conditions and what underwriters did with them."
      source: loancondition
      filter: "source == 'ai'"
      permissions: [underwriter, manager, admin]
      columns:
        - { field: text,      label: "Condition" }
        - { field: rationale, label: "AI rationale" }
        - { field: status,    label: "Outcome" }
        - { field: note,      label: "Note" }
      defaultLimit: 500

Download seed bundle