{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://releasefold.local/spec/releasefold-schedule.schema.json",
  "title": "Releasefold schedule export packet",
  "description": "A deterministic Releasefold v1 schedule packet. Amount strings use exactly six decimal places. The SHA-256 digest proves canonical payload integrity, not authorship, legal validity, or on-chain execution.",
  "type": "object",
  "additionalProperties": false,
  "required": ["kind", "version", "schedule", "digestAlgorithm", "digest", "canonicalJson"],
  "properties": {
    "kind": { "const": "releasefold.schedule" },
    "version": { "const": "1.0.0" },
    "digestAlgorithm": { "const": "SHA-256" },
    "digest": { "type": "string", "description": "Lowercase hexadecimal SHA-256 digest of canonicalJson.", "pattern": "^[a-f0-9]{64}$" },
    "canonicalJson": { "type": "string", "minLength": 2 },
    "example": {
      "type": "object",
      "additionalProperties": false,
      "required": ["synthetic", "notice"],
      "properties": {
        "synthetic": { "const": true },
        "notice": { "type": "string", "minLength": 1, "maxLength": 500, "pattern": "^(?!\\s)(?!.*\\s$)[^\\u0000-\\u001F\\u007F]+$" }
      }
    },
    "schedule": { "$ref": "#/$defs/schedule" }
  },
  "$defs": {
    "fixedAmount": {
      "type": "string",
      "description": "A normalized non-negative amount with no more than 30 integer digits and exactly six fractional digits.",
      "pattern": "^(?:0|[1-9][0-9]{0,29})\\.[0-9]{6}$"
    },
    "positiveFixedAmount": {
      "type": "string",
      "description": "A normalized amount greater than zero with exactly six fractional digits.",
      "pattern": "^(?=.{8,37}$)(?!0\\.000000$)(?:0|[1-9][0-9]{0,29})\\.[0-9]{6}$"
    },
    "percent": {
      "type": "string",
      "description": "A normalized percentage from 0.000000 through 100.000000 inclusive.",
      "pattern": "^(?:(?:[0-9]|[1-9][0-9])\\.[0-9]{6}|100\\.000000)$"
    },
    "unitString": {
      "type": "string",
      "pattern": "^(?:0|[1-9][0-9]{0,35})$"
    },
    "positiveUnitString": {
      "type": "string",
      "pattern": "^[1-9][0-9]{0,35}$"
    },
    "calendarDate": {
      "type": "string",
      "description": "A proleptic Gregorian calendar date from 0001-01-01 through 9999-12-31.",
      "format": "date",
      "pattern": "^(?!0000-)[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "input": {
      "type": "object",
      "description": "The start date plus cliffMonths and vestingMonths must remain within the 0001-01-01 through 9999-12-31 calendar range.",
      "additionalProperties": false,
      "required": ["name", "tokenSymbol", "allocation", "startDate", "initialUnlockPercent", "cliffMonths", "vestingMonths", "cadence"],
      "properties": {
        "name": { "type": "string", "minLength": 1, "maxLength": 80, "pattern": "^(?!\\s)(?!.*\\s$)[^\\u0000-\\u001F\\u007F]+$" },
        "tokenSymbol": { "type": "string", "pattern": "^[A-Z0-9._-]{1,16}$" },
        "allocation": { "$ref": "#/$defs/positiveFixedAmount" },
        "startDate": { "$ref": "#/$defs/calendarDate" },
        "initialUnlockPercent": { "$ref": "#/$defs/percent" },
        "cliffMonths": { "type": "integer", "minimum": 0, "maximum": 120 },
        "vestingMonths": { "type": "integer", "minimum": 1, "maximum": 120 },
        "cadence": { "enum": ["monthly", "quarterly"] }
      }
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "kind", "date", "monthOffset", "amount", "amountUnits", "vested", "vestedUnits", "locked", "lockedUnits"],
      "properties": {
        "index": { "type": "integer", "minimum": 1, "maximum": 121 },
        "kind": { "enum": ["initial", "scheduled"] },
        "date": { "$ref": "#/$defs/calendarDate" },
        "monthOffset": { "type": "integer", "minimum": 0, "maximum": 240 },
        "amount": { "$ref": "#/$defs/positiveFixedAmount" },
        "amountUnits": { "$ref": "#/$defs/positiveUnitString" },
        "vested": { "$ref": "#/$defs/positiveFixedAmount" },
        "vestedUnits": { "$ref": "#/$defs/positiveUnitString" },
        "locked": { "$ref": "#/$defs/fixedAmount" },
        "lockedUnits": { "$ref": "#/$defs/unitString" }
      }
    },
    "schedule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "input", "events", "completionDate", "totalUnits"],
      "properties": {
        "version": { "const": "1.0.0" },
        "input": { "$ref": "#/$defs/input" },
        "events": { "type": "array", "minItems": 1, "maxItems": 121, "items": { "$ref": "#/$defs/event" } },
        "completionDate": { "$ref": "#/$defs/calendarDate" },
        "totalUnits": { "$ref": "#/$defs/positiveUnitString" }
      }
    }
  }
}
