Exception Management and Audit Workflow

Exceptions as part of the business process: an explicit lifecycle, roles per transition, maker-checker enforced in code, audit of every attempt, and the case APIs.

  • Advanced
  • About 18 minutes
  • Includes an exercise and a knowledge check

The concept Exceptions are part of the process

Not every transaction will match automatically. Settlement has not arrived, references differ, amounts differ, several candidates exist, account information is missing, or the source record is invalid. Each becomes an explicit exception case with a category, a severity, an owner and a history.

On the left, a photo of a wall of numbered safe deposit boxes, each needing two keys. On the right, the case lifecycle: OPEN to ASSIGNED (assign, analyst or supervisor), to UNDER_INVESTIGATION (start, the assignee only), to PENDING_APPROVAL (submit resolution with reason and evidence), to RESOLVED (approve, a different supervisor), or back to UNDER_INVESTIGATION (reject). A supervisor can cancel an open case created in error. A dashed arrow from OPEN straight to RESOLVED is refused.
Two keys to close a case: explicit transitions, a role for each, and a second person at the end.

Run it Transitions, roles and maker-checker in code

javaExceptionWorkflow.java: only listed moves are allowed

import java.time.Instant;
import java.util.*;

public class ExceptionWorkflow {

    enum State { OPEN, ASSIGNED, UNDER_INVESTIGATION, PENDING_APPROVAL, RESOLVED, CANCELLED }
    enum Role { FINANCE_ANALYST, FINANCE_SUPERVISOR, CUSTOMER_SUPPORT }
    enum Action { ASSIGN, START_INVESTIGATION, SUBMIT_RESOLUTION, APPROVE, REJECT, CANCEL }
    record User(String id, Role role) {}
    record Transition(State from, Action action, State to, Set<Role> allowed) {}

    /** The only moves the workflow allows. Anything not listed is refused. */
    static final List<Transition> TRANSITIONS = List.of(
            new Transition(State.OPEN, Action.ASSIGN, State.ASSIGNED, EnumSet.of(Role.FINANCE_ANALYST, Role.FINANCE_SUPERVISOR)),
            new Transition(State.ASSIGNED, Action.START_INVESTIGATION, State.UNDER_INVESTIGATION, EnumSet.of(Role.FINANCE_ANALYST, Role.FINANCE_SUPERVISOR)),
            new Transition(State.UNDER_INVESTIGATION, Action.SUBMIT_RESOLUTION, State.PENDING_APPROVAL, EnumSet.of(Role.FINANCE_ANALYST, Role.FINANCE_SUPERVISOR)),
            new Transition(State.PENDING_APPROVAL, Action.APPROVE, State.RESOLVED, EnumSet.of(Role.FINANCE_SUPERVISOR)),
            new Transition(State.PENDING_APPROVAL, Action.REJECT, State.UNDER_INVESTIGATION, EnumSet.of(Role.FINANCE_SUPERVISOR)),
            new Transition(State.OPEN, Action.CANCEL, State.CANCELLED, EnumSet.of(Role.FINANCE_SUPERVISOR)));

    static class ExceptionCase {
        final String id;
        State state = State.OPEN;
        String assignee, submittedBy;
        final List<String> audit = new ArrayList<>();
        private Instant clock = Instant.parse("2026-11-19T15:00:00Z");

        ExceptionCase(String id) { this.id = id; }

