{
  "process_id": "FA-05",
  "policy_version": "synthetic-v1",
  "event_id": "fa-05-example-v1",
  "input": {
    "entity": "LENDER-1",
    "currency": "USD",
    "cutoff": "2026-10-31T23:59:59Z",
    "window_start": "2026-10-01T00:00:00Z",
    "commission_events": [
      {
        "entity": "LENDER-1",
        "currency": "USD",
        "known_at": "2026-10-31T23:59:59Z",
        "event_id": "E1",
        "loan_id": "L1",
        "plan_version": "P1",
        "event_date": "2026-10-02",
        "kind": "earning",
        "principal_cents": 30000000
      },
      {
        "entity": "LENDER-1",
        "currency": "USD",
        "known_at": "2026-10-31T23:59:59Z",
        "event_id": "E2",
        "loan_id": "L2",
        "plan_version": "P1",
        "event_date": "2026-10-03",
        "kind": "earning",
        "principal_cents": 20000000
      },
      {
        "entity": "LENDER-1",
        "currency": "USD",
        "known_at": "2026-10-31T23:59:59Z",
        "event_id": "R1",
        "loan_id": "L1",
        "plan_version": "P1",
        "event_date": "2026-10-04",
        "kind": "reversal",
        "reversal_of": "E1",
        "reversal_cents": 225000
      }
    ],
    "ap_invoices": [
      {
        "entity": "LENDER-1",
        "currency": "USD",
        "known_at": "2026-10-31T23:59:59Z",
        "invoice_id": "I1",
        "amount_cents": 40000
      }
    ],
    "plan": {
      "version": "P1",
      "known_at": "2026-01-01T00:00:00Z",
      "valid_from": "2026-01-01",
      "valid_to": "2026-12-31",
      "rate_bps": 75,
      "payee_splits_bps": {
        "P-A": 6000,
        "P-B": 4000
      }
    },
    "payroll_control_cents": 150000,
    "gl_expense_control_cents": 190000,
    "manifest": {
      "commission_events": {
        "as_of": "2026-10-31T23:59:59Z",
        "known_at": "2026-10-31T23:59:59Z",
        "expected_records": 3,
        "received_records": 3,
        "complete": true
      },
      "ap_invoices": {
        "as_of": "2026-10-31T23:59:59Z",
        "known_at": "2026-10-31T23:59:59Z",
        "expected_records": 1,
        "received_records": 1,
        "complete": true
      }
    }
  },
  "expected": {
    "status": "ready_for_review",
    "commission_lines": [
      {
        "event_id": "E1",
        "commission_cents": 225000
      },
      {
        "event_id": "E2",
        "commission_cents": 150000
      },
      {
        "event_id": "R1",
        "commission_cents": -225000
      }
    ],
    "net_commission_cents": 150000,
    "payee_support_cents": {
      "P-A": 90000,
      "P-B": 60000
    },
    "ap_cost_cents": 40000,
    "total_supported_cost_cents": 190000,
    "errors": []
  },
  "changes": [
    {
      "name": "Duplicate commission event cannot create a second supported cost",
      "replace_input": {
        "entity": "LENDER-1",
        "currency": "USD",
        "cutoff": "2026-10-31T23:59:59Z",
        "window_start": "2026-10-01T00:00:00Z",
        "commission_events": [
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "E1",
            "loan_id": "L1",
            "plan_version": "P1",
            "event_date": "2026-10-02",
            "kind": "earning",
            "principal_cents": 30000000
          },
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "E2",
            "loan_id": "L2",
            "plan_version": "P1",
            "event_date": "2026-10-03",
            "kind": "earning",
            "principal_cents": 20000000
          },
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "R1",
            "loan_id": "L1",
            "plan_version": "P1",
            "event_date": "2026-10-04",
            "kind": "reversal",
            "reversal_of": "E1",
            "reversal_cents": 225000
          },
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "E1",
            "loan_id": "L1",
            "plan_version": "P1",
            "event_date": "2026-10-02",
            "kind": "earning",
            "principal_cents": 30000000
          }
        ],
        "ap_invoices": [
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "invoice_id": "I1",
            "amount_cents": 40000
          }
        ],
        "plan": {
          "version": "P1",
          "known_at": "2026-01-01T00:00:00Z",
          "valid_from": "2026-01-01",
          "valid_to": "2026-12-31",
          "rate_bps": 75,
          "payee_splits_bps": {
            "P-A": 6000,
            "P-B": 4000
          }
        },
        "payroll_control_cents": 150000,
        "gl_expense_control_cents": 190000,
        "manifest": {
          "commission_events": {
            "as_of": "2026-10-31T23:59:59Z",
            "known_at": "2026-10-31T23:59:59Z",
            "expected_records": 4,
            "received_records": 4,
            "complete": true
          },
          "ap_invoices": {
            "as_of": "2026-10-31T23:59:59Z",
            "known_at": "2026-10-31T23:59:59Z",
            "expected_records": 1,
            "received_records": 1,
            "complete": true
          }
        }
      },
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:event_id:duplicate_identifier"
        ]
      }
    },
    {
      "name": "Reversal cannot exceed original commission",
      "path": [
        "commission_events",
        2,
        "reversal_cents"
      ],
      "value": 225001,
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:reversal:exceeds_original"
        ]
      }
    },
    {
      "name": "A reversal for another loan cannot clear the original",
      "path": [
        "commission_events",
        2,
        "loan_id"
      ],
      "value": "L2",
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:reversal:loan_mismatch"
        ]
      }
    },
    {
      "name": "Unsupported split does not conserve the pool",
      "path": [
        "plan",
        "payee_splits_bps",
        "P-A"
      ],
      "value": 6500,
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:splits:must_sum_to_10000"
        ]
      }
    },
    {
      "name": "Payroll mismatch remains visible",
      "path": [
        "payroll_control_cents"
      ],
      "value": 150001,
      "expected": {
        "status": "hold",
        "commission_lines": [
          {
            "event_id": "E1",
            "commission_cents": 225000
          },
          {
            "event_id": "E2",
            "commission_cents": 150000
          },
          {
            "event_id": "R1",
            "commission_cents": -225000
          }
        ],
        "net_commission_cents": 150000,
        "payee_support_cents": {
          "P-A": 90000,
          "P-B": 60000
        },
        "ap_cost_cents": 40000,
        "total_supported_cost_cents": 190000,
        "errors": [
          "payroll_commission_bridge"
        ]
      }
    },
    {
      "name": "A missing original cannot be invented",
      "path": [
        "commission_events",
        2,
        "reversal_of"
      ],
      "value": "missing",
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:reversal:missing_prior_original"
        ]
      }
    },
    {
      "name": "Same loan and plan cannot earn twice under a new source event ID",
      "replace_input": {
        "entity": "LENDER-1",
        "currency": "USD",
        "cutoff": "2026-10-31T23:59:59Z",
        "window_start": "2026-10-01T00:00:00Z",
        "commission_events": [
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "E1",
            "loan_id": "L1",
            "plan_version": "P1",
            "event_date": "2026-10-02",
            "kind": "earning",
            "principal_cents": 30000000
          },
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "E2",
            "loan_id": "L2",
            "plan_version": "P1",
            "event_date": "2026-10-03",
            "kind": "earning",
            "principal_cents": 20000000
          },
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "R1",
            "loan_id": "L1",
            "plan_version": "P1",
            "event_date": "2026-10-04",
            "kind": "reversal",
            "reversal_of": "E1",
            "reversal_cents": 225000
          },
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "event_id": "DUP-L2",
            "loan_id": "L2",
            "plan_version": "P1",
            "event_date": "2026-10-03",
            "kind": "earning",
            "principal_cents": 20000000
          }
        ],
        "ap_invoices": [
          {
            "entity": "LENDER-1",
            "currency": "USD",
            "known_at": "2026-10-31T23:59:59Z",
            "invoice_id": "I1",
            "amount_cents": 40000
          }
        ],
        "plan": {
          "version": "P1",
          "known_at": "2026-01-01T00:00:00Z",
          "valid_from": "2026-01-01",
          "valid_to": "2026-12-31",
          "rate_bps": 75,
          "payee_splits_bps": {
            "P-A": 6000,
            "P-B": 4000
          }
        },
        "payroll_control_cents": 300000,
        "gl_expense_control_cents": 340000,
        "manifest": {
          "commission_events": {
            "as_of": "2026-10-31T23:59:59Z",
            "known_at": "2026-10-31T23:59:59Z",
            "expected_records": 4,
            "received_records": 4,
            "complete": true
          },
          "ap_invoices": {
            "as_of": "2026-10-31T23:59:59Z",
            "known_at": "2026-10-31T23:59:59Z",
            "expected_records": 1,
            "received_records": 1,
            "complete": true
          }
        }
      },
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:commission:duplicate_earning_economic_key"
        ]
      }
    },
    {
      "name": "Missing source page is an incomplete population",
      "path": [
        "manifest",
        "commission_events",
        "received_records"
      ],
      "value": 0,
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:commission_events:incomplete_population"
        ]
      }
    },
    {
      "name": "Malformed source timestamp holds",
      "path": [
        "manifest",
        "commission_events",
        "known_at"
      ],
      "value": "2026-13-32T00:00:00Z",
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:commission_events.known_at:invalid_utc_timestamp"
        ]
      }
    },
    {
      "name": "Old source as-of cannot satisfy the declared exact cutoff",
      "path": [
        "manifest",
        "commission_events",
        "as_of"
      ],
      "value": "2026-10-01T00:00:00Z",
      "expected": {
        "status": "hold",
        "errors": [
          "invalid_input:commission_events:invalid_source_cutoff"
        ]
      }
    }
  ]
}
