{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hemrock-com/json-schema/hemrock-com-compute-request-schema.json",
  "title": "ComputeRequest",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hemrock-com-openapi.json#/components/schemas/ComputeRequest",
  "type": "object",
  "required": [
    "events"
  ],
  "additionalProperties": false,
  "properties": {
    "events": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/CommonIssuanceEvent"
          },
          {
            "$ref": "#/$defs/OptionPoolEvent"
          },
          {
            "$ref": "#/$defs/SecondarySaleEvent"
          },
          {
            "$ref": "#/$defs/OptionGrantEvent"
          },
          {
            "$ref": "#/$defs/ManualIssuanceEvent"
          },
          {
            "$ref": "#/$defs/ConvertibleRoundEvent"
          },
          {
            "$ref": "#/$defs/WarrantRoundEvent"
          },
          {
            "$ref": "#/$defs/PricedRoundEvent"
          }
        ],
        "description": "One cap-table event, discriminated by `type`. Pass events in chronological order."
      }
    }
  },
  "$defs": {
    "CommonIssuanceEvent": {
      "type": "object",
      "description": "Issue common stock (founders, employees).",
      "required": [
        "type",
        "label",
        "grants"
      ],
      "properties": {
        "type": {
          "const": "common_issuance"
        },
        "label": {
          "type": "string"
        },
        "grants": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "kind",
              "shares"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "kind": {
                "enum": [
                  "founder",
                  "employee"
                ]
              },
              "shares": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "ConvertibleRoundEvent": {
      "type": "object",
      "description": "Issue SAFEs or notes; they convert to preferred at the next priced round.",
      "required": [
        "type",
        "label",
        "convertibles"
      ],
      "properties": {
        "type": {
          "const": "convertible_round"
        },
        "label": {
          "type": "string"
        },
        "convertibles": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "kind",
              "principal"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "kind": {
                "enum": [
                  "safe",
                  "note"
                ]
              },
              "principal": {
                "type": "number"
              },
              "discount": {
                "type": "number",
                "description": "0..1."
              },
              "valuationCap": {
                "type": "number"
              },
              "capType": {
                "enum": [
                  "pre-money",
                  "post-money",
                  "post-money-fixed",
                  "post-money-fixed-after"
                ]
              },
              "mfn": {
                "type": "boolean"
              },
              "dilutionMode": {
                "enum": [
                  "existing-only",
                  "all"
                ],
                "description": "Defaults to \"existing-only\"."
              },
              "investmentDate": {
                "type": "string",
                "description": "ISO date. Notes only."
              },
              "conversionDate": {
                "type": "string",
                "description": "ISO date. Notes only."
              },
              "interestRate": {
                "type": "number",
                "description": "Annual fraction (0.05 = 5%). Notes only."
              },
              "accruedInterest": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "ManualIssuanceEvent": {
      "type": "object",
      "description": "Escape hatch: issue exact shares for custom arrangements.",
      "required": [
        "type",
        "label",
        "issuances"
      ],
      "properties": {
        "type": {
          "const": "manual_issuance"
        },
        "label": {
          "type": "string"
        },
        "issuances": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "kind",
              "class",
              "shares"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "kind": {
                "enum": [
                  "founder",
                  "employee",
                  "investor",
                  "pool"
                ]
              },
              "class": {
                "enum": [
                  "common",
                  "preferred",
                  "option-pool",
                  "warrant"
                ]
              },
              "countMode": {
                "enum": [
                  "shares",
                  "percent"
                ],
                "description": "Defaults to \"shares\"."
              },
              "shares": {
                "type": "number"
              },
              "targetPct": {
                "type": "number",
                "description": "0..1, used when countMode=\"percent\"."
              },
              "pctBasis": {
                "enum": [
                  "fully-diluted",
                  "issued"
                ],
                "description": "Defaults to \"fully-diluted\"."
              },
              "issuePrice": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "OptionGrantEvent": {
      "type": "object",
      "description": "Grant options to people from one pool (fully-diluted-neutral).",
      "required": [
        "type",
        "label",
        "grants"
      ],
      "properties": {
        "type": {
          "const": "option_grant"
        },
        "label": {
          "type": "string"
        },
        "poolId": {
          "type": "string",
          "description": "Pool id to grant from; omit to draw the common pool."
        },
        "grants": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "shares"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "shares": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "OptionPoolEvent": {
      "type": "object",
      "description": "Create or expand an option pool (shares authorized, not granted).",
      "required": [
        "type",
        "label",
        "shares"
      ],
      "properties": {
        "type": {
          "const": "option_pool"
        },
        "label": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "description": "Pool id, so an option_grant can name which pool it draws from."
        },
        "countMode": {
          "enum": [
            "shares",
            "percent"
          ],
          "description": "Defaults to \"shares\"."
        },
        "shares": {
          "type": "number"
        },
        "targetPct": {
          "type": "number",
          "description": "0..1 of post-event fully diluted, used when countMode=\"percent\"."
        },
        "strikePrice": {
          "type": "number"
        }
      }
    },
    "PricedRoundEvent": {
      "type": "object",
      "description": "A priced equity round: new money buys newly issued preferred.",
      "required": [
        "type",
        "label",
        "preMoneyValuation",
        "investments"
      ],
      "properties": {
        "type": {
          "const": "priced_round"
        },
        "label": {
          "type": "string"
        },
        "preMoneyValuation": {
          "type": "number"
        },
        "investments": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "amount"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "antiDilution": {
                "enum": [
                  "weighted-average",
                  "full-ratchet"
                ]
              },
              "antiDilutionMethod": {
                "enum": [
                  "conversion-ratio",
                  "new-shares"
                ],
                "description": "Defaults to \"conversion-ratio\"."
              },
              "proRata": {
                "type": "boolean",
                "description": "If true, amount is back-solved to hold pre-round ownership; match by id."
              }
            }
          }
        },
        "pools": {
          "type": "array",
          "description": "Option pool top-ups for the round (preferred over the legacy targetPoolPct trio).",
          "items": {
            "type": "object",
            "required": [
              "mode"
            ],
            "properties": {
              "mode": {
                "enum": [
                  "pre",
                  "post"
                ],
                "description": "\"pre\" dilutes existing only; \"post\" dilutes new money too."
              },
              "countMode": {
                "enum": [
                  "shares",
                  "percent"
                ],
                "description": "Defaults to \"percent\"."
              },
              "pct": {
                "type": "number",
                "description": "0..1 of post-money fully diluted, when countMode=\"percent\"."
              },
              "shares": {
                "type": "number"
              },
              "label": {
                "type": "string"
              },
              "poolId": {
                "type": "string",
                "description": "Set to track this pool separately (its own cap-table row)."
              }
            }
          }
        },
        "targetPoolPct": {
          "type": "number",
          "description": "Legacy. Prefer pools[]."
        },
        "poolMode": {
          "enum": [
            "pre",
            "post",
            "custom"
          ],
          "description": "Legacy. Prefer pools[]."
        },
        "poolPostPct": {
          "type": "number",
          "description": "Legacy. Prefer pools[]."
        }
      }
    },
    "SecondarySaleEvent": {
      "type": "object",
      "description": "Transfer existing shares from one holder to another.",
      "required": [
        "type",
        "label",
        "fromId",
        "toId",
        "toName",
        "shares"
      ],
      "properties": {
        "type": {
          "const": "secondary_sale"
        },
        "label": {
          "type": "string"
        },
        "fromId": {
          "type": "string"
        },
        "toId": {
          "type": "string"
        },
        "toName": {
          "type": "string"
        },
        "shares": {
          "type": "number"
        },
        "class": {
          "enum": [
            "common",
            "preferred",
            "option-pool",
            "warrant"
          ],
          "description": "Defaults to \"common\"."
        },
        "round": {
          "type": "string",
          "description": "Which series the shares come from (e.g. \"Series A\")."
        }
      }
    },
    "WarrantRoundEvent": {
      "type": "object",
      "description": "Issue warrants (right to buy shares at a set price); counts toward fully diluted now.",
      "required": [
        "type",
        "label",
        "warrants"
      ],
      "properties": {
        "type": {
          "const": "warrant_round"
        },
        "label": {
          "type": "string"
        },
        "warrants": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "purchaseClass",
              "countMode"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "purchaseClass": {
                "enum": [
                  "common",
                  "preferred"
                ]
              },
              "purchaseRound": {
                "type": "string",
                "description": "For a preferred warrant, the series it targets."
              },
              "purchasePrice": {
                "type": "number"
              },
              "priceFromRound": {
                "type": "string",
                "description": "Source round label to price off, when variable."
              },
              "priceDiscount": {
                "type": "number",
                "description": "0..1 discount on the source round price."
              },
              "parValue": {
                "type": "number"
              },
              "countMode": {
                "enum": [
                  "shares",
                  "value"
                ]
              },
              "shares": {
                "type": "number",
                "description": "When countMode=\"shares\"."
              },
              "totalValue": {
                "type": "number",
                "description": "When countMode=\"value\": shares = totalValue / purchasePrice."
              }
            }
          }
        }
      }
    }
  }
}