{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "case_id",
    "revision",
    "example",
    "decision",
    "evidence",
    "inputs",
    "debts",
    "no_debt_confirmed",
    "no_debt_source_ids",
    "no_debt_note",
    "actions",
    "review_notes"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "case_id": {
      "type": "string",
      "maxLength": 120
    },
    "revision": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000000000
    },
    "example": {
      "type": "boolean"
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "title",
        "type",
        "entity",
        "owner",
        "reviewer",
        "as_of",
        "period_start",
        "period_end",
        "currency",
        "basis",
        "objective",
        "alternatives",
        "limit",
        "contrary",
        "owner_time"
      ],
      "properties": {
        "title": {
          "type": "string",
          "maxLength": 2000
        },
        "type": {
          "enum": [
            "loan",
            "growth",
            "transition",
            "cash",
            "sale"
          ]
        },
        "entity": {
          "type": "string",
          "maxLength": 2000
        },
        "owner": {
          "type": "string",
          "maxLength": 2000
        },
        "reviewer": {
          "type": "string",
          "maxLength": 2000
        },
        "as_of": {
          "type": "string",
          "pattern": "^(|[0-9]{4}-[0-9]{2}-[0-9]{2})$",
          "description": "Empty or a real ISO calendar date. Application additionally validates calendar, date ordering and source-period cutoff."
        },
        "period_start": {
          "type": "string",
          "pattern": "^(|[0-9]{4}-[0-9]{2}-[0-9]{2})$",
          "description": "Empty or a real ISO calendar date. Application additionally validates calendar, date ordering and source-period cutoff."
        },
        "period_end": {
          "type": "string",
          "pattern": "^(|[0-9]{4}-[0-9]{2}-[0-9]{2})$",
          "description": "Empty or a real ISO calendar date. Application additionally validates calendar, date ordering and source-period cutoff."
        },
        "currency": {
          "enum": [
            "USD",
            "CAD",
            "GBP",
            "EUR",
            "AUD"
          ]
        },
        "basis": {
          "enum": [
            "",
            "cash",
            "accrual",
            "mixed"
          ]
        },
        "objective": {
          "type": "string",
          "maxLength": 2000
        },
        "alternatives": {
          "type": "string",
          "maxLength": 2000
        },
        "limit": {
          "type": "string",
          "maxLength": 2000
        },
        "contrary": {
          "type": "string",
          "maxLength": 2000
        },
        "owner_time": {
          "type": "string",
          "maxLength": 2000
        }
      }
    },
    "evidence": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "locator",
          "as_of",
          "state",
          "notes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 40,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "label": {
            "type": "string",
            "maxLength": 300
          },
          "locator": {
            "type": "string",
            "maxLength": 2000
          },
          "as_of": {
            "type": "string",
            "pattern": "^(|[0-9]{4}-[0-9]{2}-[0-9]{2})$",
            "description": "Empty or a real ISO calendar date. Application additionally validates calendar, date ordering and source-period cutoff."
          },
          "state": {
            "enum": [
              "missing",
              "reported",
              "book",
              "cash",
              "operating",
              "assumed",
              "reviewed",
              "conflicted",
              "superseded"
            ]
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          }
        }
      }
    },
    "inputs": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "cash",
        "restricted",
        "commitments",
        "reserve",
        "upfront",
        "receipts",
        "operating",
        "taxes",
        "newMonthly",
        "receiptDrop",
        "extraOutflow",
        "serviceNumerator",
        "legacyRevenue",
        "legacyMargin",
        "legacyDecline",
        "newUnits",
        "unitRevenue",
        "unitCost",
        "newFixed"
      ],
      "properties": {
        "cash": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Total cash balance — currency. Cash for this entity at the as-of date, including the restricted amount below."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "restricted": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Restricted cash — currency. Part of total cash that cannot fund this decision. Enter 0 only if confirmed."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "commitments": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Other committed cash uses — currency. One-time obligations set aside now. Exclude costs already in the monthly flow, debt schedule or proposed upfront cost."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "reserve": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Protected cash floor — currency. Your chosen reserve, not a Capital Control recommendation. It is a threshold, not another cash payment."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "upfront": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Proposed upfront cost — currency. A separate payment at the start. No borrowing proceeds are assumed."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "receipts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Monthly cash receipts — currency/month. Cash collected, not accounting revenue. A constant monthly run-rate for this illustration."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "operating": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Monthly operating cash payments — currency/month. Exclude taxes, debt service and the new monthly cost entered separately."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "taxes": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Monthly cash taxes — currency/month. Payments not already in operating costs. This tool does not estimate tax liability."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "newMonthly": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "New monthly commitment — currency/month. The proposed incremental cost, starting in month 1."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "receiptDrop": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 100,
              "description": "Downside receipts decline — %. Your hypothetical reduction in collections; costs do not automatically fall."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "extraOutflow": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Downside extra monthly payment — currency/month. An added cash cost in every downside month. No probability is assigned."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "serviceNumerator": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": -1000000000000,
              "maximum": 1000000000000,
              "description": "Next 12 months cash available for debt service — currency/year. Separately supported annual amount after operating needs, taxes and reinvestment, before debt service. Same entity/currency and next 12 months. This is not lender-defined NOI or a covenant DSCR."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "legacyRevenue": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Current monthly legacy revenue — currency/month. Accounting revenue for the legacy activity; not automatically cash receipts."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "legacyMargin": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 100,
              "description": "Legacy gross margin — %. After direct costs, before shared overhead."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "legacyDecline": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 100,
              "description": "Monthly legacy revenue decline — %. Compounds monthly for 12 months; an assumption to test."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "newUnits": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "New activity units per month — units/month. Constant monthly units in this simple bridge."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "unitRevenue": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Revenue per new unit — currency/unit. Expected realized unit price."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "unitCost": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "Direct cost per new unit — currency/unit. Include the direct cost and burden associated with each unit."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        },
        "newFixed": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "value",
            "source_ids",
            "note"
          ],
          "properties": {
            "value": {
              "type": [
                "number",
                "null"
              ],
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "New activity fixed cost per month — currency/month. Dedicated fixed costs. Shared overhead, financing and tax remain outside this contribution bridge."
            },
            "source_ids": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string",
                "maxLength": 40,
                "pattern": "^[A-Za-z0-9_-]+$"
              }
            },
            "note": {
              "type": "string",
              "maxLength": 2000
            }
          }
        }
      }
    },
    "debts": {
      "type": "array",
      "maxItems": 40,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "balance",
          "monthly_payment",
          "maturity",
          "balloon",
          "source_ids",
          "note"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 40,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "label": {
            "type": "string",
            "maxLength": 200
          },
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000000
          },
          "monthly_payment": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000000
          },
          "maturity": {
            "type": "string",
            "pattern": "^(|[0-9]{4}-[0-9]{2}-[0-9]{2})$",
            "description": "Empty or a real ISO calendar date. Application additionally validates calendar, date ordering and source-period cutoff."
          },
          "balloon": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000000
          },
          "source_ids": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "maxLength": 40,
              "pattern": "^[A-Za-z0-9_-]+$"
            }
          },
          "note": {
            "type": "string",
            "maxLength": 2000
          }
        }
      }
    },
    "no_debt_confirmed": {
      "type": "boolean"
    },
    "no_debt_source_ids": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "string",
        "maxLength": 40,
        "pattern": "^[A-Za-z0-9_-]+$"
      }
    },
    "no_debt_note": {
      "type": "string",
      "maxLength": 2000
    },
    "actions": {
      "type": "array",
      "maxItems": 30,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "step",
          "owner",
          "due",
          "trigger",
          "status",
          "approval_reference",
          "outcome"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 40,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "step": {
            "type": "string",
            "maxLength": 2000
          },
          "owner": {
            "type": "string",
            "maxLength": 200
          },
          "due": {
            "type": "string",
            "pattern": "^(|[0-9]{4}-[0-9]{2}-[0-9]{2})$",
            "description": "Empty or a real ISO calendar date. Application additionally validates calendar, date ordering and source-period cutoff."
          },
          "trigger": {
            "type": "string",
            "maxLength": 2000
          },
          "status": {
            "enum": [
              "proposed",
              "in_progress",
              "completed",
              "stopped"
            ]
          },
          "approval_reference": {
            "type": "string",
            "maxLength": 2000
          },
          "outcome": {
            "type": "string",
            "maxLength": 2000
          }
        }
      }
    },
    "review_notes": {
      "type": "string",
      "maxLength": 6000
    },
    "generated": {
      "type": "object",
      "readOnly": true,
      "description": "Optional output snapshot. Ignored and recomputed by the application."
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.capitalcontrol.co/workbench/schema.json",
  "title": "Capital Control Decision Workbench case 1.0",
  "description": "One user-entered case. Whole currency units. Application additionally checks duplicate IDs, real dates, historical period ordering, no-debt consistency and a 1 MB file limit. Source labels and approval references are not authenticated. Generated values are ignored on import."
}
