{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tokrepo.com/schemas/tokrepo-lock.schema.json",
  "title": "TokRepo Project Lockfile",
  "description": "Project-local lockfile written by tokrepo install so agents can inspect managed assets, file hashes, rollback actions, and install evidence before reinstalling or removing anything.",
  "type": "object",
  "required": ["schemaVersion", "lockfileVersion", "assets"],
  "properties": {
    "schemaVersion": { "type": "integer", "const": 1 },
    "schema_version": { "type": "integer", "const": 1 },
    "lockfileVersion": { "type": "integer", "const": 1 },
    "generatedBy": { "type": "string" },
    "projectRoot": { "type": "string" },
    "updatedAt": { "type": ["string", "null"] },
    "assets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["uuid", "targetTool", "files"],
        "properties": {
          "uuid": { "type": "string" },
          "title": { "type": "string" },
          "sourceUrl": { "type": "string" },
          "targetTool": { "type": "string" },
          "installMode": { "type": "string" },
          "status": { "type": "string" },
          "installedAt": { "type": "string" },
          "contentHash": { "type": "string" },
          "installPlanHash": { "type": "string" },
          "sessionId": { "type": "string" },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["path", "path_type", "sha256"],
              "properties": {
                "path": { "type": "string" },
                "path_type": { "enum": ["project_relative", "home_relative", "absolute"] },
                "sourceName": { "type": "string" },
                "type": { "type": "string" },
                "sha256": { "type": "string" },
                "bytes": { "type": "integer" },
                "riskFlags": {
                  "type": "array",
                  "items": { "type": "string" }
                }
              }
            }
          },
          "rollback": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["type", "path"],
              "properties": {
                "type": { "type": "string" },
                "path": { "type": "string" },
                "path_type": { "type": "string" }
              }
            }
          },
          "verification": { "type": ["object", "null"] },
          "policyDecision": { "type": ["object", "null"] },
          "permissionEnvelope": { "type": ["object", "null"] }
        }
      }
    }
  }
}
