{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://charlieanna.github.io/autocode/schemas/project-memory-v1.schema.json",
  "title": "Advisory AutoCode project memory version 1",
  "description": "Portable preferences only. No task criteria, approvals, raw output, credentials or absolute/private filesystem paths. Readers also enforce a 65536-byte UTF-8 limit and reject duplicate JSON keys, questions, roles and pause states. Unsafe strings are dropped whole, never redacted into quotations.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "framework",
    "test_command",
    "conventions",
    "routes",
    "human_pause_states"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "const": 1
    },
    "framework": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        {
          "type": "null"
        }
      ]
    },
    "test_command": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        {
          "type": "null"
        }
      ]
    },
    "conventions": {
      "type": "array",
      "maxItems": 32,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "question",
          "answer"
        ],
        "properties": {
          "question": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          },
          "answer": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          }
        }
      }
    },
    "routes": {
      "type": "array",
      "maxItems": 32,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "role",
          "engine",
          "provider",
          "model"
        ],
        "properties": {
          "role": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "engine": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              {
                "type": "null"
              }
            ]
          },
          "provider": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              {
                "type": "null"
              }
            ]
          },
          "model": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              {
                "type": "null"
              }
            ]
          }
        }
      }
    },
    "human_pause_states": {
      "type": "array",
      "maxItems": 32,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 96,
        "pattern": "^(?:WAITING_FOR_USER|AWAITING_GOAL_APPROVAL|PAUSED_[A-Z0-9_]+)$"
      }
    }
  }
}
