{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "version": "2.0.0",
  "$id": "https://schemas.ectropy.ai/pm/schedule-proposal.schema.json",
  "title": "Schedule Proposal Schema",
  "description": "Modifications to the 10-day look-ahead schedule triggered by PM decisions. Tracks proposed changes, approvals, and schedule impacts.",
  "type": "object",
  "required": [
    "$id",
    "$schema",
    "schemaVersion",
    "proposalId",
    "status",
    "sourceDecision",
    "proposedChanges"
  ],
  "definitions": {
    "graphMetadata": {
      "type": "object",
      "description": "Bidirectional graph traversal metadata",
      "properties": {
        "inEdges": {
          "type": "array",
          "items": {
            "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json"
          },
          "uniqueItems": true
        },
        "outEdges": {
          "type": "array",
          "items": {
            "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json"
          },
          "uniqueItems": true
        }
      }
    },
    "proposalStatus": {
      "type": "string",
      "enum": [
        "DRAFT",
        "SUBMITTED",
        "UNDER_REVIEW",
        "APPROVED",
        "REJECTED",
        "IMPLEMENTED",
        "CANCELLED"
      ]
    },
    "changeType": {
      "type": "string",
      "enum": [
        "DELAY",
        "ACCELERATION",
        "RESEQUENCE",
        "RESOURCE_CHANGE",
        "SCOPE_CHANGE",
        "DEPENDENCY_CHANGE"
      ]
    }
  },
  "properties": {
    "$id": {
      "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json",
      "description": "URN identifier. Pattern: urn:luhtech:{project}:schedule-proposal:{proposalId}"
    },
    "$schema": {
      "type": "string",
      "format": "uri",
      "description": "Schema declaration: the URI of the schema this instance follows."
    },
    "schemaVersion": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
    },
    "meta": {
      "type": "object",
      "properties": {
        "projectId": {
          "type": "string"
        },
        "sourceOfTruth": {
          "type": "string"
        },
        "lastUpdated": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "proposalId": {
      "type": "string",
      "pattern": "^PROP-[0-9]{4}-[0-9]{4}$",
      "description": "Human-readable proposal ID (e.g., PROP-2026-0001)"
    },
    "title": {
      "type": "string",
      "maxLength": 200,
      "description": "Brief descriptive title"
    },
    "description": {
      "type": "string",
      "maxLength": 5000,
      "description": "Detailed description of proposed changes"
    },
    "status": {
      "$ref": "#/definitions/proposalStatus",
      "description": "Current proposal status"
    },
    "sourceDecision": {
      "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json",
      "description": "PM decision that triggered this proposal"
    },
    "lookAheadPeriod": {
      "type": "object",
      "description": "The look-ahead period this proposal affects",
      "properties": {
        "startDate": {
          "type": "string",
          "format": "date"
        },
        "endDate": {
          "type": "string",
          "format": "date"
        },
        "weekNumber": {
          "type": "integer"
        }
      }
    },
    "proposedChanges": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "changeType",
          "description"
        ],
        "properties": {
          "changeId": {
            "type": "string"
          },
          "changeType": {
            "$ref": "#/definitions/changeType"
          },
          "description": {
            "type": "string"
          },
          "affectedVoxels": {
            "type": "array",
            "items": {
              "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json"
            }
          },
          "affectedActivities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "currentSchedule": {
            "type": "object",
            "properties": {
              "startDate": {
                "type": "string",
                "format": "date-time"
              },
              "endDate": {
                "type": "string",
                "format": "date-time"
              },
              "duration": {
                "type": "number",
                "description": "Duration in days"
              }
            }
          },
          "proposedSchedule": {
            "type": "object",
            "properties": {
              "startDate": {
                "type": "string",
                "format": "date-time"
              },
              "endDate": {
                "type": "string",
                "format": "date-time"
              },
              "duration": {
                "type": "number",
                "description": "Duration in days"
              }
            }
          },
          "deltadays": {
            "type": "integer",
            "description": "Net schedule impact in days"
          },
          "resourceChanges": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "resourceType": {
                  "type": "string",
                  "enum": [
                    "labor",
                    "equipment",
                    "material"
                  ]
                },
                "currentAllocation": {
                  "type": "string"
                },
                "proposedAllocation": {
                  "type": "string"
                },
                "reason": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "impact": {
      "type": "object",
      "description": "Overall impact assessment",
      "properties": {
        "totalScheduleImpact": {
          "type": "integer",
          "description": "Total days of schedule impact"
        },
        "criticalPathImpact": {
          "type": "boolean"
        },
        "milestoneImpacts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "milestoneRef": {
                "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json"
              },
              "currentDate": {
                "type": "string",
                "format": "date"
              },
              "proposedDate": {
                "type": "string",
                "format": "date"
              },
              "deltadays": {
                "type": "integer"
              }
            }
          }
        },
        "costImpact": {
          "type": "object",
          "properties": {
            "amount": {
              "type": "number"
            },
            "currency": {
              "type": "string",
              "default": "USD"
            },
            "breakdown": {
              "type": "object",
              "properties": {
                "acceleration": {
                  "type": "number"
                },
                "delay": {
                  "type": "number"
                },
                "resources": {
                  "type": "number"
                }
              }
            }
          }
        }
      }
    },
    "requiredAuthorityLevel": {
      "type": "integer",
      "minimum": 0,
      "maximum": 6,
      "description": "Authority level required to approve this proposal"
    },
    "approvalChain": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer"
          },
          "approver": {
            "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "rejected"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "comments": {
            "type": "string"
          }
        }
      }
    },
    "requestedBy": {
      "$ref": "https://schemas.ectropy.ai/_definitions/urn.schema.json",
      "description": "Person who submitted the proposal"
    },
    "timestamps": {
      "type": "object",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "submittedAt": {
          "type": "string",
          "format": "date-time"
        },
        "approvedAt": {
          "type": "string",
          "format": "date-time"
        },
        "implementedAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "graphMetadata": {
      "$ref": "#/definitions/graphMetadata"
    }
  },
  "additionalProperties": false
}