        void apply(User user, Action action, String detail) {
            String outcome;
            Optional<Transition> t = TRANSITIONS.stream().filter(x -> x.from() == state && x.action() == action).findFirst();
            if (t.isEmpty()) {
                outcome = "DENIED: " + action + " is not allowed from " + state;
            } else if (!t.get().allowed().contains(user.role())) {
                outcome = "DENIED: role " + user.role() + " may not " + action;
            } else if (action == Action.START_INVESTIGATION && !user.id().equals(assignee)) {
                outcome = "DENIED: only the assignee may start the investigation";
            } else if (action == Action.APPROVE && user.id().equals(submittedBy)) {
                outcome = "DENIED: the person who submitted cannot approve (maker-checker)";
            } else {
                State before = state;
                state = t.get().to();
                if (action == Action.ASSIGN) assignee = detail;
                if (action == Action.SUBMIT_RESOLUTION) submittedBy = user.id();
                outcome = before + " -> " + state + (detail == null ? "" : " (" + detail + ")");
            }
            clock = clock.plusSeconds(600);
            audit.add(String.format("%s  %-8s %-19s %s", clock, user.id(), action, outcome));
        }
    }

    public static void main(String[] args) {
        User analyst = new User("user-102", Role.FINANCE_ANALYST);
        User supervisor = new User("user-207", Role.FINANCE_SUPERVISOR);
        User support = new User("user-310", Role.CUSTOMER_SUPPORT);

        ExceptionCase c = new ExceptionCase("EXC-10021");
        c.apply(analyst, Action.APPROVE, null);                         // jump straight to resolved
        c.apply(analyst, Action.ASSIGN, "user-102");
        c.apply(analyst, Action.START_INVESTIGATION, null);
        c.apply(analyst, Action.SUBMIT_RESOLUTION, "settled under BNK-44190, match manually");
        c.apply(analyst, Action.APPROVE, null);                         // maker approves own work
        c.apply(support, Action.APPROVE, null);                         // wrong role
        c.apply(supervisor, Action.APPROVE, null);

        // A supervisor investigates a second case. Approving their own submission must still fail.
        User supervisor2 = new User("user-215", Role.FINANCE_SUPERVISOR);
        ExceptionCase d = new ExceptionCase("EXC-10022");
        d.apply(supervisor, Action.ASSIGN, "user-207");
        d.apply(supervisor, Action.START_INVESTIGATION, null);
        d.apply(supervisor, Action.SUBMIT_RESOLUTION, "duplicate bank line, keep STL-503");
        d.apply(supervisor, Action.APPROVE, null);                      // maker approves own work
        d.apply(supervisor2, Action.APPROVE, null);

        for (ExceptionCase x : List.of(c, d)) {
            System.out.println(x.id + " final state: " + x.state + ". Audit trail, denied attempts included:");
            x.audit.forEach(line -> System.out.println("  " + line));
        }
    }
}

Output

EXC-10021 final state: RESOLVED. Audit trail, denied attempts included:
  2026-11-19T15:10:00Z  user-102 APPROVE             DENIED: APPROVE is not allowed from OPEN
  2026-11-19T15:20:00Z  user-102 ASSIGN              OPEN -> ASSIGNED (user-102)
  2026-11-19T15:30:00Z  user-102 START_INVESTIGATION ASSIGNED -> UNDER_INVESTIGATION
  2026-11-19T15:40:00Z  user-102 SUBMIT_RESOLUTION   UNDER_INVESTIGATION -> PENDING_APPROVAL (settled under BNK-44190, match manually)
  2026-11-19T15:50:00Z  user-102 APPROVE             DENIED: role FINANCE_ANALYST may not APPROVE
  2026-11-19T16:00:00Z  user-310 APPROVE             DENIED: role CUSTOMER_SUPPORT may not APPROVE
  2026-11-19T16:10:00Z  user-207 APPROVE             PENDING_APPROVAL -> RESOLVED
EXC-10022 final state: RESOLVED. Audit trail, denied attempts included:
  2026-11-19T15:10:00Z  user-207 ASSIGN              OPEN -> ASSIGNED (user-207)
  2026-11-19T15:20:00Z  user-207 START_INVESTIGATION ASSIGNED -> UNDER_INVESTIGATION
  2026-11-19T15:30:00Z  user-207 SUBMIT_RESOLUTION   UNDER_INVESTIGATION -> PENDING_APPROVAL (duplicate bank line, keep STL-503)
  2026-11-19T15:40:00Z  user-207 APPROVE             DENIED: the person who submitted cannot approve (maker-checker)
  2026-11-19T15:50:00Z  user-215 APPROVE             PENDING_APPROVAL -> RESOLVED

