{
  "feature": "account-opening",
  "version": "1.0.0",
  "description": "Investment account opening workflow with product selection, risk profiling, terms acceptance, funding instructions, and compliance review",
  "category": "workflow",
  "tags": [
    "account-opening",
    "investment",
    "product-selection",
    "risk-profiling",
    "wealth-management",
    "financial-services",
    "kyc"
  ],
  "actors": [
    {
      "id": "client",
      "name": "Client",
      "type": "human",
      "role": "Client",
      "description": "Individual opening an investment account"
    },
    {
      "id": "advisor",
      "name": "Financial Advisor",
      "type": "human",
      "role": "Advisor",
      "description": "Advisor guiding client through account opening"
    },
    {
      "id": "compliance_officer",
      "name": "Compliance Officer",
      "type": "human",
      "role": "Compliance",
      "description": "Reviews and approves account applications"
    },
    {
      "id": "admin",
      "name": "Administrator",
      "type": "human",
      "role": "Admin",
      "description": "System administrator who can override or escalate"
    },
    {
      "id": "system",
      "name": "System",
      "type": "system",
      "role": "System",
      "description": "Automated checks and notifications"
    }
  ],
  "fields": [
    {
      "name": "application_id",
      "type": "text",
      "required": true,
      "validation": [
        {
          "type": "required",
          "message": "Application ID is required"
        }
      ],
      "label": "Application Id"
    },
    {
      "name": "client_id",
      "type": "text",
      "required": true,
      "validation": [
        {
          "type": "required",
          "message": "Client ID is required"
        }
      ],
      "label": "Client Id"
    },
    {
      "name": "account_type",
      "type": "select",
      "required": true,
      "label": "Account Type",
      "options": [
        {
          "value": "individual",
          "label": "Individual Investment Account"
        },
        {
          "value": "joint",
          "label": "Joint Investment Account"
        },
        {
          "value": "trust",
          "label": "Trust Account"
        },
        {
          "value": "corporate",
          "label": "Corporate Investment Account"
        },
        {
          "value": "retirement",
          "label": "Retirement Account"
        }
      ]
    },
    {
      "name": "selected_products",
      "type": "json",
      "required": true,
      "label": "Selected Investment Products"
    },
    {
      "name": "risk_profile",
      "type": "select",
      "required": true,
      "label": "Risk Profile",
      "options": [
        {
          "value": "conservative",
          "label": "Conservative"
        },
        {
          "value": "moderate_conservative",
          "label": "Moderate Conservative"
        },
        {
          "value": "moderate",
          "label": "Moderate"
        },
        {
          "value": "moderate_aggressive",
          "label": "Moderate Aggressive"
        },
        {
          "value": "aggressive",
          "label": "Aggressive"
        }
      ]
    },
    {
      "name": "risk_score",
      "type": "number",
      "required": true,
      "label": "Risk Assessment Score",
      "validation": [
        {
          "type": "min",
          "value": 1,
          "message": "Risk score must be at least 1"
        },
        {
          "type": "max",
          "value": 100,
          "message": "Risk score must not exceed 100"
        }
      ]
    },
    {
      "name": "investment_objective",
      "type": "select",
      "required": true,
      "label": "Investment Objective",
      "options": [
        {
          "value": "capital_preservation",
          "label": "Capital Preservation"
        },
        {
          "value": "income",
          "label": "Income Generation"
        },
        {
          "value": "growth",
          "label": "Capital Growth"
        },
        {
          "value": "aggressive_growth",
          "label": "Aggressive Growth"
        },
        {
          "value": "balanced",
          "label": "Balanced"
        }
      ]
    },
    {
      "name": "investment_horizon",
      "type": "select",
      "required": true,
      "label": "Investment Horizon",
      "options": [
        {
          "value": "short_term",
          "label": "Short Term (0-2 years)"
        },
        {
          "value": "medium_term",
          "label": "Medium Term (3-5 years)"
        },
        {
          "value": "long_term",
          "label": "Long Term (5-10 years)"
        },
        {
          "value": "very_long_term",
          "label": "Very Long Term (10+ years)"
        }
      ]
    },
    {
      "name": "initial_investment_amount",
      "type": "number",
      "required": true,
      "label": "Initial Investment Amount",
      "validation": [
        {
          "type": "required",
          "message": "Initial investment amount is required"
        },
        {
          "type": "min",
          "value": 0,
          "message": "Amount must be positive"
        }
      ]
    },
    {
      "name": "currency",
      "type": "select",
      "required": true,
      "label": "Currency",
      "options": [
        {
          "value": "ZAR",
          "label": "South African Rand"
        },
        {
          "value": "USD",
          "label": "US Dollar"
        },
        {
          "value": "EUR",
          "label": "Euro"
        },
        {
          "value": "GBP",
          "label": "British Pound"
        }
      ]
    },
    {
      "name": "source_of_funds",
      "type": "select",
      "required": true,
      "label": "Source of Funds",
      "options": [
        {
          "value": "salary",
          "label": "Salary / Employment Income"
        },
        {
          "value": "business",
          "label": "Business Income"
        },
        {
          "value": "inheritance",
          "label": "Inheritance"
        },
        {
          "value": "investment_proceeds",
          "label": "Investment Proceeds"
        },
        {
          "value": "retirement_fund",
          "label": "Retirement Fund"
        },
        {
          "value": "other",
          "label": "Other"
        }
      ]
    },
    {
      "name": "source_of_funds_detail",
      "type": "text",
      "required": false,
      "label": "Source of Funds Details"
    },
    {
      "name": "terms_accepted",
      "type": "boolean",
      "required": true,
      "label": "Terms and Conditions Accepted",
      "validation": [
        {
          "type": "required",
          "message": "Terms must be accepted"
        }
      ]
    },
    {
      "name": "terms_accepted_at",
      "type": "datetime",
      "required": false,
      "label": "Terms Accepted At"
    },
    {
      "name": "mandate_document_id",
      "type": "text",
      "required": false,
      "label": "Signed Mandate Document"
    },
    {
      "name": "funding_method",
      "type": "select",
      "required": true,
      "label": "Funding Method",
      "options": [
        {
          "value": "eft",
          "label": "Electronic Fund Transfer"
        },
        {
          "value": "debit_order",
          "label": "Debit Order"
        },
        {
          "value": "transfer_in",
          "label": "Transfer from Existing Account"
        }
      ]
    },
    {
      "name": "funding_reference",
      "type": "text",
      "required": false,
      "label": "Funding Reference Number"
    },
    {
      "name": "status",
      "type": "select",
      "required": true,
      "options": [
        {
          "value": "draft",
          "label": "Draft"
        },
        {
          "value": "product_selection",
          "label": "Product Selection"
        },
        {
          "value": "risk_assessment",
          "label": "Risk Assessment"
        },
        {
          "value": "terms_review",
          "label": "Terms Review"
        },
        {
          "value": "funding",
          "label": "Funding"
        },
        {
          "value": "submitted",
          "label": "Submitted"
        },
        {
          "value": "compliance_review",
          "label": "Compliance Review"
        },
        {
          "value": "approved",
          "label": "Approved"
        },
        {
          "value": "account_created",
          "label": "Account Created"
        },
        {
          "value": "rejected",
          "label": "Rejected"
        },
        {
          "value": "cancelled",
          "label": "Cancelled"
        }
      ],
      "label": "Status"
    },
    {
      "name": "compliance_notes",
      "type": "rich_text",
      "required": false,
      "label": "Compliance Review Notes"
    },
    {
      "name": "rejection_reason",
      "type": "text",
      "required": false,
      "label": "Rejection Reason"
    }
  ],
  "rules": {
    "validation": [
      "Client must complete onboarding (KYC) before opening an account",
      "At least one investment product must be selected",
      "Risk profile must be assessed before product selection is confirmed",
      "Products must be suitable for the client's risk profile",
      "Terms and conditions must be accepted before submission",
      "Source of funds declaration is mandatory for compliance"
    ],
    "product_suitability": [
      "Conservative risk profile cannot select aggressive-growth products",
      "Short-term horizon should warn on illiquid products",
      "System validates product-risk alignment and warns on mismatches"
    ],
    "compliance": [
      "All applications require compliance review before account creation",
      "Enhanced due diligence required for initial investments above threshold",
      "Source of funds must be documented for anti-money laundering",
      "Politically exposed persons require additional review"
    ],
    "permissions": [
      "Client can create and manage their own applications",
      "Advisor can create applications on behalf of assigned clients",
      "Compliance officer reviews and approves/rejects applications",
      "Admin can override status and reassign applications"
    ]
  },
  "states": {
    "field": "status",
    "values": [
      {
        "name": "draft",
        "label": "Draft",
        "initial": true
      },
      {
        "name": "product_selection",
        "label": "Product Selection"
      },
      {
        "name": "risk_assessment",
        "label": "Risk Assessment"
      },
      {
        "name": "terms_review",
        "label": "Terms Review"
      },
      {
        "name": "funding",
        "label": "Funding"
      },
      {
        "name": "submitted",
        "label": "Submitted"
      },
      {
        "name": "compliance_review",
        "label": "Compliance Review"
      },
      {
        "name": "approved",
        "label": "Approved"
      },
      {
        "name": "account_created",
        "label": "Account Created",
        "terminal": true
      },
      {
        "name": "rejected",
        "label": "Rejected",
        "terminal": true
      },
      {
        "name": "cancelled",
        "label": "Cancelled",
        "terminal": true
      }
    ],
    "transitions": [
      {
        "from": "draft",
        "to": "product_selection",
        "actor": [
          "client",
          "advisor"
        ],
        "description": "Begin product selection"
      },
      {
        "from": "product_selection",
        "to": "risk_assessment",
        "actor": [
          "client",
          "advisor"
        ],
        "condition": "selected_products is not null",
        "description": "Products selected, proceed to risk assessment"
      },
      {
        "from": "risk_assessment",
        "to": "terms_review",
        "actor": [
          "client",
          "advisor"
        ],
        "condition": "risk_score is not null",
        "description": "Risk assessment complete"
      },
      {
        "from": "terms_review",
        "to": "funding",
        "actor": [
          "client",
          "advisor"
        ],
        "condition": "terms_accepted == true",
        "description": "Terms accepted, proceed to funding"
      },
      {
        "from": "funding",
        "to": "submitted",
        "actor": [
          "client",
          "advisor"
        ],
        "condition": "funding_method is not null",
        "description": "Funding details provided, submit application"
      },
      {
        "from": "submitted",
        "to": "compliance_review",
        "actor": [
          "system",
          "compliance_officer"
        ],
        "description": "Application enters compliance review"
      },
      {
        "from": "compliance_review",
        "to": "approved",
        "actor": [
          "compliance_officer"
        ],
        "description": "Application approved by compliance"
      },
      {
        "from": "compliance_review",
        "to": "rejected",
        "actor": [
          "compliance_officer"
        ],
        "condition": "rejection_reason is not null",
        "description": "Application rejected with reason"
      },
      {
        "from": "approved",
        "to": "account_created",
        "actor": [
          "system"
        ],
        "description": "Account provisioned in CRM and system"
      },
      {
        "from": [
          "draft",
          "product_selection",
          "risk_assessment",
          "terms_review",
          "funding"
        ],
        "to": "cancelled",
        "actor": [
          "client",
          "advisor",
          "admin"
        ],
        "description": "Application cancelled"
      }
    ]
  },
  "outcomes": {
    "start_application": {
      "priority": 1,
      "given": [
        {
          "field": "client_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Client",
            "Advisor",
            "Admin"
          ]
        }
      ],
      "then": [
        {
          "action": "create_record",
          "type": "account_application",
          "target": "applications"
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "draft",
          "to": "draft"
        },
        {
          "action": "emit_event",
          "event": "account.application_started",
          "payload": [
            "application_id",
            "client_id",
            "timestamp"
          ]
        }
      ],
      "result": "New account application created in draft status"
    },
    "select_products": {
      "priority": 10,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "selected_products",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "in",
          "value": [
            "draft",
            "product_selection"
          ]
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Client",
            "Advisor"
          ]
        }
      ],
      "then": [
        {
          "action": "set_field",
          "target": "selected_products",
          "value": "from_input"
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "product_selection",
          "to": "risk_assessment"
        },
        {
          "action": "emit_event",
          "event": "account.products_selected",
          "payload": [
            "application_id",
            "selected_products",
            "timestamp"
          ]
        }
      ],
      "result": "Products selected, moved to risk assessment",
      "error": "NO_PRODUCTS_SELECTED"
    },
    "complete_risk_assessment": {
      "priority": 20,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "risk_score",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "risk_profile",
          "source": "computed",
          "operator": "exists"
        },
        {
          "field": "investment_objective",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "investment_horizon",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "eq",
          "value": "risk_assessment"
        }
      ],
      "then": [
        {
          "action": "set_field",
          "target": "risk_score",
          "value": "from_input"
        },
        {
          "action": "set_field",
          "target": "risk_profile",
          "value": "from_computed"
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "risk_assessment",
          "to": "terms_review"
        },
        {
          "action": "emit_event",
          "event": "account.risk_assessed",
          "payload": [
            "application_id",
            "risk_profile",
            "risk_score",
            "timestamp"
          ]
        }
      ],
      "result": "Risk assessment completed",
      "error": "RISK_ASSESSMENT_REQUIRED"
    },
    "product_suitability_warning": {
      "priority": 15,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "risk_profile",
          "source": "computed",
          "operator": "exists"
        },
        {
          "field": "product_risk_mismatch",
          "source": "computed",
          "operator": "eq",
          "value": true
        }
      ],
      "then": [
        {
          "action": "emit_event",
          "event": "account.suitability_warning",
          "payload": [
            "application_id",
            "risk_profile",
            "mismatched_products",
            "timestamp"
          ]
        }
      ],
      "result": "Warning displayed about product-risk profile mismatch",
      "error": "PRODUCT_SUITABILITY_VIOLATION"
    },
    "accept_terms": {
      "priority": 30,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "terms_accepted",
          "source": "input",
          "operator": "eq",
          "value": true
        },
        {
          "field": "status",
          "source": "db",
          "operator": "eq",
          "value": "terms_review"
        }
      ],
      "then": [
        {
          "action": "set_field",
          "target": "terms_accepted",
          "value": true
        },
        {
          "action": "set_field",
          "target": "terms_accepted_at",
          "value": "now"
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "terms_review",
          "to": "funding"
        },
        {
          "action": "emit_event",
          "event": "account.terms_accepted",
          "payload": [
            "application_id",
            "terms_accepted_at",
            "timestamp"
          ]
        }
      ],
      "result": "Terms accepted, moved to funding step",
      "error": "TERMS_NOT_ACCEPTED"
    },
    "provide_funding_details": {
      "priority": 40,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "funding_method",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "initial_investment_amount",
          "source": "input",
          "operator": "gt",
          "value": 0
        },
        {
          "field": "source_of_funds",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "eq",
          "value": "funding"
        }
      ],
      "then": [
        {
          "action": "set_field",
          "target": "funding_method",
          "value": "from_input"
        },
        {
          "action": "set_field",
          "target": "initial_investment_amount",
          "value": "from_input"
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "funding",
          "to": "submitted"
        },
        {
          "action": "emit_event",
          "event": "account.submitted",
          "payload": [
            "application_id",
            "funding_method",
            "amount",
            "timestamp"
          ]
        },
        {
          "action": "notify",
          "channel": "email",
          "target": "compliance_officer",
          "template": "new_application_review"
        }
      ],
      "result": "Application submitted for compliance review"
    },
    "compliance_approve": {
      "priority": 50,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "eq",
          "value": "compliance_review"
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Compliance",
            "Admin"
          ]
        }
      ],
      "then": [
        {
          "action": "transition_state",
          "field": "status",
          "from": "compliance_review",
          "to": "approved"
        },
        {
          "action": "emit_event",
          "event": "account.approved",
          "payload": [
            "application_id",
            "approved_by",
            "timestamp"
          ]
        },
        {
          "action": "notify",
          "channel": [
            "email",
            "in_app"
          ],
          "target": "client",
          "template": "application_approved"
        }
      ],
      "result": "Application approved, account creation initiated"
    },
    "compliance_reject": {
      "priority": 51,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "rejection_reason",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "eq",
          "value": "compliance_review"
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Compliance",
            "Admin"
          ]
        }
      ],
      "then": [
        {
          "action": "set_field",
          "target": "rejection_reason",
          "value": "from_input"
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "compliance_review",
          "to": "rejected"
        },
        {
          "action": "emit_event",
          "event": "account.rejected",
          "payload": [
            "application_id",
            "rejection_reason",
            "rejected_by",
            "timestamp"
          ]
        },
        {
          "action": "notify",
          "channel": [
            "email",
            "in_app"
          ],
          "target": "client",
          "template": "application_rejected"
        }
      ],
      "result": "Application rejected with reason"
    },
    "create_account": {
      "priority": 60,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "eq",
          "value": "approved"
        }
      ],
      "then": [
        {
          "action": "call_service",
          "target": "crm_create_account",
          "service": "crm",
          "method": "create_account",
          "payload": [
            "client_id",
            "account_type",
            "selected_products",
            "currency"
          ]
        },
        {
          "action": "transition_state",
          "field": "status",
          "from": "approved",
          "to": "account_created"
        },
        {
          "action": "emit_event",
          "event": "account.created",
          "payload": [
            "application_id",
            "account_number",
            "client_id",
            "timestamp"
          ]
        },
        {
          "action": "notify",
          "channel": [
            "email",
            "in_app"
          ],
          "target": "client",
          "template": "account_created"
        }
      ],
      "result": "Investment account created in CRM and client notified"
    },
    "cancel_application": {
      "priority": 5,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "status",
          "source": "db",
          "operator": "in",
          "value": [
            "draft",
            "product_selection",
            "risk_assessment",
            "terms_review",
            "funding"
          ]
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Client",
            "Advisor",
            "Admin"
          ]
        }
      ],
      "then": [
        {
          "action": "transition_state",
          "field": "status",
          "from": "current",
          "to": "cancelled"
        },
        {
          "action": "emit_event",
          "event": "account.cancelled",
          "payload": [
            "application_id",
            "cancelled_by",
            "timestamp"
          ]
        }
      ],
      "result": "Application cancelled"
    },
    "get_application_status": {
      "priority": 8,
      "given": [
        {
          "field": "application_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Client",
            "Advisor",
            "Compliance",
            "Admin"
          ]
        }
      ],
      "then": [
        {
          "action": "emit_event",
          "event": "account.status_viewed",
          "payload": [
            "application_id",
            "viewed_by",
            "timestamp"
          ]
        }
      ],
      "result": "Return current application status with progress indicator"
    },
    "get_available_products": {
      "priority": 9,
      "given": [
        {
          "field": "client_id",
          "source": "input",
          "operator": "exists"
        },
        {
          "field": "user.role",
          "source": "session",
          "operator": "in",
          "value": [
            "Client",
            "Advisor"
          ]
        }
      ],
      "then": [
        {
          "action": "emit_event",
          "event": "products.listed",
          "payload": [
            "client_id",
            "timestamp"
          ]
        }
      ],
      "result": "Return available investment products with descriptions, fees, and minimum investments"
    }
  },
  "errors": [
    {
      "code": "APPLICATION_NOT_FOUND",
      "status": 404,
      "message": "Account application not found",
      "retry": false
    },
    {
      "code": "ONBOARDING_INCOMPLETE",
      "status": 400,
      "message": "Client onboarding must be completed before opening an account",
      "retry": false
    },
    {
      "code": "NO_PRODUCTS_SELECTED",
      "status": 400,
      "message": "At least one investment product must be selected",
      "retry": false
    },
    {
      "code": "RISK_ASSESSMENT_REQUIRED",
      "status": 400,
      "message": "Risk assessment must be completed before proceeding",
      "retry": false
    },
    {
      "code": "TERMS_NOT_ACCEPTED",
      "status": 400,
      "message": "Terms and conditions must be accepted",
      "retry": false
    },
    {
      "code": "INVALID_STATUS_TRANSITION",
      "status": 400,
      "message": "This action is not allowed in the current application status",
      "retry": false
    },
    {
      "code": "PRODUCT_SUITABILITY_VIOLATION",
      "status": 400,
      "message": "Selected products do not match the client risk profile",
      "retry": false
    },
    {
      "code": "INSUFFICIENT_MINIMUM_INVESTMENT",
      "status": 400,
      "message": "Initial investment amount is below the minimum required",
      "retry": false
    },
    {
      "code": "COMPLIANCE_REVIEW_REQUIRED",
      "status": 400,
      "message": "Application requires compliance review before account creation",
      "retry": false
    },
    {
      "code": "CRM_ACCOUNT_CREATION_FAILED",
      "status": 500,
      "message": "Account creation in CRM failed. Please try again or contact support",
      "retry": true
    }
  ],
  "events": [
    {
      "name": "account.application_started",
      "description": "New account application created",
      "payload": [
        "application_id",
        "client_id",
        "timestamp"
      ]
    },
    {
      "name": "account.products_selected",
      "description": "Investment products selected",
      "payload": [
        "application_id",
        "selected_products",
        "timestamp"
      ]
    },
    {
      "name": "account.risk_assessed",
      "description": "Risk assessment completed",
      "payload": [
        "application_id",
        "risk_profile",
        "risk_score",
        "timestamp"
      ]
    },
    {
      "name": "account.suitability_warning",
      "description": "Product-risk suitability mismatch detected",
      "payload": [
        "application_id",
        "risk_profile",
        "mismatched_products",
        "timestamp"
      ]
    },
    {
      "name": "account.terms_accepted",
      "description": "Terms and conditions accepted",
      "payload": [
        "application_id",
        "terms_accepted_at",
        "timestamp"
      ]
    },
    {
      "name": "account.submitted",
      "description": "Application submitted for review",
      "payload": [
        "application_id",
        "funding_method",
        "amount",
        "timestamp"
      ]
    },
    {
      "name": "account.approved",
      "description": "Application approved by compliance",
      "payload": [
        "application_id",
        "approved_by",
        "timestamp"
      ]
    },
    {
      "name": "account.rejected",
      "description": "Application rejected by compliance",
      "payload": [
        "application_id",
        "rejection_reason",
        "rejected_by",
        "timestamp"
      ]
    },
    {
      "name": "account.created",
      "description": "Investment account created in CRM",
      "payload": [
        "application_id",
        "account_number",
        "client_id",
        "timestamp"
      ]
    },
    {
      "name": "account.cancelled",
      "description": "Application cancelled",
      "payload": [
        "application_id",
        "cancelled_by",
        "timestamp"
      ]
    },
    {
      "name": "account.status_viewed",
      "description": "Application status viewed",
      "payload": [
        "application_id",
        "viewed_by",
        "timestamp"
      ]
    },
    {
      "name": "products.listed",
      "description": "Available products listed for client",
      "payload": [
        "client_id",
        "timestamp"
      ]
    }
  ],
  "related": [
    {
      "feature": "client-onboarding",
      "type": "required",
      "reason": "KYC onboarding must be completed before account can be opened"
    },
    {
      "feature": "product-configurator",
      "type": "required",
      "reason": "Products must exist in the catalog for selection during account opening"
    },
    {
      "feature": "wizard-stepper",
      "type": "recommended",
      "reason": "Multi-step account opening flow benefits from step-by-step wizard UI"
    },
    {
      "feature": "document-management",
      "type": "recommended",
      "reason": "Mandate documents and compliance paperwork need document storage"
    },
    {
      "feature": "approval-chain",
      "type": "recommended",
      "reason": "Compliance review follows an approval workflow pattern"
    },
    {
      "feature": "email-notifications",
      "type": "recommended",
      "reason": "Status change notifications sent via email"
    },
    {
      "feature": "in-app-notifications",
      "type": "recommended",
      "reason": "Real-time status updates shown in notification center"
    },
    {
      "feature": "dataverse-client",
      "type": "required",
      "reason": "Account creation and product data synced with CRM"
    },
    {
      "feature": "audit-trail",
      "type": "recommended",
      "reason": "All application changes must be tracked for regulatory compliance"
    }
  ],
  "sla": {
    "name": "compliance_review",
    "description": "Compliance must review applications within 2 business days",
    "max_duration": "48h",
    "escalation": [
      {
        "after": "24h",
        "action": "notify_compliance_manager"
      },
      {
        "after": "48h",
        "action": "auto_escalate_to_admin"
      }
    ]
  },
  "agi": {
    "goals": [
      {
        "id": "reliable_account_opening",
        "description": "Investment account opening workflow with product selection, risk profiling, terms acceptance, funding instructions, and compliance review",
        "success_metrics": [
          {
            "metric": "processing_time",
            "target": "< 5s",
            "measurement": "Time from request to completion"
          },
          {
            "metric": "success_rate",
            "target": ">= 99%",
            "measurement": "Successful operations divided by total attempts"
          }
        ],
        "constraints": [
          {
            "type": "performance",
            "description": "Must not block dependent workflows",
            "negotiable": true
          }
        ]
      }
    ],
    "autonomy": {
      "level": "semi_autonomous",
      "human_checkpoints": [
        "before transitioning to a terminal state"
      ],
      "escalation_triggers": [
        "error_rate > 5"
      ]
    },
    "safety": {
      "action_permissions": [
        {
          "action": "start_application",
          "permission": "autonomous"
        },
        {
          "action": "select_products",
          "permission": "autonomous"
        },
        {
          "action": "complete_risk_assessment",
          "permission": "autonomous"
        },
        {
          "action": "product_suitability_warning",
          "permission": "autonomous"
        },
        {
          "action": "accept_terms",
          "permission": "autonomous"
        },
        {
          "action": "provide_funding_details",
          "permission": "autonomous"
        },
        {
          "action": "compliance_approve",
          "permission": "supervised"
        },
        {
          "action": "compliance_reject",
          "permission": "supervised"
        },
        {
          "action": "create_account",
          "permission": "supervised"
        },
        {
          "action": "cancel_application",
          "permission": "supervised"
        },
        {
          "action": "get_application_status",
          "permission": "autonomous"
        },
        {
          "action": "get_available_products",
          "permission": "autonomous"
        }
      ]
    },
    "tradeoffs": [
      {
        "prefer": "reliability",
        "over": "speed",
        "reason": "workflow steps must complete correctly before proceeding"
      }
    ],
    "coordination": {
      "protocol": "orchestrated",
      "consumes": [
        {
          "capability": "client_onboarding",
          "from": "client-onboarding",
          "fallback": "degrade"
        },
        {
          "capability": "product_configurator",
          "from": "product-configurator",
          "fallback": "degrade"
        },
        {
          "capability": "dataverse_client",
          "from": "dataverse-client",
          "fallback": "degrade"
        }
      ]
    }
  },
  "ui_hints": {
    "form_layout": "wizard",
    "progress_tracking": true,
    "steps": [
      {
        "label": "Account Type",
        "icon": "user-check"
      },
      {
        "label": "Select Products",
        "icon": "package"
      },
      {
        "label": "Risk Assessment",
        "icon": "shield-check"
      },
      {
        "label": "Terms & Conditions",
        "icon": "file-text"
      },
      {
        "label": "Funding",
        "icon": "banknote"
      },
      {
        "label": "Review & Submit",
        "icon": "check-circle"
      }
    ]
  }
}