Real output from Java 17.0.18 running this program (fictional data), November 22, 2026.

Read the audit trail. Jumping from OPEN to RESOLVED was refused. The analyst could investigate but not approve. Customer support could not approve. And in the second case even a supervisor could not approve their own submission: maker-checker is a rule in the backend, not a habit. Every refused attempt is in the trail too, which is what a security review needs.

The real audit trail. EXC-10021: user-102 APPROVE denied, not allowed from OPEN; user-102 assigns, starts and submits; user-102 APPROVE denied, analysts may not approve; user-310 APPROVE denied, customer support may not approve; user-207 approves, RESOLVED. EXC-10022: user-207 submits, then APPROVE denied by maker-checker; user-215 approves, RESOLVED.
Every attempt leaves a trace, including the refused ones.

Know the limits Investigation is not a financial adjustment

Resolving a reconciliation exception and changing a financial record are different capabilities. An analyst may find a valid reason for a mismatch; that does not authorize them to change a loan balance or a settlement record, which belong to other systems (Module 06). The case records the decision and evidence; any change in loan servicing goes through that system’s own approved process.

The endpoints The exception APIs

textOne endpoint per business action

GET    /api/v1/exceptions                       list, filter by status, owner, age
GET    /api/v1/exceptions/{id}                  detail with payment, settlement and evidence
POST   /api/v1/exceptions/{id}/assign           OPEN -> ASSIGNED
POST   /api/v1/exceptions/{id}/start            ASSIGNED -> UNDER_INVESTIGATION
POST   /api/v1/exceptions/{id}/notes            add an investigation note
POST   /api/v1/exceptions/{id}/submit           UNDER_INVESTIGATION -> PENDING_APPROVAL
POST   /api/v1/exceptions/{id}/approve          PENDING_APPROVAL -> RESOLVED (another supervisor)
POST   /api/v1/exceptions/{id}/reject           PENDING_APPROVAL -> UNDER_INVESTIGATION
GET    /api/v1/exceptions/{id}/audit            the case history

There is no generic PATCH status endpoint, and no resolve endpoint that bypasses approval. Each endpoint authenticates the caller, authorizes the action, validates the transition, records the attempt and returns the consistent response format. Audit records are append-only: no business API can edit or delete them, and reading them is itself a permission.

jsonAn audit record

{
  "entityType": "EXCEPTION_CASE",
  "entityId": "EXC-10022",
  "action": "APPROVE",
  "actor": "user-207",
  "outcome": "DENIED",
  "reason": "the person who submitted cannot approve (maker-checker)",
  "fromState": "PENDING_APPROVAL",
  "toState": "PENDING_APPROVAL",
  "timestamp": "2026-11-19T15:40:00Z",
  "correlationId": "CORR-20044"
}

Practice Implement exception management

Practical exercise

Exercise 08: a working exception management API

Build the case workflow with its controls.

  1. The exception entity and its lifecycle.
  2. The assignment, notes, submit, approve and reject APIs.
  3. The approval boundary (maker-checker).
  4. Audit records for every attempt.
  5. Authorization tests for every role and transition.
Show sample authorization tests
  • customerSupportCannotApprove: 403 and an audit entry.
  • submitterCannotApproveOwnResolution: 403 even for a supervisor.
  • openCannotJumpToResolved: 409 invalid transition.
  • onlyAssigneeCanStartInvestigation: another analyst gets 403.

3 questions

Check your understanding

1. Why use explicit state transitions?
2. A supervisor submitted a resolution. Can they approve it?
3. Should refused attempts be audited?
Answer every question to submit.

What you can do now

  • Implement an explicit case lifecycle with roles.
  • Enforce maker-checker in backend code.
  • Design one API per business action.
  • Keep an append-only audit trail, refusals included.